* Implemented second choice aggro targets for creatures. This will prevent players from tanking NPCs while being affected by immunity granting buffs.

This commit is contained in:
arrai 2008-10-18 21:05:34 +02:00
parent ae01d16a73
commit cf6413edcc

View file

@ -265,6 +265,10 @@ HostilReference* ThreatContainer::selectNextVictim(Creature* pAttacker, HostilRe
{
HostilReference* currentRef = NULL;
bool found = false;
std::list<HostilReference*>::iterator lastRef = iThreatList.end();
lastRef--;
for(std::list<HostilReference*>::iterator iter = iThreatList.begin(); iter != iThreatList.end() && !found; ++iter)
{
currentRef = (*iter);
@ -272,6 +276,17 @@ HostilReference* ThreatContainer::selectNextVictim(Creature* pAttacker, HostilRe
Unit* target = currentRef->getTarget();
assert(target); // if the ref has status online the target must be there !
// some units are prefered in comparison to others
if(iter != lastRef && (target->IsImmunedToDamage(pAttacker->GetMeleeDamageSchoolMask(), false) ||
target->hasUnitState(UNIT_STAT_CONFUSED | UNIT_STAT_FLEEING)
) )
{
// current victim is a second choice target, so don't compare threat with it below
if(currentRef == pCurrentVictim)
pCurrentVictim = NULL;
continue;
}
if(!pAttacker->IsOutOfThreatArea(target)) // skip non attackable currently targets
{
if(pCurrentVictim) // select 1.3/1.1 better target in comparison current target