fix(Scripts/ShadowLabirynth): Clean up script and fix doors (#16061)

* fix(Scripts/ShadowLabirynth): Clean up script and fix doors

* Update instance_shadow_labyrinth.cpp

* Update boss_ambassador_hellmaw.cpp
This commit is contained in:
Skjalf
2023-04-23 08:32:39 -03:00
committed by GitHub
parent 697146fc40
commit 6e7493e8df
3 changed files with 37 additions and 112 deletions

View File

@@ -52,7 +52,7 @@ struct boss_ambassador_hellmaw : public BossAI
{
Reset();
if (instance->GetData(TYPE_RITUALISTS) != DONE)
if (instance->GetPersistentData(TYPE_RITUALISTS) != DONE)
{
isBanished = true;
me->SetImmuneToAll(true);
@@ -98,7 +98,6 @@ struct boss_ambassador_hellmaw : public BossAI
}
Talk(SAY_AGGRO);
events.ScheduleEvent(EVENT_SPELL_CORROSIVE, urand(23050, 30350));
scheduler.Schedule(23050ms, 30350ms, [this](TaskContext context)
{

View File

@@ -19,6 +19,19 @@
#include "ScriptMgr.h"
#include "shadow_labyrinth.h"
DoorData const doorData[] =
{
{ GO_REFECTORY_DOOR, DATA_BLACKHEARTTHEINCITEREVENT, DOOR_TYPE_PASSAGE },
{ GO_SCREAMING_HALL_DOOR, DATA_GRANDMASTER_VORPIL, DOOR_TYPE_PASSAGE },
{ 0, 0, DOOR_TYPE_ROOM } // END
};
ObjectData const creatureData[] =
{
{ NPC_HELLMAW, TYPE_HELLMAW },
{ 0, 0 },
};
class instance_shadow_labyrinth : public InstanceMapScript
{
public:
@@ -31,62 +44,31 @@ public:
struct instance_shadow_labyrinth_InstanceMapScript : public InstanceScript
{
instance_shadow_labyrinth_InstanceMapScript(Map* map) : InstanceScript(map) {}
uint32 m_auiEncounter[MAX_ENCOUNTER];
ObjectGuid m_uiHellmawGUID;
ObjectGuid m_uiRefectoryDoorGUID;
ObjectGuid m_uiScreamingHallDoorGUID;
instance_shadow_labyrinth_InstanceMapScript(Map* map) : InstanceScript(map)
{
SetBossNumber(EncounterCount);
SetPersistentDataCount(PersistentDataCount);
LoadDoorData(doorData);
LoadObjectData(creatureData, nullptr);
}
uint32 _ritualistsAliveCount;
void Initialize() override
{
memset(&m_auiEncounter, 0, sizeof(m_auiEncounter));
_ritualistsAliveCount = 0;
}
bool IsEncounterInProgress() const override
{
for (uint8 i = 0; i < MAX_ENCOUNTER; ++i)
if (m_auiEncounter[i] == IN_PROGRESS)
return true;
return false;
}
void OnGameObjectCreate(GameObject* go) override
{
switch (go->GetEntry())
{
case REFECTORY_DOOR:
m_uiRefectoryDoorGUID = go->GetGUID();
if (m_auiEncounter[DATA_BLACKHEARTTHEINCITEREVENT] == DONE)
go->SetGoState(GO_STATE_ACTIVE);
break;
case SCREAMING_HALL_DOOR:
m_uiScreamingHallDoorGUID = go->GetGUID();
if (m_auiEncounter[DATA_GRANDMASTER_VORPIL_EVENT] == DONE)
go->SetGoState(GO_STATE_ACTIVE);
break;
}
}
void OnCreatureCreate(Creature* creature) override
{
InstanceScript::OnCreatureCreate(creature);
switch (creature->GetEntry())
if (creature->GetEntry() == NPC_CABAL_RITUALIST)
{
case NPC_CABAL_RITUALIST:
if (creature->IsAlive())
++_ritualistsAliveCount;
break;
case NPC_HELLMAW:
m_uiHellmawGUID = creature->GetGUID();
break;
if (creature->IsAlive())
{
++_ritualistsAliveCount;
}
}
}
@@ -95,84 +77,25 @@ public:
InstanceScript::OnUnitDeath(unit);
if (unit->GetEntry() == NPC_CABAL_RITUALIST)
{
if (!--_ritualistsAliveCount)
{
m_auiEncounter[TYPE_RITUALISTS] = DONE;
SaveToDB();
if (Creature* cr = instance->GetCreature(m_uiHellmawGUID))
StorePersistentData(TYPE_RITUALISTS, DONE);
if (Creature* hellmaw = GetCreature(TYPE_HELLMAW))
{
cr->AI()->DoAction(1);
hellmaw->AI()->DoAction(1);
}
}
}
void SetData(uint32 type, uint32 uiData) override
{
switch (type)
{
case DATA_BLACKHEARTTHEINCITEREVENT:
if (uiData == DONE)
DoUseDoorOrButton(m_uiRefectoryDoorGUID);
m_auiEncounter[type] = uiData;
break;
case DATA_GRANDMASTER_VORPIL_EVENT:
if (uiData == DONE)
DoUseDoorOrButton(m_uiScreamingHallDoorGUID);
m_auiEncounter[type] = uiData;
break;
case DATA_MURMUREVENT:
case TYPE_HELLMAW:
m_auiEncounter[type] = uiData;
break;
}
if (uiData == DONE)
SaveToDB();
}
uint32 GetData(uint32 type) const override
{
if (type == TYPE_RITUALISTS)
return m_auiEncounter[0];
return GetPersistentData(TYPE_RITUALISTS);
return 0;
}
std::string GetSaveData() override
{
std::ostringstream saveStream;
saveStream << "S L " << m_auiEncounter[0] << ' ' << m_auiEncounter[1] << ' '
<< m_auiEncounter[2] << ' ' << m_auiEncounter[3] << ' ' << m_auiEncounter[4];
return saveStream.str();
}
void Load(const char* in) override
{
if (!in)
{
OUT_LOAD_INST_DATA_FAIL;
return;
}
OUT_LOAD_INST_DATA(in);
char dataHead1, dataHead2;
std::istringstream loadStream(in);
loadStream >> dataHead1 >> dataHead2;
if (dataHead1 == 'S' && dataHead2 == 'L')
{
for (uint8 i = 0; i < MAX_ENCOUNTER; ++i)
{
loadStream >> m_auiEncounter[i];
if (m_auiEncounter[i] == IN_PROGRESS)
m_auiEncounter[i] = NOT_STARTED;
}
}
OUT_LOAD_INST_DATA_COMPLETE;
}
};
};

View File

@@ -42,10 +42,13 @@ enum slNPCandGO
NPC_CABAL_RITUALIST = 18794,
NPC_HELLMAW = 18731,
REFECTORY_DOOR = 183296, //door opened when blackheart the inciter dies
SCREAMING_HALL_DOOR = 183295 //door opened when grandmaster vorpil dies
GO_REFECTORY_DOOR = 183296, //door opened when blackheart the inciter dies
GO_SCREAMING_HALL_DOOR = 183295 //door opened when grandmaster vorpil dies
};
uint32 constexpr EncounterCount = 4;
uint32 constexpr PersistentDataCount = 1;
template <class AI, class T>
inline AI* GetShadowLabyrinthAI(T* obj)
{