From eccf5bf547c9b1648a453695189877c212071c70 Mon Sep 17 00:00:00 2001 From: Trazom62 Date: Sun, 25 Apr 2010 12:59:27 +0200 Subject: Refactor Creature::SelectNearestTarget(float dist) This function is used in many scripts to find the nearest enemy within the given distance. However, it had an implicit limit to the ATTACK_DISTANCE. so in many case the "dist" was in fact just ignored. In other case, the ATTACK_DISTANCE is required. So 2 functions are necessary to avoid ambiguities. The refactoring is the split of the function in 2: SelectNearestTarget and SelectNearestTargetInAttackDistance. --HG-- branch : trunk --- src/game/CreatureAI.cpp | 9 --------- 1 file changed, 9 deletions(-) (limited to 'src/game/CreatureAI.cpp') diff --git a/src/game/CreatureAI.cpp b/src/game/CreatureAI.cpp index 62396d528be..fb8f37ae492 100644 --- a/src/game/CreatureAI.cpp +++ b/src/game/CreatureAI.cpp @@ -131,15 +131,6 @@ void CreatureAI::MoveInLineOfSight(Unit *who) // me->GetMotionMaster()->MoveChase(who->getVictim()); } -void CreatureAI::SelectNearestTarget(Unit *who) -{ - if (me->getVictim() && me->GetDistanceOrder(who, me->getVictim()) && me->canAttack(who)) - { - me->getThreatManager().modifyThreatPercent(me->getVictim(), -100); - me->AddThreat(who, 1000000.0f); - } -} - void CreatureAI::EnterEvadeMode() { if (!_EnterEvadeMode()) -- cgit v1.2.3