From 5b1b6117870d21af71f0df5c5eb59a916552c9ca Mon Sep 17 00:00:00 2001 From: jugeeya Date: Thu, 14 May 2020 13:54:32 -0700 Subject: [PATCH] fix save states --- Cargo.toml | 8 +++--- src/common/mod.rs | 2 ++ src/hitbox_visualizer/mod.rs | 12 +++++---- src/lib.rs | 16 +++++++++-- src/training/Ledge.rs | 18 ++++++------- src/training/SaveStates.rs | 52 +++++++++++++++++++++++------------- src/training/Tech.rs | 17 ++++++------ 7 files changed, 79 insertions(+), 46 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index bc31fa2..9c7010e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "training_modpack" -version = "0.1.0" -authors = ["jam1garner "] +version = "2.0.0" +authors = ["jugeeya "] edition = "2018" [lib] @@ -9,8 +9,8 @@ crate-type = ["cdylib"] [dependencies] skyline = { git = "https://github.com/ultimate-research/skyline-rs.git" } -# skyline_smash = { git = "https://github.com/ultimate-research/skyline-smash.git" } -skyline_smash = { path = "../../../../src/skyline-smash" } +skyline_smash = { git = "https://github.com/ultimate-research/skyline-smash.git" } +# skyline_smash = { path = "../../../../src/skyline-smash" } [profile.dev] panic = "abort" diff --git a/src/common/mod.rs b/src/common/mod.rs index b842ffa..a4dec9a 100644 --- a/src/common/mod.rs +++ b/src/common/mod.rs @@ -25,6 +25,8 @@ pub static mut fighter_manager_addr: usize = 0; extern "C" { #[link_name = "\u{1}_ZN3app9smashball16is_training_modeEv"] pub fn is_training_mode() -> bool; + #[link_name = "\u{1}_ZN3app7utility8get_kindEPKNS_26BattleObjectModuleAccessorE"] + pub fn get_kind(module_accessor: &mut app::BattleObjectModuleAccessor) -> i32; } pub fn get_category(module_accessor: &mut app::BattleObjectModuleAccessor) -> i32 { diff --git a/src/hitbox_visualizer/mod.rs b/src/hitbox_visualizer/mod.rs index 19fe104..9dd6e38 100644 --- a/src/hitbox_visualizer/mod.rs +++ b/src/hitbox_visualizer/mod.rs @@ -235,13 +235,15 @@ pub unsafe fn get_command_flag_cat( let status_kind = StatusModule::status_kind(module_accessor) as i32; MotionAnimcmdModule::set_sleep_effect( module_accessor, - !((*FIGHTER_STATUS_KIND_CATCH..=*FIGHTER_STATUS_KIND_TREAD_FALL) - .contains(&status_kind) - || (*FIGHTER_STATUS_KIND_WAIT..=*FIGHTER_STATUS_KIND_REBOUND_JUMP) - .contains(&status_kind)), + !((status_kind >= FIGHTER_STATUS_KIND_CATCH + && status_kind <= FIGHTER_STATUS_KIND_TREAD_FALL) + || (status_kind >= FIGHTER_STATUS_KIND_WAIT + && status_kind <= FIGHTER_STATUS_KIND_REBOUND_JUMP)), ); - if !(*FIGHTER_STATUS_KIND_CATCH..=*FIGHTER_STATUS_KIND_CATCH_TURN).contains(&status_kind) { + if !(*FIGHTER_STATUS_KIND_CATCH..=*FIGHTER_STATUS_KIND_CATCH_TURN).contains(&status_kind) + && !is_shielding(module_accessor) + { EffectModule::set_visible_kind( module_accessor, Hash40 { diff --git a/src/lib.rs b/src/lib.rs index c33750c..682c978 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -44,6 +44,19 @@ pub unsafe fn handle_sub_guard_cont(fighter: &mut L2CFighterCommon) -> L2CValue } } } + if (*menu).MASH_STATE == MASH_SPOTDODGE { + if StatusModule::prev_status_kind(module_accessor, 0) == FIGHTER_STATUS_KIND_GUARD_DAMAGE { + if WorkModule::is_enable_transition_term( + module_accessor, + *FIGHTER_STATUS_TRANSITION_TERM_ID_CONT_ESCAPE, + ) { + fighter.fighter_base.change_status( + L2CValue::new_int(*FIGHTER_STATUS_KIND_ESCAPE as u64), + L2CValue::new_bool(true), + ); + } + } + } original!()(fighter) } @@ -57,7 +70,7 @@ fn nro_main(nro: &NroInfo) { } } -#[skyline::main(name = "test")] +#[skyline::main(name = "training_modpack")] pub fn main() { println!("Training modpack initialized."); hitbox_visualizer::hitbox_visualization(); @@ -73,7 +86,6 @@ pub fn main() { "w\u{0}".as_bytes().as_ptr(), ); - println!("File pointer: {:#?}", f); if !f.is_null() { fwrite(c_str(&buffer) as *const c_void, 1, buffer.len(), f); fclose(f); diff --git a/src/training/Ledge.rs b/src/training/Ledge.rs index 879ad1e..3cdde90 100644 --- a/src/training/Ledge.rs +++ b/src/training/Ledge.rs @@ -66,15 +66,15 @@ pub unsafe fn defensive_option( ) { let status = StatusModule::status_kind(module_accessor) as i32; let prev_status = StatusModule::prev_status_kind(module_accessor, 0) as i32; - if [ - *FIGHTER_STATUS_KIND_CLIFF_JUMP3, - *FIGHTER_STATUS_KIND_CLIFF_JUMP2, - *FIGHTER_STATUS_KIND_CLIFF_JUMP1, - ] - .contains(&status) - { - *flag |= *FIGHTER_PAD_CMD_CAT1_FLAG_AIR_ESCAPE; - } + // if [ + // *FIGHTER_STATUS_KIND_CLIFF_JUMP3, + // *FIGHTER_STATUS_KIND_CLIFF_JUMP2, + // *FIGHTER_STATUS_KIND_CLIFF_JUMP1, + // ] + // .contains(&status) + // { + // *flag |= *FIGHTER_PAD_CMD_CAT1_FLAG_AIR_ESCAPE; + // } if should_perform_defensive_option(module_accessor, prev_status, status) { perform_defensive_option(module_accessor, flag); diff --git a/src/training/SaveStates.rs b/src/training/SaveStates.rs index 25bf1bd..951e297 100644 --- a/src/training/SaveStates.rs +++ b/src/training/SaveStates.rs @@ -64,6 +64,7 @@ pub unsafe fn save_states(module_accessor: &mut app::BattleObjectModuleAccessor) save_state_player_state = CameraMove; save_state_cpu_state = CameraMove; } + return; } // move to camera bounds @@ -72,10 +73,7 @@ pub unsafe fn save_states(module_accessor: &mut app::BattleObjectModuleAccessor) let left_right = (*save_state_x > 0.0) as i32 as f32 - (*save_state_x < 0.0) as i32 as f32; - let mut y_pos = 0.0; - if *save_state_situation_kind == SITUATION_KIND_GROUND { - y_pos = -50.0; - } + let y_pos = 0.0; let pos = Vector3f { x: left_right * 50.0, @@ -83,17 +81,22 @@ pub unsafe fn save_states(module_accessor: &mut app::BattleObjectModuleAccessor) z: 0.0, }; PostureModule::set_pos(module_accessor, &pos); - StatusModule::set_situation_kind( - module_accessor, - app::SituationKind { - situation_kind: *SITUATION_KIND_AIR, - }, - false, - ); + + // force aerial, because from aerial state we can move anywhere + if StatusModule::situation_kind(module_accessor) == SITUATION_KIND_GROUND { + StatusModule::change_status_request(module_accessor, *FIGHTER_STATUS_KIND_JUMP_SQUAT, false); + } + return; } // move to correct pos if *save_state == PosMove { + if StatusModule::situation_kind(module_accessor) == SITUATION_KIND_GROUND { + return; + } + + KineticModule::clear_speed_all(module_accessor); + let pos = Vector3f { x: *save_state_x, y: *save_state_y, @@ -116,13 +119,25 @@ pub unsafe fn save_states(module_accessor: &mut app::BattleObjectModuleAccessor) false, ); - // Doesn't work, and I don't know why yet. - // if *save_state_situation_kind == SITUATION_KIND_GROUND && status != FIGHTER_STATUS_KIND_WAIT { - // StatusModule::change_status_request(module_accessor, *FIGHTER_STATUS_KIND_WAIT, false); - // } - // else if (*save_state_situation_kind == SITUATION_KIND_AIR && status != FIGHTER_STATUS_KIND_FALL) - // StatusModule::change_status_request(module_accessor, FIGHTER_STATUS_KIND_FALL, 0); - if *save_state_situation_kind == SITUATION_KIND_CLIFF + if *save_state_situation_kind == SITUATION_KIND_GROUND + && status != FIGHTER_STATUS_KIND_WAIT + { + StatusModule::change_status_request( + module_accessor, + *FIGHTER_STATUS_KIND_CLIFF_WAIT, + false, + ); + } + else if *save_state_situation_kind == SITUATION_KIND_AIR + && status != FIGHTER_STATUS_KIND_FALL + { + StatusModule::change_status_request( + module_accessor, + *FIGHTER_STATUS_KIND_FALL, + false, + ); + } + else if *save_state_situation_kind == SITUATION_KIND_CLIFF && status != FIGHTER_STATUS_KIND_CLIFF_CATCH_MOVE && status != FIGHTER_STATUS_KIND_CLIFF_CATCH { @@ -133,6 +148,7 @@ pub unsafe fn save_states(module_accessor: &mut app::BattleObjectModuleAccessor) ); } *save_state = NoAction; + return; } // Grab + Dpad down: Save state diff --git a/src/training/Tech.rs b/src/training/Tech.rs index 238f854..ccd2508 100644 --- a/src/training/Tech.rs +++ b/src/training/Tech.rs @@ -68,19 +68,20 @@ pub unsafe fn should_perform_defensive_option( *FIGHTER_STATUS_KIND_DOWN_STAND_ATTACK, ] .contains(&prev_status) - || [ - *FIGHTER_STATUS_KIND_DOWN_STAND, - *FIGHTER_STATUS_KIND_DOWN_STAND_FB, - *FIGHTER_STATUS_KIND_DOWN_STAND_ATTACK, - ] - .contains(&status)) + // || [ + // *FIGHTER_STATUS_KIND_DOWN_STAND, + // *FIGHTER_STATUS_KIND_DOWN_STAND_FB, + // *FIGHTER_STATUS_KIND_DOWN_STAND_ATTACK, + // ] + // .contains(&status) + ) && ( WorkModule::is_enable_transition_term( module_accessor, *FIGHTER_STATUS_TRANSITION_TERM_ID_CONT_GUARD_ON, ) - // || - // CancelModule::is_enable_cancel(module_accessor) + || + CancelModule::is_enable_cancel(module_accessor) ) }