RMMZ How to check if all monsters in any given combat are dead.

Clyve

Veteran
Veteran
Joined
Aug 6, 2013
Messages
62
Reaction score
7
First Language
English
Primarily Uses
RMMV
Anyone know of a way to get a conditional branch to check if all enemies in a battle are dead? Basically, I'm using Visu's CTB battle system and have an image to support the CTB gauge and status areas and I can't figure out how to get it to disappear when all monsters are dead. I've thrown a bunch of conditional branches in the first troop (since the plugins apply all events of troop 1 to all troops) to go down the list if enemy a is dead + b is dead + c is dead, but I'm not sure it runs properly because there's not always 8 enemies.

So if there's a way to do a script call or whatever it would take in order to check if all enemies are dead and erase the image, that would be the best way to solve it I think. The image stays on screen and conflicts with the victory aftermath.
 

DawnStar

Star of Hope
Veteran
Joined
Nov 25, 2020
Messages
44
Reaction score
52
First Language
Spanish
Primarily Uses
RMMV
Use this script as the condition:
Code:
$gameTroop.isAllDead()
 

gstv87

Veteran
Veteran
Joined
Oct 20, 2015
Messages
2,343
Reaction score
1,366
First Language
Spanish
Primarily Uses
RMVXA
don't event the image.
use the scene's own code, or the CTB code.
every battle system is scripted to it's own scene, which takes care of opening windows and refreshing gauges.
IT must have a block that loads or unloads all images. Hook up your image there.
 

Clyve

Veteran
Veteran
Joined
Aug 6, 2013
Messages
62
Reaction score
7
First Language
English
Primarily Uses
RMMV
Use this script as the condition:
Code:
$gameTroop.isAllDead()

Thanks! :D

Can't get this to function in the troop events, however. Checking at the end of turn for the entire battle with this set as a conditional to erase picture 1 doesn't erase it :/
 
Last edited:

Clyve

Veteran
Veteran
Joined
Aug 6, 2013
Messages
62
Reaction score
7
First Language
English
Primarily Uses
RMMV
don't event the image.
use the scene's own code, or the CTB code.
every battle system is scripted to it's own scene, which takes care of opening windows and refreshing gauges.
IT must have a block that loads or unloads all images. Hook up your image there.

Is this possible to do with their obfuscated code?
 

ATT_Turan

Forewarner of the Black Wind
Veteran
Joined
Jul 2, 2014
Messages
725
Reaction score
386
First Language
English
Primarily Uses
RMMV
Thanks! :D

Can't get this to function in the troop events, however. Checking at the end of turn for the entire battle with this set as a conditional to erase picture 1 doesn't erase it :/
The last enemy dying automatically ends the battle, it doesn't get to/process end of turn that turn.

The usual workaround for that is to make enemies/the troops immortal, then have page events that check for their HP to be <= 0, kill them off and then run a common event that will check for the entire troop to be empty and turn off your picture.
 

Clyve

Veteran
Veteran
Joined
Aug 6, 2013
Messages
62
Reaction score
7
First Language
English
Primarily Uses
RMMV
The last enemy dying automatically ends the battle, it doesn't get to/process end of turn that turn.

The usual workaround for that is to make enemies/the troops immortal, then have page events that check for their HP to be <= 0, kill them off and then run a common event that will check for the entire troop to be empty and turn off your picture.

Hmm, alright. I tried it with a common event run in parallel first which was to run a conditional to check if all troops were dead then erase, but it didn't seem to process it during the battle. Immortal troops sounds really cumbersome, but I'll do that if there's no better way.
 

ATT_Turan

Forewarner of the Black Wind
Veteran
Joined
Jul 2, 2014
Messages
725
Reaction score
386
First Language
English
Primarily Uses
RMMV
Well, the better way would be to figure out where to add it into the plugin's code, as gstv87 suggested. This is the simpler way.

If you want to see an explanation:
 

Clyve

Veteran
Veteran
Joined
Aug 6, 2013
Messages
62
Reaction score
7
First Language
English
Primarily Uses
RMMV
Well, the better way would be to figure out where to add it into the plugin's code, as gstv87 suggested. This is the simpler way.

If you want to see an explanation:

Right, ideally I'd like to just run $gameScreen.clearPictures(); in the victory aftermath plugin, but when I put that in there it chokes on itself.
 

gstv87

Veteran
Veteran
Joined
Oct 20, 2015
Messages
2,343
Reaction score
1,366
First Language
Spanish
Primarily Uses
RMVXA
Is this possible to do with their obfuscated code?
probably.

start by the end and work backwards: the closing block should be the one that disposes all the windows.
find a bunch of ".dispose" or ".close" or whatever, tied to objects that start up as sprites, and that should give you a reference.
obfuscated code is meant to make it harder to find things by meaningful names..... but *the sprite that gives meaning and function to the whole thing* will always be there, because otherwise there would be no thing to give meaning and function to.

