Only "mmf" once per attempted move

This commit is contained in:
Eevee (Evelyn Woods) 2021-01-25 17:22:12 -07:00
parent b87ce730f2
commit bf51cc2e0b
2 changed files with 14 additions and 23 deletions

View File

@ -1064,7 +1064,12 @@ export class Level extends LevelInterface {
// Track whether the player is blocked, both for visual effect and for doppelgangers // Track whether the player is blocked, both for visual effect and for doppelgangers
if (actor === this.player && ! success) { 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); 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 // Remember our decision so doppelgängers can copy it
this.remember_player_move(actor.decision); 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; return true;
} }

View File

@ -316,8 +316,6 @@ class SFXPlayer {
for (let [name, path] of Object.entries(this.sound_sources)) { for (let [name, path] of Object.entries(this.sound_sources)) {
this.init_sound(name, path); this.init_sound(name, path);
} }
this.mmf_cooldown = 0;
} }
async init_sound(name, path) { async init_sound(name, path) {
@ -347,17 +345,6 @@ class SFXPlayer {
return; 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(); let node = this.ctx.createBufferSource();
node.buffer = data.audiobuf; node.buffer = data.audiobuf;
@ -380,13 +367,6 @@ class SFXPlayer {
gain.connect(this.compressor_node); gain.connect(this.compressor_node);
node.start(this.ctx.currentTime); node.start(this.ctx.currentTime);
} }
// Reduce cooldowns
advance_tic() {
if (this.mmf_cooldown > 0) {
this.mmf_cooldown -= 1;
}
}
} }
class Player extends PrimaryView { class Player extends PrimaryView {
constructor(conductor) { constructor(conductor) {
@ -1371,8 +1351,6 @@ class Player extends PrimaryView {
this.debug.replay.set(this.level.tic_counter, input); 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 // Turn-based mode is considered assistance, but only if the game actually attempts to
// progress while it's enabled // progress while it's enabled
if (this.turn_mode > 0) { if (this.turn_mode > 0) {