1717/* ScriptData
1818SDName: instance_oculus
1919SD%Complete: 50
20- SDComment: Spawn instance bosses and handle Varos pre event; Dialogue NYI
20+ SDComment: Spawn instance bosses and handle Varos pre event; Dialogue handled by DBScripts
2121SDCategory: Oculus
2222EndScriptData */
2323
2424#include " precompiled.h"
2525#include " oculus.h"
2626
27- instance_oculus::instance_oculus (Map* pMap) : ScriptedInstance(pMap),
28- m_uiConstructsDead(0 )
27+ instance_oculus::instance_oculus (Map* pMap) : ScriptedInstance(pMap)
2928{
3029 Initialize ();
3130}
@@ -37,7 +36,16 @@ void instance_oculus::Initialize()
3736
3837void instance_oculus::OnPlayerEnter (Player* pPlayer)
3938{
39+ if (GetData (TYPE_EREGOS ) == DONE )
40+ return ;
41+
4042 DoSpawnNextBossIfCan ();
43+
44+ if (GetData (TYPE_DRAKOS ) == DONE && GetData (TYPE_VAROS ) == NOT_STARTED )
45+ {
46+ pPlayer->SendUpdateWorldState (WORLD_STATE_CONSTRUCTS , 1 );
47+ pPlayer->SendUpdateWorldState (WORLD_STATE_CONSTRUCTS_COUNT , m_sConstructsAliveGUIDSet.size ());
48+ }
4149}
4250
4351void instance_oculus::OnCreatureCreate (Creature* pCreature)
@@ -80,12 +88,12 @@ void instance_oculus::SetData(uint32 uiType, uint32 uiData)
8088 for (GuidList::const_iterator itr = m_lCageDoorGUIDs.begin (); itr != m_lCageDoorGUIDs.end (); ++itr)
8189 DoUseDoorOrButton (*itr);
8290
83- // Notes: There should also be a small dialogue here involving Belgaristrasz and Varos
84- // Also the Centrifuge Constructs and the related npcs should be summoned
91+ // Notes: The dialogue is handled by DB script
92+ // Also the Centrifuge Constructs and the related npcs should be summoned - requires additional research
8593
86- // Activate the world state
94+ // Activate the world state - the Centrifuge contructs should be loaded by now
8795 DoUpdateWorldState (WORLD_STATE_CONSTRUCTS , 1 );
88- DoUpdateWorldState (WORLD_STATE_CONSTRUCTS_COUNT , MAX_CONSTRUCTS );
96+ DoUpdateWorldState (WORLD_STATE_CONSTRUCTS_COUNT , m_sConstructsAliveGUIDSet. size () );
8997
9098 DoStartTimedAchievement (ACHIEVEMENT_CRITERIA_TYPE_KILL_CREATURE , ACHIEV_START_EREGOS_ID );
9199 }
@@ -94,22 +102,26 @@ void instance_oculus::SetData(uint32 uiType, uint32 uiData)
94102 m_auiEncounter[TYPE_VAROS ] = uiData;
95103 if (uiData == DONE )
96104 {
97- // Note: Image of Belgaristrasz teleports here after the boss is dead and does some dialogue
105+ // Note: Image of Belgaristrasz dialogue is handled by DB script
98106 DoSpawnNextBossIfCan ();
99107 DoUpdateWorldState (WORLD_STATE_CONSTRUCTS , 0 );
100108 }
101109 break ;
102110 case TYPE_UROM :
103111 m_auiEncounter[TYPE_UROM ] = uiData;
104- // Note: Image of Belgaristrasz teleports to this boss after it's killed and does some dialogue; Right after this, Eregos appears
112+ // Note: Image of Belgaristrasz dialogue is handled by DB script
105113 if (uiData == DONE )
106114 DoSpawnNextBossIfCan ();
107115 break ;
108116 case TYPE_EREGOS :
109117 m_auiEncounter[TYPE_EREGOS ] = uiData;
110- // Note: Image of Belgaristrasz teleports to the Cache location and does more dialogue
118+ // Note: Image of Belgaristrasz teleports to the Cache location and does more dialogue - requires additional research
111119 if (uiData == DONE )
120+ {
121+ // The data about the cache isn't consistent, so it's better to handle both cases
112122 DoToggleGameObjectFlags (instance->IsRegularDifficulty () ? GO_CACHE_EREGOS : GO_CACHE_EREGOS_H , GO_FLAG_NO_INTERACT , false );
123+ DoRespawnGameObject (instance->IsRegularDifficulty () ? GO_CACHE_EREGOS : GO_CACHE_EREGOS_H , 30 * MINUTE );
124+ }
113125 break ;
114126 }
115127
@@ -135,6 +147,24 @@ uint32 instance_oculus::GetData(uint32 uiType) const
135147 return 0 ;
136148}
137149
150+ void instance_oculus::SetData64 (uint32 uiData, uint64 uiGuid)
151+ {
152+ // If Varos already completed, just ignore
153+ if (GetData (TYPE_VAROS ) == DONE )
154+ return ;
155+
156+ // Note: this is handled in Acid. The purpose is check which Centrifuge Construct is alive, in case of server reset
157+ // The function is triggered by eventAI on generic timer
158+ if (uiData == DATA_CONSTRUCTS_EVENT )
159+ {
160+ m_sConstructsAliveGUIDSet.insert (ObjectGuid (uiGuid));
161+
162+ // Update world state in case of server reset
163+ if (GetData (TYPE_DRAKOS ) == DONE )
164+ DoUpdateWorldState (WORLD_STATE_CONSTRUCTS_COUNT , m_sConstructsAliveGUIDSet.size ());
165+ }
166+ }
167+
138168void instance_oculus::OnCreatureEnterCombat (Creature* pCreature)
139169{
140170 switch (pCreature->GetEntry ())
@@ -160,10 +190,10 @@ void instance_oculus::OnCreatureDeath(Creature* pCreature)
160190 case NPC_DRAKOS : SetData (TYPE_DRAKOS , DONE ); break ;
161191 case NPC_VAROS : SetData (TYPE_VAROS , DONE ); break ;
162192 case NPC_CENTRIFUGE_CONSTRUCT :
163- ++m_uiConstructsDead ;
164- DoUpdateWorldState (WORLD_STATE_CONSTRUCTS_COUNT , MAX_CONSTRUCTS - m_uiConstructsDead );
193+ m_sConstructsAliveGUIDSet. erase (pCreature-> GetObjectGuid ()) ;
194+ DoUpdateWorldState (WORLD_STATE_CONSTRUCTS_COUNT , m_sConstructsAliveGUIDSet. size () );
165195
166- if (m_uiConstructsDead == MAX_CONSTRUCTS )
196+ if (m_sConstructsAliveGUIDSet. empty () )
167197 {
168198 if (Creature* pVaros = GetSingleCreatureFromStorage (NPC_VAROS ))
169199 pVaros->InterruptNonMeleeSpells (false );
0 commit comments