That's actually in the original - those two last lines are the original function
😉
There are a few logical errors in that code - there's no point in checking if
$gameMap.event(this.eventId()) is valid, because there couldn't be a
this.eventId() otherwise.
It also doesn't make much sense to check for the event name to include Timeless and have an empty code block afterward - just reverse the conditional to check for it to
not include Timeless.
I don't immediately see how this would break encounters, but I think I would do this at a higher level. And if literally the only thing you're doing is incrementing a counter, why don't you just do that instead of calling an entire other common event?
Code:
Game_Interpreter.prototype.terminate = function() {
if (this.eventId() && !$gameMap.event(this.eventId()).event().name.includes("<Timeless>"))
$gameVariables.setvalue(42, $gameVariables.value(42) + 1);
this._list = null;
this._comments = "";
};
where 42 is the ID of the variable you're counting up.
It broke encounters because of some weird interaction with visustella it turns out. So I ended up moving the code somewhere else (I guess visustella needs to re-write the terminate code; So I move my code to the only function that invokes terminate). Then encountered the problem where events that map transfered the player would break the code utterly, because of course all my code would happen after the map transfer and used the map to set the id, so I ended up with this (Where i have to manually set a flag whenever i do a map transfer to ignore that event... which is not ideal... but at least it works)
Game_Interpreter.prototype.executeCommand = function() {
const command = this.currentCommand();
if (command) {
this._indent = command.indent;
const methodName = "command" + command.code;
if (typeof this[methodName] === "function") {
if (!this[methodName](command.parameters)) {
return false;
}
}
this._index++;
} else {
if ($gameSwitches.value(12))
{
$gameSwitches.setValue(12, false);
}
else
{
if ($gameMap.event(this.eventId()) != null)
{
if ($gameMap.event(this.eventId()).event().name.includes("<Timeless>") )
{
}
else
{
$gameMessage.add($gameMap.event(this.eventId()).event().name );
$gameTemp.reserveCommonEvent(2);
}
}
}
this.terminate();
}
return true;
};
Writing down this mostly for future knowledge in case someone googles this lol.
I will now try to integrate your version of the code in the new location and adding the map transfer failsafe, as yours definitelly looks better. Thanks
🙂
Ah, that said the reason why i don't increment the counter in-code, is that I eventually want to add other stuff to that common event (namely doing things depending on the counter's value, like playing cut-away cutscenes), so a common event is probably best for this use.