[ACE] Forcing HP Drain to take battler's REC parameter into account

davidgoh

Villager
Member
Joined
Dec 1, 2014
Messages
6
Reaction score
0
First Language
English
Primarily Uses
Hey guys! As you know, the HP drain in RMVX by default doesn't take into account the Recovery parameter of the battler. I'd like to fix that.

I'm not much of a scripter, but I figured that I can do this by overriding the make_damage definition under Game_ActionResult. Here's what I did: (Note, only one line was edited, the rest are still the same.)

class Game_ActionResult

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

  # * Create Damage

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

  def make_damage(value, item)

    @critical = false if value == 0

    @hp_damage = value if item.damage.to_hp?

    @mp_damage = value if item.damage.to_mp?

    @mp_damage = [@battler.mp, @mp_damage].min

    @hp_drain = @hp_damage if item.damage.drain?

    @mp_drain = @mp_damage if item.damage.drain?

    @hp_drain = (([@battler.hp, @hp_drain].min)*@battler.rec).to_i  #Edited line

    @success = true if item.damage.to_hp? || @mp_damage != 0

  end

 

end # class Game_ActionResult
Unfortunately, instead of using the initiating battler's own Recovery parameter, that code uses the target battler's Recovery parameter instead, which obviously makes no sense.

 

I'd like to fix it so that the initiating battler's REC parameter is used instead. Any help will be appreciated!
 

Kes

Veteran
Veteran
Joined
Aug 3, 2012
Messages
22,299
Reaction score
11,712
First Language
English
Primarily Uses
RMVXA
Would it be something as straightforward as using the actor's rec instead of the battler's?
 

davidgoh

Villager
Member
Joined
Dec 1, 2014
Messages
6
Reaction score
0
First Language
English
Primarily Uses
Would it be something as straightforward as using the actor's rec instead of the battler's?
Hey! Thanks for chiming in. I get an undefined error when I replace @battler with @actor, so I don't think that's the solution.

I guess this makes sense, given that this will also apply to non-actor battlers. (e.g. Enemies can use drain HP skills and their REC parameters will also be taken into account.
 

Trihan

Speedy Scripter
Veteran
Joined
Apr 12, 2012
Messages
2,604
Reaction score
1,960
First Language
English
Primarily Uses
RMMV
I think you're slightly off in your thinking of what Game_ActionResult actually does. Every battler has an instance of it, and make_damage is a method for determining the damage done to the battler it belongs to. That's why it's using the target's REC, because that's who is working out the damage at that point. In fact, Game_ActionResult doesn't care a jot about who used the damaging thing, because the value passed in already took the user's stats into account.

What you actually want is make_damage_value in Game_Battler. There is actually already a line for applying REC to recovery:

value *= rec if item.damage.recover?

So just change it to

value *= rec if item.damage.recover? || item.damage.drain?
 

Kes

Veteran
Veteran
Joined
Aug 3, 2012
Messages
22,299
Reaction score
11,712
First Language
English
Primarily Uses
RMVXA
An alternative would be to use the damage formula, which I think would be more straightforward and can be tweaked to every individual instance of where you want to do this.

Something like this, with damage type set to HP Drain

[b.hp * a.rec].to_i

It might be 

[b.hp * a.sparam(2)].to_i
 

davidgoh

Villager
Member
Joined
Dec 1, 2014
Messages
6
Reaction score
0
First Language
English
Primarily Uses
I think you're slightly off in your thinking of what Game_ActionResult actually does. Every battler has an instance of it, and make_damage is a method for determining the damage done to the battler it belongs to. That's why it's using the target's REC, because that's who is working out the damage at that point. In fact, Game_ActionResult doesn't care a jot about who used the damaging thing, because the value passed in already took the user's stats into account.

What you actually want is make_damage_value in Game_Battler. There is actually already a line for applying REC to recovery:

value *= rec if item.damage.recover?

So just change it to

value *= rec if item.damage.recover? || item.damage.drain?
Thanks for the lesson! I didn't know that Game_ActionResult is tied to the battler suffering the damage. That explains a lot!

Unfortunately, I can't seem to get your solution to work. Testing it on a new project doesn't seem to do the trick either.

An alternative would be to use the damage formula, which I think would be more straightforward and can be tweaked to every individual instance of where you want to do this.

Something like this, with damage type set to HP Drain

[b.hp * a.rec].to_i

It might be 

[b.hp * a.sparam(2)].to_i
I'm afraid I can't use that... The skills I'm creating need to be able to deal full damage regardless of the resultant drain. That means even if the skill user's REC is 0, his ability should still do damage as per normal. Thanks for the suggestion though!
 

davidgoh

Villager
Member
Joined
Dec 1, 2014
Messages
6
Reaction score
0
First Language
English
Primarily Uses
I think you're slightly off in your thinking of what Game_ActionResult actually does. Every battler has an instance of it, and make_damage is a method for determining the damage done to the battler it belongs to. That's why it's using the target's REC, because that's who is working out the damage at that point. In fact, Game_ActionResult doesn't care a jot about who used the damaging thing, because the value passed in already took the user's stats into account.

What you actually want is make_damage_value in Game_Battler. There is actually already a line for applying REC to recovery:

value *= rec if item.damage.recover?

So just change it to

value *= rec if item.damage.recover? || item.damage.drain?
Hey Trihan,

My mistake! Upon testing it again, your code actually works... it's just that its behaviour wasn't exactly what I was looking for. So sorry about that -- I wish I had been more clear!

To be exact, what I'm looking to pull off is this: 

  • Assuming a character can use a skill that has a HP Drain effect, and the skill will deal 1000 HP and drain the same amount.
  • Now, if that character has a status that results in him having 50% REC, his skill will still deal 1000 HP in damage, but the HP drain will now be at 50% (500 HP) due to the new REC value.
What your code currently does is reduce the damage and drain across the board based on the REC parameter instead.

I hope that's a lot clearer!
 
Last edited by a moderator:

Trihan

Speedy Scripter
Veteran
Joined
Apr 12, 2012
Messages
2,604
Reaction score
1,960
First Language
English
Primarily Uses
RMMV
In that case you want execute_damage in Game_Battler.

Change the line "user.hp += @result.hp_drain"

to

"user.hp += @result.hp_drain * user.rec"
 

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

Latest Threads

Latest Posts

Latest Profile Posts

People3_5 and People3_8 added!

so hopefully tomorrow i get to go home from the hospital i've been here for 5 days already and it's driving me mad. I miss my family like crazy but at least I get to use my own toiletries and my own clothes. My mom is coming to visit soon i can't wait to see her cause i miss her the most. :kaojoy:
Couple hours of work. Might use in my game as a secret find or something. Not sure. Fancy though no? :D
Holy stink, where have I been? Well, I started my temporary job this week. So less time to spend on game design... :(
Cartoonier cloud cover that better fits the art style, as well as (slightly) improved blending/fading... fading clouds when there are larger patterns is still somewhat abrupt for some reason.

Forum statistics

Threads
105,868
Messages
1,017,083
Members
137,583
Latest member
write2dgray
Top