From c722582ff232ec63eb6cee046516ba7da4c8fddb Mon Sep 17 00:00:00 2001 From: dawnDus <96957561+dawndus@users.noreply.github.com> Date: Wed, 9 Feb 2022 23:00:02 -0500 Subject: [PATCH] Assorted bugs #60 --- src/npc/ai/booster.rs | 1 + src/npc/ai/characters.rs | 3 +++ src/npc/ai/curly.rs | 12 ++++++------ src/npc/ai/misc.rs | 2 ++ src/npc/ai/plantation.rs | 6 +++++- src/npc/boss/core.rs | 2 +- src/physics.rs | 2 +- src/scene/game_scene.rs | 3 +++ src/scripting/tsc/text_script.rs | 8 ++++---- 9 files changed, 26 insertions(+), 13 deletions(-) diff --git a/src/npc/ai/booster.rs b/src/npc/ai/booster.rs index d18f87c..d410d1d 100644 --- a/src/npc/ai/booster.rs +++ b/src/npc/ai/booster.rs @@ -53,6 +53,7 @@ impl NPC { // interpolation glitch fix self.prev_x = self.x; self.prev_y = self.y; + state.sound_manager.play_sfx(29); } self.action_counter += 1; diff --git a/src/npc/ai/characters.rs b/src/npc/ai/characters.rs index 9560ef2..3d62134 100644 --- a/src/npc/ai/characters.rs +++ b/src/npc/ai/characters.rs @@ -84,6 +84,9 @@ impl NPC { self.anim_num = 0; self.anim_counter = 0; self.vel_x = 0; + if self.tsc_direction == 20 { + self.direction = Direction::Right; + } } if self.rng.range(0..120) == 10 { diff --git a/src/npc/ai/curly.rs b/src/npc/ai/curly.rs index 0834581..6baa7d5 100644 --- a/src/npc/ai/curly.rs +++ b/src/npc/ai/curly.rs @@ -87,13 +87,13 @@ impl NPC { } self.anim_num = 7; - self.vel_x = self.direction.vector_x() * 0x200; + self.vel_x = self.direction.vector_x() * -0x200; self.vel_y += 0x40; - self.action_counter += 1; if self.action_counter > 0 && self.flags.hit_bottom_wall() { self.action_num = 32; } + self.action_counter += 1; } 32 => { self.vel_x = 0; @@ -708,7 +708,7 @@ impl NPC { bullet_manager.create_bullet( self.x + 0x400, self.y - 0x800, - 12, + 6, TargetPlayer::Player1, Direction::Up, &state.constants, @@ -718,7 +718,7 @@ impl NPC { bullet_manager.create_bullet( self.x - 0x400, self.y - 0x800, - 12, + 6, TargetPlayer::Player1, Direction::Up, &state.constants, @@ -729,7 +729,7 @@ impl NPC { bullet_manager.create_bullet( self.x + 0x800, self.y + 0x600, - 12, + 6, TargetPlayer::Player1, Direction::Right, &state.constants, @@ -739,7 +739,7 @@ impl NPC { bullet_manager.create_bullet( self.x - 0x800, self.y + 0x600, - 12, + 6, TargetPlayer::Player1, Direction::Left, &state.constants, diff --git a/src/npc/ai/misc.rs b/src/npc/ai/misc.rs index a50ebd6..59abd71 100644 --- a/src/npc/ai/misc.rs +++ b/src/npc/ai/misc.rs @@ -1603,6 +1603,8 @@ impl NPC { let mut npc = NPC::create(4, &state.npc_table); npc.x = self.x + self.rng.range(-20..20) * 0x200; npc.y = self.y; + npc.cond.set_alive(true); + npc.vel_y = -0x200; let _ = npc_list.spawn(0x100, npc); } diff --git a/src/npc/ai/plantation.rs b/src/npc/ai/plantation.rs index 7441ad5..e4c7b40 100644 --- a/src/npc/ai/plantation.rs +++ b/src/npc/ai/plantation.rs @@ -526,7 +526,9 @@ impl NPC { self.x += self.vel_x; self.y += self.vel_y; - self.anim_rect = state.constants.npc.n232_orangebell[self.anim_num as usize]; + let dir_offset = if self.direction == Direction::Left { 0 } else { 3 }; + + self.anim_rect = state.constants.npc.n232_orangebell[self.anim_num as usize + dir_offset]; Ok(()) } @@ -788,6 +790,8 @@ impl NPC { self.vel_y = self.vel_y.clamp(-0x100, 0x100); + self.y += self.vel_y; + let dir_offset = if self.direction == Direction::Left { 0 } else { 6 }; self.anim_rect = state.constants.npc.n236_gunfish[dir_offset + self.anim_num as usize]; diff --git a/src/npc/boss/core.rs b/src/npc/boss/core.rs index 5b63c63..2ea4cbb 100644 --- a/src/npc/boss/core.rs +++ b/src/npc/boss/core.rs @@ -16,7 +16,7 @@ impl NPC { self.cond.set_alive(false); } - if self.flags.in_water() { + if (self.y - 0x800) > state.water_level { self.x += self.vel_x / 2; self.y += self.vel_y / 2; } else { diff --git a/src/physics.rs b/src/physics.rs index 9552e99..da9ff46 100644 --- a/src/physics.rs +++ b/src/physics.rs @@ -896,7 +896,7 @@ pub trait PhysicalEntity { } } - if self.is_player() && (self.y() - 0x800) > state.water_level { + if (self.y() - 0x800) > state.water_level { self.flags().set_in_water(true); } } diff --git a/src/scene/game_scene.rs b/src/scene/game_scene.rs index cf96c98..15a1a16 100644 --- a/src/scene/game_scene.rs +++ b/src/scene/game_scene.rs @@ -1219,6 +1219,9 @@ impl GameScene { } npc.shock = 8; + + npc = unsafe { self.boss.parts.get_unchecked_mut(i) }; + npc.shock = 8; } bullet.life = bullet.life.saturating_sub(1); diff --git a/src/scripting/tsc/text_script.rs b/src/scripting/tsc/text_script.rs index 4092bd4..0d50470 100644 --- a/src/scripting/tsc/text_script.rs +++ b/src/scripting/tsc/text_script.rs @@ -1327,7 +1327,7 @@ impl TextScriptVM { if direction == Direction::FacingPlayer { npc.direction = if game_scene.player1.x < npc.x { Direction::Left } else { Direction::Right }; - } else { + } else if tsc_direction != 5 { npc.direction = direction; } } @@ -1380,7 +1380,7 @@ impl TextScriptVM { if direction == Direction::FacingPlayer { npc.direction = if game_scene.player1.x < npc.x { Direction::Left } else { Direction::Right }; - } else { + } else if tsc_direction != 5 { npc.direction = direction; } @@ -1417,7 +1417,7 @@ impl TextScriptVM { if direction == Direction::FacingPlayer { npc.direction = if game_scene.player1.x < npc.x { Direction::Left } else { Direction::Right }; - } else { + } else if tsc_direction != 5 { npc.direction = direction; } @@ -1442,7 +1442,7 @@ impl TextScriptVM { npc.tsc_direction = tsc_direction as u16; if direction == Direction::FacingPlayer { - npc.direction = if game_scene.player1.x < npc.x { Direction::Right } else { Direction::Left }; + npc.direction = if game_scene.player1.x < npc.x { Direction::Left } else { Direction::Right }; } else { npc.direction = direction; }