1
0
Fork 0
mirror of https://github.com/doukutsu-rs/doukutsu-rs synced 2025-11-30 08:08:18 +00:00

Add max fall speed function for NPCs

This commit is contained in:
dawnDus 2022-03-26 11:05:56 -04:00
parent b0958749f6
commit 55e80b4c69
No known key found for this signature in database
GPG key ID: 972AABDE81848F21
24 changed files with 107 additions and 280 deletions

View file

@ -166,9 +166,7 @@ impl NPC {
}
self.vel_y += 0x20;
if self.vel_y > 0x5ff {
self.vel_y = 0x5ff;
}
self.clamp_fall_speed();
self.x += self.vel_x;
self.y += self.vel_y;
@ -329,9 +327,7 @@ impl NPC {
}
self.vel_y += 0x20;
if self.vel_y > 0x5ff {
self.vel_y = 0x5ff;
}
self.clamp_fall_speed();
}
30 => {
self.anim_num = 4;
@ -520,9 +516,7 @@ impl NPC {
let _ = npc_list.spawn(0x100, npc);
}
if self.vel_y > 0x5ff {
self.vel_y = 0x5ff;
}
self.clamp_fall_speed();
self.x += self.vel_x;
self.y += self.vel_y;
@ -799,9 +793,7 @@ impl NPC {
self.direction = if self.x < player.x { Direction::Right } else { Direction::Left };
}
if self.vel_y > 0x5ff {
self.vel_y = 0x5ff;
}
self.clamp_fall_speed();
self.x += self.vel_x;
self.y += self.vel_y;
@ -867,8 +859,10 @@ impl NPC {
self.vel_x += 0x10 * self.direction.vector_x();
let pi = self.get_closest_player_idx_mut(&players);
if self.action_counter >= 8 && (players[pi].x - self.x).abs() < 0x1800
&& self.y - 0x1800 < players[pi].y && self.y + 0x1000 > players[pi].y
if self.action_counter >= 8
&& (players[pi].x - self.x).abs() < 0x1800
&& self.y - 0x1800 < players[pi].y
&& self.y + 0x1000 > players[pi].y
{
self.action_num = 10;
self.anim_num = 5;
@ -980,9 +974,7 @@ impl NPC {
self.vel_x = clamp(self.vel_x, -0x400, 0x400);
self.vel_y += 0x20;
if self.vel_y > 0x5ff {
self.vel_y = 0x5ff;
}
self.clamp_fall_speed();
self.x += self.vel_x;
self.y += self.vel_y;
@ -1199,9 +1191,7 @@ impl NPC {
self.vel_y += 0x20;
self.vel_x = self.vel_x.clamp(-0x300, 0x300);
if self.vel_y > 0x5FF {
self.vel_y = 0x5FF;
}
self.clamp_fall_speed();
self.x += self.vel_x;
self.y += self.vel_y;

View file

@ -63,9 +63,7 @@ impl NPC {
self.vel_y += 0x20;
if self.vel_y > 0x5ff {
self.vel_y = 0x5ff;
}
self.clamp_fall_speed();
self.y += self.vel_y;
@ -235,9 +233,7 @@ impl NPC {
self.vel_y += 0x40;
self.vel_x = self.vel_x.clamp(-0x400, 0x400);
if self.vel_y > 0x5ff {
self.vel_y = 0x5ff;
}
self.clamp_fall_speed();
}
self.x += self.vel_x;
@ -351,9 +347,7 @@ impl NPC {
self.vel_y += 0x40;
self.vel_x = clamp(self.vel_x, -0x400, 0x400);
if self.vel_y > 0x5ff {
self.vel_y = 0x5ff;
}
self.clamp_fall_speed();
self.x += self.vel_x;
self.y += self.vel_y;
@ -434,9 +428,7 @@ impl NPC {
10 => {
self.anim_num = 0;
self.vel_y += 0x40;
if self.vel_y > 0x5FF {
self.vel_y = 0x5FF;
}
self.clamp_fall_speed();
self.y += self.vel_y;
}
20 | 21 => {
@ -558,9 +550,7 @@ impl NPC {
}
self.vel_y += 0x40;
if self.vel_y > 0x5ff {
self.vel_y = 0x5ff;
}
self.clamp_fall_speed();
self.x += self.vel_x;
self.y += self.vel_y;
@ -627,9 +617,7 @@ impl NPC {
}
self.vel_y += 0x20;
if self.vel_y > 0x5FF {
self.vel_y = 0x5FF;
}
self.clamp_fall_speed();
self.x += self.vel_x;
self.y += self.vel_y;
@ -723,9 +711,7 @@ impl NPC {
}
20 => {
self.vel_y += 0x40;
if self.vel_y > 0x5FF {
self.vel_y = 0x5FF;
}
self.clamp_fall_speed();
self.action_counter += 1;
if self.action_counter > 50 {

View file

@ -114,9 +114,7 @@ impl NPC {
_ => (),
}
if self.vel_y > 0x5ff {
self.vel_y = 0x5ff;
}
self.clamp_fall_speed();
self.x += self.vel_x;
self.y += self.vel_y;
@ -259,9 +257,7 @@ impl NPC {
self.vel_x = clamp(self.vel_x, -0x1ff, 0x1ff);
self.vel_y += 0x20;
if self.vel_y > 0x5ff {
self.vel_y = 0x5ff;
}
self.clamp_fall_speed();
self.x += self.vel_x;
self.y += self.vel_y;
@ -551,9 +547,7 @@ impl NPC {
self.vel_x = self.vel_x.clamp(-0x300, 0x300);
if self.vel_y > 0x5FF {
self.vel_y = 0x5FF;
}
self.clamp_fall_speed();
self.x += self.vel_x;
self.y += self.vel_y;

View file

@ -456,9 +456,7 @@ impl NPC {
state.npc_super_pos = (self.x, self.y);
}
if self.vel_y > 0x5ff {
self.vel_y = 0x5ff;
}
self.clamp_fall_speed();
self.x += self.vel_x;
self.y += self.vel_y;
@ -967,9 +965,7 @@ impl NPC {
}
}
if self.vel_y > 0x5FF {
self.vel_y = 0x5FF;
}
self.clamp_fall_speed();
self.x += self.vel_x;
self.y += self.vel_y;
@ -1059,9 +1055,7 @@ impl NPC {
self.vel_y += self.direction.vector_y() * 0x40;
self.action_counter += 1;
if self.vel_y > 0x5FF {
self.vel_y = 0x5FF;
}
self.clamp_fall_speed();
self.x += self.vel_x;
self.y += self.vel_y;

View file

@ -81,9 +81,7 @@ impl NPC {
self.vel_y += 0x40;
if self.vel_y > 0x5ff {
self.vel_y = 0x5ff;
}
self.clamp_fall_speed();
self.x += self.vel_x;
self.y += self.vel_y;
@ -175,9 +173,7 @@ impl NPC {
}
self.vel_y += 0x40;
if self.vel_y > 0x5ff {
self.vel_y = 0x5ff;
}
self.clamp_fall_speed();
self.x += self.vel_x;
self.y += self.vel_y;
@ -839,9 +835,7 @@ impl NPC {
self.anim_rect = state.constants.npc.n203_critter_destroyed_egg_corridor[self.anim_num as usize + dir_offset];
self.vel_y += 0x40;
if self.vel_y > 0x5ff {
self.vel_y = 0x5ff;
}
self.clamp_fall_speed();
self.x += self.vel_x;
self.y += self.vel_y;

View file

@ -149,9 +149,7 @@ impl NPC {
}
self.vel_y += 0x40;
if self.vel_y > 0x5ff {
self.vel_y = 0x5ff;
}
self.clamp_fall_speed();
self.x += self.vel_x;
self.y += self.vel_y;

View file

@ -125,9 +125,7 @@ impl NPC {
if self.action_num != 4 {
self.vel_y += 0x20;
if self.vel_y > 0x5ff {
self.vel_y = 0x5ff;
}
self.clamp_fall_speed();
} else {
self.vel_x = clamp(self.vel_x + if self.x < player.x { 0x20 } else { -0x20 }, -0x200, 0x200);
self.vel_y = clamp(self.vel_y + if self.y > self.target_y { -0x10 } else { 0x10 }, -0x200, 0x200);
@ -186,9 +184,7 @@ impl NPC {
}
3 => {
self.vel_y += 0x40;
if self.vel_y > 0x5ff {
self.vel_y = 0x5ff;
}
self.clamp_fall_speed();
if self.flags.hit_bottom_wall() {
self.vel_x *= 2;
@ -334,9 +330,7 @@ impl NPC {
if self.action_num != 4 {
self.vel_y += 0x40;
if self.vel_y > 0x5ff {
self.vel_y = 0x5ff;
}
self.clamp_fall_speed();
} else {
self.vel_x = clamp(self.vel_x + if self.x < player.x { 0x20 } else { -0x20 }, -0x200, 0x200);
self.vel_y = clamp(self.vel_y + if self.y > self.target_y { -0x10 } else { 0x10 }, -0x200, 0x200);
@ -394,9 +388,7 @@ impl NPC {
}
4 => {
self.vel_y += 0x20;
if self.vel_y > 0x5ff {
self.vel_y = 0x5ff;
}
self.clamp_fall_speed();
self.action_counter += 1;
if self.action_counter >= 20 && (self.flags.hit_bottom_wall() || self.y > player.y - 0x2000) {
@ -1084,9 +1076,7 @@ impl NPC {
}
self.vel_y += 0x40;
if self.vel_y > 0x5ff {
self.vel_y = 0x5ff;
}
self.clamp_fall_speed();
self.y += self.vel_y;
@ -1332,9 +1322,7 @@ impl NPC {
self.vel_y += if self.action_num <= 50 { 0x40 } else { 0x20 };
if self.vel_y > 0x5ff {
self.vel_y = 0x5ff;
}
self.clamp_fall_speed();
self.x += self.vel_x;
self.y += self.vel_y;

View file

@ -25,9 +25,7 @@ impl NPC {
}
self.vel_y += 0x40;
if self.vel_y > 0x5ff {
self.vel_y = 0x5ff;
}
self.clamp_fall_speed();
self.x += self.vel_x;
self.y += self.vel_y;
@ -422,9 +420,7 @@ impl NPC {
_ => (),
}
if self.vel_y > 0x5FF {
self.vel_y = 0x5FF
};
self.clamp_fall_speed();
self.x += self.vel_x;
self.y += self.vel_y;
@ -475,9 +471,7 @@ impl NPC {
}
self.vel_y += 0x20;
if self.vel_y > 0x5ff {
self.vel_y = 0x5ff;
}
self.clamp_fall_speed();
self.x += self.vel_x;
self.y += self.vel_y;
@ -635,9 +629,7 @@ impl NPC {
}
self.vel_y += 0x55;
if self.vel_y > 0x5FF {
self.vel_y = 0x5FF
};
self.clamp_fall_speed();
self.x += self.vel_x;
self.y += self.vel_y;
@ -686,9 +678,7 @@ impl NPC {
}
self.vel_y += 0x20;
if self.vel_y > 0x5ff {
self.vel_y = 0x5ff;
}
self.clamp_fall_speed();
self.x += self.vel_x;
self.y += self.vel_y;
@ -727,9 +717,7 @@ impl NPC {
};
self.vel_y += 0x2A;
if self.vel_y > 0x5FF {
self.vel_y = 0x5FF
};
self.clamp_fall_speed();
self.x += self.vel_x;
self.y += self.vel_y;

View file

@ -75,9 +75,7 @@ impl NPC {
}
self.vel_y += 0x40;
if self.vel_y > 0x5ff {
self.vel_y = 0x5ff;
}
self.clamp_fall_speed();
self.x += self.vel_x;
self.y += self.vel_y;
@ -256,9 +254,7 @@ impl NPC {
}
self.vel_y += 0x40;
if self.vel_y > 0x5ff {
self.vel_y = 0x5ff;
}
self.clamp_fall_speed();
self.x += self.vel_x;
self.y += self.vel_y;
@ -519,9 +515,7 @@ impl NPC {
}
self.vel_y += 0x33;
if self.vel_y > 0x5FF {
self.vel_y = 0x5FF;
}
self.clamp_fall_speed();
self.x += self.vel_x;
self.y += self.vel_y;

View file

@ -96,9 +96,7 @@ impl NPC {
}
self.vel_y += 0x55;
if self.vel_y > 0x5ff {
self.vel_y = 0x5ff;
}
self.clamp_fall_speed();
self.x += self.vel_x;
self.y += self.vel_y;
@ -206,9 +204,7 @@ impl NPC {
return Ok(());
}
if self.vel_y > 0x5ff {
self.vel_y = 0x5ff;
}
self.clamp_fall_speed();
self.y += self.vel_y;
self.anim_rect = state.constants.npc.n244_lava_drop;
@ -421,9 +417,7 @@ impl NPC {
}
self.vel_y += 0x20;
if self.vel_y > 0x5FF {
self.vel_y = 0x5FF;
}
self.clamp_fall_speed();
self.x += self.vel_x;
self.y += self.vel_y;

View file

@ -146,9 +146,7 @@ impl NPC {
self.vel_y = self.vel_y.clamp(-0x200, 0x200);
} else {
self.vel_y += 0x20;
if self.vel_y > 0x5FF {
self.vel_y = 0x5FF;
}
self.clamp_fall_speed();
}
self.x += self.vel_x;
@ -318,9 +316,7 @@ impl NPC {
}
self.vel_y += 0x40;
if self.vel_y > 0x5ff {
self.vel_y = 0x5ff;
}
self.clamp_fall_speed();
self.x += self.vel_x;
self.y += self.vel_y;
@ -372,9 +368,7 @@ impl NPC {
}
self.vel_y += 0x20;
if self.vel_y > 0x5ff {
self.vel_y = 0x5ff;
}
self.clamp_fall_speed();
self.x += self.vel_x;
self.y += self.vel_y;

View file

@ -83,9 +83,7 @@ impl NPC {
self.vel_y += 0x40;
if self.vel_y > 0x5ff {
self.vel_y = 0x5ff;
}
self.clamp_fall_speed();
self.x += self.vel_x;
self.y += self.vel_y;
@ -224,9 +222,7 @@ impl NPC {
self.vel_y += 0x40;
if self.vel_y > 0x5ff {
self.vel_y = 0x5ff;
}
self.clamp_fall_speed();
self.y += self.vel_y;
@ -411,9 +407,7 @@ impl NPC {
self.vel_y += 0x40;
if self.vel_y > 0x5ff {
self.vel_y = 0x5ff;
}
self.clamp_fall_speed();
self.x += self.vel_x;
self.y += self.vel_y;
@ -704,9 +698,7 @@ impl NPC {
}
}
if self.vel_y > 0x5FF {
self.vel_y = 0x5FF
};
self.clamp_fall_speed();
self.x += self.vel_x;
self.y += self.vel_y;
@ -885,9 +877,7 @@ impl NPC {
if self.action_counter2 > 300 {
self.vanish(state);
} else {
if self.vel_y > 0x5FF {
self.vel_y = 0x5FF
};
self.clamp_fall_speed();
self.x += self.vel_x;
self.y += self.vel_y;

View file

@ -125,9 +125,7 @@ impl NPC {
self.vel_y += 0x40;
if self.vel_y > 0x5ff {
self.vel_y = 0x5ff;
}
self.clamp_fall_speed();
self.y += self.vel_y;
@ -181,9 +179,7 @@ impl NPC {
}
self.vel_y += 0x40;
if self.vel_y > 0x5ff {
self.vel_y = 0x5ff;
}
self.clamp_fall_speed();
self.y += self.vel_y;
@ -211,9 +207,7 @@ impl NPC {
self.anim_rect = state.constants.npc.n016_save_point[self.anim_num as usize];
self.vel_y += 0x40;
if self.vel_y > 0x5ff {
self.vel_y = 0x5ff;
}
self.clamp_fall_speed();
self.y += self.vel_y;
@ -281,9 +275,7 @@ impl NPC {
}
self.vel_y += 0x40;
if self.vel_y > 0x5ff {
self.vel_y = 0x5ff;
}
self.clamp_fall_speed();
self.y += self.vel_y;
@ -603,9 +595,7 @@ impl NPC {
self.anim_rect = state.constants.npc.n073_water_droplet[self.rng.range(0..4) as usize];
if self.vel_y > 0x5ff {
self.vel_y = 0x5ff;
}
self.clamp_fall_speed();
self.x += self.vel_x;
self.y += self.vel_y;
@ -1021,9 +1011,7 @@ impl NPC {
self.vel_y += 0x20;
if self.vel_y > 0x5ff {
self.vel_y = 0x5ff;
}
self.clamp_fall_speed();
self.y += self.vel_y;
@ -1891,9 +1879,7 @@ impl NPC {
if self.action_num >= 5 {
self.vel_y += 0x80;
if self.vel_y > 0x5ff {
self.vel_y = 0x5ff;
}
self.clamp_fall_speed();
self.y += self.vel_y;
}
@ -2516,9 +2502,7 @@ impl NPC {
}
self.vel_y += 0x40;
if self.vel_y > 0x5ff {
self.vel_y = 0x5ff;
}
self.clamp_fall_speed();
if self.flags.hit_bottom_wall() {
self.action_num = 2;

View file

@ -120,9 +120,7 @@ impl NPC {
self.vel_y += 0x40;
if self.vel_y > 0x5ff {
self.vel_y = 0x5ff;
}
self.clamp_fall_speed();
if self.flags.hit_bottom_wall() {
state.sound_manager.play_sfx(23);
@ -1202,9 +1200,7 @@ impl NPC {
self.vel_y += 0x40;
}
if self.vel_y > 0x5FF {
self.vel_y = 0x5FF;
}
self.clamp_fall_speed();
self.x += self.vel_x;
self.y += self.vel_y;

View file

@ -106,9 +106,7 @@ impl NPC {
_ => (),
}
self.vel_y += 0x20;
if self.vel_y > 0x5FF {
self.vel_y = 0x5FF;
}
self.clamp_fall_speed();
self.x += self.vel_x;
self.y += self.vel_y;
@ -277,9 +275,7 @@ impl NPC {
self.vel_y += 0x20;
if self.vel_y > 0x5FF {
self.vel_y = 0x5FF;
}
self.clamp_fall_speed();
self.x += self.vel_x;
self.y += self.vel_y;
@ -353,9 +349,7 @@ impl NPC {
}
self.vel_y += 0x40;
if self.vel_y > 0x5FF {
self.vel_y = 0x5FF;
}
self.clamp_fall_speed();
self.x += self.vel_x;
self.y += self.vel_y;
@ -583,9 +577,7 @@ impl NPC {
}
3 => {
self.vel_y += 0x40;
if self.vel_y > 0x5ff {
self.vel_y = 0x5ff;
}
self.clamp_fall_speed();
if self.flags.hit_bottom_wall() {
self.vel_y = 0;
@ -674,9 +666,7 @@ impl NPC {
}
self.vel_y += 0x20;
if self.vel_y > 0x5ff {
self.vel_y = 0x5ff;
}
self.clamp_fall_speed();
self.x += self.vel_x;
self.y += self.vel_y;
@ -821,9 +811,7 @@ impl NPC {
}
self.vel_y += 0x20;
if self.vel_y > 0x5FF {
self.vel_y = 0x5FF;
}
self.clamp_fall_speed();
self.x += self.vel_x;
self.y += self.vel_y;
@ -893,9 +881,7 @@ impl NPC {
}
self.vel_y += 0x20;
if self.vel_y > 0x5ff {
self.vel_y = 0x5ff;
}
self.clamp_fall_speed();
self.x += self.vel_x;
self.y += self.vel_y;
@ -1038,9 +1024,7 @@ impl NPC {
}
self.vel_y += 0x55;
if self.vel_y > 0x5FF {
self.vel_y = 0x5FF;
}
self.clamp_fall_speed();
self.x += self.vel_x;
self.y += self.vel_y;
@ -1092,9 +1076,7 @@ impl NPC {
}
self.vel_y += 0x40;
if self.vel_y > 0x5FF {
self.vel_y = 0x5FF;
}
self.clamp_fall_speed();
self.x += self.vel_x;
self.y += self.vel_y;

View file

@ -263,9 +263,7 @@ impl NPC {
}
self.vel_y += 0x40;
if self.vel_y > 0x5ff {
self.vel_y = 0x5ff;
}
self.clamp_fall_speed();
if self.flags.hit_bottom_wall() {
self.vel_y = 0;
@ -426,9 +424,7 @@ impl NPC {
}
self.vel_y += 0x40;
if self.vel_y > 0x5ff {
self.vel_y = 0x5ff;
}
self.clamp_fall_speed();
if self.flags.hit_bottom_wall() {
self.vel_y = 0;

View file

@ -395,9 +395,7 @@ impl NPC {
}
self.vel_y += 0x40;
if self.vel_y > 0x5ff {
self.vel_y = 0x5ff;
}
self.clamp_fall_speed();
self.x += self.vel_x;
self.y += self.vel_y;
@ -1030,9 +1028,7 @@ impl NPC {
self.vel_x = self.vel_x.clamp(-0x200, 0x200);
if self.vel_y > 0x5ff {
self.vel_y = 0x5ff;
}
self.clamp_fall_speed();
self.y += self.vel_y;
self.x += self.vel_x;
@ -1169,9 +1165,7 @@ impl NPC {
}
self.vel_y += 0x40;
if self.vel_y > 0x5ff {
self.vel_y = 0x5ff;
}
self.clamp_fall_speed();
self.x += self.vel_x;
self.y += self.vel_y;
@ -1242,9 +1236,7 @@ impl NPC {
}
self.vel_y += 0x40;
if self.vel_y > 0x5FF {
self.vel_y = 0x5FF;
}
self.clamp_fall_speed();
self.x += self.vel_x;
self.y += self.vel_y;
@ -1355,9 +1347,7 @@ impl NPC {
}
self.vel_y += 0x40;
if self.vel_y > 0x5ff {
self.vel_y = 0x5ff;
}
self.clamp_fall_speed();
self.x += self.vel_x;
self.y += self.vel_y;
@ -1515,9 +1505,7 @@ impl NPC {
_ => (),
}
self.vel_y += 0x40;
if self.vel_y > 0x5FF {
self.vel_y = 0x5FF;
}
self.clamp_fall_speed();
self.y += self.vel_y;
let dir_offset = if self.direction == Direction::Left { 0 } else { 3 };
@ -1616,9 +1604,7 @@ impl NPC {
}
}
self.vel_y += 0x33;
if self.vel_y > 0x5FF {
self.vel_y = 0x5FF;
}
self.clamp_fall_speed();
self.vel_x = clamp(self.vel_x, -0x5ff, 0x5ff);
self.y += self.vel_y;

View file

@ -213,9 +213,7 @@ impl NPC {
self.vel_y += 0x40;
self.vel_x = self.vel_x.clamp(-0x400, 0x400);
if self.vel_y > 0x5ff {
self.vel_y = 0x5ff;
}
self.clamp_fall_speed();
self.x += self.vel_x;
self.y += self.vel_y;
@ -315,9 +313,7 @@ impl NPC {
if self.action_num > 1 {
self.vel_y += 0x20;
if self.vel_y > 0x5FF {
self.vel_y = 0x5FF;
}
self.clamp_fall_speed();
self.y += self.vel_y;
}
@ -543,9 +539,7 @@ impl NPC {
}
self.vel_y += 0x20;
if self.vel_y > 0x5FF {
self.vel_y = 0x5FF;
}
self.clamp_fall_speed();
}
43 => {
self.action_counter += 1;

View file

@ -154,9 +154,7 @@ impl NPC {
self.vel_y += 0x40;
self.vel_x = self.vel_x.clamp(-0x400, 0x400);
if self.vel_y > 0x5ff {
self.vel_y = 0x5ff;
}
self.clamp_fall_speed();
self.x += self.vel_x;
self.y += self.vel_y;
@ -258,9 +256,7 @@ impl NPC {
self.vel_y += 0x40;
self.vel_x = self.vel_x.clamp(-0x400, 0x400);
if self.vel_y > 0x5ff {
self.vel_y = 0x5ff;
}
self.clamp_fall_speed();
self.x += self.vel_x;
self.y += self.vel_y;
@ -812,9 +808,7 @@ impl NPC {
if self.action_num > 1 {
self.vel_y += 0x20;
if self.vel_y > 0x5ff {
self.vel_y = 0x5ff;
}
self.clamp_fall_speed();
self.y += self.vel_y;
}

View file

@ -463,9 +463,7 @@ impl BossNPC {
}
self.parts[0].vel_y += 0x40;
if self.parts[0].vel_y > 0x5ff {
self.parts[0].vel_y = 0x5ff;
}
self.parts[0].clamp_fall_speed();
self.parts[0].x += self.parts[0].vel_x;
self.parts[0].y += self.parts[0].vel_y;

View file

@ -30,9 +30,7 @@ impl NPC {
}
self.vel_y += 0x40;
if self.vel_y > 0x5FF {
self.vel_y = 0x5FF;
}
self.clamp_fall_speed();
self.x += self.vel_x;
self.y += self.vel_y;
@ -426,9 +424,7 @@ impl NPC {
}
self.vel_y += 0x80;
if self.vel_y > 0x5FF {
self.vel_y = 0x5FF;
}
self.clamp_fall_speed();
self.animate(1, 4, 5);
@ -525,9 +521,7 @@ impl NPC {
npc_list.create_death_smoke(self.x, self.y, 16, 16, state, &self.rng);
}
self.vel_y += 0x20;
if self.vel_y > 0x5FF {
self.vel_y = 0x5FF;
}
self.clamp_fall_speed();
self.action_counter;
self.x = self.target_x + if self.action_counter & 0x02 != 0 { 0x200 } else { -0x200 };
@ -775,9 +769,7 @@ impl NPC {
}
self.vel_y += 0x20;
if self.vel_y > 0x5FF {
self.vel_y = 0x5FF;
}
self.clamp_fall_speed();
}
1000 | 1001 => {
if self.action_num == 1000 {

View file

@ -74,8 +74,7 @@ impl BossNPC {
self.parts[0].target_y = self.parts[0].y;
self.parts[0].display_bounds =
Rect { left: 40 * 0x200, top: 40 * 0x200, right: 40 * 0x200, bottom: 0x2000 };
self.parts[0].hit_bounds =
Rect { left: 0x1000, top: 24 * 0x200, right: 0x1000, bottom: 0x2000 };
self.parts[0].hit_bounds = Rect { left: 0x1000, top: 24 * 0x200, right: 0x1000, bottom: 0x2000 };
self.parts[1].cond.set_alive(true);
self.parts[1].display_bounds =
@ -93,10 +92,8 @@ impl BossNPC {
self.parts[3].direction = Direction::Left;
self.parts[3].x = self.parts[0].x + 0x2000;
self.parts[3].y = self.parts[0].y;
self.parts[3].display_bounds =
Rect { left: 24 * 0x200, top: 0x2000, right: 0x2000, bottom: 0x2000 };
self.parts[3].hit_bounds =
Rect { left: 0x1000, top: 0x1000, right: 0x1000, bottom: 0x1000 };
self.parts[3].display_bounds = Rect { left: 24 * 0x200, top: 0x2000, right: 0x2000, bottom: 0x2000 };
self.parts[3].hit_bounds = Rect { left: 0x1000, top: 0x1000, right: 0x1000, bottom: 0x1000 };
self.hurt_sound[3] = 52;
self.parts[4].cond.set_alive(true);
@ -309,9 +306,7 @@ impl BossNPC {
let player = self.parts[5].get_closest_player_mut(players);
self.parts[5].damage = if player.flags.hit_bottom_wall() && self.parts[0].vel_y > 0 { 20 } else { 0 };
self.parts[0].vel_y += 0x24;
if self.parts[0].vel_y > 0x5ff {
self.parts[0].vel_y = 0x5ff;
}
self.parts[0].clamp_fall_speed();
self.parts[0].y += self.parts[0].vel_y;
self.parts[0].x += self.parts[0].vel_x;
@ -416,8 +411,7 @@ impl BossNPC {
self.parts[5].action_num = 1;
self.parts[5].npc_flags.set_solid_soft(true);
self.parts[5].npc_flags.set_ignore_solidity(true);
self.parts[5].hit_bounds =
Rect { left: 20 * 0x200, top: 36 * 0x200, right: 20 * 0x200, bottom: 0x2000 };
self.parts[5].hit_bounds = Rect { left: 20 * 0x200, top: 36 * 0x200, right: 20 * 0x200, bottom: 0x2000 };
}
self.parts[5].x = self.parts[0].x;

View file

@ -254,9 +254,7 @@ impl NPC {
}
Direction::Bottom => {
self.vel_y += 0x20;
if self.vel_y > 0x5FF {
self.vel_y = 0x5FF;
}
self.clamp_fall_speed();
if self.flags.hit_bottom_wall() {
self.action_num = 2;

View file

@ -12,6 +12,8 @@ use crate::rng::{Xoroshiro32PlusPlus, RNG};
use crate::shared_game_state::{SharedGameState, TileSize};
use crate::weapon::bullet::Bullet;
const MAX_FALL_SPEED: i32 = 0x5FF;
impl NPC {
/// Initializes the RNG. Called when the [NPC] is being added to an [NPCList].
pub(crate) fn init_rng(&mut self) {
@ -166,6 +168,13 @@ impl NPC {
self.direction = if self.x > player.x { Direction::Left } else { Direction::Right };
}
/// Clamps +Y velocity if above `MAX_FALL_SPEED`.
pub fn clamp_fall_speed(&mut self) {
if self.vel_y > MAX_FALL_SPEED {
self.vel_y = MAX_FALL_SPEED;
}
}
/// Returns true if the [NPC] collides with a [Bullet].
pub fn collides_with_bullet(&self, bullet: &Bullet) -> bool {
(self.npc_flags.shootable()