1
0
Fork 0
mirror of https://github.com/jugeeya/UltimateTrainingModpack.git synced 2024-11-20 00:46:34 +00:00

Save State Loading Enhancements (#305)

* First attempt. Issue with beginning of misfoot voice lines being played, trying to debug and fix.

* SFX fix, additional GFX fix
This commit is contained in:
GradualSyrup 2022-02-20 15:52:36 -06:00 committed by GitHub
parent 42ca84b820
commit e18b02e985
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 53 additions and 2 deletions

View file

@ -3,10 +3,10 @@ use crate::hitbox_visualizer;
use skyline::hooks::{getRegionAddress, InlineCtx, Region};
use skyline::nn::hid::*;
use skyline::nn::ro::LookupSymbol;
use smash::app::{self, lua_bind::*};
use smash::app::{self, lua_bind::*, enSEType};
use smash::lib::lua_const::*;
use smash::params::*;
use smash::phx::Hash40;
use smash::phx::{Hash40, Vector3f};
pub mod buff;
pub mod combo;
@ -377,6 +377,43 @@ unsafe fn stale_menu_handle(ctx: &mut InlineCtx) {
*x1 = on_text_ptr;
}
#[skyline::hook(replace = SoundModule::play_se)] // hooked to prevent death sfx from playing when loading save states
pub unsafe fn handle_se(
module_accessor: &mut app::BattleObjectModuleAccessor,
my_hash: Hash40,
bool1: bool,
bool2: bool,
bool3: bool,
bool4: bool,
se_type: enSEType
) -> u64 {
// Make effects silent while we're killing fighters. Stops death explosion and fighter misfoot.
if save_states::is_killing() {
let silent_hash = Hash40::new("se_silent");
return original!()(module_accessor,silent_hash,bool1,bool2,bool3,bool4,se_type);
}
original!()(module_accessor, my_hash,bool1,bool2,bool3,bool4,se_type)
}
#[skyline::hook(replace = EffectModule::req)] // hooked to prevent death gfx from playing when loading save states
pub unsafe fn handle_effect(
module_accessor: &mut app::BattleObjectModuleAccessor,
eff_hash: Hash40,
pos: *const Vector3f,
rot: *const Vector3f,
size: f32,
arg6: u32,
arg7: i32,
arg8: bool,
arg9: i32
) -> u64 {
if save_states::is_killing() {
// Making the size 0 prevents these effects from being displayed. Fixs throw explosions, ICs squall, etc.
return original!()(module_accessor,eff_hash,pos,rot,0.0,arg6,arg7,arg8,arg9);
}
original!()(module_accessor,eff_hash,pos,rot,size,arg6,arg7,arg8,arg9)
}
#[allow(improper_ctypes)]
extern "C" {
fn add_nn_hid_hook(callback: fn(*mut NpadHandheldState, *const u32));
@ -445,6 +482,10 @@ pub fn training_mods() {
// Stale Moves
stale_handle,
stale_menu_handle,
// Death SFX
handle_se,
// Death GFX
handle_effect,
);
combo::init();

View file

@ -270,6 +270,16 @@ pub unsafe fn save_states(module_accessor: &mut app::BattleObjectModuleAccessor)
if fighter_is_buffable {
save_state.state = ApplyBuff;
}
// Play Training Reset SFX, since silence is eerie
// Only play for the CPU so we don't have 2 overlapping
if is_cpu {
SoundModule::play_se_no3d(
module_accessor,
Hash40::new("se_system_position_reset"),
true,
true
);
}
}
// if the fighter is Popo, change the state to one where only Nana can move