- Joined
- May 12, 2018
- Messages
- 1,889
- Reaction score
- 1,845
- First Language
- English
- Primarily Uses
- RMMV
You're trying to mix an if statement with the ternary operator in a way that I'd be legit surprised if it actually worked without throwing an error.You forgot the question mark if you're gonna use ternary notation. I believe it should look like this...someone please correct me if I'm wrong btw.
if (b.isStateAffected(47)) ? (b.addState(Math.floor(Math.random() * 9) + 60)) : (a.atk * 12) / (b.def * 5) * 0.2
Code:
// ternary
x = condition ? resultIfTrue : resultIfFalse;
// if
if (condition) doThis(); else doThisInstead();
// ternary as an if statement
condition ? doThis() : doThisInstead();
At a glance, your code is just fine. Only thing I'd add is that you don't need the parentheses in your damage formula since it's all multiplication and division:The code I posted works perfectly...though maybe it’s a fluke . In addition to the math floor statement, I’m looking to do extra damage to the monster and add one tp to the actor who used the skill if the IF statement is true. (Enemy has state 47)
Hopefully that’s not too confusing. Thanks for replying!
Code:
a.atk * 12 / b.def * 5 * 0.2
Will yield the exact same result as what you had and his less cluttery to look at. Edit: You could even remove the 5 * 0.2 part (since the result is 1) but I"m guessing you have it there because other skills of yours have other defense multipliers, so it's easier to track that way.
Last edited: