mirror of
https://github.com/jugeeya/UltimateTrainingModpack.git
synced 2024-11-20 00:46:34 +00:00
Add a lockout timer to snake dthrow mistech options (#419)
* Add a lockout timer to snake dthrow mistech options * Remove print statement
This commit is contained in:
parent
6de87cd546
commit
8858fbcedd
2 changed files with 68 additions and 18 deletions
|
@ -564,4 +564,5 @@ pub fn training_mods() {
|
||||||
menu::init();
|
menu::init();
|
||||||
buff::init();
|
buff::init();
|
||||||
items::init();
|
items::init();
|
||||||
|
tech::init();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
use crate::common::consts::*;
|
use crate::common::consts::*;
|
||||||
use crate::common::*;
|
use crate::common::*;
|
||||||
use crate::training::mash;
|
use crate::training::{ frame_counter, mash };
|
||||||
use smash::app::sv_system;
|
use smash::app::sv_system;
|
||||||
use smash::app::{self, lua_bind::*};
|
use smash::app::{self, lua_bind::*};
|
||||||
use smash::hash40;
|
use smash::hash40;
|
||||||
|
@ -8,8 +8,16 @@ use smash::lib::lua_const::*;
|
||||||
use smash::lib::L2CValue;
|
use smash::lib::L2CValue;
|
||||||
use smash::lua2cpp::L2CFighterBase;
|
use smash::lua2cpp::L2CFighterBase;
|
||||||
|
|
||||||
|
|
||||||
static mut TECH_ROLL_DIRECTION: Direction = Direction::empty();
|
static mut TECH_ROLL_DIRECTION: Direction = Direction::empty();
|
||||||
static mut MISS_TECH_ROLL_DIRECTION: Direction = Direction::empty();
|
static mut MISS_TECH_ROLL_DIRECTION: Direction = Direction::empty();
|
||||||
|
static mut FRAME_COUNTER: usize = 0;
|
||||||
|
|
||||||
|
pub fn init() {
|
||||||
|
unsafe {
|
||||||
|
FRAME_COUNTER = frame_counter::register_counter();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[skyline::hook(replace = smash::lua2cpp::L2CFighterBase_change_status)]
|
#[skyline::hook(replace = smash::lua2cpp::L2CFighterBase_change_status)]
|
||||||
pub unsafe fn handle_change_status(
|
pub unsafe fn handle_change_status(
|
||||||
|
@ -187,16 +195,17 @@ pub unsafe fn get_command_flag_cat(module_accessor: &mut app::BattleObjectModule
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
let status = StatusModule::status_kind(module_accessor) as i32;
|
|
||||||
|
|
||||||
|
let status = StatusModule::status_kind(module_accessor) as i32;
|
||||||
|
let mut requested_status: i32 = 0;
|
||||||
if [
|
if [
|
||||||
*FIGHTER_STATUS_KIND_DOWN_WAIT, // Mistech
|
*FIGHTER_STATUS_KIND_DOWN_WAIT,
|
||||||
*FIGHTER_STATUS_KIND_DOWN_WAIT_CONTINUE, // Mistech
|
*FIGHTER_STATUS_KIND_DOWN_WAIT_CONTINUE,
|
||||||
*FIGHTER_STATUS_KIND_LAY_DOWN, // Snake down throw
|
|
||||||
]
|
]
|
||||||
.contains(&status)
|
.contains(&status)
|
||||||
{
|
{
|
||||||
let status: i32 = match MENU.miss_tech_state.get_random() {
|
// Mistech
|
||||||
|
requested_status = match MENU.miss_tech_state.get_random() {
|
||||||
MissTechFlags::GETUP => *FIGHTER_STATUS_KIND_DOWN_STAND,
|
MissTechFlags::GETUP => *FIGHTER_STATUS_KIND_DOWN_STAND,
|
||||||
MissTechFlags::ATTACK => *FIGHTER_STATUS_KIND_DOWN_STAND_ATTACK,
|
MissTechFlags::ATTACK => *FIGHTER_STATUS_KIND_DOWN_STAND_ATTACK,
|
||||||
MissTechFlags::ROLL_F => {
|
MissTechFlags::ROLL_F => {
|
||||||
|
@ -209,28 +218,43 @@ pub unsafe fn get_command_flag_cat(module_accessor: &mut app::BattleObjectModule
|
||||||
}
|
}
|
||||||
_ => return,
|
_ => return,
|
||||||
};
|
};
|
||||||
StatusModule::change_status_request_from_script(module_accessor, status, false);
|
} else if status == *FIGHTER_STATUS_KIND_LAY_DOWN {
|
||||||
if MENU.mash_triggers.contains(MashTrigger::MISTECH) {
|
// Snake down throw
|
||||||
mash::buffer_menu_mash();
|
let lockout_time = get_snake_laydown_lockout_time(module_accessor);
|
||||||
}
|
if frame_counter::should_delay(lockout_time, FRAME_COUNTER) { return; };
|
||||||
} else if [
|
requested_status = match MENU.miss_tech_state.get_random() {
|
||||||
|
MissTechFlags::GETUP => *FIGHTER_STATUS_KIND_DOWN_STAND,
|
||||||
|
MissTechFlags::ATTACK => *FIGHTER_STATUS_KIND_DOWN_STAND_ATTACK,
|
||||||
|
MissTechFlags::ROLL_F => {
|
||||||
|
MISS_TECH_ROLL_DIRECTION = Direction::IN; // = In
|
||||||
|
*FIGHTER_STATUS_KIND_DOWN_STAND_FB
|
||||||
|
}
|
||||||
|
MissTechFlags::ROLL_B => {
|
||||||
|
MISS_TECH_ROLL_DIRECTION = Direction::OUT; // = Away
|
||||||
|
*FIGHTER_STATUS_KIND_DOWN_STAND_FB
|
||||||
|
}
|
||||||
|
_ => return,
|
||||||
|
};
|
||||||
|
} else if status == *FIGHTER_STATUS_KIND_SLIP_WAIT {
|
||||||
// Handle slips (like Diddy banana)
|
// Handle slips (like Diddy banana)
|
||||||
*FIGHTER_STATUS_KIND_SLIP_WAIT,
|
requested_status = match MENU.miss_tech_state.get_random() {
|
||||||
]
|
|
||||||
.contains(&status)
|
|
||||||
{
|
|
||||||
let status: i32 = match MENU.miss_tech_state.get_random() {
|
|
||||||
MissTechFlags::GETUP => *FIGHTER_STATUS_KIND_SLIP_STAND,
|
MissTechFlags::GETUP => *FIGHTER_STATUS_KIND_SLIP_STAND,
|
||||||
MissTechFlags::ATTACK => *FIGHTER_STATUS_KIND_SLIP_STAND_ATTACK,
|
MissTechFlags::ATTACK => *FIGHTER_STATUS_KIND_SLIP_STAND_ATTACK,
|
||||||
MissTechFlags::ROLL_F => *FIGHTER_STATUS_KIND_SLIP_STAND_F,
|
MissTechFlags::ROLL_F => *FIGHTER_STATUS_KIND_SLIP_STAND_F,
|
||||||
MissTechFlags::ROLL_B => *FIGHTER_STATUS_KIND_SLIP_STAND_B,
|
MissTechFlags::ROLL_B => *FIGHTER_STATUS_KIND_SLIP_STAND_B,
|
||||||
_ => return,
|
_ => return,
|
||||||
};
|
};
|
||||||
StatusModule::change_status_request_from_script(module_accessor, status, false);
|
} else {
|
||||||
|
// Not in a tech situation, make sure the snake dthrow counter is fully reset.
|
||||||
|
frame_counter::full_reset(FRAME_COUNTER);
|
||||||
|
};
|
||||||
|
|
||||||
|
if requested_status != 0 {
|
||||||
|
StatusModule::change_status_request_from_script(module_accessor, requested_status, false);
|
||||||
if MENU.mash_triggers.contains(MashTrigger::MISTECH) {
|
if MENU.mash_triggers.contains(MashTrigger::MISTECH) {
|
||||||
mash::buffer_menu_mash();
|
mash::buffer_menu_mash();
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub unsafe fn change_motion(
|
pub unsafe fn change_motion(
|
||||||
|
@ -267,3 +291,28 @@ pub unsafe fn change_motion(
|
||||||
|
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
|
||||||
|
unsafe fn get_snake_laydown_lockout_time(
|
||||||
|
module_accessor: &mut app::BattleObjectModuleAccessor,
|
||||||
|
) -> u32 {
|
||||||
|
let base_lockout_time: f32 = WorkModule::get_param_float(
|
||||||
|
module_accessor,
|
||||||
|
hash40("common"),
|
||||||
|
hash40("laydown_no_action_frame"),
|
||||||
|
);
|
||||||
|
let max_lockout_time: f32 = WorkModule::get_param_float(
|
||||||
|
module_accessor,
|
||||||
|
hash40("common"),
|
||||||
|
hash40("laydown_no_action_frame_max"),
|
||||||
|
);
|
||||||
|
let max_lockout_damage: f32 = WorkModule::get_param_float(
|
||||||
|
module_accessor,
|
||||||
|
hash40("common"),
|
||||||
|
hash40("laydown_damage_max"),
|
||||||
|
);
|
||||||
|
let damage: f32 = DamageModule::damage(module_accessor, 0);
|
||||||
|
std::cmp::min(
|
||||||
|
(base_lockout_time + (damage / max_lockout_damage) * (max_lockout_time - base_lockout_time)) as u32,
|
||||||
|
max_lockout_time as u32
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue