class Game_Battler
#--------------------------------------------------------------------------
# * Damage Limit
# syntax - [minimum, maximum] or nil for no limit
#--------------------------------------------------------------------------
Damage_Limit = [-9999, 9999]
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_accessor :damage_limit_enabled
#--------------------------------------------------------------------------
# * Initialize
#--------------------------------------------------------------------------
alias_method :trick_limits_battler_initialize, :initialize
def initialize
# The Usual
trick_limits_battler_initialize
# Set Damage limit flag
@damage_limit_enabled = false
end
#--------------------------------------------------------------------------
# * Attack Effect
#--------------------------------------------------------------------------
alias_method :trick_limits_battler_attack_effect, :attack_effect
def attack_effect(*args)
# Set Damage Limit Enabled Flag
@damage_limit_enabled = true
# The Usual
trick_limits_battler_attack_effect(*args)
# Return True
return true
end
#--------------------------------------------------------------------------
# * Skill Effect
#--------------------------------------------------------------------------
alias_method :trick_limits_battler_skill_effect, :skill_effect
def skill_effect(*args)
# Set Damage Limit Enabled Flag
@damage_limit_enabled = true
# The Usual
effective = trick_limits_battler_skill_effect(*args)
# Return Effective Flag
return effective
end
#--------------------------------------------------------------------------
# * Item Effect
#--------------------------------------------------------------------------
alias_method :trick_limits_battler_item_effect, :item_effect
def item_effect(*args)
# Set Damage Limit Enabled Flag
@damage_limit_enabled = true
# The Usual
effective = trick_limits_battler_item_effect(*args)
# Return Effective Flag
return effective
end
#--------------------------------------------------------------------------
# * Set Hp (Damage Limit)
#--------------------------------------------------------------------------
alias_method :trick_limits_battler_hp=, :hp=
def hp=(hp)
# Get old hp and
old_hp, new_hp = self.hp, hp
# If Damage is A Number and Difference is damage
if (self.damage.is_a?(Numeric) and old_hp - new_hp == self.damage and
@damage_limit_enabled and not Damage_Limit.nil?)
# Get Damage
n = self.damage
# Set New Damage
damage_hp = [[n, Damage_Limit[0]].max, Damage_Limit[1]].min
# Set Hp
self.trick_limits_battler_hp = old_hp - damage_hp
# Set Damage
self.damage = damage_hp
else
# The usaul
self.trick_limits_battler_hp = hp
end
# Reset Damage Enabled Flag
@damage_limit_enabled = false
end
end