mirror of
https://github.com/doukutsu-rs/doukutsu-rs
synced 2024-09-28 21:19:24 +00:00
new npcs
This commit is contained in:
parent
b087c645d6
commit
9f70bf6fd0
|
@ -66,8 +66,7 @@ impl NPC {
|
|||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
||||
|
||||
pub(crate) fn tick_n064_first_cave_critter(&mut self, state: &mut SharedGameState, players: [&mut Player; 2]) -> GameResult {
|
||||
match self.action_num {
|
||||
0 | 1 => {
|
||||
|
|
105
src/npc/ai/last_cave.rs
Normal file
105
src/npc/ai/last_cave.rs
Normal file
|
@ -0,0 +1,105 @@
|
|||
use ggez::GameResult;
|
||||
|
||||
use crate::common::Direction;
|
||||
use crate::npc::NPC;
|
||||
use crate::player::Player;
|
||||
use crate::shared_game_state::SharedGameState;
|
||||
|
||||
impl NPC {
|
||||
pub(crate) fn tick_n241_critter_red(&mut self, state: &mut SharedGameState, players: [&mut Player; 2]) -> GameResult {
|
||||
match self.action_num {
|
||||
0 | 1 => {
|
||||
if self.action_num == 0 {
|
||||
self.y += 3 * 0x200;
|
||||
self.action_num = 1;
|
||||
self.anim_num = 0;
|
||||
}
|
||||
|
||||
let player = self.get_closest_player_mut(players);
|
||||
if self.x > player.x {
|
||||
self.direction = Direction::Left;
|
||||
} else {
|
||||
self.direction = Direction::Right;
|
||||
}
|
||||
|
||||
if self.target_x < 100 {
|
||||
self.target_x += 1;
|
||||
}
|
||||
|
||||
if self.action_counter >= 8
|
||||
&& self.x - (144 * 0x200) < player.x
|
||||
&& self.x + (144 * 0x200) > player.x
|
||||
&& self.y - (96 * 0x200) < player.y
|
||||
&& self.y + (96 * 0x200) > player.y {
|
||||
self.anim_num = 1;
|
||||
} else {
|
||||
if self.action_counter < 8 {
|
||||
self.action_counter += 1;
|
||||
}
|
||||
|
||||
self.anim_num = 0;
|
||||
}
|
||||
|
||||
if self.shock > 0 {
|
||||
self.action_num = 2;
|
||||
self.action_counter = 0;
|
||||
|
||||
self.anim_num = 0;
|
||||
}
|
||||
|
||||
if self.action_counter >= 8
|
||||
&& self.target_x >= 100
|
||||
&& self.x - (96 * 0x200) < player.x
|
||||
&& self.x + (96 * 0x200) > player.x
|
||||
&& self.y - (80 * 0x200) < player.y
|
||||
&& self.y + (80 * 0x200) > player.y {
|
||||
self.action_num = 2;
|
||||
self.action_counter = 0;
|
||||
self.anim_num = 0;
|
||||
}
|
||||
}
|
||||
2 => {
|
||||
self.action_counter += 1;
|
||||
if self.action_counter > 8 {
|
||||
self.action_num = 3;
|
||||
self.anim_num = 2;
|
||||
|
||||
self.vel_y = -0x5ff;
|
||||
state.sound_manager.play_sfx(30);
|
||||
|
||||
if self.direction == Direction::Left {
|
||||
self.vel_x = -0x200;
|
||||
} else {
|
||||
self.vel_x = 0x200;
|
||||
}
|
||||
}
|
||||
}
|
||||
3 => {
|
||||
if self.flags.hit_bottom_wall() {
|
||||
self.vel_x = 0;
|
||||
self.action_counter = 0;
|
||||
self.action_num = 1;
|
||||
self.anim_num = 0;
|
||||
|
||||
state.sound_manager.play_sfx(23);
|
||||
}
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
|
||||
self.vel_y += 0x55;
|
||||
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.n241_critter_red[self.anim_num as usize + dir_offset];
|
||||
|
||||
Ok(())
|
||||
}
|
||||
}
|
|
@ -7,6 +7,7 @@ pub mod first_cave;
|
|||
pub mod grasstown;
|
||||
pub mod igor;
|
||||
pub mod intro;
|
||||
pub mod last_cave;
|
||||
pub mod maze;
|
||||
pub mod mimiga_village;
|
||||
pub mod misc;
|
||||
|
|
|
@ -275,6 +275,7 @@ impl GameEntity<([&mut Player; 2], &NPCList, &mut Stage, &BulletManager)> for NP
|
|||
199 => self.tick_n199_wind_particles(state),
|
||||
211 => self.tick_n211_small_spikes(state),
|
||||
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),
|
||||
|
|
Loading…
Reference in a new issue