1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
|
/*
* This file is part of the AzerothCore Project. See AUTHORS file for Copyright information
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "AreaDefines.h"
#include "CreatureAI.h"
#include "InstanceMapScript.h"
#include "InstanceScript.h"
#include "SpellScript.h"
#include "SpellScriptLoader.h"
#include "uldaman.h"
enum Spells
{
SPELL_ARCHAEDAS_AWAKEN = 10347,
SPELL_AWAKEN_VAULT_WALKER = 10258,
};
enum Events
{
EVENT_SUB_BOSS_AGGRO = 2228
};
class instance_uldaman : public InstanceMapScript
{
public:
instance_uldaman() : InstanceMapScript("instance_uldaman", MAP_ULDAMAN) { }
struct instance_uldaman_InstanceMapScript : public InstanceScript
{
instance_uldaman_InstanceMapScript(Map* map) : InstanceScript(map) { }
void Initialize() override
{
SetHeaders(DataHeader);
memset(&_encounters, 0, sizeof(_encounters));
}
void OnGameObjectCreate(GameObject* gameobject) override
{
switch (gameobject->GetEntry())
{
case GO_IRONAYA_SEAL_DOOR:
case GO_KEYSTONE:
if (_encounters[DATA_IRONAYA_DOORS] == DONE)
{
HandleGameObject(ObjectGuid::Empty, true, gameobject);
gameobject->SetGameObjectFlag(GO_FLAG_NOT_SELECTABLE);
}
break;
case GO_TEMPLE_DOOR:
if (_encounters[DATA_STONE_KEEPERS] == DONE)
HandleGameObject(ObjectGuid::Empty, true, gameobject);
break;
case GO_ANCIENT_VAULT_DOOR:
ancientVaultDoorGUID = gameobject->GetGUID();
if (_encounters[DATA_ARCHAEDAS] == DONE)
HandleGameObject(ObjectGuid::Empty, true, gameobject);
break;
case GO_ARCHAEDAS_TEMPLE_DOOR:
archaedasTempleDoorGUID = gameobject->GetGUID();
break;
}
}
void SetData(uint32 type, uint32 data) override
{
switch (type)
{
case DATA_IRONAYA_DOORS:
case DATA_STONE_KEEPERS:
_encounters[type] = data;
break;
case DATA_ARCHAEDAS:
_encounters[type] = data;
HandleGameObject(ancientVaultDoorGUID, data == DONE, nullptr);
HandleGameObject(archaedasTempleDoorGUID, data != IN_PROGRESS, nullptr);
break;
}
if (data == DONE)
SaveToDB();
}
uint32 GetData(uint32 data) const override
{
if (data < MAX_ENCOUNTERS)
{
return _encounters[data];
}
return 0;
}
void ReadSaveDataMore(std::istringstream& data) override
{
data >> _encounters[DATA_IRONAYA_DOORS];
data >> _encounters[DATA_STONE_KEEPERS];
data >> _encounters[DATA_ARCHAEDAS];
}
void WriteSaveDataMore(std::ostringstream& data) override
{
data << _encounters[DATA_IRONAYA_DOORS] << ' '
<< _encounters[DATA_STONE_KEEPERS] << ' '
<< _encounters[DATA_ARCHAEDAS];
}
void OnCreatureCreate(Creature* creature) override
{
switch (creature->GetEntry())
{
case NPC_STONE_KEEPER:
if (_encounters[DATA_STONE_KEEPERS] != DONE && !creature->IsAlive())
creature->Respawn();
break;
}
}
private:
uint32 _encounters[MAX_ENCOUNTERS];
ObjectGuid archaedasTempleDoorGUID;
ObjectGuid ancientVaultDoorGUID;
};
InstanceScript* GetInstanceScript(InstanceMap* map) const override
{
return new instance_uldaman_InstanceMapScript(map);
}
};
class spell_uldaman_sub_boss_agro_keepers : public SpellScript
{
PrepareSpellScript(spell_uldaman_sub_boss_agro_keepers);
void HandleSendEvent(SpellEffIndex /*effIndex*/)
{
if (Creature* keeper = GetCaster()->FindNearestCreature(NPC_STONE_KEEPER, 100.0f, true))
keeper->AI()->SetData(1, 1);
}
void Register() override
{
OnEffectLaunch += SpellEffectFn(spell_uldaman_sub_boss_agro_keepers::HandleSendEvent, EFFECT_0, SPELL_EFFECT_SEND_EVENT);
}
};
class spell_uldaman_stoned_aura : public AuraScript
{
PrepareAuraScript(spell_uldaman_stoned_aura);
bool Load() override
{
return GetUnitOwner()->IsCreature() && GetUnitOwner()->GetMapId() == MAP_ULDAMAN;
}
void HandleEffectApply(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/)
{
Creature* target = GetUnitOwner()->ToCreature();
target->SetReactState(REACT_PASSIVE);
target->SetImmuneToAll(true);
}
void HandleEffectRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/)
{
Creature* target = GetUnitOwner()->ToCreature();
target->SetReactState(REACT_AGGRESSIVE);
target->SetImmuneToAll(false);
}
void Register() override
{
OnEffectApply += AuraEffectApplyFn(spell_uldaman_stoned_aura::HandleEffectApply, EFFECT_0, SPELL_AURA_DUMMY, AURA_EFFECT_HANDLE_REAL);
OnEffectRemove += AuraEffectRemoveFn(spell_uldaman_stoned_aura::HandleEffectRemove, EFFECT_0, SPELL_AURA_DUMMY, AURA_EFFECT_HANDLE_REAL);
}
};
class spell_uldaman_boss_agro_archaedas : public SpellScript
{
PrepareSpellScript(spell_uldaman_boss_agro_archaedas);
void HandleSendEvent(SpellEffIndex /*effIndex*/)
{
InstanceScript* instance = GetCaster()->GetInstanceScript();
if (!instance || instance->GetData(DATA_ARCHAEDAS) == IN_PROGRESS || instance->GetData(DATA_ARCHAEDAS) == DONE)
return;
instance->SetData(DATA_ARCHAEDAS, IN_PROGRESS);
if (Creature* archaedas = GetCaster()->FindNearestCreature(NPC_ARCHAEDAS, 100.0f, true))
archaedas->AI()->SetData(1, 1);
}
void Register() override
{
OnEffectLaunch += SpellEffectFn(spell_uldaman_boss_agro_archaedas::HandleSendEvent, EFFECT_0, SPELL_EFFECT_SEND_EVENT);
}
};
void AddSC_instance_uldaman()
{
new instance_uldaman();
RegisterSpellScript(spell_uldaman_sub_boss_agro_keepers);
RegisterSpellScript(spell_uldaman_stoned_aura);
RegisterSpellScript(spell_uldaman_boss_agro_archaedas);
}
|