mirror of
https://github.com/jugeeya/UltimateTrainingModpack.git
synced 2025-01-19 17:00:15 +00:00
Move mash_state from set of constants to an enum
This commit is contained in:
parent
4342f626f8
commit
f86415830d
5 changed files with 44 additions and 23 deletions
|
@ -14,6 +14,7 @@ pub const NONE: i32 = 0;
|
|||
pub const DI_RANDOM_IN_AWAY: i32 = 9;
|
||||
// const std::vector<std::string> di_items{"None", "Out", "Up Out", "Up", "Up In", "In", "Down In", "Down", "Down Out", "Random"};
|
||||
|
||||
/// Mash Attack States
|
||||
#[repr(i32)]
|
||||
#[derive(PartialEq, Debug, Copy, Clone)]
|
||||
pub enum Attack {
|
||||
|
@ -46,7 +47,7 @@ impl From<i32> for Attack {
|
|||
8 => DownB,
|
||||
9 => UpSmash,
|
||||
10 => Grab,
|
||||
_ => panic!("Invalid mash state {}", x)
|
||||
_ => panic!("Invalid mash attack state {}", x)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -86,12 +87,32 @@ pub const TECH_ROLL: i32 = 3;
|
|||
pub const TECH_MISS: i32 = 4;
|
||||
// pub const std::vector<std::string> tech_items{"None", "Random", "In-Place", "Roll", "Miss Tech"};
|
||||
|
||||
// Mash States
|
||||
pub const MASH_AIRDODGE: i32 = 1;
|
||||
pub const MASH_JUMP: i32 = 2;
|
||||
pub const MASH_ATTACK: i32 = 3;
|
||||
pub const MASH_SPOTDODGE: i32 = 4;
|
||||
pub const MASH_RANDOM: i32 = 5;
|
||||
/// Mash States
|
||||
#[repr(i32)]
|
||||
#[derive(Debug, Clone, Copy, PartialEq)]
|
||||
pub enum Mash {
|
||||
None = 0,
|
||||
Airdodge = 1,
|
||||
Jump = 2,
|
||||
Attack = 3,
|
||||
Spotdodge = 4,
|
||||
Random = 5
|
||||
}
|
||||
|
||||
impl From<i32> for Mash {
|
||||
fn from(x: i32) -> Self {
|
||||
match x {
|
||||
0 => Mash::None,
|
||||
1 => Mash::Airdodge,
|
||||
2 => Mash::Jump,
|
||||
3 => Mash::Attack,
|
||||
4 => Mash::Spotdodge,
|
||||
5 => Mash::Random,
|
||||
_ => panic!("Invalid mash state {}", x)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// pub const std::vector<std::string> mash_items{"None", "Airdodge", "Jump", "Attack", "Spotdodge", "Random"};
|
||||
|
||||
// Shield States
|
||||
|
@ -114,7 +135,7 @@ pub struct TrainingModpackMenu {
|
|||
pub mash_attack_state: Attack,
|
||||
pub ledge_state: i32,
|
||||
pub tech_state: i32,
|
||||
pub mash_state: i32,
|
||||
pub mash_state: Mash,
|
||||
pub shield_state: i32,
|
||||
pub defensive_state: i32,
|
||||
}
|
||||
|
|
|
@ -11,7 +11,7 @@ pub static mut MENU_STRUCT: consts::TrainingModpackMenu = consts::TrainingModpac
|
|||
mash_attack_state: Attack::Nair,
|
||||
ledge_state: RANDOM_LEDGE,
|
||||
tech_state: RANDOM_TECH,
|
||||
mash_state: NONE,
|
||||
mash_state: Mash::None,
|
||||
shield_state: NONE,
|
||||
defensive_state: RANDOM_DEFENSIVE,
|
||||
};
|
||||
|
|
|
@ -22,7 +22,7 @@ use smash::lua2cpp::L2CFighterCommon;
|
|||
pub unsafe fn handle_sub_guard_cont(fighter: &mut L2CFighterCommon) -> L2CValue {
|
||||
let module_accessor = sv_system::battle_object_module_accessor(fighter.lua_state_agent);
|
||||
if is_training_mode() && is_operation_cpu(module_accessor) {
|
||||
if MENU.mash_state == MASH_ATTACK && MENU.mash_attack_state == Attack::Grab {
|
||||
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 {
|
||||
if WorkModule::get_int(
|
||||
module_accessor,
|
||||
|
@ -41,7 +41,7 @@ pub unsafe fn handle_sub_guard_cont(fighter: &mut L2CFighterCommon) -> L2CValue
|
|||
}
|
||||
}
|
||||
}
|
||||
if MENU.mash_state == MASH_SPOTDODGE {
|
||||
if MENU.mash_state == Mash::Spotdodge {
|
||||
if StatusModule::prev_status_kind(module_accessor, 0) == FIGHTER_STATUS_KIND_GUARD_DAMAGE {
|
||||
if WorkModule::is_enable_transition_term(
|
||||
module_accessor,
|
||||
|
@ -55,7 +55,7 @@ pub unsafe fn handle_sub_guard_cont(fighter: &mut L2CFighterCommon) -> L2CValue
|
|||
}
|
||||
}
|
||||
|
||||
if MENU.mash_state == MASH_ATTACK {
|
||||
if MENU.mash_state == Mash::Attack {
|
||||
if MENU.mash_attack_state == Attack::UpB {
|
||||
if StatusModule::prev_status_kind(module_accessor, 0) == FIGHTER_STATUS_KIND_GUARD_DAMAGE {
|
||||
// if WorkModule::is_enable_transition_term(
|
||||
|
|
|
@ -8,9 +8,9 @@ pub unsafe fn get_attack_air_kind(
|
|||
module_accessor: &mut app::BattleObjectModuleAccessor,
|
||||
) -> Option<i32> {
|
||||
if is_training_mode() && is_operation_cpu(module_accessor) {
|
||||
if MENU.mash_state == MASH_ATTACK {
|
||||
if MENU.mash_state == Mash::Attack {
|
||||
MENU.mash_attack_state.into_attack_air_kind()
|
||||
} else if MENU.mash_state == MASH_RANDOM {
|
||||
} else if MENU.mash_state == Mash::Random {
|
||||
Some(app::sv_math::rand(hash40("fighter"), 5) + 1)
|
||||
} else {
|
||||
None
|
||||
|
@ -31,23 +31,23 @@ pub unsafe fn get_command_flag_cat(
|
|||
|| is_in_shieldstun(module_accessor)
|
||||
{
|
||||
match MENU.mash_state {
|
||||
MASH_AIRDODGE => {
|
||||
Mash::Airdodge => {
|
||||
if category == FIGHTER_PAD_COMMAND_CATEGORY1 {
|
||||
*flag |= *FIGHTER_PAD_CMD_CAT1_FLAG_AIR_ESCAPE;
|
||||
}
|
||||
}
|
||||
MASH_JUMP => {
|
||||
Mash::Jump => {
|
||||
if !is_in_landing(module_accessor) && category == FIGHTER_PAD_COMMAND_CATEGORY1
|
||||
{
|
||||
*flag |= *FIGHTER_PAD_CMD_CAT1_FLAG_JUMP_BUTTON;
|
||||
}
|
||||
}
|
||||
MASH_SPOTDODGE => {
|
||||
Mash::Spotdodge => {
|
||||
if category == FIGHTER_PAD_COMMAND_CATEGORY1 {
|
||||
*flag |= *FIGHTER_PAD_CMD_CAT1_FLAG_ESCAPE;
|
||||
}
|
||||
}
|
||||
MASH_ATTACK => {
|
||||
Mash::Attack => {
|
||||
if category == FIGHTER_PAD_COMMAND_CATEGORY1 {
|
||||
use Attack::*;
|
||||
|
||||
|
@ -68,7 +68,7 @@ pub unsafe fn get_command_flag_cat(
|
|||
}
|
||||
}
|
||||
}
|
||||
MASH_RANDOM => {
|
||||
Mash::Random => {
|
||||
if category == FIGHTER_PAD_COMMAND_CATEGORY1 {
|
||||
let situation_kind = StatusModule::situation_kind(module_accessor) as i32;
|
||||
|
||||
|
@ -133,7 +133,7 @@ pub unsafe fn check_button_on(
|
|||
) -> Option<bool> {
|
||||
if [*CONTROL_PAD_BUTTON_GUARD_HOLD, *CONTROL_PAD_BUTTON_GUARD].contains(&button) {
|
||||
if is_training_mode() && is_operation_cpu(module_accessor) {
|
||||
if MENU.mash_state == MASH_AIRDODGE
|
||||
if MENU.mash_state == Mash::Airdodge
|
||||
&& (is_in_hitstun(module_accessor) || is_in_landing(module_accessor))
|
||||
{
|
||||
return Some(true);
|
||||
|
|
|
@ -33,7 +33,7 @@ pub unsafe fn should_hold_shield(module_accessor: &mut app::BattleObjectModuleAc
|
|||
// We should hold shield if the state requires it
|
||||
if [SHIELD_HOLD, SHIELD_INFINITE].contains(&MENU.shield_state) {
|
||||
// If we are not mashing then we will always hold shield
|
||||
if MENU.mash_state == NONE {
|
||||
if MENU.mash_state == Mash::None {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -42,7 +42,7 @@ pub unsafe fn should_hold_shield(module_accessor: &mut app::BattleObjectModuleAc
|
|||
}
|
||||
|
||||
// We will only drop shield if we are in shieldstun and our attack can be performed OOS
|
||||
if MENU.mash_state == MASH_ATTACK {
|
||||
if MENU.mash_state == Mash::Attack {
|
||||
if [Attack::NeutralB, Attack::SideB, Attack::DownB].contains(&MENU.mash_attack_state) {
|
||||
return false;
|
||||
}
|
||||
|
@ -52,7 +52,7 @@ pub unsafe fn should_hold_shield(module_accessor: &mut app::BattleObjectModuleAc
|
|||
}
|
||||
}
|
||||
|
||||
if MENU.mash_state == MASH_SPOTDODGE {
|
||||
if MENU.mash_state == Mash::Spotdodge {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue