Skip to content

Commit

Permalink
Merge pull request #16666 from Treeston/3.3.5-bodypull
Browse files Browse the repository at this point in the history
[3.3.5] Fix bosses losing interest in the person running at them
  • Loading branch information
Treeston committed Feb 27, 2016
2 parents 31cd082 + b5b7ce4 commit 79a945d
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
3 changes: 3 additions & 0 deletions src/server/game/AI/CreatureAI.cpp
Expand Up @@ -134,7 +134,10 @@ void CreatureAI::MoveInLineOfSight(Unit* who)
return;

if (me->HasReactState(REACT_AGGRESSIVE) && me->CanStartAttack(who, false))
{
me->AddThreat(who, 0.0f); // ensure our initial target is the first thing added to threat list so we don't randomly switch off if DoZoneInCombat is called during the EnterCombat hook

This comment has been minimized.

Copy link
@ccrs

ccrs Feb 27, 2016

Member

I don't agree with this, Attack may return false and therefore no combat will start.

This comment has been minimized.

Copy link
@Treeston

Treeston Feb 28, 2016

Author Member

Good point. bfac62c

AttackStart(who);
}
//else if (who->GetVictim() && me->IsFriendlyTo(who)
// && me->IsWithinDistInMap(who, sWorld->getIntConfig(CONFIG_CREATURE_FAMILY_ASSISTANCE_RADIUS))
// && me->CanStartAttack(who->GetVictim(), true)) /// @todo if we use true, it will not attack it when it arrives
Expand Down
5 changes: 4 additions & 1 deletion src/server/game/Combat/ThreatManager.cpp
Expand Up @@ -335,7 +335,7 @@ HostileReference* ThreatContainer::selectNextVictim(Creature* attacker, HostileR
{
// current victim is a second choice target, so don't compare threat with it below
if (currentRef == currentVictim)
currentVictim = NULL;
currentVictim = nullptr;
++iter;
continue;
}
Expand Down Expand Up @@ -437,12 +437,15 @@ void ThreatManager::_addThreat(Unit* victim, float threat)

if (!ref) // there was no ref => create a new one
{
bool isFirst = iThreatContainer.empty();
// threat has to be 0 here
HostileReference* hostileRef = new HostileReference(victim, this, 0);
iThreatContainer.addReference(hostileRef);
hostileRef->addThreat(threat); // now we add the real threat
if (victim->GetTypeId() == TYPEID_PLAYER && victim->ToPlayer()->IsGameMaster())
hostileRef->setOnlineOfflineState(false); // GM is always offline
else if (isFirst)
setCurrentVictim(hostileRef);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/server/game/Combat/ThreatManager.h
Expand Up @@ -169,7 +169,7 @@ class ThreatContainer

HostileReference* getMostHated() const
{
return iThreatList.empty() ? NULL : iThreatList.front();
return iThreatList.empty() ? nullptr : iThreatList.front();
}

HostileReference* getReferenceByTarget(Unit* victim) const;
Expand Down

0 comments on commit 79a945d

Please sign in to comment.