Parallel events each have their own interpreter separate from the main one. However, all interpreters are updated via the main
game loop that Andar mentions, which originates in the SceneManager. This calls the current scene's update function, which may call its own, specialised, update functions. For example, for events the call chain goes through rpg_scenes.js and rpg_objects.js, something like:
Spoiler
- Scene_Map
- update
- updateMainMultiply
- updateMain
- Game_Map
- Game_Event
So, if you want something on the map to update every frame, you can alias the event
update routine. I haven't tested it, but maybe this example will show vaguely what I mean:
Spoiler
Code:
(function() {
'use strict';
const ACCEL = 'accelTime'; // Property names...
const DECEL = 'decelTime'; // ...for ease of maintenance
const ACCELMAX = 4; // Accel up to
const DECELMIN = 3; // Decel down to
const TIMER = 6; // Frame delay between call & speed change
const ALTER = 0.5; // Move speed increment/decrement
// For script calls, init appropriate countdown property for move speed adjustment
mapEventAccelerate = function(eventId) { $gameMap.event(eventId)[ACCEL] = TIMER; };
mapEventDecelerate = function(eventId) { $gameMap.event(eventId)[DECEL] = TIMER; };
// Alias of event update routine, adds speed adjustment after usual update stuff
var _Game_Event_update = Game_Event.prototype.update; // local alias
Game_Event.prototype.update = function() { // override
_Game_Event_update.call(this); // callback
if (this[ACCEL] !== undefined) { // is accelerating?
if (this[ACCEL]-- <= 0) { // decrement, check for zero
this._moveSpeed += ALTER; // increment move speed
if (this._moveSpeed >= ACCELMAX) { // has reached target speed?
this._moveSpeed = ACCELMAX; // cap at max
delete this[ACCEL]; // remove property
} else {
mapEventAccelerate(this.eventId()); // call accelerate again
}
}
} else if (this[DECEL] !== undefined) { // is decelerating?
if (this[DECEL]-- <= 0) { // decrement, check for zero
this._moveSpeed -= ALTER; // etc
if (this._moveSpeed <= DECELMIN) {
this._moveSpeed = DECELMIN;
delete this[DECEL];
} else {
mapEventDecelerate(this.eventId());
}
}
}
};
})();
/// script call usage examples:
// mapEventAccelerate(5);
// mapEventDecelerate(31);