How do I prevent a dead hero from reviving at the Inn?

From OHRRPGCE-Wiki
Jump to navigation Jump to search

As it is not very rationnal that a stay at a Inn revives a dead hero, you might want to prevent this from happening in your game.

If you are using a Inn that comes with Custom.exe[edit]

If you are using the Inn that comes with Custom.exe then, all you have to do is going under custom.Exe, editing the preference bitsets and check that the bitset Inns revive dead heroes is not activated . Check also your code. There is a command in the plotscript dictionary that does just like the bitset. The command is called :

 set inn revive mode (state)

How does this work? Well, if you see "set inn revive mode (on)" on your script, it means that, even if, the bitset is not activated your Inn can nonetheless make dead heroes revive. The purpose of this command is precisely to activate this function. To check your code, use the function search of the programm you're using and make sure that the line does not appear.

If you are using your own Inn[edit]

If you have made your own INN and if you don't want the INN to revive dead heroes you can do so by adding line in your code and combining those things

=> First step: with 2 variables, the command hero by slot and the set variable command you check the stats of your heroes and you store them accordingly to their position in the walkabout party.


define script (17, inn script, none)

global variable (15, hero in slot 0 check)
global variable (16, hero 0 level hp)

#----------------------------------------------------------------------------
plotscript, inn script, begin


  hero slot 0 ID check:=hero by slot (0) # store the number which corresponds to the slots in the order menu. From 0 to 3.
  
  # add hero slot 1 ID check:=hero by slot (1), hero slot 2 ID check:=hero by slot (2) etc for the other slots

  set variable (hero 0 level hp, get hero stat (find hero (hero in slot 0 check), stat:hp,current stat)) #store current hero in slot 0's stat
 
  #add this line if you want to store mp : set variable (hero 0 level mp, get hero stat (find hero (hero in slot 0 check), stat:mp,current stat)) 
  #add the line if you want to store hp for hero 2 : set variable (hero 0 level hp, get hero stat (find hero (hero in slot 0 check), stat:hp,current stat))

end# end of the script

=> Second step: you use the content of the HP variable to turn a tag ON or OFF. Each slot has its own tag which can be turned ON or turn OFF depending on what state the hero is.


if (hero 0 level hp <=0) then, begin #if hp level is zero
#increment (dead heroes, 1) #optional but interesting
set tag (tag: hero slot0 dead, on)
end
if (hero 0 level hp >=1) then, begin #if hp level is more than one, hero does not need revive but classic INN service
set tag (tag: hero slot0 dead, off)
end
end #end for the if hero in slot 0 check

=> Third step: Finally, you check your tags and restore the stats using the set hero stat command.


if (check tag (tag: hero slot 0 dead)==on) then, begin #hero is dead. do nothing
wait (1)
end, else, begin #hero 0 is not dead, restore stats
set hero stat (find hero (hero in slot 0 check),stat:hp, get hero stat(find hero (hero in slot 0 check),stat:hp,maximum stat))
set hero stat (find hero (hero in slot 0 check),stat:mp, get hero stat(find hero (hero in slot 0 check),stat:mp,maximum stat))
end #end for the if check tag


if (check tag (tag: hero slot 1 dead)==on) then, begin #hero is dead. do nothing
wait (1)
end, else, begin #hero 1 is not dead, restore stats
set hero stat (find hero (hero in slot 1 check),stat:hp, get hero stat(find hero (hero in slot 1 check),stat:hp,maximum stat))
set hero stat (find hero (hero in slot 1 check),stat:mp, get hero stat(find hero (hero in slot 1 check),stat:mp,maximum stat))
end #end for the if check tag


if (check tag (tag: hero slot 2 dead)==on) then, begin #hero is dead. do nothing
wait (1)
end, else, begin #hero 2 is not dead, restore stats
set hero stat (find hero (hero in slot 2 check),stat:hp, get hero stat(find hero (hero in slot 2 check),stat:hp,maximum stat))
set hero stat (find hero (hero in slot 2 check),stat:mp, get hero stat(find hero (hero in slot 2 check),stat:mp,maximum stat))
end #end for the if check tag


if (check tag (tag: hero slot 3 dead)==on) then, begin #hero is dead. do nothing
wait (1)
end, else, begin #hero 3 is not dead, restore stats
set hero stat (find hero (hero in slot 3 check),stat:hp, get hero stat(find hero (hero in slot 3 check),stat:hp,maximum stat))
set hero stat (find hero (hero in slot 3 check),stat:mp, get hero stat(find hero (hero in slot 3 check),stat:mp,maximum stat))
end #end for the if check tag

In top of identifying death heroes, you can also count them. To do so, you add a global variable.

increment (dead heroes, 1)

Why would you count them? This way you can also use it not only to check if there is a need to pay the INN Keeper (not need to stay at the INN if everyone if dead and can't revive), and it also be re-used when you make your own which at the opposite make your heroes comes back to life and even to trigger the game over sequence when all your heroes dies outside battle . As you learned in the how to chapters the game over script is launched when you lose a battle in the battle system that had been built inside Custom.exe, but can also be launched simply by calling the script. If you count dead heroes you can add a condition and write something like that :


if (dead heroes==4) then, begin #All 4 heroes of the party are dead. Game OVER
my game over script
end# end for the if

If you are interested in implementing a INN that does not revive dead heroes, the whole process had been described in details in the article below. It is quite long and complex but it worths it nonetheless and it helps you to grasp Intermediate Ploscripting writing skills.

See Also[edit]