mirror of
https://github.com/doukutsu-rs/doukutsu-rs
synced 2025-11-30 00:03:33 +00:00
Add missing NPCs (Egg Corridor, Sand Zone, Arthur's House)
This commit is contained in:
parent
0292e27e11
commit
749684c437
|
|
@ -2,6 +2,7 @@ use ggez::GameResult;
|
|||
|
||||
use crate::npc::NPC;
|
||||
use crate::shared_game_state::SharedGameState;
|
||||
use crate::common::Direction;
|
||||
|
||||
impl NPC {
|
||||
pub(crate) fn tick_n113_professor_booster(&mut self, state: &mut SharedGameState) -> GameResult {
|
||||
|
|
@ -12,9 +13,82 @@ impl NPC {
|
|||
self.anim_num = 0;
|
||||
self.anim_counter = 0;
|
||||
}
|
||||
|
||||
if self.rng.range(0..120) == 10 {
|
||||
self.action_num = 2;
|
||||
self.action_counter = 0;
|
||||
self.anim_num = 1;
|
||||
}
|
||||
}
|
||||
2 => {
|
||||
self.action_counter += 1;
|
||||
if self.action_counter > 8 {
|
||||
self.action_num = 1;
|
||||
self.anim_num = 0;
|
||||
}
|
||||
}
|
||||
3 | 4 => {
|
||||
if self.action_num == 3 {
|
||||
self.action_num = 4;
|
||||
self.anim_num = 2;
|
||||
self.anim_counter = 0;
|
||||
}
|
||||
|
||||
self.animate(5, 2, 5);
|
||||
|
||||
self.x += self.direction.vector_x() * 0x200;
|
||||
}
|
||||
5 => {
|
||||
self.anim_num = 6;
|
||||
}
|
||||
30 | 31 => {
|
||||
if self.action_num == 30 {
|
||||
self.action_num = 31;
|
||||
self.anim_num = 0;
|
||||
self.anim_counter = 0;
|
||||
self.hit_bounds.bottom = 16 * 0x200;
|
||||
self.x -= 16 * 0x200;
|
||||
self.y += 8 * 0x200;
|
||||
}
|
||||
|
||||
self.action_counter += 1;
|
||||
if self.action_counter == 64 {
|
||||
self.action_num = 32;
|
||||
self.action_counter = 0;
|
||||
}
|
||||
}
|
||||
32 => {
|
||||
self.action_counter += 1;
|
||||
if self.action_counter > 20 {
|
||||
self.action_num = 33;
|
||||
self.anim_num = 1;
|
||||
self.hit_bounds.bottom = 8 * 0x200;
|
||||
}
|
||||
}
|
||||
33 => {
|
||||
if self.flags.hit_bottom_wall() {
|
||||
self.action_num = 34;
|
||||
self.action_counter = 0;
|
||||
self.anim_num = 0;
|
||||
}
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
|
||||
self.vel_y += 0x40;
|
||||
self.y += self.vel_y;
|
||||
|
||||
let dir_offset = if self.direction == Direction::Left { 0 } else { 7 };
|
||||
|
||||
self.anim_rect = state.constants.npc.n113_professor_booster[self.anim_num as usize + dir_offset];
|
||||
|
||||
if self.action_num == 31 {
|
||||
self.anim_rect.bottom = self.action_counter / 4 + self.anim_rect.top;
|
||||
if self.action_counter / 2 % 2 != 0 {
|
||||
self.anim_rect.left += 1;
|
||||
}
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -331,12 +331,42 @@ impl NPC {
|
|||
self.x += self.vel_x;
|
||||
self.y += self.vel_y;
|
||||
|
||||
if self.direction == Direction::Left {
|
||||
self.anim_rect = state.constants.npc.n074_jack[self.anim_num as usize];
|
||||
} else {
|
||||
self.anim_rect = state.constants.npc.n074_jack[self.anim_num as usize + 6];
|
||||
let dir_offset = if self.direction == Direction::Left { 0 } else { 6 };
|
||||
|
||||
self.anim_rect = state.constants.npc.n074_jack[self.anim_num as usize + dir_offset];
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub(crate) fn tick_n151_blue_robot_standing(&mut self, state: &mut SharedGameState) -> GameResult {
|
||||
match self.action_num {
|
||||
0 | 1 => {
|
||||
if self.action_num == 0{
|
||||
self.action_num = 1;
|
||||
self.anim_num = 0;
|
||||
self.anim_counter = 0;
|
||||
}
|
||||
|
||||
if self.rng.range(0..100) == 0 {
|
||||
self.action_num = 2;
|
||||
self.action_counter = 0;
|
||||
self.anim_num = 1;
|
||||
}
|
||||
}
|
||||
2 => {
|
||||
self.action_counter += 1;
|
||||
if self.action_counter > 16 {
|
||||
self.action_num = 1;
|
||||
self.anim_num = 0;
|
||||
}
|
||||
}
|
||||
_ =>{}
|
||||
}
|
||||
|
||||
let dir_offset = if self.direction == Direction::Left { 0 } else { 2 };
|
||||
|
||||
self.anim_rect = state.constants.npc.n151_blue_robot_standing[self.anim_num as usize + dir_offset];
|
||||
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -976,6 +976,41 @@ impl NPC {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
pub(crate) fn tick_n125_hidden_item(&mut self, state: &mut SharedGameState) -> GameResult {
|
||||
if self.life < 990 {
|
||||
self.cond.set_drs_destroyed(true);
|
||||
match self.direction {
|
||||
/// hidden heart
|
||||
Direction::Left => {
|
||||
let mut npc = NPCMap::create_npc(87, &state.npc_table);
|
||||
npc.cond.set_alive(true);
|
||||
npc.x = self.x;
|
||||
npc.y = self.y;
|
||||
npc.direction = Direction::Right;
|
||||
state.new_npcs.push(npc);
|
||||
}
|
||||
/// hidden missile
|
||||
Direction::Right => {
|
||||
let mut npc = NPCMap::create_npc(86, &state.npc_table);
|
||||
npc.cond.set_alive(true);
|
||||
npc.x = self.x;
|
||||
npc.y = self.y;
|
||||
npc.direction = Direction::Right;
|
||||
state.new_npcs.push(npc);
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
|
||||
match self.direction {
|
||||
Direction::Left => self.anim_rect = state.constants.npc.n125_hidden_item[0],
|
||||
Direction::Right => self.anim_rect = state.constants.npc.n125_hidden_item[1],
|
||||
_ => {}
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub(crate) fn tick_n149_horizontal_moving_block(&mut self, state: &mut SharedGameState, players: [&mut Player; 2]) -> GameResult {
|
||||
match self.action_num {
|
||||
0 => {
|
||||
|
|
@ -1265,4 +1300,19 @@ impl NPC {
|
|||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub(crate) fn tick_n234_red_flowers_picked(&mut self, state: &mut SharedGameState) -> GameResult {
|
||||
if self.action_num == 0 {
|
||||
self.action_num = 1;
|
||||
self.y += 16 * 0x200;
|
||||
|
||||
match self.direction {
|
||||
Direction::Left => self.anim_rect = state.constants.npc.n234_red_flowers_picked[0],
|
||||
Direction::Right => self.anim_rect = state.constants.npc.n234_red_flowers_picked[1],
|
||||
_ => self.anim_rect = state.constants.npc.n234_red_flowers_picked[1],
|
||||
}
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -116,7 +116,7 @@ pub struct NPC {
|
|||
pub rng: Xoroshiro32PlusPlus,
|
||||
}
|
||||
|
||||
static PARTICLE_NPCS: [u16; 11] = [1, 4, 11, 73, 84, 86, 87, 108, 129, 199, 355];
|
||||
static PARTICLE_NPCS: [u16; 12] = [1, 4, 11, 45, 73, 84, 86, 87, 108, 129, 199, 355];
|
||||
|
||||
impl NPC {
|
||||
pub fn get_start_index(&self) -> u16 {
|
||||
|
|
@ -214,7 +214,10 @@ impl GameEntity<([&mut Player; 2], &BTreeMap<u16, RefCell<NPC>>, &mut Stage)> fo
|
|||
41 => self.tick_n041_busted_door(state),
|
||||
42 => self.tick_n042_sue(state, players, map),
|
||||
43 => self.tick_n043_chalkboard(state),
|
||||
44 => self.tick_n044_polish(state),
|
||||
45 => self.tick_n045_baby(state),
|
||||
46 => self.tick_n046_hv_trigger(players),
|
||||
47 => self.tick_n047_sandcroc(state, players),
|
||||
52 => self.tick_n052_sitting_blue_robot(state),
|
||||
55 => self.tick_n055_kazuma(state),
|
||||
58 => self.tick_n058_basu(state, players),
|
||||
|
|
@ -271,10 +274,14 @@ impl GameEntity<([&mut Player; 2], &BTreeMap<u16, RefCell<NPC>>, &mut Stage)> fo
|
|||
110 => self.tick_n110_puchi(state, players),
|
||||
111 => self.tick_n111_quote_teleport_out(state, players),
|
||||
112 => self.tick_n112_quote_teleport_in(state, players),
|
||||
113 => self.tick_n113_professor_booster(state),
|
||||
114 => self.tick_n114_press(state, players),
|
||||
124 => self.tick_n124_sunstone(state),
|
||||
125 => self.tick_n125_hidden_item(state),
|
||||
129 => self.tick_n129_fireball_snake_trail(state),
|
||||
149 => self.tick_n149_horizontal_moving_block(state, players),
|
||||
150 => self.tick_n150_quote(state, players),
|
||||
151 => self.tick_n151_blue_robot_standing(state),
|
||||
154 => self.tick_n154_gaudi_dead(state),
|
||||
157 => self.tick_n157_vertical_moving_block(state, players),
|
||||
192 => self.tick_n192_scooter(state),
|
||||
|
|
@ -282,6 +289,7 @@ impl GameEntity<([&mut Player; 2], &BTreeMap<u16, RefCell<NPC>>, &mut Stage)> fo
|
|||
194 => self.tick_n194_broken_blue_robot(state),
|
||||
199 => self.tick_n199_wind_particles(state),
|
||||
211 => self.tick_n211_small_spikes(state),
|
||||
234 => self.tick_n234_red_flowers_picked(state),
|
||||
298 => self.tick_n298_intro_doctor(state),
|
||||
299 => self.tick_n299_intro_balrog_misery(state),
|
||||
300 => self.tick_n300_intro_demon_crown(state),
|
||||
|
|
|
|||
|
|
@ -0,0 +1,327 @@
|
|||
use ggez::GameResult;
|
||||
use num_traits::{abs, clamp};
|
||||
|
||||
use crate::common::Direction;
|
||||
use crate::npc::{NPC, NPCMap};
|
||||
use crate::player::Player;
|
||||
use crate::shared_game_state::SharedGameState;
|
||||
|
||||
impl NPC {
|
||||
pub(crate) fn tick_n044_polish(&mut self, state: &mut SharedGameState) -> GameResult {
|
||||
match self.action_num {
|
||||
0 | 1 => {
|
||||
self.anim_num = 0;
|
||||
self.action_num = match self.direction {
|
||||
Direction::Left => 8,
|
||||
Direction::Right => 2,
|
||||
_ => 8,
|
||||
};
|
||||
}
|
||||
2 => {
|
||||
self.vel_y += 0x20;
|
||||
if self.vel_y > 0 && self.flags.hit_bottom_wall() {
|
||||
self.vel_y = -0x100;
|
||||
self.vel_x += 0x100;
|
||||
}
|
||||
|
||||
if self.flags.hit_right_wall() {
|
||||
self.action_num = 3;
|
||||
}
|
||||
}
|
||||
3 => {
|
||||
self.vel_x += 0x20;
|
||||
if self.vel_x > 0 && self.flags.hit_right_wall() {
|
||||
self.vel_x = -0x100;
|
||||
self.vel_y -= 0x100;
|
||||
}
|
||||
|
||||
if self.flags.hit_top_wall() {
|
||||
self.action_num = 4;
|
||||
}
|
||||
}
|
||||
4 => {
|
||||
self.vel_y -= 0x20;
|
||||
if self.vel_y < 0 && self.flags.hit_top_wall() {
|
||||
self.vel_y = 0x100;
|
||||
self.vel_x -= 0x100;
|
||||
}
|
||||
|
||||
if self.flags.hit_left_wall() {
|
||||
self.action_num = 5;
|
||||
}
|
||||
}
|
||||
5 => {
|
||||
self.vel_x -= 0x20;
|
||||
if self.vel_x < 0 && self.flags.hit_left_wall() {
|
||||
self.vel_x = 0x100;
|
||||
self.vel_y += 0x100;
|
||||
}
|
||||
|
||||
if self.flags.hit_bottom_wall() {
|
||||
self.action_num = 2;
|
||||
}
|
||||
}
|
||||
6 => {
|
||||
self.vel_y += 0x20;
|
||||
if self.vel_y > 0 && self.flags.hit_bottom_wall() {
|
||||
self.vel_y = -0x100;
|
||||
self.vel_x -= 0x100;
|
||||
}
|
||||
|
||||
if self.flags.hit_left_wall() {
|
||||
self.action_num = 7;
|
||||
}
|
||||
}
|
||||
7 => {
|
||||
self.vel_x -= 0x20;
|
||||
if self.vel_x < 0 && self.flags.hit_left_wall() {
|
||||
self.vel_x = 0x100;
|
||||
self.vel_y -= 0x100;
|
||||
}
|
||||
|
||||
if self.flags.hit_top_wall() {
|
||||
self.action_num = 8;
|
||||
}
|
||||
}
|
||||
8 => {
|
||||
self.vel_y -= 0x20;
|
||||
if self.vel_y < 0 && self.flags.hit_top_wall() {
|
||||
self.vel_y = 0x100;
|
||||
self.vel_x += 0x100;
|
||||
}
|
||||
|
||||
if self.flags.hit_right_wall() {
|
||||
self.action_num = 9;
|
||||
}
|
||||
}
|
||||
9 => {
|
||||
self.vel_x += 0x20;
|
||||
if self.vel_x > 0 && self.flags.hit_right_wall() {
|
||||
self.vel_x = -0x100;
|
||||
self.vel_y += 0x100;
|
||||
}
|
||||
|
||||
if self.flags.hit_bottom_wall() {
|
||||
self.action_num = 6;
|
||||
}
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
|
||||
if self.life <= 100 {
|
||||
self.cond.set_drs_destroyed(true);
|
||||
state.sound_manager.play_sfx(25);
|
||||
|
||||
let mut npc = NPCMap::create_npc(45, &state.npc_table);
|
||||
npc.cond.set_alive(true);
|
||||
npc.x = self.x;
|
||||
npc.y = self.y;
|
||||
for _ in 0..9 {
|
||||
state.new_npcs.push(npc);
|
||||
}
|
||||
}
|
||||
|
||||
self.vel_x = clamp(self.vel_x, -0x200, 0x200);
|
||||
self.vel_y = clamp(self.vel_y, -0x200, 0x200);
|
||||
|
||||
if self.shock > 0 {
|
||||
self.x += self.vel_x / 2;
|
||||
self.y += self.vel_y / 2;
|
||||
} else {
|
||||
self.x += self.vel_x;
|
||||
self.y += self.vel_y;
|
||||
}
|
||||
|
||||
if self.action_num > 1 && self.action_num <= 9 {
|
||||
self.anim_num += 1;
|
||||
if self.anim_num > 2 {
|
||||
self.anim_num = 1;
|
||||
}
|
||||
}
|
||||
|
||||
let dir_offset = if self.direction == Direction::Left { 0 } else { 3 };
|
||||
|
||||
self.anim_rect = state.constants.npc.n044_polish[self.anim_num as usize + dir_offset];
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub(crate) fn tick_n045_baby(&mut self, state: &mut SharedGameState) -> GameResult {
|
||||
if self.action_num == 0 {
|
||||
self.action_num = 2;
|
||||
self.vel_x = if self.rng.next_u16() & 1 != 0 {
|
||||
self.rng.range(-0x200..-0x100) as isize
|
||||
} else {
|
||||
self.rng.range(0x100..0x200) as isize
|
||||
};
|
||||
self.vel_y = if self.rng.next_u16() & 1 != 0 {
|
||||
self.rng.range(-0x200..-0x100) as isize
|
||||
} else {
|
||||
self.rng.range(0x100..0x200) as isize
|
||||
};
|
||||
self.vel_x2 = self.vel_x;
|
||||
self.vel_y2 = self.vel_y;
|
||||
}
|
||||
|
||||
match self.action_num {
|
||||
1 | 2 => {
|
||||
self.anim_num += 1;
|
||||
if self.anim_num > 2 {
|
||||
self.anim_num = 1;
|
||||
}
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
|
||||
if self.vel_x2 < 0 && self.flags.hit_left_wall() {
|
||||
self.vel_x2 = -self.vel_x2;
|
||||
}
|
||||
|
||||
if self.vel_x2 > 0 && self.flags.hit_right_wall() {
|
||||
self.vel_x2 = -self.vel_x2;
|
||||
}
|
||||
|
||||
if self.vel_y2 < 0 && self.flags.hit_top_wall() {
|
||||
self.vel_y2 = -self.vel_y2;
|
||||
}
|
||||
|
||||
if self.vel_y2 > 0 && self.flags.hit_bottom_wall() {
|
||||
self.vel_y2 = -self.vel_y2;
|
||||
}
|
||||
|
||||
self.vel_x2 = clamp(self.vel_x2, -0x200, 0x200);
|
||||
self.vel_y2 = clamp(self.vel_y2, -0x200, 0x200);
|
||||
|
||||
if self.shock > 0 {
|
||||
self.x += self.vel_x2 / 2;
|
||||
self.y += self.vel_y2 / 2;
|
||||
} else {
|
||||
self.x += self.vel_x2;
|
||||
self.y += self.vel_y2;
|
||||
}
|
||||
|
||||
self.anim_rect = state.constants.npc.n045_baby[self.anim_num as usize];
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub(crate) fn tick_n047_sandcroc(&mut self, state: &mut SharedGameState, players: [&mut Player; 2]) -> GameResult {
|
||||
match self.action_num {
|
||||
0 | 1 => {
|
||||
if self.action_num == 0 {
|
||||
self.action_num = 1;
|
||||
self.action_counter = 0;
|
||||
self.anim_num = 0;
|
||||
self.target_y = self.y;
|
||||
self.npc_flags.set_shootable(false);
|
||||
self.npc_flags.set_ignore_solidity(false);
|
||||
self.npc_flags.set_invulnerable(false);
|
||||
self.npc_flags.set_solid_soft(false);
|
||||
}
|
||||
|
||||
let player = self.get_closest_player_mut(players);
|
||||
if abs(self.x - player.x) < 8 * 0x200 && player.y > self.y && player.y < self.y + 8 * 0x200 {
|
||||
self.action_num = 2;
|
||||
self.action_counter = 0;
|
||||
state.sound_manager.play_sfx(102);
|
||||
}
|
||||
|
||||
self.x += (player.x - self.x).signum() * 2 * 0x200;
|
||||
}
|
||||
2 => {
|
||||
self.anim_counter += 1;
|
||||
if self.anim_counter > 3 {
|
||||
self.anim_num += 1;
|
||||
self.anim_counter = 0;
|
||||
}
|
||||
|
||||
match self.anim_num {
|
||||
3 => self.damage = 10,
|
||||
4 => {
|
||||
self.action_num = 3;
|
||||
self.action_counter = 0;
|
||||
self.npc_flags.set_shootable(true);
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
3 => {
|
||||
self.damage = 0;
|
||||
self.npc_flags.set_solid_soft(true);
|
||||
|
||||
self.action_counter += 1;
|
||||
if self.shock > 0 {
|
||||
self.action_num = 4;
|
||||
self.action_counter = 0;
|
||||
}
|
||||
}
|
||||
4 => {
|
||||
self.npc_flags.set_ignore_solidity(true);
|
||||
self.y += 0x200;
|
||||
self.action_counter += 1;
|
||||
if self.action_counter == 32 {
|
||||
self.action_num = 5;
|
||||
self.action_counter = 0;
|
||||
self.npc_flags.set_solid_soft(false);
|
||||
self.npc_flags.set_shootable(false);
|
||||
}
|
||||
}
|
||||
5 => {
|
||||
if self.action_counter > 99 {
|
||||
self.y = self.target_y;
|
||||
self.action_num = 0;
|
||||
self.anim_num = 0;
|
||||
} else {
|
||||
self.action_counter += 1;
|
||||
}
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
|
||||
self.anim_rect = state.constants.npc.n047_sandcroc[self.anim_num as usize];
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub(crate) fn tick_n124_sunstone(&mut self, state: &mut SharedGameState) -> GameResult {
|
||||
match self.action_num {
|
||||
0 | 1 => {
|
||||
if self.action_num ==0 {
|
||||
self.action_num = 1;
|
||||
self.x += 8 * 0x200;
|
||||
self.y += 8 * 0x200;
|
||||
}
|
||||
|
||||
self.npc_flags.set_ignore_solidity(false);
|
||||
self.anim_num = 0;
|
||||
}
|
||||
10 | 11 => {
|
||||
if self.action_num == 10 {
|
||||
self.action_num = 11;
|
||||
self.action_counter = 0;
|
||||
self.anim_num = 1;
|
||||
|
||||
self.npc_flags.set_ignore_solidity(true);
|
||||
}
|
||||
|
||||
match self.direction {
|
||||
Direction::Left => self.x -= 0x80,
|
||||
Direction::Up => self.y -= 0x80,
|
||||
Direction::Right => self.x += 0x80,
|
||||
Direction::Bottom => self.y += 0x80,
|
||||
Direction::FacingPlayer => {}
|
||||
}
|
||||
|
||||
state.quake_counter= 20;
|
||||
if self.action_counter % 8 == 0 {
|
||||
state.sound_manager.play_sfx(26);
|
||||
}
|
||||
}
|
||||
_ =>{}
|
||||
}
|
||||
|
||||
self.anim_rect = state.constants.npc.n124_sunstone[self.anim_num as usize];
|
||||
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue