1
0
Fork 0
mirror of https://github.com/jugeeya/UltimateTrainingModpack.git synced 2025-03-14 02:16:10 +00:00

Move shield_state from a group of consts to an enum

This commit is contained in:
jam1garner 2020-05-16 01:45:35 -04:00
parent f86415830d
commit 95180e6364
4 changed files with 14 additions and 8 deletions

View file

@ -115,9 +115,15 @@ impl From<i32> for Mash {
// pub const std::vector<std::string> mash_items{"None", "Airdodge", "Jump", "Attack", "Spotdodge", "Random"};
// Shield States
pub const SHIELD_INFINITE: i32 = 1;
pub const SHIELD_HOLD: i32 = 2;
/// Shield States
#[repr(i32)]
#[derive(Debug, Clone, Copy, PartialEq)]
pub enum Shield {
None = 0,
Infinite = 1,
Hold = 2,
}
// pub const std::vector<std::string> shield_items{"None", "Infinite", "Hold"};
// Defensive States
@ -136,6 +142,6 @@ pub struct TrainingModpackMenu {
pub ledge_state: i32,
pub tech_state: i32,
pub mash_state: Mash,
pub shield_state: i32,
pub shield_state: Shield,
pub defensive_state: i32,
}

View file

@ -12,7 +12,7 @@ pub static mut MENU_STRUCT: consts::TrainingModpackMenu = consts::TrainingModpac
ledge_state: RANDOM_LEDGE,
tech_state: RANDOM_TECH,
mash_state: Mash::None,
shield_state: NONE,
shield_state: Shield::None,
defensive_state: RANDOM_DEFENSIVE,
};

View file

@ -232,7 +232,7 @@ unsafe fn handle_attack(lua_state: u64) {
let z2 = l2c_agent.pop_lua_stack(15); // float or void
// hacky way of forcing no shield damage on all hitboxes
if is_training_mode() && MENU.shield_state == SHIELD_INFINITE {
if is_training_mode() && MENU.shield_state == Shield::Infinite {
let hitbox_params: Vec<L2CValue> =
(0..36).map(|i| l2c_agent.pop_lua_stack(i + 1)).collect();
l2c_agent.clear_lua_stack();

View file

@ -10,7 +10,7 @@ pub unsafe fn get_param_float(
param_hash: u64,
) -> Option<f32> {
if is_training_mode() {
if MENU.shield_state == SHIELD_INFINITE {
if MENU.shield_state == Shield::Infinite {
if param_type == hash40("common") {
if param_hash == hash40("shield_dec1") {
return Some(0.0);
@ -31,7 +31,7 @@ pub unsafe fn get_param_float(
pub unsafe fn should_hold_shield(module_accessor: &mut app::BattleObjectModuleAccessor) -> bool {
// We should hold shield if the state requires it
if [SHIELD_HOLD, SHIELD_INFINITE].contains(&MENU.shield_state) {
if [Shield::Hold, Shield::Infinite].contains(&MENU.shield_state) {
// If we are not mashing then we will always hold shield
if MENU.mash_state == Mash::None {
return true;