From 737507d718a048dd42984ecf15780227d67b7edf Mon Sep 17 00:00:00 2001 From: hondacrx Date: Wed, 23 Jun 2021 15:29:09 -0400 Subject: [PATCH] Core/Creature: Adjust SelectVictim behavior. Port From (https://github.com/TrinityCore/TrinityCore/commit/95fb6fe075f0cac7bc1822c7b5a0276a2276d897) --- Source/Game/Entities/Creature/Creature.cs | 37 ++--------------------- 1 file changed, 2 insertions(+), 35 deletions(-) diff --git a/Source/Game/Entities/Creature/Creature.cs b/Source/Game/Entities/Creature/Creature.cs index b66bd00c2..d23022b10 100644 --- a/Source/Game/Entities/Creature/Creature.cs +++ b/Source/Game/Entities/Creature/Creature.cs @@ -924,32 +924,8 @@ namespace Game.Entities { Unit target; - ThreatManager mgr = GetThreatManager(); - - if (mgr.CanHaveThreatList()) - { - target = mgr.SelectVictim(); - while (!target) - { - Unit newTarget = null; - // nothing found to attack - try to find something we're in combat with (but don't have a threat entry for yet) and start attacking it - foreach (var pair in GetCombatManager().GetPvECombatRefs()) - { - newTarget = pair.Value.GetOther(this); - if (!mgr.IsThreatenedBy(newTarget, true)) - { - mgr.AddThreat(newTarget, 0.0f, null, true, true); - Cypher.Assert(mgr.IsThreatenedBy(newTarget, true), $"{GetName()} tried to add combatant {newTarget.GetName()} to threat list, but this failed - potential infinite loop"); // prevent potential infinite loop - break; - } - else - newTarget = null; - } - if (!newTarget) - break; - target = mgr.SelectVictim(); - } - } + if (CanHaveThreatList()) + target = GetThreatManager().SelectVictim(); else if (!HasReactState(ReactStates.Passive)) { // We're a player pet, probably @@ -990,15 +966,6 @@ namespace Game.Entities if (GetVehicle()) return null; - // search nearby enemy before enter evade mode - if (HasReactState(ReactStates.Passive)) - { - target = SelectNearestTargetInAttackDistance(m_CombatDistance != 0 ? m_CombatDistance : SharedConst.AttackDistance); - - if (target && _IsTargetAcceptable(target) && CanCreatureAttack(target)) - return target; - } - var iAuras = GetAuraEffectsByType(AuraType.ModInvisibility); if (!iAuras.Empty()) {