From fc1f85dac9bdcb5df6e5f2a8d712727a407f9635 Mon Sep 17 00:00:00 2001 From: "Eevee (Evelyn Woods)" Date: Tue, 11 May 2021 16:31:28 -0600 Subject: [PATCH] Fix Lynx force floor compat switch; ensure monsters can't turn in traps --- js/defs.js | 4 ++-- js/game.js | 15 ++++++++++----- js/tiletypes.js | 21 +++++++++++++-------- 3 files changed, 25 insertions(+), 15 deletions(-) diff --git a/js/defs.js b/js/defs.js index b7dc6a4..c084464 100644 --- a/js/defs.js +++ b/js/defs.js @@ -181,8 +181,8 @@ export const COMPAT_FLAGS = [ label: "Player can't override backwards on a force floor", rulesets: new Set(['lynx']), }, { - key: 'force_floor_only_on_arrive', - label: "Force floors only affect actors when stepped on", + key: 'force_floors_inert_on_first_tic', + label: "Force floors don't trigger on the first tic", rulesets: new Set(['lynx', 'ms']), }, { key: 'traps_like_lynx', diff --git a/js/game.js b/js/game.js index eae1b56..7a4a508 100644 --- a/js/game.js +++ b/js/game.js @@ -837,13 +837,13 @@ export class Level extends LevelInterface { // only be made every third frame _advance_tic_lynx60() { this._do_decision_phase(true); - this._do_combined_action_phase(1, true); + this._do_combined_action_phase(1); this._do_post_actor_phase(); this._do_wire_phase(); this.frame_offset = 1; this._do_decision_phase(true); - this._do_combined_action_phase(1, true); + this._do_combined_action_phase(1); this._do_post_actor_phase(); this._do_wire_phase(); @@ -869,7 +869,7 @@ export class Level extends LevelInterface { let is_decision_frame = this.frame_offset === 2; this._do_decision_phase(! is_decision_frame); - this._do_combined_action_phase(1, ! is_decision_frame); + this._do_combined_action_phase(1); this._do_post_actor_phase(); this._do_wire_phase(); @@ -996,7 +996,7 @@ export class Level extends LevelInterface { } // Lynx's combined action phase: each actor attempts to move, then cools down, in order - _do_combined_action_phase(cooldown, forced_only = false) { + _do_combined_action_phase(cooldown) { for (let i = this.actors.length - 1; i >= 0; i--) { let actor = this.actors[i]; if (! actor.cell) @@ -1332,7 +1332,7 @@ export class Level extends LevelInterface { return null; if (! terrain.type.get_slide_direction) return null; - if (! actor.is_pending_slide && ! (terrain.type.slide_automatically && ! this.compat.force_floor_only_on_arrive)) + if (! (actor.is_pending_slide || terrain.type.slide_automatically)) return null; if (actor.ignores(terrain.type.name)) return null; @@ -1525,6 +1525,11 @@ export class Level extends LevelInterface { // go back into the trap. this is consistent with CC2 but not ms/lynx return; } + if (this.compat.traps_like_lynx && terrain.type.name === 'trap') { + // Lynx traps don't allow actors to turn even while open; instead they get ejected + // during their idle step + return; + } if (actor.type.decide_movement) { direction_preference = actor.type.decide_movement(actor, this); } diff --git a/js/tiletypes.js b/js/tiletypes.js index 745d06a..fb8868c 100644 --- a/js/tiletypes.js +++ b/js/tiletypes.js @@ -60,13 +60,13 @@ function _define_force_floor(direction, opposite_type) { slide_automatically: true, allow_player_override: true, get_slide_direction(me, level, other) { + if (level.compat.force_floors_inert_on_first_tic && level.tic_counter === 0) { + // Lynx: Force floors don't push on the first tic + return null; + } return direction; }, force_floor_direction: direction, - on_arrive(me, level, other) { - // Necessary for compat.force_floor_only_on_arrive, which disables slide_automatically - level._set_tile_prop(other, 'is_pending_slide', true); - }, activate(me, level) { level.transmute_tile(me, opposite_type); }, @@ -983,16 +983,16 @@ const TILE_TYPES = { speed_factor: 2, allow_player_override: true, get_slide_direction(me, level, _other) { + if (level.compat.force_floors_inert_on_first_tic && level.tic_counter === 0) { + // Lynx: Force floors don't push on the first tic + return null; + } return level.get_force_floor_direction(); }, blocks(me, level, other) { return (level.compat.rff_blocks_monsters && (other.type.collision_mask & COLLISION.monster_typical)); }, - on_arrive(me, level, other) { - // Necessary for compat.force_floor_only_on_arrive, which disables slide_automatically - level._set_tile_prop(other, 'is_pending_slide', true); - }, }, slime: { layer: LAYERS.terrain, @@ -1528,6 +1528,11 @@ const TILE_TYPES = { level.attempt_out_of_turn_step(other, other.direction); } }, + on_stand(me, level, other) { + if (level.compat.traps_like_lynx) { + level.attempt_out_of_turn_step(other, other.direction); + } + }, add_press_ready(me, level, other) { // Same as below, but without ejection level._set_tile_prop(me, 'presses', (me.presses ?? 0) + 1);