Skip to content

Commit

Permalink
Battle2k: Don't animate death until we display the message
Browse files Browse the repository at this point in the history
  • Loading branch information
fmatthew5876 committed Mar 24, 2019
1 parent 6aba0e1 commit 25973cb
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 1 deletion.
10 changes: 10 additions & 0 deletions src/scene_battle_rpg2k.cpp
Expand Up @@ -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);
}
Expand Down Expand Up @@ -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();
}

Expand Down
6 changes: 5 additions & 1 deletion src/sprite_battler.cpp
Expand Up @@ -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);
Expand All @@ -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;
Expand Down
10 changes: 10 additions & 0 deletions src/sprite_battler.h
Expand Up @@ -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();
Expand All @@ -119,6 +128,7 @@ class Sprite_Battler : public Sprite {
std::unique_ptr<BattleAnimation> 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;
Expand Down

0 comments on commit 25973cb

Please sign in to comment.