Hello, I'm trying to get a damage formula for my attacks and skills but it won't read it and keeps nullifying damage dealt to enemies.
The formula I'm trying to use is:
a.atk+(a.level/10)^2-(b.def*0.88)
I've also tried spacing it out, like:
a.atk + ( a.level / 10 ) ^ 2 - ( b.def * 0.88 )
Any suggestions?
I think the problem there is the ^ operator. From the VX Ace Help:
"...You can use the four arithmetic operators (+, -, *, and /) in your formulas..."
So, check if this works:
a.atk+(a.level/10)*(a.level/10)-(b.def*0.88)
Also, blank spaces shouldn't matter in the formulas - it's up to you use them or not 😀
If ^ is supposed to be the power operator, you may use ** instead.
^ is used for 'bitwise exclusive disjunction', which is rarely used in damage formulas.
Edit: In this case, Khas' solution would also be perfectly fine of course.
If you're still getting a Null error wrap the formula up in parenthesis' and add .to_i to the end of the statement. The Null may be due to the fact that it's returning a float instead of an integer.
It could take floats... it only nulls if the return is 0, a non-number that wouldn't have a number counterpart or if the formula has errors.
Thanks everyone for the help! 😀
Sorry that I don't create a new topic for my question (because it's about damage formula as well).
First of all, my Ruby language is ver very limited. I have read the tutorial here and tried to create my own default formula. Here is mine;
def base_dmg(a, 😎 #I don't even fully understand why needs (a, 😎 here - -"
c=a.atk/2-b.def/4 #for my raw damage
d=c/16+1 #for damage range (I set variance = 0)
if c=>1; (c-d..c+d).to_a.sample; elsif c<=0; rand(10)<5;1;else;0;end;end
I put a.base_dmg(a, 😎 in the formula box.
It works perfectly for me. So I try to make a new default formula for "magic" by creating new def (something like def base_mdmg(a, 😎 ) and changing a.atk/b.def to a.mat/b.mdf and the rest of formula is the same. Put a.base_mdmg(a, 😎 in the formula box. This time the damage when use magic skill is always Null.
EDIT: Finally I tried to add .to_i after c and it works now!!