[RESOLVED] Prevent Common Event from Executing during Battle

I've created an item (Lantern Oil) that you can use any time outside of battle. It starts an eight minute timer. I have this common event running in parallel at all times:
apsRaBT.jpg

This common event, again, is running in parallel, so that any time the timer hits 0, the plugin command executes (from Terrax Lighting, eliminating the light radius from the lantern), a sound effect plays, a switch is flipped off (excuse my language), and the timer vanishes.

The problem is, when I am in battle and the timer runs out, I am pulled out of battle and back onto the overworld screen, whereupon the plugin command and everything else executes. You can see I attempted to work around this by using a conditional branch with a script command that's supposed to check if the player is in battle, and if it's true, nothing happens, but no dice.

If all else fails I guess I could just make the timer stop when the player enters battle, but I kinda like the idea of the lantern running dry in real time during battle.

Thank you in advance for any help!
This has nothing to do with common events, and everything to do with the timer.

Common events do not run in battle, unless you use the Common Event command itself, or have a common event attached to an item or skill.

The timer DOES continue to count down during battle, and if it hits 0, the battle will end.

Because common events only run on the map, your condition to see if the game party is in battle is meaningless - there will never be a battle underway when that condition is checked, because you will have already been pulled out of battle and back on the map.

Create a new .js file in your plugins folder - call it anything you want - and put these lines in it:
Code:
Game_Timer.prototype.onExpire = function() {
};

That will stop the timer causing the battle to abort.

If you also want to pause the timer while you're in battle, add this to the same file as well:
Code:
var _Shaz_Game_Timer_update = Game_Timer.prototype.update;
Game_Timer.prototype.update = function(sceneActive) {
  if (!$gameParty.inBattle()) {
    _Shaz_Game_Timer_update.call(this, sceneActive);
  }
};

Then add it to your plugin manager.
That works perfectly. Thank you!
Thread closed IgnoreMe

Original thread: https://forums.rpgmakerweb.com/threads/resolved-prevent-common-event-from-executing-during-battle.91032/