Project SkyFire Core
SkyFire 5.4.8 server core API documentation
Loading...
Searching...
No Matches
gnomeregan.cpp
Go to the documentation of this file.
1/*
2* This file is part of Project SkyFire https://www.projectskyfire.org.
3* See LICENSE.md file for Copyright information
4*/
5
6/* Script Data Start
7SDName: Gnomeregan
8SDAuthor: Manuel
9SD%Complete: 90%
10SDComment: Some visual effects are not implemented.
11Script Data End */
12
13#include "ScriptMgr.h"
14#include "ScriptedCreature.h"
15#include "ScriptedGossip.h"
16#include "gnomeregan.h"
17#include "ScriptedEscortAI.h"
18#include "Player.h"
19
20#define GOSSIP_START_EVENT "I am ready to being"
21
49
51{
52 {-557.630f, -114.514f, -152.209f, 0.641f},
53 {-555.263f, -113.802f, -152.737f, 0.311f},
54 {-552.154f, -112.476f, -153.349f, 0.621f},
55 {-548.692f, -111.089f, -154.090f, 0.621f},
56 {-546.905f, -108.340f, -154.877f, 0.729f},
57 {-547.736f, -105.154f, -155.176f, 0.372f},
58 {-547.274f, -114.109f, -153.952f, 0.735f},
59 {-552.534f, -110.012f, -153.577f, 0.747f},
60 {-550.708f, -116.436f, -153.103f, 0.679f},
61 {-554.030f, -115.983f, -152.635f, 0.695f},
62 {-494.595f, -87.516f, -149.116f, 3.344f},
63 {-493.349f, -90.845f, -148.882f, 3.717f},
64 {-491.995f, -87.619f, -148.197f, 3.230f},
65 {-490.732f, -90.739f, -148.091f, 3.230f},
66 {-490.554f, -89.114f, -148.055f, 3.230f},
67 {-495.240f, -90.808f, -149.493f, 3.238f},
68 {-494.195f, -89.553f, -149.131f, 3.254f},
69 {-511.3304f, -139.9622f, -152.4761f, 0.7504908f},
70 {-510.6754f, -139.4371f, -152.6167f, 3.33359f},
71 {-511.8976f, -139.3562f, -152.4785f, 3.961899f}
72};
73
75{
76public:
77 npc_blastmaster_emi_shortfuse() : CreatureScript("npc_blastmaster_emi_shortfuse") { }
78
80 {
81 return new npc_blastmaster_emi_shortfuseAI(creature);
82 }
83
84 bool OnGossipSelect(Player* player, Creature* creature, uint32 /*sender*/, uint32 action) OVERRIDE
85 {
86 player->PlayerTalkClass->ClearMenus();
87 if (action == GOSSIP_ACTION_INFO_DEF+1)
88 {
90 pEscortAI->Start(true, false, player->GetGUID());
91
92 creature->setFaction(player->getFaction());
93 creature->AI()->SetData(1, 0);
94
95 player->CLOSE_GOSSIP_MENU();
96 }
97 return true;
98 }
99
100 bool OnGossipHello(Player* player, Creature* creature) OVERRIDE
101 {
102 InstanceScript* instance = creature->GetInstanceScript();
103
104 if (instance && instance->GetData(TYPE_EVENT) == NOT_STARTED)
106
107 player->SEND_GOSSIP_MENU(GOSSIP_TEXT_EMI, creature->GetGUID());
108
109 return true;
110 }
111
113 {
115 {
116 instance = creature->GetInstanceScript();
117 creature->RestoreFaction();
118 Reset();
119 }
120
122
125
126 std::list<uint64> SummonList;
127 std::list<uint64> GoSummonList;
128
130 {
132 {
133 uiTimer = 0;
134 uiPhase = 0;
135
136 RestoreAll();
137
138 SummonList.clear();
139 GoSummonList.clear();
140 }
141 }
142
143 void NextStep(uint32 uiTimerStep, bool bNextStep = true, uint8 uiPhaseStep = 0)
144 {
145 uiTimer = uiTimerStep;
146 if (bNextStep)
147 ++uiPhase;
148 else
149 uiPhase = uiPhaseStep;
150 }
151
152 void CaveDestruction(bool bBool)
153 {
154 if (GoSummonList.empty())
155 return;
156
157 for (std::list<uint64>::const_iterator itr = GoSummonList.begin(); itr != GoSummonList.end(); ++itr)
158 {
159 if (GameObject* go = GameObject::GetGameObject(*me, *itr))
160 {
161 if (go)
162 {
163 if (Creature* trigger = go->SummonTrigger(go->GetPositionX(), go->GetPositionY(), go->GetPositionZ(), 0, 1))
164 {
165 //visual effects are not working!
166 trigger->CastSpell(trigger, 11542, true);
167 trigger->CastSpell(trigger, 35470, true);
168 }
169 go->RemoveFromWorld();
170 //go->CastSpell(me, 12158); makes all die?!
171 }
172 }
173 }
174
175 if (bBool)
176 {
177 if (instance)
179 instance->HandleGameObject(0, false, go);
180 }else
181 if (instance)
183 instance->HandleGameObject(0, false, go);
184 }
185
186 void SetInFace(bool bBool)
187 {
188 if (!instance)
189 return;
190
191 if (bBool)
192 {
194 me->SetFacingToObject(go);
195 }else
197 me->SetFacingToObject(go);
198 }
199
201 {
202 if (!instance)
203 return;
204
206 instance->HandleGameObject(0, false, go);
207
209 instance->HandleGameObject(0, false, go);
210
211 if (!GoSummonList.empty())
212 for (std::list<uint64>::const_iterator itr = GoSummonList.begin(); itr != GoSummonList.end(); ++itr)
213 {
214 if (GameObject* go = GameObject::GetGameObject(*me, *itr))
215 go->RemoveFromWorld();
216 }
217
218 if (!SummonList.empty())
219 for (std::list<uint64>::const_iterator itr = SummonList.begin(); itr != SummonList.end(); ++itr)
220 {
221 if (Creature* summon = Unit::GetCreature(*me, *itr))
222 {
223 if (summon->IsAlive())
224 summon->DisappearAndDie();
225 else
226 summon->RemoveCorpse();
227 }
228 }
229 }
230
232 {
233 Map::PlayerList const &PlList = me->GetMap()->GetPlayers();
234
235 if (PlList.isEmpty())
236 return;
237
238 for (Map::PlayerList::const_iterator i = PlList.begin(); i != PlList.end(); ++i)
239 {
240 if (Player* player = i->GetSource())
241 {
242 if (player->IsGameMaster())
243 continue;
244
245 if (player->IsAlive())
246 {
247 temp->SetInCombatWith(player);
248 player->SetInCombatWith(temp);
249 temp->AddThreat(player, 0.0f);
250 }
251 }
252 }
253 }
254
256 {
257 //just in case
258 if (GetPlayerForEscort())
259 if (me->getFaction() != GetPlayerForEscort()->getFaction())
260 me->setFaction(GetPlayerForEscort()->getFaction());
261
262 switch (waypointId)
263 {
264 case 3:
265 SetEscortPaused(true);
266 NextStep(2000, false, 3);
267 break;
268 case 7:
269 SetEscortPaused(true);
270 NextStep(2000, false, 4);
271 break;
272 case 9:
273 NextStep(1000, false, 8);
274 break;
275 case 10:
276 NextStep(25000, false, 10);
277 break;
278 case 11:
279 SetEscortPaused(true);
280 SetInFace(true);
281 NextStep(1000, false, 11);
282 break;
283 case 12:
284 NextStep(25000, false, 18);
285 break;
286 case 13:
287 Summon(6);
288 NextStep(25000, false, 19);
289 break;
290 case 14:
291 SetInFace(false);
293 SetEscortPaused(true);
294 NextStep(5000, false, 20);
295 break;
296 }
297 }
298
299 void SetData(uint32 uiI, uint32 uiValue) OVERRIDE
300 {
301 switch (uiI)
302 {
303 case 1:
304 SetEscortPaused(true);
306 NextStep(2000, true);
307 break;
308 case 2:
309 if (!instance)
310 return;
311
312 switch (uiValue)
313 {
314 case 1:
316 break;
317 case 2:
318 instance->SetData(TYPE_EVENT, DONE);
319 NextStep(5000, false, 22);
320 break;
321 }
322 break;
323 }
324 }
325
326 void Summon(uint8 uiCase)
327 {
328 switch (uiCase)
329 {
330 case 1:
341 break;
342 case 2:
343 if (GameObject* go = me->SummonGameObject(183410, -533.140f, -105.322f, -156.016f, 0, 0, 0, 0, 0, 1000))
344 {
345 GoSummonList.push_back(go->GetGUID());
346 go->SetFlag(GAMEOBJECT_FIELD_FLAGS, GO_FLAG_NOT_SELECTABLE); //We can't use it!
347 }
348 Summon(3);
349 break;
350 case 3:
356 break;
357 case 4:
358 if (GameObject* go = me->SummonGameObject(183410, -542.199f, -96.854f, -155.790f, 0, 0, 0, 0, 0, 1000))
359 {
360 GoSummonList.push_back(go->GetGUID());
362 }
363 break;
364 case 5:
370 break;
371 case 6:
372 if (GameObject* go = me->SummonGameObject(183410, -507.820f, -103.333f, -151.353f, 0, 0, 0, 0, 0, 1000))
373 {
374 GoSummonList.push_back(go->GetGUID());
375 go->SetFlag(GAMEOBJECT_FIELD_FLAGS, GO_FLAG_NOT_SELECTABLE); //We can't use it!
376 Summon(5);
377 }
378 break;
379 case 7:
380 if (GameObject* go = me->SummonGameObject(183410, -511.829f, -86.249f, -151.431f, 0, 0, 0, 0, 0, 1000))
381 {
382 GoSummonList.push_back(go->GetGUID());
383 go->SetFlag(GAMEOBJECT_FIELD_FLAGS, GO_FLAG_NOT_SELECTABLE); //We can't use it!
384 }
385 break;
386 case 8:
387 if (Creature* grubbis = me->SummonCreature(NPC_GRUBBIS, SpawnPosition[15], TempSummonType::TEMPSUMMON_CORPSE_TIMED_DESPAWN, 1800000))
388 grubbis->AI()->Talk(SAY_GRUBBIS);
390 break;
391 case 9:
392 me->SummonGameObject(GO_RED_ROCKET, SpawnPosition[17].GetPositionX(), SpawnPosition[17].GetPositionY(), SpawnPosition[17].GetPositionZ(), SpawnPosition[17].GetOrientation(), 0, 0, 0, 0, 7200);
393 me->SummonGameObject(GO_RED_ROCKET, SpawnPosition[18].GetPositionX(), SpawnPosition[18].GetPositionY(), SpawnPosition[18].GetPositionZ(), SpawnPosition[18].GetOrientation(), 0, 0, 0, 0, 7200);
394 me->SummonGameObject(GO_RED_ROCKET, SpawnPosition[19].GetPositionX(), SpawnPosition[19].GetPositionY(), SpawnPosition[19].GetPositionZ(), SpawnPosition[19].GetOrientation(), 0, 0, 0, 0, 7200);
395 break;
396 }
397 }
398
399 void UpdateEscortAI(const uint32 uiDiff) OVERRIDE
400 {
401 if (uiPhase)
402 {
403 if (uiTimer <= uiDiff)
404 {
405 switch (uiPhase)
406 {
407 case 1:
409 NextStep(2000, true);
410 break;
411 case 2:
412 SetEscortPaused(false);
413 NextStep(0, false, 0);
414 break;
415 case 3:
417 SetEscortPaused(false);
418 NextStep(0, false, 0);
419 break;
420 case 4:
422 NextStep(3000, true);
423 break;
424 case 5:
426 NextStep(3000, true);
427 break;
428 case 6:
429 SetInFace(true);
431 Summon(1);
432 if (instance)
434 instance->HandleGameObject(0, true, go);
435 NextStep(3000, true);
436 break;
437 case 7:
439 SetEscortPaused(false);
440 NextStep(0, false, 0);
441 break;
442 case 8:
443 me->HandleEmoteCommand(EMOTE_STATE_USE_STANDING);
444 NextStep(25000, true);
445 break;
446 case 9:
447 Summon(2);
448 NextStep(0, false);
449 break;
450 case 10:
451 Summon(4);
453 NextStep(0, false);
454 break;
455 case 11:
457 NextStep(5000, true);
458 break;
459 case 12:
461 NextStep(5000, true);
462 break;
463 case 13:
465 CaveDestruction(true);
466 NextStep(8000, true);
467 break;
468 case 14:
470 NextStep(8500, true);
471 break;
472 case 15:
474 NextStep(2000, true);
475 break;
476 case 16:
478 SetInFace(false);
479 if (instance)
481 instance->HandleGameObject(0, true, go);
482 NextStep(2000, true);
483 break;
484 case 17:
485 SetEscortPaused(false);
487 Summon(5);
488 NextStep(0, false);
489 break;
490 case 18:
491 Summon(6);
492 NextStep(0, false);
493 break;
494 case 19:
495 SetInFace(false);
496 Summon(7);
498 NextStep(0, false);
499 break;
500 case 20:
502 NextStep(2000, true);
503 break;
504 case 21:
505 Summon(8);
506 NextStep(0, false);
507 break;
508 case 22:
509 CaveDestruction(false);
511 NextStep(3000, true);
512 break;
513 case 23:
514 Summon(9);
516 NextStep(0, false);
517 break;
518 }
519 } else uiTimer -= uiDiff;
520 }
521
522 if (!UpdateVictim())
523 return;
524
526 }
527
529 {
530 SummonList.push_back(summon->GetGUID());
531 AggroAllPlayers(summon);
532 }
533 };
534};
535
537{
538public:
539 boss_grubbis() : CreatureScript("boss_grubbis") { }
540
542 {
543 return new boss_grubbisAI(creature);
544 }
545
547 {
548 boss_grubbisAI(Creature* creature) : ScriptedAI(creature)
549 {
551 }
552
554 {
555 if (!me->IsSummon())
556 return;
557
558 if (Unit* summon = me->ToTempSummon()->GetSummoner())
559 if (Creature* creature = summon->ToCreature())
560 creature->AI()->SetData(2, 1);
561 }
562
563 void UpdateAI(uint32 /*diff*/) OVERRIDE
564 {
565 if (!UpdateVictim())
566 return;
567
569 }
570
571 void JustDied(Unit* /*killer*/) OVERRIDE
572 {
573 if (!me->IsSummon())
574 return;
575
576 if (Unit* summoner = me->ToTempSummon()->GetSummoner())
577 if (Creature* creature = summoner->ToCreature())
578 creature->AI()->SetData(2, 2);
579 }
580 };
581};
582
584{
586 new boss_grubbis();
587}
std::uint8_t uint8
Definition Define.h:79
std::uint32_t uint32
Definition Define.h:77
#define OVERRIDE
Definition Define.h:60
@ GOSSIP_ICON_CHAT
Definition GossipDef.h:46
@ IN_PROGRESS
@ DONE
@ NOT_STARTED
@ TEMPSUMMON_CORPSE_TIMED_DESPAWN
Definition Object.h:73
#define CAST_AI(a, b)
@ STATE_ESCORT_ESCORTING
@ GOSSIP_SENDER_MAIN
@ GOSSIP_ACTION_INFO_DEF
@ EMOTE_STATE_USE_STANDING
@ GO_FLAG_NOT_SELECTABLE
@ GAMEOBJECT_FIELD_FLAGS
void Talk(uint8 id, WorldObject const *whisperTarget=NULL)
bool UpdateVictim()
CreatureScript(const char *name)
static GameObject * GetGameObject(WorldObject &object, uint64 guid)
bool isEmpty() const
Definition LinkedList.h:86
MapRefManager PlayerList
Definition Map.h:406
iterator end()
iterator begin()
LinkedListHead::Iterator< MapReference const > const_iterator
Creature * ToCreature()
Definition Object.h:207
void DoMeleeAttackIfReady()
Definition UnitAI.cpp:28
Definition Unit.h:1367
void RestoreFaction()
Definition Unit.cpp:7135
void AddThreat(Unit *victim, float fThreat, SpellSchoolMask schoolMask=SPELL_SCHOOL_MASK_NORMAL, SpellInfo const *threatSpell=NULL)
Definition Unit.cpp:4463
static Creature * GetCreature(WorldObject &object, uint64 guid)
Definition Unit.cpp:4905
void SetInCombatWith(Unit *enemy)
InstanceScript * GetInstanceScript()
Definition Object.cpp:1612
Creature * SummonTrigger(float x, float y, float z, float ang, uint32 dur, CreatureAI *(*GetAI)(Creature *)=NULL)
Definition Object.cpp:2762
virtual uint32 GetData(uint32) const
Definition ZoneScript.h:36
CreatureAI * GetAI(Creature *creature) const OVERRIDE
bool OnGossipSelect(Player *player, Creature *creature, uint32, uint32 action) OVERRIDE
bool OnGossipHello(Player *player, Creature *creature) OVERRIDE
CreatureAI * GetAI(Creature *creature) const OVERRIDE
const Position SpawnPosition[]
void AddSC_gnomeregan()
BlastmasterEmi
@ SAY_BLASTMASTER_4
@ SAY_GRUBBIS
@ SAY_BLASTMASTER_0
@ SAY_BLASTMASTER_6
@ GOSSIP_TEXT_EMI
@ SAY_BLASTMASTER_15
@ SAY_BLASTMASTER_1
@ SAY_BLASTMASTER_10
@ SAY_BLASTMASTER_12
@ SAY_BLASTMASTER_14
@ SAY_BLASTMASTER_5
@ SAY_BLASTMASTER_2
@ SAY_BLASTMASTER_19
@ SAY_BLASTMASTER_7
@ SAY_BLASTMASTER_13
@ SAY_BLASTMASTER_9
@ SAY_BLASTMASTER_8
@ SAY_BLASTMASTER_3
@ SAY_BLASTMASTER_18
@ SAY_BLASTMASTER_16
@ SAY_BLASTMASTER_11
@ SAY_BLASTMASTER_17
#define GOSSIP_START_EVENT
@ DATA_GO_CAVE_IN_LEFT
Definition gnomeregan.h:31
@ DATA_GO_CAVE_IN_RIGHT
Definition gnomeregan.h:32
@ GO_RED_ROCKET
Definition gnomeregan.h:13
@ NPC_CAVERNDEEP_AMBUSHER
Definition gnomeregan.h:19
@ NPC_GRUBBIS
Definition gnomeregan.h:20
@ NPC_CHOMPER
Definition gnomeregan.h:21
@ TYPE_EVENT
Definition gnomeregan.h:26
Creature * me
ScriptedAI(Creature *creature)
void UpdateAI(uint32) OVERRIDE
== Triggered Actions Requested ==================
boss_grubbisAI(Creature *creature)
void JustDied(Unit *) OVERRIDE
void NextStep(uint32 uiTimerStep, bool bNextStep=true, uint8 uiPhaseStep=0)
void SetData(uint32 uiI, uint32 uiValue) OVERRIDE
Player * GetPlayerForEscort()
bool HasEscortState(uint32 escortState) const
npc_escortAI(Creature *creature)
void SetEscortPaused(bool on)