How do I make an NPC say something different later?

From OHRRPGCE-Wiki
Jump to: navigation, search
Revise.png
This article does not meet the standard of quality we would like to have. Feel free to revise it and make it better by using the edit link at the top of the page. This tag should be removed when an editor feels it is of high quality.

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

Often you want the same NPC to say different things when you talk to it at different times in the game. This is done with Tags, and text-box chaining.

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.

  • First, pick Edit Tag Names off the main menu.
  • Name 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."
  • 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
where ? is 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. Feel to click on How to use NPCs and Tags for more details.

Using 2 tags and plotscripting[edit]

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 a thieves. The second quest consists in going into a neighboring 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 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 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))
            text box 27 Thank you so so much! My new shop is really nice isn't it? I decided 
            to offer special discount! (go to shop with items at reduced prices)

Save your game data and edit your hss file, 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 dialagues 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)

To launch quest 2

            set tag (tag: quest1, off) #prevents interferences
            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 the next quests, 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 npcs, you may be more interested by what follows!


Use a global variable and the switch command[edit]

This method will consume less scripts and tags. It is the most efficient so I recommend you to use it if you're comfortable with scripting. Let's take again the example used above.

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.


In this example, 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 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))


Save your game data and edit the hss file. As it is easy to check text box numbers

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

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)

To launch quest 2

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


See Also[edit]