aboutsummaryrefslogtreecommitdiff
path: root/src/scripts
diff options
context:
space:
mode:
authorTrazom62 <none@none>2010-04-25 12:59:27 +0200
committerTrazom62 <none@none>2010-04-25 12:59:27 +0200
commiteccf5bf547c9b1648a453695189877c212071c70 (patch)
tree547c424a86c42bfd61944bc2d12d97f4146cec04 /src/scripts
parentb466819333eb551a64cdb02e9d8d25678fbb770e (diff)
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
Diffstat (limited to 'src/scripts')
-rw-r--r--src/scripts/kalimdor/temple_of_ahnqiraj/boss_twinemperors.cpp7
-rw-r--r--src/scripts/northrend/naxxramas/boss_four_horsemen.cpp10
-rw-r--r--src/scripts/outland/tempest_keep/the_eye/boss_alar.cpp2
3 files changed, 14 insertions, 5 deletions
diff --git a/src/scripts/kalimdor/temple_of_ahnqiraj/boss_twinemperors.cpp b/src/scripts/kalimdor/temple_of_ahnqiraj/boss_twinemperors.cpp
index a0a9723cd3c..73f17485f7f 100644
--- a/src/scripts/kalimdor/temple_of_ahnqiraj/boss_twinemperors.cpp
+++ b/src/scripts/kalimdor/temple_of_ahnqiraj/boss_twinemperors.cpp
@@ -258,12 +258,11 @@ struct boss_twinemperorsAI : public ScriptedAI
{
AfterTeleport = false;
me->clearUnitState(UNIT_STAT_STUNNED);
- Unit *nearu = me->SelectNearestTarget(100);
- //DoYell(nearu->GetName(), LANG_UNIVERSAL, 0);
- if (nearu)
+ if (Unit *nearu = me->SelectNearestTarget(100))
{
+ //DoYell(nearu->GetName(), LANG_UNIVERSAL, 0);
AttackStart(nearu);
- me->getThreatManager().addThreat(nearu, 10000);
+ me->AddThreat(nearu, 10000);
}
return true;
}
diff --git a/src/scripts/northrend/naxxramas/boss_four_horsemen.cpp b/src/scripts/northrend/naxxramas/boss_four_horsemen.cpp
index b88d45bf97a..f04b39040db 100644
--- a/src/scripts/northrend/naxxramas/boss_four_horsemen.cpp
+++ b/src/scripts/northrend/naxxramas/boss_four_horsemen.cpp
@@ -236,6 +236,16 @@ struct boss_four_horsemenAI : public BossAI
nextWP = id + 1;
}
+ // switch to "who" if nearer than current target.
+ void 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 MoveInLineOfSight(Unit *who)
{
BossAI::MoveInLineOfSight(who);
diff --git a/src/scripts/outland/tempest_keep/the_eye/boss_alar.cpp b/src/scripts/outland/tempest_keep/the_eye/boss_alar.cpp
index b26836b42e2..af5f1bd95c1 100644
--- a/src/scripts/outland/tempest_keep/the_eye/boss_alar.cpp
+++ b/src/scripts/outland/tempest_keep/the_eye/boss_alar.cpp
@@ -408,7 +408,7 @@ struct boss_alarAI : public ScriptedAI
else
{
Unit *pTarget = NULL;
- pTarget = me->SelectNearestTarget(5);
+ pTarget = me->SelectNearestTargetInAttackDistance(5);
if (pTarget)
me->AI()->AttackStart(pTarget);
else