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

Save States: Handle Ledges and Asymmetric Stages (#455)

* Don't save situation_kind_cliff

* Handle asymmetric stages
This commit is contained in:
asimon-1 2022-12-31 16:41:01 -05:00 committed by GitHub
parent f35f10e4f4
commit 7ca9e5fb77
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -17,6 +17,12 @@ use smash::hash40;
use smash::lib::lua_const::*;
use smash::phx::{Hash40, Vector3f};
use training_mod_consts::{CharacterItem, SaveDamage};
use std::collections::HashMap;
extern "C" {
#[link_name = "\u{1}_ZN3app14sv_information8stage_idEv"]
pub fn stage_id() -> i32;
}
#[derive(PartialEq)]
enum SaveState {
@ -150,6 +156,16 @@ pub unsafe fn get_param_int(
None
}
fn get_stage_offset(stage_id: i32) -> f32 {
let offsets: HashMap<i32, f32> = HashMap::from([
(*StageID::Animal_Village, 1.195),
(*StageID::Animal_City, 1.448),
(*StageID::Yoshi_Island, -1.053),
]);
*offsets.get(&stage_id).unwrap_or(&0.0)
}
fn set_damage(module_accessor: &mut app::BattleObjectModuleAccessor, damage: f32) {
unsafe {
DamageModule::heal(
@ -327,11 +343,20 @@ pub unsafe fn save_states(module_accessor: &mut app::BattleObjectModuleAccessor)
ControlModule::stop_rumble(module_accessor, false);
KineticModule::clear_speed_all(module_accessor);
let pos = Vector3f {
x: MIRROR_STATE * save_state.x,
let pos = if MIRROR_STATE == -1.0 {
Vector3f {
x: MIRROR_STATE * (save_state.x - get_stage_offset(stage_id())),
y: save_state.y,
z: 0.0,
}
} else {
Vector3f {
x: save_state.x,
y: save_state.y,
z: 0.0,
}
};
let lr = MIRROR_STATE * save_state.lr;
PostureModule::set_pos(module_accessor, &pos);
PostureModule::set_lr(module_accessor, lr);
@ -483,7 +508,12 @@ pub unsafe fn save_states(module_accessor: &mut app::BattleObjectModuleAccessor)
save_state.y = PostureModule::pos_y(module_accessor);
save_state.lr = PostureModule::lr(module_accessor);
save_state.percent = DamageModule::damage(module_accessor, 0);
save_state.situation_kind = StatusModule::situation_kind(module_accessor);
save_state.situation_kind =
if StatusModule::situation_kind(module_accessor) == *SITUATION_KIND_CLIFF {
*SITUATION_KIND_AIR
} else {
StatusModule::situation_kind(module_accessor)
};
// Always store fighter kind so that charges are handled properly
save_state.fighter_kind = app::utility::get_kind(module_accessor);
save_state.charge = charge::get_charge(module_accessor, fighter_kind);