Friday Script – PermaDeath

If you want to get the most out of RPG Maker, learn Ruby. In the meantime, lots of talented scripters have done the work for you. Every Friday, The Iron Shoe features a fun script and goes into detail about how to use it. It also covers a little bit of Ruby each time so you can make even more out of the script. And that’s just what we’re gonna do today!

Sometimes, a little bit of death isn’t enough. Sometimes you want PERMANENT DEATH. Whether you were hiring mercenaries or just had a bloated party, there are plenty of old school RPGs in which you had dozens of characters, and could afford for a few to disappear forever. If any given character was still dead at the end of the battle, you’d never see them again. How do we do this? With a really easy script.

class Game_Actor
  alias :old_battle_end :on_battle_end

  def on_battle_end
    revivable_actors = [1,2,4,8]
    if revivable_actors.include?(@actor_id) == false && @hp <= 0
      $game_party.remove_actor(@actor_id)
    end
    old_battle_end
  end

end

Ok, what’s customizeable and what does all this mean?

In the first line, we alias on_battle_end from Game_Actor. I’ve discussed aliasing in the past, but it’s important for situations where you want to preserve everything that RPG Maker does and just add a little spice. Here, we want our function to be called on each at battle end, and there’s already a function that does that. It’s called on_battle_end. But we want to also make sure RPG Maker does it’s normal routine. So we rename it to “old_battle_end” and then make a new on_battle_end. Now everything that would call on_battle_end calls ours, not the old one. At the end of our script, you’ll see we always call the old one after we’re done.

Revivable_Actors is an array of actor ids. the numbers 1,2,4 and 8 are meaningless, and can and should be replaced with the ids of any actors you want to survive a battle even if they leave it with 0 HP. Think of this array as your story character, the critically important people. Not the fluff. Forget the fluff. Is your game only fluff? Then leave the array blank, just make it look like [].

The next “if” section is looking for party members that are not in the array and who have hp less than or equal to 0 (that is, they’re dead). Any actors who fulfill both those conditions are removed from the party on battle end.

Pretty easy, right? Now go kill some red shirts.

Advertisements

One thought on “Friday Script – PermaDeath

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s