mirror of
https://github.com/jugeeya/UltimateTrainingModpack.git
synced 2025-02-17 14:40:31 +00:00
PT Load State Fix: After Training Mode Reset (#485)
* Damage percent fix * PT is fixed! * Fix ICs
This commit is contained in:
parent
10221973fa
commit
9ca84013b7
2 changed files with 81 additions and 69 deletions
|
@ -39,6 +39,7 @@ enum SaveState {
|
||||||
Save,
|
Save,
|
||||||
NoAction,
|
NoAction,
|
||||||
KillPlayer,
|
KillPlayer,
|
||||||
|
WaitForAlive,
|
||||||
PosMove,
|
PosMove,
|
||||||
NanaPosMove,
|
NanaPosMove,
|
||||||
ApplyBuff,
|
ApplyBuff,
|
||||||
|
@ -151,7 +152,8 @@ unsafe fn save_state_cpu() -> &'static mut SavedState {
|
||||||
static mut MIRROR_STATE: f32 = 1.0;
|
static mut MIRROR_STATE: f32 = 1.0;
|
||||||
|
|
||||||
pub unsafe fn is_killing() -> bool {
|
pub unsafe fn is_killing() -> bool {
|
||||||
save_state_player().state == KillPlayer || save_state_cpu().state == KillPlayer
|
(save_state_player().state == KillPlayer || save_state_player().state == WaitForAlive)
|
||||||
|
|| (save_state_cpu().state == KillPlayer || save_state_cpu().state == WaitForAlive)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub unsafe fn is_loading() -> bool {
|
pub unsafe fn is_loading() -> bool {
|
||||||
|
@ -190,7 +192,7 @@ pub unsafe fn get_param_int(
|
||||||
if param_hash == hash40("rebirth_move_frame") {
|
if param_hash == hash40("rebirth_move_frame") {
|
||||||
return Some(0);
|
return Some(0);
|
||||||
}
|
}
|
||||||
if param_hash == hash40("rebirth_move_frame_trainer") && is_killing() {
|
if param_hash == hash40("rebirth_move_frame_trainer") && is_loading() {
|
||||||
return Some(0);
|
return Some(0);
|
||||||
}
|
}
|
||||||
if param_hash == hash40("rebirth_wait_frame") {
|
if param_hash == hash40("rebirth_wait_frame") {
|
||||||
|
@ -205,7 +207,7 @@ pub unsafe fn get_param_int(
|
||||||
}
|
}
|
||||||
if param_type == hash40("param_mball")
|
if param_type == hash40("param_mball")
|
||||||
&& param_hash == hash40("change_fly_frame")
|
&& param_hash == hash40("change_fly_frame")
|
||||||
&& is_killing()
|
&& is_loading()
|
||||||
{
|
{
|
||||||
return Some(0);
|
return Some(0);
|
||||||
}
|
}
|
||||||
|
@ -268,6 +270,62 @@ unsafe fn on_ptrainer_death(module_accessor: &mut app::BattleObjectModuleAccesso
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
unsafe fn on_death(fighter_kind: i32, module_accessor: &mut app::BattleObjectModuleAccessor) {
|
||||||
|
SoundModule::stop_all_sound(module_accessor);
|
||||||
|
// Try moving off-screen so we don't see effects.
|
||||||
|
let pos = Vector3f {
|
||||||
|
x: -300.0,
|
||||||
|
y: -100.0,
|
||||||
|
z: 0.0,
|
||||||
|
};
|
||||||
|
PostureModule::set_pos(module_accessor, &pos);
|
||||||
|
|
||||||
|
// All articles have ID <= 0x25
|
||||||
|
(0..=0x25)
|
||||||
|
// Don't remove crafting table
|
||||||
|
.filter(|article_idx| {
|
||||||
|
!(fighter_kind == *FIGHTER_KIND_PICKEL
|
||||||
|
&& *article_idx == *FIGHTER_PICKEL_GENERATE_ARTICLE_TABLE)
|
||||||
|
})
|
||||||
|
.for_each(|article_idx| {
|
||||||
|
if ArticleModule::is_exist(module_accessor, article_idx) {
|
||||||
|
let article: u64 = ArticleModule::get_article(module_accessor, article_idx);
|
||||||
|
let article_object_id = Article::get_battle_object_id(article as *mut app::Article);
|
||||||
|
ArticleModule::remove_exist_object_id(module_accessor, article_object_id as u32);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
let item_mgr = *(ITEM_MANAGER_ADDR as *mut *mut app::ItemManager);
|
||||||
|
(0..ItemManager::get_num_of_active_item_all(item_mgr)).for_each(|item_idx| {
|
||||||
|
let item = ItemManager::get_active_item(item_mgr, item_idx);
|
||||||
|
if item != 0 {
|
||||||
|
let item = item as *mut Item;
|
||||||
|
let item_battle_object_id = app::lua_bind::Item::get_battle_object_id(item) as u32;
|
||||||
|
ItemManager::remove_item_from_id(item_mgr, item_battle_object_id);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
MotionAnimcmdModule::set_sleep(module_accessor, true);
|
||||||
|
SoundModule::pause_se_all(module_accessor, true);
|
||||||
|
ControlModule::stop_rumble(module_accessor, true);
|
||||||
|
SoundModule::stop_all_sound(module_accessor);
|
||||||
|
// Return camera to normal when loading save state
|
||||||
|
SlowModule::clear_whole(module_accessor);
|
||||||
|
CameraModule::zoom_out(module_accessor, 0);
|
||||||
|
// Remove blue effect (but does not remove darkened screen)
|
||||||
|
EffectModule::kill_kind(
|
||||||
|
module_accessor,
|
||||||
|
Hash40::new("sys_bg_criticalhit"),
|
||||||
|
false,
|
||||||
|
false,
|
||||||
|
);
|
||||||
|
// Removes the darkened screen from special zooms
|
||||||
|
// If there's a crit that doesn't get removed, it's likely bg_criticalhit2.
|
||||||
|
EffectModule::remove_screen(module_accessor, Hash40::new("bg_criticalhit"), 0);
|
||||||
|
// Remove all quakes to prevent screen shake lingering through load.
|
||||||
|
for quake_kind in *CAMERA_QUAKE_KIND_NONE..=*CAMERA_QUAKE_KIND_MAX {
|
||||||
|
CameraModule::stop_quake(module_accessor, quake_kind);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub unsafe fn save_states(module_accessor: &mut app::BattleObjectModuleAccessor) {
|
pub unsafe fn save_states(module_accessor: &mut app::BattleObjectModuleAccessor) {
|
||||||
if MENU.save_state_enable == OnOff::Off {
|
if MENU.save_state_enable == OnOff::Off {
|
||||||
return;
|
return;
|
||||||
|
@ -354,78 +412,30 @@ pub unsafe fn save_states(module_accessor: &mut app::BattleObjectModuleAccessor)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// move to camera bounds
|
// Kill the fighter and move them to camera bounds
|
||||||
if save_state.state == KillPlayer {
|
if save_state.state == KillPlayer {
|
||||||
on_ptrainer_death(module_accessor);
|
on_ptrainer_death(module_accessor);
|
||||||
SoundModule::stop_all_sound(module_accessor);
|
if !is_dead(module_accessor) &&
|
||||||
if status == FIGHTER_STATUS_KIND_REBIRTH || status == FIGHTER_STATUS_KIND_WAIT {
|
|
||||||
save_state.state = PosMove;
|
|
||||||
} else if !is_dead(module_accessor) && !fighter_is_nana {
|
|
||||||
// Don't kill Nana again, since she already gets killed by the game from Popo's death
|
// Don't kill Nana again, since she already gets killed by the game from Popo's death
|
||||||
// Try moving off-screen so we don't see effects.
|
!fighter_is_nana
|
||||||
let pos = Vector3f {
|
{
|
||||||
x: -300.0,
|
on_death(fighter_kind, module_accessor);
|
||||||
y: -100.0,
|
|
||||||
z: 0.0,
|
|
||||||
};
|
|
||||||
PostureModule::set_pos(module_accessor, &pos);
|
|
||||||
|
|
||||||
// All articles have ID <= 0x25
|
|
||||||
(0..=0x25)
|
|
||||||
// Don't remove crafting table
|
|
||||||
.filter(|article_idx| {
|
|
||||||
!(fighter_kind == *FIGHTER_KIND_PICKEL
|
|
||||||
&& *article_idx == *FIGHTER_PICKEL_GENERATE_ARTICLE_TABLE)
|
|
||||||
})
|
|
||||||
.for_each(|article_idx| {
|
|
||||||
if ArticleModule::is_exist(module_accessor, article_idx) {
|
|
||||||
let article: u64 = ArticleModule::get_article(module_accessor, article_idx);
|
|
||||||
let article_object_id =
|
|
||||||
Article::get_battle_object_id(article as *mut app::Article);
|
|
||||||
ArticleModule::remove_exist_object_id(
|
|
||||||
module_accessor,
|
|
||||||
article_object_id as u32,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
let item_mgr = *(ITEM_MANAGER_ADDR as *mut *mut app::ItemManager);
|
|
||||||
(0..ItemManager::get_num_of_active_item_all(item_mgr)).for_each(|item_idx| {
|
|
||||||
let item = ItemManager::get_active_item(item_mgr, item_idx);
|
|
||||||
if item != 0 {
|
|
||||||
let item = item as *mut Item;
|
|
||||||
let item_battle_object_id =
|
|
||||||
app::lua_bind::Item::get_battle_object_id(item) as u32;
|
|
||||||
ItemManager::remove_item_from_id(item_mgr, item_battle_object_id);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
MotionAnimcmdModule::set_sleep(module_accessor, true);
|
|
||||||
SoundModule::pause_se_all(module_accessor, true);
|
|
||||||
ControlModule::stop_rumble(module_accessor, true);
|
|
||||||
SoundModule::stop_all_sound(module_accessor);
|
|
||||||
// Return camera to normal when loading save state
|
|
||||||
SlowModule::clear_whole(module_accessor);
|
|
||||||
CameraModule::zoom_out(module_accessor, 0);
|
|
||||||
// Remove blue effect (but does not remove darkened screen)
|
|
||||||
EffectModule::kill_kind(
|
|
||||||
module_accessor,
|
|
||||||
Hash40::new("sys_bg_criticalhit"),
|
|
||||||
false,
|
|
||||||
false,
|
|
||||||
);
|
|
||||||
// Removes the darkened screen from special zooms
|
|
||||||
// If there's a crit that doesn't get removed, it's likely bg_criticalhit2.
|
|
||||||
EffectModule::remove_screen(module_accessor, Hash40::new("bg_criticalhit"), 0);
|
|
||||||
// Remove all quakes to prevent screen shake lingering through load.
|
|
||||||
for quake_kind in *CAMERA_QUAKE_KIND_NONE..=*CAMERA_QUAKE_KIND_MAX {
|
|
||||||
CameraModule::stop_quake(module_accessor, quake_kind);
|
|
||||||
}
|
|
||||||
|
|
||||||
StatusModule::change_status_request(module_accessor, *FIGHTER_STATUS_KIND_DEAD, false);
|
StatusModule::change_status_request(module_accessor, *FIGHTER_STATUS_KIND_DEAD, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
save_state.state = WaitForAlive;
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if save_state.state == WaitForAlive {
|
||||||
|
on_ptrainer_death(module_accessor);
|
||||||
|
if !is_dead(module_accessor) && !fighter_is_nana {
|
||||||
|
on_death(fighter_kind, module_accessor);
|
||||||
|
save_state.state = PosMove;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// move to correct pos
|
// move to correct pos
|
||||||
if save_state.state == PosMove || save_state.state == NanaPosMove {
|
if save_state.state == PosMove || save_state.state == NanaPosMove {
|
||||||
let status_kind = StatusModule::status_kind(module_accessor);
|
let status_kind = StatusModule::status_kind(module_accessor);
|
||||||
|
|
|
@ -120,7 +120,8 @@ pub unsafe fn draw(root_pane: &mut Pane, layout_name: &str) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if dmg_num.alpha != 255 || dmg_num.global_alpha != 255 {
|
if dmg_num.alpha != 255 || dmg_num.global_alpha != 255 {
|
||||||
dmg_num.set_visible(true);
|
dmg_num.alpha = 255;
|
||||||
|
dmg_num.global_alpha = 255;
|
||||||
if !has_altered_anim_list {
|
if !has_altered_anim_list {
|
||||||
iterate_anim_list(anim_list, Some(player_name));
|
iterate_anim_list(anim_list, Some(player_name));
|
||||||
has_altered_anim_list = true;
|
has_altered_anim_list = true;
|
||||||
|
@ -138,10 +139,11 @@ pub unsafe fn draw(root_pane: &mut Pane, layout_name: &str) {
|
||||||
if let Some(death_explosion) =
|
if let Some(death_explosion) =
|
||||||
parent.find_pane_by_name_recursive(death_explosion_s)
|
parent.find_pane_by_name_recursive(death_explosion_s)
|
||||||
{
|
{
|
||||||
death_explosion.set_visible(false);
|
death_explosion.alpha = 0;
|
||||||
|
death_explosion.global_alpha = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue