@result.critical not working?

Maxim

Warper
Member
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?
 

mlogan

Global Moderators
Global Mod
Joined
Mar 18, 2012
Messages
15,370
Reaction score
8,547
First Language
English
Primarily Uses
RMMV
I've moved this thread to Learning RGSS. Please be sure to post your threads in the correct forum next time. Thank you.
 
Last edited by a moderator:

Engr. Adiktuzmiko

Chemical Engineer, Game Developer, Using BlinkBoy'
Veteran
Joined
May 15, 2012
Messages
14,682
Reaction score
3,003
First Language
Tagalog
Primarily Uses
RMVXA
How did you know that you are indeed making a critical hit?


Right now what I'm sure of is that the code runs and doesn't encounter an error because if it does, your damage formula will return 0 (coz that's how it was designed, instead of showing the error it just makes the damage as 0). That means that it is indeed able to check @result.critical but seemingly it always returns false for your tests. 
 
Last edited by a moderator:

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Profile Posts

Frostorm wrote on Featherbrain's profile.
Hey, so what species are your raptors? Any of these?
... so here's my main characters running around inside "Headspace", a place people use as a safe place away from anxious/panic related thinking.
Stream will be live shortly! I will be doing some music tonight! Feel free to drop by!
Made transition effects for going inside or outside using zoom, pixi filter, and a shutter effect
I have gathered enough feedback from a few selected people. But it is still available if you want to sign up https://forums.rpgmakerweb.com/index.php?threads/looking-for-testers-a-closed-tech-demo.130774/

Forum statistics

Threads
105,992
Messages
1,018,189
Members
137,771
Latest member
evoque
Top