1
0
Fork 0
mirror of https://github.com/jugeeya/UltimateTrainingModpack.git synced 2025-03-05 14:22:19 +00:00

Format Rust code using rustfmt

This commit is contained in:
github-actions[bot] 2022-01-27 22:03:11 +00:00 committed by GitHub
parent b598aaeee2
commit d2c7ebe9ea
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 87 additions and 46 deletions

View file

@ -1,10 +1,10 @@
use crate::common::consts::*; use crate::common::consts::*;
use crate::common::*; use crate::common::*;
use crate::is_operation_cpu;
use crate::training::frame_counter;
use crate::training::handle_add_limit;
use smash::app::{self, lua_bind::*}; use smash::app::{self, lua_bind::*};
use smash::lib::lua_const::*; use smash::lib::lua_const::*;
use crate::training::handle_add_limit;
use crate::training::frame_counter;
use crate::is_operation_cpu;
static mut BUFF_DELAY_COUNTER: usize = 0; static mut BUFF_DELAY_COUNTER: usize = 0;
@ -64,16 +64,21 @@ fn get_spell_vec() -> Vec<BuffOption> {
let menu_iter = menu_buff.iter(); let menu_iter = menu_buff.iter();
let mut spell_buff: Vec<BuffOption> = Vec::new(); let mut spell_buff: Vec<BuffOption> = Vec::new();
for buff in menu_iter { for buff in menu_iter {
if buff.into_int().unwrap_or(1) != 1 { if buff.into_int().unwrap_or(1) != 1 {
// all non-spells into_int as 1 // all non-spells into_int as 1
spell_buff.push(*buff); spell_buff.push(*buff);
} }
} }
return spell_buff; return spell_buff;
} }
} }
pub unsafe fn handle_buffs(module_accessor: &mut app::BattleObjectModuleAccessor, fighter_kind: i32, status: i32, percent: f32) -> bool { pub unsafe fn handle_buffs(
module_accessor: &mut app::BattleObjectModuleAccessor,
fighter_kind: i32,
status: i32,
percent: f32,
) -> bool {
SoundModule::stop_all_sound(module_accessor); // silences buff sfx other than KO Punch SoundModule::stop_all_sound(module_accessor); // silences buff sfx other than KO Punch
ControlModule::stop_rumble(module_accessor, false); ControlModule::stop_rumble(module_accessor, false);
MotionAnimcmdModule::set_sleep(module_accessor, false); MotionAnimcmdModule::set_sleep(module_accessor, false);
@ -81,11 +86,11 @@ pub unsafe fn handle_buffs(module_accessor: &mut app::BattleObjectModuleAccessor
let menu_vec = MENU.buff_state.to_vec(); let menu_vec = MENU.buff_state.to_vec();
if fighter_kind == *FIGHTER_KIND_BRAVE { if fighter_kind == *FIGHTER_KIND_BRAVE {
return buff_hero(module_accessor,status); return buff_hero(module_accessor, status);
} else if fighter_kind == *FIGHTER_KIND_JACK && menu_vec.contains(&BuffOption::ARSENE) { } else if fighter_kind == *FIGHTER_KIND_JACK && menu_vec.contains(&BuffOption::ARSENE) {
return buff_joker(module_accessor); return buff_joker(module_accessor);
} else if fighter_kind == *FIGHTER_KIND_WIIFIT && menu_vec.contains(&BuffOption::BREATHING) { } else if fighter_kind == *FIGHTER_KIND_WIIFIT && menu_vec.contains(&BuffOption::BREATHING) {
return buff_wiifit(module_accessor,status); return buff_wiifit(module_accessor, status);
} else if fighter_kind == *FIGHTER_KIND_CLOUD && menu_vec.contains(&BuffOption::LIMIT) { } else if fighter_kind == *FIGHTER_KIND_CLOUD && menu_vec.contains(&BuffOption::LIMIT) {
return buff_cloud(module_accessor); return buff_cloud(module_accessor);
} else if fighter_kind == *FIGHTER_KIND_LITTLEMAC && menu_vec.contains(&BuffOption::KO) { } else if fighter_kind == *FIGHTER_KIND_LITTLEMAC && menu_vec.contains(&BuffOption::KO) {
@ -99,13 +104,13 @@ pub unsafe fn handle_buffs(module_accessor: &mut app::BattleObjectModuleAccessor
unsafe fn buff_hero(module_accessor: &mut app::BattleObjectModuleAccessor, status: i32) -> bool { unsafe fn buff_hero(module_accessor: &mut app::BattleObjectModuleAccessor, status: i32) -> bool {
let buff_vec = get_spell_vec(); let buff_vec = get_spell_vec();
if !is_buffing(module_accessor) { if !is_buffing(module_accessor) {
// Initial set up for spells // Initial set up for spells
start_buff(module_accessor); start_buff(module_accessor);
set_buff_rem(module_accessor,buff_vec.len() as i32); set_buff_rem(module_accessor, buff_vec.len() as i32);
// Since it's the first step of buffing, we need to set up how many buffs there are // Since it's the first step of buffing, we need to set up how many buffs there are
} }
if get_buff_rem(module_accessor) <= 0 { if get_buff_rem(module_accessor) <= 0 {
// If there are no buffs selected/left, we're done // If there are no buffs selected/left, we're done
return true; return true;
} }
@ -113,42 +118,50 @@ unsafe fn buff_hero(module_accessor: &mut app::BattleObjectModuleAccessor, statu
return false; return false;
} }
unsafe fn buff_hero_single(module_accessor: &mut app::BattleObjectModuleAccessor, status: i32, buff_vec: Vec<BuffOption>) { unsafe fn buff_hero_single(
module_accessor: &mut app::BattleObjectModuleAccessor,
status: i32,
buff_vec: Vec<BuffOption>,
) {
let prev_status_kind = StatusModule::prev_status_kind(module_accessor, 0); let prev_status_kind = StatusModule::prev_status_kind(module_accessor, 0);
if prev_status_kind == FIGHTER_BRAVE_STATUS_KIND_SPECIAL_LW_START { if prev_status_kind == FIGHTER_BRAVE_STATUS_KIND_SPECIAL_LW_START {
// If we just applied a buff successfully, subtract from buffs remaining // If we just applied a buff successfully, subtract from buffs remaining
let new_rem_value = get_buff_rem(module_accessor) - 1; let new_rem_value = get_buff_rem(module_accessor) - 1;
set_buff_rem(module_accessor, new_rem_value); set_buff_rem(module_accessor, new_rem_value);
} }
let spell_index = get_buff_rem(module_accessor) - 1; let spell_index = get_buff_rem(module_accessor) - 1;
// Used to get spell from our vector // Used to get spell from our vector
let spell_option = buff_vec.get(spell_index as usize); let spell_option = buff_vec.get(spell_index as usize);
if spell_option.is_none() { if spell_option.is_none() {
// There are no spells selected, or something went wrong with making the vector // There are no spells selected, or something went wrong with making the vector
return; return;
} }
let real_spell_value = spell_option.unwrap().into_int().unwrap(); let real_spell_value = spell_option.unwrap().into_int().unwrap();
if status != FIGHTER_BRAVE_STATUS_KIND_SPECIAL_LW_START { if status != FIGHTER_BRAVE_STATUS_KIND_SPECIAL_LW_START {
WorkModule::set_int(module_accessor, real_spell_value, *FIGHTER_BRAVE_INSTANCE_WORK_ID_INT_SPECIAL_LW_DECIDE_COMMAND); WorkModule::set_int(
module_accessor,
real_spell_value,
*FIGHTER_BRAVE_INSTANCE_WORK_ID_INT_SPECIAL_LW_DECIDE_COMMAND,
);
StatusModule::change_status_force( StatusModule::change_status_force(
module_accessor, module_accessor,
*FIGHTER_BRAVE_STATUS_KIND_SPECIAL_LW_START, *FIGHTER_BRAVE_STATUS_KIND_SPECIAL_LW_START,
true, true,
// True to prevent Shielding over the spells // True to prevent Shielding over the spells
); );
} }
if status == FIGHTER_BRAVE_STATUS_KIND_SPECIAL_LW_START { if status == FIGHTER_BRAVE_STATUS_KIND_SPECIAL_LW_START {
MotionModule::set_rate(module_accessor, 50.0); MotionModule::set_rate(module_accessor, 50.0);
} }
} }
unsafe fn buff_cloud(module_accessor: &mut app::BattleObjectModuleAccessor) -> bool { unsafe fn buff_cloud(module_accessor: &mut app::BattleObjectModuleAccessor) -> bool {
if !is_buffing(module_accessor) { if !is_buffing(module_accessor) {
// Only need to add to the limit gauge once // Only need to add to the limit gauge once
start_buff(module_accessor); start_buff(module_accessor);
handle_add_limit(100.0,module_accessor,0); handle_add_limit(100.0, module_accessor, 0);
} }
if frame_counter::should_delay(2 as u32, BUFF_DELAY_COUNTER) { if frame_counter::should_delay(2 as u32, BUFF_DELAY_COUNTER) {
// Need to wait 2 frames to make sure we stop the limit SFX, since it's a bit delayed // Need to wait 2 frames to make sure we stop the limit SFX, since it's a bit delayed
return false; return false;
} }
@ -156,30 +169,42 @@ unsafe fn buff_cloud(module_accessor: &mut app::BattleObjectModuleAccessor) -> b
} }
unsafe fn buff_joker(module_accessor: &mut app::BattleObjectModuleAccessor) -> bool { unsafe fn buff_joker(module_accessor: &mut app::BattleObjectModuleAccessor) -> bool {
if !is_buffing(module_accessor) { // Only need to add to the rebel gauge once if !is_buffing(module_accessor) {
// Only need to add to the rebel gauge once
start_buff(module_accessor); start_buff(module_accessor);
let entry_id = app::FighterEntryID(FighterId::CPU as i32); let entry_id = app::FighterEntryID(FighterId::CPU as i32);
// Strangely, this doesn't actually matter and works for both fighters // Strangely, this doesn't actually matter and works for both fighters
app::FighterSpecializer_Jack::add_rebel_gauge(module_accessor, entry_id, 120.0); app::FighterSpecializer_Jack::add_rebel_gauge(module_accessor, entry_id, 120.0);
} }
if frame_counter::should_delay(2 as u32, BUFF_DELAY_COUNTER) { if frame_counter::should_delay(2 as u32, BUFF_DELAY_COUNTER) {
// Need to wait 2 frames to make sure we stop the voice call, since it's a bit delayed // Need to wait 2 frames to make sure we stop the voice call, since it's a bit delayed
return false; return false;
} }
return true; return true;
} }
unsafe fn buff_mac(module_accessor: &mut app::BattleObjectModuleAccessor) -> bool { unsafe fn buff_mac(module_accessor: &mut app::BattleObjectModuleAccessor) -> bool {
WorkModule::set_float(module_accessor, 100.0, *FIGHTER_LITTLEMAC_INSTANCE_WORK_ID_FLOAT_KO_GAGE); WorkModule::set_float(
module_accessor,
100.0,
*FIGHTER_LITTLEMAC_INSTANCE_WORK_ID_FLOAT_KO_GAGE,
);
// Trying to stop KO Punch from playing seems to make it play multiple times in rapid succession // Trying to stop KO Punch from playing seems to make it play multiple times in rapid succession
// Look at 0x7100c44b60 for the func that handles this // Look at 0x7100c44b60 for the func that handles this
// Need to figure out how to update the KO meter if this is fixed // Need to figure out how to update the KO meter if this is fixed
return true; return true;
} }
unsafe fn buff_sepiroth(module_accessor: &mut app::BattleObjectModuleAccessor, percent: f32) -> bool { unsafe fn buff_sepiroth(
module_accessor: &mut app::BattleObjectModuleAccessor,
percent: f32,
) -> bool {
start_buff(module_accessor); start_buff(module_accessor);
if WorkModule::get_int(module_accessor, *FIGHTER_EDGE_INSTANCE_WORK_ID_INT_ONE_WINGED_WING_STATE) == 1 { if WorkModule::get_int(
module_accessor,
*FIGHTER_EDGE_INSTANCE_WORK_ID_INT_ONE_WINGED_WING_STATE,
) == 1
{
// Once we're in wing, heal to correct damage // Once we're in wing, heal to correct damage
DamageModule::heal( DamageModule::heal(
module_accessor, module_accessor,
@ -188,7 +213,8 @@ unsafe fn buff_sepiroth(module_accessor: &mut app::BattleObjectModuleAccessor, p
); );
DamageModule::add_damage(module_accessor, percent, 0); DamageModule::add_damage(module_accessor, percent, 0);
return true; return true;
} else { // if we're not in wing, add damage } else {
// if we're not in wing, add damage
DamageModule::add_damage(module_accessor, 1000.0, 0); DamageModule::add_damage(module_accessor, 1000.0, 0);
} }
return false; return false;
@ -196,7 +222,7 @@ unsafe fn buff_sepiroth(module_accessor: &mut app::BattleObjectModuleAccessor, p
unsafe fn buff_wiifit(module_accessor: &mut app::BattleObjectModuleAccessor, status: i32) -> bool { unsafe fn buff_wiifit(module_accessor: &mut app::BattleObjectModuleAccessor, status: i32) -> bool {
if is_buffing(module_accessor) { if is_buffing(module_accessor) {
if frame_counter::should_delay(2 as u32, BUFF_DELAY_COUNTER) { if frame_counter::should_delay(2 as u32, BUFF_DELAY_COUNTER) {
// Need to wait 2 frames to make sure we stop breathing SFX // Need to wait 2 frames to make sure we stop breathing SFX
return false; return false;
} }

View file

@ -7,6 +7,7 @@ use smash::lib::lua_const::*;
use smash::params::*; use smash::params::*;
use smash::phx::Hash40; use smash::phx::Hash40;
pub mod buff;
pub mod combo; pub mod combo;
pub mod directional_influence; pub mod directional_influence;
pub mod frame_counter; pub mod frame_counter;
@ -15,7 +16,6 @@ pub mod sdi;
pub mod shield; pub mod shield;
pub mod tech; pub mod tech;
pub mod throw; pub mod throw;
pub mod buff;
mod air_dodge_direction; mod air_dodge_direction;
mod attack_angle; mod attack_angle;
@ -309,26 +309,41 @@ fn params_main(params_info: &ParamsInfo<'_>) {
static CLOUD_ADD_LIMIT_OFFSET: usize = 0x008dc140; // this function is used to add limit to Cloud's limit gauge. Hooking it here so we can call it in buff.rs static CLOUD_ADD_LIMIT_OFFSET: usize = 0x008dc140; // this function is used to add limit to Cloud's limit gauge. Hooking it here so we can call it in buff.rs
#[skyline::hook(offset = CLOUD_ADD_LIMIT_OFFSET)] #[skyline::hook(offset = CLOUD_ADD_LIMIT_OFFSET)]
pub unsafe fn handle_add_limit(add_limit: f32, module_accessor: &mut app::BattleObjectModuleAccessor, is_special_lw: u64) { pub unsafe fn handle_add_limit(
original!()(add_limit,module_accessor,is_special_lw) add_limit: f32,
module_accessor: &mut app::BattleObjectModuleAccessor,
is_special_lw: u64,
) {
original!()(add_limit, module_accessor, is_special_lw)
} }
#[skyline::hook(replace = EffectModule::req_screen)] // hooked to prevent the screen from darkening when loading a save state with One-Winged Angel #[skyline::hook(replace = EffectModule::req_screen)] // hooked to prevent the screen from darkening when loading a save state with One-Winged Angel
pub unsafe fn handle_req_screen(module_accessor: &mut app::BattleObjectModuleAccessor, my_hash: Hash40, bool_1:bool, bool_2:bool, bool_3:bool) -> u64 { pub unsafe fn handle_req_screen(
module_accessor: &mut app::BattleObjectModuleAccessor,
my_hash: Hash40,
bool_1: bool,
bool_2: bool,
bool_3: bool,
) -> u64 {
if !is_training_mode() { if !is_training_mode() {
return original!()(module_accessor,my_hash,bool_1,bool_2,bool_3); return original!()(module_accessor, my_hash, bool_1, bool_2, bool_3);
} }
let new_hash = my_hash.hash; let new_hash = my_hash.hash;
if new_hash == 72422354958 && buff::is_buffing(module_accessor) { // Wing bg hash if new_hash == 72422354958 && buff::is_buffing(module_accessor) {
// Wing bg hash
let replace_hash = Hash40::new("bg"); let replace_hash = Hash40::new("bg");
return original!()(module_accessor,replace_hash,bool_1,bool_2,bool_3); return original!()(module_accessor, replace_hash, bool_1, bool_2, bool_3);
} }
original!()(module_accessor,my_hash,bool_1,bool_2,bool_3) original!()(module_accessor, my_hash, bool_1, bool_2, bool_3)
} }
#[skyline::hook(replace = app::FighterSpecializer_Jack::check_doyle_summon_dispatch)] // returns status of summon dispatch if triggered, -1 as u64 otherwise #[skyline::hook(replace = app::FighterSpecializer_Jack::check_doyle_summon_dispatch)] // returns status of summon dispatch if triggered, -1 as u64 otherwise
pub unsafe fn handle_check_doyle_summon_dispatch(module_accessor: &mut app::BattleObjectModuleAccessor, bool_1: bool, bool_2: bool) -> u64 { pub unsafe fn handle_check_doyle_summon_dispatch(
let ori = original!()(module_accessor,bool_1,bool_2); module_accessor: &mut app::BattleObjectModuleAccessor,
bool_1: bool,
bool_2: bool,
) -> u64 {
let ori = original!()(module_accessor, bool_1, bool_2);
if !is_training_mode() { if !is_training_mode() {
return ori; return ori;
} }

View file

@ -3,8 +3,8 @@ use crate::common::consts::OnOff;
use crate::common::consts::SaveStateMirroring; use crate::common::consts::SaveStateMirroring;
use crate::common::MENU; use crate::common::MENU;
use crate::common::{get_random_int, is_dead}; use crate::common::{get_random_int, is_dead};
use crate::training::reset;
use crate::training::buff; use crate::training::buff;
use crate::training::reset;
use smash::app::{self, lua_bind::*}; use smash::app::{self, lua_bind::*};
use smash::hash40; use smash::hash40;
use smash::lib::lua_const::*; use smash::lib::lua_const::*;
@ -283,14 +283,14 @@ pub unsafe fn save_states(module_accessor: &mut app::BattleObjectModuleAccessor)
return; return;
} }
if save_state.state == ApplyBuff { if save_state.state == ApplyBuff {
// needs its own save_state.state since this may take multiple frames, want it to loop // needs its own save_state.state since this may take multiple frames, want it to loop
if buff::handle_buffs(module_accessor, fighter_kind, status, save_state.percent) { if buff::handle_buffs(module_accessor, fighter_kind, status, save_state.percent) {
// returns true when done buffing fighter // returns true when done buffing fighter
buff::restart_buff(module_accessor); buff::restart_buff(module_accessor);
// set is_buffing back to false when done // set is_buffing back to false when done
save_state.state = NoAction; save_state.state = NoAction;
} }
} }