New Skill – Guardian Angel

Reddit user Top_Gorilla17 wants to implement a skill in his game. The healer would cast a spell, and then for 2-4 turns after, a random party member is healed. The healer can still act during those turns, but would have no control over who gets healed – it’s sort of a background extra heals.

If you think it sounds a lot like my previous tutorial on an Arrow Rain skill, you’re not wrong. And in fact, you should go read that tutorial before continuing with this one.

I’m calling this skill Guardian Angel, and here’s how we do it:

Make the State, Make The Skill

As with nearly everything we do, we need a state, and a skill that applies that state. And per usual, the state is a “dummy” – it doesn’t do anything itself, but we can check against it all we want.

While normally dummy states don't use icons (they're supposed to hide from the players), here I think it might actually be nice to tell the player that the state is still active.

While normally dummy states don’t use icons (they’re supposed to hide from the players), here I think it might actually be nice to tell the player that the state is still active.

Really the only important part of creating your state is the timing. Since Top Gorilla specified “2-4 turns,” that’s something we can easily represent in the state window.

Balancing this skill is going to be tricky. Too little healing, and no one will ever use it. Too much MP, and the fact that your caster can act while it's pending is meaningless.

Balancing this skill is going to be tricky. Too little healing, and no one will ever use it. Too much MP, and the fact that your caster can act while it’s pending is meaningless.

And we fill in the skill with things like name, description, resource costs, all that jazz. For the skill, make sure a few critical components are set:

  • The “Scope” is The User – we’re apply a state to the caster herself
  • “Occasion” is Only in Battle – this skill makes no sense outside of battle
  • “Hit Type” is Certain Hit – we don’t want our healer to be able to miss
  • “Effects” should have Add State: Guardian Angel 100%. The only purpose for this skill is to apply the state to your caster.

Make the Script

Now we have to make the script that does all of the healing work. Remember from our Arrow Rain skill that when we want to trigger something at turn end in a battle, we use:

class Scene_Battle
 alias :old_turn_end :turn_end 
 
 def turn_end
     #do all of our stuff here
     old_turn_end
 end
 
end

So what stuff do we need to do?

  • Check to see if anyone in our party has the Guardian Angel stat
  • If they do, get their MAT stat and calculate a healing amount based on that
  • Choose a random party member to heal for that much
  • Display a little text about it / play some SE or animation

We can put all of our stuff in an if loop, specifically

$game_party.members.each { |a|
if a.state?(26)
...

What this does is go through the array of party members and asks, do any of them have state 26? If so, let’s carry on with healing; if not, check the others and continue with battle. I’m using this approach as opposed to .any? because if .any? returned true, we need to know who has the state. .each kills both birds. NB:  In RPG Maker, $game_party.members means two different things, depending on context. Outside of battle, it’s everyone in your party. Inside of battle, it’s only those who are participating in battle.

Now, we need to figure out our healing number, choose a random party member, and heal them for that amount. Easy peasy! You can do whatever you want for your heal amount; here, for the sake of example we’re using the caster’s MAT stat times 5.

heal = a.mat * 5
recipient = $game_party.members.sample
recipient.hp += heal

Ok, we set a heal amount based on A’s MAT stat. We used .sample to choose a random person from the members in battle. And then we increased that heal-receiver’s HP by the heal amount.

Finally, we need some animation and text. I talked more about this in the Arrow Rain tutorial, you can use the same pattern. In fact, since we know the caster of Guardian Angel, we can even have a little more fun with it.

 @log_window.add_text("#{a.name}'s Guardian Angel heals #{recipient.name} for #{heal}!") 
 show_animation([recipient], 18)

You can use #{} in quotes to replace the text with whatever is there. So here, we’ve used it to show the caster’s name, the healed person’s name, and the amount they were healed for.

For the animation, make sure recipient is in brackets – RPG Maker expects a list of all targets for animation, so even though our list is only one, it still needs to look like that list. That 18 at the end is an animation ID from the database – you choose what animation you want to play on the person that gets healed.

Final Script

Putting it all together, our script looks like this:

class Scene_Battle
 alias :old_turn_end :turn_end 
 
 def turn_end
     $game_party.members.each { |a|
          if a.state?(26)
               heal = a.mat * 5
               recipient = $game_party.members.sample
               recipient.hp += heal
               @log_window.add_text("#{a.name}'s Guardian Angel heals #{recipient.name} for #{heal}!") 
               show_animation(recipient, 18)
          end
     }

     old_turn_end
 end

Drop that in your Materials section and heal away!

No promises on the combat log if your characters have exceedingly long names ;)
No promises on the combat log if your characters have exceedingly long names 😉
Advertisements

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