Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement logic for ATTACKING_TARGET_FARTHEST_AWAY
Signed-off-by: Xfurry <xfurry@cmangos.net>
- Loading branch information
Showing
2 changed files
with
20 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2274,6 +2274,25 @@ Unit* Creature::SelectAttackingTarget(AttackingTarget target, uint32 position, S | |
|
||
break; | ||
} | ||
case ATTACKING_TARGET_FARTHEST_AWAY: | ||
{ | ||
float distance = -1; | ||
Unit* suitableTarget = nullptr; | ||
|
||
for (; itr != threatlist.end(); ++itr) | ||
if (Unit* pTarget = GetMap()->GetUnit((*itr)->getUnitGuid())) | ||
{ | ||
float combatDistance = Creature::GetCombatDistance(pTarget, false); | ||
|
||
if (combatDistance > distance && MeetsSelectAttackingRequirement(pTarget, pSpellInfo, selectFlags)) | ||
{ | ||
distance = combatDistance; | ||
suitableTarget = pTarget; | ||
} | ||
} | ||
|
||
return suitableTarget; | ||
} | ||
} | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
Phatcat
Contributor
|
||
|
||
return nullptr; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
my old variant, more universally:
moved from Spell.cpp to Unit.h: