[Solved] Preventing Common Event Call Overflow

Code:
Game_Interpreter.prototype.checkOverflow = function() {
    if (this._depth >= 100) {
        throw new Error('Common event calls exceeded the limit');
    }
};

So this is how I have my function set up.
Code:
Game_Player.prototype.updateParams = function() {
    var index=null;
    var despairEnd=false;
    var insanityEnd=false;
    var hungerEnd=false;
    if ($gameUnit.deadMembers().length > 0) {
        $gameSwitches.setValue(Tamamo.Params.SoulSwitch, true);
    }
    HungerTimer+=1;
    if(HungerTimer===3600){
        HungerTimer=0;
    }
    for (var i = 0; i < 4; i++) {
        actor = $gameParty.actors[i].actorId;
        //hungertimer
        if(HungerTimer===0){
            $gameParty.actors[i].gainMp(-1);
            var shorthand =index+Tamamo.Params.HungerVariable;
            if($gameParty.actors[i].mp===0){
                $gameVariables.setValue($gameVariables.value(shorthand)+1);
                $gameParty.actors[i].gainMp($gameParty.actors[i].mmp);
            }
        }
        //dead ends
        //despair
        if($gameVariables.value(index+Tamamo.Params.DespairVariable)===1000) {
            despairEnd=true;
        }
        //insanity
        else if($gameVariables.value(index+Tamamo.Params.InsanityVariable)===1000) {
            insanityEnd=true;
        }
        //hunger
        else if($gameVariables.value(index+Tamamo.Params.HungerVariable)===4) {
            hungerEnd=true;
        }
    }
    if (despairEnd) $gameSwitches.setValue(Tamamo.Params.DespairSwitch, true);
    if (insanityEnd) $gameSwitches.setValue(Tamamo.Params.InsanitySwitch, true);
    if (hungerEnd) $gameSwitches.setValue(Tamamo.Params.HungerSwitch, true);
}

This function is called every frame and manages permadeath conditions for characters. However the common events are all Called with switches. four total.
Basically I want to prevent any of these four common events from being called until one finishes. Do to the per frame basis. They would wind up stacking. And exceed the 100 limit. 60 frames = 1 second. So give it 4 seconds. And boom it explodes if enough of the conditions are met each frame that it runs. The function is called in Game_Player.update() btw.

Basically they have a limit of one. leaving space for the other common events the game might need.

How can I do this?

edit: updated the code with the correct way of doing it.
Thread closed IgnoreMe

Original thread: https://forums.rpgmakerweb.com/threads/solved-preventing-common-event-call-overflow.105415/