From bf51cc2e0bac473126adc1363321abcc4db2441f Mon Sep 17 00:00:00 2001 From: "Eevee (Evelyn Woods)" Date: Mon, 25 Jan 2021 17:22:12 -0700 Subject: [PATCH] Only "mmf" once per attempted move --- js/game.js | 15 ++++++++++++++- js/main.js | 22 ---------------------- 2 files changed, 14 insertions(+), 23 deletions(-) diff --git a/js/game.js b/js/game.js index d6b42ba..ee98bf7 100644 --- a/js/game.js +++ b/js/game.js @@ -1064,7 +1064,12 @@ export class Level extends LevelInterface { // Track whether the player is blocked, both for visual effect and for doppelgangers if (actor === this.player && ! success) { - this.sfx.play_once('blocked'); + if (actor.last_blocked_direction !== actor.direction) { + // This is only used for checking when to play the mmf sound, doesn't need undoing; + // it's cleared when we make a successful move or a null decision + actor.last_blocked_direction = actor.direction; + this.sfx.play_once('blocked'); + } this._set_tile_prop(actor, 'is_blocked', true); } @@ -1357,6 +1362,10 @@ export class Level extends LevelInterface { } } + if (actor.decision === null) { + actor.last_blocked_direction = null; + } + // Remember our decision so doppelgängers can copy it this.remember_player_move(actor.decision); } @@ -1532,6 +1541,10 @@ export class Level extends LevelInterface { } } + if (actor === this.player) { + actor.last_blocked_direction = null; + } + return true; } diff --git a/js/main.js b/js/main.js index 0e92771..0d8c315 100644 --- a/js/main.js +++ b/js/main.js @@ -316,8 +316,6 @@ class SFXPlayer { for (let [name, path] of Object.entries(this.sound_sources)) { this.init_sound(name, path); } - - this.mmf_cooldown = 0; } async init_sound(name, path) { @@ -347,17 +345,6 @@ class SFXPlayer { return; } - // "Mmf" can technically play every tic since bumping into something doesn't give a movement - // cooldown, so give it our own sound cooldown - if (name === 'blocked' && this.player_x !== null) { - if (this.mmf_cooldown > 0) { - return; - } - else { - this.mmf_cooldown = 8; - } - } - let node = this.ctx.createBufferSource(); node.buffer = data.audiobuf; @@ -380,13 +367,6 @@ class SFXPlayer { gain.connect(this.compressor_node); node.start(this.ctx.currentTime); } - - // Reduce cooldowns - advance_tic() { - if (this.mmf_cooldown > 0) { - this.mmf_cooldown -= 1; - } - } } class Player extends PrimaryView { constructor(conductor) { @@ -1371,8 +1351,6 @@ class Player extends PrimaryView { this.debug.replay.set(this.level.tic_counter, input); } - this.sfx_player.advance_tic(); - // Turn-based mode is considered assistance, but only if the game actually attempts to // progress while it's enabled if (this.turn_mode > 0) {