From 78d4b364001ffe1e021e2721a50308ffa58e52ae Mon Sep 17 00:00:00 2001 From: GradualSyrup <68757075+GradualSyrup@users.noreply.github.com> Date: Sat, 29 Jul 2023 15:12:32 -0500 Subject: [PATCH] Override ledge fix and input recording menu fixes (#542) * GCC+tinkering * First working pass with 8-byte structure usage. Control scheme is effectively copied for CPU. * CPU override, sticks not working properly * Recording working again during record, playback issues. Also, aerials are all nair, and jump/Dash Attack issues. * Structure creation cleanup * Continued testing, still aerial, jump, and dash attack issues * Fix Dockerfile * Rework with ControlModuleInternal and ControlModuleStored - same exact issues * Fix playback inconsistency * Dead code of trying to find attack air address * It works! Fix mash.rs overrides of input playback * Action passing groundwork; Clatter off by default for now * All Overrides implemented, notes on Snake * Input Submenu, dummy slots and save state/mash playback interaction * Nana command fix, mash fix * Initial Savestate/Ledge record (slight issues) * Add TODO * Lasso handled, ledge jump issue fixed, shield decay with input recording fixed, standby setup begun * first frame playback clear, fix neutral getup * Standy by groundwork, broken by our frame late record impl * Prepare for structure change * On time small structure recording, needs ledge adjustments * Coloring fix for poessession, lockout implemented and full ledge functionality * Cleaning and menu fix * Fix ledge option loop and shield holding on mash * Fix shielding issues * turn off playback * Enable input recording * Resolving comments 1,2,4,5 * Resolve comments 6, 7, and 8 * External Mash Function * No Trigger for Overrides, Clatter and Tumble Added * LR Support, Full Hop Fix * Starting Status WIP, Structure WIP, LedgeOption PLAYBACK renaming * WIP Playback Mash - OoS issues - WIP Slots * Merge branch 'main' into for-restructure prep * more merge prep * Return None fix * More cleanup * Block -> Shieldstun * Don't crash on missing menu icons * Add input recording tab to prevent crash * Fix general override behavior * Fix teching overrides * Additional merge changes * Nana fixes (also on master so this will be awkward) * Additional Merge Fixes * Remove extra tab, prevent panic on missing input recording items * Needs proper selection of action * Ledge overrides work without trigger, remove playback/record slot until working --- src/training/ledge.rs | 57 ++++++++++++++++++++++++---------- training_mod_consts/src/lib.rs | 38 +++++++++++------------ 2 files changed, 60 insertions(+), 35 deletions(-) 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",