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

Fix all style/dead_code lints

This commit is contained in:
jam1garner 2020-05-15 23:40:27 -04:00
parent a79bedfa7f
commit 798e18a71a
11 changed files with 114 additions and 199 deletions

View file

@ -9,7 +9,6 @@ pub const NONE: i32 = 0;
*/
/* DI */
pub static mut DI_STATE: i32 = NONE;
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"};
@ -39,6 +38,7 @@ pub const ATTACK_LEDGE: i32 = 5;
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"};
@ -65,12 +65,12 @@ pub const DEFENSIVE_SHIELD: i32 = 5;
#[repr(C)]
pub struct TrainingModpackMenu {
pub HITBOX_VIS: bool,
pub DI_STATE: i32,
pub ATTACK_STATE: i32,
pub LEDGE_STATE: i32,
pub TECH_STATE: i32,
pub MASH_STATE: i32,
pub SHIELD_STATE: i32,
pub DEFENSIVE_STATE: i32,
pub hitbox_vis: bool,
pub di_state: i32,
pub attack_state: i32,
pub ledge_state: i32,
pub tech_state: i32,
pub mash_state: i32,
pub shield_state: i32,
pub defensive_state: i32,
}

View file

@ -5,26 +5,27 @@ use smash::app::{self, lua_bind::*};
use smash::lib::lua_const::*;
use smash::hash40;
pub static mut menu_struct: consts::TrainingModpackMenu = consts::TrainingModpackMenu {
HITBOX_VIS: true,
DI_STATE: NONE,
ATTACK_STATE: MASH_NAIR,
LEDGE_STATE: RANDOM_LEDGE,
TECH_STATE: RANDOM_TECH,
MASH_STATE: NONE,
SHIELD_STATE: NONE,
DEFENSIVE_STATE: RANDOM_DEFENSIVE,
pub static mut MENU_STRUCT: consts::TrainingModpackMenu = consts::TrainingModpackMenu {
hitbox_vis: true,
di_state: NONE,
attack_state: MASH_NAIR,
ledge_state: RANDOM_LEDGE,
tech_state: RANDOM_TECH,
mash_state: NONE,
shield_state: NONE,
defensive_state: RANDOM_DEFENSIVE,
};
pub static menu: &'static mut consts::TrainingModpackMenu = unsafe { &mut menu_struct};
pub static MENU: &'static mut consts::TrainingModpackMenu = unsafe { &mut MENU_STRUCT };
pub static mut fighter_manager_addr: usize = 0;
pub static mut FIGHTER_MANAGER_ADDR: usize = 0;
extern "C" {
#[link_name = "\u{1}_ZN3app9smashball16is_training_modeEv"]
pub fn is_training_mode() -> bool;
#[link_name = "\u{1}_ZN3app7utility8get_kindEPKNS_26BattleObjectModuleAccessorE"]
pub fn get_kind(module_accessor: &mut app::BattleObjectModuleAccessor) -> i32;
//#[link_name = "\u{1}_ZN3app7utility8get_kindEPKNS_26BattleObjectModuleAccessorE"]
//pub fn get_kind(module_accessor: &mut app::BattleObjectModuleAccessor) -> i32;
}
pub fn get_category(module_accessor: &mut app::BattleObjectModuleAccessor) -> i32 {
@ -75,7 +76,7 @@ pub unsafe fn perform_defensive_option(
_module_accessor: &mut app::BattleObjectModuleAccessor,
flag: &mut i32,
) {
match (*menu).DEFENSIVE_STATE {
match MENU.defensive_state {
RANDOM_DEFENSIVE => {
let random_cmds = vec![
*FIGHTER_PAD_CMD_CAT1_FLAG_ESCAPE,

View file

@ -4,80 +4,6 @@ use smash::hash40;
use smash::lib::{lua_const::*, L2CAgent, L2CValue};
use smash::phx::{Hash40, Vector3f};
/**
* Rounds a number to the nearest multiple of another number.
*/
pub fn round_to(val: f32, align: f32) -> f32 {
(val / align).round() * align
}
/**
* Linearly interpolates between two numbers, without bounds checking.
*/
pub fn lerp(min: f32, max: f32, t: f32) -> f32 {
min + (max - min) * t
}
pub fn unlerp(min: f32, max: f32, val: f32) -> f32 {
(val - min) / (max - min)
}
/**
* Linearly interpolates between two numbers, with bounds checking.
*/
pub fn lerp_bounded(min: f32, max: f32, t: f32) -> f32 {
if t <= 0.0 {
min
} else {
if t >= 1.0 {
max
} else {
lerp(min, max, t)
}
}
}
pub fn unlerp_bounded(min: f32, max: f32, val: f32) -> f32 {
if val <= min {
0.0
} else {
if val >= max {
1.0
} else {
unlerp(min, max, val)
}
}
}
/**
* Linearly interpolates between two colors, with bounds checking, accounting for
* gamma. arguments:
* - min_color (Vector3f) -- xyz maps to rgb, components are usually in the
* range [0.0f, 1.0f] but can go beyond to account for super-bright or
* super-dark colors
* - max_Color (Vector3f) -- same as minColor
* - t (float) -- how far to interpolate between the colors
* - gamma (float = 2.0f) -- used for color correction, helps avoid ugly dark
* colors when interpolating b/t bright colors
*/
pub fn color_lerp(min_color: Vector3f, max_color: Vector3f, t: f32, gamma: f32) -> Vector3f {
let gamma_inv = 1.0 / gamma;
let align = 1.0 / 255.0; // color components must be a multiple of 1/255
Vector3f {
x: round_to(
lerp_bounded(min_color.x.powf(gamma), max_color.x.powf(gamma), t).powf(gamma_inv),
align,
),
y: round_to(
lerp_bounded(min_color.y.powf(gamma), max_color.y.powf(gamma), t).powf(gamma_inv),
align,
),
z: round_to(
lerp_bounded(min_color.z.powf(gamma), max_color.z.powf(gamma), t).powf(gamma_inv),
align,
),
}
}
pub const ID_COLORS: &[Vector3f] = &[
// used to tint the hitbox effects -- make sure that at least one component
// is equal to 1.0
@ -228,11 +154,11 @@ pub unsafe fn get_command_flag_cat(
// Pause Effect AnimCMD if hitbox visualization is active
MotionAnimcmdModule::set_sleep_effect(
module_accessor,
menu.HITBOX_VIS,
MENU.hitbox_vis,
);
// apply only once per frame
if category == 0 && is_training_mode() && menu.HITBOX_VIS {
if category == 0 && is_training_mode() && MENU.hitbox_vis {
let status_kind = StatusModule::status_kind(module_accessor) as i32;
if !(*FIGHTER_STATUS_KIND_CATCH..=*FIGHTER_STATUS_KIND_CATCH_TURN).contains(&status_kind)
@ -285,7 +211,6 @@ pub unsafe fn get_command_flag_cat(
}
// Necessary to ensure we visualize on the first frame of the hitbox
#[allow(unused_unsafe)]
#[skyline::hook(replace = sv_animcmd::ATTACK)]
unsafe fn handle_attack(lua_state: u64) {
let mut l2c_agent = L2CAgent::new(lua_state);
@ -307,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();
@ -323,7 +248,7 @@ unsafe fn handle_attack(lua_state: u64) {
original!()(lua_state);
if menu.HITBOX_VIS && is_training_mode() {
if MENU.hitbox_vis && is_training_mode() {
generate_hitbox_effects(
sv_system::battle_object_module_accessor(lua_state),
joint.get_int(),
@ -339,7 +264,6 @@ unsafe fn handle_attack(lua_state: u64) {
}
}
#[allow(unused_unsafe)]
#[skyline::hook(replace = sv_animcmd::CATCH)]
unsafe fn handle_catch(lua_state: u64) {
let mut l2c_agent = L2CAgent::new(lua_state);
@ -357,7 +281,7 @@ unsafe fn handle_catch(lua_state: u64) {
original!()(lua_state);
if menu.HITBOX_VIS && is_training_mode() {
if MENU.hitbox_vis && is_training_mode() {
generate_hitbox_effects(
sv_system::battle_object_module_accessor(lua_state),
joint.get_int(),
@ -378,7 +302,6 @@ pub unsafe fn is_shielding(module_accessor: *mut app::BattleObjectModuleAccessor
(*FIGHTER_STATUS_KIND_GUARD_ON..=*FIGHTER_STATUS_KIND_GUARD_DAMAGE).contains(&status_kind)
}
#[allow(unused_unsafe)]
#[skyline::hook(replace = GrabModule::set_rebound)]
pub unsafe fn handle_set_rebound(
module_accessor: *mut app::BattleObjectModuleAccessor,

View file

@ -22,7 +22,7 @@ use smash::lua2cpp::L2CFighterCommon;
pub unsafe fn handle_sub_guard_cont(fighter: &mut L2CFighterCommon) -> L2CValue {
let module_accessor = sv_system::battle_object_module_accessor(fighter.lua_state_agent);
if is_training_mode() && is_operation_cpu(module_accessor) {
if menu.MASH_STATE == MASH_ATTACK && menu.ATTACK_STATE == MASH_GRAB {
if MENU.mash_state == MASH_ATTACK && MENU.attack_state == MASH_GRAB {
if StatusModule::prev_status_kind(module_accessor, 0) == FIGHTER_STATUS_KIND_GUARD_DAMAGE {
if WorkModule::get_int(
module_accessor,
@ -41,7 +41,7 @@ pub unsafe fn handle_sub_guard_cont(fighter: &mut L2CFighterCommon) -> L2CValue
}
}
}
if menu.MASH_STATE == MASH_SPOTDODGE {
if MENU.mash_state == MASH_SPOTDODGE {
if StatusModule::prev_status_kind(module_accessor, 0) == FIGHTER_STATUS_KIND_GUARD_DAMAGE {
if WorkModule::is_enable_transition_term(
module_accessor,
@ -54,7 +54,7 @@ pub unsafe fn handle_sub_guard_cont(fighter: &mut L2CFighterCommon) -> L2CValue
}
}
}
if menu.MASH_STATE == MASH_UP_B {
if MENU.mash_state == MASH_UP_B {
if StatusModule::prev_status_kind(module_accessor, 0) == FIGHTER_STATUS_KIND_GUARD_DAMAGE {
// if WorkModule::is_enable_transition_term(
// module_accessor,
@ -67,7 +67,7 @@ pub unsafe fn handle_sub_guard_cont(fighter: &mut L2CFighterCommon) -> L2CValue
// }
}
}
if menu.MASH_STATE == MASH_UP_SMASH {
if MENU.mash_state == MASH_UP_SMASH {
if StatusModule::prev_status_kind(module_accessor, 0) == FIGHTER_STATUS_KIND_GUARD_DAMAGE {
// if WorkModule::is_enable_transition_term(
// module_accessor,
@ -84,7 +84,7 @@ pub unsafe fn handle_sub_guard_cont(fighter: &mut L2CFighterCommon) -> L2CValue
original!()(fighter)
}
fn nro_main(nro: &NroInfo) {
fn nro_main(nro: &NroInfo<'_>) {
match nro.name {
"common" => {
println!("Loaded common NRO!");
@ -102,7 +102,7 @@ pub fn main() {
nro::add_hook(nro_main).unwrap();
unsafe {
let buffer = format!("{:x}", common::menu as *const _ as u64);
let buffer = format!("{:x}", MENU as *const _ as u64);
println!("Writing training_modpack.log with {}...\n", buffer);
mkdir("sd:/TrainingModpack/\u{0}".as_bytes().as_ptr(), 0777);
let f = fopen(

View file

@ -14,11 +14,11 @@ pub unsafe fn get_float(
{
if is_training_mode() && is_operation_cpu(module_accessor) && is_in_hitstun(module_accessor)
{
if menu.DI_STATE != NONE {
let mut angle = (menu.DI_STATE - 1) as f64 * PI / 4.0;
if MENU.di_state != NONE {
let mut angle = (MENU.di_state - 1) as f64 * PI / 4.0;
// Either 0 (right) or PI (left)
if menu.DI_STATE == DI_RANDOM_IN_AWAY {
if MENU.di_state == DI_RANDOM_IN_AWAY {
angle = app::sv_math::rand(hash40("fighter"), 2) as f64 * PI;
}
// If facing left, reverse angle

View file

@ -20,10 +20,10 @@ pub unsafe fn force_option(module_accessor: &mut app::BattleObjectModuleAccessor
let mut status = 0;
let ledge_case: i32;
if menu.LEDGE_STATE == RANDOM_LEDGE {
if MENU.ledge_state == RANDOM_LEDGE {
ledge_case = app::sv_math::rand(hash40("fighter"), 4) + 2;
} else {
ledge_case = menu.LEDGE_STATE;
ledge_case = MENU.ledge_state;
}
match ledge_case {
@ -88,7 +88,7 @@ pub unsafe fn check_button_on(
if 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 menu.DEFENSIVE_STATE == DEFENSIVE_SHIELD
if MENU.defensive_state == DEFENSIVE_SHIELD
&& should_perform_defensive_option(module_accessor, prev_status, status)
{
return Some(true);
@ -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 != NONE && is_training_mode() && is_operation_cpu(module_accessor) {
force_option(module_accessor);
defensive_option(module_accessor, category, flag);
}

View file

@ -8,8 +8,8 @@ pub unsafe fn get_attack_air_kind(
module_accessor: &mut app::BattleObjectModuleAccessor,
) -> Option<i32> {
if is_training_mode() && is_operation_cpu(module_accessor) {
if menu.MASH_STATE == MASH_ATTACK {
match menu.ATTACK_STATE {
if MENU.mash_state == MASH_ATTACK {
match MENU.attack_state {
MASH_NAIR => return Some(*FIGHTER_COMMAND_ATTACK_AIR_KIND_N),
MASH_FAIR => return Some(*FIGHTER_COMMAND_ATTACK_AIR_KIND_F),
MASH_BAIR => return Some(*FIGHTER_COMMAND_ATTACK_AIR_KIND_B),
@ -19,7 +19,7 @@ pub unsafe fn get_attack_air_kind(
}
}
if menu.MASH_STATE == MASH_RANDOM {
if MENU.mash_state == MASH_RANDOM {
return Some(app::sv_math::rand(hash40("fighter"), 5) + 1);
}
}
@ -37,7 +37,7 @@ pub unsafe fn get_command_flag_cat(
|| is_in_landing(module_accessor)
|| is_in_shieldstun(module_accessor)
{
match menu.MASH_STATE {
match MENU.mash_state {
MASH_AIRDODGE => {
if category == FIGHTER_PAD_COMMAND_CATEGORY1 {
*flag |= *FIGHTER_PAD_CMD_CAT1_FLAG_AIR_ESCAPE;
@ -56,7 +56,7 @@ pub unsafe fn get_command_flag_cat(
}
MASH_ATTACK => {
if category == FIGHTER_PAD_COMMAND_CATEGORY1 {
match menu.ATTACK_STATE {
match MENU.attack_state {
MASH_NAIR | MASH_FAIR | MASH_BAIR | MASH_UPAIR | MASH_DAIR => {
*flag |= *FIGHTER_PAD_CMD_CAT1_FLAG_ATTACK_N;
// If we are performing the attack OOS we also need to jump
@ -139,7 +139,7 @@ pub unsafe fn check_button_on(
) -> Option<bool> {
if [*CONTROL_PAD_BUTTON_GUARD_HOLD, *CONTROL_PAD_BUTTON_GUARD].contains(&button) {
if is_training_mode() && is_operation_cpu(module_accessor) {
if menu.MASH_STATE == MASH_AIRDODGE
if MENU.mash_state == MASH_AIRDODGE
&& (is_in_hitstun(module_accessor) || is_in_landing(module_accessor))
{
return Some(true);

View file

@ -1,37 +1,34 @@
use crate::common::fighter_manager_addr;
use crate::common::FIGHTER_MANAGER_ADDR;
use crate::hitbox_visualizer;
use skyline::{c_str, nn::ro::LookupSymbol};
use smash::app::{self, lua_bind::*};
mod DirectionalInfluence;
mod Ledge;
mod Mash;
mod SaveStates;
mod Shield;
mod Tech;
mod directional_influence;
mod ledge;
mod mash;
mod save_states;
mod shield;
mod tech;
#[allow(unused_unsafe)]
#[skyline::hook(replace = WorkModule::get_float)]
pub unsafe fn handle_get_float(
module_accessor: &mut app::BattleObjectModuleAccessor,
var: i32,
) -> f32 {
DirectionalInfluence::get_float(module_accessor, var)
directional_influence::get_float(module_accessor, var)
.unwrap_or_else(|| original!()(module_accessor, var))
}
#[allow(unused_unsafe)]
#[skyline::hook(replace = WorkModule::get_param_float)]
pub unsafe fn handle_get_param_float(
module_accessor: &mut app::BattleObjectModuleAccessor,
param_type: u64,
param_hash: u64,
) -> f32 {
Shield::get_param_float(module_accessor, param_type, param_hash)
shield::get_param_float(module_accessor, param_type, param_hash)
.unwrap_or_else(|| original!()(module_accessor, param_type, param_hash))
}
#[allow(unused_unsafe)]
#[skyline::hook(replace = ControlModule::get_attack_air_kind)]
pub unsafe fn handle_get_attack_air_kind(
module_accessor: &mut app::BattleObjectModuleAccessor,
@ -40,16 +37,15 @@ pub unsafe fn handle_get_attack_air_kind(
// int kind = InputRecorder::get_attack_air_kind(module_accessor, replace);
// if (replace) return kind;
Mash::get_attack_air_kind(module_accessor).unwrap_or_else(|| original!()(module_accessor))
mash::get_attack_air_kind(module_accessor).unwrap_or_else(|| original!()(module_accessor))
}
#[allow(unused_unsafe)]
#[skyline::hook(replace = ControlModule::get_command_flag_cat)]
pub unsafe fn handle_get_command_flag_cat(
module_accessor: &mut app::BattleObjectModuleAccessor,
category: i32,
) -> i32 {
SaveStates::save_states(module_accessor);
save_states::save_states(module_accessor);
let mut flag = original!()(module_accessor, category);
@ -57,9 +53,9 @@ pub unsafe fn handle_get_command_flag_cat(
// int ret = InputRecorder::get_command_flag_cat(module_accessor, category, flag, replace);
// if (replace) return ret;
Mash::get_command_flag_cat(module_accessor, category, &mut flag);
Ledge::get_command_flag_cat(module_accessor, category, &mut flag);
Tech::get_command_flag_cat(module_accessor, category, &mut flag);
mash::get_command_flag_cat(module_accessor, category, &mut flag);
ledge::get_command_flag_cat(module_accessor, category, &mut flag);
tech::get_command_flag_cat(module_accessor, category, &mut flag);
hitbox_visualizer::get_command_flag_cat(module_accessor, category);
flag
@ -101,40 +97,37 @@ pub unsafe fn handle_get_command_flag_cat(
// return stick_y;
// }
#[allow(unused_unsafe)]
#[skyline::hook(replace = ControlModule::check_button_on)]
pub unsafe fn handle_check_button_on(
module_accessor: &mut app::BattleObjectModuleAccessor,
button: i32,
) -> bool {
Shield::check_button_on(module_accessor, button).unwrap_or_else(|| {
Mash::check_button_on(module_accessor, button).unwrap_or_else(|| {
Tech::check_button_on(module_accessor, button).unwrap_or_else(|| {
Ledge::check_button_on(module_accessor, button)
shield::check_button_on(module_accessor, button).unwrap_or_else(|| {
mash::check_button_on(module_accessor, button).unwrap_or_else(|| {
tech::check_button_on(module_accessor, button).unwrap_or_else(|| {
ledge::check_button_on(module_accessor, button)
.unwrap_or_else(|| original!()(module_accessor, button))
})
})
})
}
#[allow(unused_unsafe)]
#[skyline::hook(replace = ControlModule::check_button_off)]
pub unsafe fn handle_check_button_off(
module_accessor: &mut app::BattleObjectModuleAccessor,
button: i32,
) -> bool {
Shield::check_button_off(module_accessor, button)
shield::check_button_off(module_accessor, button)
.unwrap_or_else(|| original!()(module_accessor, button))
}
#[allow(unused_unsafe)]
#[skyline::hook(replace = StatusModule::init_settings)]
pub unsafe fn handle_init_settings(
module_accessor: &mut app::BattleObjectModuleAccessor,
situationKind: i32,
situation_kind: i32,
unk1: i32,
unk2: u32,
groundCliffCheckKind: i32,
ground_cliff_check_kind: i32,
unk3: bool,
unk4: i32,
unk5: i32,
@ -142,13 +135,13 @@ pub unsafe fn handle_init_settings(
unk7: i32,
) {
let status_kind = StatusModule::status_kind(module_accessor) as i32;
Tech::init_settings(module_accessor, status_kind).unwrap_or_else(|| {
tech::init_settings(module_accessor, status_kind).unwrap_or_else(|| {
original!()(
module_accessor,
situationKind,
situation_kind,
unk1,
unk2,
groundCliffCheckKind,
ground_cliff_check_kind,
unk3,
unk4,
unk5,
@ -158,7 +151,6 @@ pub unsafe fn handle_init_settings(
})
}
#[allow(unused_unsafe)]
#[skyline::hook(replace = MotionModule::change_motion)]
pub unsafe fn handle_change_motion(
module_accessor: &mut app::BattleObjectModuleAccessor,
@ -170,7 +162,7 @@ pub unsafe fn handle_change_motion(
unk5: bool,
unk6: bool,
) -> u64 {
Tech::change_motion(module_accessor, motion_kind).unwrap_or_else(|| {
tech::change_motion(module_accessor, motion_kind).unwrap_or_else(|| {
original!()(
module_accessor,
motion_kind,
@ -188,10 +180,10 @@ pub fn training_mods() {
println!("Applying training mods.");
unsafe {
LookupSymbol(
&mut fighter_manager_addr,
&mut FIGHTER_MANAGER_ADDR,
c_str("_ZN3lib9SingletonIN3app14FighterManagerEE9instance_E"),
);
println!("Lookup symbol output: {:#?}", fighter_manager_addr);
println!("Lookup symbol output: {:#?}", FIGHTER_MANAGER_ADDR);
}
skyline::install_hooks!(

View file

@ -11,23 +11,22 @@ enum SaveState {
PosMove,
}
use crate::training::SaveStates::SaveState::*;
use SaveState::*;
static mut save_state_player_state: SaveState = NoAction;
static mut save_state_cpu_state: SaveState = NoAction;
static mut save_state_move_alert: bool = false;
static mut SAVE_STATE_PLAYER_STATE: SaveState = NoAction;
static mut SAVE_STATE_CPU_STATE: SaveState = NoAction;
static mut save_state_x_player: f32 = 0.0;
static mut save_state_y_player: f32 = 0.0;
static mut save_state_percent_player: f32 = 0.0;
static mut save_state_lr_player: f32 = 1.0;
static mut save_state_situation_kind_player: i32 = 0 as i32;
static mut SAVE_STATE_X_PLAYER: f32 = 0.0;
static mut SAVE_STATE_Y_PLAYER: f32 = 0.0;
static mut SAVE_STATE_PERCENT_PLAYER: f32 = 0.0;
static mut SAVE_STATE_LR_PLAYER: f32 = 1.0;
static mut SAVE_STATE_SITUATION_KIND_PLAYER: i32 = 0 as i32;
static mut save_state_x_cpu: f32 = 0.0;
static mut save_state_y_cpu: f32 = 0.0;
static mut save_state_percent_cpu: f32 = 0.0;
static mut save_state_lr_cpu: f32 = 1.0;
static mut save_state_situation_kind_cpu: i32 = 0 as i32;
static mut SAVE_STATE_X_CPU: f32 = 0.0;
static mut SAVE_STATE_Y_CPU: f32 = 0.0;
static mut SAVE_STATE_PERCENT_CPU: f32 = 0.0;
static mut SAVE_STATE_LR_CPU: f32 = 1.0;
static mut SAVE_STATE_SITUATION_KIND_CPU: i32 = 0 as i32;
pub unsafe fn save_states(module_accessor: &mut app::BattleObjectModuleAccessor) {
let status = StatusModule::status_kind(module_accessor) as i32;
@ -39,19 +38,19 @@ pub unsafe fn save_states(module_accessor: &mut app::BattleObjectModuleAccessor)
let save_state_situation_kind: *mut i32;
let save_state: *mut SaveState;
if is_operation_cpu(module_accessor) {
save_state_x = &mut save_state_x_cpu;
save_state_y = &mut save_state_y_cpu;
save_state_percent = &mut save_state_percent_cpu;
save_state_lr = &mut save_state_lr_cpu;
save_state_situation_kind = &mut save_state_situation_kind_cpu;
save_state = &mut save_state_cpu_state;
save_state_x = &mut SAVE_STATE_X_CPU;
save_state_y = &mut SAVE_STATE_Y_CPU;
save_state_percent = &mut SAVE_STATE_PERCENT_CPU;
save_state_lr = &mut SAVE_STATE_LR_CPU;
save_state_situation_kind = &mut SAVE_STATE_SITUATION_KIND_CPU;
save_state = &mut SAVE_STATE_CPU_STATE;
} else {
save_state_x = &mut save_state_x_player;
save_state_y = &mut save_state_y_player;
save_state_percent = &mut save_state_percent_player;
save_state_lr = &mut save_state_lr_player;
save_state_situation_kind = &mut save_state_situation_kind_player;
save_state = &mut save_state_player_state;
save_state_x = &mut SAVE_STATE_X_PLAYER;
save_state_y = &mut SAVE_STATE_Y_PLAYER;
save_state_percent = &mut SAVE_STATE_PERCENT_PLAYER;
save_state_lr = &mut SAVE_STATE_LR_PLAYER;
save_state_situation_kind = &mut SAVE_STATE_SITUATION_KIND_PLAYER;
save_state = &mut SAVE_STATE_PLAYER_STATE;
}
// Grab + Dpad up: reset state
@ -60,8 +59,8 @@ pub unsafe fn save_states(module_accessor: &mut app::BattleObjectModuleAccessor)
!= 0
{
if *save_state == NoAction {
save_state_player_state = CameraMove;
save_state_cpu_state = CameraMove;
SAVE_STATE_PLAYER_STATE = CameraMove;
SAVE_STATE_CPU_STATE = CameraMove;
}
return;
}
@ -155,8 +154,8 @@ pub unsafe fn save_states(module_accessor: &mut app::BattleObjectModuleAccessor)
&& ControlModule::check_button_trigger(module_accessor, *CONTROL_PAD_BUTTON_APPEAL_LW)
!= 0
{
save_state_player_state = Save;
save_state_cpu_state = Save;
SAVE_STATE_PLAYER_STATE = Save;
SAVE_STATE_CPU_STATE = Save;
}
if *save_state == Save {

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,9 +31,9 @@ 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 == NONE {
if MENU.mash_state == NONE {
return true;
}
@ -42,12 +42,12 @@ pub unsafe fn should_hold_shield(module_accessor: &mut app::BattleObjectModuleAc
}
// We will only drop shield if we are in shieldstun and our attack can be performed OOS
if menu.MASH_STATE == MASH_ATTACK {
if [MASH_NEUTRAL_B, MASH_SIDE_B, MASH_DOWN_B].contains(&menu.ATTACK_STATE) {
if MENU.mash_state == MASH_ATTACK {
if [MASH_NEUTRAL_B, MASH_SIDE_B, MASH_DOWN_B].contains(&MENU.attack_state) {
return false;
}
if [MASH_SPOTDODGE, MASH_GRAB].contains(&menu.ATTACK_STATE) {
if [MASH_SPOTDODGE, MASH_GRAB].contains(&MENU.attack_state) {
return true;
}
}

View file

@ -10,7 +10,7 @@ pub unsafe fn init_settings(
) -> Option<()> {
if is_training_mode() && is_operation_cpu(module_accessor) {
if status_kind == FIGHTER_STATUS_KIND_DOWN {
match menu.TECH_STATE {
match MENU.tech_state {
RANDOM_TECH => {
let random_statuses = vec![
*FIGHTER_STATUS_KIND_DOWN,
@ -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 != 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 [
@ -125,7 +125,7 @@ pub unsafe fn check_button_on(
if 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 menu.DEFENSIVE_STATE == DEFENSIVE_SHIELD
if MENU.defensive_state == DEFENSIVE_SHIELD
&& should_perform_defensive_option(module_accessor, prev_status, status)
{
return Some(true);
@ -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 != 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"));