From 7511c756e3309973c47746f7286a1838f4a773f9 Mon Sep 17 00:00:00 2001 From: arrai Date: Sat, 18 Oct 2008 21:05:34 +0200 Subject: [PATCH] * Implemented second choice aggro targets for creatures. This will prevent players from tanking NPCs while being affected by immunity granting buffs. --- src/game/ThreatManager.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/game/ThreatManager.cpp b/src/game/ThreatManager.cpp index c6b8da1da..537e0e4d9 100644 --- a/src/game/ThreatManager.cpp +++ b/src/game/ThreatManager.cpp @@ -265,6 +265,10 @@ HostilReference* ThreatContainer::selectNextVictim(Creature* pAttacker, HostilRe { HostilReference* currentRef = NULL; bool found = false; + + std::list::iterator lastRef = iThreatList.end(); + lastRef--; + for(std::list::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 -- 2.11.4.GIT