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_ */