Skip to content

Commit

Permalink
Implement Eye of Kilrogg threat propagation disabling and remove redu…
Browse files Browse the repository at this point in the history
…ndant code
  • Loading branch information
killerwife committed Aug 17, 2021
1 parent d8d0464 commit 51ab47c
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/game/Combat/ThreatManager.cpp
Expand Up @@ -512,7 +512,7 @@ void ThreatManager::addThreatDirectly(Unit* victim, float threat)
Unit* owner = getOwner();
owner->TriggerAggroLinkingEvent(victim);
Unit* victim_owner = victim->GetMaster();
if (victim_owner && victim_owner->IsAlive() && victim_owner->CanJoinInAttacking(getOwner()) && !victim_owner->hasUnitState(UNIT_STAT_FEIGN_DEATH))
if (victim->IsPropagatingThreatToOwner() && victim_owner && victim_owner->IsAlive() && victim_owner->CanJoinInAttacking(getOwner()))
addThreat(victim_owner, 0.0f); // create a threat to the owner of a pet, if the pet attacks
if (owner->IsOfflineTarget(victim) || victim->IsPlayer() && static_cast<Player*>(victim)->IsGameMaster())
hostileReference->setOnlineOfflineState(false); // GM is always offline
Expand Down
15 changes: 9 additions & 6 deletions src/game/Entities/Unit.cpp
Expand Up @@ -358,6 +358,7 @@ Unit::Unit() :
m_alwaysHit = false;
m_noThreat = false;
m_supportThreatOnly = false;
m_ownerThreatPropagation = true;
m_extraAttacksExecuting = false;
m_debuggingMovement = false;

Expand Down Expand Up @@ -2134,10 +2135,11 @@ void Unit::DealMeleeDamage(CalcDamageInfo* calcDamageInfo, bool durabilityLoss)
// if damage pVictim call AI reaction
victim->AttackedBy(this);

if (Unit* owner = GetOwner())
if (owner->GetTypeId() == TYPEID_UNIT)
if (owner->CanJoinInAttacking(victim))
owner->EngageInCombatWithAggressor(victim);
if (IsPropagatingThreatToOwner())
if (Unit* owner = GetOwner())
if (owner->GetTypeId() == TYPEID_UNIT)
if (owner->CanJoinInAttacking(victim))
owner->EngageInCombatWithAggressor(victim);

for (m_guardianPetsIterator = m_guardianPets.begin(); m_guardianPetsIterator != m_guardianPets.end();)
if (Pet* guardian = GetMap()->GetPet(*(m_guardianPetsIterator++)))
Expand Down Expand Up @@ -9445,7 +9447,7 @@ void Unit::SetInCombatState(bool PvP, Unit* enemy)
// TODO: Unify this combat propagation with linking combat propagation in threat system
Unit* controller = GetMaster();

if (controller && controller->CanJoinInAttacking(enemy))
if (IsPropagatingThreatToOwner() && controller && controller->CanJoinInAttacking(enemy))
{
if (HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PLAYER_CONTROLLED))
{
Expand Down Expand Up @@ -13357,7 +13359,8 @@ void Unit::Uncharm(Unit* charmed, uint32 spellId)
{
attacker->AttackStop(true, true);
attacker->getThreatManager().modifyThreatPercent(charmed, -101); // only remove the possessed creature from threat list because it can be filled by other players
attacker->AddThreat(this);
if (charmed->IsPropagatingThreatToOwner())
attacker->AddThreat(this);
}

// we have to restore initial MotionMaster
Expand Down
4 changes: 4 additions & 0 deletions src/game/Entities/Unit.h
Expand Up @@ -2461,6 +2461,9 @@ class Unit : public WorldObject
void SetSupportThreatOnly(bool state) { m_supportThreatOnly = state; }
bool IsSupportThreatOnly() { return m_supportThreatOnly; }

void DisableThreatPropagationToOwner() { m_ownerThreatPropagation = false; }
bool IsPropagatingThreatToOwner() { return m_ownerThreatPropagation; } // TBC+ - Eye of Kilrogg

float GetAttackDistance(Unit const* pl) const;
virtual uint32 GetDetectionRange() const { return 20.f; }

Expand Down Expand Up @@ -2675,6 +2678,7 @@ class Unit : public WorldObject
bool m_alwaysHit;
bool m_noThreat;
bool m_supportThreatOnly;
bool m_ownerThreatPropagation;
bool m_ignoreRangedTargets; // Ignores ranged targets when picking someone to attack
bool m_debuggingMovement;

Expand Down
1 change: 1 addition & 0 deletions src/game/Spells/SpellAuras.cpp
Expand Up @@ -3063,6 +3063,7 @@ void Aura::HandleAuraDummy(bool apply, bool Real)
if (pet && pet->GetEntry() == 4277)
{
pet->CastSpell(pet, 2585, TRIGGERED_OLD_TRIGGERED);
pet->DisableThreatPropagationToOwner();
}
}
break;
Expand Down

0 comments on commit 51ab47c

Please sign in to comment.