How to set up this damage formula?

Milennin

"With a bang and a boom!"
Veteran
Joined
Feb 7, 2013
Messages
2,486
Reaction score
1,621
First Language
English
Primarily Uses
RMMV
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

^_^
Veteran
Joined
Feb 21, 2018
Messages
1,916
Reaction score
1,362
First Language
EN
Primarily Uses
RMMZ
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
  else b.addState(B);  // has A, not B => add B
}
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!"
Veteran
Joined
Feb 7, 2013
Messages
2,486
Reaction score
1,621
First Language
English
Primarily Uses
RMMV
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
  else b.addState(B);  // has A, not B => add B
}
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. :D
 

Users Who Are Viewing This Thread (Users: 1, Guests: 1)

Latest Threads

Latest Posts

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....

Forum statistics

Threads
104,231
Messages
1,004,874
Members
135,753
Latest member
thedan95
Top