Conversation

Topics regarding Scripting with Reality Factory
Post Reply
User avatar
Grok
Posts: 137
Joined: Sat May 27, 2017 9:20 pm

Conversation

Post by Grok »

I am trying to learn the conversation system and I am having some problems. Any help I could get would be appreciated.

I'm not sure if the this is the right forum but at least scripting is part of the process.

Here is a movie of the result I am getting this far, followed by a video edited representation of what I would like to have.

http://pekj.deviantart.com/art/Dialog-testing-691318740

I have read the conversiation.ini chapter in the on-line manual, the corresponding information in the chm help file and the chapter on conversation in the Chinese lecture serial. I have also search the forum for threads.

The scene is filmed by a fixed camera. Both characters in the scene are pawns. The actual player is placed outside camera view. One of the pawns represent the player character (agent Kat). I am using a pawn to be able to use animations that would not be available with the actual player character. The conversation is connected to the other pawn, (the commander).

The conversation is started in the script for the commander type pawn.

Code: Select all


{


Start[()
{


	PlayAnimation("comsit2", true, "");
  Conversation("mission");
  
NewOrder("Animation");

}]


Animation[()
{
	
	PlayAnimation("comsit2", true, "");
    RestartOrder();
	
}]

}
The conversation script looks like this

Code: Select all

{

  mission[ ()
  {
	
	  
      Speak("OfficeStart","");
	  //SoundCustomReplyBackground("conva5.bmp", 10, 300);
      SoundReply(1,"HowHelp","");
      SoundReply(2,"lastMission","");
	  // MenuReply(1,"HowHelp","");
      //MenuReply(2,"lastMission","");
	  //Reply(1,"HowHelp","");
      //Reply(2,"lastMission","");
      switch(Conversation(0))
      {
          case 1
          {
              NewConversation("mission2",true);
          }
          case 2
          {
              NewConversation("mission2",true);
          }
      }
  } ]

  mission2[ ()
  {
	 
      Speak("NextMission","");
	 SoundReply(1,"Laws","");
	  
	 // MenuReply(1,"Laws","");
	  //Reply(1,"Laws","");
      switch(Conversation(0))
      {
          case 1
          {
              NewConversation("mission",false);
          }
      }
  } ]

}

