1
0
Fork 0
mirror of https://github.com/jugeeya/UltimateTrainingModpack.git synced 2025-03-16 11:26:11 +00:00

Launch indicator fix for #205 (#210)

* Add workflow_dispatch

* Use persistent variable to track DI case instead of trying to roll only on the first frame of hitstun

Co-authored-by: asimon-1 <asimon1@protonmail.com>
This commit is contained in:
asimon-1 2021-07-16 08:24:12 -04:00 committed by GitHub
parent cd8755012c
commit bbbf2ac898
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 33 additions and 5 deletions

View file

@ -8,6 +8,28 @@ use smash::lua2cpp::L2CFighterCommon;
static mut DI_CASE: Direction = Direction::empty();
pub fn roll_di_case() {
unsafe {
if DI_CASE != Direction::empty() {
// DI direction already selected, don't pick a new one
return;
}
DI_CASE = MENU.di_state.get_random();
}
}
pub fn reset_di_case(module_accessor: &mut app::BattleObjectModuleAccessor) {
if is_in_hitstun(module_accessor) {
// Don't reset the DI direction during hitstun
return;
}
unsafe {
if DI_CASE != Direction::empty() {
DI_CASE = Direction::empty();
}
}
}
#[skyline::hook(replace = smash::lua2cpp::L2CFighterCommon_FighterStatusDamage__correctDamageVectorCommon)]
pub unsafe fn handle_correct_damage_vector_common(
@ -31,10 +53,8 @@ unsafe fn mod_handle_di(fighter: &mut L2CFighterCommon, _arg1: L2CValue) {
return;
}
// Either left, right, or none
if MotionModule::frame(module_accessor) == 0.0 {
DI_CASE = MENU.di_state.get_random();
}
roll_di_case();
let angle_tuple = DI_CASE
.into_angle()
.map_or((0.0, 0.0), |angle| {
@ -75,3 +95,11 @@ fn set_x_y(module_accessor: &mut app::BattleObjectModuleAccessor, x: f32, y: f32
);
}
}
pub fn get_command_flag_cat(module_accessor: &mut app::BattleObjectModuleAccessor) {
if !is_operation_cpu(module_accessor) {
return;
}
reset_di_case(module_accessor);
}

View file

@ -113,7 +113,7 @@ fn once_per_frame_per_fighter(
frame_counter::get_command_flag_cat(module_accessor);
ledge::get_command_flag_cat(module_accessor);
shield::get_command_flag_cat(module_accessor);
directional_influence::get_command_flag_cat(module_accessor);
reset::check_reset(module_accessor);
}