mirror of
https://github.com/liyunfan1223/azerothcore-wotlk.git
synced 2026-08-08 15:58:04 +00:00
refactor(Scripts/BloodFurnace): Clean up instance script (#21207)
This commit is contained in:
@@ -612,6 +612,12 @@ void InstanceScript::DoRespawnGameObject(ObjectGuid uiGuid, uint32 uiTimeToDespa
|
|||||||
LOG_DEBUG("scripts", "InstanceScript: DoRespawnGameObject failed");
|
LOG_DEBUG("scripts", "InstanceScript: DoRespawnGameObject failed");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void InstanceScript::DoRespawnGameObject(uint32 type)
|
||||||
|
{
|
||||||
|
if (GameObject* go = instance->GetGameObject(GetObjectGuid(type)))
|
||||||
|
go->Respawn();
|
||||||
|
}
|
||||||
|
|
||||||
void InstanceScript::DoRespawnCreature(ObjectGuid guid, bool force)
|
void InstanceScript::DoRespawnCreature(ObjectGuid guid, bool force)
|
||||||
{
|
{
|
||||||
if (Creature* creature = instance->GetCreature(guid))
|
if (Creature* creature = instance->GetCreature(guid))
|
||||||
|
|||||||
@@ -203,6 +203,9 @@ public:
|
|||||||
//Respawns a GO having negative spawntimesecs in gameobject-table
|
//Respawns a GO having negative spawntimesecs in gameobject-table
|
||||||
void DoRespawnGameObject(ObjectGuid guid, uint32 timeToDespawn = MINUTE);
|
void DoRespawnGameObject(ObjectGuid guid, uint32 timeToDespawn = MINUTE);
|
||||||
|
|
||||||
|
// Respawns a GO by instance storage index
|
||||||
|
void DoRespawnGameObject(uint32 type);
|
||||||
|
|
||||||
// Respawns a creature.
|
// Respawns a creature.
|
||||||
void DoRespawnCreature(ObjectGuid guid, bool force = false);
|
void DoRespawnCreature(ObjectGuid guid, bool force = false);
|
||||||
|
|
||||||
|
|||||||
@@ -33,12 +33,8 @@ enum bloodFurnace
|
|||||||
DATA_KELIDAN = 2,
|
DATA_KELIDAN = 2,
|
||||||
MAX_ENCOUNTER = 3,
|
MAX_ENCOUNTER = 3,
|
||||||
|
|
||||||
DATA_DOOR1 = 10,
|
|
||||||
DATA_DOOR2 = 11,
|
|
||||||
DATA_DOOR3 = 12,
|
|
||||||
DATA_BROGGOK_REAR_DOOR = 13,
|
DATA_BROGGOK_REAR_DOOR = 13,
|
||||||
DATA_BROGGOK_LEVER = 14,
|
DATA_BROGGOK_LEVER = 14,
|
||||||
DATA_DOOR6 = 15,
|
|
||||||
|
|
||||||
DATA_PRISON_CELL1 = 20,
|
DATA_PRISON_CELL1 = 20,
|
||||||
DATA_PRISON_CELL2 = 21,
|
DATA_PRISON_CELL2 = 21,
|
||||||
@@ -62,7 +58,11 @@ enum BloodFurnaceGO
|
|||||||
{
|
{
|
||||||
GO_BROGGOK_DOOR_FRONT = 181822,
|
GO_BROGGOK_DOOR_FRONT = 181822,
|
||||||
GO_BROGGOK_DOOR_REAR = 181819,
|
GO_BROGGOK_DOOR_REAR = 181819,
|
||||||
GO_BROGGOK_LEVER = 181982
|
GO_BROGGOK_LEVER = 181982,
|
||||||
|
GO_KELIDAN_DOOR_EXIT1 = 181823,
|
||||||
|
GO_KELIDAN_DOOR_EXIT2 = 181766,
|
||||||
|
GO_MAKER_DOOR_FRONT = 181811,
|
||||||
|
GO_MAKER_DOOR_REAR = 181812
|
||||||
};
|
};
|
||||||
|
|
||||||
template <class AI, class T>
|
template <class AI, class T>
|
||||||
|
|||||||
@@ -101,15 +101,10 @@ public:
|
|||||||
bool OnGossipHello(Player* /*player*/, GameObject* go) override
|
bool OnGossipHello(Player* /*player*/, GameObject* go) override
|
||||||
{
|
{
|
||||||
if (InstanceScript* instance = go->GetInstanceScript())
|
if (InstanceScript* instance = go->GetInstanceScript())
|
||||||
{
|
|
||||||
if (instance->GetBossState(DATA_BROGGOK) == NOT_STARTED)
|
if (instance->GetBossState(DATA_BROGGOK) == NOT_STARTED)
|
||||||
{
|
|
||||||
if (Creature* broggok = instance->GetCreature(DATA_BROGGOK))
|
if (Creature* broggok = instance->GetCreature(DATA_BROGGOK))
|
||||||
{
|
|
||||||
broggok->AI()->DoAction(ACTION_PREPARE_BROGGOK);
|
broggok->AI()->DoAction(ACTION_PREPARE_BROGGOK);
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
go->UseDoorOrButton();
|
go->UseDoorOrButton();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -67,10 +67,6 @@ struct boss_kelidan_the_breaker : public BossAI
|
|||||||
me->SetReactState(REACT_PASSIVE);
|
me->SetReactState(REACT_PASSIVE);
|
||||||
me->SetUnitFlag(UNIT_FLAG_NOT_SELECTABLE);
|
me->SetUnitFlag(UNIT_FLAG_NOT_SELECTABLE);
|
||||||
DoCastSelf(SPELL_EVOCATION);
|
DoCastSelf(SPELL_EVOCATION);
|
||||||
if (instance)
|
|
||||||
{
|
|
||||||
instance->SetData(DATA_KELIDAN, NOT_STARTED);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void JustEngagedWith(Unit* /*who*/) override
|
void JustEngagedWith(Unit* /*who*/) override
|
||||||
@@ -78,10 +74,7 @@ struct boss_kelidan_the_breaker : public BossAI
|
|||||||
Talk(SAY_WAKE);
|
Talk(SAY_WAKE);
|
||||||
_JustEngagedWith();
|
_JustEngagedWith();
|
||||||
me->InterruptNonMeleeSpells(false);
|
me->InterruptNonMeleeSpells(false);
|
||||||
if (instance)
|
|
||||||
{
|
|
||||||
instance->SetData(DATA_KELIDAN, IN_PROGRESS);
|
|
||||||
}
|
|
||||||
scheduler.Schedule(1s, [this](TaskContext context)
|
scheduler.Schedule(1s, [this](TaskContext context)
|
||||||
{
|
{
|
||||||
DoCastAOE(SPELL_SHADOW_BOLT_VOLLEY);
|
DoCastAOE(SPELL_SHADOW_BOLT_VOLLEY);
|
||||||
@@ -97,9 +90,7 @@ struct boss_kelidan_the_breaker : public BossAI
|
|||||||
me->AddAura(SPELL_BURNING_NOVA, me);
|
me->AddAura(SPELL_BURNING_NOVA, me);
|
||||||
ApplyImmunities(true);
|
ApplyImmunities(true);
|
||||||
if (IsHeroic())
|
if (IsHeroic())
|
||||||
{
|
|
||||||
DoCastAOE(SPELL_VORTEX);
|
DoCastAOE(SPELL_VORTEX);
|
||||||
}
|
|
||||||
scheduler.DelayGroup(0, 6s);
|
scheduler.DelayGroup(0, 6s);
|
||||||
scheduler.Schedule(5s, [this](TaskContext /*context*/)
|
scheduler.Schedule(5s, [this](TaskContext /*context*/)
|
||||||
{
|
{
|
||||||
@@ -112,41 +103,29 @@ struct boss_kelidan_the_breaker : public BossAI
|
|||||||
void KilledUnit(Unit* /*victim*/) override
|
void KilledUnit(Unit* /*victim*/) override
|
||||||
{
|
{
|
||||||
if (urand(0, 1))
|
if (urand(0, 1))
|
||||||
{
|
|
||||||
Talk(SAY_KILL);
|
Talk(SAY_KILL);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DoAction(int32 param) override
|
void DoAction(int32 param) override
|
||||||
{
|
{
|
||||||
if (param == ACTION_CHANNELER_DIED)
|
if (param == ACTION_CHANNELER_DIED)
|
||||||
{
|
{
|
||||||
if (me->FindNearestCreature(NPC_SHADOWMOON_CHANNELER, 100.0f))
|
if (!me->FindNearestCreature(NPC_SHADOWMOON_CHANNELER, 100.0f))
|
||||||
{
|
{
|
||||||
return;
|
me->RemoveUnitFlag(UNIT_FLAG_NOT_SELECTABLE);
|
||||||
|
me->SetReactState(REACT_AGGRESSIVE);
|
||||||
|
me->SetInCombatWithZone();
|
||||||
}
|
}
|
||||||
me->RemoveUnitFlag(UNIT_FLAG_NOT_SELECTABLE);
|
|
||||||
me->SetReactState(REACT_AGGRESSIVE);
|
|
||||||
me->SetInCombatWithZone();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (param == ACTION_CHANNELER_AGGRO)
|
else if (param == ACTION_CHANNELER_AGGRO)
|
||||||
{
|
|
||||||
Talk(SAY_ADD_AGGRO);
|
Talk(SAY_ADD_AGGRO);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void JustDied(Unit* /*killer*/) override
|
void JustDied(Unit* /*killer*/) override
|
||||||
{
|
{
|
||||||
Talk(SAY_DIE);
|
Talk(SAY_DIE);
|
||||||
_JustDied();
|
_JustDied();
|
||||||
if (instance)
|
me->GetMap()->LoadGrid(0, -111.0f);
|
||||||
{
|
|
||||||
me->GetMap()->LoadGrid(0, -111.0f);
|
|
||||||
instance->SetData(DATA_KELIDAN, DONE);
|
|
||||||
instance->HandleGameObject(instance->GetGuidData(DATA_DOOR1), true);
|
|
||||||
instance->HandleGameObject(instance->GetGuidData(DATA_DOOR6), true);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ApplyImmunities(bool apply)
|
void ApplyImmunities(bool apply)
|
||||||
|
|||||||
@@ -42,22 +42,10 @@ struct boss_the_maker : public BossAI
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void Reset() override
|
|
||||||
{
|
|
||||||
_Reset();
|
|
||||||
if (instance)
|
|
||||||
{
|
|
||||||
instance->SetData(DATA_THE_MAKER, NOT_STARTED);
|
|
||||||
instance->HandleGameObject(instance->GetGuidData(DATA_DOOR2), true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void JustEngagedWith(Unit* /*who*/) override
|
void JustEngagedWith(Unit* /*who*/) override
|
||||||
{
|
{
|
||||||
Talk(SAY_AGGRO);
|
Talk(SAY_AGGRO);
|
||||||
_JustEngagedWith();
|
_JustEngagedWith();
|
||||||
instance->SetData(DATA_THE_MAKER, IN_PROGRESS);
|
|
||||||
instance->HandleGameObject(instance->GetGuidData(DATA_DOOR2), false);
|
|
||||||
scheduler.Schedule(6s, [this](TaskContext context)
|
scheduler.Schedule(6s, [this](TaskContext context)
|
||||||
{
|
{
|
||||||
DoCastRandomTarget(SPELL_EXPLODING_BEAKER);
|
DoCastRandomTarget(SPELL_EXPLODING_BEAKER);
|
||||||
@@ -72,30 +60,13 @@ struct boss_the_maker : public BossAI
|
|||||||
void KilledUnit(Unit* victim) override
|
void KilledUnit(Unit* victim) override
|
||||||
{
|
{
|
||||||
if (victim->IsPlayer() && urand(0, 1))
|
if (victim->IsPlayer() && urand(0, 1))
|
||||||
{
|
|
||||||
Talk(SAY_KILL);
|
Talk(SAY_KILL);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void JustDied(Unit* /*killer*/) override
|
void JustDied(Unit* /*killer*/) override
|
||||||
{
|
{
|
||||||
Talk(SAY_DIE);
|
Talk(SAY_DIE);
|
||||||
_JustDied();
|
_JustDied();
|
||||||
instance->SetData(DATA_THE_MAKER, DONE);
|
|
||||||
instance->HandleGameObject(instance->GetGuidData(DATA_DOOR2), true);
|
|
||||||
instance->HandleGameObject(instance->GetGuidData(DATA_DOOR3), true);
|
|
||||||
}
|
|
||||||
|
|
||||||
void UpdateAI(uint32 diff) override
|
|
||||||
{
|
|
||||||
if (!UpdateVictim())
|
|
||||||
return;
|
|
||||||
|
|
||||||
scheduler.Update(diff);
|
|
||||||
if (me->HasUnitState(UNIT_STATE_CASTING))
|
|
||||||
return;
|
|
||||||
|
|
||||||
DoMeleeAttackIfReady();
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -22,9 +22,13 @@
|
|||||||
|
|
||||||
DoorData const doorData[] =
|
DoorData const doorData[] =
|
||||||
{
|
{
|
||||||
{ GO_BROGGOK_DOOR_FRONT, DATA_BROGGOK, DOOR_TYPE_ROOM },
|
{ GO_MAKER_DOOR_FRONT, DATA_THE_MAKER, DOOR_TYPE_ROOM },
|
||||||
{ GO_BROGGOK_DOOR_REAR, DATA_BROGGOK, DOOR_TYPE_PASSAGE },
|
{ GO_MAKER_DOOR_REAR, DATA_THE_MAKER, DOOR_TYPE_PASSAGE },
|
||||||
{ 0, 0, DOOR_TYPE_ROOM } // END
|
{ GO_BROGGOK_DOOR_FRONT, DATA_BROGGOK, DOOR_TYPE_ROOM },
|
||||||
|
{ GO_BROGGOK_DOOR_REAR, DATA_BROGGOK, DOOR_TYPE_PASSAGE },
|
||||||
|
{ GO_KELIDAN_DOOR_EXIT1, DATA_KELIDAN, DOOR_TYPE_PASSAGE },
|
||||||
|
{ GO_KELIDAN_DOOR_EXIT2, DATA_KELIDAN, DOOR_TYPE_PASSAGE },
|
||||||
|
{ 0, 0, DOOR_TYPE_ROOM } // END
|
||||||
};
|
};
|
||||||
|
|
||||||
ObjectData const gameobjectData[] =
|
ObjectData const gameobjectData[] =
|
||||||
@@ -56,26 +60,15 @@ public:
|
|||||||
LoadObjectData(creatureData, gameobjectData);
|
LoadObjectData(creatureData, gameobjectData);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32 _auiEncounter[MAX_ENCOUNTER];
|
|
||||||
ObjectGuid _doorGUIDs[6];
|
|
||||||
ObjectGuid _prisonGUIDs[4];
|
|
||||||
|
|
||||||
GuidSet _prisonersCell[4];
|
|
||||||
|
|
||||||
uint8 _prisonerCounter[4];
|
|
||||||
|
|
||||||
void Initialize() override
|
void Initialize() override
|
||||||
{
|
{
|
||||||
memset(&_auiEncounter, 0, sizeof(_auiEncounter));
|
|
||||||
memset(&_prisonerCounter, 0, sizeof(_prisonerCounter));
|
memset(&_prisonerCounter, 0, sizeof(_prisonerCounter));
|
||||||
}
|
}
|
||||||
|
|
||||||
void OnCreatureCreate(Creature* creature) override
|
void OnCreatureCreate(Creature* creature) override
|
||||||
{
|
{
|
||||||
if (creature->GetEntry() == NPC_NASCENT_FEL_ORC)
|
if (creature->GetEntry() == NPC_NASCENT_FEL_ORC)
|
||||||
{
|
|
||||||
StorePrisoner(creature);
|
StorePrisoner(creature);
|
||||||
}
|
|
||||||
|
|
||||||
InstanceScript::OnCreatureCreate(creature);
|
InstanceScript::OnCreatureCreate(creature);
|
||||||
}
|
}
|
||||||
@@ -88,20 +81,6 @@ public:
|
|||||||
|
|
||||||
void OnGameObjectCreate(GameObject* go) override
|
void OnGameObjectCreate(GameObject* go) override
|
||||||
{
|
{
|
||||||
if (go->GetEntry() == 181766) //Final exit door
|
|
||||||
_doorGUIDs[0] = go->GetGUID();
|
|
||||||
if (go->GetEntry() == 181811) //The Maker Front door
|
|
||||||
_doorGUIDs[1] = go->GetGUID();
|
|
||||||
if (go->GetEntry() == 181812) //The Maker Rear door
|
|
||||||
{
|
|
||||||
_doorGUIDs[2] = go->GetGUID();
|
|
||||||
if (GetData(DATA_THE_MAKER) == DONE)
|
|
||||||
HandleGameObject(go->GetGUID(), true);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (go->GetEntry() == 181823) //Kelidan exit door
|
|
||||||
_doorGUIDs[5] = go->GetGUID();
|
|
||||||
|
|
||||||
if (go->GetEntry() == 181821) //Broggok prison cell front right
|
if (go->GetEntry() == 181821) //Broggok prison cell front right
|
||||||
_prisonGUIDs[0] = go->GetGUID();
|
_prisonGUIDs[0] = go->GetGUID();
|
||||||
if (go->GetEntry() == 181818) //Broggok prison cell back right
|
if (go->GetEntry() == 181818) //Broggok prison cell back right
|
||||||
@@ -118,12 +97,6 @@ public:
|
|||||||
{
|
{
|
||||||
switch (data)
|
switch (data)
|
||||||
{
|
{
|
||||||
case DATA_DOOR1:
|
|
||||||
case DATA_DOOR2:
|
|
||||||
case DATA_DOOR3:
|
|
||||||
case DATA_DOOR6:
|
|
||||||
return _doorGUIDs[data - DATA_DOOR1];
|
|
||||||
|
|
||||||
case DATA_PRISON_CELL1:
|
case DATA_PRISON_CELL1:
|
||||||
case DATA_PRISON_CELL2:
|
case DATA_PRISON_CELL2:
|
||||||
case DATA_PRISON_CELL3:
|
case DATA_PRISON_CELL3:
|
||||||
@@ -142,50 +115,17 @@ public:
|
|||||||
if (type == DATA_BROGGOK)
|
if (type == DATA_BROGGOK)
|
||||||
{
|
{
|
||||||
if (state == IN_PROGRESS)
|
if (state == IN_PROGRESS)
|
||||||
{
|
|
||||||
ActivateCell(DATA_PRISON_CELL1);
|
ActivateCell(DATA_PRISON_CELL1);
|
||||||
HandleGameObject(_doorGUIDs[3], false);
|
|
||||||
}
|
|
||||||
else if (state == NOT_STARTED)
|
else if (state == NOT_STARTED)
|
||||||
{
|
{
|
||||||
ResetPrisons();
|
ResetPrisons();
|
||||||
HandleGameObject(_doorGUIDs[4], false);
|
DoRespawnGameObject(DATA_BROGGOK_LEVER);
|
||||||
HandleGameObject(_doorGUIDs[3], true);
|
|
||||||
if (GameObject* lever = GetGameObject(DATA_BROGGOK_LEVER))
|
|
||||||
{
|
|
||||||
lever->Respawn();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetData(uint32 type, uint32 data) override
|
|
||||||
{
|
|
||||||
switch (type)
|
|
||||||
{
|
|
||||||
case DATA_THE_MAKER:
|
|
||||||
case DATA_KELIDAN:
|
|
||||||
_auiEncounter[type] = data;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (data == DONE)
|
|
||||||
SaveToDB();
|
|
||||||
}
|
|
||||||
|
|
||||||
uint32 GetData(uint32 type) const override
|
|
||||||
{
|
|
||||||
switch (type)
|
|
||||||
{
|
|
||||||
case DATA_THE_MAKER:
|
|
||||||
case DATA_KELIDAN:
|
|
||||||
return _auiEncounter[type];
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ResetPrisons()
|
void ResetPrisons()
|
||||||
{
|
{
|
||||||
for (uint8 i = 0; i < 4; ++i)
|
for (uint8 i = 0; i < 4; ++i)
|
||||||
@@ -273,13 +213,9 @@ public:
|
|||||||
break;
|
break;
|
||||||
case DATA_BROGGOK_REAR_DOOR:
|
case DATA_BROGGOK_REAR_DOOR:
|
||||||
if (GameObject* go = GetGameObject(DATA_BROGGOK_REAR_DOOR))
|
if (GameObject* go = GetGameObject(DATA_BROGGOK_REAR_DOOR))
|
||||||
{
|
|
||||||
HandleGameObject(ObjectGuid::Empty, true, go);
|
HandleGameObject(ObjectGuid::Empty, true, go);
|
||||||
}
|
|
||||||
if (Creature* broggok = GetCreature(DATA_BROGGOK))
|
if (Creature* broggok = GetCreature(DATA_BROGGOK))
|
||||||
{
|
|
||||||
broggok->AI()->DoAction(ACTION_ACTIVATE_BROGGOK);
|
broggok->AI()->DoAction(ACTION_ACTIVATE_BROGGOK);
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -294,6 +230,11 @@ public:
|
|||||||
prisoner->SetInCombatWithZone();
|
prisoner->SetInCombatWithZone();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
ObjectGuid _prisonGUIDs[4];
|
||||||
|
GuidSet _prisonersCell[4];
|
||||||
|
uint8 _prisonerCounter[4];
|
||||||
};
|
};
|
||||||
|
|
||||||
InstanceScript* GetInstanceScript(InstanceMap* map) const override
|
InstanceScript* GetInstanceScript(InstanceMap* map) const override
|
||||||
|
|||||||
Reference in New Issue
Block a user