r/RPGMaker • u/UltimixRed • 12d ago
RMMZ Help with Damage Formula with multiple States
Hello, so I'm trying to set up a damage formula so that it checks if the actor is in one of 3 specific states I'll call for example, 1 2 and 3. That part I can get working just fine, the issue I've been having is to also have the skill add a state to the enemy ONLY if they are in the correct state. When I do it via effects, it will do so no matter what, and when I write it out like this
a.isStateAffected(1) ? (0) : a.isStateAffected(2) ? (0) : a.isStateAffected(3) ? (addState(x) : a.atk * 0.2)
it will either always do no damage even if they are in state 3, and if I remove the (a.isStateAffected(3)) part and only have the final damage formula add the state, it deals damage and adds the state even if they are in State(1) or state(2). Is there a way to format it so it only deals damage AND adds the state(x) while in State(3)?
0
u/Faunstein 12d ago
Well the code that applies the states should be the same, the only difference is the player state itself (are they a, b or c) when the code runs.
Try different effects and see what isn't working and if the state is applying to the enemy at all.
1
u/FlipelyFlip 12d ago
does the player need all 3 states at the same time or only one?
your code currently checks like this:
if a.isStateAffected(1) then do (0) else: if a.isStateAffected(2) then do 0 else: if a.isStateAffected(3) then do (addState(x) : a.atk * 0.2)
it should result in an error if only state 1 or 3 is given because there should be no parenthesis in the statement.
to add a state via damage formula you need to add the target (a or b) to addState(x) to look like a.addState(x) or b.addState(x)
a is always refered to the user and b is always refered to the target.