Heya, I'm having trouble with a formula. (honestly i dont even know what half the stuff does. I still dont know what
; means, and what
: means)
Im making a formula that makes
C the same as the
targets mp.
then it makes a formula based on
C, and assigns it to
D. (I plan to change the targets MP before the damage goes out)
so it checks the
mp, damages the
mp, and then does
hp damage to that target, based on the mp they had before they just lost the mp in this very same attack.
but i only wanted it to deal mp damage, IF the target had a state on them.
so i wrote the formula like this
c=b.mp; d=a.atk-b.def-c; if (b.isStateAffected(21)) b.gainMp(-d); d; else a.atk - b.def
the weird thing is, not only does it not work, dealing only 0 dmg, but when broken down into a simpler formula, taking 1 step out, every step works.
for example, if i remove the if stateAffected part out, the target loses mp, and loses hp just fine.
so b.gainMp(-d); d; works as is. If i remove the b.gainMp part out, and go with if (b.isStateAffected(21)) d; else a.atk - b.def it works as is, and deals dmg based on the targets mp with the state, but does normal dmg w/o the state.
if i use the if statement to check the state, and deal mp damage, but no hp dmg, it works just fine as well. if (b.isStateAffected(21)) b.gainMp(-d); else a.atk - b.def
but all 3? it stops functioning.
i can only assume i need something that tells it to do 2 actions under the same if statement. like a sort of "this & this"; else this
FINAL EDIT: I figured it out. When doing if statements, you can NOT do 2 things. example, you cant apply a buff, a debuff, and do dmg. you can do only ONE thing after an if statement. (idk why) but in the else part, you can do as many multiple things as you want.
so i changed the formula to simply have
if(!b.isStateAffected where the "normal" formula happens after the
if(! but the actual 2 things i want to happen, due to the buff, happen in the "else"
So it currently looks like
c=b.mp; d=a.atk-b.def-c; if (!b.isStateAffected(21)) a.atk - b.def; else b.gainMp(-a.atk-b.def); d
(I think theres a small error, but this mostly works now, ill fine tune details later)
This is technically all thanks to the following user, despite them not knowing it.
I feel like I asked this question a couple years ago, but couldn't find the answer and couldn't find it in a regular search...
How do I make a damage formula with more than one condition? In other words there are 3 cases...
If a.agi > (b.agi * 2) then do normal damage formula * 2
if b.agi > (a.agi * 2) then do normal damage formula * 0.5
if neither of these are true, then just do the normal damage formula
I believe someone said the answer to this is
If(x){ if(y){a} else{b} }else{
c}
but its more to do with the "else". correct me if im wrong.
With the above ex you have 3 possible outcomes, 2
false, and 1
true. (
b,
c, and
a)
so in your question youre looking to see if ppl meet an agi number, but im saying to instead look to see if they fail it twice. if they fail both checks, you get normal dmg (true), and if they meet the checks, they reach the 2 different else (false)
so something like
if(fails equation1){ if(fails equation2){normal dmg} else{ * 0.5 dmg} }else{*2 dmg}
Also, thanks for asking this question, because the solution to this question, ended up being the solution to my own problem. I just had to invert what the if question was asking.