Damage formula "double condition"

Hello!


I trying to make a double condition formula from one I already using.


This is the one I already using and working: Conditon is the bold one


r=a.mat*3-b.mdf*2;x=r*b.element_rate(3);x>=1?v[16]+=v[24]:nil;r


Now I wish to add a second condition at the begining of the formula:


v[34]==1?


And this is the final formula:


v[34]==1?r=a.mat+20*3-b.mdf*2:r=a.mat+999*3-b.mdf*2;x=r*b.element_rate(3);x>=1?v[16]+=v[24]:nil;r


A total of 97 typed caracters.


I dont get error, but damage not changing with the condition.


I using exagerated value of 999 to see well if the damages change.


It takes only the "a.mat+999*3-b.mdf*2" part whatever the variable is 1 or 0.


Thanks in advance.
There are lot of scripts that change formulas, targets, add effects.


You should search one specific for your needs, maybe one word can replace your entire formula
 
The damage formula allows you to enter scripts - it's a way to avoid having to use scripts.

v[34]==1?r=a.mat+20*3-b.mdf*2:r=a.mat+999*3-b.mdf*2



I don't see anything wrong with it, but to reduce your formula length, you could change it to this, since the 20/999 is the only difference:


r=a.mat+(v[34]==1?20:999)*3-b.mdf*2


Did you retype the whole thing, or did you copy/paste from your damage formula into the post?  If you retyped it, it's possible you entered it correctly here, but have a typo in your damage formula.


Also, is that really what you want to do - multiply 20 or 999 by 3 and then add that to a.mat?  Or did you mean to add 20 or 999 to a.mat and then multiply the result by 3?  You'll need brackets around the a.mat + (20 or 999) if that's the case.
I used your reduced version and added it to the rest.

r=a.mat+(v[34]==1?20:999)*3-b.mdf*2

r=a.mat+(v[34]==1?20:999)*3-b.mdf*2;x=r*b.element_rate(3);x>=1?v[16]+=2:nil;r


It looks to works.


In fact, It was my fault. I just dicovered an useless v[34] turning to 0 somewhere in my event before the fight.


I used a v[x] cause it thing there is no short cut for $game_switches[x] ... or am I wrong?


EDIT #1: This not working:


r=a.mat+(v[54]==1?v[22]:10)*300-b.mdf*2;x=r*b.element_rate(3);x>=1?v[16]+=2:nil;r


The skill user as 17 MAG


The ennemi has 10 D.MAG


The value of v[22] = 0


I using *300 to figure out well the damage


 The damage is 0


EDIT #2 MAMAMAMAaaaa, ok ok ! This is working. Needed to add (( )):


r=(a.mat+(v[54]==1?v[22]:10))*3-b.mdf*2;x=r*b.element_rate(3);x>=1?v[16]+=2:nil;r


Thank you for your reduced version !

Original thread: https://forums.rpgmakerweb.com/threads/damage-formula-double-condition.72566/