mirror of
https://github.com/jugeeya/UltimateTrainingModpack.git
synced 2024-11-28 04:44:06 +00:00
Add Save State Damage Toggle (#176)
Added toggle to not overwrite the damage when loading a save state
This commit is contained in:
parent
950407553f
commit
ebc046db1d
5 changed files with 37 additions and 13 deletions
|
@ -347,3 +347,6 @@ DEFINE_ENUM_CLASS(AttackAngleFlag);
|
|||
|
||||
const std::string attack_angle_help = R""""(
|
||||
Set angleable tilt and smash attacks.)"""";
|
||||
|
||||
const std::string save_damage_help = R""""(
|
||||
Set if save states should apply to damage.)"""";
|
|
@ -34,6 +34,7 @@ static struct TrainingModpackMenu
|
|||
DelayFlags AERIAL_DELAY = DelayFlags::None;
|
||||
BoolFlags FULL_HOP = BoolFlags::None;
|
||||
int INPUT_DELAY = 0;
|
||||
OnOffFlags SAVE_DAMAGE = OnOffFlag::On;
|
||||
} menu;
|
||||
|
||||
static struct TrainingModpackMenu defaultMenu = menu;
|
||||
|
@ -401,6 +402,9 @@ tsl::elm::Element* GuiMain::createUI()
|
|||
saveStateItem->setHelpListener([](std::string title, std::string help) { tsl::changeTo<GuiHelp>(title, help); });
|
||||
list->addItem(saveStateItem);
|
||||
|
||||
list->addItem(new BitFlagToggleListItem<OnOffFlags::Type>(
|
||||
"Save Damage", OnOffFlag::On, &menu.SAVE_DAMAGE, "Save Damage", save_damage_help));
|
||||
|
||||
ValueListItem* inputDelayItem =
|
||||
new ValueListItem("Input Delay", input_delay_items, &menu.INPUT_DELAY, "inputDelay", input_delay_help);
|
||||
list->addItem(inputDelayItem);
|
||||
|
|
|
@ -337,6 +337,7 @@ pub struct TrainingModpackMenu {
|
|||
pub aerial_delay: Delay,
|
||||
pub full_hop: BoolFlag,
|
||||
pub input_delay: i32,
|
||||
pub save_damage: OnOff,
|
||||
}
|
||||
|
||||
// Fighter Ids
|
||||
|
|
|
@ -30,6 +30,7 @@ pub static mut MENU_STRUCT: consts::TrainingModpackMenu = consts::TrainingModpac
|
|||
aerial_delay: Delay::empty(),
|
||||
full_hop: BoolFlag::empty(),
|
||||
input_delay: 0,
|
||||
save_damage: OnOff::On,
|
||||
};
|
||||
|
||||
pub static mut MENU: &consts::TrainingModpackMenu = unsafe { &mut MENU_STRUCT };
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
use crate::common::consts::FighterId;
|
||||
use crate::common::consts::OnOff;
|
||||
use crate::common::MENU;
|
||||
use crate::training::reset;
|
||||
use smash::app::{self, lua_bind::*};
|
||||
use smash::hash40;
|
||||
|
@ -66,10 +68,32 @@ pub unsafe fn get_param_int(
|
|||
None
|
||||
}
|
||||
|
||||
fn set_damage(module_accessor: &mut app::BattleObjectModuleAccessor, damage : f32) {
|
||||
let overwrite_damage;
|
||||
|
||||
unsafe {
|
||||
overwrite_damage = MENU.save_damage == OnOff::On;
|
||||
}
|
||||
|
||||
if !overwrite_damage {
|
||||
return;
|
||||
}
|
||||
|
||||
unsafe {
|
||||
DamageModule::heal(
|
||||
module_accessor,
|
||||
-1.0 * DamageModule::damage(module_accessor, 0),
|
||||
0,
|
||||
);
|
||||
DamageModule::add_damage(module_accessor, damage, 0);
|
||||
}
|
||||
}
|
||||
|
||||
pub unsafe fn save_states(module_accessor: &mut app::BattleObjectModuleAccessor) {
|
||||
let status = StatusModule::status_kind(module_accessor) as i32;
|
||||
let save_state = if WorkModule::get_int(module_accessor, *FIGHTER_INSTANCE_WORK_ID_INT_ENTRY_ID)
|
||||
== FighterId::CPU as i32 {
|
||||
let save_state = if WorkModule::get_int(module_accessor, *FIGHTER_INSTANCE_WORK_ID_INT_ENTRY_ID)
|
||||
== FighterId::CPU as i32
|
||||
{
|
||||
&mut SAVE_STATE_CPU
|
||||
} else {
|
||||
&mut SAVE_STATE_PLAYER
|
||||
|
@ -107,11 +131,7 @@ pub unsafe fn save_states(module_accessor: &mut app::BattleObjectModuleAccessor)
|
|||
ControlModule::stop_rumble(module_accessor, true);
|
||||
SoundModule::stop_all_sound(module_accessor);
|
||||
|
||||
StatusModule::change_status_request(
|
||||
module_accessor,
|
||||
*FIGHTER_STATUS_KIND_DEAD,
|
||||
false,
|
||||
);
|
||||
StatusModule::change_status_request(module_accessor, *FIGHTER_STATUS_KIND_DEAD, false);
|
||||
}
|
||||
|
||||
return;
|
||||
|
@ -171,12 +191,7 @@ pub unsafe fn save_states(module_accessor: &mut app::BattleObjectModuleAccessor)
|
|||
|
||||
// if we're done moving, reset percent
|
||||
if save_state.state == NoAction {
|
||||
DamageModule::heal(
|
||||
module_accessor,
|
||||
-1.0 * DamageModule::damage(module_accessor, 0),
|
||||
0,
|
||||
);
|
||||
DamageModule::add_damage(module_accessor, save_state.percent, 0);
|
||||
set_damage(module_accessor, save_state.percent);
|
||||
}
|
||||
|
||||
return;
|
||||
|
|
Loading…
Reference in a new issue