Implement Electrified Floor

Conducts power (like a blue teleporter). While powered, destroys anything not wearing lightning boots (except dirt blocks).
This commit is contained in:
Timothy Stiles 2021-02-14 14:22:28 +11:00
parent d874e4d956
commit 1f6c86c146
5 changed files with 63 additions and 1 deletions

View File

@ -787,6 +787,10 @@ const TILE_ENCODING = {
},
// LL-specific tiles
0xd0: {
name: 'electrified_floor',
is_extension: true,
},
0xe0: {
name: 'gift_bow',
has_next: true,

View File

@ -1604,6 +1604,7 @@ const EDITOR_PALETTE = [{
'fire_sticks',
'turntable_cw',
'turntable_ccw',
'electrified_floor',
],
}];
@ -2202,6 +2203,10 @@ const EDITOR_TILE_DESCRIPTIONS = {
name: "Turntable (Counterclockwise)",
desc: "Rotates anything entering this tile counterclockwise. Frame blocks are rotated too. If connected to wire, only functions while receiving power.",
},
electrified_floor: {
name: "Electrified Floor",
desc: "Conducts power (like a blue teleporter). While powered, destroys anything not wearing lightning boots (except dirt blocks).",
},
};
const SPECIAL_PALETTE_ENTRIES = {

View File

@ -91,6 +91,12 @@ const OBITUARIES = {
"no place to be",
"on a trip to nowhere",
],
electrocuted: [
"a shocking revelation",
"danger: high voltage",
"inadequate insulation",
"rode the lightning",
],
generic: [
"you had a bad time",
],

View File

@ -1048,6 +1048,11 @@ export const LL_TILESET_LAYOUT = Object.assign({}, CC2_TILESET_LAYOUT, {
active: [8, 43],
inactive: [10, 43],
},
electrified_floor: {
__special__: 'visual-state',
active: [[5, 41], [6, 41], [7, 41]],
inactive: [4, 41],
},
});
export const TILESET_LAYOUTS = {

View File

@ -169,6 +169,9 @@ function player_visual_state(me) {
else if (me.fail_reason === 'slimed') {
return 'slimed';
}
else if (me.fail_reason === 'electrocuted') {
return 'burned'; //same gfx for now
}
else if (me.fail_reason) {
return 'failed';
}
@ -1108,7 +1111,7 @@ const TILE_TYPES = {
blocks_collision: COLLISION.all,
is_actor: true,
is_block: true,
ignores: new Set(['fire', 'flame_jet_on']),
ignores: new Set(['fire', 'flame_jet_on', 'electrified_floor']),
can_reverse_on_railroad: true,
movement_speed: 4,
},
@ -1885,6 +1888,44 @@ const TILE_TYPES = {
me.type.activate(me, level);
},
},
electrified_floor: {
layer: LAYERS.terrain,
wire_propagation_mode: 'all',
on_begin(me, level) {
// TODO if wire destruction is ever allowed, this will need to update somehow
me.is_wired = level.is_tile_wired(me, false);
me.is_active = ! me.is_wired;
},
on_tic(me, level) {
if (me.is_active)
{
let actor = me.cell.get_actor();
if (actor && actor.movement_cooldown <= 0 && ! actor.ignores(me.type.name)) {
if (actor.type.is_real_player) {
level.fail('electrocuted', me, actor);
}
else {
level.sfx.play_once('bomb', me.cell);
level.transmute_tile(actor, 'explosion');
}
}
}
},
on_power(me, level) {
if (me.is_wired) {
level._set_tile_prop(me, 'is_active', true);
}
},
on_depower(me, level) {
if (me.is_wired) {
level._set_tile_prop(me, 'is_active', false);
}
},
visual_state(me) {
return ! me || me.is_active ? 'active' : 'inactive';
},
},
// Buttons
button_blue: {
layer: LAYERS.terrain,
@ -2855,6 +2896,7 @@ const TILE_TYPES = {
is_item: true,
is_tool: true,
blocks_collision: COLLISION.block_cc1 | (COLLISION.monster_solid & ~COLLISION.rover),
item_ignores: new Set(['electrified_floor']),
},
speed_boots: {
layer: LAYERS.item,