mirror of
https://github.com/mangosfour/server.git
synced 2025-12-12 01:37:00 +00:00
[9832] Move function to select an attacking target from EventAi to Creature class
Also rename function to a more descriptive name, SelectAttackingTarget Signed-off-by: NoFantasy <nofantasy@nf.no>
This commit is contained in:
parent
0cc946e91e
commit
92ab082fc6
5 changed files with 47 additions and 38 deletions
|
|
@ -1793,6 +1793,45 @@ void Creature::SetInCombatWithZone()
|
|||
}
|
||||
}
|
||||
|
||||
Unit* Creature::SelectAttackingTarget(AttackingTarget target, uint32 position) const
|
||||
{
|
||||
if (!CanHaveThreatList())
|
||||
return NULL;
|
||||
|
||||
//ThreatList m_threatlist;
|
||||
ThreatList const& threatlist = getThreatManager().getThreatList();
|
||||
ThreatList::const_iterator i = threatlist.begin();
|
||||
ThreatList::const_reverse_iterator r = threatlist.rbegin();
|
||||
|
||||
if (position >= threatlist.size() || !threatlist.size())
|
||||
return NULL;
|
||||
|
||||
switch(target)
|
||||
{
|
||||
case ATTACKING_TARGET_RANDOM:
|
||||
{
|
||||
advance(i, position + (rand() % (threatlist.size() - position)));
|
||||
return Unit::GetUnit(*this, (*i)->getUnitGuid());
|
||||
}
|
||||
case ATTACKING_TARGET_TOPAGGRO:
|
||||
{
|
||||
advance(i, position);
|
||||
return Unit::GetUnit(*this, (*i)->getUnitGuid());
|
||||
}
|
||||
case ATTACKING_TARGET_BOTTOMAGGRO:
|
||||
{
|
||||
advance(r, position);
|
||||
return Unit::GetUnit(*this, (*r)->getUnitGuid());
|
||||
}
|
||||
// TODO: implement these
|
||||
//case ATTACKING_TARGET_RANDOM_PLAYER:
|
||||
//case ATTACKING_TARGET_TOPAGGRO_PLAYER:
|
||||
//case ATTACKING_TARGET_BOTTOMAGGRO_PLAYER:
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void Creature::_AddCreatureSpellCooldown(uint32 spell_id, time_t end_time)
|
||||
{
|
||||
m_CreatureSpellCooldowns[spell_id] = end_time;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue