diff --git a/src/training/ledge.rs b/src/training/ledge.rs index 0aca3e2..8da9ca8 100644 --- a/src/training/ledge.rs +++ b/src/training/ledge.rs @@ -3,9 +3,7 @@ use smash::lib::lua_const::*; use crate::common::consts::*; use crate::common::*; -use crate::training::frame_counter; -use crate::training::mash; -use crate::training::input_record; +use crate::training::{frame_counter, mash, input_record}; const NOT_SET: u32 = 9001; static mut LEDGE_DELAY: u32 = NOT_SET; @@ -59,6 +57,43 @@ fn roll_ledge_case() { } } +fn get_ledge_option() -> Option { + unsafe { + let mut override_action: Option = None; + let regular_action = if MENU.mash_triggers.contains(MashTrigger::LEDGE) + {Some(MENU.mash_state.get_random())} + else {None}; + + match LEDGE_CASE { + LedgeOption::NEUTRAL => { + if MENU.ledge_neutral_override != Action::empty() { + override_action = Some(MENU.ledge_neutral_override.get_random()); + } + } + LedgeOption::ROLL => { + if MENU.ledge_roll_override != Action::empty() { + override_action = Some(MENU.ledge_roll_override.get_random()); + } + } + LedgeOption::JUMP => { + if MENU.ledge_jump_override != Action::empty() { + override_action = Some(MENU.ledge_jump_override.get_random()); + } + } + LedgeOption::ATTACK => { + if MENU.ledge_attack_override != Action::empty() { + override_action = Some(MENU.ledge_attack_override.get_random()); + } + } + _ => { + override_action = None; + } + } + return override_action.or(regular_action); + } + +} + pub unsafe fn force_option(module_accessor: &mut app::BattleObjectModuleAccessor) { if StatusModule::situation_kind(module_accessor) != *SITUATION_KIND_CLIFF { // No longer on ledge, so re-roll the ledge case and reset the delay counter for next time @@ -124,19 +159,9 @@ pub unsafe fn force_option(module_accessor: &mut app::BattleObjectModuleAccessor StatusModule::change_status_request_from_script(module_accessor, status, true); } - if MENU.mash_triggers.contains(MashTrigger::LEDGE) { - if LEDGE_CASE == LedgeOption::NEUTRAL && MENU.ledge_neutral_override != Action::empty() { - mash::external_buffer_menu_mash(MENU.ledge_neutral_override.get_random()); - } else if LEDGE_CASE == LedgeOption::ROLL && MENU.ledge_roll_override != Action::empty() { - mash::external_buffer_menu_mash(MENU.ledge_roll_override.get_random()); - } else if LEDGE_CASE == LedgeOption::JUMP && MENU.ledge_jump_override != Action::empty() { - mash::external_buffer_menu_mash(MENU.ledge_jump_override.get_random()); - } else if LEDGE_CASE == LedgeOption::ATTACK && MENU.ledge_attack_override != Action::empty() - { - mash::external_buffer_menu_mash(MENU.ledge_attack_override.get_random()); - } else { - mash::external_buffer_menu_mash(MENU.mash_state.get_random()); - } + let ledge_option: Option = get_ledge_option(); + if ledge_option.is_some() { + mash::external_buffer_menu_mash(ledge_option.unwrap()); } } diff --git a/training_mod_consts/src/lib.rs b/training_mod_consts/src/lib.rs index 7087fc9..c2dd72d 100644 --- a/training_mod_consts/src/lib.rs +++ b/training_mod_consts/src/lib.rs @@ -73,8 +73,8 @@ pub struct TrainingModpackMenu { pub landing_override: Action, pub trump_override: Action, pub save_state_playback: OnOff, - pub recording_slot: RecordSlot, - pub playback_slot: PlaybackSlot, + //pub recording_slot: RecordSlot, + //pub playback_slot: PlaybackSlot, pub playback_mash: OnOff, pub record_trigger: RecordTrigger, pub hitstun_playback: HitstunPlayback, @@ -169,12 +169,12 @@ pub static DEFAULTS_MENU: TrainingModpackMenu = TrainingModpackMenu { landing_override: Action::empty(), trump_override: Action::empty(), save_state_playback: OnOff::Off, - recording_slot: RecordSlot::S1, - playback_slot: PlaybackSlot::S1, + //recording_slot: RecordSlot::S1, + //playback_slot: PlaybackSlot::S1, playback_mash: OnOff::On, record_trigger: RecordTrigger::None, //Command? hitstun_playback: HitstunPlayback::Hitstun, - // TODO: alphabetize? + // TODO: alphabetize }; pub static mut MENU: TrainingModpackMenu = DEFAULTS_MENU; @@ -752,20 +752,20 @@ pub unsafe fn ui_menu(menu: TrainingModpackMenu) -> UiMenu<'static> { true, &(menu.save_state_playback as u32), ); - input_tab.add_submenu_with_toggles::( - "Recording Slot", - "recording_slot", - "Recording Slot: Choose which slot to record into", - true, - &(menu.recording_slot as u32), - ); - input_tab.add_submenu_with_toggles::( // TODO: This menu should really be a submenu inside Action menus, probably want to be able to customize for each action - "Playback Slots", - "playback_slot", - "Playback Slots: Choose which slots to choose between for playback when this action is triggered", - false, - &(menu.playback_slot.bits() as u32), - ); + // input_tab.add_submenu_with_toggles::( + // "Recording Slot", + // "recording_slot", + // "Recording Slot: Choose which slot to record into", + // true, + // &(menu.recording_slot as u32), + // ); + // input_tab.add_submenu_with_toggles::( // TODO: This menu should really be a submenu inside Action menus, probably want to be able to customize for each action + // "Playback Slots", + // "playback_slot", + // "Playback Slots: Choose which slots to choose between for playback when this action is triggered", + // false, + // &(menu.playback_slot.bits() as u32), + // ); input_tab.add_submenu_with_toggles::( "Mash Ends Playback", "playback_mash",