The data class for damage.
The type of damage.
The element ID.
The formula.
The degree of variability.
Critical hit (true/false).
Determines whether the damage type is [None]. Returns true if the value of type is 0.
Determines whether there is an effect on HP. Returns true if the value of type is 1, 3, or 5.
Determines whether there is an effect on MP. Returns true if the value of type is 2, 4, or 6.
Determines whether there is recovery. Returns true if the value of type is 3 or 4.
Determines whether there is draining. Returns true if the value of type is 5 or 6.
The damage sign. Returns -1 if recovery, otherwise returns 1.
Evaluates the formula. The action-side battler, target-side battler, and in-game variable array ($game_variables) are specified by a, b, and v, respectively.
Returns a negative value if recovery.
class RPG::UsableItem::Damage def initialize @type = 0 @element_id = 0 @formula = '0' @variance = 20 @critical = false end def none? @type == 0 end def to_hp? [1,3,5].include?(@type) end def to_mp? [2,4,6].include?(@type) end def recover? [3,4].include?(@type) end def drain? [5,6].include?(@type) end def sign recover? ? -1 : 1 end def eval(a, b, v) [Kernel.eval(@formula), 0].max * sign rescue 0 end attr_accessor :type attr_accessor :element_id attr_accessor :formula attr_accessor :variance attr_accessor :critical end