Gentlemans, during combat, damage with elements is calculated incorrectly.
I changed the Game_battler item_element_rate so that while the attribute effectiveness coefficient was being calculated, conditions were being added/removed from me.
But when I entered battle, conditions were being added/removed, but the damage of my attribute-based skills didn't change on targets with attribute effectiveness.
I added lines so that the values were written to game_variables, but that didn't help me figure out the problem.
Because after looking at the variables, I saw that
variable 17 = 0.0
variable 18 = 0
variable 19 = 800
variable 20 = 800.0
even though variable 20 should be 0 and damage 0 when the expression value *= item_element_rate(user, item) was executed, where item_element_rate(user, item) is 0.
Help me find the error. PLZ
UPD
I noticed that the lines value *= pdr if item.physical? and value *= mdr if item.magical? don't change the value regardless of the value. It's as if the value doesn't change at all and the damage is dealt according to the formula.
I changed the Game_battler item_element_rate so that while the attribute effectiveness coefficient was being calculated, conditions were being added/removed from me.
Ruby:
def item_element_rate(user, item)
$game_variables[15] = user.features_set(FEATURE_ATK_ELEMENT)
$game_variables[16] = item.damage.element_id
$game_variables[17] = element_rate(item.damage.element_id)
case item.damage.element_id
when 7 #earth
result = user.atk_elements.empty? ? 1.0 : elements_max_rate(user.atk_elements)
if state?(29)
add_state(33)
remove_state(29)
end
if state?(30)
add_state(26)
remove_state(30)
else
remove_state(26)
end
return result
when 3 #fire
result = user.atk_elements.empty? ? 1.0 : elements_max_rate(user.atk_elements)
if state?(27)
add_state(31)
remove_state(27)
end
if state?(32)
add_state(28)
remove_state(32)
else
remove_state(28)
end
return result
when 4 #frost
result = user.atk_elements.empty? ? 1.0 : elements_max_rate(user.atk_elements)
if state?(28)
add_state(32)
remove_state(28)
end
if state?(31)
add_state(27)
remove_state(31)
else
remove_state(27)
end
return result
when 8 #air
result = user.atk_elements.empty? ? 1.0 : elements_max_rate(user.atk_elements)
if state?(26)
add_state(30)
remove_state(26)
end
if state?(33)
add_state(29)
remove_state(33)
else
remove_state(29)
end
return result
else element_rate(item.damage.element_id)
end
$game_variables[18] = result
end
Ruby:
def make_damage_value(user, item)
value = item.damage.eval(user, self, $game_variables)
$game_variables[19] = value
value *= item_element_rate(user, item)
$game_variables[20] = value
value *= pdr if item.physical?
value *= mdr if item.magical?
value *= rec if item.damage.recover?
value = apply_critical(value) if @result.critical
value = apply_variance(value, item.damage.variance)
value = apply_guard(value)
$game_variables[21] = value
@result.make_damage(value.to_i, item)
end
Because after looking at the variables, I saw that
variable 17 = 0.0
variable 18 = 0
variable 19 = 800
variable 20 = 800.0
even though variable 20 should be 0 and damage 0 when the expression value *= item_element_rate(user, item) was executed, where item_element_rate(user, item) is 0.
Help me find the error. PLZ
UPD
I noticed that the lines value *= pdr if item.physical? and value *= mdr if item.magical? don't change the value regardless of the value. It's as if the value doesn't change at all and the damage is dealt according to the formula.