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

Update Hold Shield Mode (#79)

* Update Hold Shield Mode

Shield decay is paused until hit for the first time to simulate a frame perfect shield hold

* Update Readme

* Remove Debugging Code
This commit is contained in:
sidschingis 2020-06-08 22:21:34 +02:00 committed by GitHub
parent 365c1da1ee
commit 9a1e572a4b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 44 additions and 8 deletions

View file

@ -70,7 +70,7 @@ Specific options include:
CPUs will hold a shield that does not deteriorate over time or by damage.
###### Hold
CPUs will hold a normal shield.
CPUs will hold a shield that does not deteriorate over time until hit for the first time.
#### Force CPU DI
##### All DI Toggles

View file

@ -45,6 +45,7 @@ pub unsafe fn handle_get_command_flag_cat(
// int ret = InputRecorder::get_command_flag_cat(module_accessor, category, flag, replace);
// if (replace) return ret;
shield::get_command_flag_cat(module_accessor);
mash::get_command_flag_cat(module_accessor, category, &mut flag);
ledge::get_command_flag_cat(module_accessor, category, &mut flag);
tech::get_command_flag_cat(module_accessor, category, &mut flag);
@ -125,7 +126,7 @@ pub unsafe fn handle_change_motion(
unk6: bool,
) -> u64 {
let motion_kind = tech::change_motion(module_accessor, motion_kind).unwrap_or(motion_kind);
original!()(
module_accessor,
motion_kind,
@ -154,12 +155,12 @@ pub fn training_mods() {
// Hold/Infinite shield
handle_check_button_on,
handle_check_button_off,
handle_get_param_float,
// Mash attack
handle_get_attack_air_kind,
// Tech options
handle_change_motion,
);

View file

@ -8,13 +8,40 @@ use smash::app::sv_system;
use smash::lib::L2CValue;
use smash::lua2cpp::L2CFighterCommon;
// Toggle for shield decay
static mut SHIELD_DECAY: bool = false;
unsafe fn set_shield_decay(value: bool) {
SHIELD_DECAY = value;
}
unsafe fn should_pause_shield_decay() -> bool {
!SHIELD_DECAY
}
pub unsafe fn get_command_flag_cat(module_accessor: &mut app::BattleObjectModuleAccessor) {
if !is_training_mode() {
return;
}
if !is_operation_cpu(module_accessor) {
return;
}
// Reset when not shielding
let status_kind = StatusModule::status_kind(module_accessor);
if !(status_kind == FIGHTER_STATUS_KIND_GUARD) {
set_shield_decay(false);
}
}
pub unsafe fn get_param_float(
_module_accessor: &mut app::BattleObjectModuleAccessor,
param_type: u64,
param_hash: u64,
) -> Option<f32> {
if is_training_mode() {
if MENU.shield_state == Shield::Infinite {
if MENU.shield_state == Shield::Infinite || should_pause_shield_decay() {
if param_type == hash40("common") {
if param_hash == hash40("shield_dec1") {
return Some(0.0);
@ -49,8 +76,8 @@ pub unsafe fn should_hold_shield(module_accessor: &mut app::BattleObjectModuleAc
if MENU.mash_state == Mash::Attack {
if [Attack::NeutralB, Attack::SideB, Attack::DownB].contains(&MENU.mash_attack_state) {
return false;
}
}
if MENU.mash_attack_state == Attack::Grab {
return true;
}
@ -63,6 +90,14 @@ pub unsafe fn should_hold_shield(module_accessor: &mut app::BattleObjectModuleAc
#[skyline::hook(replace = smash::lua2cpp::L2CFighterCommon_sub_guard_cont)]
pub unsafe fn handle_sub_guard_cont(fighter: &mut L2CFighterCommon) -> L2CValue {
let module_accessor = sv_system::battle_object_module_accessor(fighter.lua_state_agent);
// Enable shield decay
if is_training_mode()
&& is_operation_cpu(module_accessor)
&& StatusModule::prev_status_kind(module_accessor, 0) == FIGHTER_STATUS_KIND_GUARD_DAMAGE {
set_shield_decay(true);
}
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 {