1
0
Fork 0
mirror of https://github.com/jugeeya/UltimateTrainingModpack.git synced 2025-01-19 17:00:15 +00:00

fix existing common functions

This commit is contained in:
jugeeya 2020-04-30 17:17:03 -07:00
parent 8ab1d8a0d8
commit 5b94e8907e

View file

@ -3,7 +3,8 @@ pub mod consts;
use smash::lib::lua_const::{*};
use crate::common::consts::*;
use smash::app::{self};
use smash::app::lua_bind::*;
use smash::app::lua_bind::{self, *};
use smash::app::{FighterManager, FighterInformation};
use smash::hash40;
pub static menu : consts::TrainingModpackMenu = consts::TrainingModpackMenu{
@ -17,26 +18,27 @@ pub static menu : consts::TrainingModpackMenu = consts::TrainingModpackMenu{
DEFENSIVE_STATE : RANDOM_DEFENSIVE,
};
static fighter_manager_addr: u64 = 0;
static mut fighter_manager: FighterManager = FighterManager{ _address: 0 };
extern "C" {
#[link_name = "\u{1}_ZN3app9smashball16is_training_modeEv"]
pub fn is_training_mode() -> bool;
}
// pub fn get_category(module_accessor: &mut app::BattleObjectModuleAccessor) -> u8 {
// return (u8)(*(u32*)(module_accessor + 8) >> 28);
// }
pub fn get_category(module_accessor: &mut app::BattleObjectModuleAccessor) -> i32 {
return (module_accessor.info >> 28) as u8 as i32;
}
// pub fn is_operation_cpu(module_accessor: &mut app::BattleObjectModuleAccessor) -> bool{
// if (get_category(module_accessor) != BATTLE_OBJECT_CATEGORY_FIGHTER)
// return false;
pub unsafe fn is_operation_cpu(module_accessor: &mut app::BattleObjectModuleAccessor) -> bool {
if get_category(module_accessor) as i32 != BATTLE_OBJECT_CATEGORY_FIGHTER {
return false
}
// let entry_id = WorkModule::get_int(module_accessor, FIGHTER_INSTANCE_WORK_ID_INT_ENTRY_ID) as i32;
// u64 fighter_information = FighterManager::get_fighter_information(LOAD64(fighter_manager_addr), entry_id);
let entry_id = app::FighterEntryID(WorkModule::get_int(module_accessor, *FIGHTER_INSTANCE_WORK_ID_INT_ENTRY_ID) as i32);
let fighter_information = lua_bind::FighterManager::get_fighter_information(&mut fighter_manager, entry_id) as *mut FighterInformation;
// return FighterInformation::is_operation_cpu(fighter_information);
// }
lua_bind::FighterInformation::is_operation_cpu(fighter_information)
}
pub unsafe fn is_in_hitstun(module_accessor: &mut app::BattleObjectModuleAccessor) -> bool {
let status_kind = StatusModule::status_kind(module_accessor) as i32;
@ -64,27 +66,27 @@ pub unsafe fn is_in_landing(module_accessor: &mut app::BattleObjectModuleAccesso
}
// pub fn perform_defensive_option(module_accessor: &mut app::BattleObjectModuleAccessor, flag: &i32) {
// if menu.DEFENSIVE_STATE == RANDOM_DEFENSIVE {
// let NUM_DEFENSIVE_CMDS = 4;
// let random_cmds = vec![
// FIGHTER_PAD_CMD_CAT1_FLAG_ESCAPE,
// FIGHTER_PAD_CMD_CAT1_FLAG_ESCAPE_F,
// FIGHTER_PAD_CMD_CAT1_FLAG_ESCAPE_B,
// FIGHTER_PAD_CMD_CAT1_FLAG_ATTACK_N
// ];
pub unsafe fn perform_defensive_option(module_accessor: &mut app::BattleObjectModuleAccessor, flag: &mut i32) {
if menu.DEFENSIVE_STATE == RANDOM_DEFENSIVE {
let NUM_DEFENSIVE_CMDS = 4;
let random_cmds = vec![
*FIGHTER_PAD_CMD_CAT1_FLAG_ESCAPE,
*FIGHTER_PAD_CMD_CAT1_FLAG_ESCAPE_F,
*FIGHTER_PAD_CMD_CAT1_FLAG_ESCAPE_B,
*FIGHTER_PAD_CMD_CAT1_FLAG_ATTACK_N
];
// let random_cmd_index = app::sv_math::rand(hash40("fighter"), random_cmds.len() as i32) as usize;
// flag |= random_cmds[random_cmd_index];
// } else if menu.DEFENSIVE_STATE == DEFENSIVE_ROLL {
// if app::sv_math::rand(hash40("fighter"), 2) == 0 {
// flag |= FIGHTER_PAD_CMD_CAT1_FLAG_ESCAPE_F;
// } else {
// flag |= FIGHTER_PAD_CMD_CAT1_FLAG_ESCAPE_B;
// }
// } else if menu.DEFENSIVE_STATE == DEFENSIVE_SPOTDODGE {
// flag |= FIGHTER_PAD_CMD_CAT1_FLAG_ESCAPE;
// } else if menu.DEFENSIVE_STATE == DEFENSIVE_JAB {
// flag |= FIGHTER_PAD_CMD_CAT1_FLAG_ATTACK_N;
// }
// }
let random_cmd_index = app::sv_math::rand(hash40("fighter"), random_cmds.len() as i32) as usize;
*flag |= random_cmds[random_cmd_index];
} else if menu.DEFENSIVE_STATE == DEFENSIVE_ROLL {
if app::sv_math::rand(hash40("fighter"), 2) == 0 {
*flag |= *FIGHTER_PAD_CMD_CAT1_FLAG_ESCAPE_F;
} else {
*flag |= *FIGHTER_PAD_CMD_CAT1_FLAG_ESCAPE_B;
}
} else if menu.DEFENSIVE_STATE == DEFENSIVE_SPOTDODGE {
*flag |= *FIGHTER_PAD_CMD_CAT1_FLAG_ESCAPE;
} else if menu.DEFENSIVE_STATE == DEFENSIVE_JAB {
*flag |= *FIGHTER_PAD_CMD_CAT1_FLAG_ATTACK_N;
}
}