[Solved] Preventing Common Event Call Overflow

Status
Not open for further replies.

Nekohime1989

Nekohime
Veteran
Joined
May 31, 2014
Messages
498
Reaction score
226
First Language
English
Primarily Uses
RMMZ
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.
 
Last edited:
Status
Not open for further replies.

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

Couple hours of work. Might use in my game as a secret find or something. Not sure. Fancy though no? :D
Holy stink, where have I been? Well, I started my temporary job this week. So less time to spend on game design... :(
Cartoonier cloud cover that better fits the art style, as well as (slightly) improved blending/fading... fading clouds when there are larger patterns is still somewhat abrupt for some reason.
Do you Find Tilesetting or Looking for Tilesets/Plugins more fun? Personally I like making my tileset for my Game (Cretaceous Park TM) xD
How many parameters is 'too many'??

Forum statistics

Threads
105,862
Messages
1,017,050
Members
137,571
Latest member
grr
Top