MV Damage formula problem

Hey Game makers I'm a a problem where my damage formula is not doing what I want it to.
Here's the code

b.elementRate(13) > 1 ? b.addState(9); 100
It's not adding rhe state and only doing 0 damage.
Please help.
what is the element rate for the target? How many elements does your game have?
you should also try >= instead of >

And as an additional info: if any part of the javascript in a damage formula returns any error, the engine will default to 0 - even if it is a typo or similat.
what is the element rate for the target? How many elements does your game have?
you should also try >= instead of >

And as an additional info: if any part of the javascript in a damage formula returns any error, the engine will default to 0 - even if it is a typo or similat.
1 target, element rate is 150, and I want to add state 9 if the target is weak to element 13 and do 100 damage


.
Wait, you want to add the damage AND the state?

I think it can only do one of them. I'd suggest you put the state in the "effects" tab (unless there's a particular reason it needs to go there) and leave the damage by itself.

Also, you need to put something else to happen if the conditions aren't met. Like dealing 1 damage or something. You separate both statements with a :. Like this:

b.elementRate(13) > 1 ? 100 : 1
Wait, you want to add the damage AND the state?

I think it can only do one of them. I'd suggest you put the state in the "effects" tab (unless there's a particular reason it needs to go there) and leave the damage by itself.

Also, you need to put something else to happen if the conditions aren't met. Like dealing 1 damage or something. You separate both statements with a :. Like this:

b.elementRate(13) > 1 ? 100 : 1
Want I want is for the state to be applied only if the target is weak to the element and for it to do damage at the same time.
Oh, right. Then I'd say the main problem would be the "else" part of the formula. Have you tried adding it?
The format of your ternary statement is incorrect. It's question mark then colon, but you have a semicolon which indicates the end of a code statement in JavaScript.

Want I want is for the state to be applied only if the target is weak to the element and for it to do damage at the same time.
Then you're doing the wrong thing entirely. A ternary statement is "if-else" - it will only ever do one of the things.

If you want to apply the state conditionally, then simply use "if." Then if the damage is done either way, it's its own statement. So:
Code:
if (b.elementRate(13)>1) b.addState(9); 100

Note that if you're using the auto battle trait anywhere or if this skill is given to enemies, adding a state in the damage formula is not a good idea because it may result in targets getting the state without actually having the skill executed on them.

It would be better to use something like Yanfly's Skill Core and put it into a Pre-Damage Eval notetag.
The format of your ternary statement is incorrect. It's question mark then colon, but you have a semicolon which indicates the end of a code statement in JavaScript.


Then you're doing the wrong thing entirely. A ternary statement is "if-else" - it will only ever do one of the things.

If you want to apply the state conditionally, then simply use "if." Then if the damage is done either way, it's its own statement. So:
Code:
if (b.elementRate(13)>1) b.addState(9); 100

Note that if you're using the auto battle trait anywhere or if this skill is given to enemies, adding a state in the damage formula is not a good idea because it may result in targets getting the state without actually having the skill executed on them.

It would be better to use something like Yanfly's Skill Core and put it into a Pre-Damage Eval notetag.
Note taken. Thanks for the help.

Original thread: https://forums.rpgmakerweb.com/threads/damage-formula-problem.155847/