# How to set up this damage formula?

#### Milennin

##### "With a bang and a boom!"
I'm not very good with damage formulas, and this one goes beyond my knowledge with them. What I want to achieve is:

If target is affected by State A -> inflict State B. If that foe is already affected by both State A and B -> deal 50% more damage instead.

#### caethyril

##### ^_^
Untested:
JavaScript:
``````const A = 5, B = 6;  // state IDs
let r = a.atk * 4 - b.def * 2;  // damage formula
if (b.isStateAffected(A)) {
if (b.isStateAffected(B)) r *= 1.5;  // has both states => 150% damage
}
r  // output value``````
Compacted to a single line for the damage formula:
JavaScript:
``const A = 5, B = 6; let r = a.atk * 4 - b.def * 2; if (b.isStateAffected(A)) { if (b.isStateAffected(B)) r *= 1.5; else b.addState(B); }; r``
Edit the values assigned to `A`, `B`, and `r` to alter the result. These are temporary variables for convenience; they do not exist outside of the damage formula.

#### Milennin

##### "With a bang and a boom!"
Untested:
JavaScript:
``````const A = 5, B = 6;  // state IDs
let r = a.atk * 4 - b.def * 2;  // damage formula
if (b.isStateAffected(A)) {
if (b.isStateAffected(B)) r *= 1.5;  // has both states => 150% damage
}
r  // output value``````
Compacted to a single line for the damage formula:
JavaScript:
``const A = 5, B = 6; let r = a.atk * 4 - b.def * 2; if (b.isStateAffected(A)) { if (b.isStateAffected(B)) r *= 1.5; else b.addState(B); }; r``
Edit the values assigned to `A`, `B`, and `r` to alter the result. These are temporary variables for convenience; they do not exist outside of the damage formula.
Thanks. Works like a charm.

### Latest Profile Posts

Those kittens I met the other day all found loving homes. I might miss playing with them, but I'm glad they found owners to care for them. In the meantime, my Orlando trip is likely to happen on the 29th. While I wait for that, I'll be working on Angel of Justice...
I really need to work on my time management skills... I have one plot-based roleplay here, another plot-based roleplay there, I have the fangame to work on, I'm trying to get into Runescape again....