Skip to content

Commit 389d920

Browse files
committed
Spell: Fix spells with negative SPELL_EFFECT_THREAT and SPELL_ATTR_EX_NO_THREAT
1 parent 38a0373 commit 389d920

File tree

3 files changed

+8
-33
lines changed

3 files changed

+8
-33
lines changed

src/game/Combat/ThreatManager.cpp

Lines changed: 6 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -48,25 +48,8 @@ float ThreatCalcHelper::CalcThreat(Unit* hatedUnit, Unit* hatingUnit, float thre
4848

4949
if (threatSpell)
5050
{
51-
// Keep exception to calculate the real threat for SPELL_AURA_MOD_TOTAL_THREAT
52-
bool HasExceptionForNoThreat = false;
53-
for (int i = 0; i < MAX_EFFECT_INDEX; i++)
54-
{
55-
if (threatSpell->EffectApplyAuraName[i] == SPELL_AURA_MOD_TOTAL_THREAT && threatSpell->EffectBasePoints[i] < 0)
56-
{
57-
HasExceptionForNoThreat = true;
58-
break;
59-
}
60-
}
61-
62-
if (!HasExceptionForNoThreat)
63-
{
64-
if (threatSpell->HasAttribute(SPELL_ATTR_EX_NO_THREAT))
65-
return 0.0f;
66-
67-
if (Player* modOwner = hatedUnit->GetSpellModOwner())
68-
modOwner->ApplySpellMod(threatSpell->Id, SPELLMOD_THREAT, threat);
69-
}
51+
if (Player* modOwner = hatedUnit->GetSpellModOwner())
52+
modOwner->ApplySpellMod(threatSpell->Id, SPELLMOD_THREAT, threat);
7053

7154
if (crit)
7255
threat *= hatedUnit->GetTotalAuraMultiplierByMiscMask(SPELL_AURA_MOD_CRITICAL_THREAT, schoolMask);
@@ -502,7 +485,7 @@ void ThreatManager::addThreat(Unit* victim, float threat, bool crit, SpellSchool
502485
{
503486
float redirectedThreat = threat * redirectedMod;
504487
totalMod += redirectedMod;
505-
addThreatDirectly(redirectedTarget, redirectedThreat);
488+
addThreatDirectly(redirectedTarget, redirectedThreat, false);
506489
}
507490
}
508491
if (totalMod != 0.f)
@@ -512,10 +495,10 @@ void ThreatManager::addThreat(Unit* victim, float threat, bool crit, SpellSchool
512495
}
513496
}
514497

515-
addThreatDirectly(victim, calculatedThreat);
498+
addThreatDirectly(victim, calculatedThreat, threatSpell && threatSpell->HasAttribute(SPELL_ATTR_EX_NO_THREAT));
516499
}
517500

518-
void ThreatManager::addThreatDirectly(Unit* victim, float threat)
501+
void ThreatManager::addThreatDirectly(Unit* victim, float threat, bool noNew)
519502
{
520503
HostileReference* ref = iThreatContainer.addThreat(victim, threat);
521504
// Ref is online
@@ -525,7 +508,7 @@ void ThreatManager::addThreatDirectly(Unit* victim, float threat)
525508
else
526509
ref = iThreatOfflineContainer.addThreat(victim, threat);
527510

528-
if (!ref) // there was no ref => create a new one
511+
if (!ref && !noNew) // there was no ref => create a new one
529512
{
530513
HostileReference* hostileReference = new HostileReference(victim, this, 0); // threat has to be 0 here
531514
iThreatContainer.addReference(hostileReference);

src/game/Combat/ThreatManager.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ class ThreatManager
204204
void addThreat(Unit* victim, float threat) { addThreat(victim, threat, false, SPELL_SCHOOL_MASK_NONE, nullptr, false); }
205205

206206
// add threat as raw value (ignore redirections and expection all mods applied already to it
207-
void addThreatDirectly(Unit* victim, float threat);
207+
void addThreatDirectly(Unit* victim, float threat, bool noNew);
208208

209209
void modifyThreatPercent(Unit* victim, int32 threatPercent); // -101 removes whole ref, -100 sets threat to 0, rest modifies it
210210
void modifyAllThreatPercent(int32 threatPercent);

src/game/Spells/SpellEffects.cpp

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7664,7 +7664,7 @@ void Spell::EffectTaunt(SpellEffectIndex eff_idx)
76647664
if (unitTarget->CanHaveThreatList())
76657665
{
76667666
float addedThreat = unitTarget->getThreatManager().GetHighestThreat() - unitTarget->getThreatManager().getThreat(m_caster);
7667-
unitTarget->getThreatManager().addThreatDirectly(m_caster, addedThreat);
7667+
unitTarget->getThreatManager().addThreatDirectly(m_caster, addedThreat, false);
76687668
unitTarget->getThreatManager().setCurrentVictimByTarget(m_caster); // force changes the target to caster of taunt
76697669
}
76707670
// Units without threat lists but with AI are susceptible to attack target interference by taunt effect:
@@ -7975,14 +7975,6 @@ void Spell::EffectThreat(SpellEffectIndex /*eff_idx*/)
79757975
if (!unitTarget->CanHaveThreatList())
79767976
return;
79777977

7978-
if (!m_caster->IsInCombat() || !unitTarget->IsInCombat())
7979-
{
7980-
if (unitTarget->AI())
7981-
unitTarget->AI()->AttackStart(m_caster);
7982-
else
7983-
unitTarget->EngageInCombatWith(m_caster);
7984-
}
7985-
79867978
unitTarget->AddThreat(m_caster, float(damage), false, GetSpellSchoolMask(m_spellInfo), m_spellInfo);
79877979
}
79887980

0 commit comments

Comments
 (0)