I want to add a guaranteed critical hit if a player/battler is affected by state.
I figure it will be in the damage formula for the Attack skill, and I have a rough idea of how it should look. Would anyone mind correcting the below? I imagine it would look something like this, but I know I am missing parts of the syntax.
If b.state = 11 then critical hit = 100% | a.atk * 4 - b.def *2
Thanks!!
b.state would mean the target of the attack has the state, not the user. For the user to have the state in the calculation, use a.state.
I'm at work and can't test but something like this perhaps?
c = a.atk * 4 - b.def *2; a.isStateAffected(11) ? c*2 : c
edit:
a.isStateAffected(11) if you want to check the user of the skill for state 11
b.isStateAffected(11) if you want to check the target of the skill for state 11
b.isStateAffected(11) ? (a.atk * 4 - b.def *2 )*2 : a.atk * 4 - b.def *2
I've had to play around with damage formula logic a bit to get things you'd think should work to work. Likely my inexperience haha anywho, try the above. It's essentially the same thing just written out more. If that doesn't work, I'll give it a few spins when I get home in a few hours.
Yeah, that was essentially what I changed it to earlier. It does do the extra damage, it just doesn't register as a critical hit (changing the color of the text, etc.), so the player would see the additional damage, but not make the connection that it is a crit.
I looked at that, but I think it works as a buff and not a debuff. Meaning, if I set a notetag on sleep to set the critical rate at say 999% to ensure a critical, then I would need to be under the effect of asleep to get the change in critical rate.
I'll give it a try and see if I can adjust it.
We are so close!
I get the critical hit in regards to it changing the color, but it only does normal damage.
Edit*
I understand the basic concepts of programming, so I understand that ?: is the equivalent of an if/then statement. I think that ; ends a statement and starts a new one?
I am not 100% sure of where the critical gets it's value. I know that the critical damage is * 3.
Maybe it derives it's value from the dmg formula so we should set it first?
Sidenote, in case anyone is testing it. The state is actually 10, I incorrectly set it as 11 in the first post.
That did indeed work!
I did think about the negative critical evasion, but I think that skill is set to dodge critical hits.
Edit* I tested it by setting CEV to - 999% on the Sleep state and every hit was still a normal hit.
BUT that gave me an idea. I went back and used your formula that was providing the color change but still doing base damage, and added 300% physical damage to the Sleep state. By doing so I was able to get the red text, deal 300% damage and ensure as not to get double criticals!
I really appreciate both of you helping me solve this issue!!
If you have the action sequence and critical control plugins from Yanfly (the latter requires the Damage Core), there's an action sequence command to "force critical". Using "if target.isStateAffected(10)" (10 is the default ID for Sleep) before it will check for your target to have the sleep state then guarantee a critical hit.
Sorry for the bump, but I was just wrestling w/ this problem myself today and figured out a simple solution that also resolves the double critical issue.
It requires Yanfly's Critical Control plugin, which of course also requires his Damage Core plugin. Here's the code:
<Critical Rate Formula>
if (target.isStateAffected(73)) {
rate = 1;
}
</Critical Rate Formula>
My state ID was 73, you should obviously change it to w/e suits your needs.