Scripts/Auchindoun: Last one, hopefully. Remove reliance on large grid searchers by integrating with instance script.

This commit is contained in:
Treeston
2017-07-21 17:29:06 +02:00
parent 04dc47e7e2
commit d80d7c6685
3 changed files with 62 additions and 13 deletions

View File

@@ -27,7 +27,6 @@
enum BlackheartTheInciter enum BlackheartTheInciter
{ {
NPC_BLACKHEART = 18667,
SPELL_INCITE_CHAOS = 33676, SPELL_INCITE_CHAOS = 33676,
SPELL_INCITE_CHAOS_B = 33684, //debuff applied to each member of party SPELL_INCITE_CHAOS_B = 33684, //debuff applied to each member of party
SPELL_CHARGE = 33709, SPELL_CHARGE = 33709,
@@ -80,7 +79,7 @@ class BlackheartCharmedPlayerAI : public SimpleCharmedPlayerAI
void OnCharmed(bool apply) override void OnCharmed(bool apply) override
{ {
SimpleCharmedPlayerAI::OnCharmed(apply); SimpleCharmedPlayerAI::OnCharmed(apply);
if (Creature* blackheart = me->FindNearestCreature(NPC_BLACKHEART, 50000.0f)) if (Creature* blackheart = ObjectAccessor::GetCreature(*me, me->GetInstanceScript()->GetGuidData(DATA_BLACKHEART_THE_INCITER)))
{ {
blackheart->AI()->SetData(0, apply); blackheart->AI()->SetData(0, apply);
blackheart->GetThreatManager().AddThreat(me, 0.0f); blackheart->GetThreatManager().AddThreat(me, 0.0f);
@@ -183,24 +182,25 @@ struct boss_blackheart_the_inciter_mc_dummy : public NullCreatureAI
{ {
using NullCreatureAI::NullCreatureAI; using NullCreatureAI::NullCreatureAI;
void InitializeAI() override { me->SetReactState(REACT_PASSIVE); } void InitializeAI() override { me->SetReactState(REACT_PASSIVE); }
static const uint32 FIRST_DUMMY = 19300, LAST_DUMMY = 19304; static const uint32 FIRST_DUMMY = NPC_BLACKHEART_DUMMY1, LAST_DUMMY = NPC_BLACKHEART_DUMMY5;
void IsSummonedBy(Unit* who) override void IsSummonedBy(Unit* who) override
{ {
me->CastSpell(who, SPELL_INCITE_CHAOS_B, true); me->CastSpell(who, SPELL_INCITE_CHAOS_B, true);
// ensure everyone is in combat with everyone // ensure everyone is in combat with everyone
for (uint32 entry = FIRST_DUMMY; entry <= LAST_DUMMY; ++entry) if (auto* dummies = GetBlackheartDummies(me->GetInstanceScript()))
if (entry != me->GetEntry()) for (ObjectGuid const& guid : *dummies)
if (Creature* trigger = me->FindNearestCreature(entry, 50000.0f)) if (Creature* trigger = ObjectAccessor::GetCreature(*me, guid))
{ if (me->GetEntry() != trigger->GetEntry())
me->GetThreatManager().AddThreat(trigger, 0.0f);
trigger->GetThreatManager().AddThreat(who, 0.0f);
for (Unit* other : trigger->m_Controlled)
{ {
me->GetThreatManager().AddThreat(other, 0.0f); me->GetThreatManager().AddThreat(trigger, 0.0f);
other->GetThreatManager().AddThreat(who, 0.0f); trigger->GetThreatManager().AddThreat(who, 0.0f);
for (Unit* other : trigger->m_Controlled)
{
me->GetThreatManager().AddThreat(other, 0.0f);
other->GetThreatManager().AddThreat(who, 0.0f);
}
} }
}
} }
void UpdateAI(uint32 /*diff*/) override void UpdateAI(uint32 /*diff*/) override
{ {

View File

@@ -53,6 +53,16 @@ class instance_shadow_labyrinth : public InstanceMapScript
case NPC_AMBASSADOR_HELLMAW: case NPC_AMBASSADOR_HELLMAW:
AmbassadorHellmawGUID = creature->GetGUID(); AmbassadorHellmawGUID = creature->GetGUID();
break; break;
case NPC_BLACKHEART:
BlackheartGUID = creature->GetGUID();
break;
case NPC_BLACKHEART_DUMMY1:
case NPC_BLACKHEART_DUMMY2:
case NPC_BLACKHEART_DUMMY3:
case NPC_BLACKHEART_DUMMY4:
case NPC_BLACKHEART_DUMMY5:
BlackheartDummyGUIDs.insert(creature->GetGUID());
break;
case NPC_GRANDMASTER_VORPIL: case NPC_GRANDMASTER_VORPIL:
GrandmasterVorpilGUID = creature->GetGUID(); GrandmasterVorpilGUID = creature->GetGUID();
break; break;
@@ -69,6 +79,22 @@ class instance_shadow_labyrinth : public InstanceMapScript
} }
} }
void OnCreatureRemove(Creature* creature) override
{
switch (creature->GetEntry())
{
case NPC_BLACKHEART_DUMMY1:
case NPC_BLACKHEART_DUMMY2:
case NPC_BLACKHEART_DUMMY3:
case NPC_BLACKHEART_DUMMY4:
case NPC_BLACKHEART_DUMMY5:
BlackheartDummyGUIDs.erase(creature->GetGUID());
break;
default:
break;
}
}
void OnGameObjectCreate(GameObject* go) override void OnGameObjectCreate(GameObject* go) override
{ {
switch (go->GetEntry()) switch (go->GetEntry())
@@ -128,6 +154,8 @@ class instance_shadow_labyrinth : public InstanceMapScript
{ {
switch (type) switch (type)
{ {
case DATA_BLACKHEART_THE_INCITER:
return BlackheartGUID;
case DATA_GRANDMASTER_VORPIL: case DATA_GRANDMASTER_VORPIL:
return GrandmasterVorpilGUID; return GrandmasterVorpilGUID;
default: default:
@@ -136,8 +164,12 @@ class instance_shadow_labyrinth : public InstanceMapScript
return ObjectGuid::Empty; return ObjectGuid::Empty;
} }
GuidUnorderedSet const& GetBlackheartDummies() const { return BlackheartDummyGUIDs; }
protected: protected:
ObjectGuid AmbassadorHellmawGUID; ObjectGuid AmbassadorHellmawGUID;
ObjectGuid BlackheartGUID;
GuidUnorderedSet BlackheartDummyGUIDs;
ObjectGuid GrandmasterVorpilGUID; ObjectGuid GrandmasterVorpilGUID;
uint32 FelOverseerCount; uint32 FelOverseerCount;
}; };
@@ -148,6 +180,14 @@ class instance_shadow_labyrinth : public InstanceMapScript
} }
}; };
GuidUnorderedSet const* GetBlackheartDummies(InstanceScript const* s)
{
if (auto* script = dynamic_cast<instance_shadow_labyrinth::instance_shadow_labyrinth_InstanceMapScript const*>(s))
return &script->GetBlackheartDummies();
return nullptr;
}
void AddSC_instance_shadow_labyrinth() void AddSC_instance_shadow_labyrinth()
{ {
new instance_shadow_labyrinth(); new instance_shadow_labyrinth();

View File

@@ -19,6 +19,7 @@
#define SHADOW_LABYRINTH_H_ #define SHADOW_LABYRINTH_H_
#include "CreatureAIImpl.h" #include "CreatureAIImpl.h"
#include "ObjectGuid.h"
#define SLScriptName "instance_shadow_labyrinth" #define SLScriptName "instance_shadow_labyrinth"
#define DataHeader "SL" #define DataHeader "SL"
@@ -40,6 +41,12 @@ enum SLDataTypes
enum SLCreatureIds enum SLCreatureIds
{ {
NPC_AMBASSADOR_HELLMAW = 18731, NPC_AMBASSADOR_HELLMAW = 18731,
NPC_BLACKHEART = 18667,
NPC_BLACKHEART_DUMMY1 = 19300,
NPC_BLACKHEART_DUMMY2 = 19301,
NPC_BLACKHEART_DUMMY3 = 19302,
NPC_BLACKHEART_DUMMY4 = 19303,
NPC_BLACKHEART_DUMMY5 = 19304,
NPC_GRANDMASTER_VORPIL = 18732, NPC_GRANDMASTER_VORPIL = 18732,
NPC_FEL_OVERSEER = 18796 NPC_FEL_OVERSEER = 18796
}; };
@@ -56,6 +63,8 @@ enum SLMisc
ACTION_AMBASSADOR_HELLMAW_BANISH = 2, ACTION_AMBASSADOR_HELLMAW_BANISH = 2,
}; };
GuidUnorderedSet const* GetBlackheartDummies(InstanceScript const* s);
template <class AI, class T> template <class AI, class T>
inline AI* GetShadowLabyrinthAI(T* obj) inline AI* GetShadowLabyrinthAI(T* obj)
{ {