From c6c4105fc3d6a0aecd9ecf950b1b245b84c6bbf7 Mon Sep 17 00:00:00 2001
From: GradualSyrup <68757075+GradualSyrup@users.noreply.github.com>
Date: Fri, 18 Mar 2022 12:53:06 -0500
Subject: [PATCH] cleanup and psyche up fix (#321)

---
 src/training/buff.rs        |  1 +
 src/training/save_states.rs | 17 +++++++++++++++++
 2 files changed, 18 insertions(+)

diff --git a/src/training/buff.rs b/src/training/buff.rs
index bc1cb8d5..2054d935 100644
--- a/src/training/buff.rs
+++ b/src/training/buff.rs
@@ -82,6 +82,7 @@ pub unsafe fn handle_buffs(
     SoundModule::stop_all_sound(module_accessor); // silences buff sfx other than KO Punch
     ControlModule::stop_rumble(module_accessor, false);
     MotionAnimcmdModule::set_sleep(module_accessor, false);
+    CameraModule::stop_quake(module_accessor, *CAMERA_QUAKE_KIND_M); // stops Psyche-Up quake
 
     let menu_vec = MENU.buff_state.to_vec();
 
diff --git a/src/training/save_states.rs b/src/training/save_states.rs
index edc9a16b..e654bc57 100644
--- a/src/training/save_states.rs
+++ b/src/training/save_states.rs
@@ -229,6 +229,23 @@ pub unsafe fn save_states(module_accessor: &mut app::BattleObjectModuleAccessor)
             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);
         }