diff options
| author | Treeston <treeston.mmoc@gmail.com> | 2017-07-01 20:18:02 +0200 |
|---|---|---|
| committer | Shauren <shauren.trinity@gmail.com> | 2017-07-01 20:18:02 +0200 |
| commit | e2a1ccd118d129b96e09ff1a15ed0adb1d4a3897 (patch) | |
| tree | bbe6600c4066078bb7c64a117df457dce0d00b26 /src/server/scripts/EasternKingdoms | |
| parent | 5879eb2198fdb976b9fff136757bf8187adb6cf0 (diff) | |
[3.3.5] Combat/Threat rewrite - prep & refactor (#19966)
* Combat/Threat rewrite (PR #19930) prep work. Mostly refactors, and a compatibility layer on ThreatManager/HostileReference that allows scripts to be changed already.
Diffstat (limited to 'src/server/scripts/EasternKingdoms')
50 files changed, 141 insertions, 227 deletions
diff --git a/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackrockDepths/boss_coren_direbrew.cpp b/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackrockDepths/boss_coren_direbrew.cpp index 7d3d77f52b1..9b17017501b 100644 --- a/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackrockDepths/boss_coren_direbrew.cpp +++ b/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackrockDepths/boss_coren_direbrew.cpp @@ -321,7 +321,7 @@ public: }) .Schedule(Seconds(2), [this](TaskContext mugChuck) { - if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, 0.0f, false, -SPELL_HAS_DARK_BREWMAIDENS_BREW)) + if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, 0.0f, false, true, -SPELL_HAS_DARK_BREWMAIDENS_BREW)) DoCast(target, SPELL_CHUCK_MUG); mugChuck.Repeat(Seconds(4)); }); diff --git a/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackrockDepths/instance_blackrock_depths.cpp b/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackrockDepths/instance_blackrock_depths.cpp index 1ac6dfd542c..cf569cbeba5 100644 --- a/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackrockDepths/instance_blackrock_depths.cpp +++ b/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackrockDepths/instance_blackrock_depths.cpp @@ -376,7 +376,7 @@ public: {//do not call EnterEvadeMode(), it will create infinit loops boss->Respawn(); boss->RemoveAllAuras(); - boss->DeleteThreatList(); + boss->GetThreatManager().ClearAllThreat(); boss->CombatStop(true); boss->LoadCreaturesAddon(); boss->GetMotionMaster()->MoveTargetedHome(); diff --git a/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackwingLair/boss_broodlord_lashlayer.cpp b/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackwingLair/boss_broodlord_lashlayer.cpp index d8403641dfa..d60f821d314 100644 --- a/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackwingLair/boss_broodlord_lashlayer.cpp +++ b/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackwingLair/boss_broodlord_lashlayer.cpp @@ -89,8 +89,8 @@ public: break; case EVENT_KNOCKBACK: DoCastVictim(SPELL_KNOCKBACK); - if (DoGetThreat(me->GetVictim())) - DoModifyThreatPercent(me->GetVictim(), -50); + if (GetThreat(me->GetVictim())) + ModifyThreatByPercent(me->GetVictim(), -50); events.ScheduleEvent(EVENT_KNOCKBACK, urand(15000, 30000)); break; case EVENT_CHECK: diff --git a/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackwingLair/boss_firemaw.cpp b/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackwingLair/boss_firemaw.cpp index 024fc54e6a0..835a6fd77f7 100644 --- a/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackwingLair/boss_firemaw.cpp +++ b/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackwingLair/boss_firemaw.cpp @@ -72,8 +72,8 @@ public: break; case EVENT_WINGBUFFET: DoCastVictim(SPELL_WINGBUFFET); - if (DoGetThreat(me->GetVictim())) - DoModifyThreatPercent(me->GetVictim(), -75); + if (GetThreat(me->GetVictim())) + ModifyThreatByPercent(me->GetVictim(), -75); events.ScheduleEvent(EVENT_WINGBUFFET, 30000); break; case EVENT_FLAMEBUFFET: diff --git a/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackwingLair/boss_flamegor.cpp b/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackwingLair/boss_flamegor.cpp index 31d606975bb..a7cc955295c 100644 --- a/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackwingLair/boss_flamegor.cpp +++ b/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackwingLair/boss_flamegor.cpp @@ -77,8 +77,8 @@ public: break; case EVENT_WINGBUFFET: DoCastVictim(SPELL_WINGBUFFET); - if (DoGetThreat(me->GetVictim())) - DoModifyThreatPercent(me->GetVictim(), -75); + if (GetThreat(me->GetVictim())) + ModifyThreatByPercent(me->GetVictim(), -75); events.ScheduleEvent(EVENT_WINGBUFFET, 30000); break; case EVENT_FRENZY: diff --git a/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackwingLair/boss_nefarian.cpp b/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackwingLair/boss_nefarian.cpp index f213a2be37c..b4b9e5da0e0 100644 --- a/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackwingLair/boss_nefarian.cpp +++ b/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackwingLair/boss_nefarian.cpp @@ -321,7 +321,7 @@ public: DoCast(target, SPELL_SHADOWBOLT); break; } - DoResetThreat(); + ResetThreatList(); events.ScheduleEvent(EVENT_SHADOW_BOLT, urand(3000, 10000)); break; case EVENT_FEAR: diff --git a/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackwingLair/boss_razorgore.cpp b/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackwingLair/boss_razorgore.cpp index b7c4e32188d..14b73446602 100644 --- a/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackwingLair/boss_razorgore.cpp +++ b/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackwingLair/boss_razorgore.cpp @@ -151,10 +151,6 @@ public: break; case EVENT_CONFLAGRATION: DoCastVictim(SPELL_CONFLAGRATION); - // @todo is this even necessary? pretty sure AI ignores targets with disorient by default - if (me->GetVictim() && me->EnsureVictim()->HasAura(SPELL_CONFLAGRATION)) - if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 1, 100, true)) - me->TauntApply(target); events.ScheduleEvent(EVENT_CONFLAGRATION, 30000); break; } diff --git a/src/server/scripts/EasternKingdoms/BlackrockMountain/MoltenCore/boss_baron_geddon.cpp b/src/server/scripts/EasternKingdoms/BlackrockMountain/MoltenCore/boss_baron_geddon.cpp index ef9378df968..f2e2a8e3e15 100644 --- a/src/server/scripts/EasternKingdoms/BlackrockMountain/MoltenCore/boss_baron_geddon.cpp +++ b/src/server/scripts/EasternKingdoms/BlackrockMountain/MoltenCore/boss_baron_geddon.cpp @@ -98,7 +98,7 @@ class boss_baron_geddon : public CreatureScript events.ScheduleEvent(EVENT_INFERNO, 45000); break; case EVENT_IGNITE_MANA: - if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, 0.0f, true, -SPELL_IGNITE_MANA)) + if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, 0.0f, true, true, -SPELL_IGNITE_MANA)) DoCast(target, SPELL_IGNITE_MANA); events.ScheduleEvent(EVENT_IGNITE_MANA, 30000); break; diff --git a/src/server/scripts/EasternKingdoms/BlackrockMountain/MoltenCore/boss_magmadar.cpp b/src/server/scripts/EasternKingdoms/BlackrockMountain/MoltenCore/boss_magmadar.cpp index 1fa9bfeec25..7ee31766add 100644 --- a/src/server/scripts/EasternKingdoms/BlackrockMountain/MoltenCore/boss_magmadar.cpp +++ b/src/server/scripts/EasternKingdoms/BlackrockMountain/MoltenCore/boss_magmadar.cpp @@ -97,7 +97,7 @@ class boss_magmadar : public CreatureScript events.ScheduleEvent(EVENT_PANIC, 35000); break; case EVENT_LAVA_BOMB: - if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, 0.0f, true, -SPELL_LAVA_BOMB)) + if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, 0.0f, true, true, -SPELL_LAVA_BOMB)) DoCast(target, SPELL_LAVA_BOMB); events.ScheduleEvent(EVENT_LAVA_BOMB, 12000); break; diff --git a/src/server/scripts/EasternKingdoms/BlackrockMountain/MoltenCore/boss_ragnaros.cpp b/src/server/scripts/EasternKingdoms/BlackrockMountain/MoltenCore/boss_ragnaros.cpp index 49bb5f11ecc..96af55e719c 100644 --- a/src/server/scripts/EasternKingdoms/BlackrockMountain/MoltenCore/boss_ragnaros.cpp +++ b/src/server/scripts/EasternKingdoms/BlackrockMountain/MoltenCore/boss_ragnaros.cpp @@ -249,7 +249,7 @@ class boss_ragnaros : public CreatureScript //is not very well supported in the core //no it really isnt //so added normaly spawning and banish workaround and attack again after 90 secs. me->AttackStop(); - DoResetThreat(); + ResetThreatList(); me->SetReactState(REACT_PASSIVE); me->InterruptNonMeleeSpells(false); //Root self diff --git a/src/server/scripts/EasternKingdoms/BlackrockMountain/MoltenCore/boss_shazzrah.cpp b/src/server/scripts/EasternKingdoms/BlackrockMountain/MoltenCore/boss_shazzrah.cpp index bf7e1d8a213..9bb68840955 100644 --- a/src/server/scripts/EasternKingdoms/BlackrockMountain/MoltenCore/boss_shazzrah.cpp +++ b/src/server/scripts/EasternKingdoms/BlackrockMountain/MoltenCore/boss_shazzrah.cpp @@ -82,7 +82,7 @@ class boss_shazzrah : public CreatureScript DoCastVictim(SPELL_ARCANE_EXPLOSION); break; case EVENT_SHAZZRAH_CURSE: - if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, 0.0f, true, -SPELL_SHAZZRAH_CURSE)) + if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, 0.0f, true, true, -SPELL_SHAZZRAH_CURSE)) DoCast(target, SPELL_SHAZZRAH_CURSE); events.ScheduleEvent(EVENT_SHAZZRAH_CURSE, urand(25000, 30000)); break; @@ -95,7 +95,7 @@ class boss_shazzrah : public CreatureScript events.ScheduleEvent(EVENT_COUNTERSPELL, urand(16000, 20000)); break; case EVENT_SHAZZRAH_GATE: - DoResetThreat(); + ResetThreatList(); DoCastAOE(SPELL_SHAZZRAH_GATE_DUMMY); events.ScheduleEvent(EVENT_ARCANE_EXPLOSION_TRIGGERED, 2000); events.RescheduleEvent(EVENT_ARCANE_EXPLOSION, urand(3000, 6000)); diff --git a/src/server/scripts/EasternKingdoms/BlackrockMountain/MoltenCore/boss_sulfuron_harbinger.cpp b/src/server/scripts/EasternKingdoms/BlackrockMountain/MoltenCore/boss_sulfuron_harbinger.cpp index 778e4bd9069..6469ddea0fb 100644 --- a/src/server/scripts/EasternKingdoms/BlackrockMountain/MoltenCore/boss_sulfuron_harbinger.cpp +++ b/src/server/scripts/EasternKingdoms/BlackrockMountain/MoltenCore/boss_sulfuron_harbinger.cpp @@ -185,12 +185,12 @@ class npc_flamewaker_priest : public CreatureScript events.ScheduleEvent(EVENT_HEAL, urand(15000, 20000)); break; case EVENT_SHADOW_WORD_PAIN: - if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, 0.0f, true, -SPELL_SHADOWWORDPAIN)) + if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, 0.0f, true, true, -SPELL_SHADOWWORDPAIN)) DoCast(target, SPELL_SHADOWWORDPAIN); events.ScheduleEvent(EVENT_SHADOW_WORD_PAIN, urand(18000, 26000)); break; case EVENT_IMMOLATE: - if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, 0.0f, true, -SPELL_IMMOLATE)) + if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, 0.0f, true, true, -SPELL_IMMOLATE)) DoCast(target, SPELL_IMMOLATE); events.ScheduleEvent(EVENT_IMMOLATE, urand(15000, 25000)); break; diff --git a/src/server/scripts/EasternKingdoms/Gnomeregan/gnomeregan.cpp b/src/server/scripts/EasternKingdoms/Gnomeregan/gnomeregan.cpp index f787da07308..83d0fdcc943 100644 --- a/src/server/scripts/EasternKingdoms/Gnomeregan/gnomeregan.cpp +++ b/src/server/scripts/EasternKingdoms/Gnomeregan/gnomeregan.cpp @@ -214,11 +214,7 @@ public: continue; if (player->IsAlive()) - { - temp->SetInCombatWith(player); - player->SetInCombatWith(temp); - temp->AddThreat(player, 0.0f); - } + AddThreat(player, 0.0f, temp); } } } diff --git a/src/server/scripts/EasternKingdoms/Karazhan/boss_curator.cpp b/src/server/scripts/EasternKingdoms/Karazhan/boss_curator.cpp index 8676bbe9520..44244eef0e7 100644 --- a/src/server/scripts/EasternKingdoms/Karazhan/boss_curator.cpp +++ b/src/server/scripts/EasternKingdoms/Karazhan/boss_curator.cpp @@ -102,7 +102,7 @@ public: switch (eventId) { case EVENT_HATEFUL_BOLT: - if (Unit* target = SelectTarget(SELECT_TARGET_TOPAGGRO, 1)) + if (Unit* target = SelectTarget(SELECT_TARGET_MAXTHREAT, 1)) DoCast(target, SPELL_HATEFUL_BOLT); events.Repeat(Seconds(7), Seconds(15)); break; diff --git a/src/server/scripts/EasternKingdoms/Karazhan/boss_midnight.cpp b/src/server/scripts/EasternKingdoms/Karazhan/boss_midnight.cpp index fa7a27082d8..75b119e9936 100644 --- a/src/server/scripts/EasternKingdoms/Karazhan/boss_midnight.cpp +++ b/src/server/scripts/EasternKingdoms/Karazhan/boss_midnight.cpp @@ -173,12 +173,11 @@ public: scheduler.Schedule(Seconds(10), Seconds(25), [this](TaskContext task) { Unit* target = nullptr; - ThreatContainer::StorageType const& t_list = me->getThreatManager().getThreatList(); std::vector<Unit*> target_list; - for (ThreatContainer::StorageType::const_iterator itr = t_list.begin(); itr != t_list.end(); ++itr) + for (auto* ref : me->GetThreatManager().GetUnsortedThreatList()) { - target = ObjectAccessor::GetUnit(*me, (*itr)->getUnitGuid()); + target = ref->GetVictim(); if (target && !target->IsWithinDist(me, 8.00f, false) && target->IsWithinDist(me, 25.0f, false)) target_list.push_back(target); diff --git a/src/server/scripts/EasternKingdoms/Karazhan/boss_moroes.cpp b/src/server/scripts/EasternKingdoms/Karazhan/boss_moroes.cpp index 8b0f5a7a150..9ab217b6765 100644 --- a/src/server/scripts/EasternKingdoms/Karazhan/boss_moroes.cpp +++ b/src/server/scripts/EasternKingdoms/Karazhan/boss_moroes.cpp @@ -300,14 +300,8 @@ public: if (Blind_Timer <= diff) { - std::list<Unit*> targets; - SelectTargetList(targets, 5, SELECT_TARGET_RANDOM, me->GetCombatReach()*5, true); - for (std::list<Unit*>::const_iterator i = targets.begin(); i != targets.end(); ++i) - if (!me->IsWithinMeleeRange(*i)) - { - DoCast(*i, SPELL_BLIND); - break; - } + if (Unit* target = SelectTarget(SELECT_TARGET_MINDISTANCE, 0, 0.0f, true, false)) + DoCast(target, SPELL_BLIND); Blind_Timer = 40000; } else Blind_Timer -= diff; } diff --git a/src/server/scripts/EasternKingdoms/Karazhan/boss_netherspite.cpp b/src/server/scripts/EasternKingdoms/Karazhan/boss_netherspite.cpp index 36777a5670c..be22ce083ec 100644 --- a/src/server/scripts/EasternKingdoms/Karazhan/boss_netherspite.cpp +++ b/src/server/scripts/EasternKingdoms/Karazhan/boss_netherspite.cpp @@ -227,7 +227,7 @@ public: } // aggro target if Red Beam if (j == RED_PORTAL && me->GetVictim() != target && target->GetTypeId() == TYPEID_PLAYER) - me->getThreatManager().addThreat(target, 100000.0f+DoGetThreat(me->GetVictim())); + AddThreat(target, 100000.0f); } } diff --git a/src/server/scripts/EasternKingdoms/Karazhan/boss_nightbane.cpp b/src/server/scripts/EasternKingdoms/Karazhan/boss_nightbane.cpp index 95510202610..ffabc345b4f 100644 --- a/src/server/scripts/EasternKingdoms/Karazhan/boss_nightbane.cpp +++ b/src/server/scripts/EasternKingdoms/Karazhan/boss_nightbane.cpp @@ -321,7 +321,7 @@ public: me->GetMotionMaster()->MoveAlongSplineChain(POINT_INTRO_END, SPLINE_CHAIN_INTRO_END, false); break; case EVENT_RAIN_OF_BONES: - DoResetThreat(); + ResetThreatList(); if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, 0.0f, true)) { me->SetFacingToObject(target); diff --git a/src/server/scripts/EasternKingdoms/Karazhan/boss_prince_malchezaar.cpp b/src/server/scripts/EasternKingdoms/Karazhan/boss_prince_malchezaar.cpp index e2843844076..837fdad72b3 100644 --- a/src/server/scripts/EasternKingdoms/Karazhan/boss_prince_malchezaar.cpp +++ b/src/server/scripts/EasternKingdoms/Karazhan/boss_prince_malchezaar.cpp @@ -316,19 +316,18 @@ public: if (!info) return; - ThreatContainer::StorageType const& t_list = me->getThreatManager().getThreatList(); + Unit* tank = me->GetThreatManager().GetCurrentVictim(); std::vector<Unit*> targets; - if (t_list.empty()) - return; + for (ThreatReference* ref : me->GetThreatManager().GetUnsortedThreatList()) + { + Unit* target = ref->GetVictim(); + if (target != tank && target->IsAlive() && target->GetTypeId() == TYPEID_PLAYER) + targets.push_back(target); + } - //begin + 1, so we don't target the one with the highest threat - ThreatContainer::StorageType::const_iterator itr = t_list.begin(); - std::advance(itr, 1); - for (; itr != t_list.end(); ++itr) //store the threat list in a different container - if (Unit* target = ObjectAccessor::GetUnit(*me, (*itr)->getUnitGuid())) - if (target->IsAlive() && target->GetTypeId() == TYPEID_PLAYER) - targets.push_back(target); + if (targets.empty()) + return; //cut down to size if we have more than 5 targets while (targets.size() > 5) @@ -455,9 +454,7 @@ public: if (target) { axe->AI()->AttackStart(target); - //axe->getThreatManager().tauntApply(target); //Taunt Apply and fade out does not work properly - // So we'll use a hack to add a lot of threat to our target - axe->AddThreat(target, 10000000.0f); + AddThreat(target, 10000000.0f, axe); } } } @@ -493,11 +490,9 @@ public: if (Unit* axe = ObjectAccessor::GetUnit(*me, axes[i])) { if (axe->GetVictim()) - DoModifyThreatPercent(axe->GetVictim(), -100); + ResetThreat(axe->GetVictim(), axe); if (target) - axe->AddThreat(target, 1000000.0f); - //axe->getThreatManager().tauntFadeOut(axe->GetVictim()); - //axe->getThreatManager().tauntApply(target); + AddThreat(target, 1000000.0f, axe); } } } diff --git a/src/server/scripts/EasternKingdoms/Karazhan/boss_shade_of_aran.cpp b/src/server/scripts/EasternKingdoms/Karazhan/boss_shade_of_aran.cpp index 0f44933caeb..4309ae2d31f 100644 --- a/src/server/scripts/EasternKingdoms/Karazhan/boss_shade_of_aran.cpp +++ b/src/server/scripts/EasternKingdoms/Karazhan/boss_shade_of_aran.cpp @@ -185,19 +185,11 @@ public: void FlameWreathEffect() { std::vector<Unit*> targets; - ThreatContainer::StorageType const& t_list = me->getThreatManager().getThreatList(); - - if (t_list.empty()) - return; - //store the threat list in a different container - for (ThreatContainer::StorageType::const_iterator itr = t_list.begin(); itr!= t_list.end(); ++itr) - { - Unit* target = ObjectAccessor::GetUnit(*me, (*itr)->getUnitGuid()); - //only on alive players - if (target && target->IsAlive() && target->GetTypeId() == TYPEID_PLAYER) - targets.push_back(target); - } + for (auto* ref : me->GetThreatManager().GetUnsortedThreatList()) + if (Player* target = ref->GetVictim()->ToPlayer()) + if (target->IsAlive()) + targets.push_back(target); //cut down to size if we have more than 3 targets while (targets.size() > 3) diff --git a/src/server/scripts/EasternKingdoms/Karazhan/boss_terestian_illhoof.cpp b/src/server/scripts/EasternKingdoms/Karazhan/boss_terestian_illhoof.cpp index 37c944500e5..85b9ddf84bf 100644 --- a/src/server/scripts/EasternKingdoms/Karazhan/boss_terestian_illhoof.cpp +++ b/src/server/scripts/EasternKingdoms/Karazhan/boss_terestian_illhoof.cpp @@ -126,7 +126,7 @@ public: events.Repeat(Seconds(42)); break; case EVENT_SHADOWBOLT: - if (Unit* target = SelectTarget(SELECT_TARGET_TOPAGGRO, 0)) + if (Unit* target = SelectTarget(SELECT_TARGET_MAXTHREAT, 0)) DoCast(target, SPELL_SHADOW_BOLT); events.Repeat(Seconds(4), Seconds(10)); break; diff --git a/src/server/scripts/EasternKingdoms/Karazhan/bosses_opera.cpp b/src/server/scripts/EasternKingdoms/Karazhan/bosses_opera.cpp index 9a01970f68b..68dee5eadc8 100644 --- a/src/server/scripts/EasternKingdoms/Karazhan/bosses_opera.cpp +++ b/src/server/scripts/EasternKingdoms/Karazhan/bosses_opera.cpp @@ -924,11 +924,11 @@ public: { Talk(SAY_WOLF_HOOD); DoCast(target, SPELL_LITTLE_RED_RIDING_HOOD, true); - TempThreat = DoGetThreat(target); + TempThreat = GetThreat(target); if (TempThreat) - DoModifyThreatPercent(target, -100); + ModifyThreatByPercent(target, -100); HoodGUID = target->GetGUID(); - me->AddThreat(target, 1000000.0f); + AddThreat(target, 1000000.0f); ChaseTimer = 20000; IsChasing = true; } @@ -940,9 +940,9 @@ public: if (Unit* target = ObjectAccessor::GetUnit(*me, HoodGUID)) { HoodGUID.Clear(); - if (DoGetThreat(target)) - DoModifyThreatPercent(target, -100); - me->AddThreat(target, TempThreat); + if (GetThreat(target)) + ModifyThreatByPercent(target, -100); + AddThreat(target, TempThreat); TempThreat = 0; } @@ -1257,7 +1257,7 @@ public: Julianne->GetMotionMaster()->Clear(); Julianne->setDeathState(JUST_DIED); Julianne->CombatStop(true); - Julianne->DeleteThreatList(); + Julianne->GetThreatManager().ClearAllThreat(); Julianne->SetUInt32Value(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_LOOTABLE); } return; @@ -1285,7 +1285,7 @@ public: Creature* Julianne = (ObjectAccessor::GetCreature((*me), JulianneGUID)); if (Julianne && Julianne->GetVictim()) { - me->AddThreat(Julianne->GetVictim(), 1.0f); + AddThreat(Julianne->GetVictim(), 1.0f); AttackStart(Julianne->GetVictim()); } } @@ -1527,7 +1527,7 @@ void boss_julianne::boss_julianneAI::DamageTaken(Unit* /*done_by*/, uint32 &dama Romulo->GetMotionMaster()->Clear(); Romulo->setDeathState(JUST_DIED); Romulo->CombatStop(true); - Romulo->DeleteThreatList(); + Romulo->GetThreatManager().ClearAllThreat(); Romulo->SetUInt32Value(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_LOOTABLE); } diff --git a/src/server/scripts/EasternKingdoms/MagistersTerrace/boss_felblood_kaelthas.cpp b/src/server/scripts/EasternKingdoms/MagistersTerrace/boss_felblood_kaelthas.cpp index 600ab5d379b..5cf03b678f6 100644 --- a/src/server/scripts/EasternKingdoms/MagistersTerrace/boss_felblood_kaelthas.cpp +++ b/src/server/scripts/EasternKingdoms/MagistersTerrace/boss_felblood_kaelthas.cpp @@ -199,15 +199,15 @@ public: if (!summonedUnit) return; - ThreatContainer::StorageType const& threatlist = me->getThreatManager().getThreatList(); + ThreatContainer::StorageType const& threatlist = me->GetThreatManager().getThreatList(); ThreatContainer::StorageType::const_iterator i = threatlist.begin(); for (i = threatlist.begin(); i != threatlist.end(); ++i) { Unit* unit = ObjectAccessor::GetUnit(*me, (*i)->getUnitGuid()); if (unit && unit->IsAlive()) { - float threat = me->getThreatManager().getThreat(unit); - summonedUnit->AddThreat(unit, threat); + float threat = me->GetThreatManager().getThreat(unit); + AddThreat(unit, threat, summonedUnit); } } } @@ -217,7 +217,7 @@ public: float x = KaelLocations[0][0]; float y = KaelLocations[0][1]; me->UpdatePosition(x, y, LOCATION_Z, 0.0f); - ThreatContainer::StorageType threatlist = me->getThreatManager().getThreatList(); + ThreatContainer::StorageType threatlist = me->GetThreatManager().getThreatList(); ThreatContainer::StorageType::const_iterator i = threatlist.begin(); for (i = threatlist.begin(); i != threatlist.end(); ++i) { @@ -230,7 +230,7 @@ public: void CastGravityLapseKnockUp() { - ThreatContainer::StorageType threatlist = me->getThreatManager().getThreatList(); + ThreatContainer::StorageType threatlist = me->GetThreatManager().getThreatList(); ThreatContainer::StorageType::const_iterator i = threatlist.begin(); for (i = threatlist.begin(); i != threatlist.end(); ++i) { @@ -243,7 +243,7 @@ public: void CastGravityLapseFly() // Use Fly Packet hack for now as players can't cast "fly" spells unless in map 530. Has to be done a while after they get knocked into the air... { - ThreatContainer::StorageType threatlist = me->getThreatManager().getThreatList(); + ThreatContainer::StorageType threatlist = me->GetThreatManager().getThreatList(); ThreatContainer::StorageType::const_iterator i = threatlist.begin(); for (i = threatlist.begin(); i != threatlist.end(); ++i) { @@ -259,7 +259,7 @@ public: void RemoveGravityLapse() { - ThreatContainer::StorageType threatlist = me->getThreatManager().getThreatList(); + ThreatContainer::StorageType threatlist = me->GetThreatManager().getThreatList(); ThreatContainer::StorageType::const_iterator i = threatlist.begin(); for (i = threatlist.begin(); i != threatlist.end(); ++i) { @@ -399,7 +399,7 @@ public: if (Orb && target) { Orb->SetSpeedRate(MOVE_RUN, 0.5f); - Orb->AddThreat(target, 1000000.0f); + AddThreat(target, 1000000.0f, Orb); Orb->AI()->AttackStart(target); } } @@ -680,7 +680,7 @@ public: { if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, 100, true)) { - me->AddThreat(target, 1.0f); + AddThreat(target, 1.0f); me->TauntApply(target); AttackStart(target); } diff --git a/src/server/scripts/EasternKingdoms/MagistersTerrace/boss_priestess_delrissa.cpp b/src/server/scripts/EasternKingdoms/MagistersTerrace/boss_priestess_delrissa.cpp index 8cddec4b58f..da54f79f6c7 100644 --- a/src/server/scripts/EasternKingdoms/MagistersTerrace/boss_priestess_delrissa.cpp +++ b/src/server/scripts/EasternKingdoms/MagistersTerrace/boss_priestess_delrissa.cpp @@ -169,16 +169,9 @@ public: Talk(SAY_AGGRO); for (uint8 i = 0; i < MAX_ACTIVE_LACKEY; ++i) - { if (Unit* pAdd = ObjectAccessor::GetUnit(*me, m_auiLackeyGUID[i])) - { - if (!pAdd->GetVictim()) - { - who->SetInCombatWith(pAdd); - pAdd->AddThreat(who, 0.0f); - } - } - } + if (!pAdd->IsEngaged()) + AddThreat(who, 0.0f, pAdd); instance->SetBossState(DATA_DELRISSA, IN_PROGRESS); } @@ -402,25 +395,13 @@ struct boss_priestess_lackey_commonAI : public ScriptedAI return; for (uint8 i = 0; i < MAX_ACTIVE_LACKEY; ++i) - { if (Unit* pAdd = ObjectAccessor::GetUnit(*me, m_auiLackeyGUIDs[i])) - { - if (!pAdd->GetVictim() && pAdd != me) - { - who->SetInCombatWith(pAdd); - pAdd->AddThreat(who, 0.0f); - } - } - } + if (!pAdd->IsEngaged() && pAdd != me) + AddThreat(who, 0.0f, pAdd); if (Creature* pDelrissa = ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_DELRISSA))) - { - if (pDelrissa->IsAlive() && !pDelrissa->GetVictim()) - { - who->SetInCombatWith(pDelrissa); - pDelrissa->AddThreat(who, 0.0f); - } - } + if (pDelrissa->IsAlive() && !pDelrissa->IsEngaged()) + AddThreat(who, 0.0f, pDelrissa); } void JustDied(Unit* /*killer*/) override @@ -477,7 +458,7 @@ struct boss_priestess_lackey_commonAI : public ScriptedAI if (ResetThreatTimer <= diff) { - DoResetThreat(); + ResetThreatList(); ResetThreatTimer = urand(5000, 20000); } else ResetThreatTimer -= diff; } @@ -549,10 +530,10 @@ public: Unit* unit = SelectTarget(SELECT_TARGET_RANDOM, 0); - DoResetThreat(); + ResetThreatList(); if (unit) - me->AddThreat(unit, 1000.0f); + AddThreat(unit, 1000.0f); InVanish = true; Vanish_Timer = 30000; @@ -874,7 +855,7 @@ public: if (Blink_Timer <= diff) { bool InMeleeRange = false; - ThreatContainer::StorageType const& t_list = me->getThreatManager().getThreatList(); + ThreatContainer::StorageType const& t_list = me->GetThreatManager().getThreatList(); for (ThreatContainer::StorageType::const_iterator itr = t_list.begin(); itr!= t_list.end(); ++itr) { if (Unit* target = ObjectAccessor::GetUnit(*me, (*itr)->getUnitGuid())) @@ -968,7 +949,7 @@ public: if (Intercept_Stun_Timer <= diff) { bool InMeleeRange = false; - ThreatContainer::StorageType const& t_list = me->getThreatManager().getThreatList(); + ThreatContainer::StorageType const& t_list = me->GetThreatManager().getThreatList(); for (ThreatContainer::StorageType::const_iterator itr = t_list.begin(); itr!= t_list.end(); ++itr) { if (Unit* target = ObjectAccessor::GetUnit(*me, (*itr)->getUnitGuid())) diff --git a/src/server/scripts/EasternKingdoms/ScarletEnclave/chapter5.cpp b/src/server/scripts/EasternKingdoms/ScarletEnclave/chapter5.cpp index bc950388ec7..5484bb78c2f 100644 --- a/src/server/scripts/EasternKingdoms/ScarletEnclave/chapter5.cpp +++ b/src/server/scripts/EasternKingdoms/ScarletEnclave/chapter5.cpp @@ -430,7 +430,7 @@ public: if (me->Attack(who, true)) { - me->AddThreat(who, 0.0f); + AddThreat(who, 0.0f); me->SetInCombatWith(who); who->SetInCombatWith(me); DoStartMovement(who); @@ -1384,7 +1384,7 @@ public: if (me->HasAura(SPELL_THE_MIGHT_OF_MOGRAINE)) me->RemoveAurasDueToSpell(SPELL_THE_MIGHT_OF_MOGRAINE); me->RemoveAllAuras(); - me->DeleteThreatList(); + me->GetThreatManager().ClearAllThreat(); me->CombatStop(true); me->InterruptNonMeleeSpells(false); me->SetWalk(false); @@ -1405,7 +1405,7 @@ public: if (Creature* temp = ObjectAccessor::GetCreature(*me, uiKorfaxGUID)) { temp->RemoveAllAuras(); - temp->DeleteThreatList(); + temp->GetThreatManager().ClearAllThreat(); temp->CombatStop(true); temp->AttackStop(); temp->SetFaction(me->GetFaction()); @@ -1416,7 +1416,7 @@ public: if (Creature* temp = ObjectAccessor::GetCreature(*me, uiMaxwellGUID)) { temp->RemoveAllAuras(); - temp->DeleteThreatList(); + temp->GetThreatManager().ClearAllThreat(); temp->CombatStop(true); temp->AttackStop(); temp->SetFaction(me->GetFaction()); @@ -1427,7 +1427,7 @@ public: if (Creature* temp = ObjectAccessor::GetCreature(*me, uiEligorGUID)) { temp->RemoveAllAuras(); - temp->DeleteThreatList(); + temp->GetThreatManager().ClearAllThreat(); temp->CombatStop(true); temp->AttackStop(); temp->SetFaction(me->GetFaction()); @@ -1439,7 +1439,7 @@ public: if (Creature* temp = ObjectAccessor::GetCreature(*me, uiKoltiraGUID)) { temp->RemoveAllAuras(); - temp->DeleteThreatList(); + temp->GetThreatManager().ClearAllThreat(); temp->CombatStop(true); temp->AttackStop(); temp->SetFaction(me->GetFaction()); @@ -1454,7 +1454,7 @@ public: if (Creature* temp = ObjectAccessor::GetCreature(*me, uiThassarianGUID)) { temp->RemoveAllAuras(); - temp->DeleteThreatList(); + temp->GetThreatManager().ClearAllThreat(); temp->CombatStop(true); temp->AttackStop(); temp->SetFaction(me->GetFaction()); @@ -1484,15 +1484,11 @@ public: { if (Creature* temp = ObjectAccessor::GetCreature(*me, ui_GUID)) if (temp->IsAlive()) - if (Unit* pTarger = SelectTarget(SELECT_TARGET_RANDOM, 0)) - if (pTarger->IsAlive()) + if (Unit* pTarget = SelectTarget(SELECT_TARGET_RANDOM, 0)) + if (pTarget->IsAlive()) { - // temp->DeleteThreatList(); - temp->AddThreat(pTarger, 0.0f); - temp->AI()->AttackStart(pTarger); - temp->SetInCombatWith(pTarger); - pTarger->SetInCombatWith(temp); - // temp->GetMotionMaster()->MoveChase(pTarger, 20.0f); + AddThreat(pTarget, 0.0f, temp); + temp->AI()->AttackStart(pTarget); } } @@ -1550,7 +1546,7 @@ public: { temp = me->SummonCreature(NPC_DEFENDER_OF_THE_LIGHT, LightofDawnLoc[0].GetPositionWithOffset({ float(rand32() % 30), float(rand32() % 30), 0.0f, 0.0f }), TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 300000); temp->SetFaction(FACTION_SCARLET_CRUSADE); - me->AddThreat(temp, 0.0f); + AddThreat(temp, 0.0f); uiDefenderGUID[i] = temp->GetGUID(); } } @@ -1561,7 +1557,7 @@ public: { temp = me->SummonCreature(NPC_RIMBLAT_EARTHSHATTER, LightofDawnLoc[0].GetPositionWithOffset({ float(rand32() % 30), float(rand32() % 30), 0.0f, 0.0f }), TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 300000); temp->SetFaction(FACTION_SCARLET_CRUSADE); - me->AddThreat(temp, 0.0f); + AddThreat(temp, 0.0f); uiEarthshatterGUID[i] = temp->GetGUID(); } } @@ -1570,7 +1566,7 @@ public: { temp = me->SummonCreature(NPC_KORFAX_CHAMPION_OF_THE_LIGHT, LightofDawnLoc[0].GetPositionWithOffset({ float(rand32() % 30), float(rand32() % 30), 0.0f, 0.0f }), TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 600000); temp->SetFaction(FACTION_SCARLET_CRUSADE); - me->AddThreat(temp, 0.0f); + AddThreat(temp, 0.0f); uiKorfaxGUID = temp->GetGUID(); } temp = ObjectAccessor::GetCreature(*me, uiMaxwellGUID); @@ -1578,7 +1574,7 @@ public: { temp = me->SummonCreature(NPC_LORD_MAXWELL_TYROSUS, LightofDawnLoc[0].GetPositionWithOffset({ float(rand32() % 30), float(rand32() % 30), 0.0f, 0.0f }), TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 600000); temp->SetFaction(FACTION_SCARLET_CRUSADE); - me->AddThreat(temp, 0.0f); + AddThreat(temp, 0.0f); uiMaxwellGUID = temp->GetGUID(); } temp = ObjectAccessor::GetCreature(*me, uiEligorGUID); @@ -1586,7 +1582,7 @@ public: { temp = me->SummonCreature(NPC_COMMANDER_ELIGOR_DAWNBRINGER, LightofDawnLoc[0].GetPositionWithOffset({ float(rand32() % 30), float(rand32() % 30), 0.0f, 0.0f }), TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 600000); temp->SetFaction(FACTION_SCARLET_CRUSADE); - me->AddThreat(temp, 0.0f); + AddThreat(temp, 0.0f); uiEligorGUID = temp->GetGUID(); } temp = ObjectAccessor::GetCreature(*me, uiRayneGUID); @@ -1594,7 +1590,7 @@ public: { temp = me->SummonCreature(NPC_RAYNE, LightofDawnLoc[0].GetPositionWithOffset({ float(rand32() % 30), float(rand32() % 30), 0.0f, 0.0f }), TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 300000); temp->SetFaction(FACTION_SCARLET_CRUSADE); - me->AddThreat(temp, 0.0f); + AddThreat(temp, 0.0f); uiRayneGUID = temp->GetGUID(); } } diff --git a/src/server/scripts/EasternKingdoms/ScarletMonastery/boss_headless_horseman.cpp b/src/server/scripts/EasternKingdoms/ScarletMonastery/boss_headless_horseman.cpp index 5dcbf9490ec..d946e98706e 100644 --- a/src/server/scripts/EasternKingdoms/ScarletMonastery/boss_headless_horseman.cpp +++ b/src/server/scripts/EasternKingdoms/ScarletMonastery/boss_headless_horseman.cpp @@ -606,14 +606,6 @@ public: DoCast(me, SPELL_HEAD); caster->GetMotionMaster()->Clear(false); caster->GetMotionMaster()->MoveFollow(me, 6, float(urand(0, 5))); - //DoResetThreat();//not sure if need - ThreatContainer::StorageType threatlist = caster->getThreatManager().getThreatList(); - for (ThreatContainer::StorageType::const_iterator itr = threatlist.begin(); itr != threatlist.end(); ++itr) - { - Unit* unit = ObjectAccessor::GetUnit(*me, (*itr)->getUnitGuid()); - if (unit && unit->IsAlive() && unit != caster) - me->AddThreat(unit, caster->getThreatManager().getThreat(unit)); - } } } @@ -863,7 +855,7 @@ public: if (!who || !me->IsValidAttackTarget(who) || me->GetVictim()) return; - me->AddThreat(who, 0.0f); + AddThreat(who, 0.0f); if (sprouted) DoStartMovement(who); } diff --git a/src/server/scripts/EasternKingdoms/ScarletMonastery/boss_high_inquisitor_fairbanks.cpp b/src/server/scripts/EasternKingdoms/ScarletMonastery/boss_high_inquisitor_fairbanks.cpp index 92db652813a..cfe5ae32599 100644 --- a/src/server/scripts/EasternKingdoms/ScarletMonastery/boss_high_inquisitor_fairbanks.cpp +++ b/src/server/scripts/EasternKingdoms/ScarletMonastery/boss_high_inquisitor_fairbanks.cpp @@ -120,7 +120,7 @@ public: //Sleep_Timer if (Sleep_Timer <= diff) { - if (Unit* target = SelectTarget(SELECT_TARGET_TOPAGGRO, 0)) + if (Unit* target = SelectTarget(SELECT_TARGET_MAXTHREAT, 0)) DoCast(target, SPELL_SLEEP); Sleep_Timer = 30000; diff --git a/src/server/scripts/EasternKingdoms/Scholomance/boss_jandice_barov.cpp b/src/server/scripts/EasternKingdoms/Scholomance/boss_jandice_barov.cpp index e4d7140e6f1..fc8e74c0052 100644 --- a/src/server/scripts/EasternKingdoms/Scholomance/boss_jandice_barov.cpp +++ b/src/server/scripts/EasternKingdoms/Scholomance/boss_jandice_barov.cpp @@ -91,7 +91,7 @@ public: DoCast(SPELL_ILLUSION); me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); me->SetDisplayId(11686); // Invisible Model - DoModifyThreatPercent(me->GetVictim(), -99); + ModifyThreatByPercent(me->GetVictim(), -99); events.ScheduleEvent(EVENT_SET_VISIBILITY, 3000); events.ScheduleEvent(EVENT_ILLUSION, 25000); break; diff --git a/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_brutallus.cpp b/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_brutallus.cpp index 66ef84c2273..0f8e0fc98f7 100644 --- a/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_brutallus.cpp +++ b/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_brutallus.cpp @@ -321,14 +321,8 @@ public: if (BurnTimer <= diff) { - std::list<Unit*> targets; - SelectTargetList(targets, 10, SELECT_TARGET_RANDOM, 100, true); - for (std::list<Unit*>::const_iterator i = targets.begin(); i != targets.end(); ++i) - if (!(*i)->HasAura(SPELL_BURN)) - { - (*i)->CastSpell((*i), SPELL_BURN, true); - break; - } + if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, 100.0f, true, true, -SPELL_BURN)) + target->CastSpell(target, SPELL_BURN, true); BurnTimer = urand(60000, 180000); } else BurnTimer -= diff; diff --git a/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_eredar_twins.cpp b/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_eredar_twins.cpp index 51aad495c37..c872a654a1a 100644 --- a/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_eredar_twins.cpp +++ b/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_eredar_twins.cpp @@ -120,7 +120,7 @@ public: if (temp->isDead()) temp->Respawn(); else if (temp->GetVictim()) - me->getThreatManager().addThreat(temp->GetVictim(), 0.0f); + AddThreat(temp->GetVictim(), 0.0f); } if (!me->IsInCombat()) @@ -275,7 +275,7 @@ public: temp = DoSpawnCreature(NPC_SHADOW_IMAGE, 0, 0, 0, 0, TEMPSUMMON_CORPSE_DESPAWN, 10000); if (temp && target) { - temp->AddThreat(target, 1000000); //don't change target(healers) + AddThreat(target, 1000000.0f, temp); //don't change target(healers) temp->AI()->AttackStart(target); } } @@ -372,7 +372,7 @@ public: if (temp->isDead()) temp->Respawn(); else if (temp->GetVictim()) - me->getThreatManager().addThreat(temp->GetVictim(), 0.0f); + AddThreat(temp->GetVictim(), 0.0f); } if (!me->IsInCombat()) @@ -550,7 +550,7 @@ public: Creature* sisiter = instance->GetCreature(DATA_SACROLASH); if (sisiter && !sisiter->isDead() && sisiter->GetVictim()) { - me->AddThreat(sisiter->GetVictim(), 0.0f); + AddThreat(sisiter->GetVictim(), 0.0f); DoStartNoMovement(sisiter->GetVictim()); me->Attack(sisiter->GetVictim(), false); } diff --git a/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_felmyst.cpp b/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_felmyst.cpp index 045f6d956bb..88254211099 100644 --- a/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_felmyst.cpp +++ b/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_felmyst.cpp @@ -385,7 +385,7 @@ public: uiFlightCount = 4; break; case 9: - if (Unit* target = SelectTarget(SELECT_TARGET_TOPAGGRO)) + if (Unit* target = SelectTarget(SELECT_TARGET_MAXTHREAT)) DoStartMovement(target); else { @@ -397,7 +397,7 @@ public: me->SetDisableGravity(false); me->HandleEmoteCommand(EMOTE_ONESHOT_LAND); EnterPhase(PHASE_GROUND); - AttackStart(SelectTarget(SELECT_TARGET_TOPAGGRO)); + AttackStart(SelectTarget(SELECT_TARGET_MAXTHREAT)); break; } ++uiFlightCount; diff --git a/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_kalecgos.cpp b/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_kalecgos.cpp index f6c02074774..5dd4a3248ac 100644 --- a/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_kalecgos.cpp +++ b/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_kalecgos.cpp @@ -208,7 +208,7 @@ public: me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE + UNIT_FLAG_NOT_SELECTABLE); me->InterruptNonMeleeSpells(true); me->RemoveAllAuras(); - me->DeleteThreatList(); + me->GetThreatManager().ClearAllThreat(); me->CombatStop(); ++TalkSequence; } @@ -301,7 +301,7 @@ public: if (SpectralBlastTimer <= diff) { - ThreatContainer::StorageType const& m_threatlist = me->getThreatManager().getThreatList(); + ThreatContainer::StorageType const& m_threatlist = me->GetThreatManager().getThreatList(); std::list<Unit*> targetList; for (ThreatContainer::StorageType::const_iterator itr = m_threatlist.begin(); itr!= m_threatlist.end(); ++itr) { @@ -648,7 +648,7 @@ public: { KalecGUID = Kalec->GetGUID(); me->CombatStart(Kalec); - me->AddThreat(Kalec, 100.0f); + AddThreat(Kalec, 100.0f); Kalec->setActive(true); } Talk(SAY_SATH_AGGRO); @@ -775,12 +775,12 @@ public: if (ResetThreat <= diff) { - ThreatContainer::StorageType threatlist = me->getThreatManager().getThreatList(); + ThreatContainer::StorageType threatlist = me->GetThreatManager().getThreatList(); for (ThreatContainer::StorageType::const_iterator itr = threatlist.begin(); itr != threatlist.end(); ++itr) { if (Unit* unit = ObjectAccessor::GetUnit(*me, (*itr)->getUnitGuid())) if (unit->GetPositionZ() > me->GetPositionZ() + 5) - me->getThreatManager().modifyThreatPercent(unit, -100); + me->GetThreatManager().ModifyThreatByPercent(unit, -100); } ResetThreat = 1000; } else ResetThreat -= diff; diff --git a/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_kiljaeden.cpp b/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_kiljaeden.cpp index 4e841a82e14..5dbd255ecd2 100644 --- a/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_kiljaeden.cpp +++ b/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_kiljaeden.cpp @@ -469,7 +469,7 @@ public: break; case NPC_KILJAEDEN: summoned->CastSpell(summoned, SPELL_REBIRTH, false); - summoned->AddThreat(me->GetVictim(), 1.0f); + AddThreat(me->GetVictim(), 1.0f, summoned); break; } summons.Summon(summoned); @@ -670,7 +670,7 @@ public: Talk(SAY_KJ_REFLECTION); for (uint8 i = 0; i < 4; ++i) { - if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, 100, true, -SPELL_VENGEANCE_OF_THE_BLUE_FLIGHT)) + if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, 100, true, true, -SPELL_VENGEANCE_OF_THE_BLUE_FLIGHT)) { float x, y, z; target->GetPosition(x, y, z); @@ -955,7 +955,7 @@ public: { instance->SetBossState(DATA_KILJAEDEN, IN_PROGRESS); if (Creature* pControl = instance->GetCreature(DATA_KILJAEDEN_CONTROLLER)) - pControl->AddThreat(who, 1.0f); + AddThreat(who, 1.0f, pControl); me->InterruptNonMeleeSpells(true); } @@ -991,15 +991,8 @@ public: if (FelfirePortalTimer <= diff) { if (Creature* pPortal = DoSpawnCreature(NPC_FELFIRE_PORTAL, 0, 0, 0, 0, TEMPSUMMON_TIMED_DESPAWN, 20000)) - { - ThreatContainer::StorageType const& threatlist = me->getThreatManager().getThreatList(); - for (ThreatContainer::StorageType::const_iterator itr = threatlist.begin(); itr != threatlist.end(); ++itr) - { - Unit* unit = ObjectAccessor::GetUnit(*me, (*itr)->getUnitGuid()); - if (unit) - pPortal->AddThreat(unit, 1.0f); - } - } + for (ThreatReference* ref : me->GetThreatManager().GetUnsortedThreatList()) + AddThreat(ref->GetVictim(), 1.0f, pPortal); FelfirePortalTimer = 20000; } else FelfirePortalTimer -= diff; @@ -1059,7 +1052,7 @@ public: if (uiSpawnFiendTimer <= diff) { if (Creature* pFiend = DoSpawnCreature(NPC_VOLATILE_FELFIRE_FIEND, 0, 0, 0, 0, TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 20000)) - pFiend->AddThreat(SelectTarget(SELECT_TARGET_RANDOM, 0), 100000.0f); + AddThreat(SelectTarget(SELECT_TARGET_RANDOM, 0), 100000.0f, pFiend); uiSpawnFiendTimer = urand(4000, 8000); } else uiSpawnFiendTimer -= diff; } @@ -1112,7 +1105,7 @@ public: if (!bLockedTarget) { - me->AddThreat(me->GetVictim(), 10000000.0f); + AddThreat(me->GetVictim(), 10000000.0f); bLockedTarget = true; } diff --git a/src/server/scripts/EasternKingdoms/Uldaman/boss_ironaya.cpp b/src/server/scripts/EasternKingdoms/Uldaman/boss_ironaya.cpp index 5a17339b4de..0f70182260b 100644 --- a/src/server/scripts/EasternKingdoms/Uldaman/boss_ironaya.cpp +++ b/src/server/scripts/EasternKingdoms/Uldaman/boss_ironaya.cpp @@ -75,18 +75,10 @@ class boss_ironaya : public CreatureScript return; //If we are <50% hp do knockaway ONCE - if (!bHasCastKnockaway && HealthBelowPct(50)) + if (!bHasCastKnockaway && HealthBelowPct(50) && me->GetVictim()) { DoCastVictim(SPELL_KNOCKAWAY, true); - - // current aggro target is knocked away pick new target - Unit* target = SelectTarget(SELECT_TARGET_TOPAGGRO, 0); - - if (!target || target == me->GetVictim()) - target = SelectTarget(SELECT_TARGET_TOPAGGRO, 1); - - if (target) - me->TauntApply(target); + me->GetThreatManager().ResetThreat(me->EnsureVictim()); //Shouldn't cast this agian bHasCastKnockaway = true; diff --git a/src/server/scripts/EasternKingdoms/Uldaman/uldaman.cpp b/src/server/scripts/EasternKingdoms/Uldaman/uldaman.cpp index 9c84b399e43..6db29b9bc6a 100644 --- a/src/server/scripts/EasternKingdoms/Uldaman/uldaman.cpp +++ b/src/server/scripts/EasternKingdoms/Uldaman/uldaman.cpp @@ -93,13 +93,7 @@ class npc_jadespine_basilisk : public CreatureScript //Stop attacking target thast asleep and pick new target uiCslumberTimer = 28000; - Unit* target = SelectTarget(SELECT_TARGET_TOPAGGRO, 0); - - if (!target || target == me->GetVictim()) - target = SelectTarget(SELECT_TARGET_RANDOM, 0, 100, true); - - if (target) - me->TauntApply(target); + me->GetThreatManager().ResetThreat(me->GetVictim()); } else uiCslumberTimer -= uiDiff; diff --git a/src/server/scripts/EasternKingdoms/ZulAman/boss_akilzon.cpp b/src/server/scripts/EasternKingdoms/ZulAman/boss_akilzon.cpp index f1b6c993a41..2983ae15477 100644 --- a/src/server/scripts/EasternKingdoms/ZulAman/boss_akilzon.cpp +++ b/src/server/scripts/EasternKingdoms/ZulAman/boss_akilzon.cpp @@ -333,7 +333,7 @@ class boss_akilzon : public CreatureScript Creature* creature = me->SummonCreature(NPC_SOARING_EAGLE, x, y, z, 0, TEMPSUMMON_CORPSE_DESPAWN, 0); if (creature) { - creature->AddThreat(me->GetVictim(), 1.0f); + AddThreat(me->GetVictim(), 1.0f, creature); creature->AI()->AttackStart(me->GetVictim()); BirdGUIDs[i] = creature->GetGUID(); } diff --git a/src/server/scripts/EasternKingdoms/ZulAman/boss_hexlord.cpp b/src/server/scripts/EasternKingdoms/ZulAman/boss_hexlord.cpp index ead3781d89b..6bced5b64d0 100644 --- a/src/server/scripts/EasternKingdoms/ZulAman/boss_hexlord.cpp +++ b/src/server/scripts/EasternKingdoms/ZulAman/boss_hexlord.cpp @@ -614,7 +614,7 @@ class boss_alyson_antille : public CreatureScript if (me->Attack(who, false)) { me->GetMotionMaster()->MoveChase(who, 20); - me->AddThreat(who, 0.0f); + AddThreat(who, 0.0f); } } } @@ -874,7 +874,7 @@ class boss_slither : public CreatureScript if (me->Attack(who, false)) { me->GetMotionMaster()->MoveChase(who, 20); - me->AddThreat(who, 0.0f); + AddThreat(who, 0.0f); } } } diff --git a/src/server/scripts/EasternKingdoms/ZulAman/boss_zuljin.cpp b/src/server/scripts/EasternKingdoms/ZulAman/boss_zuljin.cpp index 1ebecc41b4b..02313eab281 100644 --- a/src/server/scripts/EasternKingdoms/ZulAman/boss_zuljin.cpp +++ b/src/server/scripts/EasternKingdoms/ZulAman/boss_zuljin.cpp @@ -302,7 +302,7 @@ class boss_zuljin : public CreatureScript case 3: case 4: DoTeleportTo(CENTER_X, CENTER_Y, CENTER_Z, 100); - DoResetThreat(); + ResetThreatList(); me->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID, 0); me->RemoveAurasDueToSpell(Transform[Phase].unaura); DoCast(me, Transform[Phase].spell); diff --git a/src/server/scripts/EasternKingdoms/ZulGurub/boss_arlokk.cpp b/src/server/scripts/EasternKingdoms/ZulGurub/boss_arlokk.cpp index 8946edbe809..9d2a8a61a9a 100644 --- a/src/server/scripts/EasternKingdoms/ZulGurub/boss_arlokk.cpp +++ b/src/server/scripts/EasternKingdoms/ZulGurub/boss_arlokk.cpp @@ -227,7 +227,7 @@ class boss_arlokk : public CreatureScript break; case EVENT_MARK_OF_ARLOKK: { - Unit* target = SelectTarget(SELECT_TARGET_TOPAGGRO, urand(1, 3), 0.0f, false, -SPELL_MARK_OF_ARLOKK); + Unit* target = SelectTarget(SELECT_TARGET_MAXTHREAT, urand(1, 3), 0.0f, false, true, -SPELL_MARK_OF_ARLOKK); if (!target) target = me->GetVictim(); if (target) @@ -250,7 +250,7 @@ class boss_arlokk : public CreatureScript me->UpdateDamagePhysical(BASE_ATTACK); */ me->AttackStop(); - DoResetThreat(); + ResetThreatList(); me->SetReactState(REACT_PASSIVE); me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE|UNIT_FLAG_NOT_SELECTABLE); DoCast(me, SPELL_VANISH_VISUAL); diff --git a/src/server/scripts/EasternKingdoms/ZulGurub/boss_grilek.cpp b/src/server/scripts/EasternKingdoms/ZulGurub/boss_grilek.cpp index 4a6feab82eb..4561a2dd924 100644 --- a/src/server/scripts/EasternKingdoms/ZulGurub/boss_grilek.cpp +++ b/src/server/scripts/EasternKingdoms/ZulGurub/boss_grilek.cpp @@ -83,8 +83,8 @@ class boss_grilek : public CreatureScript // grilek DoCast(me, SPELL_AVATAR); if (Unit* victim = me->GetVictim()) { - if (DoGetThreat(victim)) - DoModifyThreatPercent(victim, -50); + if (GetThreat(victim)) + ModifyThreatByPercent(victim, -50); } if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 1)) diff --git a/src/server/scripts/EasternKingdoms/ZulGurub/boss_jeklik.cpp b/src/server/scripts/EasternKingdoms/ZulGurub/boss_jeklik.cpp index 63d6388d497..ba259ac2000 100644 --- a/src/server/scripts/EasternKingdoms/ZulGurub/boss_jeklik.cpp +++ b/src/server/scripts/EasternKingdoms/ZulGurub/boss_jeklik.cpp @@ -117,7 +117,7 @@ class boss_jeklik : public CreatureScript { me->RemoveAurasDueToSpell(SPELL_BAT_FORM); me->SetCanFly(false); - DoResetThreat(); + ResetThreatList(); events.SetPhase(PHASE_TWO); events.ScheduleEvent(EVENT_SHADOW_WORD_PAIN, 6000, 0, PHASE_TWO); events.ScheduleEvent(EVENT_MIND_FLAY, 11000, 0, PHASE_TWO); diff --git a/src/server/scripts/EasternKingdoms/ZulGurub/boss_jindo.cpp b/src/server/scripts/EasternKingdoms/ZulGurub/boss_jindo.cpp index 2c6ebefd1cb..5f9e3faef3f 100644 --- a/src/server/scripts/EasternKingdoms/ZulGurub/boss_jindo.cpp +++ b/src/server/scripts/EasternKingdoms/ZulGurub/boss_jindo.cpp @@ -124,8 +124,8 @@ class boss_jindo : public CreatureScript if (Unit* target = me->GetVictim()) { DoCast(target, SPELL_HEX, true); - if (DoGetThreat(target)) - DoModifyThreatPercent(target, -80); + if (GetThreat(target)) + ModifyThreatByPercent(target, -80); } events.ScheduleEvent(EVENT_HEX, urand(12000, 20000)); break; @@ -143,8 +143,8 @@ class boss_jindo : public CreatureScript if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, 100.0f, true)) { DoTeleportPlayer(target, TeleportLoc.GetPositionX(), TeleportLoc.GetPositionY(), TeleportLoc.GetPositionZ(), TeleportLoc.GetOrientation()); - if (DoGetThreat(me->GetVictim())) - DoModifyThreatPercent(target, -100); + if (GetThreat(me->GetVictim())) + ModifyThreatByPercent(target, -100); // Summon a formation of trolls for (uint8 i = 0; i < 10; ++i) diff --git a/src/server/scripts/EasternKingdoms/ZulGurub/boss_marli.cpp b/src/server/scripts/EasternKingdoms/ZulGurub/boss_marli.cpp index 9537aaec3e5..f9176d25a9a 100644 --- a/src/server/scripts/EasternKingdoms/ZulGurub/boss_marli.cpp +++ b/src/server/scripts/EasternKingdoms/ZulGurub/boss_marli.cpp @@ -160,8 +160,8 @@ class boss_marli : public CreatureScript */ me->ApplyStatPctModifier(UNIT_MOD_DAMAGE_MAINHAND, TOTAL_PCT, DamageIncrease); // hack DoCastVictim(SPELL_ENVOLWINGWEB); - if (DoGetThreat(me->GetVictim())) - DoModifyThreatPercent(me->GetVictim(), -100); + if (GetThreat(me->GetVictim())) + ModifyThreatByPercent(me->GetVictim(), -100); events.ScheduleEvent(EVENT_CHARGE_PLAYER, 1500, 0, PHASE_THREE); events.ScheduleEvent(EVENT_TRANSFORM_BACK, 25000, 0, PHASE_THREE); events.SetPhase(PHASE_THREE); diff --git a/src/server/scripts/EasternKingdoms/ZulGurub/boss_renataki.cpp b/src/server/scripts/EasternKingdoms/ZulGurub/boss_renataki.cpp index 351445c0c62..972229a1a8f 100644 --- a/src/server/scripts/EasternKingdoms/ZulGurub/boss_renataki.cpp +++ b/src/server/scripts/EasternKingdoms/ZulGurub/boss_renataki.cpp @@ -144,8 +144,8 @@ class boss_renataki : public CreatureScript { if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, 100.0f, true)) { - if (DoGetThreat(me->GetVictim())) - DoModifyThreatPercent(me->GetVictim(), -50); + if (GetThreat(me->GetVictim())) + ModifyThreatByPercent(me->GetVictim(), -50); AttackStart(target); } diff --git a/src/server/scripts/EasternKingdoms/ZulGurub/boss_thekal.cpp b/src/server/scripts/EasternKingdoms/ZulGurub/boss_thekal.cpp index 7e6a9970629..3bcc13f6df3 100644 --- a/src/server/scripts/EasternKingdoms/ZulGurub/boss_thekal.cpp +++ b/src/server/scripts/EasternKingdoms/ZulGurub/boss_thekal.cpp @@ -172,7 +172,7 @@ class boss_thekal : public CreatureScript me->UpdateDamagePhysical(BASE_ATTACK); */ me->ApplyStatPctModifier(UNIT_MOD_DAMAGE_MAINHAND, TOTAL_PCT, DamageIncrease); // hack - DoResetThreat(); + ResetThreatList(); events.ScheduleEvent(EVENT_FRENZY, 30000, 0, PHASE_TWO); // Phase 2 events.ScheduleEvent(EVENT_FORCEPUNCH, 4000, 0, PHASE_TWO); // Phase 2 events.ScheduleEvent(EVENT_SPELL_CHARGE, 12000, 0, PHASE_TWO); // Phase 2 @@ -226,7 +226,7 @@ class boss_thekal : public CreatureScript if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0)) { DoCast(target, SPELL_CHARGE); - DoResetThreat(); + ResetThreatList(); AttackStart(target); } events.ScheduleEvent(EVENT_CHARGE, urand(15000, 22000), 0, PHASE_TWO); @@ -503,8 +503,8 @@ class npc_zealot_zath : public CreatureScript { DoCastVictim(SPELL_GOUGE); - if (DoGetThreat(me->GetVictim())) - DoModifyThreatPercent(me->GetVictim(), -100); + if (GetThreat(me->GetVictim())) + ModifyThreatByPercent(me->GetVictim(), -100); Gouge_Timer = 17000 + rand32() % 10000; } else Gouge_Timer -= diff; diff --git a/src/server/scripts/EasternKingdoms/ZulGurub/boss_venoxis.cpp b/src/server/scripts/EasternKingdoms/ZulGurub/boss_venoxis.cpp index e8b0b59d317..9be8fab7f61 100644 --- a/src/server/scripts/EasternKingdoms/ZulGurub/boss_venoxis.cpp +++ b/src/server/scripts/EasternKingdoms/ZulGurub/boss_venoxis.cpp @@ -190,7 +190,7 @@ class boss_venoxis : public CreatureScript for (uint8 i = 0; i < 10; ++i) { - if (Unit* target = SelectTarget(SELECT_TARGET_TOPAGGRO, i)) + if (Unit* target = SelectTarget(SELECT_TARGET_MAXTHREAT, i)) // check if target is within melee-distance if (me->IsWithinMeleeRange(target)) ++_inMeleeRange; @@ -245,7 +245,7 @@ class boss_venoxis : public CreatureScript // shapeshift at 50% health DoCast(me, SPELL_VENOXIS_TRANSFORM); Talk(SAY_VENOXIS_TRANSFORM); - DoResetThreat(); + ResetThreatList(); // phase two events (snakeform) events.ScheduleEvent(EVENT_VENOM_SPIT, 5000, 0, PHASE_TWO); diff --git a/src/server/scripts/EasternKingdoms/zone_isle_of_queldanas.cpp b/src/server/scripts/EasternKingdoms/zone_isle_of_queldanas.cpp index 3109ec7c92e..db23c49f437 100644 --- a/src/server/scripts/EasternKingdoms/zone_isle_of_queldanas.cpp +++ b/src/server/scripts/EasternKingdoms/zone_isle_of_queldanas.cpp @@ -70,7 +70,7 @@ public: if (Creature* Myrmidon = me->FindNearestCreature(NPC_DARKSPINE_MYRIDON, 70)) { - me->AddThreat(Myrmidon, 100000.0f); + AddThreat(Myrmidon, 100000.0f); AttackStart(Myrmidon); } } diff --git a/src/server/scripts/EasternKingdoms/zone_silverpine_forest.cpp b/src/server/scripts/EasternKingdoms/zone_silverpine_forest.cpp index bc0f6ea959f..4a4e19d0225 100644 --- a/src/server/scripts/EasternKingdoms/zone_silverpine_forest.cpp +++ b/src/server/scripts/EasternKingdoms/zone_silverpine_forest.cpp @@ -236,7 +236,7 @@ public: target = me; summoned->SetFaction(FACTION_ENEMY); - summoned->AddThreat(target, 32.0f); + AddThreat(target, 32.0f, summoned); summoned->AI()->AttackStart(target); } } diff --git a/src/server/scripts/EasternKingdoms/zone_stranglethorn_vale.cpp b/src/server/scripts/EasternKingdoms/zone_stranglethorn_vale.cpp index edcfc78d510..0d399cb907e 100644 --- a/src/server/scripts/EasternKingdoms/zone_stranglethorn_vale.cpp +++ b/src/server/scripts/EasternKingdoms/zone_stranglethorn_vale.cpp @@ -79,7 +79,7 @@ public: { me->SetUInt32Value(UNIT_NPC_EMOTESTATE, EMOTE_STATE_STUN); me->CombatStop(); //stop combat - me->DeleteThreatList(); //unsure of this + me->GetThreatManager().ClearAllThreat(); //unsure of this me->SetFaction(FACTION_HORDE_GENERIC); bReset = true; @@ -111,7 +111,7 @@ public: if (player->GetTeam() == HORDE) { me->CombatStop(); - me->DeleteThreatList(); + me->GetThreatManager().ClearAllThreat(); } } } diff --git a/src/server/scripts/EasternKingdoms/zone_wetlands.cpp b/src/server/scripts/EasternKingdoms/zone_wetlands.cpp index 2966af7a3c5..51dbdf19a03 100644 --- a/src/server/scripts/EasternKingdoms/zone_wetlands.cpp +++ b/src/server/scripts/EasternKingdoms/zone_wetlands.cpp @@ -118,7 +118,7 @@ public: me->RestoreFaction(); me->RemoveAllAuras(); - me->DeleteThreatList(); + me->GetThreatManager().ClearAllThreat(); me->CombatStop(true); SetRun(false); |
