How do I make the story continue after you die in battle?

From OHRRPGCE-Wiki
Jump to navigation Jump to search

Sometimes as part of the plot of your game, you want a battle that you have to lose. How do you make the story continue after you die, rather than just sending you back to the title screen?

This is done with a "game-over script" (also known as a "deathscript"). If you haven't written any plotscripts before, you should go and read the Plotscripting Tutorial, which will familiarize you with compiling and importing scripts. Then you can come back here and try to write a game-over script.

When you have a game-over script and you die in battle, that script will be run instead of dumping you back to the title screen. Here is an example game-over script.

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

plotscript, die in battle, begin
  if(check tag(tag:do not die)==OFF)
  then,begin
    game over
  end
end

Before this script will compile, you should name one of your Tags "do not die" in the Edit Tag Names menu, and then export an HSI file from the Script Management menu

Compile the script, and import it into your RPG file. From the main menu, go into Edit General Game Data, and then into Special Plotscripts. Assign "dieinbattle" as your game-over script

Now, whenever you die in a battle, the script will be run. The first thing it will do is check the value of your "do not die" tag. if this tag is OFF (all tags start OFF by default) then the script will execute the game over command, and you will return to the title screen as normal.

However, if the "do not die" tag is ON, then you will return to the map and you can continue playing.

Here is an example of a script that starts a battle with an impossible boss.

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

plotscript, die in battle, begin
  if(check tag(tag:do not die)==OFF)
  then,begin
    game over
  end
end

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

plotscript, unbeatable boss, begin

  #boss says "death to all who oppose me!"
  show text box(1)
  wait for text box

  #dying doesn't send you back to the title screen
  set tag(tag:do not die,ON)

  #fight a formation with a boss that is so
  #strong that he is sure to kill you

  set death script (@die in battle)
  fight formation(1)

  #restore normal death
  set tag(tag:do not die,OFF)

end

The set death script command always to use (thanks to tag effect) the script "die in a battle" instead of the game over script.

One thing to remember is that your heroes will still have zero HP after a death script. You might want to correct that in the game-over script. here is an example

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

plotscript, die in battle, begin
  variable(i)

  if(check tag(tag:do not die)==OFF)
  then,begin
    game over
  end
  else,begin
    for(i,0,3) do,begin
      if (get hero stat(i,stat:HP,current stat) <= 0)
      then (set hero stat(i,stat:HP,1))
      # you have one hp left after losing against the boss
    end
  end
end