How do I make an NPC say something different later?

From OHRRPGCE-Wiki
Jump to navigation Jump to search

NPC plays a important role in Rpgs because it's from them that you get the information you need to go on your journey. The OHRRPCE is not exception to the rule and offers various way to make a NPC saying something different later. The first solution is using an option in the text box menu called #next. But in this article we'll learn how to use the other one #instead.

The second solution consists in using 2 tags and plotscripting. With the third solution, you need a global variable and the switch command and finally the fourth uses ony one tag and a global variable. As the fourth one works best several npcs it, the method is described in a separate article. So let's go!


Using a text box conditional, "jump to textbox # instead"[edit]

Suppose you have an NPC who says "Go Kill the Dragon.", and you want him to say "Thank you!" after you have killed the dragon. How shall we proceed?

Well as always go under custom.exe. Edit Tag Names. Pick up an unused tag and name it "Dragon is Dead" (or any other name that may help you to remember what the tag is used for). We will pretend it is tag 10 for sake of example.

Then go to the dialogue editor and make a text box that says

 "Go kill the Dragon."

Pick up another one and write in it

 "Thank you"

Edit the text box's conditionals. The first conditional in the list will say:

 never do the following
 use [text box or script] instead

Use the left and right arrow keys to change it so it reads:

If tag 10 = ON (Dragon is Dead)
jump to text box ? instead

Replace the question mark with the number of the text box that says "Thank you!" On the same text box that launches the battle with the Dragon, be sure to put the conditional:

always do the following
set tag 10 = ON (Dragon is Dead)

In the old times that are not that old, a demo game had been made to explain newbies how to do this. Just click on How to use NPCs and Tags for more details.

Using 2 tags and plotscripting[edit]

With this second method, we can update the dialogue of our NPC several times. It's quite simple to use and does requiere to use complexe plotscrpting commands. So how shall we do?

Open Custom.exe. Edit the text boxes and pick up 3 free tags. Name them: Quest1, Quest2, Quest2 complete. Edit the text boxes and put 4 free text boxes. The first one is when quest1 is not active (and when you meet the first time the NPC) In the example it will be text box 23. The second text box is when quest1 is active. It will be text box 24. The third box is when quest 2 is not active (text box 25) and the fourth text box is when quest 2 have ended.

In this example, quest1 consists in saving the village from thieves. The second quest consists in going into a neighboring town to convince the king to give money to restore houses damaged while fighting against the thieves. NPC 4 is a merchant and will say something like

            text box 23 "Hello! I usually sell 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: 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? 

Edit the conditionals of this text box and use the arrows to have

            shop always do  the following
            vil.gene.shop #village general shop is shop 5
            text box 26 I hope that you'll manage to convince the king. By the way would you
            be interested by one of these?

Edit the conditionals of this text box and use the arrows to have

            shop always do  the following
            vil.gene.shop #village general shop is shop 5


            text box 27 Thank you so so much! My new shop is really nice isn't it? I decided 
            to offer special discount!

Edit the conditionals of this text box and use the arrow to have

            shop always do  the following
            gene.shop.disc vil.#village general shop with discount price is shop 6



Save your game data and edit your hss file before adding the following scripts:

#------------------------------------------------------------------------------
# behaviour for npc 4 the armor merchant
plotscript, npc 4 behaviour quest 1, begin

  suspend npcs
  suspend player

  if (check tag (tag: quest1)==on) then, begin
    show text box (24)
    wait for text box
  end, else, begin
    show text box (23)
    wait for text box
  end# end for the tag

  resume npcs
  resume player

end #end for the script

#------------------------------------------------------------------------------
# behaviour for npc 4 the armor merchant while quest 2
plotscript, npc 4 behaviour speech quest 2, begin

  suspend npcs
  suspend player

  if (check tag (tag: quest2)==on) then, begin
    show text box (26)
    wait for text box
  end, else, begin
    show text box (25)
    wait for text box
  end# end for the tag

  resume npcs
  resume player

end #end for the script

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

Then you'll need to make an autorun script for the village's map (map3 in our example). It will alter the npc so that the NPC keeps his/her new behaviour script when the map is loaded.

#--------------------------------------------------------------------------------------------
# village autorun map

