mirror of
https://github.com/jugeeya/UltimateTrainingModpack.git
synced 2025-02-26 02:50:23 +00:00
Save States: Handle Ledges and Asymmetric Stages (#455)
* Don't save situation_kind_cliff * Handle asymmetric stages
This commit is contained in:
parent
f35f10e4f4
commit
7ca9e5fb77
1 changed files with 35 additions and 5 deletions
|
@ -17,6 +17,12 @@ use smash::hash40;
|
||||||
use smash::lib::lua_const::*;
|
use smash::lib::lua_const::*;
|
||||||
use smash::phx::{Hash40, Vector3f};
|
use smash::phx::{Hash40, Vector3f};
|
||||||
use training_mod_consts::{CharacterItem, SaveDamage};
|
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)]
|
#[derive(PartialEq)]
|
||||||
enum SaveState {
|
enum SaveState {
|
||||||
|
@ -150,6 +156,16 @@ pub unsafe fn get_param_int(
|
||||||
None
|
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) {
|
fn set_damage(module_accessor: &mut app::BattleObjectModuleAccessor, damage: f32) {
|
||||||
unsafe {
|
unsafe {
|
||||||
DamageModule::heal(
|
DamageModule::heal(
|
||||||
|
@ -327,11 +343,20 @@ pub unsafe fn save_states(module_accessor: &mut app::BattleObjectModuleAccessor)
|
||||||
ControlModule::stop_rumble(module_accessor, false);
|
ControlModule::stop_rumble(module_accessor, false);
|
||||||
KineticModule::clear_speed_all(module_accessor);
|
KineticModule::clear_speed_all(module_accessor);
|
||||||
|
|
||||||
let pos = Vector3f {
|
let pos = if MIRROR_STATE == -1.0 {
|
||||||
x: MIRROR_STATE * save_state.x,
|
Vector3f {
|
||||||
y: save_state.y,
|
x: MIRROR_STATE * (save_state.x - get_stage_offset(stage_id())),
|
||||||
z: 0.0,
|
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;
|
let lr = MIRROR_STATE * save_state.lr;
|
||||||
PostureModule::set_pos(module_accessor, &pos);
|
PostureModule::set_pos(module_accessor, &pos);
|
||||||
PostureModule::set_lr(module_accessor, lr);
|
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.y = PostureModule::pos_y(module_accessor);
|
||||||
save_state.lr = PostureModule::lr(module_accessor);
|
save_state.lr = PostureModule::lr(module_accessor);
|
||||||
save_state.percent = DamageModule::damage(module_accessor, 0);
|
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
|
// Always store fighter kind so that charges are handled properly
|
||||||
save_state.fighter_kind = app::utility::get_kind(module_accessor);
|
save_state.fighter_kind = app::utility::get_kind(module_accessor);
|
||||||
save_state.charge = charge::get_charge(module_accessor, fighter_kind);
|
save_state.charge = charge::get_charge(module_accessor, fighter_kind);
|
||||||
|
|
Loading…
Add table
Reference in a new issue