1
0
Fork 0
mirror of https://github.com/jugeeya/UltimateTrainingModpack.git synced 2025-01-31 22:47:25 +00:00

Move tech_state from grouped consts to an enum

This commit is contained in:
jam1garner 2020-05-16 02:18:58 -04:00
parent 4d28004367
commit 78e53c29bd
4 changed files with 46 additions and 29 deletions

View file

@ -12,7 +12,6 @@ pub const NONE: i32 = 0;
/* DI */
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)]
@ -69,8 +68,6 @@ impl Attack {
}
}
// pub const std::vector<std::string> attack_items{"Neutral Air", "Forward Air", "Back Air", "Up Air", "Down Air", "Neutral B", "Side B", "Up B", "Down B", "Up Smash", "Grab"};
// Ledge Option
#[repr(i32)]
#[derive(Debug, Copy, Clone, PartialEq)]
@ -99,15 +96,45 @@ impl From<i32> for LedgeOption {
}
}
// pub const std::vector<std::string> ledge_items{"None", "Random", "Ntrl. Getup", "Roll", "Jump", "Attack"};
impl LedgeOption {
pub fn into_status(&self) -> Option<i32> {
Some(
match self {
LedgeOption::Neutral => status = *FIGHTER_STATUS_KIND_CLIFF_CLIMB,
LedgeOption::Roll => status = *FIGHTER_STATUS_KIND_CLIFF_ESCAPE,
LedgeOption::Jump => status = *FIGHTER_STATUS_KIND_CLIFF_JUMP1,
LedgeOption::Attack => status = *FIGHTER_STATUS_KIND_CLIFF_ATTACK,
_ => return None,
}
)
}
}
// Tech Option
pub const RANDOM_TECH: i32 = 1;
pub const TECH_IN_PLACE: i32 = 2;
pub const TECH_ROLL: i32 = 3;
#[allow(dead_code)]
pub const TECH_MISS: i32 = 4;
// pub const std::vector<std::string> tech_items{"None", "Random", "In-Place", "Roll", "Miss Tech"};
#[repr(i32)]
#[derive(Debug, Clone, Copy, PartialEq)]
pub enum TechOption {
None = 0,
Random = 1,
InPlace = 2,
Roll = 3,
Miss = 4
}
impl From<i32> for TechOption {
fn from(x: i32) -> Self {
use TechOption::*;
match x {
0 => None,
1 => Random,
2 => InPlace,
3 => Roll,
4 => Miss,
_ => panic!("Invalid tech option {}", x)
}
}
}
/// Mash States
#[repr(i32)]
@ -135,8 +162,6 @@ impl From<i32> for Mash {
}
}
// pub const std::vector<std::string> mash_items{"None", "Airdodge", "Jump", "Attack", "Spotdodge", "Random"};
/// Shield States
#[repr(i32)]
#[derive(Debug, Clone, Copy, PartialEq)]
@ -146,8 +171,6 @@ pub enum Shield {
Hold = 2,
}
// pub const std::vector<std::string> shield_items{"None", "Infinite", "Hold"};
// Defensive States
#[repr(i32)]
#[derive(Debug, Clone, Copy, PartialEq)]
@ -176,15 +199,13 @@ impl From<i32> for Defensive {
}
}
// pub const std::vector<std::string> defensive_items{"None", "Random", "Spotdodge", "Roll", "Jab", "Flash Shield"};
#[repr(C)]
pub struct TrainingModpackMenu {
pub hitbox_vis: bool,
pub di_state: i32,
pub mash_attack_state: Attack,
pub ledge_state: LedgeOption,
pub tech_state: i32,
pub tech_state: TechOption,
pub mash_state: Mash,
pub shield_state: Shield,
pub defensive_state: Defensive,

View file

@ -10,7 +10,7 @@ pub static mut MENU_STRUCT: consts::TrainingModpackMenu = consts::TrainingModpac
di_state: NONE,
mash_attack_state: Attack::Nair,
ledge_state: LedgeOption::Random,
tech_state: RANDOM_TECH,
tech_state: TechOption::Random,
mash_state: Mash::None,
shield_state: Shield::None,
defensive_state: Defensive::Random,

View file

@ -26,12 +26,8 @@ pub unsafe fn force_option(module_accessor: &mut app::BattleObjectModuleAccessor
ledge_case = MENU.ledge_state;
}
match ledge_case {
LedgeOption::Neutral => status = *FIGHTER_STATUS_KIND_CLIFF_CLIMB,
LedgeOption::Roll => status = *FIGHTER_STATUS_KIND_CLIFF_ESCAPE,
LedgeOption::Jump => status = *FIGHTER_STATUS_KIND_CLIFF_JUMP1,
LedgeOption::Attack => status = *FIGHTER_STATUS_KIND_CLIFF_ATTACK,
_ => (),
if let Some(new_status) = ledge_case.into_status() {
status = new_status;
}
StatusModule::change_status_request_from_script(module_accessor, status, true);

View file

@ -11,7 +11,7 @@ pub unsafe fn init_settings(
if is_training_mode() && is_operation_cpu(module_accessor) {
if status_kind == FIGHTER_STATUS_KIND_DOWN {
match MENU.tech_state {
RANDOM_TECH => {
TechOption::Random => {
let random_statuses = vec![
*FIGHTER_STATUS_KIND_DOWN,
*FIGHTER_STATUS_KIND_PASSIVE,
@ -30,7 +30,7 @@ pub unsafe fn init_settings(
return Some(());
}
}
TECH_IN_PLACE => {
TechOption::InPlace => {
StatusModule::change_status_request_from_script(
module_accessor,
*FIGHTER_STATUS_KIND_PASSIVE,
@ -38,7 +38,7 @@ pub unsafe fn init_settings(
);
return Some(());
}
TECH_ROLL => {
TechOption::Roll => {
StatusModule::change_status_request_from_script(
module_accessor,
*FIGHTER_STATUS_KIND_PASSIVE_FB,
@ -89,7 +89,7 @@ pub unsafe fn get_command_flag_cat(
_category: i32,
flag: &mut i32,
) {
if MENU.tech_state != NONE && is_training_mode() && is_operation_cpu(module_accessor) {
if MENU.tech_state != TechOption::None && is_training_mode() && is_operation_cpu(module_accessor) {
let prev_status = StatusModule::prev_status_kind(module_accessor, 0) as i32;
let status = StatusModule::status_kind(module_accessor) as i32;
if [
@ -140,7 +140,7 @@ pub unsafe fn change_motion(
module_accessor: &mut app::BattleObjectModuleAccessor,
motion_kind: u64,
) -> Option<u64> {
if MENU.tech_state != NONE && is_training_mode() && is_operation_cpu(module_accessor) {
if MENU.tech_state != TechOption::None && is_training_mode() && is_operation_cpu(module_accessor) {
if [hash40("passive_stand_f"), hash40("passive_stand_b")].contains(&motion_kind) {
if app::sv_math::rand(hash40("fighter"), 2) != 0 {
return Some(hash40("passive_stand_f"));