mirror of
https://github.com/jugeeya/UltimateTrainingModpack.git
synced 2025-03-22 22:36:10 +00:00
Merge pull request #57 from jam1garner/master
Refactor to Make Codebase More Idiomatic
This commit is contained in:
commit
af54cd90bb
11 changed files with 413 additions and 374 deletions
|
@ -1,4 +1,4 @@
|
||||||
pub const NONE: i32 = 0;
|
use smash::lib::lua_const::*;
|
||||||
|
|
||||||
// Side Taunt
|
// Side Taunt
|
||||||
|
|
||||||
|
@ -8,69 +8,209 @@ pub const NONE: i32 = 0;
|
||||||
0, pi/4, pi/2, 3pi/4, pi, 5pi/4, 3pi/2, 7pi/4
|
0, pi/4, pi/2, 3pi/4, pi, 5pi/4, 3pi/2, 7pi/4
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* DI */
|
/// DI
|
||||||
pub static mut DI_STATE: i32 = NONE;
|
#[repr(i32)]
|
||||||
pub const DI_RANDOM_IN_AWAY: i32 = 9;
|
#[derive(Debug, Clone, Copy, PartialEq)]
|
||||||
// const std::vector<std::string> di_items{"None", "Out", "Up Out", "Up", "Up In", "In", "Down In", "Down", "Down Out", "Random"};
|
pub enum DirectionalInfluence {
|
||||||
|
None = 0,
|
||||||
|
// lol what goes here jug smh my head
|
||||||
|
RandomInAway = 9,
|
||||||
|
}
|
||||||
|
|
||||||
// Attack Option
|
/// Mash Attack States
|
||||||
pub const MASH_NAIR: i32 = 0;
|
#[repr(i32)]
|
||||||
pub const MASH_FAIR: i32 = 1;
|
#[derive(PartialEq, Debug, Copy, Clone)]
|
||||||
pub const MASH_BAIR: i32 = 2;
|
pub enum Attack {
|
||||||
pub const MASH_UPAIR: i32 = 3;
|
Nair = 0,
|
||||||
pub const MASH_DAIR: i32 = 4;
|
Fair = 1,
|
||||||
pub const MASH_NEUTRAL_B: i32 = 5;
|
Bair = 2,
|
||||||
pub const MASH_SIDE_B: i32 = 6;
|
UpAir = 3,
|
||||||
pub const MASH_UP_B: i32 = 7;
|
Dair = 4,
|
||||||
pub const MASH_DOWN_B: i32 = 8;
|
NeutralB = 5,
|
||||||
pub const MASH_UP_SMASH: i32 = 9;
|
SideB = 6,
|
||||||
pub const MASH_GRAB: i32 = 10;
|
UpB = 7,
|
||||||
// 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"};
|
DownB = 8,
|
||||||
|
UpSmash = 9,
|
||||||
|
Grab = 10
|
||||||
|
}
|
||||||
|
|
||||||
|
impl From<i32> for Attack {
|
||||||
|
fn from(x: i32) -> Self {
|
||||||
|
use Attack::*;
|
||||||
|
|
||||||
|
match x {
|
||||||
|
0 => Nair,
|
||||||
|
1 => Fair,
|
||||||
|
2 => Bair,
|
||||||
|
3 => UpAir,
|
||||||
|
4 => Dair,
|
||||||
|
5 => NeutralB,
|
||||||
|
6 => SideB,
|
||||||
|
7 => UpB,
|
||||||
|
8 => DownB,
|
||||||
|
9 => UpSmash,
|
||||||
|
10 => Grab,
|
||||||
|
_ => panic!("Invalid mash attack state {}", x)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Attack {
|
||||||
|
pub fn into_attack_air_kind(&self) -> Option<i32> {
|
||||||
|
use Attack::*;
|
||||||
|
|
||||||
|
Some(
|
||||||
|
match self {
|
||||||
|
Nair => *FIGHTER_COMMAND_ATTACK_AIR_KIND_N,
|
||||||
|
Fair => *FIGHTER_COMMAND_ATTACK_AIR_KIND_F,
|
||||||
|
Bair => *FIGHTER_COMMAND_ATTACK_AIR_KIND_B,
|
||||||
|
Dair => *FIGHTER_COMMAND_ATTACK_AIR_KIND_LW,
|
||||||
|
UpAir => *FIGHTER_COMMAND_ATTACK_AIR_KIND_HI,
|
||||||
|
_ => return None,
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Ledge Option
|
// Ledge Option
|
||||||
pub const RANDOM_LEDGE: i32 = 1;
|
#[repr(i32)]
|
||||||
pub const NEUTRAL_LEDGE: i32 = 2;
|
#[derive(Debug, Copy, Clone, PartialEq)]
|
||||||
pub const ROLL_LEDGE: i32 = 3;
|
pub enum LedgeOption {
|
||||||
pub const JUMP_LEDGE: i32 = 4;
|
None = 0,
|
||||||
pub const ATTACK_LEDGE: i32 = 5;
|
Random = 1,
|
||||||
// pub const std::vector<std::string> ledge_items{"None", "Random", "Ntrl. Getup", "Roll", "Jump", "Attack"};
|
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)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl LedgeOption {
|
||||||
|
pub fn into_status(&self) -> Option<i32> {
|
||||||
|
Some(
|
||||||
|
match self {
|
||||||
|
LedgeOption::Neutral => *FIGHTER_STATUS_KIND_CLIFF_CLIMB,
|
||||||
|
LedgeOption::Roll => *FIGHTER_STATUS_KIND_CLIFF_ESCAPE,
|
||||||
|
LedgeOption::Jump => *FIGHTER_STATUS_KIND_CLIFF_JUMP1,
|
||||||
|
LedgeOption::Attack => *FIGHTER_STATUS_KIND_CLIFF_ATTACK,
|
||||||
|
_ => return None,
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Tech Option
|
// Tech Option
|
||||||
pub const RANDOM_TECH: i32 = 1;
|
#[repr(i32)]
|
||||||
pub const TECH_IN_PLACE: i32 = 2;
|
#[derive(Debug, Clone, Copy, PartialEq)]
|
||||||
pub const TECH_ROLL: i32 = 3;
|
pub enum TechOption {
|
||||||
pub const TECH_MISS: i32 = 4;
|
None = 0,
|
||||||
// pub const std::vector<std::string> tech_items{"None", "Random", "In-Place", "Roll", "Miss Tech"};
|
Random = 1,
|
||||||
|
InPlace = 2,
|
||||||
|
Roll = 3,
|
||||||
|
Miss = 4
|
||||||
|
}
|
||||||
|
|
||||||
// Mash States
|
impl From<i32> for TechOption {
|
||||||
pub const MASH_AIRDODGE: i32 = 1;
|
fn from(x: i32) -> Self {
|
||||||
pub const MASH_JUMP: i32 = 2;
|
use TechOption::*;
|
||||||
pub const MASH_ATTACK: i32 = 3;
|
|
||||||
pub const MASH_SPOTDODGE: i32 = 4;
|
|
||||||
pub const MASH_RANDOM: i32 = 5;
|
|
||||||
// pub const std::vector<std::string> mash_items{"None", "Airdodge", "Jump", "Attack", "Spotdodge", "Random"};
|
|
||||||
|
|
||||||
// Shield States
|
match x {
|
||||||
pub const SHIELD_INFINITE: i32 = 1;
|
0 => None,
|
||||||
pub const SHIELD_HOLD: i32 = 2;
|
1 => Random,
|
||||||
// pub const std::vector<std::string> shield_items{"None", "Infinite", "Hold"};
|
2 => InPlace,
|
||||||
|
3 => Roll,
|
||||||
|
4 => Miss,
|
||||||
|
_ => panic!("Invalid tech option {}", x)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Mash States
|
||||||
|
#[repr(i32)]
|
||||||
|
#[derive(Debug, Clone, Copy, PartialEq)]
|
||||||
|
pub enum Mash {
|
||||||
|
None = 0,
|
||||||
|
Airdodge = 1,
|
||||||
|
Jump = 2,
|
||||||
|
Attack = 3,
|
||||||
|
Spotdodge = 4,
|
||||||
|
Random = 5
|
||||||
|
}
|
||||||
|
|
||||||
|
impl From<i32> for Mash {
|
||||||
|
fn from(x: i32) -> Self {
|
||||||
|
match x {
|
||||||
|
0 => Mash::None,
|
||||||
|
1 => Mash::Airdodge,
|
||||||
|
2 => Mash::Jump,
|
||||||
|
3 => Mash::Attack,
|
||||||
|
4 => Mash::Spotdodge,
|
||||||
|
5 => Mash::Random,
|
||||||
|
_ => panic!("Invalid mash state {}", x)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Shield States
|
||||||
|
#[repr(i32)]
|
||||||
|
#[derive(Debug, Clone, Copy, PartialEq)]
|
||||||
|
pub enum Shield {
|
||||||
|
None = 0,
|
||||||
|
Infinite = 1,
|
||||||
|
Hold = 2,
|
||||||
|
}
|
||||||
|
|
||||||
// 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,
|
||||||
// pub const std::vector<std::string> defensive_items{"None", "Random", "Spotdodge", "Roll", "Jab", "Flash Shield"};
|
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)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
pub struct TrainingModpackMenu {
|
pub struct TrainingModpackMenu {
|
||||||
pub HITBOX_VIS: bool,
|
pub hitbox_vis: bool,
|
||||||
pub DI_STATE: i32,
|
pub di_state: DirectionalInfluence,
|
||||||
pub ATTACK_STATE: i32,
|
pub mash_attack_state: Attack,
|
||||||
pub LEDGE_STATE: i32,
|
pub ledge_state: LedgeOption,
|
||||||
pub TECH_STATE: i32,
|
pub tech_state: TechOption,
|
||||||
pub MASH_STATE: i32,
|
pub mash_state: Mash,
|
||||||
pub SHIELD_STATE: i32,
|
pub shield_state: Shield,
|
||||||
pub DEFENSIVE_STATE: i32,
|
pub defensive_state: Defensive,
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,32 +1,31 @@
|
||||||
pub mod consts;
|
pub mod consts;
|
||||||
|
|
||||||
use crate::common::consts::*;
|
use crate::common::consts::*;
|
||||||
use smash::app::lua_bind::*;
|
use smash::app::{self, lua_bind::*};
|
||||||
use smash::app::{self};
|
|
||||||
use smash::lib::lua_const::*;
|
use smash::lib::lua_const::*;
|
||||||
// use smash::app::{FighterManager, FighterInformation};
|
|
||||||
use smash::hash40;
|
use smash::hash40;
|
||||||
|
|
||||||
pub static mut menu_struct: consts::TrainingModpackMenu = consts::TrainingModpackMenu {
|
pub static mut MENU_STRUCT: consts::TrainingModpackMenu = consts::TrainingModpackMenu {
|
||||||
HITBOX_VIS: true,
|
hitbox_vis: true,
|
||||||
DI_STATE: NONE,
|
di_state: DirectionalInfluence::None,
|
||||||
ATTACK_STATE: MASH_NAIR,
|
mash_attack_state: Attack::Nair,
|
||||||
LEDGE_STATE: RANDOM_LEDGE,
|
ledge_state: LedgeOption::Random,
|
||||||
TECH_STATE: RANDOM_TECH,
|
tech_state: TechOption::Random,
|
||||||
MASH_STATE: NONE,
|
mash_state: Mash::None,
|
||||||
SHIELD_STATE: NONE,
|
shield_state: Shield::None,
|
||||||
DEFENSIVE_STATE: RANDOM_DEFENSIVE,
|
defensive_state: Defensive::Random,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub static mut menu: *mut consts::TrainingModpackMenu = 0 as *mut consts::TrainingModpackMenu;
|
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" {
|
extern "C" {
|
||||||
#[link_name = "\u{1}_ZN3app9smashball16is_training_modeEv"]
|
#[link_name = "\u{1}_ZN3app9smashball16is_training_modeEv"]
|
||||||
pub fn is_training_mode() -> bool;
|
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 {
|
pub fn get_category(module_accessor: &mut app::BattleObjectModuleAccessor) -> i32 {
|
||||||
|
@ -40,7 +39,7 @@ pub unsafe fn is_operation_cpu(module_accessor: &mut app::BattleObjectModuleAcce
|
||||||
|
|
||||||
let entry_id_int =
|
let entry_id_int =
|
||||||
WorkModule::get_int(module_accessor, *FIGHTER_INSTANCE_WORK_ID_INT_ENTRY_ID) as i32;
|
WorkModule::get_int(module_accessor, *FIGHTER_INSTANCE_WORK_ID_INT_ENTRY_ID) as i32;
|
||||||
let entry_id = app::FighterEntryID(entry_id_int);
|
let _entry_id = app::FighterEntryID(entry_id_int);
|
||||||
// let mut mgr = FighterManager{_address : fighter_manager_addr as u64};
|
// let mut mgr = FighterManager{_address : fighter_manager_addr as u64};
|
||||||
// let fighter_information = lua_bind::FighterManager::get_fighter_information(&mut mgr, entry_id) as *mut FighterInformation;
|
// let fighter_information = lua_bind::FighterManager::get_fighter_information(&mut mgr, entry_id) as *mut FighterInformation;
|
||||||
// println!("FighterInformation: {:#?}", fighter_information);
|
// println!("FighterInformation: {:#?}", fighter_information);
|
||||||
|
@ -74,11 +73,11 @@ pub unsafe fn is_in_landing(module_accessor: &mut app::BattleObjectModuleAccesso
|
||||||
}
|
}
|
||||||
|
|
||||||
pub unsafe fn perform_defensive_option(
|
pub unsafe fn perform_defensive_option(
|
||||||
module_accessor: &mut app::BattleObjectModuleAccessor,
|
_module_accessor: &mut app::BattleObjectModuleAccessor,
|
||||||
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,
|
||||||
|
@ -90,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,
|
||||||
_ => (),
|
_ => (),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,88 +1,9 @@
|
||||||
use crate::common::*;
|
use crate::common::{*, consts::*};
|
||||||
use crate::common::consts::*;
|
use smash::app::{self, lua_bind::*, sv_animcmd, sv_system};
|
||||||
use smash::app::lua_bind::*;
|
|
||||||
use smash::app::sv_animcmd::{self};
|
|
||||||
use smash::app::sv_system::{self};
|
|
||||||
use smash::app::{self};
|
|
||||||
use smash::hash40;
|
use smash::hash40;
|
||||||
use smash::lib::lua_const::*;
|
use smash::lib::{lua_const::*, L2CAgent, L2CValue};
|
||||||
use smash::lib::{L2CAgent, L2CValue};
|
|
||||||
use smash::phx::{Hash40, Vector3f};
|
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] = &[
|
pub const ID_COLORS: &[Vector3f] = &[
|
||||||
// used to tint the hitbox effects -- make sure that at least one component
|
// used to tint the hitbox effects -- make sure that at least one component
|
||||||
// is equal to 1.0
|
// is equal to 1.0
|
||||||
|
@ -141,18 +62,18 @@ pub unsafe fn generate_hitbox_effects(
|
||||||
z2: Option<f32>,
|
z2: Option<f32>,
|
||||||
color: Vector3f,
|
color: Vector3f,
|
||||||
) {
|
) {
|
||||||
let red = L2CValue::new_num(color.x);
|
let _red = L2CValue::new_num(color.x);
|
||||||
let green = L2CValue::new_num(color.y);
|
let _green = L2CValue::new_num(color.y);
|
||||||
let blue = L2CValue::new_num(color.z);
|
let _blue = L2CValue::new_num(color.z);
|
||||||
|
|
||||||
let size_mult = 19.0 / 200.0;
|
let size_mult = 19.0 / 200.0;
|
||||||
|
|
||||||
let shield_effect = L2CValue::new_int(hash40("sys_shield"));
|
let _shield_effect = L2CValue::new_int(hash40("sys_shield"));
|
||||||
let zero_rot = L2CValue::new_num(0.0);
|
let _zero_rot = L2CValue::new_num(0.0);
|
||||||
let terminate = L2CValue::new_bool(true);
|
let _terminate = L2CValue::new_bool(true);
|
||||||
let effect_size = L2CValue::new_num(size * size_mult);
|
let _effect_size = L2CValue::new_num(size * size_mult);
|
||||||
|
|
||||||
let rate = L2CValue::new_num(8.0);
|
let _rate = L2CValue::new_num(8.0);
|
||||||
|
|
||||||
let x_dist: f32;
|
let x_dist: f32;
|
||||||
let y_dist: f32;
|
let y_dist: f32;
|
||||||
|
@ -233,11 +154,11 @@ pub unsafe fn get_command_flag_cat(
|
||||||
// Pause Effect AnimCMD if hitbox visualization is active
|
// Pause Effect AnimCMD if hitbox visualization is active
|
||||||
MotionAnimcmdModule::set_sleep_effect(
|
MotionAnimcmdModule::set_sleep_effect(
|
||||||
module_accessor,
|
module_accessor,
|
||||||
(*menu).HITBOX_VIS,
|
MENU.hitbox_vis,
|
||||||
);
|
);
|
||||||
|
|
||||||
// apply only once per frame
|
// 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;
|
let status_kind = StatusModule::status_kind(module_accessor) as i32;
|
||||||
if !(*FIGHTER_STATUS_KIND_CATCH..=*FIGHTER_STATUS_KIND_CATCH_TURN).contains(&status_kind)
|
if !(*FIGHTER_STATUS_KIND_CATCH..=*FIGHTER_STATUS_KIND_CATCH_TURN).contains(&status_kind)
|
||||||
|
@ -290,7 +211,6 @@ pub unsafe fn get_command_flag_cat(
|
||||||
}
|
}
|
||||||
|
|
||||||
// Necessary to ensure we visualize on the first frame of the hitbox
|
// Necessary to ensure we visualize on the first frame of the hitbox
|
||||||
#[allow(unused_unsafe)]
|
|
||||||
#[skyline::hook(replace = sv_animcmd::ATTACK)]
|
#[skyline::hook(replace = sv_animcmd::ATTACK)]
|
||||||
unsafe fn handle_attack(lua_state: u64) {
|
unsafe fn handle_attack(lua_state: u64) {
|
||||||
let mut l2c_agent = L2CAgent::new(lua_state);
|
let mut l2c_agent = L2CAgent::new(lua_state);
|
||||||
|
@ -298,11 +218,11 @@ unsafe fn handle_attack(lua_state: u64) {
|
||||||
// get all necessary grabbox params
|
// get all necessary grabbox params
|
||||||
let id = l2c_agent.pop_lua_stack(1); // int
|
let id = l2c_agent.pop_lua_stack(1); // int
|
||||||
let joint = l2c_agent.pop_lua_stack(3); // hash40
|
let joint = l2c_agent.pop_lua_stack(3); // hash40
|
||||||
let damage = l2c_agent.pop_lua_stack(4); // float
|
let _damage = l2c_agent.pop_lua_stack(4); // float
|
||||||
let _angle = l2c_agent.pop_lua_stack(5); // int
|
let _angle = l2c_agent.pop_lua_stack(5); // int
|
||||||
let kbg = l2c_agent.pop_lua_stack(6); // int
|
let _kbg = l2c_agent.pop_lua_stack(6); // int
|
||||||
let fkb = l2c_agent.pop_lua_stack(7); // int
|
let _fkb = l2c_agent.pop_lua_stack(7); // int
|
||||||
let bkb = l2c_agent.pop_lua_stack(8); // int
|
let _bkb = l2c_agent.pop_lua_stack(8); // int
|
||||||
let size = l2c_agent.pop_lua_stack(9); // float
|
let size = l2c_agent.pop_lua_stack(9); // float
|
||||||
let x = l2c_agent.pop_lua_stack(10); // float
|
let x = l2c_agent.pop_lua_stack(10); // float
|
||||||
let y = l2c_agent.pop_lua_stack(11); // float
|
let y = l2c_agent.pop_lua_stack(11); // float
|
||||||
|
@ -312,7 +232,7 @@ unsafe fn handle_attack(lua_state: u64) {
|
||||||
let z2 = l2c_agent.pop_lua_stack(15); // float or void
|
let z2 = l2c_agent.pop_lua_stack(15); // float or void
|
||||||
|
|
||||||
// hacky way of forcing no shield damage on all hitboxes
|
// 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> =
|
let hitbox_params: Vec<L2CValue> =
|
||||||
(0..36).map(|i| l2c_agent.pop_lua_stack(i + 1)).collect();
|
(0..36).map(|i| l2c_agent.pop_lua_stack(i + 1)).collect();
|
||||||
l2c_agent.clear_lua_stack();
|
l2c_agent.clear_lua_stack();
|
||||||
|
@ -328,7 +248,7 @@ unsafe fn handle_attack(lua_state: u64) {
|
||||||
|
|
||||||
original!()(lua_state);
|
original!()(lua_state);
|
||||||
|
|
||||||
if (*menu).HITBOX_VIS && is_training_mode() {
|
if MENU.hitbox_vis && is_training_mode() {
|
||||||
generate_hitbox_effects(
|
generate_hitbox_effects(
|
||||||
sv_system::battle_object_module_accessor(lua_state),
|
sv_system::battle_object_module_accessor(lua_state),
|
||||||
joint.get_int(),
|
joint.get_int(),
|
||||||
|
@ -344,7 +264,6 @@ unsafe fn handle_attack(lua_state: u64) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(unused_unsafe)]
|
|
||||||
#[skyline::hook(replace = sv_animcmd::CATCH)]
|
#[skyline::hook(replace = sv_animcmd::CATCH)]
|
||||||
unsafe fn handle_catch(lua_state: u64) {
|
unsafe fn handle_catch(lua_state: u64) {
|
||||||
let mut l2c_agent = L2CAgent::new(lua_state);
|
let mut l2c_agent = L2CAgent::new(lua_state);
|
||||||
|
@ -362,7 +281,7 @@ unsafe fn handle_catch(lua_state: u64) {
|
||||||
|
|
||||||
original!()(lua_state);
|
original!()(lua_state);
|
||||||
|
|
||||||
if (*menu).HITBOX_VIS && is_training_mode() {
|
if MENU.hitbox_vis && is_training_mode() {
|
||||||
generate_hitbox_effects(
|
generate_hitbox_effects(
|
||||||
sv_system::battle_object_module_accessor(lua_state),
|
sv_system::battle_object_module_accessor(lua_state),
|
||||||
joint.get_int(),
|
joint.get_int(),
|
||||||
|
@ -383,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)
|
(*FIGHTER_STATUS_KIND_GUARD_ON..=*FIGHTER_STATUS_KIND_GUARD_DAMAGE).contains(&status_kind)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(unused_unsafe)]
|
|
||||||
#[skyline::hook(replace = GrabModule::set_rebound)]
|
#[skyline::hook(replace = GrabModule::set_rebound)]
|
||||||
pub unsafe fn handle_set_rebound(
|
pub unsafe fn handle_set_rebound(
|
||||||
module_accessor: *mut app::BattleObjectModuleAccessor,
|
module_accessor: *mut app::BattleObjectModuleAccessor,
|
||||||
|
@ -415,7 +333,9 @@ pub unsafe fn handle_set_rebound(
|
||||||
|
|
||||||
pub fn hitbox_visualization() {
|
pub fn hitbox_visualization() {
|
||||||
println!("Applying hitbox visualization mods.");
|
println!("Applying hitbox visualization mods.");
|
||||||
skyline::install_hook!(handle_attack);
|
skyline::install_hooks!(
|
||||||
skyline::install_hook!(handle_catch);
|
handle_attack,
|
||||||
skyline::install_hook!(handle_set_rebound);
|
handle_catch,
|
||||||
|
handle_set_rebound
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
25
src/lib.rs
25
src/lib.rs
|
@ -1,9 +1,6 @@
|
||||||
#![feature(proc_macro_hygiene)]
|
#![feature(proc_macro_hygiene)]
|
||||||
#![allow(unused_variables)]
|
|
||||||
#![allow(dead_code)]
|
|
||||||
#![allow(non_snake_case)]
|
|
||||||
#![allow(non_upper_case_globals)]
|
|
||||||
#![feature(with_options)]
|
#![feature(with_options)]
|
||||||
|
#![feature(const_mut_refs)]
|
||||||
|
|
||||||
mod common;
|
mod common;
|
||||||
mod hitbox_visualizer;
|
mod hitbox_visualizer;
|
||||||
|
@ -16,17 +13,16 @@ use skyline::c_str;
|
||||||
use skyline::libc::{c_void, mkdir, fclose, fopen, fwrite};
|
use skyline::libc::{c_void, mkdir, fclose, fopen, fwrite};
|
||||||
use skyline::nro::{self, NroInfo};
|
use skyline::nro::{self, NroInfo};
|
||||||
use smash::app::lua_bind::*;
|
use smash::app::lua_bind::*;
|
||||||
use smash::app::sv_system::{self};
|
use smash::app::sv_system;
|
||||||
use smash::lib::lua_const::*;
|
use smash::lib::lua_const::*;
|
||||||
use smash::lib::L2CValue;
|
use smash::lib::L2CValue;
|
||||||
use smash::lua2cpp::L2CFighterCommon;
|
use smash::lua2cpp::L2CFighterCommon;
|
||||||
|
|
||||||
#[allow(unused_unsafe)]
|
|
||||||
#[skyline::hook(replace = smash::lua2cpp::L2CFighterCommon_sub_guard_cont)]
|
#[skyline::hook(replace = smash::lua2cpp::L2CFighterCommon_sub_guard_cont)]
|
||||||
pub unsafe fn handle_sub_guard_cont(fighter: &mut L2CFighterCommon) -> L2CValue {
|
pub unsafe fn handle_sub_guard_cont(fighter: &mut L2CFighterCommon) -> L2CValue {
|
||||||
let module_accessor = sv_system::battle_object_module_accessor(fighter.lua_state_agent);
|
let module_accessor = sv_system::battle_object_module_accessor(fighter.lua_state_agent);
|
||||||
if is_training_mode() && is_operation_cpu(module_accessor) {
|
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.mash_attack_state == Attack::Grab {
|
||||||
if StatusModule::prev_status_kind(module_accessor, 0) == FIGHTER_STATUS_KIND_GUARD_DAMAGE {
|
if StatusModule::prev_status_kind(module_accessor, 0) == FIGHTER_STATUS_KIND_GUARD_DAMAGE {
|
||||||
if WorkModule::get_int(
|
if WorkModule::get_int(
|
||||||
module_accessor,
|
module_accessor,
|
||||||
|
@ -45,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 StatusModule::prev_status_kind(module_accessor, 0) == FIGHTER_STATUS_KIND_GUARD_DAMAGE {
|
||||||
if WorkModule::is_enable_transition_term(
|
if WorkModule::is_enable_transition_term(
|
||||||
module_accessor,
|
module_accessor,
|
||||||
|
@ -58,7 +54,9 @@ pub unsafe fn handle_sub_guard_cont(fighter: &mut L2CFighterCommon) -> L2CValue
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (*menu).MASH_STATE == MASH_UP_B {
|
|
||||||
|
if MENU.mash_state == Mash::Attack {
|
||||||
|
if MENU.mash_attack_state == Attack::UpB {
|
||||||
if StatusModule::prev_status_kind(module_accessor, 0) == FIGHTER_STATUS_KIND_GUARD_DAMAGE {
|
if StatusModule::prev_status_kind(module_accessor, 0) == FIGHTER_STATUS_KIND_GUARD_DAMAGE {
|
||||||
// if WorkModule::is_enable_transition_term(
|
// if WorkModule::is_enable_transition_term(
|
||||||
// module_accessor,
|
// module_accessor,
|
||||||
|
@ -71,7 +69,7 @@ pub unsafe fn handle_sub_guard_cont(fighter: &mut L2CFighterCommon) -> L2CValue
|
||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (*menu).MASH_STATE == MASH_UP_SMASH {
|
if MENU.mash_attack_state == Attack::UpSmash {
|
||||||
if StatusModule::prev_status_kind(module_accessor, 0) == FIGHTER_STATUS_KIND_GUARD_DAMAGE {
|
if StatusModule::prev_status_kind(module_accessor, 0) == FIGHTER_STATUS_KIND_GUARD_DAMAGE {
|
||||||
// if WorkModule::is_enable_transition_term(
|
// if WorkModule::is_enable_transition_term(
|
||||||
// module_accessor,
|
// module_accessor,
|
||||||
|
@ -85,10 +83,12 @@ pub unsafe fn handle_sub_guard_cont(fighter: &mut L2CFighterCommon) -> L2CValue
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
original!()(fighter)
|
original!()(fighter)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn nro_main(nro: &NroInfo) {
|
fn nro_main(nro: &NroInfo<'_>) {
|
||||||
match nro.name {
|
match nro.name {
|
||||||
"common" => {
|
"common" => {
|
||||||
println!("Loaded common NRO!");
|
println!("Loaded common NRO!");
|
||||||
|
@ -106,8 +106,7 @@ pub fn main() {
|
||||||
nro::add_hook(nro_main).unwrap();
|
nro::add_hook(nro_main).unwrap();
|
||||||
|
|
||||||
unsafe {
|
unsafe {
|
||||||
common::menu = &mut common::menu_struct;
|
let buffer = format!("{:x}", MENU as *const _ as u64);
|
||||||
let buffer = format!("{:x}", common::menu as u64);
|
|
||||||
println!("Writing training_modpack.log with {}...\n", buffer);
|
println!("Writing training_modpack.log with {}...\n", buffer);
|
||||||
mkdir("sd:/TrainingModpack/\u{0}".as_bytes().as_ptr(), 0777);
|
mkdir("sd:/TrainingModpack/\u{0}".as_bytes().as_ptr(), 0777);
|
||||||
let f = fopen(
|
let f = fopen(
|
||||||
|
|
|
@ -1,8 +1,7 @@
|
||||||
use crate::common::consts::*;
|
use crate::common::consts::*;
|
||||||
use crate::common::*;
|
use crate::common::*;
|
||||||
use core::f64::consts::PI;
|
use core::f64::consts::PI;
|
||||||
use smash::app::lua_bind::*;
|
use smash::app::{self, lua_bind::*};
|
||||||
use smash::app::{self};
|
|
||||||
use smash::hash40;
|
use smash::hash40;
|
||||||
use smash::lib::lua_const::*;
|
use smash::lib::lua_const::*;
|
||||||
|
|
||||||
|
@ -15,13 +14,14 @@ pub unsafe fn get_float(
|
||||||
{
|
{
|
||||||
if is_training_mode() && is_operation_cpu(module_accessor) && is_in_hitstun(module_accessor)
|
if is_training_mode() && is_operation_cpu(module_accessor) && is_in_hitstun(module_accessor)
|
||||||
{
|
{
|
||||||
if (*menu).DI_STATE != NONE {
|
if MENU.di_state != DirectionalInfluence::None {
|
||||||
let mut angle = ((*menu).DI_STATE - 1) as f64 * PI / 4.0;
|
let mut angle = (MENU.di_state as i32 - 1) as f64 * PI / 4.0;
|
||||||
|
|
||||||
// Either 0 (right) or PI (left)
|
// Either 0 (right) or PI (left)
|
||||||
if (*menu).DI_STATE == DI_RANDOM_IN_AWAY {
|
if MENU.di_state == DirectionalInfluence::RandomInAway {
|
||||||
angle = app::sv_math::rand(hash40("fighter"), 2) as f64 * PI;
|
angle = app::sv_math::rand(hash40("fighter"), 2) as f64 * PI;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If facing left, reverse angle
|
// If facing left, reverse angle
|
||||||
if PostureModule::lr(module_accessor) != -1.0 {
|
if PostureModule::lr(module_accessor) != -1.0 {
|
||||||
angle -= PI;
|
angle -= PI;
|
|
@ -1,7 +1,6 @@
|
||||||
use crate::common::consts::*;
|
use crate::common::consts::*;
|
||||||
use crate::common::*;
|
use crate::common::*;
|
||||||
use smash::app::lua_bind::*;
|
use smash::app::{self, lua_bind::*};
|
||||||
use smash::app::{self};
|
|
||||||
use smash::hash40;
|
use smash::hash40;
|
||||||
use smash::lib::lua_const::*;
|
use smash::lib::lua_const::*;
|
||||||
|
|
||||||
|
@ -19,20 +18,16 @@ pub unsafe fn force_option(module_accessor: &mut app::BattleObjectModuleAccessor
|
||||||
let frame = MotionModule::frame(module_accessor) as f32;
|
let frame = MotionModule::frame(module_accessor) as f32;
|
||||||
if frame == random_frame || frame > 30.0 {
|
if frame == random_frame || frame > 30.0 {
|
||||||
let mut status = 0;
|
let mut status = 0;
|
||||||
let ledge_case: i32;
|
let ledge_case: LedgeOption;
|
||||||
|
|
||||||
if (*menu).LEDGE_STATE == RANDOM_LEDGE {
|
if MENU.ledge_state == LedgeOption::Random {
|
||||||
ledge_case = app::sv_math::rand(hash40("fighter"), 4) + 2;
|
ledge_case = (app::sv_math::rand(hash40("fighter"), 4) + 2).into();
|
||||||
} else {
|
} else {
|
||||||
ledge_case = (*menu).LEDGE_STATE;
|
ledge_case = MENU.ledge_state;
|
||||||
}
|
}
|
||||||
|
|
||||||
match ledge_case {
|
if let Some(new_status) = ledge_case.into_status() {
|
||||||
NEUTRAL_LEDGE => status = *FIGHTER_STATUS_KIND_CLIFF_CLIMB,
|
status = new_status;
|
||||||
ROLL_LEDGE => status = *FIGHTER_STATUS_KIND_CLIFF_ESCAPE,
|
|
||||||
JUMP_LEDGE => status = *FIGHTER_STATUS_KIND_CLIFF_JUMP1,
|
|
||||||
ATTACK_LEDGE => status = *FIGHTER_STATUS_KIND_CLIFF_ATTACK,
|
|
||||||
_ => (),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
StatusModule::change_status_request_from_script(module_accessor, status, true);
|
StatusModule::change_status_request_from_script(module_accessor, status, true);
|
||||||
|
@ -61,7 +56,7 @@ pub unsafe fn should_perform_defensive_option(
|
||||||
|
|
||||||
pub unsafe fn defensive_option(
|
pub unsafe fn defensive_option(
|
||||||
module_accessor: &mut app::BattleObjectModuleAccessor,
|
module_accessor: &mut app::BattleObjectModuleAccessor,
|
||||||
category: i32,
|
_category: i32,
|
||||||
flag: &mut i32,
|
flag: &mut i32,
|
||||||
) {
|
) {
|
||||||
let status = StatusModule::status_kind(module_accessor) as i32;
|
let status = StatusModule::status_kind(module_accessor) as i32;
|
||||||
|
@ -89,7 +84,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);
|
||||||
|
@ -105,7 +100,7 @@ pub unsafe fn get_command_flag_cat(
|
||||||
category: i32,
|
category: i32,
|
||||||
flag: &mut 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);
|
force_option(module_accessor);
|
||||||
defensive_option(module_accessor, category, flag);
|
defensive_option(module_accessor, category, flag);
|
||||||
}
|
}
|
|
@ -1,7 +1,6 @@
|
||||||
use crate::common::consts::*;
|
use crate::common::consts::*;
|
||||||
use crate::common::*;
|
use crate::common::*;
|
||||||
use smash::app::lua_bind::*;
|
use smash::app::{self, lua_bind::*};
|
||||||
use smash::app::{self};
|
|
||||||
use smash::hash40;
|
use smash::hash40;
|
||||||
use smash::lib::lua_const::*;
|
use smash::lib::lua_const::*;
|
||||||
|
|
||||||
|
@ -9,24 +8,17 @@ pub unsafe fn get_attack_air_kind(
|
||||||
module_accessor: &mut app::BattleObjectModuleAccessor,
|
module_accessor: &mut app::BattleObjectModuleAccessor,
|
||||||
) -> Option<i32> {
|
) -> Option<i32> {
|
||||||
if is_training_mode() && is_operation_cpu(module_accessor) {
|
if is_training_mode() && is_operation_cpu(module_accessor) {
|
||||||
if (*menu).MASH_STATE == MASH_ATTACK {
|
if MENU.mash_state == Mash::Attack {
|
||||||
match (*menu).ATTACK_STATE {
|
MENU.mash_attack_state.into_attack_air_kind()
|
||||||
MASH_NAIR => return Some(*FIGHTER_COMMAND_ATTACK_AIR_KIND_N),
|
} else if MENU.mash_state == Mash::Random {
|
||||||
MASH_FAIR => return Some(*FIGHTER_COMMAND_ATTACK_AIR_KIND_F),
|
Some(app::sv_math::rand(hash40("fighter"), 5) + 1)
|
||||||
MASH_BAIR => return Some(*FIGHTER_COMMAND_ATTACK_AIR_KIND_B),
|
} else {
|
||||||
MASH_UPAIR => return Some(*FIGHTER_COMMAND_ATTACK_AIR_KIND_HI),
|
|
||||||
MASH_DAIR => return Some(*FIGHTER_COMMAND_ATTACK_AIR_KIND_LW),
|
|
||||||
_ => (),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (*menu).MASH_STATE == MASH_RANDOM {
|
|
||||||
return Some(app::sv_math::rand(hash40("fighter"), 5) + 1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
None
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub unsafe fn get_command_flag_cat(
|
pub unsafe fn get_command_flag_cat(
|
||||||
module_accessor: &mut app::BattleObjectModuleAccessor,
|
module_accessor: &mut app::BattleObjectModuleAccessor,
|
||||||
|
@ -38,44 +30,45 @@ pub unsafe fn get_command_flag_cat(
|
||||||
|| is_in_landing(module_accessor)
|
|| is_in_landing(module_accessor)
|
||||||
|| is_in_shieldstun(module_accessor)
|
|| is_in_shieldstun(module_accessor)
|
||||||
{
|
{
|
||||||
match (*menu).MASH_STATE {
|
match MENU.mash_state {
|
||||||
MASH_AIRDODGE => {
|
Mash::Airdodge => {
|
||||||
if category == FIGHTER_PAD_COMMAND_CATEGORY1 {
|
if category == FIGHTER_PAD_COMMAND_CATEGORY1 {
|
||||||
*flag |= *FIGHTER_PAD_CMD_CAT1_FLAG_AIR_ESCAPE;
|
*flag |= *FIGHTER_PAD_CMD_CAT1_FLAG_AIR_ESCAPE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
MASH_JUMP => {
|
Mash::Jump => {
|
||||||
if !is_in_landing(module_accessor) && category == FIGHTER_PAD_COMMAND_CATEGORY1
|
if !is_in_landing(module_accessor) && category == FIGHTER_PAD_COMMAND_CATEGORY1
|
||||||
{
|
{
|
||||||
*flag |= *FIGHTER_PAD_CMD_CAT1_FLAG_JUMP_BUTTON;
|
*flag |= *FIGHTER_PAD_CMD_CAT1_FLAG_JUMP_BUTTON;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
MASH_SPOTDODGE => {
|
Mash::Spotdodge => {
|
||||||
if category == FIGHTER_PAD_COMMAND_CATEGORY1 {
|
if category == FIGHTER_PAD_COMMAND_CATEGORY1 {
|
||||||
*flag |= *FIGHTER_PAD_CMD_CAT1_FLAG_ESCAPE;
|
*flag |= *FIGHTER_PAD_CMD_CAT1_FLAG_ESCAPE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
MASH_ATTACK => {
|
Mash::Attack => {
|
||||||
if category == FIGHTER_PAD_COMMAND_CATEGORY1 {
|
if category == FIGHTER_PAD_COMMAND_CATEGORY1 {
|
||||||
match (*menu).ATTACK_STATE {
|
use Attack::*;
|
||||||
MASH_NAIR | MASH_FAIR | MASH_BAIR | MASH_UPAIR | MASH_DAIR => {
|
|
||||||
|
match MENU.mash_attack_state {
|
||||||
|
Nair | Fair | Bair | UpAir | Dair => {
|
||||||
*flag |= *FIGHTER_PAD_CMD_CAT1_FLAG_ATTACK_N;
|
*flag |= *FIGHTER_PAD_CMD_CAT1_FLAG_ATTACK_N;
|
||||||
// If we are performing the attack OOS we also need to jump
|
// If we are performing the attack OOS we also need to jump
|
||||||
if is_in_shieldstun(module_accessor) {
|
if is_in_shieldstun(module_accessor) {
|
||||||
*flag |= *FIGHTER_PAD_CMD_CAT1_FLAG_JUMP_BUTTON;
|
*flag |= *FIGHTER_PAD_CMD_CAT1_FLAG_JUMP_BUTTON;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
MASH_NEUTRAL_B => *flag |= *FIGHTER_PAD_CMD_CAT1_FLAG_SPECIAL_N,
|
NeutralB => *flag |= *FIGHTER_PAD_CMD_CAT1_FLAG_SPECIAL_N,
|
||||||
MASH_SIDE_B => *flag |= *FIGHTER_PAD_CMD_CAT1_FLAG_SPECIAL_S,
|
SideB => *flag |= *FIGHTER_PAD_CMD_CAT1_FLAG_SPECIAL_S,
|
||||||
MASH_UP_B => *flag |= *FIGHTER_PAD_CMD_CAT1_FLAG_SPECIAL_HI,
|
UpB => *flag |= *FIGHTER_PAD_CMD_CAT1_FLAG_SPECIAL_HI,
|
||||||
MASH_DOWN_B => *flag |= *FIGHTER_PAD_CMD_CAT1_FLAG_SPECIAL_LW,
|
DownB => *flag |= *FIGHTER_PAD_CMD_CAT1_FLAG_SPECIAL_LW,
|
||||||
MASH_UP_SMASH => *flag |= *FIGHTER_PAD_CMD_CAT1_FLAG_ATTACK_HI4,
|
UpSmash => *flag |= *FIGHTER_PAD_CMD_CAT1_FLAG_ATTACK_HI4,
|
||||||
MASH_GRAB => *flag |= *FIGHTER_PAD_CMD_CAT1_FLAG_CATCH,
|
Grab => *flag |= *FIGHTER_PAD_CMD_CAT1_FLAG_CATCH,
|
||||||
_ => (),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
MASH_RANDOM => {
|
Mash::Random => {
|
||||||
if category == FIGHTER_PAD_COMMAND_CATEGORY1 {
|
if category == FIGHTER_PAD_COMMAND_CATEGORY1 {
|
||||||
let situation_kind = StatusModule::situation_kind(module_accessor) as i32;
|
let situation_kind = StatusModule::situation_kind(module_accessor) as i32;
|
||||||
|
|
||||||
|
@ -140,7 +133,7 @@ pub unsafe fn check_button_on(
|
||||||
) -> Option<bool> {
|
) -> Option<bool> {
|
||||||
if [*CONTROL_PAD_BUTTON_GUARD_HOLD, *CONTROL_PAD_BUTTON_GUARD].contains(&button) {
|
if [*CONTROL_PAD_BUTTON_GUARD_HOLD, *CONTROL_PAD_BUTTON_GUARD].contains(&button) {
|
||||||
if is_training_mode() && is_operation_cpu(module_accessor) {
|
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))
|
&& (is_in_hitstun(module_accessor) || is_in_landing(module_accessor))
|
||||||
{
|
{
|
||||||
return Some(true);
|
return Some(true);
|
|
@ -1,37 +1,34 @@
|
||||||
use crate::common::fighter_manager_addr;
|
use crate::common::FIGHTER_MANAGER_ADDR;
|
||||||
use crate::hitbox_visualizer;
|
use crate::hitbox_visualizer;
|
||||||
use skyline::{c_str, nn::ro::LookupSymbol};
|
use skyline::{c_str, nn::ro::LookupSymbol};
|
||||||
use smash::app::{self, lua_bind::*};
|
use smash::app::{self, lua_bind::*};
|
||||||
|
|
||||||
mod DirectionalInfluence;
|
mod directional_influence;
|
||||||
mod Ledge;
|
mod ledge;
|
||||||
mod Mash;
|
mod mash;
|
||||||
mod SaveStates;
|
mod save_states;
|
||||||
mod Shield;
|
mod shield;
|
||||||
mod Tech;
|
mod tech;
|
||||||
|
|
||||||
#[allow(unused_unsafe)]
|
|
||||||
#[skyline::hook(replace = WorkModule::get_float)]
|
#[skyline::hook(replace = WorkModule::get_float)]
|
||||||
pub unsafe fn handle_get_float(
|
pub unsafe fn handle_get_float(
|
||||||
module_accessor: &mut app::BattleObjectModuleAccessor,
|
module_accessor: &mut app::BattleObjectModuleAccessor,
|
||||||
var: i32,
|
var: i32,
|
||||||
) -> f32 {
|
) -> f32 {
|
||||||
DirectionalInfluence::get_float(module_accessor, var)
|
directional_influence::get_float(module_accessor, var)
|
||||||
.unwrap_or_else(|| original!()(module_accessor, var))
|
.unwrap_or_else(|| original!()(module_accessor, var))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(unused_unsafe)]
|
|
||||||
#[skyline::hook(replace = WorkModule::get_param_float)]
|
#[skyline::hook(replace = WorkModule::get_param_float)]
|
||||||
pub unsafe fn handle_get_param_float(
|
pub unsafe fn handle_get_param_float(
|
||||||
module_accessor: &mut app::BattleObjectModuleAccessor,
|
module_accessor: &mut app::BattleObjectModuleAccessor,
|
||||||
param_type: u64,
|
param_type: u64,
|
||||||
param_hash: u64,
|
param_hash: u64,
|
||||||
) -> f32 {
|
) -> 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))
|
.unwrap_or_else(|| original!()(module_accessor, param_type, param_hash))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(unused_unsafe)]
|
|
||||||
#[skyline::hook(replace = ControlModule::get_attack_air_kind)]
|
#[skyline::hook(replace = ControlModule::get_attack_air_kind)]
|
||||||
pub unsafe fn handle_get_attack_air_kind(
|
pub unsafe fn handle_get_attack_air_kind(
|
||||||
module_accessor: &mut app::BattleObjectModuleAccessor,
|
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);
|
// int kind = InputRecorder::get_attack_air_kind(module_accessor, replace);
|
||||||
// if (replace) return kind;
|
// 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)]
|
#[skyline::hook(replace = ControlModule::get_command_flag_cat)]
|
||||||
pub unsafe fn handle_get_command_flag_cat(
|
pub unsafe fn handle_get_command_flag_cat(
|
||||||
module_accessor: &mut app::BattleObjectModuleAccessor,
|
module_accessor: &mut app::BattleObjectModuleAccessor,
|
||||||
category: i32,
|
category: i32,
|
||||||
) -> i32 {
|
) -> i32 {
|
||||||
SaveStates::save_states(module_accessor);
|
save_states::save_states(module_accessor);
|
||||||
|
|
||||||
let mut flag = original!()(module_accessor, category);
|
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);
|
// int ret = InputRecorder::get_command_flag_cat(module_accessor, category, flag, replace);
|
||||||
// if (replace) return ret;
|
// if (replace) return ret;
|
||||||
|
|
||||||
Mash::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);
|
ledge::get_command_flag_cat(module_accessor, category, &mut flag);
|
||||||
Tech::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);
|
hitbox_visualizer::get_command_flag_cat(module_accessor, category);
|
||||||
|
|
||||||
flag
|
flag
|
||||||
|
@ -101,40 +97,37 @@ pub unsafe fn handle_get_command_flag_cat(
|
||||||
// return stick_y;
|
// return stick_y;
|
||||||
// }
|
// }
|
||||||
|
|
||||||
#[allow(unused_unsafe)]
|
|
||||||
#[skyline::hook(replace = ControlModule::check_button_on)]
|
#[skyline::hook(replace = ControlModule::check_button_on)]
|
||||||
pub unsafe fn handle_check_button_on(
|
pub unsafe fn handle_check_button_on(
|
||||||
module_accessor: &mut app::BattleObjectModuleAccessor,
|
module_accessor: &mut app::BattleObjectModuleAccessor,
|
||||||
button: i32,
|
button: i32,
|
||||||
) -> bool {
|
) -> bool {
|
||||||
Shield::check_button_on(module_accessor, button).unwrap_or_else(|| {
|
shield::check_button_on(module_accessor, button).unwrap_or_else(|| {
|
||||||
Mash::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(|| {
|
tech::check_button_on(module_accessor, button).unwrap_or_else(|| {
|
||||||
Ledge::check_button_on(module_accessor, button)
|
ledge::check_button_on(module_accessor, button)
|
||||||
.unwrap_or_else(|| original!()(module_accessor, button))
|
.unwrap_or_else(|| original!()(module_accessor, button))
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(unused_unsafe)]
|
|
||||||
#[skyline::hook(replace = ControlModule::check_button_off)]
|
#[skyline::hook(replace = ControlModule::check_button_off)]
|
||||||
pub unsafe fn handle_check_button_off(
|
pub unsafe fn handle_check_button_off(
|
||||||
module_accessor: &mut app::BattleObjectModuleAccessor,
|
module_accessor: &mut app::BattleObjectModuleAccessor,
|
||||||
button: i32,
|
button: i32,
|
||||||
) -> bool {
|
) -> bool {
|
||||||
Shield::check_button_off(module_accessor, button)
|
shield::check_button_off(module_accessor, button)
|
||||||
.unwrap_or_else(|| original!()(module_accessor, button))
|
.unwrap_or_else(|| original!()(module_accessor, button))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(unused_unsafe)]
|
|
||||||
#[skyline::hook(replace = StatusModule::init_settings)]
|
#[skyline::hook(replace = StatusModule::init_settings)]
|
||||||
pub unsafe fn handle_init_settings(
|
pub unsafe fn handle_init_settings(
|
||||||
module_accessor: &mut app::BattleObjectModuleAccessor,
|
module_accessor: &mut app::BattleObjectModuleAccessor,
|
||||||
situationKind: i32,
|
situation_kind: i32,
|
||||||
unk1: i32,
|
unk1: i32,
|
||||||
unk2: u32,
|
unk2: u32,
|
||||||
groundCliffCheckKind: i32,
|
ground_cliff_check_kind: i32,
|
||||||
unk3: bool,
|
unk3: bool,
|
||||||
unk4: i32,
|
unk4: i32,
|
||||||
unk5: i32,
|
unk5: i32,
|
||||||
|
@ -142,13 +135,13 @@ pub unsafe fn handle_init_settings(
|
||||||
unk7: i32,
|
unk7: i32,
|
||||||
) {
|
) {
|
||||||
let status_kind = StatusModule::status_kind(module_accessor) as 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!()(
|
original!()(
|
||||||
module_accessor,
|
module_accessor,
|
||||||
situationKind,
|
situation_kind,
|
||||||
unk1,
|
unk1,
|
||||||
unk2,
|
unk2,
|
||||||
groundCliffCheckKind,
|
ground_cliff_check_kind,
|
||||||
unk3,
|
unk3,
|
||||||
unk4,
|
unk4,
|
||||||
unk5,
|
unk5,
|
||||||
|
@ -158,7 +151,6 @@ pub unsafe fn handle_init_settings(
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(unused_unsafe)]
|
|
||||||
#[skyline::hook(replace = MotionModule::change_motion)]
|
#[skyline::hook(replace = MotionModule::change_motion)]
|
||||||
pub unsafe fn handle_change_motion(
|
pub unsafe fn handle_change_motion(
|
||||||
module_accessor: &mut app::BattleObjectModuleAccessor,
|
module_accessor: &mut app::BattleObjectModuleAccessor,
|
||||||
|
@ -170,7 +162,7 @@ pub unsafe fn handle_change_motion(
|
||||||
unk5: bool,
|
unk5: bool,
|
||||||
unk6: bool,
|
unk6: bool,
|
||||||
) -> u64 {
|
) -> u64 {
|
||||||
Tech::change_motion(module_accessor, motion_kind).unwrap_or_else(|| {
|
tech::change_motion(module_accessor, motion_kind).unwrap_or_else(|| {
|
||||||
original!()(
|
original!()(
|
||||||
module_accessor,
|
module_accessor,
|
||||||
motion_kind,
|
motion_kind,
|
||||||
|
@ -188,26 +180,32 @@ pub fn training_mods() {
|
||||||
println!("Applying training mods.");
|
println!("Applying training mods.");
|
||||||
unsafe {
|
unsafe {
|
||||||
LookupSymbol(
|
LookupSymbol(
|
||||||
&mut fighter_manager_addr,
|
&mut FIGHTER_MANAGER_ADDR,
|
||||||
c_str("_ZN3lib9SingletonIN3app14FighterManagerEE9instance_E"),
|
c_str("_ZN3lib9SingletonIN3app14FighterManagerEE9instance_E"),
|
||||||
);
|
);
|
||||||
println!("Lookup symbol output: {:#?}", fighter_manager_addr);
|
println!("Lookup symbol output: {:#?}", FIGHTER_MANAGER_ADDR);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
skyline::install_hooks!(
|
||||||
// Mash airdodge/jump
|
// Mash airdodge/jump
|
||||||
skyline::install_hook!(handle_get_command_flag_cat);
|
handle_get_command_flag_cat,
|
||||||
|
|
||||||
// Set DI
|
// Set DI
|
||||||
skyline::install_hook!(handle_get_float);
|
handle_get_float,
|
||||||
|
|
||||||
// Hold/Infinite shield
|
// Hold/Infinite shield
|
||||||
skyline::install_hook!(handle_check_button_on);
|
handle_check_button_on,
|
||||||
skyline::install_hook!(handle_check_button_off);
|
handle_check_button_off,
|
||||||
|
|
||||||
skyline::install_hook!(handle_get_param_float);
|
handle_get_param_float,
|
||||||
|
|
||||||
// Mash attack
|
// Mash attack
|
||||||
skyline::install_hook!(handle_get_attack_air_kind);
|
handle_get_attack_air_kind,
|
||||||
|
|
||||||
|
// Tech options
|
||||||
|
handle_init_settings,
|
||||||
|
handle_change_motion,
|
||||||
|
);
|
||||||
|
|
||||||
// // Input recorder
|
// // Input recorder
|
||||||
// SaltySD_function_replace_sym(
|
// SaltySD_function_replace_sym(
|
||||||
|
@ -216,8 +214,4 @@ pub fn training_mods() {
|
||||||
// SaltySD_function_replace_sym(
|
// SaltySD_function_replace_sym(
|
||||||
// "_ZN3app8lua_bind31ControlModule__get_stick_y_implEPNS_26BattleObjectModuleAccessorE",
|
// "_ZN3app8lua_bind31ControlModule__get_stick_y_implEPNS_26BattleObjectModuleAccessorE",
|
||||||
// (u64)&ControlModule::get_stick_y_replace);
|
// (u64)&ControlModule::get_stick_y_replace);
|
||||||
|
|
||||||
// Tech options
|
|
||||||
skyline::install_hook!(handle_init_settings);
|
|
||||||
skyline::install_hook!(handle_change_motion);
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
use crate::common::*;
|
use crate::common::*;
|
||||||
use smash::app::lua_bind::*;
|
use smash::app::{self, lua_bind::*};
|
||||||
use smash::app::{self};
|
|
||||||
use smash::lib::lua_const::*;
|
use smash::lib::lua_const::*;
|
||||||
use smash::phx::Vector3f;
|
use smash::phx::Vector3f;
|
||||||
|
|
||||||
|
@ -12,23 +11,22 @@ enum SaveState {
|
||||||
PosMove,
|
PosMove,
|
||||||
}
|
}
|
||||||
|
|
||||||
use crate::training::SaveStates::SaveState::*;
|
use SaveState::*;
|
||||||
|
|
||||||
static mut save_state_player_state: SaveState = NoAction;
|
static mut SAVE_STATE_PLAYER_STATE: SaveState = NoAction;
|
||||||
static mut save_state_cpu_state: SaveState = NoAction;
|
static mut SAVE_STATE_CPU_STATE: SaveState = NoAction;
|
||||||
static mut save_state_move_alert: bool = false;
|
|
||||||
|
|
||||||
static mut save_state_x_player: f32 = 0.0;
|
static mut SAVE_STATE_X_PLAYER: f32 = 0.0;
|
||||||
static mut save_state_y_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_PERCENT_PLAYER: f32 = 0.0;
|
||||||
static mut save_state_lr_player: f32 = 1.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_SITUATION_KIND_PLAYER: i32 = 0 as i32;
|
||||||
|
|
||||||
static mut save_state_x_cpu: f32 = 0.0;
|
static mut SAVE_STATE_X_CPU: f32 = 0.0;
|
||||||
static mut save_state_y_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_PERCENT_CPU: f32 = 0.0;
|
||||||
static mut save_state_lr_cpu: f32 = 1.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_SITUATION_KIND_CPU: i32 = 0 as i32;
|
||||||
|
|
||||||
pub unsafe fn save_states(module_accessor: &mut app::BattleObjectModuleAccessor) {
|
pub unsafe fn save_states(module_accessor: &mut app::BattleObjectModuleAccessor) {
|
||||||
let status = StatusModule::status_kind(module_accessor) as i32;
|
let status = StatusModule::status_kind(module_accessor) as i32;
|
||||||
|
@ -40,29 +38,28 @@ pub unsafe fn save_states(module_accessor: &mut app::BattleObjectModuleAccessor)
|
||||||
let save_state_situation_kind: *mut i32;
|
let save_state_situation_kind: *mut i32;
|
||||||
let save_state: *mut SaveState;
|
let save_state: *mut SaveState;
|
||||||
if is_operation_cpu(module_accessor) {
|
if is_operation_cpu(module_accessor) {
|
||||||
save_state_x = &mut save_state_x_cpu;
|
save_state_x = &mut SAVE_STATE_X_CPU;
|
||||||
save_state_y = &mut save_state_y_cpu;
|
save_state_y = &mut SAVE_STATE_Y_CPU;
|
||||||
save_state_percent = &mut save_state_percent_cpu;
|
save_state_percent = &mut SAVE_STATE_PERCENT_CPU;
|
||||||
save_state_lr = &mut save_state_lr_cpu;
|
save_state_lr = &mut SAVE_STATE_LR_CPU;
|
||||||
save_state_situation_kind = &mut save_state_situation_kind_cpu;
|
save_state_situation_kind = &mut SAVE_STATE_SITUATION_KIND_CPU;
|
||||||
save_state = &mut save_state_cpu_state;
|
save_state = &mut SAVE_STATE_CPU_STATE;
|
||||||
} else {
|
} else {
|
||||||
save_state_x = &mut save_state_x_player;
|
save_state_x = &mut SAVE_STATE_X_PLAYER;
|
||||||
save_state_y = &mut save_state_y_player;
|
save_state_y = &mut SAVE_STATE_Y_PLAYER;
|
||||||
save_state_percent = &mut save_state_percent_player;
|
save_state_percent = &mut SAVE_STATE_PERCENT_PLAYER;
|
||||||
save_state_lr = &mut save_state_lr_player;
|
save_state_lr = &mut SAVE_STATE_LR_PLAYER;
|
||||||
save_state_situation_kind = &mut save_state_situation_kind_player;
|
save_state_situation_kind = &mut SAVE_STATE_SITUATION_KIND_PLAYER;
|
||||||
save_state = &mut save_state_player_state;
|
save_state = &mut SAVE_STATE_PLAYER_STATE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Grab + Dpad up: reset state
|
// Grab + Dpad up: reset state
|
||||||
if ControlModule::check_button_on(module_accessor, *CONTROL_PAD_BUTTON_CATCH) != 0
|
if ControlModule::check_button_on(module_accessor, *CONTROL_PAD_BUTTON_CATCH)
|
||||||
&& ControlModule::check_button_trigger(module_accessor, *CONTROL_PAD_BUTTON_APPEAL_HI)
|
&& ControlModule::check_button_trigger(module_accessor, *CONTROL_PAD_BUTTON_APPEAL_HI)
|
||||||
!= 0
|
|
||||||
{
|
{
|
||||||
if *save_state == NoAction {
|
if *save_state == NoAction {
|
||||||
save_state_player_state = CameraMove;
|
SAVE_STATE_PLAYER_STATE = CameraMove;
|
||||||
save_state_cpu_state = CameraMove;
|
SAVE_STATE_CPU_STATE = CameraMove;
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -152,12 +149,11 @@ pub unsafe fn save_states(module_accessor: &mut app::BattleObjectModuleAccessor)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Grab + Dpad down: Save state
|
// Grab + Dpad down: Save state
|
||||||
if ControlModule::check_button_on(module_accessor, *CONTROL_PAD_BUTTON_CATCH) != 0
|
if ControlModule::check_button_on(module_accessor, *CONTROL_PAD_BUTTON_CATCH)
|
||||||
&& ControlModule::check_button_trigger(module_accessor, *CONTROL_PAD_BUTTON_APPEAL_LW)
|
&& ControlModule::check_button_trigger(module_accessor, *CONTROL_PAD_BUTTON_APPEAL_LW)
|
||||||
!= 0
|
|
||||||
{
|
{
|
||||||
save_state_player_state = Save;
|
SAVE_STATE_PLAYER_STATE = Save;
|
||||||
save_state_cpu_state = Save;
|
SAVE_STATE_CPU_STATE = Save;
|
||||||
}
|
}
|
||||||
|
|
||||||
if *save_state == Save {
|
if *save_state == Save {
|
|
@ -1,16 +1,16 @@
|
||||||
use crate::common::consts::*;
|
use crate::common::consts::*;
|
||||||
use crate::common::*;
|
use crate::common::*;
|
||||||
use smash::app::{self};
|
use smash::app;
|
||||||
use smash::hash40;
|
use smash::hash40;
|
||||||
use smash::lib::lua_const::*;
|
use smash::lib::lua_const::*;
|
||||||
|
|
||||||
pub unsafe fn get_param_float(
|
pub unsafe fn get_param_float(
|
||||||
module_accessor: &mut app::BattleObjectModuleAccessor,
|
_module_accessor: &mut app::BattleObjectModuleAccessor,
|
||||||
param_type: u64,
|
param_type: u64,
|
||||||
param_hash: u64,
|
param_hash: u64,
|
||||||
) -> Option<f32> {
|
) -> Option<f32> {
|
||||||
if is_training_mode() {
|
if is_training_mode() {
|
||||||
if (*menu).SHIELD_STATE == SHIELD_INFINITE {
|
if MENU.shield_state == Shield::Infinite {
|
||||||
if param_type == hash40("common") {
|
if param_type == hash40("common") {
|
||||||
if param_hash == hash40("shield_dec1") {
|
if param_hash == hash40("shield_dec1") {
|
||||||
return Some(0.0);
|
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 {
|
pub unsafe fn should_hold_shield(module_accessor: &mut app::BattleObjectModuleAccessor) -> bool {
|
||||||
// We should hold shield if the state requires it
|
// 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 we are not mashing then we will always hold shield
|
||||||
if (*menu).MASH_STATE == NONE {
|
if MENU.mash_state == Mash::None {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -42,15 +42,19 @@ 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
|
// We will only drop shield if we are in shieldstun and our attack can be performed OOS
|
||||||
if (*menu).MASH_STATE == MASH_ATTACK {
|
if MENU.mash_state == Mash::Attack {
|
||||||
if [MASH_NEUTRAL_B, MASH_SIDE_B, MASH_DOWN_B].contains(&(*menu).ATTACK_STATE) {
|
if [Attack::NeutralB, Attack::SideB, Attack::DownB].contains(&MENU.mash_attack_state) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if [MASH_SPOTDODGE, MASH_GRAB].contains(&(*menu).ATTACK_STATE) {
|
if MENU.mash_attack_state == Attack::Grab {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if MENU.mash_state == Mash::Spotdodge {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
false
|
false
|
|
@ -1,7 +1,6 @@
|
||||||
use crate::common::consts::*;
|
use crate::common::consts::*;
|
||||||
use crate::common::*;
|
use crate::common::*;
|
||||||
use smash::app::lua_bind::*;
|
use smash::app::{self, lua_bind::*};
|
||||||
use smash::app::{self};
|
|
||||||
use smash::hash40;
|
use smash::hash40;
|
||||||
use smash::lib::lua_const::*;
|
use smash::lib::lua_const::*;
|
||||||
|
|
||||||
|
@ -11,8 +10,8 @@ pub unsafe fn init_settings(
|
||||||
) -> Option<()> {
|
) -> Option<()> {
|
||||||
if is_training_mode() && is_operation_cpu(module_accessor) {
|
if is_training_mode() && is_operation_cpu(module_accessor) {
|
||||||
if status_kind == FIGHTER_STATUS_KIND_DOWN {
|
if status_kind == FIGHTER_STATUS_KIND_DOWN {
|
||||||
match (*menu).TECH_STATE {
|
match MENU.tech_state {
|
||||||
RANDOM_TECH => {
|
TechOption::Random => {
|
||||||
let random_statuses = vec![
|
let random_statuses = vec![
|
||||||
*FIGHTER_STATUS_KIND_DOWN,
|
*FIGHTER_STATUS_KIND_DOWN,
|
||||||
*FIGHTER_STATUS_KIND_PASSIVE,
|
*FIGHTER_STATUS_KIND_PASSIVE,
|
||||||
|
@ -31,7 +30,7 @@ pub unsafe fn init_settings(
|
||||||
return Some(());
|
return Some(());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
TECH_IN_PLACE => {
|
TechOption::InPlace => {
|
||||||
StatusModule::change_status_request_from_script(
|
StatusModule::change_status_request_from_script(
|
||||||
module_accessor,
|
module_accessor,
|
||||||
*FIGHTER_STATUS_KIND_PASSIVE,
|
*FIGHTER_STATUS_KIND_PASSIVE,
|
||||||
|
@ -39,7 +38,7 @@ pub unsafe fn init_settings(
|
||||||
);
|
);
|
||||||
return Some(());
|
return Some(());
|
||||||
}
|
}
|
||||||
TECH_ROLL => {
|
TechOption::Roll => {
|
||||||
StatusModule::change_status_request_from_script(
|
StatusModule::change_status_request_from_script(
|
||||||
module_accessor,
|
module_accessor,
|
||||||
*FIGHTER_STATUS_KIND_PASSIVE_FB,
|
*FIGHTER_STATUS_KIND_PASSIVE_FB,
|
||||||
|
@ -87,10 +86,10 @@ pub unsafe fn should_perform_defensive_option(
|
||||||
|
|
||||||
pub unsafe fn get_command_flag_cat(
|
pub unsafe fn get_command_flag_cat(
|
||||||
module_accessor: &mut app::BattleObjectModuleAccessor,
|
module_accessor: &mut app::BattleObjectModuleAccessor,
|
||||||
category: i32,
|
_category: i32,
|
||||||
flag: &mut i32,
|
flag: &mut i32,
|
||||||
) {
|
) {
|
||||||
if (*menu).TECH_STATE != NONE && is_training_mode() && is_operation_cpu(module_accessor) {
|
if MENU.tech_state != TechOption::None && 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 [
|
if [
|
||||||
|
@ -126,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);
|
||||||
|
@ -141,7 +140,7 @@ pub unsafe fn change_motion(
|
||||||
module_accessor: &mut app::BattleObjectModuleAccessor,
|
module_accessor: &mut app::BattleObjectModuleAccessor,
|
||||||
motion_kind: u64,
|
motion_kind: u64,
|
||||||
) -> Option<u64> {
|
) -> Option<u64> {
|
||||||
if (*menu).TECH_STATE != NONE && is_training_mode() && is_operation_cpu(module_accessor) {
|
if MENU.tech_state != TechOption::None && is_training_mode() && is_operation_cpu(module_accessor) {
|
||||||
if [hash40("passive_stand_f"), hash40("passive_stand_b")].contains(&motion_kind) {
|
if [hash40("passive_stand_f"), hash40("passive_stand_b")].contains(&motion_kind) {
|
||||||
if app::sv_math::rand(hash40("fighter"), 2) != 0 {
|
if app::sv_math::rand(hash40("fighter"), 2) != 0 {
|
||||||
return Some(hash40("passive_stand_f"));
|
return Some(hash40("passive_stand_f"));
|
Loading…
Add table
Reference in a new issue