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

Get the correct amount to reduce clatter time from start_clatter (#428)

This commit is contained in:
asimon-1 2022-11-11 00:37:01 -05:00 committed by GitHub
parent 6466918f7b
commit 97c2dc5fd0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 40 additions and 1 deletions

View file

@ -143,6 +143,8 @@ pub unsafe fn is_dead(module_accessor: &mut app::BattleObjectModuleAccessor) ->
}
pub unsafe fn is_in_clatter(module_accessor: &mut app::BattleObjectModuleAccessor) -> bool {
// TODO: this function can give false positives if the clatter status ends for some reason
// other than a mash out (e.g. the fighter was thrown, or was hit hard enough)
ControlModule::get_clatter_time(module_accessor, 0) > 0.0
}

View file

@ -8,9 +8,10 @@ use smash::phx::{Hash40, Vector3f};
static mut COUNTER: u32 = 0;
static mut WAS_IN_CLATTER_FLAG: bool = false;
static mut CLATTER_STEP: f32 = 8.0;
unsafe fn do_clatter_input(module_accessor: &mut BattleObjectModuleAccessor) {
ControlModule::add_clatter_time(module_accessor, -8.0, 0);
ControlModule::add_clatter_time(module_accessor, -1.0 * CLATTER_STEP, 0);
let zeros = Vector3f {
x: 0.0,
y: 0.0,
@ -36,6 +37,8 @@ unsafe fn do_clatter_input(module_accessor: &mut BattleObjectModuleAccessor) {
}
pub unsafe fn handle_clatter(module_accessor: &mut BattleObjectModuleAccessor) {
// TODO: handle swallowed and cargo carry statuses.
// Look at set_dec_time/set_dec_time_recovery functions
if !is_training_mode() || !is_operation_cpu(module_accessor) {
return;
}
@ -54,3 +57,35 @@ pub unsafe fn handle_clatter(module_accessor: &mut BattleObjectModuleAccessor) {
do_clatter_input(module_accessor);
}
}
#[skyline::hook(replace = ControlModule::start_clatter)]
pub unsafe fn hook_start_clatter(
module_accessor: &mut BattleObjectModuleAccessor,
initial_clatter_time: f32,
auto_recovery_rate: f32,
manual_recovery_rate: f32,
arg5: i8,
arg6: i32,
arg7: bool,
arg8: bool,
) -> u64 {
// This function is called at the beginning of every clatter situation
// Grab the manual recovery rate and set that as the amount to reduce
// the clatter time during each simulated input.
//
// Most of the time this is 8 frames, but could be less depending on
// the status (e.g. freeze is 4 frames / input)
if is_training_mode() && is_operation_cpu(module_accessor) {
CLATTER_STEP = manual_recovery_rate.clone();
}
original!()(
module_accessor,
initial_clatter_time,
auto_recovery_rate,
manual_recovery_rate,
arg5,
arg6,
arg7,
arg8,
)
}

View file

@ -553,6 +553,8 @@ pub fn training_mods() {
handle_effect,
// Star KO turn off
handle_star_ko,
// Clatter
clatter::hook_start_clatter,
);
combo::init();