From cb62786470acbc9a4a48ac17ed8f941cfa2cb914 Mon Sep 17 00:00:00 2001 From: "Eevee (Evelyn Woods)" Date: Thu, 3 Dec 2020 22:43:24 -0700 Subject: [PATCH] Fix yellow teleport behavior (you pick up even if it itself is not blocked); play pickup sound --- js/game.js | 18 +++++++++++++++--- js/tiletypes.js | 1 - 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/js/game.js b/js/game.js index 4db9e3d..33eed68 100644 --- a/js/game.js +++ b/js/game.js @@ -1167,6 +1167,10 @@ export class Level { if (teleporter.type.teleport_try_all_directions && dest !== teleporter) { num_directions = 4; } + // FIXME bleugh hardcode + if (dest === teleporter && teleporter.type.name === 'teleport_yellow') { + break; + } for (let i = 0; i < num_directions; i++) { if (this.attempt_step(actor, direction)) { success = true; @@ -1196,8 +1200,10 @@ export class Level { if (! success && actor.type.has_inventory && teleporter.type.name === 'teleport_yellow') { // Super duper special yellow teleporter behavior: you pick it the fuck up // FIXME not if there's only one in the level? - this.give_actor(actor, 'teleport_yellow'); - this.transmute_tile(teleporter, 'floor'); + this.attempt_take(actor, teleporter); + if (actor === this.player) { + this.sfx.play_once('get-tool', teleporter.cell); + } } } } @@ -1696,7 +1702,13 @@ export class Level { return false; if (this.give_actor(actor, tile.type.name)) { - this.remove_tile(tile); + if (tile.type.draw_layer === 0) { + // This should only happen for the yellow teleporter + this.transmute_tile(tile, 'floor'); + } + else { + this.remove_tile(tile); + } if (mod && mod.type.item_modifier === 'pickup') { this.remove_tile(mod); } diff --git a/js/tiletypes.js b/js/tiletypes.js index 144e8fe..fb6be8a 100644 --- a/js/tiletypes.js +++ b/js/tiletypes.js @@ -1053,7 +1053,6 @@ const TILE_TYPES = { draw_layer: DRAW_LAYERS.terrain, teleport_allow_override: true, teleport_dest_order(me, level, other) { - // FIXME special pickup behavior; NOT an item though, does not combine with no sign return level.iter_tiles_in_reading_order(me.cell, 'teleport_yellow', true); }, },