Bug fixes for #63

This commit is contained in:
dawnDus 2022-02-16 23:16:25 -05:00
parent 44f478be75
commit 0d20b1a209
No known key found for this signature in database
GPG Key ID: 972AABDE81848F21
7 changed files with 19 additions and 20 deletions

View File

@ -1737,7 +1737,14 @@ impl EngineConstants {
pub fn load_nx_stringtable(&mut self, ctx: &mut Context) -> GameResult {
if let Ok(file) = filesystem::open(ctx, "/base/stringtable.sta") {
let mut reader = BufReader::new(file);
let _ = reader.read_exact(&mut [0; 3]);
// Only some versions start with the BOM marker, thankfully the file isn't that large to read twice
let mut bom = [0xef, 0xbb, 0xbf];
let buf = reader.fill_buf()?;
if buf.len() > 3 && buf[0..3] == bom {
reader.read_exact(&mut bom)?;
}
if let Ok(xml) = Element::parse(reader) {
for node in &xml.get_child("category").unwrap().children {
let element = node.as_element().unwrap();

View File

@ -191,14 +191,7 @@ impl NPC {
self.x += self.vel_x;
self.y += self.vel_y;
self.anim_counter += 1;
if self.anim_counter > 1 {
self.anim_counter = 0;
if self.anim_num > 2 {
self.anim_num = 0;
}
}
self.animate(1, 0, 2);
self.anim_rect = state.constants.npc.n011_balrog_energy_shot[self.anim_num as usize];

View File

@ -969,6 +969,7 @@ impl NPC {
&state.constants,
);
state.create_caret(npc.x, npc.y, CaretType::Shoot, self.direction);
state.sound_manager.play_sfx(117);
}
let mut dir_offset = if self.direction == Direction::Left { 0 } else { 3 };

View File

@ -982,8 +982,8 @@ impl NPC {
for i in 0..4 {
npc.x = self.x + self.rng.range(-0x10..0x10) * 0x200;
npc.y = self.y - ((0x150 - self.action_counter as i32) / 8) * 0x200;
npc.vel_x = 2 * self.rng.range(-0x200..0);
npc.vel_y = if i >= 2 { 0 } else { self.rng.range(-0x200..0x200) };
npc.vel_y = 2 * self.rng.range(-0x200..0);
npc.vel_x = if i >= 2 { 0 } else { self.rng.range(-0x200..0x200) };
npc.direction = Direction::Bottom;
let _ = npc_list.spawn(0xAA, npc.clone());
}

View File

@ -370,8 +370,7 @@ impl NPC {
self.anim_num = 1;
}
if abs(self.x - player.x) < 0x1000 && self.y - 0x1000 < player.y && self.y + 96 * 0x200 > player.y
{
if abs(self.x - player.x) < 0x1000 && self.y - 0x1000 < player.y && self.y + 96 * 0x200 > player.y {
self.action_num = 3;
self.anim_num = 0;
}
@ -1056,10 +1055,7 @@ impl NPC {
let player = self.get_closest_player_mut(players);
if abs(self.x - player.x) < 32 * 0x200
&& self.y - 32 * 0x200 < player.y
&& self.y + 0x2000 > player.y
{
if abs(self.x - player.x) < 32 * 0x200 && self.y - 32 * 0x200 < player.y && self.y + 0x2000 > player.y {
self.direction = if self.x > player.x { Direction::Left } else { Direction::Right };
}
}
@ -1293,9 +1289,9 @@ impl NPC {
let player = self.get_closest_player_mut(players);
if player.x > self.x + 0x12000
&& player.x < self.x - 0x12000
&& player.y > self.y + 0x6000
&& player.y < self.y - 0x12000
|| player.x < self.x - 0x12000
|| player.y > self.y + 0x6000
|| player.y < self.y - 0x12000
{
self.action_num = 0;
}

View File

@ -62,6 +62,7 @@ impl NPC {
let mut npc = NPC::create(297, &state.npc_table);
npc.cond.set_alive(true);
npc.parent_id = self.id;
let _ = npc_list.spawn(0x100, npc);
}
_ => (),

View File

@ -63,6 +63,7 @@ impl BossNPC {
self.parts[0].y = 0;
self.parts[0].display_bounds = Rect { left: 0x5000, top: 0x7800, right: 0x5000, bottom: 0x7800 };
self.parts[0].hit_bounds = Rect { left: 0x6200, top: 0x7800, right: 0x5000, bottom: 0x6000 };
self.hurt_sound[0] = 54;
self.parts[0].npc_flags.set_ignore_solidity(true);
self.parts[0].npc_flags.set_solid_hard(true);
self.parts[0].npc_flags.set_event_when_killed(true);