How to set up this damage formula?

Milennin

"With a bang and a boom!"
Veteran
Joined
Feb 7, 2013
Messages
2,511
Reaction score
1,642
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
2,089
Reaction score
1,508
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,511
Reaction score
1,642
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: 0, Guests: 1)

Latest Threads

Latest Profile Posts

Couple hours of work. Might use in my game as a secret find or something. Not sure. Fancy though no? :D
Holy stink, where have I been? Well, I started my temporary job this week. So less time to spend on game design... :(
Cartoonier cloud cover that better fits the art style, as well as (slightly) improved blending/fading... fading clouds when there are larger patterns is still somewhat abrupt for some reason.
Do you Find Tilesetting or Looking for Tilesets/Plugins more fun? Personally I like making my tileset for my Game (Cretaceous Park TM) xD
How many parameters is 'too many'??

Forum statistics

Threads
105,867
Messages
1,017,062
Members
137,575
Latest member
akekaphol101
Top