Implement Cracked Ice
Cracked Ice: Turns into water when something steps off of it (except ghosts). Also had to implement slide_ignores/item_slide_ignores since I needed a way to ignore static aspects of the tile without preventing its functions from being called. there's probably a better way IDK
This commit is contained in:
parent
c27af789cb
commit
f64302f324
@ -799,6 +799,10 @@ const TILE_ENCODING = {
|
||||
name: 'cracked_floor',
|
||||
is_extension: true,
|
||||
},
|
||||
0xd3: {
|
||||
name: 'cracked_ice',
|
||||
is_extension: true,
|
||||
},
|
||||
0xe0: {
|
||||
name: 'gift_bow',
|
||||
has_next: true,
|
||||
|
||||
19
js/game.js
19
js/game.js
@ -107,6 +107,21 @@ export class Tile {
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
slide_ignores(name) {
|
||||
if (this.type.slide_ignores && this.type.slide_ignores.has(name))
|
||||
return true;
|
||||
|
||||
if (this.toolbelt) {
|
||||
for (let item of this.toolbelt) {
|
||||
let item_type = TILE_TYPES[item];
|
||||
if (item_type.item_slide_ignores && item_type.item_slide_ignores.has(name))
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
can_push(tile, direction) {
|
||||
// This tile already has a push queued, sorry
|
||||
@ -1509,7 +1524,7 @@ export class Level extends LevelInterface {
|
||||
if (actor.has_item('speed_boots')) {
|
||||
speed /= 2;
|
||||
}
|
||||
else if (terrain && terrain.type.speed_factor && ! actor.ignores(terrain.type.name)) {
|
||||
else if (terrain && terrain.type.speed_factor && ! actor.ignores(terrain.type.name) && !actor.slide_ignores(terrain.type.name)) {
|
||||
speed /= terrain.type.speed_factor;
|
||||
}
|
||||
|
||||
@ -1594,6 +1609,8 @@ export class Level extends LevelInterface {
|
||||
continue;
|
||||
if (actor.ignores(tile.type.name))
|
||||
continue;
|
||||
if (actor.slide_ignores(tile.type.name))
|
||||
continue;
|
||||
|
||||
// Possibly kill a player
|
||||
if (actor.has_item('helmet') || tile.has_item('helmet')) {
|
||||
|
||||
@ -1607,6 +1607,7 @@ const EDITOR_PALETTE = [{
|
||||
'electrified_floor',
|
||||
'hole',
|
||||
'cracked_floor',
|
||||
'cracked_ice',
|
||||
],
|
||||
}];
|
||||
|
||||
@ -2217,6 +2218,10 @@ const EDITOR_TILE_DESCRIPTIONS = {
|
||||
name: "Cracked Floor",
|
||||
desc: "Turns into a hole when something steps off of it (except ghosts).",
|
||||
},
|
||||
cracked_ice: {
|
||||
name: "Cracked Ice",
|
||||
desc: "Turns into water when something steps off of it (except ghosts).",
|
||||
},
|
||||
};
|
||||
|
||||
const SPECIAL_PALETTE_ENTRIES = {
|
||||
|
||||
@ -1061,6 +1061,7 @@ export const LL_TILESET_LAYOUT = Object.assign({}, CC2_TILESET_LAYOUT, {
|
||||
open: [9, 41],
|
||||
},
|
||||
cracked_floor: [11, 43],
|
||||
cracked_ice: [7, 40],
|
||||
});
|
||||
|
||||
export const TILESET_LAYOUTS = {
|
||||
|
||||
@ -841,6 +841,16 @@ const TILE_TYPES = {
|
||||
level.sfx.play_once('splash', me.cell);
|
||||
},
|
||||
},
|
||||
cracked_ice: {
|
||||
layer: LAYERS.terrain,
|
||||
slide_mode: 'ice',
|
||||
speed_factor: 2,
|
||||
on_depart(me, level, other) {
|
||||
level.transmute_tile(me, 'water');
|
||||
level.spawn_animation(me.cell, 'splash');
|
||||
level.sfx.play_once('splash', me.cell);
|
||||
},
|
||||
},
|
||||
ice: {
|
||||
layer: LAYERS.terrain,
|
||||
slide_mode: 'ice',
|
||||
@ -2579,7 +2589,7 @@ const TILE_TYPES = {
|
||||
ignores: new Set([
|
||||
'bomb',
|
||||
'water',
|
||||
'ice', 'ice_nw', 'ice_ne', 'ice_sw', 'ice_se',
|
||||
'ice', 'ice_nw', 'ice_ne', 'ice_sw', 'ice_se', 'cracked_ice',
|
||||
'force_floor_n', 'force_floor_s', 'force_floor_e', 'force_floor_w', 'force_floor_all',
|
||||
// Ghosts don't activate swivels or popwalls
|
||||
'popwall', 'swivel_nw', 'swivel_ne', 'swivel_se', 'swivel_sw',
|
||||
@ -2700,7 +2710,7 @@ const TILE_TYPES = {
|
||||
is_item: true,
|
||||
is_tool: true,
|
||||
blocks_collision: COLLISION.block_cc1 | (COLLISION.monster_solid & ~COLLISION.rover),
|
||||
item_ignores: new Set(['ice', 'ice_nw', 'ice_ne', 'ice_sw', 'ice_se']),
|
||||
item_slide_ignores: new Set(['ice', 'ice_nw', 'ice_ne', 'ice_sw', 'ice_se', 'cracked_ice']),
|
||||
},
|
||||
suction_boots: {
|
||||
layer: LAYERS.item,
|
||||
@ -3004,7 +3014,7 @@ const TILE_TYPES = {
|
||||
has_inventory: true,
|
||||
can_reveal_walls: true,
|
||||
movement_speed: 4,
|
||||
ignores: new Set(['ice', 'ice_nw', 'ice_ne', 'ice_sw', 'ice_se']),
|
||||
ignores: new Set(['ice', 'ice_nw', 'ice_ne', 'ice_sw', 'ice_se', 'cracked_ice']),
|
||||
pushes: {
|
||||
dirt_block: true,
|
||||
ice_block: true,
|
||||
@ -3050,7 +3060,7 @@ const TILE_TYPES = {
|
||||
has_inventory: true,
|
||||
can_reveal_walls: true, // XXX i think?
|
||||
movement_speed: 4,
|
||||
ignores: new Set(['ice', 'ice_nw', 'ice_ne', 'ice_sw', 'ice_se']),
|
||||
ignores: new Set(['ice', 'ice_nw', 'ice_ne', 'ice_sw', 'ice_se', 'cracked_ice']),
|
||||
pushes: {
|
||||
dirt_block: true,
|
||||
ice_block: true,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user