From 25973cb7ddfd33606ab32bff72b6171efb8975fa Mon Sep 17 00:00:00 2001 From: Matthew Fioravante Date: Sun, 24 Mar 2019 14:23:17 -0400 Subject: [PATCH] Battle2k: Don't animate death until we display the message Fix #1725 --- src/scene_battle_rpg2k.cpp | 10 ++++++++++ src/sprite_battler.cpp | 6 +++++- src/sprite_battler.h | 10 ++++++++++ 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/src/scene_battle_rpg2k.cpp b/src/scene_battle_rpg2k.cpp index 152c0b01c70..566e751b100 100644 --- a/src/scene_battle_rpg2k.cpp +++ b/src/scene_battle_rpg2k.cpp @@ -633,6 +633,15 @@ bool Scene_Battle_Rpg2k::ProcessActionApply(Game_BattleAlgorithm::AlgorithmBase* return ProcessNextAction(BattleActionState_Finished, action); } + // This is a hack to ensure the sprite's death animation doesn't happen + // until we actually transition to the death state in the battle system. + if (action->IsLethal()) { + auto* target_sprite = Game_Battle::GetSpriteset().FindBattler(target); + if (target_sprite) { + target_sprite->SetForcedAlive(true); + } + } + if (!action->IsPositive() && action->GetAffectedHp() >= 0) { return ProcessNextAction(BattleActionState_Damage, action); } @@ -775,6 +784,7 @@ bool Scene_Battle_Rpg2k::ProcessActionDeath(Game_BattleAlgorithm::AlgorithmBase* Game_System::SePlay(*se); } if (target_sprite) { + target_sprite->SetForcedAlive(false); target_sprite->DetectStateChange(); } diff --git a/src/sprite_battler.cpp b/src/sprite_battler.cpp index 37ab2e30385..48bf65b26f2 100644 --- a/src/sprite_battler.cpp +++ b/src/sprite_battler.cpp @@ -330,6 +330,10 @@ void Sprite_Battler::CreateSprite() { SetVisible(!battler->IsHidden()); } +void Sprite_Battler::SetForcedAlive(bool value) { + forced_alive = value; +} + void Sprite_Battler::DoIdleAnimation() { if (battler->IsDefending()) { SetAnimationState(AnimationState_Defending); @@ -342,7 +346,7 @@ void Sprite_Battler::DoIdleAnimation() { if (battler->GetBattleAnimationId() <= 0) { // Monster // Only visually different state is Death - if (state && state->ID == 1) { + if (state && state->ID == 1 && !forced_alive) { idling_anim = AnimationState_Dead; } else { idling_anim = AnimationState_Idle; diff --git a/src/sprite_battler.h b/src/sprite_battler.h index f73b13c5740..e42d8a80b2e 100644 --- a/src/sprite_battler.h +++ b/src/sprite_battler.h @@ -96,6 +96,15 @@ class Sprite_Battler : public Sprite { int GetWidth() const override; int GetHeight() const override; + /** + * A hack for 2k battle system. Treat the sprite as not dead + * even if the battler is dead. This is needed because battler "dies" + * before the 2k battle system animates the death + * + * @param value whether to force alive or not + */ + void SetForcedAlive(bool value); + protected: void CreateSprite(); void DoIdleAnimation(); @@ -119,6 +128,7 @@ class Sprite_Battler : public Sprite { std::unique_ptr animation; // false when a newly set animation didn't loop once bool idling = true; + bool forced_alive = false; float zoom = 1.0; FileRequestBinding request_id;