Damage formula problem.

I made a new skill, and it keeps giving me this error during playtesting:

Script 'Game_Battler' line 352: SyntaxError occurredunexpected tIDENTIFIER, expecting ':'b.state?(9) ? r = (3/4)b.hp * 2 : (3/4)b.hpWhat the skill is supposed to be doing is reducing the target's HP to a quarter of their current HP (In other words, shaving off 75% of the target's HP), regardless if they're guarding or not.

What's confusing me is that a similar damage formula that I'm using for an HP halving attack works perfectly fine:

b.state?(9) ? r = (b.hp/2) * 2 : b.hp/2What's going on?

Perhaps you guys can see something that I'm not seeing.
I see two possible problems.  You are using 3/4 = three quarters.  Computers use decimals, so that should be 0.75.  The other thing is the way you have constructed the last bit of the formula.  Try something like this.

b.state?(9) ? r = (b.hp * 0.75) * 2 : (b.hp * 0.75)
I see two possible problems.  You are using 3.4 = three quarters.  Computers use decimals, so that should be 0.75.  The other thing is the way you have constructed the last bit of the formula.  Try something like this.

b.state?(9) ? r = (b.hp * 0.75) * 2 : (b.hp * 0.75)
It works perfectly now. Thanks.

I still don't see what the problem was though, because 3/4 is a division function, meaning the computer would've gotten 0.75 anyway.

I also don't see how the last bit of the formula was constructed wrong.
In your original it was (3/4)b.hp

There is no mathematical connection between the 3/4 and the b.hp because the b.hp was outside the brackets and there was nothing to tell the computer that it should be multiplied by the result of the division inside the brackets.  Put the b.hp into the brackets with a * and the computer knows what to do with it.
In your original it was (3/4)b.hp

There is no mathematical connection between the 3/4 and the b.hp because the b.hp was outside the brackets and there was nothing to tell the computer that it should be multiplied by the result of the division inside the brackets.  Put the b.hp into the brackets with a * and the computer knows what to do with it.
That's strange, because in most other cases I've seen, multiplication is implied if a variable is next to a function enclosed by brackets or parenthesis.
Well that is the only explanation which occurs to me.  Perhaps someone more knowledgeable will pass by and give another explanation.  All I can say at the moment is: my formula works.
Yeah, the multiplication is not implied, you have to write it. The formula wont calculate decimals unless you tell it to, so in your formula 3/4 = 0.

Code:
b.state?(9) ? r = (3/4.0)*b.hp * 2 : (3/4.0)*b.hp
Rgss3 doesnt recognize (x)5 as multiplication... From the languages I've used, none of them so far does so... I do thinknits only implied in real world scenarios, not in coding.
That's strange, because in most other cases I've seen, multiplication is implied if a variable is next to a function enclosed by brackets or parenthesis.
That is only for human writing. The computer has no intuition, and I don't know a single computer language where the multiplication is implied.
Yeah I can confirm this. I had the same issue with my initial damage formula:

((2 * level + 10)/250)(a.atk/b.def)(a.atk+2)

Which I had to change to:

((2 * level + 10)/250) * (a.atk/b.def) * (a.atk+2)

and that fixed all my problems other than flooring at zero

Original thread: https://forums.rpgmakerweb.com/threads/damage-formula-problem.42602/