-
Notifications
You must be signed in to change notification settings - Fork 202
Expand file tree
/
Copy pathzuldrak.cpp
More file actions
295 lines (244 loc) · 8.53 KB
/
zuldrak.cpp
File metadata and controls
295 lines (244 loc) · 8.53 KB
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
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
/* This file is part of the ScriptDev2 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, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/* ScriptData
SDName: Zuldrak
SD%Complete: 100
SDComment: Quest support: 12652, 12934.
SDCategory: Zuldrak
EndScriptData */
/* ContentData
npc_gurgthock
npc_ghoul_feeding_bunny
npc_decaying_ghoul
EndContentData */
#include "precompiled.h"
#include "TemporarySummon.h"
/*######
## npc_gurgthock
######*/
enum
{
QUEST_FROM_BEYOND = 12934,
NPC_AZBARIN = 30026,
NPC_DUKE_SINGEN = 30019,
NPC_ERATHIUS = 30025,
NPC_GARGORAL = 30024
};
static float m_afSpawnLocation[] = {5768.71f, -2969.29f, 273.816f};
static uint32 m_auiBosses[] = {NPC_AZBARIN, NPC_DUKE_SINGEN, NPC_ERATHIUS, NPC_GARGORAL};
struct npc_gurgthockAI : public ScriptedAI
{
npc_gurgthockAI(Creature* pCreature) : ScriptedAI(pCreature) { Reset(); }
ObjectGuid m_playerGuid;
void SetPlayer(Player* pPlayer)
{
m_playerGuid = pPlayer->GetObjectGuid();
}
void Reset() override
{
m_playerGuid.Clear();
}
void SummonedCreatureJustDied(Creature* pSummoned) override
{
uint32 uiEntry = pSummoned->GetEntry();
for (uint8 i = 0; i < 4; ++i)
{
if (uiEntry == m_auiBosses[i])
{
if (Player* pPlayer = m_creature->GetMap()->GetPlayer(m_playerGuid))
pPlayer->GroupEventHappens(QUEST_FROM_BEYOND, m_creature);
m_playerGuid.Clear();
return;
}
}
}
};
bool QuestAccept_npc_gurgthock(Player* pPlayer, Creature* pCreature, const Quest* pQuest)
{
if (pQuest->GetQuestId() == QUEST_FROM_BEYOND)
{
pCreature->SummonCreature(m_auiBosses[urand(0, 3)], m_afSpawnLocation[0], m_afSpawnLocation[1], m_afSpawnLocation[2], 0.0f, TEMPSUMMON_TIMED_OOC_OR_CORPSE_DESPAWN, 600000);
if (npc_gurgthockAI* pGurthockAI = dynamic_cast<npc_gurgthockAI*>(pCreature->AI()))
pGurthockAI->SetPlayer(pPlayer);
}
return true;
}
CreatureAI* GetAI_npc_gurgthock(Creature* pCreature)
{
return new npc_gurgthockAI(pCreature);
}
/*######
## npc_ghoul_feeding_bunny
######*/
enum
{
SPELL_ATTRACT_GHOUL = 52037, // script target on npc 28565
SPELL_GHOUL_KILL_CREDIT = 52030,
// SPELL_GHOUL_KILL_CREDIT_EFFECT = 52038, // triggers 52039; purpose unk - same effect as 52030 but with different target
NPC_DECAYING_GHOUL = 28565,
};
struct npc_ghoul_feeding_bunnyAI : public ScriptedAI
{
npc_ghoul_feeding_bunnyAI(Creature* pCreature) : ScriptedAI(pCreature) { Reset(); }
uint32 m_uiAttractTimer;
void Reset() override
{
m_uiAttractTimer = 1000;
}
void ReceiveAIEvent(AIEventType eventType, Creature* /*pSender*/, Unit* pInvoker, uint32 /*uiMiscValue*/) override
{
if (eventType == AI_EVENT_CUSTOM_A && pInvoker->GetEntry() == NPC_DECAYING_GHOUL)
{
// Give kill credit to the summoner player
if (m_creature->IsTemporarySummon())
{
TemporarySummon* pTemporary = (TemporarySummon*)m_creature;
if (Player* pSummoner = m_creature->GetMap()->GetPlayer(pTemporary->GetSummonerGuid()))
DoCastSpellIfCan(pSummoner, SPELL_GHOUL_KILL_CREDIT, CAST_TRIGGERED);
}
}
}
void UpdateAI(const uint32 uiDiff) override
{
if (m_uiAttractTimer)
{
if (m_uiAttractTimer <= uiDiff)
{
// try to target a nearby ghoul
if (DoCastSpellIfCan(m_creature, SPELL_ATTRACT_GHOUL) == CAST_OK)
m_uiAttractTimer = 0;
else
m_uiAttractTimer = 5000;
}
else
m_uiAttractTimer -= uiDiff;
}
}
};
CreatureAI* GetAI_npc_ghoul_feeding_bunny(Creature* pCreature)
{
return new npc_ghoul_feeding_bunnyAI(pCreature);
}
/*######
## npc_decaying_ghoul
######*/
enum
{
SPELL_BIRTH = 26047,
SPELL_FLESH_ROT = 28913,
NPC_GHOUL_FEEDING_BUNNY = 28591,
};
struct npc_decaying_ghoulAI : public ScriptedAI
{
npc_decaying_ghoulAI(Creature* pCreature) : ScriptedAI(pCreature)
{
m_bSpawnAnim = false;
Reset();
}
uint32 m_uiFleshRotTimer;
bool m_bSpawnAnim;
ObjectGuid m_feedingBunnyGuid;
void Reset() override
{
m_uiFleshRotTimer = urand(1000, 3000);
}
void JustRespawned() override
{
DoCastSpellIfCan(m_creature, SPELL_BIRTH);
m_creature->HandleEmote(EMOTE_STATE_NONE);
m_feedingBunnyGuid.Clear();
}
void MovementInform(uint32 uiMoveType, uint32 uiPointId) override
{
if (uiMoveType != POINT_MOTION_TYPE || !uiPointId)
return;
// handle the animation and despawn
m_creature->GetMotionMaster()->MoveIdle();
m_creature->HandleEmote(EMOTE_STATE_EAT_NO_SHEATHE);
m_creature->ForcedDespawn(10000);
// send AI event for the quest credit
if (Creature* pBunny = m_creature->GetMap()->GetCreature(m_feedingBunnyGuid))
SendAIEvent(AI_EVENT_CUSTOM_A, m_creature, pBunny);
}
void ReceiveAIEvent(AIEventType eventType, Creature* /*pSender*/, Unit* pInvoker, uint32 /*uiMiscValue*/) override
{
if (eventType == AI_EVENT_CUSTOM_A && pInvoker->GetEntry() == NPC_GHOUL_FEEDING_BUNNY)
{
// check if the ghoul has already a feeding bunny set
if (m_feedingBunnyGuid)
return;
// move the ghoul to the feeding target
float fX, fY, fZ;
m_creature->SetWalk(false);
m_creature->GetMotionMaster()->Clear();
pInvoker->GetContactPoint(m_creature, fX, fY, fZ);
m_creature->GetMotionMaster()->MovePoint(1, fX, fY, fZ);
m_feedingBunnyGuid = pInvoker->GetObjectGuid();
}
}
void UpdateAI(const uint32 uiDiff) override
{
// cast birth animation
if (!m_bSpawnAnim)
{
if (DoCastSpellIfCan(m_creature, SPELL_BIRTH) == CAST_OK)
m_bSpawnAnim = true;
}
if (!m_creature->SelectHostileTarget() || !m_creature->getVictim())
return;
if (m_uiFleshRotTimer < uiDiff)
{
if (DoCastSpellIfCan(m_creature->getVictim(), SPELL_FLESH_ROT) == CAST_OK)
m_uiFleshRotTimer = urand(7000, 15000);
}
else
m_uiFleshRotTimer -= uiDiff;
DoMeleeAttackIfReady();
}
};
CreatureAI* GetAI_npc_decaying_ghoul(Creature* pCreature)
{
return new npc_decaying_ghoulAI(pCreature);
}
bool EffectDummyCreature_npc_decaying_ghoul(Unit* pCaster, uint32 uiSpellId, SpellEffectIndex uiEffIndex, Creature* pCreatureTarget, ObjectGuid /*originalCasterGuid*/)
{
if (uiSpellId == SPELL_ATTRACT_GHOUL && uiEffIndex == EFFECT_INDEX_0 && pCreatureTarget->GetEntry() == NPC_DECAYING_GHOUL)
{
if (pCaster->GetEntry() != NPC_GHOUL_FEEDING_BUNNY)
return true;
pCreatureTarget->AI()->SendAIEvent(AI_EVENT_CUSTOM_A, pCaster, pCreatureTarget);
return true;
}
return false;
}
void AddSC_zuldrak()
{
Script* pNewScript;
pNewScript = new Script;
pNewScript->Name = "npc_gurgthock";
pNewScript->GetAI = &GetAI_npc_gurgthock;
pNewScript->pQuestAcceptNPC = &QuestAccept_npc_gurgthock;
pNewScript->RegisterSelf();
pNewScript = new Script;
pNewScript->Name = "npc_ghoul_feeding_bunny";
pNewScript->GetAI = &GetAI_npc_ghoul_feeding_bunny;
pNewScript->RegisterSelf();
pNewScript = new Script;
pNewScript->Name = "npc_decaying_ghoul";
pNewScript->GetAI = &GetAI_npc_decaying_ghoul;
pNewScript->pEffectDummyNPC = &EffectDummyCreature_npc_decaying_ghoul;
pNewScript->RegisterSelf();
}