Changing drain formula

Hello, I'd like to implement something in my project related with the drain value the attacker receives. I'd like target's Luck reduces the damage percentage the caster recover, I think the key to modify this is in Game_ActionResult scripts

Code:
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
    @success = true if item.damage.to_hp? || @mp_damage != 0
  end

The idea would be to modify the first @hp_drain line to multiply the damage by (target's luk / 100)

Does someone know how to make this? Thank you
Something like this maybe
Code:
  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 * (@battler.luk / 100.0) if item.damage.drain?
    @mp_drain = @mp_damage if item.damage.drain?
    @hp_drain = [@battler.hp, @hp_drain].min
    @success = true if item.damage.to_hp? || @mp_damage != 0
  end
Something like this maybe
Code:
  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 * (@battler.luk / 100.0) if item.damage.drain?
    @mp_drain = @mp_damage if item.damage.drain?
    @hp_drain = [@battler.hp, @hp_drain].min
    @success = true if item.damage.to_hp? || @mp_damage != 0
  end

It's working, I forgot the idea was to reduce the recovered HP if the target has more luck so it'd be more like this line

Code:
@hp_drain = @hp_damage * (1 - (@battler.luk / 100.0)) if item.damage.drain?

I tried to add the .to_i at the end of the script but now it doesn't show the recovered HP, can you tell me how to solve this little problem? 🙂
I'm not sure how .to_i have anything to do with showing recovered hp. And how you put .to_i in the first place anyway?
Personally, I'd go something like this
Code:
 @hp_drain = [@battler.hp, @hp_drain].min.to_i
I'm not sure how .to_i have anything to do with showing recovered hp. And how you put .to_i in the first place anyway?
Personally, I'd go something like this
Code:
 @hp_drain = [@battler.hp, @hp_drain].min.to_i

I tested and writing it like that solves the problem

Code:
 @hp_drain = (@hp_damage * (1 - (@battler.luk / 100.0))).to_i if item.damage.drain?

Previously I wrote it of this way

Code:
 @hp_drain = @hp_damage * (1 - (@battler.luk / 100.0)).to_i if item.damage.drain?

So that multplied the 1 by 0 because that's the result of rounding out this division. Thanks for the help, this problem is solved!

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.

Original thread: https://forums.rpgmakerweb.com/threads/changing-drain-formula.95812/