ACE HP or SP Recovery Rate - kyonides - 02-12-2024
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
Code: # * 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!
RE: ACE HP or SP Recovery Rate - kyonides - 02-12-2024
Maintenance Update
I suddenly forgot to change the name of the REC parameter related constants but it's been updated now.
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. So I just reintroduced it here.
RE: ACE HP or SP Recovery Rate - kyonides - 02-13-2024
Last Edition of VX ACE Port Released!
From now on, I will consider this VX ACE script feature complete.
This means that I will not be willing to modify it any further.
|