How do I use plotscripts to make an NPC created through plotscripting stay on the map?

From OHRRPGCE-Wiki
Jump to: navigation, search

You may have noticed that when you have place an npc on the map will a plotscript using the command

create NPC (ID,X,Y,direction)

it does not stay on the map. Let's take a example: your hero has found a thieves hideout. He enters and suddenly he hears the thieves coming back.(The thieves are ncps 4,5 and 6 of the hideout map and you use the command create npc to place them on the map) Your managed to beat them while a fight but... when the fight ends the npcs that looks like the thieves npcs have disappeared. How come?

Well, if you look carefully on the plotscript dictionnary it's said that "The new NPC is not permanent. It only lasts until a new map is loaded" In the example above the map have been loaded when the fight ends and it was enought to make your thieves npcs disappear. Fortunatelly you perfectly can make them stay on the map.

First way: old way using the autorun map and a tag

Here's how to do : First go under custom.exe and edit the tags. Pick up a free one and name it "thieves in hideout" or any other name that will make you remember what is the tag for. Then go to the script management menu and export names for script (in other terms update your hsi file) Now you can save the changes and leave custom.

The next step editing your hss file. Let's work with the example of the thieves' hideout

script, enter hideout, begin

walk hero (me, north 2)
wait for hero (me)
walk hero (me, south, 3) 
wait for hero (me)

show text box (34) #where are we ?
wait for text box
show text box (37) # thieves hideout
wait for text box
show text box (42) # ??? what's this?
wait for text box

create npc ( 4, 45, 65)
walk npc (4, east, 5)
wait for npc (4)
create npc ( 5, 45, 65)
walk npc ( 5, east, 3)
wait for npc (5)
create npc ( 6, 45, 65)
walk npc npc ( 6, east, 2)
wait for npc (6)

set tag (tag : thieves in hideout, on)# tag allows thieves to stay on the map as long as we want them to
show text box (43) #what are you doing here?
wait for text box
show text box (37) # thieves We'll slay you
wait for text box
fight formation (5)

show text box (37) # heroes: Victory!
wait for text box

alter NPC (4, Npcstat:picture, 13) # thieves get their tied down appearance
alter NPC (4, Npcstat:palette, 14)
wait for npc (4) 

alter NPC (5, Npcstat:picture, 23)
alter NPC (5, Npcstat:palette, 24)
wait for npc (5) 

alter NPC (6, Npcstat:picture, 21)
alter NPC (6, Npcstat:palette, 22)
wait for npc (6) 

show text box (34)# Let's search for the sheriff
wait for text box
end  #end of the script

What is important in the script above is the line "set tag (tag : thieves in hideout, on)" It saves your npcs.

Now we'll need a autorun map.

#map 13 is the thieves hideout
script, autorunmap 13, begin

if (check tag (tag : thieves in hideout)== on) then, begin

create npc ( 4, 40, 65)
alter NPC (4, Npcstat:picture, 13) 
alter NPC (4, Npcstat:palette, 14)

create npc ( 5, 42, 65)
alter NPC (5, Npcstat:picture, 23)
alter NPC (5, Npcstat:palette, 24)

create npc ( 6, 43, 65)
alter NPC (6, Npcstat:picture, 21)
alter NPC (6, Npcstat:palette, 22)

end #end of the script

As you can see the autorun map script is the most difficult to do. Be sure you get the correct x,y coordonates and last appearance references when you write the script, else you can have surprises when you get back on the hideout map.

Now save the hss file and compile your script. Then, lauch custom.exe again and edit map 13 (the thieves hideout map). Go into the general map data and give your map its autorun script. Save the changes... and you can test the whole thing! As long as the tag is turned on, the thieves will be tied down on the hideout waiting for the sheriff to arrest them. Isn't the OHRRPGCE a beautiful rpg maker?? ^___^

Second way brand new and easy way: using plotscripting :

Download the nighly version of the OhrRpgCe. Launch Custom.exe and get down until you see "npc data". Use the arrow and pick up the line "remember state when leaving" "save npc state" which automatically keeps your plotscriptbourne NPCs on the map

Personal tools