plotscript, autorunmap3, begin

  if (check tag (tag: quest2)==on) then, begin
    Alter NPC (4,NPCstat:script,@npc 4 behaviour speech quest 2) #add several npcs here new speech script
  end, else, begin
    if (check tag (tag: quest2 complete)==on) then, begin #if previous quest tags has been turned off then alter npc the same new dialogues requires
      Alter NPC (4,NPCstat:script,@npc 4 behaviour speech quest 2) #update npc behaviour script
    end #end if check quest complete
  end #end if check tag quest2

end #end for the script
#---------------------------------------------------------------------------------------------

To launch quest 1

            set tag (tag: quest1, off) # launched by default. All tags are off when a game starts
            set tag (tag: quest1, on) # display dialogues before update for Quest2 after Quest1 has ended

To launch quest 2

            set tag (tag: quest2, on)
            set tag (tag: quest2 complete, on)

If you're on the village map when quests ends add

            Alter NPC (4,NPCstat:script,@npc 4 behaviour speech quest 2)

To activate the next quest, you'll have to create 2 tags for each quests. You need the second one to keep the effects of the alter npc command. As it consumes many tags, you may want to use the third way of doing it explained in the next section.

All that is left is to save again the .hss file, to import its content in your game and voilà! You are ready to test.

Use a global variable and the switch command[edit]

This method will consume less scripts and tags. It is the most efficient but it can be quite tricky for newbies. I recommend you to use it if you're comfortable with writing plotcripts and if you are very ease with custom.exe's menus. Let's take again the example used above. So we have a village that have racketted by thieves. The heroes first save the village, but houses are destroyed. Then the villagers ask the hero to go and see the king to get money. So what shall we do?


Open your game and edit the text boxes and pick 2 free tags. Name them: Quest1 and Quest2. Edit the text boxes and put 4 text boxes. The first one is when quest1 is not active (and when you meet the first time the NPC)In the example it will be text box 23. The second text box is when quest1 is active.It will be text box 24. The third box is when quest 2 is not active (text box 25) and the fourth text box is when quest 2 have ended.


Quest1 consists of saving the village from thieves. The second quest consists in going into a neighboring town to convince the king to give money to restore houses damaged while fighting against the thieves. NPC 4 is a merchant and will say something like

            text box 23 "Hello! I usually sell 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: 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? 

Text box 25 and text box 26 had their conditionnals edited and be given a different shop. Text box 25 is linked to shop 5 and text box 26 to shop 6.


Save your game data and edit the hss file. Check carefully the text box numbers when you're implementing this in your game.

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

Global variable (10, npc behaviour)

#-------------------------------------------------------------------------------------
plotscript, behaviour npc 4, begin

  
  switch (npc4 behaviour) do, begin

    case (0) do, begin 
      if (check tag (tag: quest1)==on) then, begin
        show text box (24) # behaviour while quest 1
        wait for text box
      end, else, begin
        show text box (23) # behaviour when you first meet the npc
        wait for text box
      end# end for the tag
    end #end for the case

    case (1) do, begin  #if variable behaviour npc5 have been implemented then...
      if (check tag (tag: quest2)==on) then, begin
        show text box (26) # behaviour while quest 2
        wait for text box
      end, else, begin
        show text box (25) # behaviour after quest 1
        wait for text box
      end# end for the tag
    end #end for the case

  end #end for the switch

end #end for the script
#-------------------------------------------------------------------------------------------------

When quest 1 (and then quest 2) ends add the following lines.

To launch quest 1

            set tag (tag: quest1, off) #tag is off by default when the game starts
            set tag (tag: quest1, on) #to have dialogue before Quest 2 starts. 

To launch quest 2

            set tag (tag: quest1, off) #prevents interferences
            set tag (tag: quest2, on)
            increment (behaviour npc4, 1)

You can now test the whole thing! This method which a variant of the first one use less tags, which is good because the number of tags is limited. A always don't panic if you have hspeak.exe giving your errors messages. Also don't forget that you can ask for help on the discord or on the forum of the community: slime salad

Using 1 tag and a global variable[edit]

This method is more efficient if you need several NPC (at least 4) to say something different later. (see the article How do I make several NPCs say something different later? for more details). Nonetheless, you can choose to use only to one kind of npcs (more likely the potion merchant or the inn keeper) to say different things all along the game.


See Also[edit]