Skip to content

Commit 2ec5a46

Browse files
committed
[2855] Add more improvements to Uldaman
This will allow the Alter Event to be properly handled.
1 parent d0030bb commit 2ec5a46

4 files changed

Lines changed: 95 additions & 66 deletions

File tree

scripts/eastern_kingdoms/uldaman/boss_archaedas.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616

1717
/* ScriptData
1818
SDName: Boss_Archaedas
19-
SD%Complete: 60
20-
SDComment: Need correct way to deal with awaken vault and guardian spells, waiting for additions in mangos for them (target combination 22/7)
19+
SD%Complete: 100
20+
SDComment:
2121
SDCategory: Uldaman
2222
EndScriptData */
2323

scripts/eastern_kingdoms/uldaman/instance_uldaman.cpp

Lines changed: 86 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ EndScriptData
2626
#include "uldaman.h"
2727

2828
instance_uldaman::instance_uldaman(Map* pMap) : ScriptedInstance(pMap),
29-
m_uiKeeperCooldown(5000),
29+
m_uiKeeperCooldown(0),
3030
m_uiStoneKeepersFallen(0)
3131
{
3232
Initialize();
@@ -43,11 +43,11 @@ void instance_uldaman::OnObjectCreate(GameObject* pGo)
4343
{
4444
case GO_TEMPLE_DOOR_UPPER:
4545
case GO_TEMPLE_DOOR_LOWER:
46-
if (m_auiEncounter[0] == DONE)
46+
if (GetData(TYPE_ALTAR_EVENT) == DONE)
4747
pGo->SetGoState(GO_STATE_ACTIVE);
4848
break;
4949
case GO_ANCIENT_VAULT:
50-
if (m_auiEncounter[1] == DONE)
50+
if (GetData(TYPE_ARCHAEDAS) == DONE)
5151
pGo->SetGoState(GO_STATE_ACTIVE);
5252
break;
5353
case GO_ANCIENT_TREASURE:
@@ -67,8 +67,7 @@ void instance_uldaman::OnCreatureCreate(Creature* pCreature)
6767
m_lWardens.push_back(pCreature->GetObjectGuid());
6868
break;
6969
case NPC_STONE_KEEPER:
70-
// FIXME - This isAlive check is currently useless
71-
m_mKeeperMap[pCreature->GetObjectGuid()] = pCreature->isAlive();
70+
m_lKeepers.push_back(pCreature->GetObjectGuid());
7271
break;
7372
case NPC_ARCHAEDAS:
7473
m_mNpcEntryGuidStore[NPC_ARCHAEDAS] = pCreature->GetObjectGuid();
@@ -87,16 +86,26 @@ void instance_uldaman::SetData(uint32 uiType, uint32 uiData)
8786
{
8887
DoUseDoorOrButton(GO_TEMPLE_DOOR_UPPER);
8988
DoUseDoorOrButton(GO_TEMPLE_DOOR_LOWER);
90-
91-
m_auiEncounter[0] = uiData;
9289
}
90+
else if (uiData == IN_PROGRESS)
91+
{
92+
// Also do a reset before starting the event - this will respawn dead Keepers
93+
DoResetKeeperEvent();
94+
m_uiKeeperCooldown = 5000;
95+
}
96+
else if (uiData == NOT_STARTED)
97+
{
98+
DoResetKeeperEvent();
99+
m_uiStoneKeepersFallen = 0;
100+
}
101+
m_auiEncounter[0] = uiData;
93102
break;
94103

95104
case TYPE_ARCHAEDAS:
96105
if (uiData == DONE)
97106
{
98107
DoUseDoorOrButton(GO_ANCIENT_VAULT);
99-
DoRespawnGameObject(GO_ANCIENT_TREASURE, 30 * MINUTE);
108+
DoRespawnGameObject(GO_ANCIENT_TREASURE, 40 * MINUTE);
100109
}
101110
m_auiEncounter[1] = uiData;
102111
break;
@@ -142,6 +151,7 @@ void instance_uldaman::SetData64(uint32 uiData, uint64 uiGuid)
142151
{
143152
switch (uiData)
144153
{
154+
// ToDo: check if this one is used in ACID. Otherwise it can be dropped
145155
case DATA_EVENT_STARTER:
146156
m_playerGuid = ObjectGuid(uiGuid);
147157
break;
@@ -152,6 +162,8 @@ uint32 instance_uldaman::GetData(uint32 uiType) const
152162
{
153163
switch (uiType)
154164
{
165+
case TYPE_ALTAR_EVENT:
166+
return m_auiEncounter[0];
155167
case TYPE_ARCHAEDAS:
156168
return m_auiEncounter[1];
157169
}
@@ -174,25 +186,31 @@ void instance_uldaman::StartEvent(uint32 uiEventId, Player* pPlayer)
174186

175187
if (uiEventId == EVENT_ID_ALTAR_KEEPER)
176188
{
177-
if (m_auiEncounter[0] == NOT_STARTED)
178-
m_auiEncounter[0] = IN_PROGRESS;
189+
if (GetData(TYPE_ALTAR_EVENT) == NOT_STARTED)
190+
SetData(TYPE_ALTAR_EVENT, IN_PROGRESS);
191+
}
192+
else if (uiEventId == EVENT_ID_ALTAR_ARCHAEDAS)
193+
{
194+
if (GetData(TYPE_ARCHAEDAS) == NOT_STARTED || GetData(TYPE_ARCHAEDAS) == FAIL)
195+
SetData(TYPE_ARCHAEDAS, SPECIAL);
179196
}
180-
else if (m_auiEncounter[1] == NOT_STARTED || m_auiEncounter[1] == FAIL)
181-
m_auiEncounter[1] = SPECIAL;
182197
}
183198

184199
void instance_uldaman::DoResetKeeperEvent()
185200
{
186-
m_auiEncounter[0] = NOT_STARTED;
187-
m_uiStoneKeepersFallen = 0;
201+
if (m_lKeepers.empty())
202+
{
203+
script_error_log("Instance Uldaman: ERROR creature %u couldn't be found or something really bad happened.", NPC_STONE_KEEPER);
204+
return;
205+
}
188206

189-
for (std::map<ObjectGuid, bool>::iterator itr = m_mKeeperMap.begin(); itr != m_mKeeperMap.end(); ++itr)
207+
// Force reset all keepers to the original state
208+
for (GuidList::const_iterator itr = m_lKeepers.begin(); itr != m_lKeepers.end(); ++itr)
190209
{
191-
if (Creature* pKeeper = instance->GetCreature(itr->first))
210+
if (Creature* pKeeper = instance->GetCreature(*itr))
192211
{
193-
pKeeper->SetRespawnDelay(3);
194-
pKeeper->ForcedDespawn(1000);
195-
itr->second = true;
212+
if (!pKeeper->isAlive())
213+
pKeeper->Respawn();
196214
}
197215
}
198216
}
@@ -216,58 +234,66 @@ Creature* instance_uldaman::GetClosestDwarfNotInCombat(Creature* pSearcher)
216234
return lTemp.front();
217235
}
218236

219-
void instance_uldaman::Update(uint32 uiDiff)
237+
void instance_uldaman::OnCreatureEvade(Creature* pCreature)
220238
{
221-
if (m_auiEncounter[0] == IN_PROGRESS)
239+
// Reset Altar event
240+
if (pCreature->GetEntry() == NPC_STONE_KEEPER)
241+
SetData(TYPE_ALTAR_EVENT, NOT_STARTED);
242+
}
243+
244+
void instance_uldaman::OnCreatureDeath(Creature* pCreature)
245+
{
246+
if (pCreature->GetEntry() == NPC_STONE_KEEPER)
222247
{
223-
if (m_uiKeeperCooldown >= uiDiff)
224-
m_uiKeeperCooldown -= uiDiff;
248+
++m_uiStoneKeepersFallen;
249+
250+
if (m_lKeepers.size() == m_uiStoneKeepersFallen)
251+
SetData(TYPE_ALTAR_EVENT, DONE);
225252
else
226-
{
227253
m_uiKeeperCooldown = 5000;
254+
}
255+
}
256+
257+
void instance_uldaman::Update(uint32 uiDiff)
258+
{
259+
if (GetData(TYPE_ALTAR_EVENT) != IN_PROGRESS)
260+
return;
228261

229-
if (!m_mKeeperMap.empty())
262+
if (!m_uiKeeperCooldown)
263+
return;
264+
265+
if (m_uiKeeperCooldown <= uiDiff)
266+
{
267+
for (GuidList::const_iterator itr = m_lKeepers.begin(); itr != m_lKeepers.end(); ++itr)
268+
{
269+
// Get Keeper which is alive and out of combat
270+
Creature* pKeeper = instance->GetCreature(*itr);
271+
if (!pKeeper || !pKeeper->isAlive() || pKeeper->getVictim())
272+
continue;
273+
274+
// Get starter player for attack
275+
Player* pPlayer = pKeeper->GetMap()->GetPlayer(m_playerGuid);
276+
if (!pPlayer || !pPlayer->isAlive())
230277
{
231-
for (std::map<ObjectGuid, bool>::iterator itr = m_mKeeperMap.begin(); itr != m_mKeeperMap.end(); ++itr)
278+
// If he's not available, then get a random player, within a reasonamble distance in map
279+
pPlayer = GetPlayerInMap(true, false);
280+
if (!pPlayer || !pPlayer->IsWithinDistInMap(pKeeper, 50.0f))
232281
{
233-
// died earlier
234-
if (!itr->second)
235-
continue;
236-
237-
if (Creature* pKeeper = instance->GetCreature(itr->first))
238-
{
239-
if (pKeeper->isAlive() && !pKeeper->getVictim())
240-
{
241-
if (Player* pPlayer = pKeeper->GetMap()->GetPlayer(m_playerGuid))
242-
{
243-
// we should use group instead, event starter can be dead while group is still fighting
244-
if (pPlayer->isAlive() && !pPlayer->isInCombat())
245-
{
246-
pKeeper->RemoveAurasDueToSpell(SPELL_STONED);
247-
pKeeper->AI()->AttackStart(pPlayer);
248-
}
249-
else
250-
{
251-
if (!pPlayer->isAlive())
252-
DoResetKeeperEvent();
253-
}
254-
}
255-
256-
break;
257-
}
258-
else if (!pKeeper->isAlive())
259-
{
260-
itr->second = pKeeper->isAlive();
261-
++m_uiStoneKeepersFallen;
262-
}
263-
}
282+
SetData(TYPE_ALTAR_EVENT, NOT_STARTED);
283+
return;
264284
}
265-
266-
if (m_uiStoneKeepersFallen == m_mKeeperMap.size())
267-
SetData(TYPE_ALTAR_EVENT, DONE);
268285
}
286+
287+
// Attack the player
288+
pKeeper->RemoveAurasDueToSpell(SPELL_STONED);
289+
pKeeper->AI()->AttackStart(pPlayer);
290+
break;
269291
}
292+
293+
m_uiKeeperCooldown = 0;
270294
}
295+
else
296+
m_uiKeeperCooldown -= uiDiff;
271297
}
272298

273299
InstanceData* GetInstanceData_instance_uldaman(Map* pMap)

scripts/eastern_kingdoms/uldaman/uldaman.h

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ class MANGOS_DLL_DECL instance_uldaman : public ScriptedInstance
4343
void OnObjectCreate(GameObject* pGo) override;
4444
void OnCreatureCreate(Creature* pCreature) override;
4545

46+
void OnCreatureDeath(Creature* pCreature) override;
47+
void OnCreatureEvade(Creature* pCreature) override;
48+
4649
void Update(uint32 uiDiff) override;
4750

4851
void SetData(uint32 uiType, uint32 uiData) override;
@@ -52,14 +55,14 @@ class MANGOS_DLL_DECL instance_uldaman : public ScriptedInstance
5255

5356
void StartEvent(uint32 uiEventId, Player* pPlayer);
5457

55-
void DoResetKeeperEvent();
56-
5758
Creature* GetClosestDwarfNotInCombat(Creature* pSearcher);
5859

5960
const char* Save() const override { return m_strInstData.c_str(); }
6061
void Load(const char* chrIn) override;
6162

6263
protected:
64+
void DoResetKeeperEvent();
65+
6366
uint32 m_auiEncounter[MAX_ENCOUNTER];
6467
std::string m_strInstData;
6568

@@ -69,7 +72,7 @@ class MANGOS_DLL_DECL instance_uldaman : public ScriptedInstance
6972
uint32 m_uiStoneKeepersFallen;
7073

7174
GuidList m_lWardens;
72-
std::map<ObjectGuid, bool> m_mKeeperMap;
75+
GuidList m_lKeepers;
7376
};
7477

7578
#endif

sd2_revision_nr.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
#ifndef __SD2_REVISION_NR_H__
22
#define __SD2_REVISION_NR_H__
3-
#define SD2_REVISION_NR "2854"
3+
#define SD2_REVISION_NR "2855"
44
#endif // __SD2_REVISION_NR_H__

0 commit comments

Comments
 (0)