How do I make choices in a dialogue box and use them for different NPCs?

From OHRRPGCE-Wiki
Jump to navigation Jump to search

In this article we're going to see how to make choice in dialogues and make it change accordingly to the NPC displaying it, so that yo can save string, plotscripts, and tag and use only the amount you really need. If you have never done this, it is recommanded you learn How do I make choices in a dialog box for a single NPC (the link is in the see also section) So let's go!


Using, text box, string and plotscripting[edit]

That's based on the method described in the first section (the one implying text box and choices)... but adapted to be displays accordingly different NPCS.

First open the text file your created to serve as memo for string use. If not, create one. Pick up a free string. In our example it will be string 8.

Now go under custom. Check you has a tag for yes/on question. If not create one. In this example it will be tag 13 Edit the text box. Pick up a free one (let's say text box 17) Edit choices. Make choices enable. Write yes and no. If the player chooses yes, the tag is turned on and if the player choose no you turn the tag off. Now edit the text. We're using the edit string property of the text box. Write:

  ${s8}

Pick up other text boxes for the dialogues

text box 24 write

   thank you! Here is the key

text box 25 write

   Please don't lie about something so important

text box 28

   Are you sure? Narration: You check and find medical herb. You gave it to NPC NAME

text box 29 write

   I see.. good luck! 

Check also that there is a item called key (for the storage room) and a item medical herb. Pick up a tag and name it medical herb. Make a treasure chest that contain the medical herb for testing.

Go back to the main menu and save up the whole thing.


#------------------------------------------------------------------------------------------------- 

Golbal variable (9, npcchosen)
Global variable (12, yesno content)		

#------------------------------------------------------------------------------------------------- 
# NPC4 is save point
plotscript, Npc4 script, begin

yesno content:=0 #basic behaviour save point
npcchosen:=4 # adapt dialogues
$8= "Would you like to save?"
wait (1) #give a second for string to catch value

switch (npcchosen) do, begin
case (4) do, begin
show text box (17)# show text box with correct dialogue
wait for text box

end #end for the case
end #end for the switch

end# end of the script
#-------------------------------------------------------------------------------------------------
# townpople asking for help
plotscript, Npc5 script, begin

yesno content:=1 #basic behaviour save point
npcchosen:=5 # adapt dialogues
$8= "Have you found the medicine?
wait (1) #give a second for string to catch value

switch (npcchosen) do, begin
case (5) do, begin
show text box (17) # show text box with correct dialogue
wait for text box

end #end for the case
end #end for the switch

end# end of the script

#-------------------------------------------------------------------------------------------------
plotscript, yesno question script, begin

if (check tag (tag:yesno question)==on) then, begin

switch (yesno content) do, begin

case (0) do, begin
suspend player
suspend NPCs
use shop (4) #shop 4 is save point
resume player 
resume npcs
end # end for the case

case (1) do, begin #you bring the medicine for (npc name) of (name place)

if (check tag (tag: medical herb)==on) then, begin #check if we don't lie and if the item is in stock
suspend player
suspend NPCs
show text box (24) # thank you! Here is the key
wait for text box
delete item (17, 1) #give medical herb
get item (24, 1) #item 24 store room key. get only one copy
resume player 
resume npcs
end, else, begin 

suspend player
suspend NPCs
#menu 1 is closed through bitset; fake text box disappear
show text box (25) # Please don't lie about something this important
wait for text box
resume player 
resume npcs
end# end for the if check tag check medical herb
end # end for the case #1

end #end for the switch
end, else, begin #if tag is off then...

switch (yesno content) do, begin

case (0) do, begin # case 0 close after saving
suspend player
suspend NPCs

wait for text box # nothing special really
resume player 
resume npcs
end #end for the case

case (1) do, begin  #you bring the medicine for (npc name) of (name place)

if (check tag (tag: medical herb)==off) then, begin 
suspend player
suspend NPCs
#menu 1 is closed through bitset; fake text box disappear
show text box (29) # I see.. good luck! 
wait for text box
resume player 
resume npcs
end, else, begin #check if the player didn't noticed/ forgot he/she have the medical herb if fact TAG is ON but we chose "no" T_T

suspend player
suspend NPCs
#menu 1 is closed through bitset; fake text box disappear
show text box (28) # Are you sure? Narration: You check and find medical herb. You gave it to (ill npc relative)
wait for text box
show text box (24)  #Thank you! Here is key item 24 store room key. get only one copy
wait for text box
delete item (17, 1) #give medical herb
get item (24, 1) #item 24 store room key. get only one copy

resume player 
resume npcs
end# end for the if check tag check medical herb
end #end for the case


end #end for the switch
end #end for the if check tag yesno question

end# end of the script 

#------------------------------------------------------------------------------------------------- 

Now go back under custom. Edit the text box menu. Pick up again text box 17

Edit the conditonnals Go down to the last menu and use the left arrow until you see

 AFTER: always do the following
 run script yesno question script next


Now go back to the map menu. Give "Npc4 script" to... Npc4 and "Npc5 script" to Npc5 Finally, you can save the changes and exit custom.exe. Edit the .hsi file, and import the. hss Save your game. Test it! If you have troubles implementing this, feel free to ask questions on the forum.

Using a menu, a fake text box and a string[edit]

Let's take back the example below. To remind you, we have NPC 4 which is a save point and npc 5 which ask if have found medical herb to cure a member of his/her family. As a reward, npc 5 give you a key to enter a room where the personn you need to meet is. You'll have something like this.

#------------------------------------------------------------------------------------------------- 
Global variable (12, box)
Global variable (12, yesno content)		

#------------------------------------------------------------------------------------------------- 
# NPC4 is save point
plotscript, Npc4 script, begin


yesno content:=0 #basic behaviour save point
$3= "Would you like to save?"
show string at (3, 10, 10)
#slice is rect (box)	
box:= create rect (320, 35, 0) #witdh, height style style number from 0 to 14,
#set slice x (box, 10)
#set slice y (box, 10)
set rect trans (box, false) # change false to true if you're plain text boxes
open menu (4) # open yes no menu
wait (1)	 
end #end for the tag


end# end of the script
#-------------------------------------------------------------------------------------------------
# townpople asking for help
plotscript, Npc5 script, begin

yesno content:=1 #case 1 helping (npc name) of (name place) to get medicine
$3= "Have you found the medicine?"
show string at (3, 10, 10)
#slice is rect (box)	
box:= create rect (320, 35, 0) #witdh, height style style number from 0 to 14,
#set slice x (box, 10)
#set slice y (box, 10)
set rect trans (box, false)
open menu (4) # open yes no menu
wait (1)	 
end #end for the tag

end# end of the script
#-------------------------------------------------------------------------------------------------
plotscript, choice menu yes script, begin

if (check tag (tag:yesno question)==on) then, begin

switch (yesno content) do, begin

case (0) do, begin #you use the save point
suspend player
suspend NPCs
#menu 1 is closed through bitset; fake text box disappear
free slice (box)  
clear string(3)
wait (3)
use shop (4) #shop 4 is save point
resume player 
resume npcs
end # end for the case

case (1) do, begin #you bring the medicine for (npc name) of (name place)

if (check tag (tag: medical herb)==on) then, begin #check if we don't lie and if the item is in stock
suspend player
suspend NPCs
#menu 1 is closed through bitset; fake text box disappear
free slice (box)  
clear string(3)
wait (3)
show text box (24) # thank you! Here is the key
wait for text box
delete item (17, 1) #give medical herb
get item (24, 1) #item 24 store room key. get only one copy
resume player 
resume npcs
end, else, begin 

suspend player
suspend NPCs
#menu 1 is closed through bitset; fake text box disappear
free slice (box)  
clear string(3)
wait (3)
show text box (25) # Please don't lie about somthing this important
wait for text box
resume player 
resume npcs
end# end for the if check tag check medical herb
end # end for the case #1

end #end for the switch
end #end for the if check tak: yes/no uestion

end# end of the script 

#------------------------------------------------------------------------------------------------- 

plotscript, choice menu no script, begin


if (check tag (tag:yesno question)==off) then, begin

switch (yesno content) do, begin

case (0) do, begin # case 0 close after saving
suspend player
suspend NPCs

#menu 1 is closed through bitset; fake text box disappear
free slice (box)  
clear string(3)
wait (3)
show text box (24)
wait for text box

resume player 
resume npcs
end #end for the case

case (1) do, begin  #you bring the medicine for (npc name) of (name place)

if (check tag (tag: medical herb)==off) then, begin 
suspend player
suspend NPCs
#menu 1 is closed through bitset; fake text box disappear
free slice (box)  
clear string(3)
wait (3)
show text box (29) # I see.. good luck! 
wait for text box
resume player 
resume npcs
end, else, begin #check if the player didn't noticed/ forgot he/she have the medical herb if fact TAG is ON but we choose "no" T_T

suspend player
suspend NPCs
#menu 1 is closed through bitset; fake text box disappear
free slice (box)  
clear string(3)
wait (3)
show text box (28) # Are you sure? Narration: You check and find medical herb. You gave it to (ill npc relative)
wait for text box
show text box (24)  #Thank you! Here is key item 24 store room key. get only one copy
wait for text box
delete item (17, 1) #give medical herb
get item (24, 1) #item 24 store room key. get only one copy

resume player 
resume npcs
end# end for the if check tag check medical herb
end #end for the case


end #end for the switch
end #end for the if check tag yesno question

end# end of the script 

#------------------------------------------------------------------------------------------------- 

You have saved a script and a text box. If your game is 2 hours long and have 15 yes/no situation you can save quite a lot script and text boxes!! This also a good opportunity to learn to use slices to make fake text boxes. If you implement mini games like James, created fake text box and updating you content is very important!

You can customing the fake text box throught slices to make exactly the ones you customized editing the appearance on the text box menu . Free feel to ask about it on the forum if you have trouble implementing it!

To finish remember than hspeak.exe don't like very large script so after the global variable (yesno content) reach value 4 or 5 you have to start spliting you script. Check the article above about it.

See Also[edit]