ACE HP or SP Recovery Rates

ACE HP or SP Recovery Rate
Final Version

For Actors, Enemies, Items, Skills, States

by Kyonides​

Introduction

By default the VX ACE engine offers you 1 Sp-Parameter to alter the HP and the SP Recovery Rates.
This script lets you keep their increase rates separate! 😉

Just read the embedded comments in the script below to learn how to use it.

The Script

Ruby:
# * ACE HP or MP Recovery Rates *
#   Scripter : Kyonides Arkanthes
#   v1.0.0 - 2024-02-13

# Just leave a Note Tag in the corresponding Note Box.
# Valid for Actors, Enemies or Items or Skills or States.
# For HP or MP Only. Normally, you would only need 1 of them!
# It is applied to damage calculation whenever a recovery item is being used.
# Use the REC Sp-Parameter for the other value instead.
# - Examples:
# <hp recover 1000>
# <mp recover 1000>
# <hp recover 0.5>

module HpMpRec
  RECOVER_HP_NOTE_TAG = /<hp recover (\d+[.]?\d*)>/i
  RECOVER_MP_NOTE_TAG = /<mp recover (\d+[.]?\d*)>/i
  def find_recover_note(type)
    note_tag = type == :hp ? RECOVER_HP_NOTE_TAG : RECOVER_MP_NOTE_TAG
    @note[note_tag]
    $1.to_f
  end

  def hp_recover
    find_recover_note(:hp)
  end

  def mp_recover
    find_recover_note(:mp)
  end
end

class RPG::BaseItem
  include HpMpRec
end

class Game_Battler
  def states_hp_rec
    states.inject(0.0) {|n, s| n + s.hp_recover }
  end

  def states_mp_rec
    states.inject(0.0) {|n, s| n + s.mp_recover }
  end

  def item_effect_recover_hp(user, item, effect)
    rec_rate = db_unit.hp_recover + item.hp_recover + states_hp_rec
    rec_rate = rec if rec_rate == 0
    value = (mhp * effect.value1 + effect.value2) * rec_rate
    value *= user.pha if item.is_a?(RPG::Item)
    value = value.to_i
    @result.hp_damage -= value
    @result.success = true
    self.hp += value
  end

  def item_effect_recover_mp(user, item, effect)
    rec_rate = db_unit.mp_recover + item.mp_recover + states_mp_rec
    rec_rate = rec if rec_rate == 0
    value = (mmp * effect.value1 + effect.value2) * rec_rate
    value *= user.pha if item.is_a?(RPG::Item)
    value = value.to_i
    @result.mp_damage -= value
    @result.success = value != 0
    self.mp += value
  end

  def apply_recovery_rate(value, item)
    rate = 0
    rate += db_unit.hp_recover + item.hp_recover if item.damage.to_hp?
    rate += db_unit.mp_recover + item.mp_recover if item.damage.to_mp?
    value *= rec + rate
  end

  def make_damage_value(user, item)
    value = item.damage.eval(user, self, $game_variables)
    value *= item_element_rate(user, item)
    value *= pdr if item.physical?
    value *= mdr if item.magical?
    value = apply_recovery_rate(value, item) if item.damage.recover?
    value = apply_critical(value) if @result.critical
    value = apply_variance(value, item.damage.variance)
    value = apply_guard(value)
    @result.make_damage(value.to_i, item)
  end
end

class Game_Actor
  alias :db_unit :actor
end

class Game_Enemy
  alias :db_unit :enemy
end

Terms & Conditions

Free for use in ANY game.
Due credit is mandatory.
That's it! 😛
I have noticed some problems that the script causes in game to things it is not even suposed to effect.

1707752122280.png


Simply having a skill that heals someone through an effect results in this error text box, even if you didn't add to the "Note" page the "<hp recover 1000>".

1707752029953.png




And I am still unsure if this is how the script works, you are just supposed to add this "<hp recover 1000>" to the "Note" page of an status effect and it will act like the REC modifier but only to Hp? Because at the moment I have one of my status effect with this on it’s note box, but nothing is changing.

1707752312818.png


If you could provide an exemple of how the script is supposed to be used on a status effect or anything it would help at clarifying the problem a lot.
Maintenance Update​

I suddenly forgot :eswt: to change the name of the REC related constants but it's been updated now.

And yes, you only need to leave a Note Tag in an actor's note box as stated in the comments embedded in the script. (Posted just a while ago, I must add.)
Ey! Progress was made here.

Before I was not putting the code under the notebox of the Actor, I was putting it under the notebox of a Status Effect (which is what I want to use it on), so my mistake there lol.
So I tried putting it now in the Actor's notebox to see if it worked, and it did work!... Somewhat, here's what I've noticed.

The number that goes in the <hp recover 1000> it's in fact multiplying the healing received. I was kind of jumpscared when a 25 hp heal brought someone to full health for some reason. I was assuming it was a percentage thing, so it would basically be that I was increasing it by 1000%, but it is not that, it is a 1000 times increase.

Which wouldn't be a problem, if not for the fact that you can't make it be a decimal, like if I wanted to boost a heal by 50%, the minimal heal increase possible here is 2x (since it doesn't understand something like 1.5 or 1,5)

So aside from that, I’ve also found that it is only working on health changes coming from the effects tab now, and it doesn’t work for health changes coming from the damage formula.

(Works on these)

rch3D_tpCIQW06dKuqoH3c2PAhOkkjnAjSlmJwtsLhTPSlW_uSdPeAdG6qdnJVKWHQlqGdWnHb6-hw7O-DQwqpfyyfMX4lLE-l2xVtLxfXiFOELCzDxYWykrgUoGgWKZt7EkcUgh4ZX37mhryLAxxLs


(Don’t work on these)
1707756805553.png


And now, any health gained by the effect tab is “invisible”, the healing text not showing up, even if you didn’t use the Note Tag under that actor notebox.

(Meaning that these numbers don’t show up anymore, and if the heal is negative it just shows a 0, even though is supposed to show -50 )
-n0Hlqb43kM1Lp6fMR2H0LdEzY4AwADFJIF5JpffQ0o41PXrvJERxvLDDlv6W_dB9XdiBmMHbzumTL1AEIhoiRbe-LnuJ9SxLqdosq31K9SRH8AT8YUIYiq1vgGvbcv5Dpo6_MKaaDjk2SjX1psB1Vk
Script Upgrade​

OK, I came back with a new upgrade. Now the latest release does allow you to set decimals numbers if needed. I gotta admit that the original implementation works this way by default. :eswt: So I just reintroduced it here. 😛
This is great! Having more control over how much it is changed will help out a lot.

But sorry for asking more out of you, but I wanted to add this increase in mp/hp gain on a status effect, like giving it as part of a skill, and making so that later heals would heal for more.
The current version only works if I put in the actor notebox, so it is not very versatile.

Is there a way to apply this script to an Status Effect?

And also, it still doesn't affect mp or hp gain coming from the damage formula, only direct increases from the affects tab, so if the healing output is coming from that, the script will not effect it.
Do you think that can also be changed?

If not, this was still a lot of help, so I thank you for that.
Final Version Released!​

I consider this script is mature enough to leave it untouched from now on.
Yes guys, this means that I won't keep updating it. 😛

Original thread: https://forums.rpgmakerweb.com/threads/ace-hp-or-sp-recovery-rates.165669/