Skip to content

Commit

Permalink
Merge branch 'fighter-crate-refactor' of https://github.com/HDR-Devel…
Browse files Browse the repository at this point in the history
…opment/HewDraw-Remix into fighter-crate-refactor
  • Loading branch information
BEANSS0328 committed Mar 24, 2024
2 parents 18381bd + a6ba14f commit a7f8332
Show file tree
Hide file tree
Showing 17 changed files with 467 additions and 286 deletions.
2 changes: 0 additions & 2 deletions dynamic/src/consts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -184,8 +184,6 @@ pub mod vars {

pub const IS_FLOAT: i32 = 0x0066;

pub const TRAINING_KILL_EFFECTS: i32 = 0x0067;

// ints

pub const LAST_ATTACK_RECEIVER_ENTRY_ID: i32 = 0x0000;
Expand Down
23 changes: 12 additions & 11 deletions fighters/common/src/function_hooks/attack.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,17 +140,18 @@ unsafe fn handle_on_attack_event(ctx: &mut skyline::hooks::InlineCtx) {
#[skyline::hook(offset = 0x33a9d90, inline)]
unsafe fn set_weapon_hitlag(ctx: &mut skyline::hooks::InlineCtx) {
let opponent_boma = &mut *(*ctx.registers[24].x.as_ref() as *mut BattleObjectModuleAccessor);

let hitlag = *ctx.registers[21].w.as_ref();
let kb = DamageModule::reaction(opponent_boma, 0);
IS_KB_CALC_EARLY = true;
KB = kb;
let max_hitlag = WorkModule::get_param_float(opponent_boma, hash40("battle_object"), hash40("hitstop_frame_max"));
let attack_data = (*ctx.registers[20].x.as_ref() as *mut smash_rs::app::AttackData);
let attr: smashline::Hash40 = std::mem::transmute((*attack_data).attr);
if ![Hash40::new("collision_attr_paralyze"), Hash40::new("collision_attr_saving")].contains(&attr) {
// Set hitlag for attacking article
*ctx.registers[21].w.as_mut() = (hitlag as f32 * (0.414 * std::f32::consts::E.powf(0.0063 * kb)).clamp(1.0, 2.0)).round().min(max_hitlag) as u32;
if !opponent_boma.is_item() {
let hitlag = *ctx.registers[21].w.as_ref();
let kb = DamageModule::reaction(opponent_boma, 0);
IS_KB_CALC_EARLY = true;
KB = kb;
let max_hitlag = WorkModule::get_param_float(opponent_boma, hash40("battle_object"), hash40("hitstop_frame_max"));
let attack_data = (*ctx.registers[20].x.as_ref() as *mut smash_rs::app::AttackData);
let attr: smashline::Hash40 = std::mem::transmute((*attack_data).attr);
if ![Hash40::new("collision_attr_paralyze"), Hash40::new("collision_attr_saving")].contains(&attr) {
// Set hitlag for attacking article
*ctx.registers[21].w.as_mut() = (hitlag as f32 * (0.414 * std::f32::consts::E.powf(0.0063 * kb)).clamp(1.0, 2.0)).round().min(max_hitlag) as u32;
}
}
}

Expand Down
27 changes: 4 additions & 23 deletions fighters/common/src/opff/other.rs
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,10 @@ pub unsafe fn faf_ac_debug(fighter: &mut L2CFighterCommon) {
if fighter.is_status(*FIGHTER_STATUS_KIND_APPEAL) && fighter.status_frame() == 10 {
if ControlModule::check_button_on(boma, *CONTROL_PAD_BUTTON_GUARD) && ControlModule::check_button_on(boma, *CONTROL_PAD_BUTTON_SPECIAL_RAW) {
println!("toggling debug");
fighter.clear_lua_stack();
lua_args!(fighter, Hash40::new("sys_hit_dead"), Hash40::new("top"), 0, 10, 0, 0, 0, 0, 1, true);
smash::app::sv_animcmd::EFFECT_FOLLOW(fighter.lua_state_agent);
fighter.pop_lua_stack(1);
let prev = VarModule::is_flag(fighter.battle_object, vars::common::instance::ENABLE_FRAME_DATA_DEBUG);
VarModule::set_flag(fighter.battle_object, vars::common::instance::ENABLE_FRAME_DATA_DEBUG, !prev);
VarModule::set_int(fighter.battle_object, vars::common::instance::FRAME_COUNTER, 1);
Expand Down Expand Up @@ -337,29 +341,6 @@ const HANDLE: i32 = 0x01FF;
const COUNTER: i32 = 0x01FE;

unsafe extern "C" fn kill_screen_handler(fighter: &mut L2CFighterCommon) {
// allow kill effects to be toggled on and off in training mode
if is_training_mode() {
let is_toggle = VarModule::is_flag(fighter.object(), vars::common::instance::TRAINING_KILL_EFFECTS);
let is_input = fighter.is_status(*FIGHTER_STATUS_KIND_APPEAL)
&& fighter.is_button_on(Buttons::Guard)
&& fighter.is_button_on(Buttons::Attack);
if !is_toggle && is_input
&& fighter.is_button_on(Buttons::AppealHi) {
VarModule::on_flag(fighter.object(), vars::common::instance::TRAINING_KILL_EFFECTS);
fighter.clear_lua_stack();
lua_args!(fighter, Hash40::new("sys_hit_dead"), Hash40::new("top"), 0, 10, 0, 0, 0, 0, 1, true);
smash::app::sv_animcmd::EFFECT_FOLLOW(fighter.lua_state_agent);
fighter.pop_lua_stack(1);
} else if is_toggle && is_input
&& fighter.is_button_on(Buttons::AppealLw) {
VarModule::off_flag(fighter.object(), vars::common::instance::TRAINING_KILL_EFFECTS);
fighter.clear_lua_stack();
lua_args!(fighter, Hash40::new("sys_equip_end"), Hash40::new("top"), 0, 10, 0, 0, 0, 0, 1.5, true);
smash::app::sv_animcmd::EFFECT_FOLLOW(fighter.lua_state_agent);
fighter.pop_lua_stack(1);
}
}

// handles turning off kill effects
if VarModule::get_int(fighter.object(), COUNTER) > 0 {
let scale = (30 - VarModule::get_int(fighter.object(), COUNTER)) as f32 / 30.0 * 5.0;
Expand Down
24 changes: 23 additions & 1 deletion fighters/kirby/src/opff/copy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -635,6 +635,25 @@ unsafe fn knife_drift(boma: &mut BattleObjectModuleAccessor, status_kind: i32, s
}
}

// Richter's Knife land cancel
unsafe fn knife_lc(boma: &mut BattleObjectModuleAccessor) {
if boma.is_status(*FIGHTER_KIRBY_STATUS_KIND_RICHTER_SPECIAL_N)
&& VarModule::is_flag(boma.object(), vars::richter::instance::SPECIAL_N_LAND_CANCEL)
&& boma.is_situation(*SITUATION_KIND_GROUND) {
// remove the unthrown knife from richter's hand
if (2.0..13.0).contains(&boma.motion_frame())
&& ArticleModule::is_exist(boma, *FIGHTER_SIMON_GENERATE_ARTICLE_AXE){
ArticleModule::remove_exist(boma, *FIGHTER_SIMON_GENERATE_ARTICLE_AXE, ArticleOperationTarget(*ARTICLE_OPE_TARGET_ALL));
}

let landing_lag = 10.0; // amount of frames until richter can act when landing
let rate = 27.0 / landing_lag;
MotionModule::change_motion(boma, Hash40::new("landing_heavy"), 0.0, rate, false, 0.0, false, false);
VarModule::off_flag(boma.object(), vars::richter::instance::SPECIAL_N_LAND_CANCEL);
EffectModule::kill_kind(boma, Hash40::new("sys_sp_flash"), true, true);
}
}

// Toon Link's Bow Drift
unsafe fn heros_bow_drift(boma: &mut BattleObjectModuleAccessor, status_kind: i32, situation_kind: i32, cat2: i32, stick_y: f32) {
if status_kind == *FIGHTER_KIRBY_STATUS_KIND_TOONLINK_SPECIAL_N {
Expand Down Expand Up @@ -1078,7 +1097,10 @@ pub unsafe fn kirby_copy_handler(fighter: &mut L2CFighterCommon, boma: &mut Batt
// Simon
0x43 => axe_drift(boma, status_kind, situation_kind, cat[1], stick_y),
// Richter
0x44 => knife_drift(boma, status_kind, situation_kind, cat[1], stick_y),
0x44 => {
knife_drift(boma, status_kind, situation_kind, cat[1], stick_y);
knife_lc(boma);
},
// Toon Link
0x2E => heros_bow_drift(boma, status_kind, situation_kind, cat[1], stick_y),
// Young Link
Expand Down
Loading

0 comments on commit a7f8332

Please sign in to comment.