Struggling with battle scripts.

Ladysmaell

Villager
Member
Joined
Dec 2, 2015
Messages
9
Reaction score
1
First Language
English
Primarily Uses
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.
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,108
Reaction score
13,713
First Language
English
Primarily Uses
RMMV
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.
 

Ladysmaell

Villager
Member
Joined
Dec 2, 2015
Messages
9
Reaction score
1
First Language
English
Primarily Uses
Thanks I'll give it a try.
 

Ladysmaell

Villager
Member
Joined
Dec 2, 2015
Messages
9
Reaction score
1
First Language
English
Primarily Uses
Seems to work, haven't encountered any issues yet, thank you so much.
 

Sekunri

Creator of Worlds
Veteran
Joined
Jan 12, 2014
Messages
132
Reaction score
75
First Language
English
Primarily Uses
RMMV
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.
 

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

Latest Threads

Latest Profile Posts

Day 9 of giveaways! 8 prizes today :D
He mad, but he cute :kaopride:

Our latest feature is an interview with... me?!

People4_2 (Capelet off and on) added!

Just beat the last of us 2 last night and starting jedi: fallen order right now, both use unreal engine & when I say i knew 80% of jedi's buttons right away because they were the same buttons as TLOU2 its ridiculous, even the same narrow hallway crawl and barely-made-it jump they do. Unreal Engine is just big budget RPG Maker the way they make games nearly identical at its core lol.

Forum statistics

Threads
106,040
Messages
1,018,476
Members
137,824
Latest member
dobratemporal
Top