Wintermute Engine Forum

Wintermute Engine => Scripts, plugins, utilities, goodies => Topic started by: metamorphium on August 04, 2008, 11:25:20 AM

Title: Gits like talk window
Post by: metamorphium on August 04, 2008, 11:25:20 AM
I was many times already asked how I did in Ghost in the Sheet the talk window. So I've decided to share the code. Basically it works like this. I have a couple of images with special characters (Larisa, Scott etc.) named approprietly.

when my Talk method is called, it takes 3 parameters: srcString (line to speak), srcActor (which is used to select propper image for the speaking character and xPosition which sets the
start of the talk text block (some images are at the beginning of the window, some at the end).

As most of the lines are spoken by Ghost, the defaults are set to the window so you can call it like

Ghost.Talk("blabla");

if you need reply from Larisa, it would be:

Ghost.Talk("blablabla", "larisa", 500);


Code: WME Script
  1. method Talk(srcString,srcActor,xPosition)
  2. {
  3.  
  4.         var twin;
  5.         if (srcActor == null) twin = "talk"; // basic window with ghost
  6.         else
  7.         twin = srcActor; // NPC window
  8.        
  9.         var tmpState = Game.Interactive;
  10.         Game.Interactive = false// we save the interactivity state for later and turn it off
  11.  
  12.         var dlgWin = Game.LoadWindow("windows\dlgWindow.window"); // load the dialogue window
  13.         var  talkRobotEnt = Scene.CreateEntity()// create the entity used for talking
  14.         var tString = Game.ExpandString(srcString)// prepare the localized string to handle formatting
  15.         var tLength = tString.Length;
  16.         var lines = ToInt(tLength / 300) + 1; // find out how many lines will we need
  17.                
  18.         dlgWin.SetImage("windows/"+twin+".png");   // set the image
  19.         dlgWin.Y = 425
  20.                
  21.         // set the caption parameters
  22.         talkRobotEnt.SubtitlePosRelative = false;
  23.         talkRobotEnt.SubtitlesPosXCenter = false;
  24.         talkRobotEnt.SubtitlesWidth = 680;
  25.         talkRobotEnt.SubtitlesPosX = 90;       
  26.        
  27.         if (xPosition != null) talkRobotEnt.SubtitlesPosX = xPosition;
  28.        
  29.                        
  30.         talkRobotEnt.SubtitlesPosY = 630 + 15* lines;  // position the caption in the window based on number of lines
  31.  
  32.        
  33.         talkRobotEnt.SetFont("fonts\verdana.font"); // set the speech font
  34.  
  35.         talkRobotEnt.SoundPanning = false// make the sound centered
  36.         talkRobotEnt.Talk(srcString, null, "", "", 0)// say the line
  37.        
  38.         Game.UnloadObject(dlgWin)// dispose of the window
  39.         Scene.DeleteEntity(talkRobotEnt); // kill the talk entity
  40.        
  41.         Game.Interactive = tmpState;   
  42.  
  43. }
  44.  


Nowadays I'd make it a bit differently, but you get the idea...
Title: Re: Gits like talk window
Post by: Drake on August 04, 2008, 12:01:22 PM
Hey this is great! You rock! ::rock
Thank you very much!

PS: First post on the board! ;D
Title: Re: Gits like talk window
Post by: Jyujinkai on August 05, 2008, 03:29:49 AM
please post an image or 2?
Title: Re: Gits like talk window
Post by: Jyujinkai on August 11, 2008, 04:37:51 AM
can we please get a screenshot or somthing.. so we canunderstand why this "talk" window is cool?
Title: Re: Gits like talk window
Post by: metamorphium on August 11, 2008, 06:59:32 AM
uhm, I thought the people asking for that code actually saw gits in action. :P

http://www.ghostinthesheet.com/dialog.jpg
Title: Re: Gits like talk window
Post by: Jyujinkai on August 11, 2008, 03:43:04 PM
Thanks Meta

uhm, I thought the people asking for that code actually saw gits in action. :P

true.. but random people in community hunting for code snipits in the "Scripts, plugins, utilities, goodies" area of forum... may not have played GITS but still be interested in chat ideas.
Title: Re: Gits like talk window
Post by: Chris on October 21, 2009, 07:17:20 PM
 can't use with animation charecter . plese help me

how do use "method Talk" with animation charecter ???