From efd25294ac1966bbdddea9da7aecbb6dc45499cd Mon Sep 17 00:00:00 2001 From: "Eevee (Evelyn Woods)" Date: Mon, 14 Dec 2020 17:05:01 -0700 Subject: [PATCH] Restore the notion of an out-of-turn move This fixes a lot of replay sync issues with cloners; in CC2, actors advance only one frame (1/3 tic) at a time, so when a cloned object happens to get a turn later in the same tic that it was cloned, it only ends up 1 frame ahead of everything else. Since actors can only begin moves on tic-aligned frames, even though it does get where it was going sooner, it has to wait for a frame before moving, so the advantage doesn't change anything. The problem is that LL counts movement in tics, not frames, so that kind of bonus turn puts the clone an entire tic ahead which can gum things up. This is still not perfect, but it's much closer. --- js/game.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/js/game.js b/js/game.js index 82b6634..28ccaee 100644 --- a/js/game.js +++ b/js/game.js @@ -564,7 +564,7 @@ export class Level { if (! actor.cell) continue; - if (actor.movement_cooldown > 0) { + if (actor.movement_cooldown > 0 && actor.cooldown_delay_tic !== this.tic_counter) { this._set_tile_prop(actor, 'movement_cooldown', Math.max(0, actor.movement_cooldown - 1)); if (actor.movement_cooldown <= 0) { @@ -1078,7 +1078,13 @@ export class Level { // FIXME delete this attempt_out_of_turn_step(actor, direction) { - return this.attempt_step(actor, direction); + if (this.attempt_step(actor, direction)) { + this._set_tile_prop(actor, 'cooldown_delay_tic', this.tic_counter); + return true; + } + else { + return false; + } } // Move the given actor to the given position and perform any appropriate