1
0
Fork 0
mirror of https://github.com/jugeeya/UltimateTrainingModpack.git synced 2024-11-24 10:54:16 +00:00

Format Rust code using rustfmt

This commit is contained in:
github-actions[bot] 2022-05-08 20:43:20 +00:00 committed by GitHub
parent 365d8107dc
commit cef391b519
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1,253 +1,257 @@
use crate::common::consts::*; use crate::common::consts::*;
use crate::is_operation_cpu; use crate::is_operation_cpu;
use crate::training::frame_counter; use crate::training::frame_counter;
use crate::training::handle_add_limit; 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::*;
static mut BUFF_DELAY_COUNTER: usize = 0; static mut BUFF_DELAY_COUNTER: usize = 0;
static mut BUFF_REMAINING_PLAYER: i32 = 0; static mut BUFF_REMAINING_PLAYER: i32 = 0;
static mut BUFF_REMAINING_CPU: i32 = 0; static mut BUFF_REMAINING_CPU: i32 = 0;
static mut IS_BUFFING_PLAYER: bool = false; static mut IS_BUFFING_PLAYER: bool = false;
static mut IS_BUFFING_CPU: bool = false; static mut IS_BUFFING_CPU: bool = false;
pub fn init() { pub fn init() {
unsafe { unsafe {
BUFF_DELAY_COUNTER = frame_counter::register_counter(); BUFF_DELAY_COUNTER = frame_counter::register_counter();
} }
} }
pub unsafe fn restart_buff(module_accessor: &mut app::BattleObjectModuleAccessor) { pub unsafe fn restart_buff(module_accessor: &mut app::BattleObjectModuleAccessor) {
if is_operation_cpu(module_accessor) { if is_operation_cpu(module_accessor) {
IS_BUFFING_CPU = false; IS_BUFFING_CPU = false;
return; return;
} }
IS_BUFFING_PLAYER = false; IS_BUFFING_PLAYER = false;
} }
pub unsafe fn start_buff(module_accessor: &mut app::BattleObjectModuleAccessor) { pub unsafe fn start_buff(module_accessor: &mut app::BattleObjectModuleAccessor) {
if is_operation_cpu(module_accessor) { if is_operation_cpu(module_accessor) {
IS_BUFFING_CPU = true; IS_BUFFING_CPU = true;
return; return;
} }
IS_BUFFING_PLAYER = true; IS_BUFFING_PLAYER = true;
} }
pub unsafe fn is_buffing(module_accessor: &mut app::BattleObjectModuleAccessor) -> bool { pub unsafe fn is_buffing(module_accessor: &mut app::BattleObjectModuleAccessor) -> bool {
if is_operation_cpu(module_accessor) { if is_operation_cpu(module_accessor) {
return IS_BUFFING_CPU; return IS_BUFFING_CPU;
} }
IS_BUFFING_PLAYER IS_BUFFING_PLAYER
} }
pub unsafe fn set_buff_rem(module_accessor: &mut app::BattleObjectModuleAccessor, new_value: i32) { pub unsafe fn set_buff_rem(module_accessor: &mut app::BattleObjectModuleAccessor, new_value: i32) {
if is_operation_cpu(module_accessor) { if is_operation_cpu(module_accessor) {
BUFF_REMAINING_CPU = new_value; BUFF_REMAINING_CPU = new_value;
return; return;
} }
BUFF_REMAINING_PLAYER = new_value; BUFF_REMAINING_PLAYER = new_value;
} }
pub unsafe fn get_buff_rem(module_accessor: &mut app::BattleObjectModuleAccessor) -> i32 { pub unsafe fn get_buff_rem(module_accessor: &mut app::BattleObjectModuleAccessor) -> i32 {
if is_operation_cpu(module_accessor) { if is_operation_cpu(module_accessor) {
return BUFF_REMAINING_CPU; return BUFF_REMAINING_CPU;
} }
BUFF_REMAINING_PLAYER BUFF_REMAINING_PLAYER
} }
fn get_spell_vec() -> Vec<BuffOption> { fn get_spell_vec() -> Vec<BuffOption> {
unsafe { unsafe {
let menu_buff = MENU.buff_state.to_vec(); let menu_buff = MENU.buff_state.to_vec();
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);
} }
} }
spell_buff spell_buff
} }
} }
pub unsafe fn handle_buffs( pub unsafe fn handle_buffs(
module_accessor: &mut app::BattleObjectModuleAccessor, module_accessor: &mut app::BattleObjectModuleAccessor,
fighter_kind: i32, fighter_kind: i32,
status: i32, status: i32,
percent: f32, percent: f32,
) -> bool { ) -> 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);
CameraModule::stop_quake(module_accessor, *CAMERA_QUAKE_KIND_M); // stops Psyche-Up quake CameraModule::stop_quake(module_accessor, *CAMERA_QUAKE_KIND_M); // stops Psyche-Up quake
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, percent); return buff_wiifit(module_accessor, status, percent);
} 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) {
return buff_mac(module_accessor); return buff_mac(module_accessor);
} else if fighter_kind == *FIGHTER_KIND_EDGE && menu_vec.contains(&BuffOption::WING) { } else if fighter_kind == *FIGHTER_KIND_EDGE && menu_vec.contains(&BuffOption::WING) {
return buff_sepiroth(module_accessor, percent); return buff_sepiroth(module_accessor, percent);
} }
true true
} }
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;
} }
buff_hero_single(module_accessor, status, buff_vec); buff_hero_single(module_accessor, status, buff_vec);
false false
} }
unsafe fn buff_hero_single( unsafe fn buff_hero_single(
module_accessor: &mut app::BattleObjectModuleAccessor, module_accessor: &mut app::BattleObjectModuleAccessor,
status: i32, status: i32,
buff_vec: Vec<BuffOption>, 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( WorkModule::set_int(
module_accessor, module_accessor,
real_spell_value, real_spell_value,
*FIGHTER_BRAVE_INSTANCE_WORK_ID_INT_SPECIAL_LW_DECIDE_COMMAND, *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_u32, BUFF_DELAY_COUNTER) { if frame_counter::should_delay(2_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;
} }
true true
} }
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) { if !is_buffing(module_accessor) {
// Only need to add to the rebel gauge once // 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_u32, BUFF_DELAY_COUNTER) { if frame_counter::should_delay(2_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;
} }
true true
} }
unsafe fn buff_mac(module_accessor: &mut app::BattleObjectModuleAccessor) -> bool { unsafe fn buff_mac(module_accessor: &mut app::BattleObjectModuleAccessor) -> bool {
WorkModule::set_float( WorkModule::set_float(
module_accessor, module_accessor,
100.0, 100.0,
*FIGHTER_LITTLEMAC_INSTANCE_WORK_ID_FLOAT_KO_GAGE, *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
true true
} }
unsafe fn buff_sepiroth( unsafe fn buff_sepiroth(
module_accessor: &mut app::BattleObjectModuleAccessor, module_accessor: &mut app::BattleObjectModuleAccessor,
percent: f32, percent: f32,
) -> bool { ) -> bool {
start_buff(module_accessor); start_buff(module_accessor);
if WorkModule::get_int( if WorkModule::get_int(
module_accessor, module_accessor,
*FIGHTER_EDGE_INSTANCE_WORK_ID_INT_ONE_WINGED_WING_STATE, *FIGHTER_EDGE_INSTANCE_WORK_ID_INT_ONE_WINGED_WING_STATE,
) == 1 ) == 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,
-1.0 * DamageModule::damage(module_accessor, 0), -1.0 * DamageModule::damage(module_accessor, 0),
0, 0,
); );
DamageModule::add_damage(module_accessor, percent, 0); DamageModule::add_damage(module_accessor, percent, 0);
return true; return true;
} else { } else {
// if we're not in wing, add damage // if we're not in wing, add damage
DamageModule::add_damage(module_accessor, 1000.0, 0); DamageModule::add_damage(module_accessor, 1000.0, 0);
} }
false false
} }
unsafe fn buff_wiifit(module_accessor: &mut app::BattleObjectModuleAccessor, status: i32, percent: f32) -> bool { unsafe fn buff_wiifit(
if is_buffing(module_accessor) { module_accessor: &mut app::BattleObjectModuleAccessor,
if frame_counter::should_delay(2_u32, BUFF_DELAY_COUNTER) { status: i32,
// Need to wait 2 frames to make sure we stop breathing SFX percent: f32,
return false; ) -> bool {
} if is_buffing(module_accessor) {
// Deep Breathing can heal, so we need to reset the damage if frame_counter::should_delay(2_u32, BUFF_DELAY_COUNTER) {
DamageModule::heal( // Need to wait 2 frames to make sure we stop breathing SFX
module_accessor, return false;
-1.0 * DamageModule::damage(module_accessor, 0), }
0, // Deep Breathing can heal, so we need to reset the damage
); DamageModule::heal(
DamageModule::add_damage(module_accessor, percent, 0); module_accessor,
return true; -1.0 * DamageModule::damage(module_accessor, 0),
} 0,
let prev_status_kind = StatusModule::prev_status_kind(module_accessor, 0); );
if prev_status_kind == FIGHTER_WIIFIT_STATUS_KIND_SPECIAL_LW_SUCCESS { DamageModule::add_damage(module_accessor, percent, 0);
start_buff(module_accessor); return true;
return false; }
} let prev_status_kind = StatusModule::prev_status_kind(module_accessor, 0);
if status != FIGHTER_WIIFIT_STATUS_KIND_SPECIAL_LW_SUCCESS { if prev_status_kind == FIGHTER_WIIFIT_STATUS_KIND_SPECIAL_LW_SUCCESS {
StatusModule::change_status_force( start_buff(module_accessor);
module_accessor, return false;
*FIGHTER_WIIFIT_STATUS_KIND_SPECIAL_LW_SUCCESS, }
false, if status != FIGHTER_WIIFIT_STATUS_KIND_SPECIAL_LW_SUCCESS {
); StatusModule::change_status_force(
} else { module_accessor,
MotionModule::set_rate(module_accessor, 40.0); *FIGHTER_WIIFIT_STATUS_KIND_SPECIAL_LW_SUCCESS,
} false,
false );
} } else {
MotionModule::set_rate(module_accessor, 40.0);
}
false
}