How to make this if and else statement work?

also how do i change line 5 so that its if the whole party dies the loop ends.
Thanks
the battle automatically ends if all enemies are dead or if all actors are dead, you don't need any troop event for that.

that said, you would make multiple troop events, each one for one enemy with HP=0 as condition
then have that event count up a variable and then check if however many enemies you want are dead.


A loop in this way is a very badf idea because it messes up too many things in the regular battle mechanics.
so please describe the evvect you want and we can tell you how to achieve that without a loop.
The correct syntax would be:
JavaScript:
$gameTroop.members()[0].isStateAffected(0) && $gameTroop.members()[1].isStateAffected(0);

You can also achieve the same thing by using the conditional branch on page 3 for enemies.
Enemy #1 Goblin -> State 0001 Dead

To check if everyone in the party is dead you would do:
JavaScript:
$gameParty.aliveMembers().length === 0
@ChunkyChunky The Script event command doesn't parse English words...it takes code, JavaScript.

As mentioned, it really seems like you need to provide a bit of context and explanation of what you're trying to accomplish (and what that common event does).

Just looking at this, it doesn't look like you're using the Loop correctly nor that your goal is going to work in battle.

To check if everyone in the party is dead you would do:
True, but without other plugins in play that code would never be evaluated because the battle would already have ended 😉
@ChunkyChunky The Script event command doesn't parse English words...it takes code, JavaScript.

As mentioned, it really seems like you need to provide a bit of context and explanation of what you're trying to accomplish (and what that common event does).

Just looking at this, it doesn't look like you're using the Loop correctly nor that your goal is going to work in battle.


True, but without other plugins in play that code would never be evaluated because the battle would already have ended 😉
Sorry I realised just now I should’ve given more context to it.
So the point on having the loop is because the way combat works in my game is that you have to answer questions correctly and every time you answer it correctly you get to choose between attacking or guarding, that’s what”Commen Event Addition” is and the whole point of the loop. However when testing out combat I found that even after the enemies died combat never ended and the questions kept on going because I had to use a loop so I tried to add an if statement where if either the party of enemies died the loop would bread and combat would end.
the battle automatically ends if all enemies are dead or if all actors are dead, you don't need any troop event for that.

that said, you would make multiple troop events, each one for one enemy with HP=0 as condition
then have that event count up a variable and then check if however many enemies you want are dead.


A loop in this way is a very badf idea because it messes up too many things in the regular battle mechanics.
so please describe the evvect you want and we can tell you how to achieve that without a loop.
Thanks for the idea I honestly think just having a variable that increases for every kill until it matches the total enemies if a good idea.
But if you have any better ideas please let me know, I have described my combat mechanics in the reply above, thanks.
Huh, I retract my prior statement. The BattleManager specifically checks for the end of battle after events finish. I thought it was also when battlers got refreshed.

So, the script call @TobyYasha provided will work as a check for battle to end.

The way you describe your gameplay still doesn't seem, to me, to mesh with the event you show. Do enemies not get turns? Have you replaced the entirety of the actual battle mechanics with this other loop?

If you had just described that to me and not made anything, I would've said it's simply a troop event that runs every turn (Turn 1 + 1) and you're given a question for each living actor. If it's correct, you get to take a turn with them. If the answer is wrong, they're given a state with the Cannot Move restriction.

That way you're not covering up so much of the built-in mechanics that will take care of details like this for you.
as said above, you should be using the default mechanics instead of trying to replace them.

my suggestion would be to attach two different common events to the skills attack and guard and allow them to handle your questions while the rest of the battleengine runs trough their usual turns instead of the loop.

Original thread: https://forums.rpgmakerweb.com/threads/how-to-make-this-if-and-else-statement-work.165221/