diff --git a/src/npc/misc.rs b/src/npc/misc.rs index ad6de57..e7f3920 100644 --- a/src/npc/misc.rs +++ b/src/npc/misc.rs @@ -86,6 +86,51 @@ impl NPC { Ok(()) } + pub(crate) fn tick_n013_forcefield(&mut self, state: &mut SharedGameState) -> GameResult { + self.anim_counter = (self.anim_counter + 1) % 2; + if self.anim_counter == 1 { + self.anim_num = (self.anim_num + 1) % 4; + self.anim_rect = state.constants.npc.n013_forcefield[self.anim_num as usize]; + } + + Ok(()) + } + + pub(crate) fn tick_n014_key(&mut self, state: &mut SharedGameState) -> GameResult { + if self.action_num == 0 { + self.action_num = 1; + + if self.direction == Direction::Right { + self.vel_y = -0x200; + } + } + + if self.flags.hit_bottom_wall() { + self.npc_flags.set_interactable(true); + } + + self.anim_counter += 1; + if self.anim_counter > 1 { + self.anim_counter = 0; + self.anim_num += 1; + if self.anim_num > 2 { + self.anim_num = 0 + } + } + + self.vel_y += 0x40; + + if self.vel_y > 0x5ff { + self.vel_y = 0x5ff; + } + + self.y += self.vel_y; + + self.anim_rect = state.constants.npc.n014_key[self.anim_num as usize]; + + Ok(()) + } + pub(crate) fn tick_n015_chest_closed(&mut self, state: &mut SharedGameState) -> GameResult { match self.action_num { 0 | 1 => { diff --git a/src/npc/mod.rs b/src/npc/mod.rs index 2abba2e..5ac4d4f 100644 --- a/src/npc/mod.rs +++ b/src/npc/mod.rs @@ -118,6 +118,8 @@ impl GameEntity<(&mut Player, &HashMap>, &mut Stage)> for NPC 10 => { self.tick_n010_balrog_shooting(state, player) } 11 => { self.tick_n011_balrogs_projectile(state) } 12 => { self.tick_n012_balrog_cutscene(state, player, map, stage) } + 13 => { self.tick_n013_forcefield(state) } + 14 => { self.tick_n014_key(state) } 15 => { self.tick_n015_chest_closed(state) } 16 => { self.tick_n016_save_point(state) } 17 => { self.tick_n017_health_refill(state) }