- Joined
- Nov 2, 2016
- Messages
- 2
- Reaction score
- 0
- First Language
- English
- Primarily Uses
Due to my damage formula being complicated and not fitting in the editor text box, I've created methods for the damage formulas in the script. They've worked exactly as intended.
I have decided that, rather than a critical hit being a multiplier on the final damage, I would have it multiply the damage inflicted before defensive stats are factored in. I knew that whether a critical was scored was determined before the damage formula was calculated from prior testing, so I thought using "@result.critical" as the base scripts do, as in the code that factors in the critical multiplier—
value = apply_critical(value) if @result.critical
—would work perfectly fine. So this is the script for the (physical) damage formula with the code for critical damage added:
def calc_phys(b)
a = self
damage = a.atk ** 0.500 * 2 / 3 * a.xstat.dam
damage *= (1.00 + a.luk * 0.01) if @result.critical
reduce = 1.000 - (b.def ** 0.900 * 0.01)
damage = damage * reduce - b.xstat.abs
return damage
end
However, "@result.critical" does not work here. The formula will only do standard damage when a critical hit is scored. The multiplier works if the "if @result.critical" is removed.
What is the issue here, and if I cannot use "@result.critical" here, how can I work around this?
I have decided that, rather than a critical hit being a multiplier on the final damage, I would have it multiply the damage inflicted before defensive stats are factored in. I knew that whether a critical was scored was determined before the damage formula was calculated from prior testing, so I thought using "@result.critical" as the base scripts do, as in the code that factors in the critical multiplier—
value = apply_critical(value) if @result.critical
—would work perfectly fine. So this is the script for the (physical) damage formula with the code for critical damage added:
def calc_phys(b)
a = self
damage = a.atk ** 0.500 * 2 / 3 * a.xstat.dam
damage *= (1.00 + a.luk * 0.01) if @result.critical
reduce = 1.000 - (b.def ** 0.900 * 0.01)
damage = damage * reduce - b.xstat.abs
return damage
end
However, "@result.critical" does not work here. The formula will only do standard damage when a critical hit is scored. The multiplier works if the "if @result.critical" is removed.
What is the issue here, and if I cannot use "@result.critical" here, how can I work around this?


