Fix demo playback (!): bumping doesn't cause cooldown, thieves were backwards

This commit is contained in:
Eevee (Evelyn Woods) 2020-09-01 05:00:57 -06:00
parent 2ae053d87a
commit ab377f6593
2 changed files with 21 additions and 35 deletions

View File

@ -19,27 +19,6 @@ class CC2Demo {
// byte 0 is unknown, always 0?
this.force_floor_seed = this.bytes[1];
this.blob_seed = this.bytes[2];
let l = this.bytes.length;
if (l % 2 === 0) {
l--;
}
for (let p = 3; p < l; p += 2) {
let delay = this.bytes[p];
let input_mask = this.bytes[p + 1];
let input = new Set;
if ((input_mask & 0x80) !== 0) {
input.add('p2');
}
for (let [action, bit] of Object.entries(CC2_DEMO_INPUT_MASK)) {
if ((input_mask & bit) !== 0) {
input.add(action);
}
}
console.log('demo step', delay, input);
}
}
*[Symbol.iterator]() {
@ -65,9 +44,8 @@ class CC2Demo {
// t >= 2: skips a move, also desyncs before yellow door
// t >= 1: same as 2
// t >= 0: same as 3
while (t > 0) {
while (t >= 3) {
t -= 3;
console.log(t, input);
yield input;
}
@ -150,7 +128,7 @@ const TILE_ENCODING = {
0x3c: ['suction_boots', '#next'],
0x3d: ['fire_boots', '#next'],
0x3e: ['flippers', '#next'],
0x3f: 'thief_keys',
0x3f: 'thief_tools',
0x40: ['bomb', '#next'],
//0x41: Open trap (unused in main levels) :
0x42: 'trap',
@ -225,7 +203,7 @@ const TILE_ENCODING = {
// 0x87: Black button :
// 0x88: ON/OFF switch (OFF) :
// 0x89: ON/OFF switch (ON) :
0x8a: 'thief_tools',
0x8a: 'thief_keys',
// 0x8b: Ghost : '#direction', '#next'
// 0x8c: Steel foil : '#next'
0x8d: ['turtle', 'water'],

View File

@ -143,10 +143,15 @@ class Tile {
this.inventory[name] = (this.inventory[name] ?? 0) + 1;
}
take_item(name) {
take_item(name, amount = null) {
if (this.inventory[name] && this.inventory[name] >= 1) {
if (!(this.type.infinite_items && this.type.infinite_items[name])) {
this.inventory[name]--;
if (amount == null && this.type.infinite_items && this.type.infinite_items[name]) {
// Some items can't be taken away normally, by which I mean,
// green keys
;
}
else {
this.inventory[name] = Math.max(0, this.inventory[name] - (amount || 1));
}
return true;
}
@ -358,7 +363,6 @@ class Level {
}
else if (actor === this.player) {
if (player_direction) {
//console.log('--- player moving', player_direction);
direction_preference = [player_direction];
actor.last_move_was_force = false;
}
@ -410,13 +414,15 @@ class Level {
}
}
// Always set the cooldown if we even attempt to move. Speed
// multiplier is based on the tile we landed /on/, if any.
let speed_multiplier = 1;
if (actor.slide_mode !== null) {
speed_multiplier = 2;
// Only set movement cooldown if we actually moved!
if (moved) {
// Speed multiplier is based on the tile we landed /on/.
let speed_multiplier = 1;
if (actor.slide_mode !== null) {
speed_multiplier = 2;
}
actor.movement_cooldown = actor.type.movement_speed / speed_multiplier;
}
actor.movement_cooldown = actor.type.movement_speed / speed_multiplier;
// TODO do i need to do this more aggressively?
if (this.state === 'success' || this.state === 'failure')
@ -940,6 +946,8 @@ class Game {
t += 1;
}
this.demo = this.level.stored_level.demo[Symbol.iterator]();
// FIXME should probably start playback on first input
this.set_state('playing');
}
else {
// TODO update these, as appropriate, when loading a level