Creature/AI: Fix incorrect evade logic (closes #16461)

This commit is contained in:
treeston committed 2016-02-03 21:34:17 +01:00
1 parent fe2a0fda44
commit 53d6431c19
2 files changed
+11 -14

No files matched your search

+6 -14
View File
@@ -12750,7 +12750,7 @@ Unit* Creature::SelectVictim()
}
}
else
return NULL;
return nullptr;
if (target && _IsTargetAcceptable(target) && CanCreatureAttack(target))
{
@@ -12759,14 +12759,6 @@ Unit* Creature::SelectVictim()
return target;
}
// Case where mob is being kited.
// Mob may not be in range to attack or may have dropped target. In any case,
// don't evade if damage received within the last 10 seconds
// Does not apply to world bosses to prevent kiting to cities
if (!isWorldBoss() && !GetInstanceId())
if (time(NULL) - GetLastDamagedTime() <= MAX_AGGRO_RESET_TIME)
return target;
// last case when creature must not go to evade mode:
// it in combat but attacker not make any damage and not enter to aggro radius to have record in threat list
// for example at owner command to pet attack some far away creature
@@ -12775,12 +12767,12 @@ Unit* Creature::SelectVictim()
{
if ((*itr) && !CanCreatureAttack(*itr) && (*itr)->GetTypeId() != TYPEID_PLAYER
&& !(*itr)->ToCreature()->HasUnitTypeMask(UNIT_MASK_CONTROLABLE_GUARDIAN))
return NULL;
return nullptr;
}
/// @todo a vehicle may eat some mob, so mob should not evade
if (GetVehicle())
return NULL;
return nullptr;
// search nearby enemy before enter evade mode
if (HasReactState(REACT_AGGRESSIVE))
@@ -12798,17 +12790,17 @@ Unit* Creature::SelectVictim()
{
if ((*itr)->GetBase()->IsPermanent())
{
AI()->EnterEvadeMode();
AI()->EnterEvadeMode(CreatureAI::EVADE_REASON_OTHER);
break;
}
}
return NULL;
return nullptr;
}
// enter in evade mode in other case
AI()->EnterEvadeMode(CreatureAI::EVADE_REASON_NO_HOSTILES);
return NULL;
return nullptr;
}
//======================================================================