Creating an "if" statement formula that applies damage and a state?

Papillon

Veteran
Veteran
Joined
Feb 22, 2017
Messages
60
Reaction score
8
First Language
English
Primarily Uses
RMMV
Hi there.
I'm currently trying to create a damage formula which checks if an enemy has a state and applies damage and a another state depending on if it's applied.
Problem is it always returns 0 damage so long as addState is in the code.
I've tried
Code:
if ( b.isStateAffected(40) ) { a.atk * 1.25; b.addState(41); } else { a.atk * 0.75; }
and
Code:
b.isStateAffected(40) ? b.addState(41) ; a.atk * 1.25: a.atk * 0.75
and different variations of these but they always return 0 damage.
Can anyone point out what I'm doing wrong?
 

Poryg

Dark Lord of the Castle of Javascreeps
Veteran
Joined
Mar 23, 2017
Messages
4,125
Reaction score
10,637
First Language
Czech
Primarily Uses
RMMV
That's because return value of an eval is the return value of last legit code. Meaning that if b is affected by the state, the damage is equal to 0, because addState doesn't have any return value.

As for the second thing, that's just wrong, because
premise ? happenIfTrue : happenIfFalse
accepts only one line, so you can't use ; there.
 
Last edited:

Papillon

Veteran
Veteran
Joined
Feb 22, 2017
Messages
60
Reaction score
8
First Language
English
Primarily Uses
RMMV
That's because return value of an eval is the return value of last legit code. Meaning that if b is affected by the state, the damage is equal to 0, because addState doesn't have any return value.

As for the second thing, that's just wrong, because
premise ? happenIfTrue : happenIfFalse
accepts only one line, so you can't use ; there.
I knew I was doing something completely wrong. Is what I'm trying to do possible, or would this be something I'd have to get a plugin for?
Normally I'd just apply the state with the Effects menu but that would just allow the attack to apply both the state while still doing the lower damage.
Also sorry for the sloppy coding. I haven't touched Javascript in quite a while.
 

Poryg

Dark Lord of the Castle of Javascreeps
Veteran
Joined
Mar 23, 2017
Messages
4,125
Reaction score
10,637
First Language
Czech
Primarily Uses
RMMV
The first case should work, just swap the state add with the damage calculation in the true case.
 

Papillon

Veteran
Veteran
Joined
Feb 22, 2017
Messages
60
Reaction score
8
First Language
English
Primarily Uses
RMMV
The first case should work, just swap the state add with the damage calculation in the true case.
Bloody hell I'm stupid.
It works now.
Thank you for the help!
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

Was stressing about this plugin earlier, but pretty happy with how its looking now! Purple makes it pop more too!! :)
A friend requested me to do a pfp for his twitch channel, so far he approved one of my sketches, so going to digital now. The style he's looking for is quite different from my usual, hopefully I can get it right... :kaoback:
I am so hyped! A new post update and im anxious to see reactions..eeeeeeee
When a youtuber plays your project or game made by you using MAKERs, you will just be awe struck

Forum statistics

Threads
105,478
Messages
1,014,005
Members
137,117
Latest member
Deli
Top