From 1e02c6aa6f94bfa8aef94df50cdff151546eae29 Mon Sep 17 00:00:00 2001 From: "Eevee (Evelyn Woods)" Date: Wed, 22 Dec 2021 22:30:59 -0700 Subject: [PATCH] Complete the pgchip ice block emulation (fixes #34) --- js/defs.js | 3 +-- js/game.js | 2 +- js/tiletypes.js | 28 ++++++++++++++++++++++------ 3 files changed, 24 insertions(+), 9 deletions(-) diff --git a/js/defs.js b/js/defs.js index f6eca18..8648aea 100644 --- a/js/defs.js +++ b/js/defs.js @@ -246,8 +246,7 @@ export const COMPAT_FLAGS = [ label: "Pulling blocks with the hook happens at decision time", rulesets: new Set(['steam', 'steam-strict']), }, { - // FIXME this is kind of annoying, there are some collision rules too - key: 'tanks_teeth_push_ice_blocks', + key: 'use_pgchip_ice_blocks', label: "Ice blocks emulate pgchip rules", rulesets: new Set(['ms']), }, { diff --git a/js/game.js b/js/game.js index 84d5c1d..8f4c485 100644 --- a/js/game.js +++ b/js/game.js @@ -1631,7 +1631,7 @@ export class Level extends LevelInterface { return false; if (actor.can_push(tile, direction, this) || ( - this.compat.tanks_teeth_push_ice_blocks && tile.type.name === 'ice_block' && + this.compat.use_pgchip_ice_blocks && tile.type.name === 'ice_block' && (actor.type.name === 'teeth' || actor.type.name === 'teeth_timid' || actor.type.name === 'tank_blue') )) { // Collect pushables for later, so we don't inadvertently push through a wall diff --git a/js/tiletypes.js b/js/tiletypes.js index 960b287..c7b5458 100644 --- a/js/tiletypes.js +++ b/js/tiletypes.js @@ -166,7 +166,7 @@ function button_visual_state(me) { } } return 'released'; -}; +} // Logic for chasing after the player (or running away); shared by both teeth and mimics function pursue_player(me, level) { @@ -213,6 +213,15 @@ function pursue_player(me, level) { } } +// Ugh. Check for can_reveal_walls, but special-casing it for the pgchip ice blocks, where the +// static property is different. This sux!! +function can_actually_reveal_walls(tile, level) { + if (level.compat.use_pgchip_ice_blocks && tile.type.name == 'ice_block') + return false; + + return tile.type.can_reveal_walls; +} + // Chunks of properties that are shared among bunches of tiles const COMMON_MONSTER = { layer: LAYERS.actor, @@ -311,7 +320,7 @@ const TILE_TYPES = { layer: LAYERS.terrain, blocks_collision: COLLISION.all_but_ghost, on_bumped(me, level, other) { - if (other.type.can_reveal_walls) { + if (can_actually_reveal_walls(other, level)) { level.spawn_animation(me.cell, 'wall_invisible_revealed'); } }, @@ -320,7 +329,7 @@ const TILE_TYPES = { layer: LAYERS.terrain, blocks_collision: COLLISION.all_but_ghost, on_bumped(me, level, other) { - if (other.type.can_reveal_walls) { + if (can_actually_reveal_walls(other, level)) { level.transmute_tile(me, 'wall'); } }, @@ -406,7 +415,7 @@ const TILE_TYPES = { } }, on_bumped(me, level, other) { - if (other.type.can_reveal_walls) { + if (can_actually_reveal_walls(other, level)) { level.transmute_tile(me, 'wall'); } }, @@ -422,7 +431,7 @@ const TILE_TYPES = { } }, on_bumped(me, level, other) { - if (other.type.can_reveal_walls && ! level.compat.blue_floors_vanish_on_arrive) { + if (can_actually_reveal_walls(other, level) && ! level.compat.blue_floors_vanish_on_arrive) { this.reveal(me, level, other); } }, @@ -1141,6 +1150,13 @@ const TILE_TYPES = { ice_block: { layer: LAYERS.actor, collision_mask: COLLISION.block_cc2, + blocked_by(me, level, other) { + // pgchip's ice blocks followed dirt block collision rules, except for being able to go + // on dirt + if (level.compat.use_pgchip_ice_blocks && other.type.name !== 'dirt' && + (other.type.blocks_collision & COLLISION.block_cc1)) + return true; + }, blocks_collision: COLLISION.all, item_pickup_priority: PICKUP_PRIORITIES.never, is_actor: true, @@ -1158,7 +1174,7 @@ const TILE_TYPES = { on_after_bumped(me, level, other) { // Fireballs melt ice blocks on regular floor FIXME and water! // XXX what if i'm in motion? - if (other.type.name === 'fireball') { + if (other.type.name === 'fireball' && ! level.compat.use_pgchip_ice_blocks) { let terrain = me.cell.get_terrain(); if (terrain.type.name === 'floor') { level.transmute_tile(me, 'splash');