1
0
Fork 0
mirror of https://github.com/jugeeya/UltimateTrainingModpack.git synced 2025-03-16 11:26:11 +00:00

Add OOS Offset (#81)

* Add Roll Options

Added forward/backwards roll options

* Update TrainingModpackOverlay

* Change Option Order

* Update TrainingModpackOverlay

* Add OOS Offset

Allow delaying OOS options until a certain number of hits have connected on shield

* Update TrainingModpackOverlay

* get_param_float  fix

Fixed applying to non CPU values

* Remove Debugging
This commit is contained in:
sidschingis 2020-06-10 20:38:01 +02:00 committed by GitHub
parent 300bce1161
commit 4363935a1d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 86 additions and 3 deletions

@ -1 +1 @@
Subproject commit e9e48521ee22ba1d022cc639d366670aaea95b7d
Subproject commit 5a5350b52d53dec2ae3c1aa1ab0a158731daf640

View file

@ -217,4 +217,5 @@ pub struct TrainingModpackMenu {
pub mash_state: Mash,
pub shield_state: Shield,
pub defensive_state: Defensive,
pub oos_offset: u8,
}

View file

@ -14,6 +14,7 @@ pub static mut MENU_STRUCT: consts::TrainingModpackMenu = consts::TrainingModpac
mash_state: Mash::None,
shield_state: Shield::None,
defensive_state: Defensive::Random,
oos_offset: 0,
};
pub static MENU: &'static mut consts::TrainingModpackMenu = unsafe { &mut MENU_STRUCT };
@ -23,7 +24,7 @@ pub static mut FIGHTER_MANAGER_ADDR: usize = 0;
extern "C" {
#[link_name = "\u{1}_ZN3app9smashball16is_training_modeEv"]
pub fn is_training_mode() -> bool;
//#[link_name = "\u{1}_ZN3app7utility8get_kindEPKNS_26BattleObjectModuleAccessorE"]
//pub fn get_kind(module_accessor: &mut app::BattleObjectModuleAccessor) -> i32;
}
@ -50,6 +51,11 @@ pub unsafe fn is_operation_cpu(module_accessor: &mut app::BattleObjectModuleAcce
FighterInformation::is_operation_cpu(fighter_information)
}
pub unsafe fn is_idle(module_accessor: &mut app::BattleObjectModuleAccessor) -> bool {
let status_kind = StatusModule::status_kind(module_accessor);
status_kind == FIGHTER_STATUS_KIND_WAIT
}
pub unsafe fn is_in_hitstun(module_accessor: &mut app::BattleObjectModuleAccessor) -> bool {
let status_kind = StatusModule::status_kind(module_accessor);
(*FIGHTER_STATUS_KIND_DAMAGE..=*FIGHTER_STATUS_KIND_DAMAGE_FALL).contains(&status_kind)

View file

@ -1,5 +1,6 @@
use crate::common::consts::*;
use crate::common::*;
use crate::training::shield;
use smash::app::{self, lua_bind::*};
use smash::hash40;
use smash::lib::lua_const::*;
@ -25,6 +26,12 @@ pub unsafe fn get_command_flag_cat(
category: i32,
flag: &mut i32,
) {
// Check for OOS delay
if is_training_mode() && is_operation_cpu(module_accessor)
&& is_in_shieldstun(module_accessor) && !shield::allow_oos(){
return;
}
if is_training_mode() && is_operation_cpu(module_accessor) {
if is_in_hitstun(module_accessor)
|| is_in_landing(module_accessor)

View file

@ -8,6 +8,11 @@ use smash::app::sv_system;
use smash::lib::L2CValue;
use smash::lua2cpp::L2CFighterCommon;
// How many hits to hold shield until picking an Out Of Shield option
static mut MULTI_HIT_OFFSET : u8 = MENU.oos_offset;
// Used to only decrease once per shieldstun change
static mut WAS_IN_SHIELDSTUN: bool = false;
// Toggle for shield decay
static mut SHIELD_DECAY: bool = false;
@ -19,6 +24,42 @@ unsafe fn should_pause_shield_decay() -> bool {
!SHIELD_DECAY
}
unsafe fn reset_oos_offset(){
/*
* Need to offset by 1, since we decrease as soon as shield gets hit
* but only check later if we can OOS
*/
MULTI_HIT_OFFSET = MENU.oos_offset + 1;
}
unsafe fn handle_oos_offset(module_accessor: &mut app::BattleObjectModuleAccessor)
{
// Check if we are currently in shield stun
if !is_in_shieldstun(module_accessor) {
// Make sure we don't forget and wait until we get hit on shield
WAS_IN_SHIELDSTUN = false;
return;
}
// Make sure we just freshly entered shield stun
if WAS_IN_SHIELDSTUN {
return;
}
// Decrease offset once if needed
if MULTI_HIT_OFFSET > 0 {
MULTI_HIT_OFFSET -= 1;
}
// Mark that we were in shield stun, so we don't decrease again
WAS_IN_SHIELDSTUN = true;
}
pub unsafe fn allow_oos()->bool {
// Delay OOS until offset hits 0
MULTI_HIT_OFFSET == 0
}
pub unsafe fn get_command_flag_cat(module_accessor: &mut app::BattleObjectModuleAccessor) {
if !is_training_mode() {
return;
@ -28,6 +69,12 @@ pub unsafe fn get_command_flag_cat(module_accessor: &mut app::BattleObjectModule
return;
}
// Reset oos offset when standing
if is_idle(module_accessor)
|| is_in_hitstun(module_accessor){
reset_oos_offset();
}
// Reset when not shielding
let status_kind = StatusModule::status_kind(module_accessor);
if !(status_kind == FIGHTER_STATUS_KIND_GUARD) {
@ -36,11 +83,20 @@ pub unsafe fn get_command_flag_cat(module_accessor: &mut app::BattleObjectModule
}
pub unsafe fn get_param_float(
_module_accessor: &mut app::BattleObjectModuleAccessor,
module_accessor: &mut app::BattleObjectModuleAccessor,
param_type: u64,
param_hash: u64,
) -> Option<f32> {
if !is_operation_cpu(module_accessor) {
return None;
}
if is_training_mode() {
if MENU.shield_state != Shield::None {
handle_oos_offset(module_accessor);
}
if MENU.shield_state == Shield::Infinite || should_pause_shield_decay() {
if param_type == hash40("common") {
if param_hash == hash40("shield_dec1") {
@ -68,6 +124,11 @@ pub unsafe fn should_hold_shield(module_accessor: &mut app::BattleObjectModuleAc
return true;
}
// Hold shield while OOS is not allowed
if !allow_oos() {
return true;
}
if !is_in_shieldstun(module_accessor) {
return true;
}
@ -98,6 +159,14 @@ pub unsafe fn handle_sub_guard_cont(fighter: &mut L2CFighterCommon) -> L2CValue
set_shield_decay(true);
}
// Check for OOS delay
if is_training_mode()
&& is_operation_cpu(module_accessor)
&& StatusModule::prev_status_kind(module_accessor, 0) == FIGHTER_STATUS_KIND_GUARD_DAMAGE
&& !allow_oos() {
return original!()(fighter);
}
if is_training_mode() && is_operation_cpu(module_accessor) {
if MENU.mash_state == Mash::Attack && MENU.mash_attack_state == Attack::Grab {
if StatusModule::prev_status_kind(module_accessor, 0) == FIGHTER_STATUS_KIND_GUARD_DAMAGE {