Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
mehah committed Dec 21, 2024
1 parent 05ff8be commit dea09f2
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
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
7 changes: 6 additions & 1 deletion src/creatures/creature.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -209,9 +209,14 @@ 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 {
return healthMax;
}
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

0 comments on commit dea09f2

Please sign in to comment.