I have tried a couple of different command for the replies that I have left in the code but ”commented out” (//). The different versions of reply basically gives the same result for me.

SoundCustomReplyBackground("conva5.bmp", 10, 300) makes the game freeze when it gets to that line in the script.




The part concerning conversation in the Pawn.ini file looks like this

[It is basically the text that came with the original file.

I have made a new background image (and image for the alpha information) in a size fitting the windowed version I want the game to play in (640x400). I have regrouped the variables to get a better view of what each represents and of course changed a couple of the values.]

Code: Select all


[Conversation]
iconx = 0  
icony = 0

background = conva5.bmp
backgroundalpha = a_conva5.bmp
speachx = 22
speachy = 20
speachwidth = 600 
speachheight = 100 
speachfont = 11
speachwindowx = 10
speachwindowy = 10


replybackground = conva5.bmp
replybackgroundalpha = a_conva5.bmp
replyx = 22
replyy = 10; 
replywidth = 600 
replyheight = 100 
replyfont = 11
replywindowx = 10
replywindowy = 380

replymenufont = 11
replymenubar = menuconv.bmp
replymenubaralpha = a_menuconv.bmp


giffile0 = menu\arrow.gif
;giffile1 = 
;giffile2 = 
;giffile3 = 
;giffile4 = 
;giffile5 = 
;giffile6 = 
;giffile7 = 
;giffile8 = 
gifx = 8
gify = 8 
The result that I am getting is partly what I'm looking for.

The commander speaks his first line. The player gets 2 alternatives to chose from. The player can chose by clicking key 1 or key 2. When the player does that the conversation moves on to the commanders second line and the player is presented 1 option to reply. When the player chose that the conversation ends.

So far so god. That is basically what I want to happen in this try out.

Problems.

1. the animations stop running during the dialog. This is not a major problem, but it would be a lot better if the animations kept running.
2. The mouse pointer disappears. I would like to have the option for the player to chose his reply by point and click.
3. I don't get a background for the reply window. Makes it harder to read the text. This is a major problem.
4. The second set of replies are written on top of the first set of commands. That is, the first set of commands are not cleared before the second one is printed onto the screen. I suspect fixing problem 3 might also fix this problem (or maybe not). This too is a major problem.
5. There are x and y coordinates for a speaker icon, but not a variable for the icon image file. Not a major problem, but slightly confusing.
User avatar
QuestOfDreams
Site Admin
Posts: 1520
Joined: Sun Jul 03, 2005 11:12 pm
Location: Austria
Contact:

Re: Conversation

Post by QuestOfDreams »

1. the animations stop running during the dialog. This is not a major problem, but it would be a lot better if the animations kept running.
This is not possible with RF 0.76.x since the conversation system is running in its own execution loop (only rendering the conversation images like background and text) while the rest of the systems is paused. (One of the reasons the conversation system got a rewrite for 0.78.)
2. The mouse pointer disappears. I would like to have the option for the player to chose his reply by point and click.
You need to use the MenuReply command instead of SoundReply.
3. I don't get a background for the reply window. Makes it harder to read the text. This is a major problem.
Could be because you start the conversation with the Conversation command, for using SoundReply, MenuReply and related commands, the conversation should be started via SoundConversation.
You may have a look at the scripting_conv.s sample script that is used for the second demo level that comes with RF.
4. The second set of replies are written on top of the first set of commands. That is, the first set of commands are not cleared before the second one is printed onto the screen. I suspect fixing problem 3 might also fix this problem (or maybe not). This too is a major problem.
Indeed, this is related to 3 and my answer to 1. The scene might not get cleared & re-rendered and just renders the new text on top of the already rendered scene.
5. There are x and y coordinates for a speaker icon, but not a variable for the icon image file. Not a major problem, but slightly confusing.
This is because the icon position is the same for any conversation; the icon declaration itself is part of the pawn setup in the pawn.ini file.
User avatar
Grok
Posts: 137
Joined: Sat May 27, 2017 9:20 pm

Re: Conversation

Post by Grok »

QuestOfDreams wrote: ---
This is not possible with RF 0.76.x since the conversation system is running in its own execution loop (only rendering the conversation images like background and text) while the rest of the systems is paused. (One of the reasons the conversation system got a rewrite for 0.78.)
---
I'm using 0.76 since it is marked stable. I'm not more adventurous than that :)

QuestOfDreams wrote: ---
You need to use the MenuReply command instead of SoundReply.
---
Could be because you start the conversation with the Conversation command, for using SoundReply, MenuReply and related commands, the conversation should be started via SoundConversation.
You may have a look at the scripting_conv.s sample script that is used for the second demo level that comes with RF.
---
The first set of speak/replies now looks as it should. The second set does not. I don't know why ... yet.
I can now see that the system is a bit different from what I first thought. I will look at the scripting_conv.s
again.

Thank you for your help. It is much appreciated.
User avatar
Grok
Posts: 137
Joined: Sat May 27, 2017 9:20 pm

Re: Conversation

Post by Grok »

OK, I now think I have a working system for using the conversation system. Below a link to a video of testing the system. Also in the video testing using a video as a cut-scene.

https://www.youtube.com/watch?v=7YaRmAGO5ZE

While looking at at the scripting_con.s file I added comments (picking them from other documents) in the script to easier follow what the script was doing. This is the script with the comments, if by chance they could be of use for some one else, as well.


I noticed that the 3:de order will move on to the next order at the same time as the text of the reply is printed to the screen. Which means that the text will not be seen.

ShowOnlyASoundReply[ () //3
{
SoundReply(1, "OnlyAReply", "");
SoundConversation(0);
NewConversation("ShowSoundReply", true);//4
}]

By changing the line "SoundConversation(0);" to "SoundConversation(5);" the text will be seen while it is printed out and disappear at the time it is fully printed out.


Code: Select all

