mirror of
https://github.com/doukutsu-rs/doukutsu-rs
synced 2025-11-22 21:14:15 +00:00
a bunch of new npcs
This commit is contained in:
parent
c5b058014a
commit
9d76cf7e48
|
|
@ -644,6 +644,7 @@ impl EngineConstants {
|
|||
"Npc/NpcHeri" => (320, 128),
|
||||
"Npc/NpcIronH" => (320, 72),
|
||||
"Npc/NpcIsland" => (320, 80),
|
||||
"Npc/NpcKaze" => (320, 240),
|
||||
"Npc/NpcKings" => (96, 48),
|
||||
"Npc/NpcMaze" => (320, 192),
|
||||
"Npc/NpcMiza" => (320, 240),
|
||||
|
|
|
|||
|
|
@ -684,4 +684,145 @@ impl NPC {
|
|||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub(crate) fn tick_n208_basu_destroyed_egg_corridor(&mut self, state: &mut SharedGameState, players: [&mut Player; 2], npc_list: &NPCList) -> GameResult {
|
||||
let player = self.get_closest_player_mut(players);
|
||||
|
||||
match self.action_num {
|
||||
0 => {
|
||||
if player.x < self.x + 16 * 0x200 && player.x > self.x - 16 * 0x200 {
|
||||
self.target_x = self.x;
|
||||
self.target_y = self.y;
|
||||
self.action_num = 1;
|
||||
self.action_counter = 0;
|
||||
self.action_counter2 = 0;
|
||||
self.damage = 6;
|
||||
self.vel_y = -0x100;
|
||||
self.tsc_direction = self.direction as u16;
|
||||
self.npc_flags.set_shootable(true);
|
||||
|
||||
self.x = player.x + self.direction.vector_x() * 16 * 16 * 0x200;
|
||||
self.vel_x = self.direction.vector_x() * 0x2ff;
|
||||
} else {
|
||||
self.anim_rect = Rect::new(0, 0, 0, 0);
|
||||
self.damage = 0;
|
||||
self.vel_x = 0;
|
||||
self.vel_y = 0;
|
||||
self.npc_flags.set_shootable(false);
|
||||
}
|
||||
|
||||
return Ok(());
|
||||
}
|
||||
1 => {
|
||||
if self.x > player.x {
|
||||
self.direction = Direction::Left;
|
||||
self.vel_x -= 0x10;
|
||||
} else {
|
||||
self.direction = Direction::Right;
|
||||
self.vel_x += 0x10;
|
||||
}
|
||||
|
||||
if self.flags.hit_left_wall() {
|
||||
self.vel_x = 0x200;
|
||||
}
|
||||
|
||||
if self.flags.hit_right_wall() {
|
||||
self.vel_x = -0x200;
|
||||
}
|
||||
|
||||
self.vel_y += ((self.target_y - self.y).signum() | 1) * 0x08;
|
||||
|
||||
self.vel_x = clamp(self.vel_x, -0x2ff, 0x2ff);
|
||||
self.vel_y = clamp(self.vel_y, -0x100, 0x100);
|
||||
|
||||
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 player.x > self.x + 400 * 0x200 || player.x < self.x - 400 * 0x200 {
|
||||
self.action_num = 0;
|
||||
self.vel_x = 0;
|
||||
self.x = self.target_x;
|
||||
self.damage = 0;
|
||||
self.direction = Direction::from_int_facing(self.tsc_direction as usize)
|
||||
.unwrap_or(Direction::Left);
|
||||
self.anim_rect = Rect::new(0, 0, 0, 0);
|
||||
return Ok(());
|
||||
}
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
|
||||
if self.action_counter < 150 {
|
||||
self.action_counter += 1;
|
||||
} else {
|
||||
self.action_counter2 += 1;
|
||||
if (self.action_counter2 % 8) == 0 && abs(self.x - player.x) < 160 * 0x200 {
|
||||
let angle = f64::atan2((self.y - player.y) as f64, (self.x - player.x) as f64)
|
||||
+ self.rng.range(-6..6) as f64 * CDEG_RAD;
|
||||
|
||||
let mut npc = NPC::create(209, &state.npc_table);
|
||||
npc.cond.set_alive(true);
|
||||
npc.x = self.x;
|
||||
npc.y = self.y;
|
||||
npc.vel_x = (angle.cos() * -1536.0) as i32;
|
||||
npc.vel_y = (angle.sin() * -1536.0) as i32;
|
||||
|
||||
let _ = npc_list.spawn(0x100, npc);
|
||||
state.sound_manager.play_sfx(39);
|
||||
}
|
||||
|
||||
if self.action_counter2 > 16 {
|
||||
self.action_counter = 0;
|
||||
self.action_counter2 = 0;
|
||||
}
|
||||
}
|
||||
|
||||
self.anim_counter += 1;
|
||||
if self.anim_counter > 1 {
|
||||
self.anim_counter = 0;
|
||||
self.anim_num += 1;
|
||||
if self.anim_num > 1 {
|
||||
self.anim_num = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if self.action_counter > 120 && self.action_counter / 2 % 2 == 1 && self.anim_num == 1 {
|
||||
self.anim_num = 2;
|
||||
}
|
||||
|
||||
let dir_offset = if self.direction == Direction::Left { 0 } else { 3 };
|
||||
self.anim_rect = state.constants.npc.n208_basu_destroyed_egg_corridor[self.anim_num as usize + dir_offset];
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub(crate) fn tick_n209_basu_projectile_destroyed_egg_corridor(&mut self, state: &mut SharedGameState) -> GameResult {
|
||||
self.x += self.vel_x;
|
||||
self.y += self.vel_y;
|
||||
|
||||
self.anim_counter += 1;
|
||||
if self.anim_counter > 2 {
|
||||
self.anim_counter = 0;
|
||||
self.anim_num += 1;
|
||||
|
||||
if self.anim_num > 3 {
|
||||
self.anim_num = 0;
|
||||
}
|
||||
}
|
||||
|
||||
self.anim_rect = state.constants.npc.n209_basu_projectile_destroyed_egg_corridor[self.anim_num as usize];
|
||||
|
||||
self.action_counter2 += 1;
|
||||
if self.flags.0 != 0 || self.action_counter2 > 300 {
|
||||
state.create_caret(self.x, self.y, CaretType::ProjectileDissipation, Direction::Left);
|
||||
self.cond.set_alive(false);
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,6 +10,48 @@ use crate::shared_game_state::SharedGameState;
|
|||
|
||||
impl NPC {
|
||||
pub(crate) fn tick_n154_gaudi_dead(&mut self, state: &mut SharedGameState) -> GameResult {
|
||||
match self.action_num {
|
||||
0 => {
|
||||
self.npc_flags.set_shootable(false);
|
||||
self.npc_flags.set_ignore_solidity(false);
|
||||
self.damage = 0;
|
||||
self.action_num = 1;
|
||||
self.anim_num = 0;
|
||||
self.vel_y = -0x200;
|
||||
|
||||
match self.direction {
|
||||
Direction::Left => self.vel_x = 0x100,
|
||||
Direction::Right => self.vel_x = -0x100,
|
||||
_ => {},
|
||||
};
|
||||
state.sound_manager.play_sfx(53);
|
||||
}
|
||||
1 if self.flags.hit_bottom_wall() => {
|
||||
self.action_num = 2;
|
||||
self.action_counter = 0;
|
||||
self.anim_num = 1;
|
||||
self.anim_counter = 0;
|
||||
}
|
||||
2 => {
|
||||
self.vel_x = 8 * self.vel_x / 9;
|
||||
self.animate(3, 1, 2);
|
||||
|
||||
self.action_counter += 1;
|
||||
if self.action_counter > 50 {
|
||||
self.cond.set_explode_die(true);
|
||||
}
|
||||
}
|
||||
_ => {},
|
||||
}
|
||||
|
||||
self.vel_y += 0x20;
|
||||
if self.vel_y > 0x5ff {
|
||||
self.vel_y = 0x5ff;
|
||||
}
|
||||
|
||||
self.x += self.vel_x;
|
||||
self.y += self.vel_y;
|
||||
|
||||
let dir_offset = if self.direction == Direction::Left { 0 } else { 3 };
|
||||
self.anim_rect = state.constants.npc.n154_gaudi_dead[self.anim_num as usize + dir_offset];
|
||||
|
||||
|
|
@ -31,4 +73,10 @@ impl NPC {
|
|||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub(crate) fn tick_n173_gaudi_armored(&mut self, state: &mut SharedGameState, players: [&mut Player; 2]) -> GameResult {
|
||||
let player = self.get_closest_player_mut(players);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1314,4 +1314,21 @@ impl NPC {
|
|||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub(crate) fn tick_n359_water_droplet_generator(&mut self, state: &mut SharedGameState, players: [&mut Player; 2], npc_list: &NPCList) -> GameResult {
|
||||
let player = self.get_closest_player_mut(players);
|
||||
if abs(player.x - self.x) < 320 * 0x200
|
||||
&& player.y < self.y + 320 * 0x200
|
||||
&& player.y > self.y - 160 * 0x200
|
||||
&& self.rng.range(0..100) == 2 {
|
||||
let mut npc = NPC::create(73, &state.npc_table);
|
||||
npc.cond.set_alive(true);
|
||||
npc.x = self.x + self.rng.range(-6..6) * 0x200;
|
||||
npc.y = self.y - 7 * 0x200;
|
||||
|
||||
let _ = npc_list.spawn(0, npc);
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ pub mod maze;
|
|||
pub mod mimiga_village;
|
||||
pub mod misc;
|
||||
pub mod misery;
|
||||
pub mod outer_wall;
|
||||
pub mod pickups;
|
||||
pub mod quote;
|
||||
pub mod sand_zone;
|
||||
|
|
|
|||
89
src/npc/ai/outer_wall.rs
Normal file
89
src/npc/ai/outer_wall.rs
Normal file
|
|
@ -0,0 +1,89 @@
|
|||
use crate::npc::NPC;
|
||||
use crate::shared_game_state::SharedGameState;
|
||||
use crate::player::Player;
|
||||
use ggez::GameResult;
|
||||
use num_traits::abs;
|
||||
|
||||
impl NPC {
|
||||
pub(crate) fn tick_n215_sandcroc_outer_wall(&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) < 12 * 0x200 && player.y > self.y && player.y < self.y + 8 * 0x200 {
|
||||
self.action_num = 15;
|
||||
self.action_counter = 0;
|
||||
}
|
||||
}
|
||||
15 => {
|
||||
self.action_counter += 1;
|
||||
if self.action_counter > 10 {
|
||||
state.sound_manager.play_sfx(102);
|
||||
self.action_num = 20;
|
||||
}
|
||||
}
|
||||
20 => {
|
||||
self.anim_counter += 1;
|
||||
if self.anim_counter > 3 {
|
||||
self.anim_num += 1;
|
||||
self.anim_counter = 0;
|
||||
}
|
||||
|
||||
match self.anim_num {
|
||||
3 => self.damage = 15,
|
||||
4 => {
|
||||
self.action_num = 30;
|
||||
self.action_counter = 0;
|
||||
self.npc_flags.set_shootable(true);
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
30 => {
|
||||
self.damage = 0;
|
||||
self.npc_flags.set_solid_soft(true);
|
||||
|
||||
self.action_counter += 1;
|
||||
if self.shock > 0 {
|
||||
self.action_num = 40;
|
||||
self.action_counter = 0;
|
||||
}
|
||||
}
|
||||
40 => {
|
||||
self.npc_flags.set_ignore_solidity(true);
|
||||
self.y += 0x200;
|
||||
self.action_counter += 1;
|
||||
if self.action_counter == 32 {
|
||||
self.action_num = 50;
|
||||
self.action_counter = 0;
|
||||
self.npc_flags.set_solid_soft(false);
|
||||
self.npc_flags.set_shootable(false);
|
||||
}
|
||||
}
|
||||
50 => {
|
||||
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.n215_sandcroc_outer_wall[self.anim_num as usize];
|
||||
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
|
@ -273,12 +273,16 @@ impl GameEntity<([&mut Player; 2], &NPCList, &mut Stage, &BulletManager)> for NP
|
|||
193 => self.tick_n193_broken_scooter(state),
|
||||
194 => self.tick_n194_broken_blue_robot(state),
|
||||
199 => self.tick_n199_wind_particles(state),
|
||||
208 => self.tick_n208_basu_destroyed_egg_corridor(state, players, npc_list),
|
||||
209 => self.tick_n209_basu_projectile_destroyed_egg_corridor(state),
|
||||
211 => self.tick_n211_small_spikes(state),
|
||||
215 => self.tick_n215_sandcroc_outer_wall(state, players),
|
||||
234 => self.tick_n234_red_flowers_picked(state),
|
||||
241 => self.tick_n241_critter_red(state, players),
|
||||
298 => self.tick_n298_intro_doctor(state),
|
||||
299 => self.tick_n299_intro_balrog_misery(state),
|
||||
300 => self.tick_n300_intro_demon_crown(state),
|
||||
359 => self.tick_n359_water_droplet_generator(state, players, npc_list),
|
||||
_ => Ok(()),
|
||||
}?;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue