fix: enemies and summons drop targets that have died

FindTarget kept returning the current target while it stayed inside the
tether radius, even after it died, so enemies stood over dead players
(most visible in long respawn areas like the Battle of Nimbus Station)
and pet or summon AI hovered over enemies playing their death animation.

A dead current target now loses its threat and a new target is picked,
and dead entities are skipped both as proximity candidates and as threat
entries. Players who respawn are picked up again through the usual
proximity and threat paths.

Verified by building WorldServer and the test suite; needs an in-game
check (die to an enemy, the enemy should return to idle or pick another
player).

Fixes #1428

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Aaron Kimbrell
2026-09-26 18:41:58 -05:00
parent 8a2ccb1ae7
commit 363e02e963

View File

@@ -375,6 +375,13 @@ LWOOBJID BaseCombatAIComponent::FindTarget() {
auto* target = GetTargetEntity();
// A target that died is no longer worth attacking, drop it and look for someone else.
if (target != nullptr && target->GetIsDead()) {
SetThreat(m_Target, 0.0f);
target = nullptr;
m_DirtyThreat = true;
}
if (target != nullptr && !m_DirtyThreat) {
const auto targetPosition = target->GetPosition();
@@ -399,7 +406,7 @@ LWOOBJID BaseCombatAIComponent::FindTarget() {
for (const auto& entry : possibleTargets) {
auto* entity = Game::entityManager->GetEntity(entry);
if (entity == nullptr) {
if (entity == nullptr || entity->GetIsDead()) {
continue;
}
@@ -445,7 +452,7 @@ LWOOBJID BaseCombatAIComponent::FindTarget() {
for (const auto& threatTarget : m_ThreatEntries) {
auto* entity = Game::entityManager->GetEntity(threatTarget.first);
if (entity == nullptr) {
if (entity == nullptr || entity->GetIsDead()) {
deadThreats.push_back(threatTarget.first);
continue;