Custom revive/heal script not working

Status
Not open for further replies.

Kes

Veteran
Veteran
Joined
Aug 3, 2012
Messages
22,299
Reaction score
11,713
First Language
English
Primarily Uses
RMVXA
I have a skill which has a basic and an upgrade form.

The basic version is the user attacks an enemy and also revives any dead allies with 20% HP
The upgrade version attacks 2 enemies and also revives any dead allies with 40% HP

As the damage formula is too long for the formula box, I use snippets in the script editor which I then call up from the damage formula.

The basic version looks like this:
Code:
class Game_Battler < Game_BattlerBase
  def energy_rebirth()
    $game_party.members.each do |m|
      if (m.state?(1))
        m.remove_state(1)
        m.hp += (m.mhp * 20 / 100) # You can replace 20 with a variable heal rate, e.g. $game_variables[43]
      end
    end
  end
end
The damage formula has
a.energy_rebirth();
followed by the damage formula itself.

The upgrade version has:
Code:
class Game_Battler < Game_BattlerBase
  def energy_rebirthup(b)
    $game_party.members.each do |m|
      m.hp += (m.mhp * 40 / 100) if (m.hp == 40) # change percentage here to be the variable you use to store the actual percentage
    end
  end
end
The damage formula calls it up with
a.energy_rebirthup(b);

I have been trying to test the upgrade version and it simply does not work.
I saw that it lacked the lines:
Code:
  if (m.state?(1))
        m.remove_state(1)
so tried it with those lines and an extra 'end' where needed, but still the dead ally did not revive.

I also tried it calling it up from the damage formula with
a.energy_rebirthup()
but that made no difference.

Can anyone see what the problem might be?
Thank you.
 

bgillisp

Global Moderators
Global Mod
Joined
Jul 2, 2014
Messages
13,528
Reaction score
14,261
First Language
English
Primarily Uses
RMVXA
I think the issue is the if(a.hp == 40) line as that looks like it is going to call it only if your HP is exactly 40. What happens if you change that to 0?
 

Wavelength

MSD Strong
Global Mod
Joined
Jul 22, 2014
Messages
5,635
Reaction score
5,116
First Language
English
Primarily Uses
RMVXA
Hey Kes, looks like this is playing around with the formula I gave you last year. Where I say "You can replace 20 with a variable heal rate, e.g. $game_variables[43]" in my comment, that means that if you replace the 20 with a variable, you can change the variable during the game (i.e. when the actor gets the upgrade to the skill - say, from 20 to 40) and then just call the same method.

If you have no way to do that, then just copy my "basic version" code, change the 20 to a 40 manually, and change the method's name (such as: def energy_rebirthup() . ) That should get you everything you need. You were correct that lacking the check for if m.state?(1) was an issue (the actor would remain KO'ed), and @bgillisp was also right that the if (m.hp == 40) line is screwing things up (it makes no sense to check the member's current HP). Including the target "(b)" as an argument also makes no sense because you don't need to check anything about the skill's target(s); you only need to look through each actor which the code body already provides.
 
  • Like
Reactions: Kes

Kes

Veteran
Veteran
Joined
Aug 3, 2012
Messages
22,299
Reaction score
11,713
First Language
English
Primarily Uses
RMVXA
@bgillisp and @Wavelength
Thank you both, this has sorted the problem out. Not only is that a relief in itself, but I was also becoming deeply fed up testing this. I had to play the encounter badly enough to get at least one actor killed, but not so badly that the actor with the skill went down. I discovered so many ways that the careless/unobservant player could screw up this boss battle I'm left wondering if I'll be the only one who can beat it first go.

Once again, thanks. I am grateful for your help.
 

bgillisp

Global Moderators
Global Mod
Joined
Jul 2, 2014
Messages
13,528
Reaction score
14,261
First Language
English
Primarily Uses
RMVXA

This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.

 
Status
Not open for further replies.

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Profile Posts

Our latest feature is an interview with... me?!

People4_2 (Capelet off and on) added!

Just beat the last of us 2 last night and starting jedi: fallen order right now, both use unreal engine & when I say i knew 80% of jedi's buttons right away because they were the same buttons as TLOU2 its ridiculous, even the same narrow hallway crawl and barely-made-it jump they do. Unreal Engine is just big budget RPG Maker the way they make games nearly identical at its core lol.
Can someone recommend some fun story-heavy RPGs to me? Coming up with good gameplay is a nightmare! I was thinking of making some gameplay platforming-based, but that doesn't work well in RPG form*. I also was thinking of removing battles, but that would be too much like OneShot. I don't even know how to make good puzzles!
one bad plugin combo later and one of my followers is moonwalking off the screen on his own... I didn't even more yet on the new map lol.

Forum statistics

Threads
106,034
Messages
1,018,447
Members
137,820
Latest member
georg09byron
Top