Skip to content

Commit

Permalink
fix: switch target when unreachable/untarggetable (opentibiabr#1890)
Browse files Browse the repository at this point in the history
  • Loading branch information
luan authored Nov 23, 2023
1 parent 60dd5bd commit 45e622d
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/creatures/monsters/monster.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -773,7 +773,9 @@ void Monster::onThink(uint32_t interval) {
}
} else if (!targetList.empty()) {
const bool attackedCreatureIsDisconnected = attackedCreature && attackedCreature->getPlayer() && attackedCreature->getPlayer()->isDisconnected();
if (!attackedCreature || attackedCreatureIsDisconnected) {
const bool attackedCreatureIsUnattackable = attackedCreature && !canUseAttack(getPosition(), attackedCreature);
const bool attackedCreatureIsUnreachable = targetDistance <= 1 && attackedCreature && followCreature && !hasFollowPath;
if (!attackedCreature || attackedCreatureIsDisconnected || attackedCreatureIsUnattackable || attackedCreatureIsUnreachable) {
if (!followCreature || !hasFollowPath || attackedCreatureIsDisconnected) {
searchTarget(TARGETSEARCH_NEAREST);
} else if (attackedCreature && isFleeing() && !canUseAttack(getPosition(), attackedCreature)) {
Expand Down

0 comments on commit 45e622d

Please sign in to comment.