1
0
Fork 0
mirror of https://github.com/jugeeya/UltimateTrainingModpack.git synced 2024-11-24 10:54:16 +00:00

fix frame advantage buffer bug

This commit is contained in:
jugeeya 2020-08-07 17:42:14 -07:00
parent 658c0fe63c
commit e7ec867581
3 changed files with 73 additions and 13 deletions

View file

@ -22,3 +22,7 @@ lto = true
[package.metadata.skyline]
titleid = "01006A800016E000"
plugin-dependencies = [
{ name = "libnro_hook.nro", url = "https://github.com/ultimate-research/nro-hook-plugin/releases/download/v0.1.1/libnro_hook.nro" },
]

View file

@ -37,20 +37,62 @@ unsafe fn get_module_accessor(fighter_id: FighterId) -> *mut app::BattleObjectMo
app::sv_battle_object::module_accessor(current_fighter_id as u32)
}
macro_rules! actionable_statuses {
() => {
vec![
FIGHTER_STATUS_TRANSITION_TERM_ID_CONT_ESCAPE_AIR,
FIGHTER_STATUS_TRANSITION_TERM_ID_CONT_ATTACK_AIR,
FIGHTER_STATUS_TRANSITION_TERM_ID_CONT_GUARD_ON,
FIGHTER_STATUS_TRANSITION_TERM_ID_CONT_ESCAPE
];
};
}
unsafe fn is_actionable(module_accessor: *mut app::BattleObjectModuleAccessor) -> bool {
WorkModule::is_enable_transition_term(
module_accessor,
*FIGHTER_STATUS_TRANSITION_TERM_ID_CONT_ESCAPE_AIR,
) || WorkModule::is_enable_transition_term(
module_accessor,
*FIGHTER_STATUS_TRANSITION_TERM_ID_CONT_ATTACK_AIR,
) || WorkModule::is_enable_transition_term(
module_accessor,
*FIGHTER_STATUS_TRANSITION_TERM_ID_CONT_GUARD_ON,
) || WorkModule::is_enable_transition_term(
module_accessor,
*FIGHTER_STATUS_TRANSITION_TERM_ID_CONT_ESCAPE,
) || CancelModule::is_enable_cancel(module_accessor)
actionable_statuses!().iter().any(
|actionable_transition|
WorkModule::is_enable_transition_term(module_accessor, **actionable_transition))
|| CancelModule::is_enable_cancel(module_accessor)
}
pub unsafe fn is_enable_transition_term(
module_accessor: *mut app::BattleObjectModuleAccessor,
transition_term: i32,
is: bool
) {
let entry_id_int =
WorkModule::get_int(module_accessor, *FIGHTER_INSTANCE_WORK_ID_INT_ENTRY_ID) as i32;
if entry_id_int != (FighterId::Player as i32) {
return;
}
// Extra check later in the frame.
// This is in the case that the transition term becomes enabled after our initial check
// and the user buffers that action on that frame.
if !PLAYER_ACTIONABLE &&
(
(is && actionable_statuses!().iter().any(|actionable_transition| *actionable_transition == transition_term))
||
(CancelModule::is_enable_cancel(module_accessor))
) {
PLAYER_ACTIVE_FRAME = frame_counter::get_frame_count(FRAME_COUNTER_INDEX);
PLAYER_ACTIONABLE = true;
// if both are now active
if PLAYER_ACTIONABLE && CPU_ACTIONABLE {
if FRAME_ADVANTAGE_CHECK {
let cpu_module_accessor = get_module_accessor(FighterId::CPU);
if was_in_hitstun(cpu_module_accessor) || was_in_shieldstun(cpu_module_accessor) {
FRAME_ADVANTAGE = (CPU_ACTIVE_FRAME as i64 - PLAYER_ACTIVE_FRAME as i64) as i32;
}
frame_counter::stop_counting(FRAME_COUNTER_INDEX);
FRAME_ADVANTAGE_CHECK = false;
}
}
}
}
pub unsafe fn get_command_flag_cat(

View file

@ -196,6 +196,18 @@ pub unsafe fn handle_change_motion(
)
}
#[skyline::hook(replace = WorkModule::is_enable_transition_term)]
pub unsafe fn handle_is_enable_transition_term(
module_accessor: *mut app::BattleObjectModuleAccessor,
transition_term: i32
) -> bool {
let is = original!()(module_accessor, transition_term);
combo::is_enable_transition_term(module_accessor, transition_term, is);
is
}
pub fn training_mods() {
println!("[Training Modpack] Applying training mods.");
unsafe {
@ -230,6 +242,8 @@ pub fn training_mods() {
// Directional AirDodge,
get_stick_x,
get_stick_y,
// Combo
handle_is_enable_transition_term,
);
combo::init();