Skip to content

Commit

Permalink
Update taunt and threat
Browse files Browse the repository at this point in the history
* Better support for crowd controlled creatures interaction with taunts and aggro
* "Bubblewall" support: taunted creatures now ignore taunter's damage immunity factor when considering switching between targets
  • Loading branch information
Warlockbugs committed Jan 14, 2017
1 parent 1024985 commit 63ee155
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions src/game/ThreatManager.cpp
Expand Up @@ -309,7 +309,7 @@ HostileReference* ThreatContainer::selectNextVictim(Creature* pAttacker, Hostile
// some units are prefered in comparison to others
// if (checkThreatArea) consider IsOutOfThreatArea - expected to be only set for pCurrentVictim
// This prevents dropping valid targets due to 1.1 or 1.3 threat rule vs invalid current target
if (!onlySecondChoiceTargetsFound && pAttacker->IsSecondChoiceTarget(pTarget, pCurrentRef == pCurrentVictim))
if (!onlySecondChoiceTargetsFound && pAttacker->IsSecondChoiceTarget(pTarget, false, pCurrentRef == pCurrentVictim))
{
if (iter != lastRef)
++iter;
Expand Down Expand Up @@ -345,7 +345,7 @@ HostileReference* ThreatContainer::selectNextVictim(Creature* pAttacker, Hostile
{
Unit* pCurrentTarget = pCurrentVictim->getTarget();
MANGOS_ASSERT(pCurrentTarget);
if (pAttacker->IsSecondChoiceTarget(pCurrentTarget, true))
if (pAttacker->IsSecondChoiceTarget(pCurrentTarget, false, true))
{
// CurrentVictim is invalid, so return CurrentRef
found = true;
Expand Down
12 changes: 6 additions & 6 deletions src/game/Unit.cpp
Expand Up @@ -9397,7 +9397,7 @@ void Unit::TauntApply(Unit* taunter)
return;

// Only attack taunter if this is a valid target
if (!hasUnitState(UNIT_STAT_STUNNED | UNIT_STAT_DIED) && !IsSecondChoiceTarget(taunter, true))
if (CanReactInCombat() && !IsSecondChoiceTarget(taunter, true, true))
{
if (GetTargetGuid() || !target)
SetInFront(taunter);
Expand Down Expand Up @@ -9470,7 +9470,7 @@ void Unit::FixateTarget(Unit* pVictim)

//======================================================================

bool Unit::IsSecondChoiceTarget(Unit* pTarget, bool checkThreatArea) const
bool Unit::IsSecondChoiceTarget(Unit* pTarget, bool taunt, bool checkThreatArea) const
{
MANGOS_ASSERT(pTarget);

Expand All @@ -9479,7 +9479,7 @@ bool Unit::IsSecondChoiceTarget(Unit* pTarget, bool checkThreatArea) const

return
pTarget->IsTargetUnderControl(*this) ||
pTarget->IsImmuneToDamage(GetMeleeDamageSchoolMask()) ||
(!taunt && pTarget->IsImmuneToDamage(GetMeleeDamageSchoolMask())) ||
pTarget->hasNegativeAuraWithInterruptFlag(AURA_INTERRUPT_FLAG_DAMAGE) ||
(thisCreature && checkThreatArea && thisCreature->IsOutOfThreatArea(pTarget));
}
Expand Down Expand Up @@ -9512,7 +9512,7 @@ bool Unit::SelectHostileTarget()
else
{
Unit* pFixateTarget = GetMap()->GetUnit(m_fixateTargetGuid);
if (pFixateTarget && pFixateTarget->isAlive() && !IsSecondChoiceTarget(pFixateTarget, true))
if (pFixateTarget && pFixateTarget->isAlive() && !IsSecondChoiceTarget(pFixateTarget, false, true))
target = pFixateTarget;
}
}
Expand All @@ -9528,7 +9528,7 @@ bool Unit::SelectHostileTarget()
{
if ((caster = (*aura)->GetCaster()) && caster->IsInMap(this) &&
caster->isTargetableForAttack() && caster->isInAccessablePlaceFor((Creature*)this) &&
!IsSecondChoiceTarget(caster, true))
!IsSecondChoiceTarget(caster, true, true))
{
target = caster;
break;
Expand All @@ -9542,7 +9542,7 @@ bool Unit::SelectHostileTarget()

if (target)
{
if (!hasUnitState(UNIT_STAT_STUNNED | UNIT_STAT_DIED))
if (CanReactInCombat())
{
SetInFront(target);
if (oldTarget != target)
Expand Down
2 changes: 1 addition & 1 deletion src/game/Unit.h
Expand Up @@ -2097,7 +2097,7 @@ class MANGOS_DLL_SPEC Unit : public WorldObject
void AddThreat(Unit* pVictim, float threat = 0.0f, bool crit = false, SpellSchoolMask schoolMask = SPELL_SCHOOL_MASK_NONE, SpellEntry const* threatSpell = nullptr);
float ApplyTotalThreatModifier(float threat, SpellSchoolMask schoolMask = SPELL_SCHOOL_MASK_NORMAL);
void DeleteThreatList();
bool IsSecondChoiceTarget(Unit* pTarget, bool checkThreatArea) const;
bool IsSecondChoiceTarget(Unit* pTarget, bool taunt, bool checkThreatArea) const;
bool SelectHostileTarget();
void TauntApply(Unit* pVictim);
void TauntFadeOut(Unit* taunter);
Expand Down

0 comments on commit 63ee155

Please sign in to comment.