From 633686c6c1097252816a0cad847866659486acd0 Mon Sep 17 00:00:00 2001 From: Mohammad Saad Date: Thu, 7 Sep 2023 13:40:37 -0400 Subject: [PATCH] Add Wario waft options to buff menu (#626) * add wario waft options to buff menu * remove comment * get waft threshold values from params rather than guessing * more friendly menu names * set GASS_LEVEL to be safe * format and cleanup * use match instead of if * fix compile warning * Fix clippy * Fix clippy again * fix formatting again --------- Co-authored-by: jugeeya --- src/training/buff.rs | 40 ++++++++++++++++++++++++++++++ src/training/save_states.rs | 1 + training_mod_consts/src/options.rs | 16 ++++++++++++ 3 files changed, 57 insertions(+) diff --git a/src/training/buff.rs b/src/training/buff.rs index 61cec69..55e2277 100644 --- a/src/training/buff.rs +++ b/src/training/buff.rs @@ -1,4 +1,5 @@ use smash::app::{self, lua_bind::*}; +use smash::hash40; use smash::lib::lua_const::*; use smash::phx::{Hash40, Vector3f}; @@ -93,6 +94,8 @@ pub unsafe fn handle_buffs( return buff_shulk(module_accessor, status); } else if fighter_kind == *FIGHTER_KIND_TANTAN && menu_vec.contains(&BuffOption::POWER_DRAGON) { return buff_minmin(module_accessor); + } else if fighter_kind == *FIGHTER_KIND_WARIO { + return buff_wario(module_accessor); } true } @@ -233,6 +236,43 @@ unsafe fn buff_sepiroth(module_accessor: &mut app::BattleObjectModuleAccessor) - false } +unsafe fn buff_wario(module_accessor: &mut app::BattleObjectModuleAccessor) -> bool { + if !is_buffing(module_accessor) { + let waft_level: BuffOption = MENU.buff_state.wario_buffs().get_random(); + let waft_count_secs = match waft_level { + BuffOption::WAFT_MINI => WorkModule::get_param_float( + module_accessor, + hash40("param_special_lw"), + hash40("gass_middle_time"), + ) as i32, + BuffOption::WAFT_HALF => WorkModule::get_param_float( + module_accessor, + hash40("param_special_lw"), + hash40("gass_large_time"), + ) as i32, + BuffOption::WAFT_FULL => WorkModule::get_param_float( + module_accessor, + hash40("param_special_lw"), + hash40("gass_max_time"), + ) as i32, + _ => return true, + }; + let waft_count_frames = waft_count_secs * 60; + WorkModule::set_int( + module_accessor, + waft_count_frames, + *FIGHTER_WARIO_INSTANCE_WORK_ID_INT_GASS_COUNT, + ); + WorkModule::set_int( + module_accessor, + waft_level.into_int().unwrap(), + *FIGHTER_WARIO_INSTANCE_WORK_ID_INT_GASS_LEVEL, + ); + } + start_buff(module_accessor); + true +} + unsafe fn buff_shulk(module_accessor: &mut app::BattleObjectModuleAccessor, status: i32) -> bool { let current_art = MENU.buff_state.shulk_buffs().get_random(); if current_art == BuffOption::empty() { diff --git a/src/training/save_states.rs b/src/training/save_states.rs index 80b352e..62e27ed 100644 --- a/src/training/save_states.rs +++ b/src/training/save_states.rs @@ -431,6 +431,7 @@ pub unsafe fn save_states(module_accessor: &mut app::BattleObjectModuleAccessor) *FIGHTER_KIND_WIIFIT, *FIGHTER_KIND_SHULK, *FIGHTER_KIND_TANTAN, + *FIGHTER_KIND_WARIO, ] .contains(&fighter_kind); diff --git a/training_mod_consts/src/options.rs b/training_mod_consts/src/options.rs index 9e144b4..f7ff546 100644 --- a/training_mod_consts/src/options.rs +++ b/training_mod_consts/src/options.rs @@ -734,6 +734,9 @@ bitflags! { const MONAD_BUSTER = 0x1000; const MONAD_SMASH = 0x2000; const POWER_DRAGON = 0x4000; + const WAFT_MINI = 0x8000; + const WAFT_HALF = 0x10000; + const WAFT_FULL = 0x20000; } } @@ -757,6 +760,9 @@ impl BuffOption { BuffOption::MONAD_BUSTER => *FIGHTER_SHULK_MONAD_TYPE_BUSTER, BuffOption::MONAD_SMASH => *FIGHTER_SHULK_MONAD_TYPE_SMASH, BuffOption::POWER_DRAGON => 1, + BuffOption::WAFT_MINI => *FIGHTER_WARIO_GASS_LEVEL_M, + BuffOption::WAFT_HALF => *FIGHTER_WARIO_GASS_LEVEL_L, + BuffOption::WAFT_FULL => *FIGHTER_WARIO_GASS_LEVEL_FLY, _ => return None, }) } @@ -783,6 +789,13 @@ impl BuffOption { .union(BuffOption::MONAD_SMASH); self.intersection(shulk_buffs_bitflags) } + + pub fn wario_buffs(self) -> BuffOption { + let wario_buffs_bitflags = BuffOption::WAFT_MINI + .union(BuffOption::WAFT_HALF) + .union(BuffOption::WAFT_FULL); + self.intersection(wario_buffs_bitflags) + } } impl fmt::Display for BuffOption { @@ -807,6 +820,9 @@ impl fmt::Display for BuffOption { BuffOption::MONAD_BUSTER => "Buster", BuffOption::MONAD_SMASH => "Smash", BuffOption::POWER_DRAGON => "Power Dragon", + BuffOption::WAFT_MINI => "Mini Waft", + BuffOption::WAFT_HALF => "Half Waft", + BuffOption::WAFT_FULL => "Full Waft", _ => combination_string.as_str(), } )