diff --git a/src/game_battle.cpp b/src/game_battle.cpp index 5bcc6b9c9e..8d67afd1a8 100644 --- a/src/game_battle.cpp +++ b/src/game_battle.cpp @@ -234,7 +234,11 @@ void Game_Battle::UpdateAtbGauges() { } bool Game_Battle::ManiacBattleHook(Game_Interpreter_Battle::ManiacBattleHookType hook_type, int var1, int var2, int var3, int var4, int var5, int var6) { - return interpreter->ManiacBattleHook(hook_type, var1, var2, var3, var4, var5, var6); + if (Player::IsPatchManiac() && interpreter) { + return interpreter->ManiacBattleHook(hook_type, var1, var2, var3, var4, var5, var6); + } else { + return false; + } } bool Game_Battle::ManiacProcessSubEvents() { diff --git a/src/game_battle.h b/src/game_battle.h index 7eeece4b71..a800d7c177 100644 --- a/src/game_battle.h +++ b/src/game_battle.h @@ -114,6 +114,7 @@ namespace Game_Battle { * Convenience function to call a maniacs battle hook, which processes sub-events at any time. */ bool ManiacBattleHook(Game_Interpreter_Battle::ManiacBattleHookType hook_type, int var1, int var2, int var3, int var4 = 0, int var5 = 0, int var6 = 0); + /** * Convenience function to process all maniacs sub-events, and return whether they're currently running */ diff --git a/src/game_battlealgorithm.cpp b/src/game_battlealgorithm.cpp index 2ccb0262ef..c858202f94 100644 --- a/src/game_battlealgorithm.cpp +++ b/src/game_battlealgorithm.cpp @@ -197,17 +197,15 @@ int Game_BattleAlgorithm::AlgorithmBase::ApplySpEffect() { source->ChangeSp(-sp); } - if (Player::IsPatchManiac()) { - Game_Battle::ManiacBattleHook( - Game_Interpreter_Battle::ManiacBattleHookType::StatChange, - target->GetType() == Game_Battler::Type_Enemy, - target->GetPartyIndex(), - target->GetDisplayX(), - target->GetDisplayY(), - 3, - sp - ); - } + Game_Battle::ManiacBattleHook( + Game_Interpreter_Battle::ManiacBattleHookType::StatChange, + target->GetType() == Game_Battler::Type_Enemy, + target->GetPartyIndex(), + target->GetDisplayX(), + target->GetDisplayY(), + 3, + sp + ); } return sp; @@ -223,17 +221,15 @@ int Game_BattleAlgorithm::AlgorithmBase::ApplyAtkEffect() { source->ChangeAtkModifier(-atk); } - if (Player::IsPatchManiac()) { - Game_Battle::ManiacBattleHook( - Game_Interpreter_Battle::ManiacBattleHookType::StatChange, - target->GetType() == Game_Battler::Type_Enemy, - target->GetPartyIndex(), - target->GetDisplayX(), - target->GetDisplayY(), - 4, - atk - ); - } + Game_Battle::ManiacBattleHook( + Game_Interpreter_Battle::ManiacBattleHookType::StatChange, + target->GetType() == Game_Battler::Type_Enemy, + target->GetPartyIndex(), + target->GetDisplayX(), + target->GetDisplayY(), + 4, + atk + ); } return atk; } @@ -248,17 +244,15 @@ int Game_BattleAlgorithm::AlgorithmBase::ApplyDefEffect() { source->ChangeDefModifier(-def); } - if (Player::IsPatchManiac()) { - Game_Battle::ManiacBattleHook( - Game_Interpreter_Battle::ManiacBattleHookType::StatChange, - target->GetType() == Game_Battler::Type_Enemy, - target->GetPartyIndex(), - target->GetDisplayX(), - target->GetDisplayY(), - 5, - def - ); - } + Game_Battle::ManiacBattleHook( + Game_Interpreter_Battle::ManiacBattleHookType::StatChange, + target->GetType() == Game_Battler::Type_Enemy, + target->GetPartyIndex(), + target->GetDisplayX(), + target->GetDisplayY(), + 5, + def + ); } return def; } @@ -273,17 +267,15 @@ int Game_BattleAlgorithm::AlgorithmBase::ApplySpiEffect() { source->ChangeSpiModifier(-spi); } - if (Player::IsPatchManiac()) { - Game_Battle::ManiacBattleHook( - Game_Interpreter_Battle::ManiacBattleHookType::StatChange, - target->GetType() == Game_Battler::Type_Enemy, - target->GetPartyIndex(), - target->GetDisplayX(), - target->GetDisplayY(), - 6, - spi - ); - } + Game_Battle::ManiacBattleHook( + Game_Interpreter_Battle::ManiacBattleHookType::StatChange, + target->GetType() == Game_Battler::Type_Enemy, + target->GetPartyIndex(), + target->GetDisplayX(), + target->GetDisplayY(), + 6, + spi + ); } return spi; } @@ -298,17 +290,15 @@ int Game_BattleAlgorithm::AlgorithmBase::ApplyAgiEffect() { source->ChangeAgiModifier(-agi); } - if (Player::IsPatchManiac()) { - Game_Battle::ManiacBattleHook( - Game_Interpreter_Battle::ManiacBattleHookType::StatChange, - target->GetType() == Game_Battler::Type_Enemy, - target->GetPartyIndex(), - target->GetDisplayX(), - target->GetDisplayY(), - 7, - agi - ); - } + Game_Battle::ManiacBattleHook( + Game_Interpreter_Battle::ManiacBattleHookType::StatChange, + target->GetType() == Game_Battler::Type_Enemy, + target->GetPartyIndex(), + target->GetDisplayX(), + target->GetDisplayY(), + 7, + agi + ); } return agi; } diff --git a/src/game_battler.cpp b/src/game_battler.cpp index 221975a69e..d6dee13a2e 100644 --- a/src/game_battler.cpp +++ b/src/game_battler.cpp @@ -576,12 +576,22 @@ int Game_Battler::GetAgi(Weapon weapon) const { } int Game_Battler::GetDisplayX() const { - int shake_pos = Main_Data::game_screen->GetShakeOffsetX() + shake.position; + int shake_x = 0; + if (Main_Data::game_screen) { + shake_x = Main_Data::game_screen->GetShakeOffsetX(); + } + + int shake_pos = shake_x + shake.position; return Player::menu_offset_x + ((GetBattlePosition().x + shake_pos) * MENU_WIDTH / MENU_WIDTH); } int Game_Battler::GetDisplayY() const { - int shake_pos = Main_Data::game_screen->GetShakeOffsetY(); + int shake_y = 0; + if (Main_Data::game_screen) { + shake_y = Main_Data::game_screen->GetShakeOffsetY(); + } + + int shake_pos = shake_y; return Player::menu_offset_y + ((GetBattlePosition().y + GetFlyingOffset() + shake_pos) * MENU_HEIGHT / MENU_HEIGHT); }