Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/creatures/creature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -711,6 +711,10 @@ std::shared_ptr<Item> Creature::getCorpse(const std::shared_ptr<Creature> &, con
}

void Creature::changeHealth(int32_t healthChange, bool sendHealthChange /* = true*/) {
if (isLifeless()) {
return;
}

int32_t oldHealth = health;

if (healthChange > 0) {
Expand Down
6 changes: 5 additions & 1 deletion src/creatures/creature.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,11 @@ class Creature : virtual public Thing, public SharedObject {
}

bool isAlive() const {
return !isDead();
return !isLifeless();
}

bool isLifeless() const {
return health <= 0;
}

virtual int32_t getMaxHealth() const {
Expand Down
2 changes: 1 addition & 1 deletion src/creatures/monsters/monster.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1109,7 +1109,7 @@ void Monster::onThink_async() {

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

Expand Down