How do I make several NPCs say something different later?

From OHRRPGCE-Wiki
Jump to navigation Jump to search

To do so you just need one tag, and one global variable!

This method allows you to save a lot of tags . In modern gameplay, when you tend to come back on a town you want many things (especially dialogues) to change.

The purpose of this article is to help you doing and saving tags at the same time. Using the method described above, you only need one tag! All thanks to the global variable ^_^

Ok Let's take again the example used in the article How do I make several npcs says something different later?. So we have quest1 which consists of saving the village from thieves, and quest 2 which is to go and see the king to get money to reconstruct the village.

As often with the OHR the first thing you need is to launch custom.exe and edit text boxes.

We have NPC 4: the merchant

           text box 23 "Hello! I usually sold armors and helms but since the thieves settled I have
           troubles in feeding my family" Hero: Sorry about that!
           text box 24 "I hope that you'll manage to stop them" Here are some things that may help you"
           Narration that you received an basic armor and 2 potions
           text box 25 Thank you so much! I got my goods back! Are you interested in something? (linked
           to a shop)
           text box 26 I hope that you'll manage to convince the king. By the way would you
           be interested by one of these? (conditional Go to the shop (same shop as before))

Let's add NPC 5: the inn keeper


           text box 31 "Hello! I usually offer my service to traveller for the knight 
           but since the thieves settled nobody is coming anymore" Hero: ...
           text box 32 "I hope that you'll manage to stop them" I you can find something to eat, I'll
           let you rest in one of the room usptairs (= setup this npc to start a playscene when you give him a food item)
           text box 33 Thank you so much! Customers have came back. The Inn is full but there's
           always be a room for you (edit the text box and link it to a inn shop)
           text box 34 I hope that you'll manage to convince the king. Good luck!
          (edit the text box and make it follow by a second one which is to a link shop (which is different from box 33))


An finally NPC 6: the village Chief


           text box 35 "Hello! Welcome to our town... That's why I would like to say
           but Thief have taken or village" Hero: ...
           text box 36 "I hope that you'll manage to stop them" Please save my son
           text box 37 Thank you so much! You even managed to save my son! You'll alaways be welcome
           on this village 
           text box 38 Please try to convince the king to help us reconstruct! I'll will ask my brother
           Kaine to go with you. He's is near the fountain of the village

Then go in the tag menu and pick a free. Name it game progress or any other name that'll make you able to remember its purpose. Now save the changes leave custom.exe and edit your .hss file

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

Global variable (10, game progression)

#-------------------------------------------------------------------------------------
# plotscript for the village merchant
plotscript, behaviour npc 4, begin


  suspend npcs 
  suspend player

  switch (game progression) do, begin
  
  case (0) do, begin
  show text box (23)  # dialogue when you first meet the npc
  wait for text box
  end #end for the case
  
  case (1) do, begin
  show text box (24)
  wait for text box
  end
  
  case (2) do, begin
  show text box (25) 
  wait for text box
  end
  
  case (3) do, begin
  show text box (26)
  wait for text box
  end

  
  end# end for the switch

resume npcs
resume player

end #end for the script


#--------------------------------------------------------------------------------------
# plotscript for the inn keeper
plotscript, behaviour npc 5, begin
  
  suspend npcs 
  suspend player

  switch (game progression) do, begin
  
  case (0) do, begin
  show text box (31)  # dialogue when you first meet the npc
  wait for text box
  end #end for the case
  
  case (1) do, begin
  show text box (32)
  wait for text box
  end
  
  case (2) do, begin
  show text box (33) 
  wait for text box
  end
  
  case (3) do, begin
  show text box (34)
  wait for text box
  end

  
  end# end for the switch

resume npcs
resume player

