Game closing with no error message.

Hello. In my game there is an enemy who you can fight multiple times (it never truly gets destroyed). If you defeat it, it disappears temporarily until you rest. Then it reappears. This has been controlled using switches.

When you first fight the enemy, there is absolutely no problem with the running of the game. But when you rest and then fight a second time or third time, the game often closes.

This is inconsistent. Often it closes, sometimes it doesn't. When it does, it loads the battle, displays the enemy and then shuts down before the windows are displayed. There is no error code and going into the script editor to find the offending line does not yield a consistent result (once it looked like it was a problem with displaying the sprite, once it looked like a problem drawing the window, today nothing.)

I have tried reducing the amount of eventing attached to the game object by moving some of it into common events that are called. I have also tried making the sprite transparent and 'throughable' rather than switching on and off. This has never happened on any of my other projects before, although I've never created an enemy that can be fought multiple times like this before. I am happy to supply any further detail but if someone can at least shine a light on what is going wrong, I would really appreciate it!
there are only two ways to close the game without an error message:
1) if it is closed by an external program like an antivirus
2) if you give the script command to close the game

you need to give us screenshots of the enemy event(s) if you want help with checking the second option.
the first option is on your computer but outside the project, you need to check the logs of all your protection and security programs (there are more than just your official antivirus)
Many thanks my friend. I have taken the object events as well as the troop events. I can share the common events too, if needed, but I haven't because the game is closing before any of them are called.

Yes, I know that the object eventing is convoluted but it's because I was trying to fix this error.

I can't see anything out of the ordinary so if you can then muchos muchos gracias.
So you are turning switches on. Where or what do those switches affect?
44 and 27.
There is a common events called what do they do?
Switch 27 skips the battle aftermath. https://forums.rpgmakerweb.com/index.php?threads/disabling-victory-aftermath.146828/#post-1268589 I'm using Yanfly's victory aftermath script (https://yanflychannel.wordpress.com/rmvxa/battle-scripts/victory-aftermath/) to disable the fanfare/exp/loot, etc. because after the battle the relevant common event ("14: Win VS Mummy" or "15: Lose VS Mummy") is called, which uses pictures to make a results screen.

Switch 44 controls a conditional branch in a common event (pictured). This is used to add an additional effect to a skill when used against this specific enemy (because the fire burns away the bandages and causes the enemy to transform).
perhaps I should explain the second part of my answer above in a bit more detail:
2) if you give the script command to close the game

No regular event command can close the game that way, only scripts and script commands can do this.
The question for the event screenshots was to see if you have anything in there that uses or triggers script commands. And that went to the switches to check what they trigger because there are no script commands in your screenshots.

and while switches can trigger scripts and other effects, it is rarely the script where you intentionally placed them.
best guess so far would be that one of those switches is used without your knowledge in some other script.
so basically you have to go through all your scripts and check everyone of them for use of switches and variables. This is best done from scratch by making a new list of all switch and variable assignments in all your scripts without any crosschecking during that listing, and only after you got everything you compare it to what you believed those switches do (and check their naming etc then).
Gotcha. Thanks.

Can I at least assume that the problem will NOT be with the default scripts, but rather with the ones I have imported?

Also, will it be a case of simply checking the configuration modules of those scripts, or will I have to go through the entirety of each one, coding sections and all?
Can I at least assume that the problem will NOT be with the default scripts, but rather with the ones I have imported?
yes - no default script ever used switches or variables.
they never had a need, because all the flags and values were placed into the database itself.

but external scripters have no way to change the database, that is the reason why they invented notetags and use switches and variables for interaction.
Okay, I've done that. I went through and did searches for "switch" and "variable" on all imported scripts. I only looked at the modules and recorded the ones where a switch >0 was bound to a function. Yes, there are indeed some which are incorrectly bound (screenshot attached) but none that I can that are active at this point in the project and none that (as far as I can see) would order the game to close.

My next step is going to be to remove the scripts one at a time and try to replicate the problem to isolate which one is causing the error.

One thing that is interesting, though: the fault is inconsistent. It never occurs on the first time the enemy is fought on any particular session (i.e. if the game is saved and loaded, the fault never occurs, even if the enemy has been defeated once already.) It is always on at least the second time fighting the enemy in any particular session. And the game closes at the same point. i.e. just before the command window displays.

However, the occurance is inconsistent. I just tried to replicate it and the first time it crashed on the 4th battle, then the 2nd, and then not even after 7. If you have any thoughts on this, I would be very grateful to hear them.
there is another thing you should do before disabling all the scripts one after another:
compare how many lines each script has in the editor to the number of lines it has in its original download.

one of the possible causes for a close without an error message is if the function iterations went wrong due to a missing close of one script - and it is easy to miss on copy&paste if you made a mistake and missed the last end on the last line or something like that, especially since most scripts have multiple end lines.

and comparing the number of lines is the quickest way to find out if there was such a copy&paste error.
I've seen the RGSS3-player being kicked by Windows into nirvana without any hint what has happened so many times I could never count.

My guess I can tell from experience with this frustrating behaviour is that at least one of the added scripts in the game maybe has a few edge-cases where it's accessing object-instances that get killed too early while their code still hangs somewhere like e.g. in the callstack.

I can't say for sure, but on my end, this problem occurs way less often since I carefully reordered many of my own processes that involve terminating and disposing objects. If the custom-code in your project is not your own, it may be an even worse task to solve this (if it even was what has helped).

~炬燵あ

Original thread: https://forums.rpgmakerweb.com/threads/game-closing-with-no-error-message.146986/