mirror of
https://github.com/jugeeya/UltimateTrainingModpack.git
synced 2024-11-24 10:54:16 +00:00
Move defensive_state from grouped constants to an enum
This commit is contained in:
parent
eb03831d3c
commit
cb3d829e03
4 changed files with 35 additions and 13 deletions
|
@ -127,11 +127,33 @@ pub enum Shield {
|
||||||
// pub const std::vector<std::string> shield_items{"None", "Infinite", "Hold"};
|
// pub const std::vector<std::string> shield_items{"None", "Infinite", "Hold"};
|
||||||
|
|
||||||
// Defensive States
|
// Defensive States
|
||||||
pub const RANDOM_DEFENSIVE: i32 = 1;
|
#[repr(i32)]
|
||||||
pub const DEFENSIVE_SPOTDODGE: i32 = 2;
|
#[derive(Debug, Clone, Copy, PartialEq)]
|
||||||
pub const DEFENSIVE_ROLL: i32 = 3;
|
pub enum Defensive {
|
||||||
pub const DEFENSIVE_JAB: i32 = 4;
|
None = 0,
|
||||||
pub const DEFENSIVE_SHIELD: i32 = 5;
|
Random = 1,
|
||||||
|
Spotdodge = 2,
|
||||||
|
Roll = 3,
|
||||||
|
Jab = 4,
|
||||||
|
Shield = 5,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl From<i32> for Defensive {
|
||||||
|
fn from(x: i32) -> Self {
|
||||||
|
use Defensive::*;
|
||||||
|
|
||||||
|
match x {
|
||||||
|
0 => None,
|
||||||
|
1 => Random,
|
||||||
|
2 => Spotdodge,
|
||||||
|
3 => Roll,
|
||||||
|
4 => Jab,
|
||||||
|
5 => Shield,
|
||||||
|
_ => panic!("Invalid mash state {}", x)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// pub const std::vector<std::string> defensive_items{"None", "Random", "Spotdodge", "Roll", "Jab", "Flash Shield"};
|
// pub const std::vector<std::string> defensive_items{"None", "Random", "Spotdodge", "Roll", "Jab", "Flash Shield"};
|
||||||
|
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
|
@ -143,5 +165,5 @@ pub struct TrainingModpackMenu {
|
||||||
pub tech_state: i32,
|
pub tech_state: i32,
|
||||||
pub mash_state: Mash,
|
pub mash_state: Mash,
|
||||||
pub shield_state: Shield,
|
pub shield_state: Shield,
|
||||||
pub defensive_state: i32,
|
pub defensive_state: Defensive,
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,7 +13,7 @@ pub static mut MENU_STRUCT: consts::TrainingModpackMenu = consts::TrainingModpac
|
||||||
tech_state: RANDOM_TECH,
|
tech_state: RANDOM_TECH,
|
||||||
mash_state: Mash::None,
|
mash_state: Mash::None,
|
||||||
shield_state: Shield::None,
|
shield_state: Shield::None,
|
||||||
defensive_state: RANDOM_DEFENSIVE,
|
defensive_state: Defensive::Random,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub static MENU: &'static mut consts::TrainingModpackMenu = unsafe { &mut MENU_STRUCT };
|
pub static MENU: &'static mut consts::TrainingModpackMenu = unsafe { &mut MENU_STRUCT };
|
||||||
|
@ -77,7 +77,7 @@ pub unsafe fn perform_defensive_option(
|
||||||
flag: &mut i32,
|
flag: &mut i32,
|
||||||
) {
|
) {
|
||||||
match MENU.defensive_state {
|
match MENU.defensive_state {
|
||||||
RANDOM_DEFENSIVE => {
|
Defensive::Random => {
|
||||||
let random_cmds = vec![
|
let random_cmds = vec![
|
||||||
*FIGHTER_PAD_CMD_CAT1_FLAG_ESCAPE,
|
*FIGHTER_PAD_CMD_CAT1_FLAG_ESCAPE,
|
||||||
*FIGHTER_PAD_CMD_CAT1_FLAG_ESCAPE_F,
|
*FIGHTER_PAD_CMD_CAT1_FLAG_ESCAPE_F,
|
||||||
|
@ -89,15 +89,15 @@ pub unsafe fn perform_defensive_option(
|
||||||
app::sv_math::rand(hash40("fighter"), random_cmds.len() as i32) as usize;
|
app::sv_math::rand(hash40("fighter"), random_cmds.len() as i32) as usize;
|
||||||
*flag |= random_cmds[random_cmd_index];
|
*flag |= random_cmds[random_cmd_index];
|
||||||
}
|
}
|
||||||
DEFENSIVE_ROLL => {
|
Defensive::Roll => {
|
||||||
if app::sv_math::rand(hash40("fighter"), 2) == 0 {
|
if app::sv_math::rand(hash40("fighter"), 2) == 0 {
|
||||||
*flag |= *FIGHTER_PAD_CMD_CAT1_FLAG_ESCAPE_F;
|
*flag |= *FIGHTER_PAD_CMD_CAT1_FLAG_ESCAPE_F;
|
||||||
} else {
|
} else {
|
||||||
*flag |= *FIGHTER_PAD_CMD_CAT1_FLAG_ESCAPE_B;
|
*flag |= *FIGHTER_PAD_CMD_CAT1_FLAG_ESCAPE_B;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
DEFENSIVE_SPOTDODGE => *flag |= *FIGHTER_PAD_CMD_CAT1_FLAG_ESCAPE,
|
Defensive::Spotdodge => *flag |= *FIGHTER_PAD_CMD_CAT1_FLAG_ESCAPE,
|
||||||
DEFENSIVE_JAB => *flag |= *FIGHTER_PAD_CMD_CAT1_FLAG_ATTACK_N,
|
Defensive::Jab => *flag |= *FIGHTER_PAD_CMD_CAT1_FLAG_ATTACK_N,
|
||||||
_ => (),
|
_ => (),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -88,7 +88,7 @@ pub unsafe fn check_button_on(
|
||||||
if is_training_mode() && is_operation_cpu(module_accessor) {
|
if is_training_mode() && is_operation_cpu(module_accessor) {
|
||||||
let prev_status = StatusModule::prev_status_kind(module_accessor, 0) as i32;
|
let prev_status = StatusModule::prev_status_kind(module_accessor, 0) as i32;
|
||||||
let status = StatusModule::status_kind(module_accessor) as i32;
|
let status = StatusModule::status_kind(module_accessor) as i32;
|
||||||
if MENU.defensive_state == DEFENSIVE_SHIELD
|
if MENU.defensive_state == Defensive::Shield
|
||||||
&& should_perform_defensive_option(module_accessor, prev_status, status)
|
&& should_perform_defensive_option(module_accessor, prev_status, status)
|
||||||
{
|
{
|
||||||
return Some(true);
|
return Some(true);
|
||||||
|
|
|
@ -125,7 +125,7 @@ pub unsafe fn check_button_on(
|
||||||
if is_training_mode() && is_operation_cpu(module_accessor) {
|
if is_training_mode() && is_operation_cpu(module_accessor) {
|
||||||
let prev_status = StatusModule::prev_status_kind(module_accessor, 0) as i32;
|
let prev_status = StatusModule::prev_status_kind(module_accessor, 0) as i32;
|
||||||
let status = StatusModule::status_kind(module_accessor) as i32;
|
let status = StatusModule::status_kind(module_accessor) as i32;
|
||||||
if MENU.defensive_state == DEFENSIVE_SHIELD
|
if MENU.defensive_state == Defensive::Shield
|
||||||
&& should_perform_defensive_option(module_accessor, prev_status, status)
|
&& should_perform_defensive_option(module_accessor, prev_status, status)
|
||||||
{
|
{
|
||||||
return Some(true);
|
return Some(true);
|
||||||
|
|
Loading…
Reference in a new issue