1
0
Fork 0
mirror of https://github.com/doukutsu-rs/doukutsu-rs synced 2025-07-13 00:06:01 +00:00

Implemented Heavy Press boss fight (#40)

* heavy press

* fixed incorrect scale for death smoke call

* Shoot caret animates at correct speed

* formatting
This commit is contained in:
dawndus 2022-01-09 22:02:27 -05:00 committed by GitHub
parent e7b666b4cc
commit 87ddcc1324
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 313 additions and 11 deletions

View file

@ -150,7 +150,7 @@ impl Caret {
}
self.anim_counter += 1;
if self.anim_counter > 3 {
if self.anim_counter > 2 {
self.anim_counter = 0;
self.anim_num += 1;

View file

@ -1066,6 +1066,9 @@ pub struct NPCConsts {
#[serde(default = "default_b07_undead_core")]
pub b07_undead_core: [Rect<u16>; 15],
#[serde(default = "default_b08_heavy_press")]
pub b08_heavy_press: [Rect<u16>; 6],
}
fn default_n001_experience() -> [Rect<u16>; 6] {
@ -4769,3 +4772,16 @@ fn default_b07_undead_core() -> [Rect<u16>; 15] {
Rect { left: 256, top: 80, right: 320, bottom: 120 },
]
}
fn default_b08_heavy_press() -> [Rect<u16>; 6] {
[
// Normal
Rect { left: 0, top: 0, right: 80, bottom: 120 },
Rect { left: 80, top: 0, right: 160, bottom: 120 },
Rect { left: 160, top: 0, right: 240, bottom: 120 },
// Hurt
Rect { left: 0, top: 120, right: 80, bottom: 240 },
Rect { left: 80, top: 120, right: 160, bottom: 240 },
Rect { left: 160, top: 120, right: 240, bottom: 240 },
]
}

View file

@ -961,7 +961,7 @@ impl NPC {
_ => (),
}
if player.controller.trigger_shoot() && bullet_manager.count_bullets_multi(&[43], TargetPlayer::Player1) < 2 {
if player.controller.trigger_shoot() && state.control_flags.control_enabled() && bullet_manager.count_bullets_multi(&[43], TargetPlayer::Player1) < 2 {
bullet_manager.create_bullet(npc.x, npc.y, 43, TargetPlayer::Player1, self.direction, &state.constants,);
state.create_caret(npc.x, npc.y, CaretType::Shoot, self.direction);
}

283
src/npc/boss/heavy_press.rs Normal file
View file

@ -0,0 +1,283 @@
use crate::common::{Direction, Rect};
use crate::framework::error::GameResult;
use crate::npc::boss::BossNPC;
use crate::npc::list::NPCList;
use crate::npc::NPC;
use crate::rng::RNG;
use crate::shared_game_state::SharedGameState;
use crate::stage::Stage;
impl NPC {
pub(crate) fn tick_n325_heavy_press_lightning(
&mut self,
state: &mut SharedGameState,
npc_list: &NPCList,
) -> GameResult {
match self.action_num {
0 | 1 => {
if self.action_num == 0 {
self.action_num = 1;
state.sound_manager.play_sfx(29);
}
self.animate(0, 0, 2);
self.action_counter += 1;
if self.action_counter > 50 {
self.action_num = 10;
self.anim_counter = 0;
self.anim_num = 3;
self.damage = 10;
self.display_bounds.left = 0x1000;
self.display_bounds.top = 0x1800;
state.sound_manager.play_sfx(101);
npc_list.create_death_smoke(self.x, self.y + 0xA800, 0, 3, state, &self.rng);
}
}
10 => {
self.animate(2, 3, 7);
if self.anim_num > 6 {
self.cond.set_alive(false);
return Ok(());
};
}
_ => (),
}
self.anim_rect = state.constants.npc.n325_heavy_press_lightning[self.anim_num as usize];
Ok(())
}
}
impl BossNPC {
pub(crate) fn tick_b08_heavy_press(&mut self, state: &mut SharedGameState, npc_list: &NPCList, stage: &mut Stage) {
match self.parts[0].action_num {
0 => {
self.parts[0].action_num = 10;
self.parts[0].cond.set_alive(true);
self.parts[0].exp = 1;
self.parts[0].direction = Direction::Right;
self.parts[0].x = 0;
self.parts[0].y = 0;
self.parts[0].display_bounds = Rect { left: 0x5000, top: 0x7800, right: 0x5000, bottom: 0x7800 };
self.parts[0].hit_bounds = Rect { left: 0x6200, top: 0x7800, right: 0x5000, bottom: 0x6000 };
self.parts[0].npc_flags.set_ignore_solidity(true);
self.parts[0].npc_flags.set_solid_hard(true);
self.parts[0].npc_flags.set_event_when_killed(true);
self.parts[0].npc_flags.set_show_damage(true);
self.parts[0].size = 3;
self.parts[0].damage = 10;
self.parts[0].event_num = 1000;
self.parts[0].life = 700;
}
5 => {
self.parts[0].action_num = 6;
self.parts[0].x = 0;
self.parts[0].y = 0;
self.parts[1].cond.set_alive(false);
self.parts[2].cond.set_alive(false);
}
10 => {
self.parts[0].action_num = 11;
self.parts[0].x = 0x14000;
self.parts[0].y = 0x9400;
}
20 | 21 => {
if self.parts[0].action_num == 20 {
self.parts[0].action_num = 21;
self.parts[0].damage = 0;
self.parts[0].x = 0x14000;
self.parts[0].y = 0x33A00;
self.parts[0].npc_flags.set_solid_hard(false);
self.parts[1].cond.set_alive(false);
self.parts[2].cond.set_alive(false);
}
self.parts[0].action_counter += 1;
if self.parts[0].action_counter % 16 == 0 {
npc_list.create_death_smoke(
self.parts[0].x + self.parts[0].rng.range(-40..40) * 0x200,
self.parts[0].y + self.parts[0].rng.range(-60..60) * 0x200,
1,
1,
state,
&self.parts[0].rng,
);
}
}
30 | 31 => {
if self.parts[0].action_num == 30 {
self.parts[0].action_num = 31;
self.parts[0].anim_num = 2;
self.parts[0].x = 0x14000;
self.parts[0].y = 0x8000;
}
self.parts[0].y += 0x800;
if self.parts[0].y >= 0x33A00 {
self.parts[0].y = 0x33A00;
self.parts[0].anim_num = 0;
self.parts[0].action_num = 20;
state.sound_manager.play_sfx(44);
for _ in 0..5 {
let mut npc = NPC::create(4, &state.npc_table);
npc.x = self.parts[0].x + self.parts[0].rng.range(-40..40) * 0x200;
npc.y = self.parts[0].y + 0x7800;
let _ = npc_list.spawn(0x100, npc.clone());
}
}
}
100 | 101 => {
if self.parts[0].action_num == 100 {
self.parts[0].action_num = 101;
self.parts[0].action_counter3 = 9;
self.parts[0].action_counter = 0; // This should be -100
self.parts[1].cond.set_alive(true);
self.parts[1].npc_flags.set_invulnerable(true);
self.parts[1].npc_flags.set_ignore_solidity(true);
self.parts[1].hit_bounds = Rect { left: 0x1C00, top: 0x1000, right: 0x1C00, bottom: 0x1000 };
self.parts[2] = self.parts[1].clone();
self.parts[3].cond.set_alive(true);
self.parts[3].cond.set_damage_boss(true);
self.parts[3].npc_flags.set_shootable(true);
self.parts[3].hit_bounds = Rect { left: 0xC00, top: 0x1000, right: 0xC00, bottom: 0x1000 };
let mut npc = NPC::create(325, &state.npc_table);
npc.cond.set_alive(true);
npc.x = self.parts[0].x;
npc.y = self.parts[0].y + 0x7800;
let _ = npc_list.spawn(0x100, npc);
}
if self.parts[0].action_counter3 > 1 && self.parts[0].life < self.parts[0].action_counter3 * 70 {
self.parts[0].action_counter3 -= 1;
// This relies heavily on the map not being changed
// Need to calculate offset from the default starting location
for i in 0..5 {
stage.change_tile(i + 8, self.parts[0].action_counter3 as usize, 0);
npc_list.create_death_smoke(
(i as i32 + 8) * 0x2000,
self.parts[0].action_counter3 as i32 * 0x2000,
0,
4,
state,
&self.parts[0].rng,
);
state.sound_manager.play_sfx(12);
}
}
self.parts[0].action_counter += 1;
// All of these checks are +100 to account for no negative values
if self.parts[0].action_counter == 181 || self.parts[0].action_counter == 341 {
let mut npc = NPC::create(323, &state.npc_table);
npc.cond.set_alive(true);
npc.x = 0x6000;
npc.y = 0x1E000;
npc.direction = Direction::Up;
let _ = npc_list.spawn(0x100, npc);
} else if self.parts[0].action_counter == 101 || self.parts[0].action_counter == 261 {
let mut npc = NPC::create(323, &state.npc_table);
npc.cond.set_alive(true);
npc.x = 0x22000;
npc.y = 0x1E000;
npc.direction = Direction::Up;
let _ = npc_list.spawn(0x100, npc);
} else if self.parts[0].action_counter >= 400 {
self.parts[0].action_counter = 100; // Should be 0
let mut npc = NPC::create(325, &state.npc_table);
npc.cond.set_alive(true);
npc.x = self.parts[0].x;
npc.y = self.parts[0].y + 0x7800;
let _ = npc_list.spawn(0x100, npc);
}
}
500 | 501 => {
if self.parts[0].action_num == 500 {
self.parts[3].npc_flags.set_shootable(false);
self.parts[0].action_num = 501;
self.parts[0].action_counter = 0;
self.parts[0].action_counter2 = 0;
npc_list.kill_npcs_by_type(325, true, state);
npc_list.kill_npcs_by_type(330, true, state);
}
self.parts[0].action_counter += 1;
if self.parts[0].action_counter % 16 == 0 {
state.sound_manager.play_sfx(12);
npc_list.create_death_smoke(
self.parts[0].x + self.parts[0].rng.range(-40..40) * 0x200,
self.parts[0].y + self.parts[0].rng.range(-60..60) * 0x200,
1,
1,
state,
&self.parts[0].rng,
);
}
if self.parts[0].action_counter == 95 {
self.parts[0].anim_num = 1;
} else if self.parts[0].action_counter == 98 {
self.parts[0].anim_num = 2;
} else if self.parts[0].action_counter > 100 {
self.parts[0].action_num = 510;
}
}
510 => {
self.parts[0].vel_y += 64;
self.parts[0].damage = 127;
self.parts[0].y += self.parts[0].vel_y;
if self.parts[0].action_counter2 == 0 && self.parts[0].y > 0x14000 {
self.parts[0].action_counter2 = 1;
self.parts[0].vel_y = -0x200;
self.parts[0].damage = 0;
// This relies heavily on the map not being changed
// Need to calculate offset from the default starting location
for i in 0..7 {
stage.change_tile(i + 7, 14, 0);
npc_list.create_death_smoke((i as i32 + 7) * 0x2000, 0x1C000, 0, 1, state, &self.parts[0].rng);
state.sound_manager.play_sfx(12);
}
}
if self.parts[0].y > 0x3C000 {
self.parts[0].action_num = 520;
}
}
_ => (),
}
self.parts[1].x = self.parts[0].x - 0x3000;
self.parts[1].y = self.parts[0].y + 0x6800;
self.parts[2].x = self.parts[0].x + 0x3000;
self.parts[2].y = self.parts[0].y + 0x6800;
self.parts[3].x = self.parts[0].x;
self.parts[3].y = self.parts[0].y + 0x5000;
let mut anim_offset = 0;
if self.parts[0].shock != 0 {
self.parts[4].action_counter += 1;
if self.parts[4].action_counter & 0x02 == 0 {
anim_offset = 3;
}
}
self.parts[0].anim_rect = state.constants.npc.b08_heavy_press[self.parts[0].anim_num as usize + anim_offset];
}
}

View file

@ -20,7 +20,7 @@ pub mod core;
pub mod ironhead;
pub mod monster_x;
pub mod omega;
pub mod press;
pub mod heavy_press;
pub mod sisters;
pub mod undead_core;
@ -86,7 +86,7 @@ impl GameEntity<([&mut Player; 2], &NPCList, &mut Stage, &BulletManager, &mut Fl
5 => self.tick_b05_ironhead(state, players, npc_list),
6 => self.tick_b06_sisters(state, players, npc_list, flash),
7 => self.tick_b07_undead_core(state, npc_list, stage, flash),
8 => self.tick_b08_press(),
8 => self.tick_b08_heavy_press(state, npc_list, stage),
9 => self.tick_b09_ballos(),
_ => {}
}

View file

@ -1,7 +0,0 @@
use crate::npc::boss::BossNPC;
impl BossNPC {
pub(crate) fn tick_b08_press(&mut self) {
}
}

View file

@ -565,6 +565,7 @@ impl GameEntity<([&mut Player; 2], &NPCList, &mut Stage, &mut BulletManager, &mu
322 => self.tick_n322_deleet(state, npc_list, stage),
323 => self.tick_n323_bute_spinning(state, players),
324 => self.tick_n324_bute_generator(state, npc_list),
325 => self.tick_n325_heavy_press_lightning(state, npc_list),
326 => self.tick_n326_sue_itoh_human_transition(state, npc_list),
327 => self.tick_n327_sneeze(state, npc_list),
328 => self.tick_n328_human_transform_machine(state),

View file

@ -959,6 +959,15 @@ impl GameScene {
self.draw_light_raycast(state.tile_size, npc.x, npc.y, (255, 0, 0), scale, 0..360, batch)
}
325 => {
let size = 0.5 * (npc.anim_num as f32 + 1.0);
self.draw_light(
interpolate_fix9_scale(npc.prev_x - self.frame.prev_x, npc.x - self.frame.x, state.frame_time),
interpolate_fix9_scale(npc.prev_y - self.frame.prev_y, npc.y - self.frame.y, state.frame_time),
size,
(255, 255, 255),
batch,)
}
_ => {}
}
}