1
0
Fork 0
mirror of https://github.com/jugeeya/UltimateTrainingModpack.git synced 2024-10-03 09:44:26 +00:00

Move ledge_state from grouped consts to an enum

This commit is contained in:
jam1garner 2020-05-16 02:08:07 -04:00
parent cb3d829e03
commit 4d28004367
3 changed files with 37 additions and 15 deletions

View file

@ -72,11 +72,33 @@ 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
pub const RANDOM_LEDGE: i32 = 1;
pub const NEUTRAL_LEDGE: i32 = 2;
pub const ROLL_LEDGE: i32 = 3;
pub const JUMP_LEDGE: i32 = 4;
pub const ATTACK_LEDGE: i32 = 5;
#[repr(i32)]
#[derive(Debug, Copy, Clone, PartialEq)]
pub enum LedgeOption {
None = 0,
Random = 1,
Neutral = 2,
Roll = 3,
Jump = 4,
Attack = 5,
}
impl From<i32> for LedgeOption {
fn from(x: i32) -> Self {
use LedgeOption::*;
match x {
0 => None,
1 => Random,
2 => Neutral,
3 => Roll,
4 => Jump,
5 => Attack,
_ => panic!("Invalid ledge option {}", x)
}
}
}
// pub const std::vector<std::string> ledge_items{"None", "Random", "Ntrl. Getup", "Roll", "Jump", "Attack"};
// Tech Option
@ -161,7 +183,7 @@ pub struct TrainingModpackMenu {
pub hitbox_vis: bool,
pub di_state: i32,
pub mash_attack_state: Attack,
pub ledge_state: i32,
pub ledge_state: LedgeOption,
pub tech_state: i32,
pub mash_state: Mash,
pub shield_state: Shield,

View file

@ -9,7 +9,7 @@ pub static mut MENU_STRUCT: consts::TrainingModpackMenu = consts::TrainingModpac
hitbox_vis: true,
di_state: NONE,
mash_attack_state: Attack::Nair,
ledge_state: RANDOM_LEDGE,
ledge_state: LedgeOption::Random,
tech_state: RANDOM_TECH,
mash_state: Mash::None,
shield_state: Shield::None,

View file

@ -18,19 +18,19 @@ pub unsafe fn force_option(module_accessor: &mut app::BattleObjectModuleAccessor
let frame = MotionModule::frame(module_accessor) as f32;
if frame == random_frame || frame > 30.0 {
let mut status = 0;
let ledge_case: i32;
let ledge_case: LedgeOption;
if MENU.ledge_state == RANDOM_LEDGE {
ledge_case = app::sv_math::rand(hash40("fighter"), 4) + 2;
if MENU.ledge_state == LedgeOption::Random {
ledge_case = (app::sv_math::rand(hash40("fighter"), 4) + 2).into();
} else {
ledge_case = MENU.ledge_state;
}
match ledge_case {
NEUTRAL_LEDGE => status = *FIGHTER_STATUS_KIND_CLIFF_CLIMB,
ROLL_LEDGE => status = *FIGHTER_STATUS_KIND_CLIFF_ESCAPE,
JUMP_LEDGE => status = *FIGHTER_STATUS_KIND_CLIFF_JUMP1,
ATTACK_LEDGE => status = *FIGHTER_STATUS_KIND_CLIFF_ATTACK,
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,
_ => (),
}
@ -104,7 +104,7 @@ pub unsafe fn get_command_flag_cat(
category: i32,
flag: &mut i32,
) {
if MENU.ledge_state != NONE && is_training_mode() && is_operation_cpu(module_accessor) {
if MENU.ledge_state != LedgeOption::None && is_training_mode() && is_operation_cpu(module_accessor) {
force_option(module_accessor);
defensive_option(module_accessor, category, flag);
}