{

	CHARPROSEC [20]


   
	Spawn[()  //1
	{
		RestoreBackground(true);
		Speak("OpeningsText", "");
		SpeakShowTime(3000);
		SoundConversation(CHARPROSEC); // 20
		NewConversation("ShowSpeakAndOneSoundReply", true);//2
	
	/*	
		
	RestoreBackground(bool Flag);
	Defines whether the screen is cleared between a speak and a reply command or not. 
	If Flag is true only the speak window is visible, if Flag is false both speak and 
	the reply window are visible.
	
		
	
	[OpeningsText]
	The text you just saw "walking" was realized using the High level pawn command ShowText.
  Please wait. This window will auto-complete in a few seconds by using the SpeakShowTime
  command.
	
	
	SpeakShowTime(3000) shows Speak-text for 3 seconds. The script than moves on to 
	ShowSpeakAndOneSoundReply  
	
	
	SoundConversation(CHARPROSEC); // 20
	SoundConversation(int CharactersPerSecond);
    SoundConversation(int CharactersPerSecond, bool ShowHud);
CharactersPerSecond is the time in milliseconds that defines the speed by which the speak 
and reply text is displayed. 0 is used to immediately display the full text. If ShowHud is 
present and true, display the HUD during the conversation.
	
	
*/
	
     }]
	
	
	
	
	
	ShowSpeakAndOneSoundReply[()  //2
	{
		Speak("OnlyOneSoundReplyText", "");
		SoundReply(1, "MenuText1", "");
		SoundConversation(CHARPROSEC);
		NewConversation("ShowOnlyASoundReply", true);//3
		
/*	
		[OnlyOneSoundReplyText]
Now we demonstrate the SoundReply command. First a speak-reply-session with only one
reply is shown. Notice that there will be no reply number to select. Use the space bar to
continue.	
		
		[MenuText1]
MenuOption 1
		
		
		Speak is shown until spacebar is pressed. Reply-option is the shown in the speak window. 
		Press space bar to move on.
		
*/		
		
	}]

	
	
	ShowOnlyASoundReply[ () //3
	{
		SoundReply(1, "OnlyAReply", "");
		//SoundConversation(0);
		SoundConversation(5);
		NewConversation("ShowSoundReply", true);//4
		
	
	/*	
		[OnlyAReply]
This text is shown using only a SoundReply command, not a speak command	
		
		
		
		The script moves on to new conversation as soon as the reply-text is shown. 
		No spacebar to be pushed.
		Original script had "SoundConversation(0);" and the text just flashed by so fast it is not seen.
		
	*/	
		
		
	}]

	
	
	
	ShowSoundReply[()//4
	{
		Speak("SoundReplyText", "");
		SoundReply(1, "MenuText1", "");
		SoundReply(2, "MenuText2", "");
		SoundReply(3, "MenuText3", "");
		SoundConversation(CHARPROSEC);
		NewConversation("MenuWithSingleFont", true);//5
	
	/*
		
	[SoundReplyText]
Now let's take a closer look at the SoundReply command. At the top, you can see the speak
window. The reply window is at the bottom. Select a reply option by pressing 1, 2 or 3.
When the selected reply is displayed press the space bar to continue.

[MenuText1]
MenuOption 1

[MenuText2]
MenuOption 2

[MenuText3]
MenuOption 3
		
		
		
    */	
		
		
		
		
		
	}]

	
	
	
	
	MenuWithSingleFont[ ()//5
	{
		Speak("SingleFontText", "");
		MenuReply(1, "MenuText1", "", 11, 11);
		MenuReply(2, "MenuText2", "");
		MenuReply(3, "MenuText3", "");
		SoundConversation(CHARPROSEC);
		NewConversation("MenuWithDifferentFonts", true);//6
		
		
	/*	
		[SingleFontText]
        Here the difference with a MenuReply command. In this example the 
		font color of the selected and the not-selected menu options are 
		choosen identical. Select a reply option by mouse (or number). Next 
		press the space bar to continue.
		
		
		[MenuText1]
        MenuOption 1

        [MenuText2]
         MenuOption 2

        [MenuText3]
         MenuOption 3
		
		
		MenuReply(int Reply#, string ReplyMessage, string ReplySound,
		int MenuFont, int ReplyFont);
		
		MenuFont is the number of the font used to write the menu text on top 
		of the MenuBackground for this MenuOption. 
        ReplyFont is the number of the font used to write the menu text on top 
		of the ReplyMenuBarBitmap and MenuGIF-Picture as soon as the mouse is 
		over this MenuOption. 

		
	*/
		
		
	}]

	
	
	
	MenuWithDifferentFonts[ ()//6
	{
		Speak("DifferentFontsText","");
		// SoundCustomReplyBackground("", 100, 300, 100, 300, 500, 500);    
		MenuReply(1,"MenuText1", "", 11, 10);
		MenuReply(2,"MenuText2", "");
		MenuReply(3,"MenuText3", "");
		SoundConversation(CHARPROSEC);
		NewConversation("MenuWithBitmap", true);//7
		
		
	/*	
		
		[DifferentFontsText]
        Now a MenuReply command with different font colors for the selected and 
		not-selected menu options. Press the space bar to continue.
		
		
		
		[MenuText1]
        MenuOption 1

        [MenuText2]
         MenuOption 2

        [MenuText3]
         MenuOption 3
		
		
		
		
	*/	
		
		
		
		
	}]

	
	
	MenuWithBitmap[()//7
	{
		SoundCustomReplyBackground("menubackground.bmp", 272, 200, 12, 12);      
		Speak("MenuWithBitmapText","");
		MenuReply(1,"MenuText1", "", 11, 10, "menubar.bmp", "a_menubar.bmp");
		MenuReply(2,"MenuText2", "");
		MenuReply(3,"MenuText3", "");
		SoundConversation(CHARPROSEC);
		NewConversation("MenuWithBitmapAndGIF", true);//8
		
		
		/*
		
		SoundCustomSpeakBackground(string BackgroundBitmap, int ImageX, int ImageY, int SpeakX, int SpeakY);

		
		
		[MenuWithBitmapText]
        We can make our menus a bit more fancy using different colors and special 
		shapes. Select a reply option by mouse and press the space bar or left 
		mouse button.
		
		
		MenuReply(int Reply#, string ReplyMessage, string ReplySound, 
		int MenuFont, int ReplyFont, 
		string ReplyMenuBarBitmap, string ReplyMenuBarAlphaBitmap);

		
		ReplyMenuBarBitmap is the name of the image (BMP, JPG, TGA) that will be 
		drawn on top of the MenuBackground as soon as the mouse is over the this 
		MenuOption. 
		
		ReplyMenuBarAlphaBitmap is thename of the alpha map that will be used in 
		for the ReplyMenuBarBitmap. The alpha map is optional and can be defined 
		as an empty string ("") if no alpha is used. 

		
		
		*/
		
		
		
		
	}]

	
	
	MenuWithBitmapAndGIF[()//8
	{
		SoundCustomReplyBackground("menubackground.bmp", 272, 200, 32, 12);      
		Speak("MenuWithBitmapAndGIFText","");
		MenuReply(1,"MenuText1", "", 11, 10, "menubar.bmp", "a_menubar.bmp", 1);
		MenuReply(2,"MenuText2", "", 11, 10, "menubar.bmp", "a_menubar.bmp", 1);
		MenuReply(3,"MenuText3", "", 11, 10, "menubar.bmp", "a_menubar.bmp", 1);
		SoundConversation(CHARPROSEC);
		NewConversation("MenuWithGIFonly", true);//9
		
		
		/*
		[MenuWithBitmapAndGIFText]
        You may also add an animated GIF picture to it. Select a reply option by 
		mouse and press the space bar or left mouse button.
		
		
		*/
		
		
	}]

	
	
	MenuWithGIFonly[()//9
	{
		SoundCustomReplyBackground("menubackground.bmp", 272, 200, 32, 12, 200, 100);
		Speak("MenuWithGIFOnlyText","");
		MenuReply(1,"MenuText1", "", 11, 11, "", "", 1, 8, 8);      
		MenuReply(2,"MenuText2", "", 11, 11, "", "", 1, 8, 8);
		MenuReply(3,"MenuText3", "", 11, 11, "", "", 1, 8, 8);
		SoundConversation(CHARPROSEC);
		NewConversation("AttachText", true);//10
		
		
		/*
		SoundCustomSpeakBackground(string BackgroundBitmap, int ImageX, int ImageY, int SpeakX, int SpeakY, int SpeakWidth, int SpeakHeight);
        
		
		[MenuWithGIFOnlyText]
         If you prefer to use only GIF's, here is the way to do it. Select a reply 
		option by mouse and press the space bar or left mouse button.
		
		
		MenuReply(int Reply#, string ReplyMessage, string ReplySound, 
		int MenuFont, int ReplyFont, 
		string ReplyMenuBarBitmap, string ReplyMenuBarAlphaBitmap, 
		int Gif#, int GifX, int GifY);
		
		Gif# is the number of a pre-defined GIF file to be used for the MenuOption. 
		This number starts at 1 (not 0). The GIF file will be displayed and animate 
		while the Mouse is positioned over the area window belonging to this MenuOption. 
		Each GIF-file needs to be pre-defined in the Pawn.ini file in the [Conversation] 
		section. The definition of a GIF-file to be used for a MenuOption is optional. 
		The GIF file is always displayed on top of the MenuBarBitmap. 
		
		GifX, GifY define the X- and Y-position of the GIF relative to the top left 
		corner of the ReplyMenuBarBitmap. 

				
		*/
		
	}]

	
	
	AttachText[ ()//10
	{
		AttachSpeakToPawn("Nout", -20, -270, 250, 400, 10);
		AttachReplyToPawn("Rob", 0, -150, 250, 400, 10);
		Speak("WalkTextSpeak", "");
		SoundReply(1, "WalkTextReply", "");      
		SoundConversation(CHARPROSEC);
		NewConversation("SpeakOnly", true);//11
		
		/*
		
		AttachSpeakToPawn(string PawnName, int OffsetX, int OffsetY, int TextAreaWidth, 
		int TextAreaHeight, int Font); 
        Attaches the speak window and text to the pawn PawnName. If PawnName is "Player" 
		the speak window is attached to the player. By defining an empty speak background,
		you can attach only the speak text message. If the pawn/player walks around, the 
		text will follow the pawn/player.
  
         AttachReplyToPawn(string PawnName, int OffsetX, int OffsetY, int TextAreaWidth, 
		int TextAreaHeight, int Font); 
		Attaches the reply window and text to the pawn PawnName. If PawnName is "Player" 
		the reply window is attached to the player. By defining an empty reply background,
		you can attach only the reply text message. If the pawn/player walks around, the 
		text will follow the pawn/player.
 

		
		
		
		
		[WalkTextSpeak]
        Yes, we can attach a conversation to a pawn! He, Rob, all OK? 
		Press space to continue.
		
		[WalkTextReply]
		Of course, <Player>, looks great! Press space to continue.
		
		*/
		
	}]

	
	
	SpeakOnly[ ()//11
	{
		Speak("ShowTopMenu","");
		SoundConversation(CHARPROSEC);
		NewConversation("Spawn", false);//end
		
		
		/*
		[ShowTopMenu]
         For the ShowPicture-demo, press space and move the mouse to the top of the game 
		window. Try out all buttons now and at any time later in the demo!
		
		*/
		
	}]
  
}