find a scene from the vanilla code and look at it's structure, it's always the same, because all scenes are the same object Scene, with their innards modified by overrides.
 

Clyve

Veteran
Veteran
Joined
Aug 6, 2013
Messages
62
Reaction score
7
First Language
English
Primarily Uses
RMMV
I solved it by putting $gameScreen.clearPictures(); in the managers.js in the checkBattleEnd area. Seems to play well with the Visu plugins so all is well now :D

Thanks to the both of you.
 

gstv87

Veteran
Veteran
Joined
Oct 20, 2015
Messages
2,343
Reaction score
1,366
First Language
Spanish
Primarily Uses
RMVXA
not the ideal solution, unless you alias that through Visu's work.
if you added that call through Visu's own code and not the vanilla code, it'll be fine as long as there are no other pictures that get cleared by it when they don't have to.
if that's an edit to the vanilla code, it could conflict with other calls to render pictures.

all in all, this approach is much better than eventing the picture to show up, which is the top-most layer of the stack.
 

Clyve

Veteran
Veteran
Joined
Aug 6, 2013
Messages
62
Reaction score
7
First Language
English
Primarily Uses
RMMV
not the ideal solution, unless you alias that through Visu's work.
if you added that call through Visu's own code and not the vanilla code, it'll be fine as long as there are no other pictures that get cleared by it when they don't have to.
if that's an edit to the vanilla code, it could conflict with other calls to render pictures.

all in all, this approach is much better than eventing the picture to show up, which is the top-most layer of the stack.
I tried putting it in various spots in both the battle manager and victory aftermath plugins, but it just kills both of them with an error.
 

gstv87

Veteran
Veteran
Joined
Oct 20, 2015
Messages
2,343
Reaction score
1,366
First Language
Spanish
Primarily Uses
RMVXA
probably because neither grabs the screen.... IDK.
the point is, the instruction exists, to remove the picture from the screen.
if you add and remove the picture by eventing, you'll have problems when the removal of that picture isn't available because the scene changes through another route.
if you instead task the scene to take care of it, IT will always perform the cleanup because all scenes work the same, and scenes handle their own structure, which doesn't require a *screen* (object)
the problem in this case is adding the instruction before or after the execution of the add-on that is Visu's plugin, which runs separately.
IT must run as if there was no editing, mind your editing when shutting down, run your code, and then return control to the vanilla code. How exactly to do that? I don't know, it depends on Visu's code, not yours. If it's a mess, you can still figure it out because the instructions are always the same, even if they're not named the same.
 

Shaz

Global Moderators
Global Mod
Joined
Mar 2, 2012
Messages
41,879
Reaction score
14,525
First Language
English
Primarily Uses
RMMV

I've moved this thread to Plugin Support. Please be sure to post your threads in the correct forum next time. Thank you.

 

Clyve

Veteran
Veteran
Joined
Aug 6, 2013
Messages
62
Reaction score
7
First Language
English
Primarily Uses
RMMV
[move]Plugin Support[/move]
I wasn't looking for support on a plugin, I was looking for a script call within RPG Maker itself to verify that a condition had been met and a general script command is what fixed the issue.

Not sure if you want to move it back since people might have this issue in general since it's not specific to plugins.
 

Shaz

Global Moderators
Global Mod
Joined
Mar 2, 2012
Messages
41,879
Reaction score
14,525
First Language
English
Primarily Uses
RMMV
I moved it here because you were talking about a specific battle system that you're using, so it would need to be done within the confines of that battle system. By default, troop events won't run after the last enemy has been killed, unless you go with the method mentioned of setting enemies to immortal. There are plugins that will get around that, but maybe the one you're using already has that ability.
 

Latest Threads

Latest Posts

Latest Profile Posts

Today *Fix the game UI
RMMZ maxRows make me tired.
The game supports real-time language switching (really interesting).
8laFKAa.png


jBYDFzZ.png


lYbvPth.png

mY99lgU.png

Swag collecting in the new randomly generated area. Now the mini map also shows the randomly generated features... And even illustrates the whole "bubble" system" that I made to manage memory... Though that part's inadvertent. We'll just call that "the fog of war"... Yes, that's what we'll do. Nobody will be the wiser! :kaopride:
not me being not lazy for 5 seconds and drawing another char portrait (her name is hazel)
its_hazel.png
Been a while since the last time I made a song remix. Had a blast making this
One thing those jp developer still get wrong about boob physic is that... men's muscly hard pecs can jiggle too.

Forum statistics

Threads
110,454
Messages
1,053,443
Members
143,542
Latest member
Back-AlleySnowman
Top