State Categories (YEP)

Hi I'm trying to set up a damage formula based on the amount of states that the target has, and damage caps at 5 States..

This is the code I've been trying but it just hits 0s 🙁

<Damage Formula> var state = battler.getStateCategoryAffectedCount('ailment'); if (state === 1) { value = a.luk * 4 - b.luk * 2 } if (state === 2) { value = a.luk * 5 - b.luk * 2 } if (state === 3) { value = a.luk * 6 - b.luk * 2 } if (state === 4) { value = a.luk * 7 - b.luk * 2 } if (state >== 5) { value = a.luk * 8 - b.luk * 2 } else if (state === 0) { value = a.luk * 3 - b.luk * 2 } </Damage Formula>
The problem is either the way I'm writing it, or the battler. is checking the current actor and not the enemy, can I do .target?

EDIT: I forgot to show my skill window how silly of me I apologize here it is:

1681416444272.png


I put 0 in the damage because that's what other skills with damage formula note tags tell me to do that as well, as it follows the note tags.
Code:
var state = battler.getStateCategoryAffectedCount('ailment');
There's no such variable as "battler" - you need to use an actual reference to one of the battlers. Per the instructions in Damage Core, your options are "user" and "target". (you can also probably use "a" and "b", but that's not explicitly stated in the instructions)

This is why you're getting a result of 0, you're doing math with an undefined variable.

Code:
if (state === 1) {
value = a.luk * 4 - b.luk * 2
}
if (state === 2) {
value = a.luk * 5 - b.luk * 2
}
if (state === 3) {
value = a.luk * 6 - b.luk * 2
}
if (state === 4) {
value = a.luk * 7 - b.luk * 2
}
if (state >== 5) {
value = a.luk * 8 - b.luk * 2
}
else if (state === 0) {
value = a.luk * 3 - b.luk * 2
}
This is all super over complicated. Just use some math here.

Code:
<damage formula>
var state = Math.min(target.getStateCategoryAffectedCount('ailment'), 5);
value = user.luk * (3 + state) - target.luk * 2;
</damage formula>

I put 0 in the damage because...
I'm not sure where you saw these "other skills" but that doesn't matter. Per the Damage Core instructions, the notetag will completely overwrite whatever (if anything) is typed into the actual damage formula box.
There's no such variable as "battler" - you need to use an actual reference to one of the battlers. Per the instructions in Damage Core, your options are "user" and "target". (you can also probably use "a" and "b", but that's not explicitly stated in the instructions)

This is why you're getting a result of 0, you're doing math with an undefined variable.


This is all super over complicated. Just use some math here.

Code:
<damage formula>
var state = Math.min(target.getStateCategoryAffectedCount('ailment'), 5);
value = user.luk * (3 + state) - target.luk * 2;
</damage formula>


I'm not sure where you saw these "other skills" but that doesn't matter. Per the Damage Core instructions, the notetag will completely overwrite whatever (if anything) is typed into the actual damage formula box.
Wow I made this very confusing... so I CAN replace battler with target, that is perfect! and you showed me how to make a condensed version of the massive block of code I tried to write 😅 Thanks for that! You are literally the best I cannot thank you enough for this!
Thread closed

Original thread: https://forums.rpgmakerweb.com/threads/state-categories-yep.156641/