Struggling with battle scripts.

Ok I am a complete newbie at and utter suck at it.

I've written a small if statement to whether a character and an enemy have a certain state on board then the regular attack does more damage, however I want it to check for multiple states and the dmg formula box doesn't have that much space.

This is the code I wrote.

If (a.isStateAffected(21) == b.isStateAffected(21)) {a.atk*8-b.def*2} else {a.atk*4-b.def*2}

21 is a passive state just used as a designator. I want to do it for multiple states and I'm not sure how to do it. As said before the formula box is too small and I don't know how to call it from a common event, a script or even put it in the notetags correctly.

Can someone please help.
The damage formula box has pretty much unlimited space. It's just that you can only see a small portion at a time.

You can reduce the space your condition takes by using the ? : format rather than if/else:

a.isStateAffected(21) && b.isStateAffected(21) ? a.atk*8 - b.def*2 : a.atk*4 - b.def*2

Also, your condition is not checking if they both have state 21. It's checking if they both have the state, OR if they both DON'T have the state.


If you want the same formula to be applied for multiple states, if the attacker and the target both have the state, it would be something like this:

[21, 22, 23, 24, 25].some(function (st) { return a.isStateAffected(st) && b.isStateAffected(st); }) ? (a.atk*8 - b.def*2) : (a.atk*4 - b.def*2)

Just not sure if I've got the syntax right there.
Thanks I'll give it a try.
Seems to work, haven't encountered any issues yet, thank you so much.
My suggestion is to definitely write and or copy paste the formula on an editor so you can see it all.

I personally keep a spreadsheet of formulas since I have a few different skill and item formulas.

Original thread: https://forums.rpgmakerweb.com/threads/struggling-with-battle-scripts.94336/