1
0
Fork 0
mirror of https://github.com/doukutsu-rs/doukutsu-rs synced 2024-11-22 13:42:47 +00:00

fix a few NPC inaccuracies from #165

This commit is contained in:
József Sallai 2022-09-24 23:27:27 +03:00
parent 2b9a0198cb
commit f0949f49cf
5 changed files with 30 additions and 23 deletions

View file

@ -533,7 +533,7 @@ impl NPC {
}
20 => {
self.vel_x /= 2;
self.vel_y += 0x10;
self.vel_y += 0x20;
if self.shock == 0 {
self.action_num = 10;
@ -1275,6 +1275,7 @@ impl NPC {
self.anim_num = 1;
self.anim_counter = 0;
self.damage = 0;
state.sound_manager.play_sfx(23);
let player = self.get_closest_player_mut(players);
if player.x > self.x + 0x12000
@ -1309,6 +1310,8 @@ impl NPC {
self.npc_flags.set_shootable(false);
self.npc_flags.set_solid_soft(false);
state.sound_manager.play_sfx(51);
}
if self.flags.hit_bottom_wall() {

View file

@ -28,15 +28,11 @@ impl NPC {
self.direction = Direction::Right;
}
if self.target_x < 100 {
self.target_x += 1;
}
if self.action_counter >= 8
&& self.x - 0x12000 < player.x
&& self.x + 0x12000 > player.x
&& self.y - 0xc000 < player.y
&& self.y + 0xc000 > player.y
&& self.y - 0xa000 < player.y
&& self.y + 0xa000 > player.y
{
self.anim_num = 1;
} else {
@ -55,11 +51,10 @@ impl NPC {
}
if self.action_counter >= 8
&& self.target_x >= 100
&& self.x - 0xc000 < player.x
&& self.x + 0xc000 > player.x
&& self.y - 0xa000 < player.y
&& self.y + 0xa000 > player.y
&& self.y + 0xc000 > player.y
{
self.action_num = 2;
self.action_counter = 0;

View file

@ -436,8 +436,8 @@ impl NPC {
return Ok(());
}
self.anim_counter = (self.anim_counter + 1) % 4;
self.anim_num = self.anim_counter / 2;
self.anim_counter = (self.anim_counter + 1) % 6;
self.anim_num = self.anim_counter / 3;
self.anim_rect = state.constants.npc.n032_life_capsule[self.anim_num as usize];
Ok(())

View file

@ -918,7 +918,7 @@ impl NPC {
}
self.action_counter += 1;
if self.action_counter % 5 != 0 {
if self.action_counter % 5 == 0 {
state.sound_manager.play_sfx(110);
}
@ -975,7 +975,12 @@ impl NPC {
self.action_counter2 = 0;
self.vel_y = -0x600;
self.vel_x = self.direction.vector_x() * 0x200;
if self.target_x > self.x {
self.vel_x = 0x200;
} else {
self.vel_x = -0x200;
}
}
}
12 => {

View file

@ -485,7 +485,9 @@ impl NPC {
match self.action_num {
0 | 1 => {
if self.action_num == 0 {
let is_in_spawn_radius = (player.x - self.x).abs() < 0x28000 && (player.y - self.y).abs() < 0x28000;
if self.action_num == 0 && is_in_spawn_radius {
self.action_num = 1;
self.target_x = self.x;
self.target_y = self.y;
@ -495,16 +497,16 @@ impl NPC {
npc.cond.set_alive(true);
npc.parent_id = self.id;
let _ = npc_list.spawn(0, npc);
}
} else if self.action_num == 1 || (self.action_num == 0 && is_in_spawn_radius) {
self.direction = if player.x >= self.x { Direction::Right } else { Direction::Left };
self.vel_y += (self.target_y - self.y).signum() * 0x0a;
self.vel_y = clamp(self.vel_y, -0x200, 0x200);
self.direction = if player.x >= self.x { Direction::Right } else { Direction::Left };
self.vel_y += (self.target_y - self.y).signum() * 0x0a;
self.vel_y = clamp(self.vel_y, -0x200, 0x200);
if self.vel_y2 >= 10 {
self.action_num = 2;
} else {
self.vel_y2 += 1;
if self.vel_y2 >= 10 {
self.action_num = 2;
} else {
self.vel_y2 += 1;
}
}
}
2 => {
@ -1060,6 +1062,8 @@ impl NPC {
Direction::FacingPlayer => {}
}
self.action_counter += 1;
state.quake_counter = 20;
state.quake_rumble_counter = 20;
if self.action_counter % 8 == 0 {