Damage formula help.

Hi there I'm trying to set a skill up so that it does significantly more damage if a target is effected by a certain state. However the skill just seems to do zero damage. I can only think I must be making some kind of syntax error but for the life of me the syntax appears correct. This is a cut and paste from my damage formula box .. I would appreciate any help.

if b.isStateAffected(20) {a.atk * 8} else {a.atk * 1}
If you only want it to be like that, just change to this:
b.isStateAffected(20) ? a.atk * 8 : a.atk * 1
Thank you .. that worked. I'm guessing the arguments are condition ? yes:no?
That's right. For a complex one, you might need to use if-then. You can take a look HERE for some more examples about Damage Formula.
Another question if you don't mind. I'm trying to create an assassination skill that does X damage for every negative state on the enemy. Can I include multiple formula in one box? I tried using common events. But since you can't designate an in combat target with a common event conditional it won't work.

I basically just need some way to make the game count the number of states on the target. Either within the damage formula. Or just output it to a variable. I tried this

(b.isStateAffected(4) ? r = a.atk 5: r = a.atk * 1) + (b.isStateAffected(8) ? r = a.atk 5: r = a.atk * 1) + (b.isStateAffected(9) ? r = a.atk 5: r = a.atk * 1)

Just for 3 states and it doesn't work.
I guess you cannot do that. I think i have another method for you, but this is a bit complicated.
If you are using Yanfly's Buffs & States Core plugin, you can also use this State Categories plugin: http://yanfly.moe/2016/04/03/yep-89-state-categories/

The State Categories Plugin provides you a way to group many states into one using this note tag <Category: text>. For example, i group all negative states into 1 called "Ailment", so i put this note tag in every single negative state: <Category: Ailment>

This plugin also provides you a function to return the number of categorized states: battler.getStateCategoryAffectedCount('text');

So if you want to return the number of negative states that is categorized in "Ailment" group and is currently affecting your target, put this in your damage formula:
b.getStateCategoryAffectedCount('Ailment')

For example, the damage is equal to your ATK * number of negative states on target, the damage formula should be: a.atk * b.getStateCategoryAffectedCount('Ailment')

I haven't tested this yet so i can't guarantee that it will work.
@JamesRyan
Moderator note: Please do not use red or blue text in your posts as those colors are reserved for mod use
Scratch that post .. I think you just might have found my solution! .. I'm going to do some more testing .. But I think this is it!!

Testing complete .. the principle is sound. This completely works! Thank you ever so much!
@JamesRyan
Moderator note: Please do not use red or blue text in your posts as those colors are reserved for mod use

Sorry i just wanted to highlight texts. Gonna use other colors next time.

Original thread: https://forums.rpgmakerweb.com/threads/damage-formula-help.79146/