diff --git a/src/MobManager.cpp b/src/MobManager.cpp index 150e4b1..a2718be 100644 --- a/src/MobManager.cpp +++ b/src/MobManager.cpp @@ -488,11 +488,19 @@ void MobManager::deadStep(Mob *mob, time_t currTime) { void MobManager::combatStep(Mob *mob, time_t currTime) { assert(mob->target != nullptr); + // lose aggro if the player lost connection + if (PlayerManager::players.find(mob->target) == PlayerManager::players.end()) { + mob->target = nullptr; + mob->state = MobState::RETREAT; + if (!aggroCheck(mob, currTime)) + clearDebuff(mob); + return; + } + Player *plr = PlayerManager::getPlayer(mob->target); - // Lose aggro if the player lost connection, became invulnerable or died + // lose aggro if the player became invulnerable or died if (plr->HP <= 0 - || PlayerManager::players.find(mob->target) == PlayerManager::players.end() || (plr->iSpecialState & CN_SPECIAL_STATE_FLAG__INVULNERABLE)) { mob->target = nullptr; mob->state = MobState::RETREAT;