Skip to content

Commit df006fb

Browse files
mehahvllworldbuilding
authored andcommitted
fix: death call several times (opentibiabr#3186)
fix opentibiabr#3177
1 parent 4c286b8 commit df006fb

File tree

3 files changed

+10
-2
lines changed

3 files changed

+10
-2
lines changed

src/creatures/creature.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -711,6 +711,10 @@ std::shared_ptr<Item> Creature::getCorpse(const std::shared_ptr<Creature> &, con
711711
}
712712

713713
void Creature::changeHealth(int32_t healthChange, bool sendHealthChange /* = true*/) {
714+
if (isLifeless()) {
715+
return;
716+
}
717+
714718
int32_t oldHealth = health;
715719

716720
if (healthChange > 0) {

src/creatures/creature.hpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,11 @@ class Creature : virtual public Thing, public SharedObject {
209209
}
210210

211211
bool isAlive() const {
212-
return !isDead();
212+
return !isLifeless();
213+
}
214+
215+
bool isLifeless() const {
216+
return health <= 0;
213217
}
214218

215219
virtual int32_t getMaxHealth() const {

src/creatures/monsters/monster.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1110,7 +1110,7 @@ void Monster::onThink_async() {
11101110

11111111
void Monster::doAttacking(uint32_t interval) {
11121112
const auto &attackedCreature = getAttackedCreature();
1113-
if (!attackedCreature || (isSummon() && attackedCreature.get() == this)) {
1113+
if (!attackedCreature || attackedCreature->isLifeless() || (isSummon() && attackedCreature.get() == this)) {
11141114
return;
11151115
}
11161116

0 commit comments

Comments
 (0)