mirror of
https://github.com/mangosfour/server.git
synced 2025-12-17 07:37:03 +00:00
* 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:
parent
ae01d16a73
commit
cf6413edcc
1 changed files with 15 additions and 0 deletions
|
|
@ -265,6 +265,10 @@ HostilReference* ThreatContainer::selectNextVictim(Creature* pAttacker, HostilRe
|
||||||
{
|
{
|
||||||
HostilReference* currentRef = NULL;
|
HostilReference* currentRef = NULL;
|
||||||
bool found = false;
|
bool found = false;
|
||||||
|
|
||||||
|
std::list<HostilReference*>::iterator lastRef = iThreatList.end();
|
||||||
|
lastRef--;
|
||||||
|
|
||||||
for(std::list<HostilReference*>::iterator iter = iThreatList.begin(); iter != iThreatList.end() && !found; ++iter)
|
for(std::list<HostilReference*>::iterator iter = iThreatList.begin(); iter != iThreatList.end() && !found; ++iter)
|
||||||
{
|
{
|
||||||
currentRef = (*iter);
|
currentRef = (*iter);
|
||||||
|
|
@ -272,6 +276,17 @@ HostilReference* ThreatContainer::selectNextVictim(Creature* pAttacker, HostilRe
|
||||||
Unit* target = currentRef->getTarget();
|
Unit* target = currentRef->getTarget();
|
||||||
assert(target); // if the ref has status online the target must be there !
|
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(!pAttacker->IsOutOfThreatArea(target)) // skip non attackable currently targets
|
||||||
{
|
{
|
||||||
if(pCurrentVictim) // select 1.3/1.1 better target in comparison current target
|
if(pCurrentVictim) // select 1.3/1.1 better target in comparison current target
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue