-
Notifications
You must be signed in to change notification settings - Fork 202
Expand file tree
/
Copy pathdesolace.cpp
More file actions
417 lines (349 loc) · 13.3 KB
/
desolace.cpp
File metadata and controls
417 lines (349 loc) · 13.3 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
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
/* 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: Desolace
SD%Complete: 100
SDComment: Quest support: 1440, 5561, 6132
SDCategory: Desolace
EndScriptData */
/* ContentData
npc_aged_dying_ancient_kodo
npc_dalinda_malem
npc_melizza_brimbuzzle
EndContentData */
#include "precompiled.h"
#include "escort_ai.h"
/*######
## npc_aged_dying_ancient_kodo
######*/
enum
{
SAY_SMEED_HOME_1 = -1000348,
SAY_SMEED_HOME_2 = -1000349,
SAY_SMEED_HOME_3 = -1000350,
QUEST_KODO = 5561,
NPC_SMEED = 11596,
NPC_AGED_KODO = 4700,
NPC_DYING_KODO = 4701,
NPC_ANCIENT_KODO = 4702,
NPC_TAMED_KODO = 11627,
SPELL_KODO_KOMBO_ITEM = 18153,
SPELL_KODO_KOMBO_PLAYER_BUFF = 18172, // spells here have unclear function, but using them at least for visual parts and checks
SPELL_KODO_KOMBO_DESPAWN_BUFF = 18377,
SPELL_KODO_KOMBO_GOSSIP = 18362
};
struct npc_aged_dying_ancient_kodoAI : public ScriptedAI
{
npc_aged_dying_ancient_kodoAI(Creature* pCreature) : ScriptedAI(pCreature) { Reset(); }
uint32 m_uiDespawnTimer;
void Reset() override
{
m_uiDespawnTimer = 0;
}
void MoveInLineOfSight(Unit* pWho) override
{
if (pWho->GetEntry() == NPC_SMEED)
{
if (m_creature->HasFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP))
return;
if (m_creature->IsWithinDistInMap(pWho, 10.0f))
{
switch (urand(0, 2))
{
case 0: DoScriptText(SAY_SMEED_HOME_1, pWho); break;
case 1: DoScriptText(SAY_SMEED_HOME_2, pWho); break;
case 2: DoScriptText(SAY_SMEED_HOME_3, pWho); break;
}
// spell have no implemented effect (dummy), so useful to notify spellHit
m_creature->CastSpell(m_creature, SPELL_KODO_KOMBO_GOSSIP, true);
}
}
}
void SpellHit(Unit* /*pCaster*/, SpellEntry const* pSpell) override
{
if (pSpell->Id == SPELL_KODO_KOMBO_GOSSIP)
{
m_creature->SetFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP);
m_uiDespawnTimer = 60000;
}
}
void UpdateAI(const uint32 diff) override
{
// timer should always be == 0 unless we already updated entry of creature. Then not expect this updated to ever be in combat.
if (m_uiDespawnTimer && m_uiDespawnTimer <= diff)
{
if (!m_creature->getVictim() && m_creature->isAlive())
{
Reset();
m_creature->SetDeathState(JUST_DIED);
m_creature->Respawn();
return;
}
}
else m_uiDespawnTimer -= diff;
if (!m_creature->SelectHostileTarget() || !m_creature->getVictim())
return;
DoMeleeAttackIfReady();
}
};
CreatureAI* GetAI_npc_aged_dying_ancient_kodo(Creature* pCreature)
{
return new npc_aged_dying_ancient_kodoAI(pCreature);
}
bool EffectDummyCreature_npc_aged_dying_ancient_kodo(Unit* pCaster, uint32 spellId, SpellEffectIndex effIndex, Creature* pCreatureTarget, ObjectGuid /*originalCasterGuid*/)
{
// always check spellid and effectindex
if (spellId == SPELL_KODO_KOMBO_ITEM && effIndex == EFFECT_INDEX_0)
{
// no effect if player/creature already have aura from spells
if (pCaster->HasAura(SPELL_KODO_KOMBO_PLAYER_BUFF) || pCreatureTarget->HasAura(SPELL_KODO_KOMBO_DESPAWN_BUFF))
return true;
if (pCreatureTarget->GetEntry() == NPC_AGED_KODO ||
pCreatureTarget->GetEntry() == NPC_DYING_KODO ||
pCreatureTarget->GetEntry() == NPC_ANCIENT_KODO)
{
pCaster->CastSpell(pCaster, SPELL_KODO_KOMBO_PLAYER_BUFF, true);
pCreatureTarget->UpdateEntry(NPC_TAMED_KODO);
pCreatureTarget->CastSpell(pCreatureTarget, SPELL_KODO_KOMBO_DESPAWN_BUFF, false);
if (pCreatureTarget->GetMotionMaster()->GetCurrentMovementGeneratorType() == WAYPOINT_MOTION_TYPE)
pCreatureTarget->GetMotionMaster()->MoveIdle();
pCreatureTarget->GetMotionMaster()->MoveFollow(pCaster, PET_FOLLOW_DIST, PET_FOLLOW_ANGLE);
}
// always return true when we are handling this spell and effect
return true;
}
return false;
}
bool GossipHello_npc_aged_dying_ancient_kodo(Player* pPlayer, Creature* pCreature)
{
if (pPlayer->HasAura(SPELL_KODO_KOMBO_PLAYER_BUFF) && pCreature->HasAura(SPELL_KODO_KOMBO_DESPAWN_BUFF))
{
// the expected quest objective
pPlayer->TalkedToCreature(pCreature->GetEntry(), pCreature->GetObjectGuid());
pPlayer->RemoveAurasDueToSpell(SPELL_KODO_KOMBO_PLAYER_BUFF);
pCreature->GetMotionMaster()->MoveIdle();
}
pPlayer->SEND_GOSSIP_MENU(pPlayer->GetGossipTextId(pCreature), pCreature->GetObjectGuid());
return true;
}
/*######
## npc_dalinda_malem
######*/
enum
{
QUEST_RETURN_TO_VAHLARRIEL = 1440,
};
struct npc_dalinda_malemAI : public npc_escortAI
{
npc_dalinda_malemAI(Creature* m_creature) : npc_escortAI(m_creature) { Reset(); }
void Reset() override {}
void JustStartedEscort() override
{
m_creature->SetStandState(UNIT_STAND_STATE_STAND);
}
void WaypointReached(uint32 uiPointId) override
{
if (uiPointId == 18)
{
if (Player* pPlayer = GetPlayerForEscort())
pPlayer->GroupEventHappens(QUEST_RETURN_TO_VAHLARRIEL, m_creature);
}
}
};
CreatureAI* GetAI_npc_dalinda_malem(Creature* pCreature)
{
return new npc_dalinda_malemAI(pCreature);
}
bool QuestAccept_npc_dalinda_malem(Player* pPlayer, Creature* pCreature, const Quest* pQuest)
{
if (pQuest->GetQuestId() == QUEST_RETURN_TO_VAHLARRIEL)
{
if (npc_dalinda_malemAI* pEscortAI = dynamic_cast<npc_dalinda_malemAI*>(pCreature->AI()))
{
// TODO This faction change needs confirmation, also possible that we need to drop her PASSIVE flag
pCreature->SetFactionTemporary(FACTION_ESCORT_A_NEUTRAL_PASSIVE, TEMPFACTION_RESTORE_RESPAWN | TEMPFACTION_TOGGLE_PASSIVE);
pEscortAI->Start(false, pPlayer, pQuest);
}
}
return true;
}
/*######
## npc_melizza_brimbuzzle
######*/
enum
{
QUEST_GET_ME_OUT_OF_HERE = 6132,
GO_MELIZZAS_CAGE = 177706,
SAY_MELIZZA_START = -1000784,
SAY_MELIZZA_FINISH = -1000785,
SAY_MELIZZA_1 = -1000786,
SAY_MELIZZA_2 = -1000787,
SAY_MELIZZA_3 = -1000788,
NPC_MARAUDINE_MARAUDER = 4659,
NPC_MARAUDINE_BONEPAW = 4660,
NPC_MARAUDINE_WRANGLER = 4655,
NPC_MELIZZA = 12277,
POINT_ID_QUEST_COMPLETE = 1,
POINT_ID_EVENT_COMPLETE = 2,
MAX_MARAUDERS = 2,
MAX_WRANGLERS = 3,
};
static const DialogueEntry aIntroDialogue[] =
{
{POINT_ID_QUEST_COMPLETE, 0, 1000},
{QUEST_GET_ME_OUT_OF_HERE, NPC_MELIZZA, 0},
{POINT_ID_EVENT_COMPLETE, 0, 2000},
{SAY_MELIZZA_1, NPC_MELIZZA, 4000},
{SAY_MELIZZA_2, NPC_MELIZZA, 5000},
{SAY_MELIZZA_3, NPC_MELIZZA, 4000},
{NPC_MELIZZA, 0, 0},
{0, 0, 0},
};
struct SummonLocation
{
float m_fX, m_fY, m_fZ;
};
static const SummonLocation aMarauderSpawn[] =
{
{ -1291.492f, 2644.650f, 111.556f},
{ -1306.730f, 2675.163f, 111.561f},
};
static const SummonLocation wranglerSpawn = { -1393.194f, 2429.465f, 88.689f };
struct npc_melizza_brimbuzzleAI : public npc_escortAI, private DialogueHelper
{
npc_melizza_brimbuzzleAI(Creature* m_creature) : npc_escortAI(m_creature),
DialogueHelper(aIntroDialogue)
{
Reset();
}
void Reset() override {}
void JustStartedEscort() override
{
if (GameObject* pCage = GetClosestGameObjectWithEntry(m_creature, GO_MELIZZAS_CAGE, INTERACTION_DISTANCE))
pCage->UseDoorOrButton();
}
Creature* GetSpeakerByEntry(uint32 uiEntry) override
{
if (uiEntry == NPC_MELIZZA)
return m_creature;
return NULL;
}
void WaypointReached(uint32 uiPointId) override
{
switch (uiPointId)
{
case 1:
if (Player* pPlayer = GetPlayerForEscort())
DoScriptText(SAY_MELIZZA_START, m_creature, pPlayer);
m_creature->SetFactionTemporary(FACTION_ESCORT_N_NEUTRAL_PASSIVE, TEMPFACTION_RESTORE_RESPAWN);
break;
case 4:
for (uint8 i = 0; i < MAX_MARAUDERS; ++i)
{
for (uint8 j = 0; j < MAX_MARAUDERS; ++j)
{
// Summon 2 Marauders on each point
float fX, fY, fZ;
m_creature->GetRandomPoint(aMarauderSpawn[i].m_fX, aMarauderSpawn[i].m_fY, aMarauderSpawn[i].m_fZ, 7.0f, fX, fY, fZ);
m_creature->SummonCreature(NPC_MARAUDINE_MARAUDER, fX, fY, fZ, 0.0f, TEMPSUMMON_DEAD_DESPAWN, 0);
}
}
break;
case 9:
for (uint8 i = 0; i < MAX_WRANGLERS; ++i)
{
float fX, fY, fZ;
m_creature->GetRandomPoint(wranglerSpawn.m_fX, wranglerSpawn.m_fY, wranglerSpawn.m_fZ, 10.0f, fX, fY, fZ);
m_creature->SummonCreature(NPC_MARAUDINE_BONEPAW, fX, fY, fZ, 0.0f, TEMPSUMMON_DEAD_DESPAWN, 0);
m_creature->GetRandomPoint(wranglerSpawn.m_fX, wranglerSpawn.m_fY, wranglerSpawn.m_fZ, 10.0f, fX, fY, fZ);
m_creature->SummonCreature(NPC_MARAUDINE_WRANGLER, fX, fY, fZ, 0.0f, TEMPSUMMON_DEAD_DESPAWN, 0);
}
break;
case 12:
StartNextDialogueText(POINT_ID_QUEST_COMPLETE);
break;
case 19:
StartNextDialogueText(POINT_ID_EVENT_COMPLETE);
break;
}
}
void JustDidDialogueStep(int32 iEntry) override
{
switch (iEntry)
{
case POINT_ID_QUEST_COMPLETE:
SetEscortPaused(true);
break;
case QUEST_GET_ME_OUT_OF_HERE:
if (Player* pPlayer = GetPlayerForEscort())
{
DoScriptText(SAY_MELIZZA_FINISH, m_creature, pPlayer);
pPlayer->GroupEventHappens(QUEST_GET_ME_OUT_OF_HERE, m_creature);
}
m_creature->ClearTemporaryFaction();
SetRun(true);
SetEscortPaused(false);
break;
case POINT_ID_EVENT_COMPLETE:
SetEscortPaused(true);
m_creature->SetFacingTo(4.71f);
break;
case NPC_MELIZZA:
SetEscortPaused(false);
break;
}
}
void UpdateEscortAI(const uint32 uiDiff) override
{
DialogueUpdate(uiDiff);
if (!m_creature->SelectHostileTarget() || !m_creature->getVictim())
return;
DoMeleeAttackIfReady();
}
};
CreatureAI* GetAI_npc_melizza_brimbuzzle(Creature* pCreature)
{
return new npc_melizza_brimbuzzleAI(pCreature);
}
bool QuestAccept_npc_melizza_brimbuzzle(Player* pPlayer, Creature* pCreature, const Quest* pQuest)
{
if (pQuest->GetQuestId() == QUEST_GET_ME_OUT_OF_HERE)
{
if (npc_melizza_brimbuzzleAI* pEscortAI = dynamic_cast<npc_melizza_brimbuzzleAI*>(pCreature->AI()))
pEscortAI->Start(false, pPlayer, pQuest);
}
return true;
}
void AddSC_desolace()
{
Script* pNewScript;
pNewScript = new Script;
pNewScript->Name = "npc_aged_dying_ancient_kodo";
pNewScript->GetAI = &GetAI_npc_aged_dying_ancient_kodo;
pNewScript->pEffectDummyNPC = &EffectDummyCreature_npc_aged_dying_ancient_kodo;
pNewScript->pGossipHello = &GossipHello_npc_aged_dying_ancient_kodo;
pNewScript->RegisterSelf();
pNewScript = new Script;
pNewScript->Name = "npc_dalinda_malem";
pNewScript->GetAI = &GetAI_npc_dalinda_malem;
pNewScript->pQuestAcceptNPC = &QuestAccept_npc_dalinda_malem;
pNewScript->RegisterSelf();
pNewScript = new Script;
pNewScript->Name = "npc_melizza_brimbuzzle";
pNewScript->GetAI = &GetAI_npc_melizza_brimbuzzle;
pNewScript->pQuestAcceptNPC = &QuestAccept_npc_melizza_brimbuzzle;
pNewScript->RegisterSelf();
}