User avatar
seppgirty
Posts: 161
Joined: Sat May 16, 2015 12:37 am
Location: Pittsburgh, Pa.
Contact:

Re: Conversation

Post by seppgirty »

Did you use the tree builder program for this or did you do the script yourself?
Gamer, Lover, Film maker,

http://www.chaosbrosfilms.com
User avatar
Grok
Posts: 137
Joined: Sat May 27, 2017 9:20 pm

Re: Conversation

Post by Grok »

seppgirty wrote:Did you use the tree builder program for this or did you do the script yourself?

I started out with the tree-builder but in the end I "hand scripted" it.


If it's of any help this is the text of the script. It is not a complete conversation but i covers the general principles,

Code: Select all


{

  mission[ ()
  {
	 RestoreBackground(true);
	  
      Speak("OfficeStart","");
	  MenuReply(1,"HowHelp","");
	  MenuReply(2,"lastMission","");
	 
	   switch(SoundConversation(20))
      {
          case 1
          {
              NewConversation("m2",true);
          }
          case 2
          {
              NewConversation("m3",true);
          }
      }
  } ]

  
  
  m2[ ()
  {
	 CustomIcon("huntress.bmp", 8, 30);
      Speak("HowHelp2","");
	  SpeakShowTime(6000);
	  SoundConversation(0);
	NewConversation("m4",true);
         
  } ]
  
  
  m3[ ()
  {
	 CustomIcon("huntress.bmp", 8, 30);
      Speak("lastMission2","");
	  SpeakShowTime(6000);
	  SoundConversation(0);
	NewConversation("m2",true);
         
  } ]
  
  
   m4[ ()
  {
	 
      Speak("NextMission","");
	  SpeakShowTime(6000);
	  SoundConversation(0);
	NewConversation("m5",true);
         
  } ]
  
  
   m5[ ()
  {
	 CustomIcon("huntress.bmp", 8, 30);
      Speak("Laws","");
	  SpeakShowTime(6000);
	  SoundConversation(0);
	NewConversation("m6",true);
         
  } ]
  
  
  
  m6[ ()
  {
	 
	  
      Speak("next2","");
	  MenuReply(1,"laws2","");
	  MenuReply(2,"laws3","");
	  MenuReply(3,"laws4","");
	  MenuReply(4,"laws5","");
	 
	   switch(SoundConversation(20))
      {
          case 1
          {
              NewConversation("m7a",true);
          }
          case 2
          {
              NewConversation("m3",true);
          }
		   case 3
          {
              NewConversation("m3",true);
          }
		  case 4
          {
              NewConversation("m3",true);
          }
      }
	  
	 } ]
	 
	 
		  m7a[ ()
  {
	 CustomIcon("huntress.bmp", 8, 30);
      Speak("laws2","");
	  SpeakShowTime(6000);
	  SoundConversation(0);
	NewConversation("m7",true);
         
  } ]  
	 
	 
	 
	  
	  m7[ ()
  {
	 
      Speak("theLaws1","");
	  SpeakShowTime(6000);
	  SoundConversation(0);
	NewConversation("m8",true);
         
  } ] 
  
  
  
     m8[ ()
  {
	 
      Speak("theLaws2","");
	  SpeakShowTime(6000);
	  SoundConversation(0);
	NewConversation("m9",true);
         
  } ] 
  
  
       m9[ ()
  {
	 
      Speak("theLaws3","");
	  SpeakShowTime(6000);
	  SoundConversation(0);
	NewConversation("m10",true);
         
  } ] 
	  
	  
 

}


User avatar
seppgirty
Posts: 161
Joined: Sat May 16, 2015 12:37 am
Location: Pittsburgh, Pa.
Contact:

Re: Conversation

Post by seppgirty »

I started out with the tree-builder but in the end I "hand scripted" it.
Why did you end up hand scripting it. Did tree builder not work?
Gamer, Lover, Film maker,

http://www.chaosbrosfilms.com
User avatar
QuestOfDreams
Site Admin
Posts: 1520
Joined: Sun Jul 03, 2005 11:12 pm
Location: Austria
Contact:

Re: Conversation

Post by QuestOfDreams »

Treebuilder does not support the SoundConversation + SoundReply/MenuReply commands.
User avatar
Grok
Posts: 137
Joined: Sat May 27, 2017 9:20 pm

Re: Conversation

Post by Grok »

seppgirty wrote: Why did you end up hand scripting it. Did tree builder not work?
QuestOfDreams wrote: Treebuilder does not support the SoundConversation + SoundReply/MenuReply commands.
And also, I'm perfectly comfortable with writing the script by hand. I probably do that faster than using an editor.
Post Reply