From b45dd01c7286b1f98982e1ac90228cace7c52198 Mon Sep 17 00:00:00 2001 From: Felix Ableitner Date: Sun, 25 Aug 2013 22:49:52 +0200 Subject: [PATCH] Fixed respawn/health problems after shotgun death. --- src/sprites/abstract/Character.cpp | 5 ++++- src/sprites/abstract/Character.h | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/sprites/abstract/Character.cpp b/src/sprites/abstract/Character.cpp index a12dcf5..b7c913b 100644 --- a/src/sprites/abstract/Character.cpp +++ b/src/sprites/abstract/Character.cpp @@ -58,8 +58,11 @@ Character::onDamage(int damage) { mCurrentHealth = mMaxHealth; if (mCurrentHealth <= 0) { + // Seperated to avoid firing multiple times (when damaged multiple times). + if (!mIsDead) + onDeath(); + mIsDead = true; mCurrentHealth = 0; - onDeath(); setDelete(true); } } diff --git a/src/sprites/abstract/Character.h b/src/sprites/abstract/Character.h index ca676bd..0dcee7a 100644 --- a/src/sprites/abstract/Character.h +++ b/src/sprites/abstract/Character.h @@ -93,6 +93,7 @@ private: std::vector mPath; //< Contains nodes to reach a set destination. Vector2f mLastPosition; Faction mFaction; + bool mIsDead = false; }; #endif /* DG_ACTOR_H_ */