end #end for the script
resume player
end #end for the script
#-------------------------------------------------------------------------------------------------
# plotscript for the Village Chief 
plotscript, behaviour npc 6, begin

  suspend npcs 
  suspend player

  switch (game progression) do, begin
  
  case (0) do, begin
  show text box (35)  # dialogue when you first meet the npc
  wait for text box
  end #end for the case
  
  case (1) do, begin
  show text box (36)
  wait for text box
  end
  
  case (2) do, begin
  show text box (37) 
  wait for text box
  end
  
  case (3) do, begin
  show text box (38)
  wait for text box
  end

  
  end# end for the switch

resume npcs
resume player

end #end for the script

resume npcs
resume player
end #end for the script
#-------------------------------------------------------------------------------------------------

Save your hss file. Go back under custom. Edit the village map. Edit the NPCS. Give each NPC its script. Be sure that you see display text [none] Else the NPC will go on displaying it on top of the one in the script. Save your changes.

Go back to the .hss file and go on with


#------------------------------------------------------------------------------------
# this is village autorun map. Map active when you enter the village map 


plotscript, village autorun map , begin

if (check tag (tag: save quest progress)==on) then, begin
increment (savequestdata, 1)
set tag (tag: save quest progress, off)
end

end #end of the script

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

Now how to trigger all this? You may have guessed it: by simply turning the tag on... in different scripts as the game goes on. The tag will be activated just to change the value of the variable and not to offer choices between text boxes. For example you can add the line :

set tag (tag: save quest progress, on)

- first time in the script when you mention you decide to take on the thief gang (You may have first to a sub quest to gain the villagers' trust)

- second time in the script when you defeated the leader of the thief gang

- third time in the script when you mention you decide to take on the challenge to (You may have first to go through an obstacle (ex the bridge which go to the capital is broken))

- fourth time in the script which include the repairs of the buildings

What is great about ths system is that if the village is near the final boss H.Q, you just have to add

  case (4) do, begin
  
  end

You may then wonder how to check where you are?. This system can be tricky if you mistake text boxes numbers while implementation. For example, One NPC says that you're doing this quest, the other npc says you're doing quest n°2. So what should you do? You should check the value in the global variable "game progression". It's easy you just need a simple text box!

Go under custom.exe.

Pick up a free text box . If you need to edit the village map and note down the name you game to npcs' plotscript.

       text box 55 
       The number inside the variable game progression is ${v10}

Give it to a free npc. Place it on the map. Save the changes. Then launch the game and make him/her display the text box. Note the number. This is where you are. Let's say point n°2. the variable returns 3. Pick up a piece of paper and look up the code. In the npcs plotscript search for:

 switch (game progression)

 ...
 case (3) do, begin

Note on piece paper which NPC has which text boxes. Then go under custom.exe. Now you just have 1) edit the text box and put the right text or 2) find the text box which the text want, note it on your paper sheet and change the number on your hss file. This method may seems complex but you have saved 5 tags ! With the one from the previous section you would have need to use 2 tags for each of the 3npcs, which make 6 in total. And if you make a game with 10 different villages you save 6x 10= 60 tags !

A very important thing to remember : don't try to use this particular global variable for something else, you would mess up things terribly. Use a free one instead! The last version allows a huge number of global variables! If you take you time to implement the code bit by bit, it should be ok!

Finally you make wonder what about the sub quest? Let's say that you want the player to get some apple to NPC 5 the inn keeper before he allows the hero to stay up for the night? Well it's rather easy. First go under custom. On the tag menu, use on the save up tag and name it inn keeper apple (or any other name which make you easily remember what the tag is for)

  case (0) do, begin
  
  if (check tag (tag: inn keep apple)==off) then, begin
  
  show text box (31)  # dialogue when you first meet the npc
  wait for text box
  end, else, begin
  show text box (40)
  wait for text box
  end #end for the if  
  
  end #end for the case

Go under custom and write

  text box 40
  Oh you brought me some apples! It's not very much but feel to use the room upstairs!
  

Add the line

set tag (tag: inn keep apple, on)

just after you get the apples. Feel free to ask for help on the forum if you have troubles implementing!

See Also[edit]