From ed528c95d797fd1722d9d67a337d89bb6f530f2e Mon Sep 17 00:00:00 2001 From: GradualSyrup <68757075+GradualSyrup@users.noreply.github.com> Date: Wed, 9 Feb 2022 23:03:30 -0600 Subject: [PATCH] Stale Move hooks and buff cleanup (#304) --- src/training/buff/training.rs | 0 src/training/mod.rs | 26 +++++++++++++++++++++++++- 2 files changed, 25 insertions(+), 1 deletion(-) delete mode 100644 src/training/buff/training.rs diff --git a/src/training/buff/training.rs b/src/training/buff/training.rs deleted file mode 100644 index e69de29..0000000 diff --git a/src/training/mod.rs b/src/training/mod.rs index 0134c2d..4fd60bc 100644 --- a/src/training/mod.rs +++ b/src/training/mod.rs @@ -6,6 +6,7 @@ use smash::app::{self, lua_bind::*}; use smash::lib::lua_const::*; use smash::params::*; use smash::phx::Hash40; +use skyline::hooks::{InlineCtx, Region, getRegionAddress}; pub mod buff; pub mod combo; @@ -355,6 +356,27 @@ pub unsafe fn handle_check_doyle_summon_dispatch( return ori; } +// Set Stale Moves to On +static STALE_OFFSET: usize = 0x013e88a4; +// One instruction after stale moves toggle register is set to 0 +#[skyline::hook(offset=STALE_OFFSET, inline)] +unsafe fn stale_handle(ctx: &mut InlineCtx) { + let x22 = ctx.registers[22].x.as_mut(); + let training_structure_address = (*x22 + 0xb60) as *mut u8; + *training_structure_address = 1; +} + +// Set Stale Moves to On in the menu text +static STALE_MENU_OFFSET: usize = 0x013e88a0; +// One instruction after menu text register is set to off +#[skyline::hook(offset=STALE_MENU_OFFSET, inline)] +unsafe fn stale_menu_handle(ctx: &mut InlineCtx) { + // Set the text pointer to where "mel_training_on" is located + let on_text_ptr = ((getRegionAddress(Region::Text) as u64) + (0x42b215e as u64)) as u64; + let x1 = ctx.registers[1].x.as_mut(); + *x1 = on_text_ptr; +} + #[allow(improper_ctypes)] extern "C" { fn add_nn_hid_hook(callback: fn(*mut NpadHandheldState, *const u32)); @@ -417,10 +439,12 @@ pub fn training_mods() { // SDI crate::training::sdi::check_hit_stop_delay_command, // Buffs - //get_param_float_hook, handle_add_limit, handle_check_doyle_summon_dispatch, handle_req_screen, + // Stale Moves + stale_handle, + stale_menu_handle, ); combo::init();