1
0
Fork 0
mirror of https://github.com/doukutsu-rs/doukutsu-rs synced 2024-11-25 23:12:56 +00:00

add toroko with stick

This commit is contained in:
Alula 2020-09-19 15:20:06 +02:00
parent e89f08804d
commit e0b1eba88d
No known key found for this signature in database
GPG key ID: 3E00485503A1D8BA
2 changed files with 107 additions and 5 deletions

View file

@ -7,6 +7,112 @@ use crate::player::Player;
use crate::SharedGameState;
impl NPC {
pub(crate) fn tick_n063_toroko_stick(&mut self, state: &mut SharedGameState) -> GameResult {
match self.action_num {
0 | 1 => {
if self.action_num == 0 {
self.action_num = 1;
self.action_counter = 0;
self.anim_counter = 0;
self.vel_y = -0x400;
}
if self.vel_y > 0 {
self.npc_flags.set_ignore_solidity(true);
}
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.vel_x = 0x100 * self.direction.vector_x();
self.action_counter += 1;
if self.action_counter != 0 && self.flags.hit_bottom_wall() {
self.action_num = 2;
}
}
2 | 3 => {
if self.action_num ==2 {
self.action_num = 3;
self.action_counter = 0;
self.anim_num = 0;
self.anim_counter = 0;
}
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.action_counter += 1;
if self.action_counter > 50 {
self.action_counter = 40;
self.vel_x = -self.vel_x;
self.direction = self.direction.opposite();
}
if self.action_counter > 35 {
self.npc_flags.set_shootable(true);
}
self.vel_x += 0x40 * self.direction.vector_x();
if self.shock > 0 {
self.action_num = 4;
self.anim_num = 4;
self.vel_y = -0x400;
self.npc_flags.set_shootable(false);
self.damage = 0;
}
}
4 => {
self.vel_x = 0x100 * self.direction.vector_x();
self.action_counter += 1;
if self.action_counter != 0 && self.flags.hit_bottom_wall() {
self.action_num = 5;
self.npc_flags.set_interactable(true);
}
}
5 => {
self.vel_x = 0;
self.anim_num = 5;
}
_ => {}
}
self.vel_y += 0x40;
self.vel_x = clamp(self.vel_x, -0x400, 0x400);
if self.vel_y > 0x5ff {
self.vel_y = 0x5ff;
}
self.x += self.vel_x;
self.y += self.vel_y;
if self.direction == Direction::Left {
self.anim_rect = state.constants.npc.n063_toroko_stick[self.anim_num as usize];
} else {
self.anim_rect = state.constants.npc.n063_toroko_stick[self.anim_num as usize + 6];
}
Ok(())
}
pub(crate) fn tick_n071_chinfish(&mut self, state: &mut SharedGameState) -> GameResult {
if self.action_num == 0 {
self.action_num = 1;
@ -124,7 +230,6 @@ impl NPC {
if (self.x - (32 * 0x200) < player.x) && (self.x + (32 * 0x200) > player.x)
&& (self.y - (32 * 0x200) < player.y) && (self.y + (16 * 0x200) > player.y) {
if self.x > player.x {
self.direction = Direction::Left;
} else {

View file

@ -94,10 +94,6 @@ impl NPC {
impl GameEntity<&mut Player> for NPC {
fn tick(&mut self, state: &mut SharedGameState, player: &mut Player) -> GameResult {
if !self.cond.alive() {
return Ok(());
}
match self.npc_type {
0 => { self.tick_n000_null() }
1 => { self.tick_n001_experience(state) }
@ -131,6 +127,7 @@ impl GameEntity<&mut Player> for NPC {
60 => { self.tick_n060_toroko(state, player) }
61 => { self.tick_n061_king(state) }
62 => { self.tick_n062_kazuma_computer(state) }
63 => { self.tick_n063_toroko_stick(state) }
64 => { self.tick_n064_first_cave_critter(state, player) }
65 => { self.tick_n065_first_cave_bat(state, player) }
70 => { self.tick_n070_sparkle(state) }