Healing over time, damage over time
Thu, 05 Jun 2008 12:24:23 +0000 - Author: Peter O.
The script below is for RPG Maker VX.
The following script implements "healing over time". Put it in the Materials section of the script editor. For each state that includes this healing effect, add the note "[HealingState: X]" where X is the amount of HP that the state recovers each turn. (Don't include the quotation marks. Example: [HealingState: 40]) X can also be a percentage, for example: [HealingState: 15%] . Also implements "damage over time". Similar to "healing over time", but reduces HP instead. Each state that has this ability should have the note [DamageOverTime: X] where X is the amount of HP to subtract and can be a number or a percentage.
The following script implements "healing over time". Put it in the Materials section of the script editor. For each state that includes this healing effect, add the note "[HealingState: X]" where X is the amount of HP that the state recovers each turn. (Don't include the quotation marks. Example: [HealingState: 40]) X can also be a percentage, for example: [HealingState: 15%] . Also implements "damage over time". Similar to "healing over time", but reduces HP instead. Each state that has this ability should have the note [DamageOverTime: X] where X is the amount of HP to subtract and can be a number or a percentage.
class Game_Battler
def setHPDamage(amount)
@missed=false
@evaded=false
@hp_damage=amount
@mp_damage=0
@absorbed=false
execute_damage(nil)
end
end
class Scene_Battle
alias :petero_healingStates_turn_end :turn_end
@@_HealingStates=nil
@@_DamageOverTime=nil
def turn_end
if @@_HealingStates==nil
@@_DamageOverTime={}
@@_HealingStates={}
for dataState in $data_states
next if !dataState
dataState.note.gsub!(/\[HealingState\:\s*(\d+)\]/i){
@@_HealingStates[dataState.id]=$1.to_i; next ""
}
dataState.note.gsub!(/\[HealingState\:\s*(\d+)%\]/i){
@@_HealingStates[dataState.id]=-($1.to_i); next ""
}
dataState.note.gsub!(/\[DamageOverTime\:\s*(\d+)\]/i){
@@_DamageOverTime[dataState.id]=$1.to_i; next ""
}
dataState.note.gsub!(/\[DamageOverTime\:\s*(\d+)%\]/i){
@@_DamageOverTime[dataState.id]=-($1.to_i); next ""
}
end
end
for battler in $game_party.members + $game_troop.members
damage=0
for state in @@_HealingStates.keys
if battler.state?(state)
amt=@@_HealingStates[state]
if amt<0
damage-=battler.maxhp*(-amt)/100
else
damage-=amt
end
end
end
if damage!=0
battler.setHPDamage(damage)
display_damage(battler)
display_state_changes(battler)
wait(25)
end
damage=0
for state in @@_DamageOverTime.keys
if battler.state?(state)
amt=@@_DamageOverTime[state]
if amt<0
damage+=battler.maxhp*(-amt)/100
else
damage+=amt
end
end
end
if damage!=0
battler.setHPDamage(damage)
display_damage(battler)
display_state_changes(battler)
wait(25)
end
end
petero_healingStates_turn_end
end
end