TrinityCore
gnomeregan.cpp
Go to the documentation of this file.
1/*
2 * This file is part of the TrinityCore Project. See AUTHORS file for Copyright information
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by the
6 * Free Software Foundation; either version 2 of the License, or (at your
7 * option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12 * more details.
13 *
14 * You should have received a copy of the GNU General Public License along
15 * with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18/* Script Data Start
19SDName: Gnomeregan
20SDAuthor: Manuel
21SD%Complete: 90%
22SDComment: Some visual effects are not implemented.
23Script Data End */
24
25#include "ScriptMgr.h"
26#include "GameObject.h"
27#include "gnomeregan.h"
28#include "InstanceScript.h"
29#include "Map.h"
30#include "ObjectAccessor.h"
31#include "Player.h"
32#include "ScriptedEscortAI.h"
33#include "ScriptedGossip.h"
34#include "TemporarySummon.h"
35
37{
58
60
62};
63
65{
66 {-557.630f, -114.514f, -152.209f, 0.641f},
67 {-555.263f, -113.802f, -152.737f, 0.311f},
68 {-552.154f, -112.476f, -153.349f, 0.621f},
69 {-548.692f, -111.089f, -154.090f, 0.621f},
70 {-546.905f, -108.340f, -154.877f, 0.729f},
71 {-547.736f, -105.154f, -155.176f, 0.372f},
72 {-547.274f, -114.109f, -153.952f, 0.735f},
73 {-552.534f, -110.012f, -153.577f, 0.747f},
74 {-550.708f, -116.436f, -153.103f, 0.679f},
75 {-554.030f, -115.983f, -152.635f, 0.695f},
76 {-494.595f, -87.516f, -149.116f, 3.344f},
77 {-493.349f, -90.845f, -148.882f, 3.717f},
78 {-491.995f, -87.619f, -148.197f, 3.230f},
79 {-490.732f, -90.739f, -148.091f, 3.230f},
80 {-490.554f, -89.114f, -148.055f, 3.230f},
81 {-495.240f, -90.808f, -149.493f, 3.238f},
82 {-494.195f, -89.553f, -149.131f, 3.254f},
83 {-511.3304f, -139.9622f, -152.4761f, 0.7504908f},
84 {-510.6754f, -139.4371f, -152.6167f, 3.33359f},
85 {-511.8976f, -139.3562f, -152.4785f, 3.961899f}
86};
87
89{
90public:
91 npc_blastmaster_emi_shortfuse() : CreatureScript("npc_blastmaster_emi_shortfuse") { }
92
93 CreatureAI* GetAI(Creature* creature) const override
94 {
95 return GetGnomereganAI<npc_blastmaster_emi_shortfuseAI>(creature);
96 }
97
99 {
101 {
102 instance = creature->GetInstanceScript();
103 creature->RestoreFaction();
104 Initialize();
105 }
106
108 {
109 uiTimer = 0;
110 uiPhase = 0;
111 }
112
114
117
120
121 void Reset() override
122 {
124 {
125 Initialize();
126
127 RestoreAll();
128
130 GoSummonList.clear();
131 }
132 }
133
134 bool OnGossipSelect(Player* player, uint32 /*menuId*/, uint32 gossipListId) override
135 {
136 if (gossipListId == 0)
137 {
139 Start(true, player->GetGUID());
140
141 me->SetFaction(player->GetFaction());
142 SetData(1, 0);
143
144 player->PlayerTalkClass->SendCloseGossip();
145 }
146 return false;
147 }
148
149 void NextStep(uint32 uiTimerStep, bool bNextStep = true, uint8 uiPhaseStep = 0)
150 {
151 uiTimer = uiTimerStep;
152 if (bNextStep)
153 ++uiPhase;
154 else
155 uiPhase = uiPhaseStep;
156 }
157
158 void CaveDestruction(bool isRight)
159 {
160 if (GoSummonList.empty())
161 return;
162
163 for (GuidList::const_iterator itr = GoSummonList.begin(); itr != GoSummonList.end(); ++itr)
164 {
166 {
167 if (Creature* trigger = go->SummonTrigger(go->GetPositionX(), go->GetPositionY(), go->GetPositionZ(), 0, 1ms))
168 {
169 //visual effects are not working!
170 trigger->CastSpell(trigger, 11542, true);
171 trigger->CastSpell(trigger, 35470, true);
172 }
173 go->RemoveFromWorld();
174 //go->CastSpell(me, 12158); makes all die?!
175 }
176 }
177
180 }
181
182 void SetInFace(bool isRight)
183 {
186 }
187
189 {
192
195
196 if (!GoSummonList.empty())
197 for (GuidList::const_iterator itr = GoSummonList.begin(); itr != GoSummonList.end(); ++itr)
198 {
200 go->RemoveFromWorld();
201 }
202
203 if (!SummonList.empty())
204 for (GuidList::const_iterator itr = SummonList.begin(); itr != SummonList.end(); ++itr)
205 {
206 if (Creature* summon = ObjectAccessor::GetCreature(*me, *itr))
207 {
208 summon->DespawnOrUnsummon();
209 }
210 }
211 }
212
214 {
215 Map::PlayerList const& PlList = me->GetMap()->GetPlayers();
216 for (Map::PlayerList::const_iterator i = PlList.begin(); i != PlList.end(); ++i)
217 {
218 if (Player* player = i->GetSource())
219 {
220 if (player->IsGameMaster())
221 continue;
222
223 if (player->IsAlive())
224 AddThreat(player, 0.0f, temp);
225 }
226 }
227 }
228
229 void WaypointReached(uint32 waypointId, uint32 /*pathId*/) override
230 {
231 //just in case
232 if (GetPlayerForEscort())
233 if (me->GetFaction() != GetPlayerForEscort()->GetFaction())
234 me->SetFaction(GetPlayerForEscort()->GetFaction());
235
236 switch (waypointId)
237 {
238 case 3:
239 SetEscortPaused(true);
240 NextStep(2000, false, 3);
241 break;
242 case 7:
243 SetEscortPaused(true);
244 NextStep(2000, false, 4);
245 break;
246 case 9:
247 NextStep(1000, false, 8);
248 break;
249 case 10:
250 NextStep(25000, false, 10);
251 break;
252 case 11:
253 SetEscortPaused(true);
254 SetInFace(true);
255 NextStep(1000, false, 11);
256 break;
257 case 12:
258 NextStep(25000, false, 18);
259 break;
260 case 13:
261 Summon(6);
262 NextStep(25000, false, 19);
263 break;
264 case 14:
265 SetInFace(false);
267 SetEscortPaused(true);
268 NextStep(5000, false, 20);
269 break;
270 }
271 }
272
273 void SetData(uint32 uiI, uint32 uiValue) override
274 {
275 switch (uiI)
276 {
277 case 1:
278 SetEscortPaused(true);
280 NextStep(2000, true);
281 break;
282 case 2:
283 switch (uiValue)
284 {
285 case 1:
287 break;
288 case 2:
290 NextStep(5000, false, 22);
291 break;
292 }
293 break;
294 }
295 }
296
297 void Summon(uint8 uiCase)
298 {
299 switch (uiCase)
300 {
301 case 1:
312 break;
313 case 2:
314 if (GameObject* go = me->SummonGameObject(183410, -533.140f, -105.322f, -156.016f, 0.f, QuaternionData(), 1s))
315 {
316 GoSummonList.push_back(go->GetGUID());
317 go->SetFlag(GO_FLAG_NOT_SELECTABLE); //We can't use it!
318 }
319 Summon(3);
320 break;
321 case 3:
327 break;
328 case 4:
329 if (GameObject* go = me->SummonGameObject(183410, -542.199f, -96.854f, -155.790f, 0.f, QuaternionData(), 1s))
330 {
331 GoSummonList.push_back(go->GetGUID());
332 go->SetFlag(GO_FLAG_NOT_SELECTABLE);
333 }
334 break;
335 case 5:
341 break;
342 case 6:
343 if (GameObject* go = me->SummonGameObject(183410, -507.820f, -103.333f, -151.353f, 0.f, QuaternionData(), 1s))
344 {
345 GoSummonList.push_back(go->GetGUID());
346 go->SetFlag(GO_FLAG_NOT_SELECTABLE); //We can't use it!
347 Summon(5);
348 }
349 break;
350 case 7:
351 if (GameObject* go = me->SummonGameObject(183410, -511.829f, -86.249f, -151.431f, 0.f, QuaternionData(), 1s))
352 {
353 GoSummonList.push_back(go->GetGUID());
354 go->SetFlag(GO_FLAG_NOT_SELECTABLE); //We can't use it!
355 }
356 break;
357 case 8:
359 grubbis->AI()->Talk(SAY_GRUBBIS);
361 break;
362 case 9:
366 break;
367 }
368 }
369
370 void UpdateEscortAI(uint32 uiDiff) override
371 {
372 if (uiPhase)
373 {
374 if (uiTimer <= uiDiff)
375 {
376 switch (uiPhase)
377 {
378 case 1:
380 NextStep(2000, true);
381 break;
382 case 2:
383 SetEscortPaused(false);
384 NextStep(0, false, 0);
385 break;
386 case 3:
388 SetEscortPaused(false);
389 NextStep(0, false, 0);
390 break;
391 case 4:
393 NextStep(3000, true);
394 break;
395 case 5:
397 NextStep(3000, true);
398 break;
399 case 6:
400 SetInFace(true);
402 Summon(1);
405 NextStep(3000, true);
406 break;
407 case 7:
409 SetEscortPaused(false);
410 NextStep(0, false, 0);
411 break;
412 case 8:
414 NextStep(25000, true);
415 break;
416 case 9:
417 Summon(2);
418 NextStep(0, false);
419 break;
420 case 10:
421 Summon(4);
423 NextStep(0, false);
424 break;
425 case 11:
427 NextStep(5000, true);
428 break;
429 case 12:
431 NextStep(5000, true);
432 break;
433 case 13:
435 CaveDestruction(true);
436 NextStep(8000, true);
437 break;
438 case 14:
440 NextStep(8500, true);
441 break;
442 case 15:
444 NextStep(2000, true);
445 break;
446 case 16:
448 SetInFace(false);
451 NextStep(2000, true);
452 break;
453 case 17:
454 SetEscortPaused(false);
456 Summon(5);
457 NextStep(0, false);
458 break;
459 case 18:
460 Summon(6);
461 NextStep(0, false);
462 break;
463 case 19:
464 SetInFace(false);
465 Summon(7);
467 NextStep(0, false);
468 break;
469 case 20:
471 NextStep(2000, true);
472 break;
473 case 21:
474 Summon(8);
475 NextStep(0, false);
476 break;
477 case 22:
478 CaveDestruction(false);
480 NextStep(3000, true);
481 break;
482 case 23:
483 Summon(9);
485 NextStep(0, false);
486 break;
487 }
488 } else uiTimer -= uiDiff;
489 }
490
491 UpdateVictim();
492 }
493
494 void JustSummoned(Creature* summon) override
495 {
496 SummonList.push_back(summon->GetGUID());
497 AggroAllPlayers(summon);
498 }
499 };
500
501};
502
504{
505public:
506 boss_grubbis() : CreatureScript("boss_grubbis") { }
507
508 CreatureAI* GetAI(Creature* creature) const override
509 {
510 return GetGnomereganAI<boss_grubbisAI>(creature);
511 }
512
514 {
515 boss_grubbisAI(Creature* creature) : ScriptedAI(creature)
516 {
518 }
519
521 {
522 if (!me->IsSummon())
523 return;
524
525 if (Unit* summon = me->ToTempSummon()->GetSummonerUnit())
526 if (Creature* creature = summon->ToCreature())
527 creature->AI()->SetData(2, 1);
528 }
529
530 void JustDied(Unit* /*killer*/) override
531 {
532 if (!me->IsSummon())
533 return;
534
535 if (Unit* summoner = me->ToTempSummon()->GetSummonerUnit())
536 if (Creature* creature = summoner->ToCreature())
537 creature->AI()->SetData(2, 2);
538 }
539 };
540
541};
542
544{
546 new boss_grubbis();
547}
uint8_t uint8
Definition: Define.h:144
uint32_t uint32
Definition: Define.h:142
@ IN_PROGRESS
@ DONE
@ TEMPSUMMON_CORPSE_TIMED_DESPAWN
Definition: ObjectDefines.h:68
std::list< ObjectGuid > GuidList
Definition: ObjectGuid.h:394
@ STATE_ESCORT_ESCORTING
@ EMOTE_STATE_USE_STANDING
@ GO_FLAG_NOT_SELECTABLE
void Talk(uint8 id, WorldObject const *whisperTarget=nullptr)
Definition: CreatureAI.cpp:56
bool UpdateVictim()
Definition: CreatureAI.cpp:245
Creature *const me
Definition: CreatureAI.h:61
virtual bool SetBossState(uint32 id, EncounterState state)
void HandleGameObject(ObjectGuid guid, bool open, GameObject *go=nullptr)
virtual ObjectGuid GetGuidData(uint32 type) const override
iterator end()
Definition: MapRefManager.h:35
iterator begin()
Definition: MapRefManager.h:34
PlayerList const & GetPlayers() const
Definition: Map.h:367
static ObjectGuid const Empty
Definition: ObjectGuid.h:274
static Creature * ToCreature(Object *o)
Definition: Object.h:219
static ObjectGuid GetGUID(Object const *o)
Definition: Object.h:159
std::unique_ptr< PlayerMenu > PlayerTalkClass
Definition: Player.h:2380
bool empty() const
iterator begin()
iterator end()
Unit * GetSummonerUnit() const
Definition: Unit.h:627
void RestoreFaction()
Definition: Unit.cpp:11417
void SetFaction(uint32 faction) override
Definition: Unit.h:859
void SetFacingToObject(WorldObject const *object, bool force=true)
Definition: Unit.cpp:12671
TempSummon * ToTempSummon()
Definition: Unit.h:1756
bool IsSummon() const
Definition: Unit.h:738
uint32 GetFaction() const override
Definition: Unit.h:858
void HandleEmoteCommand(Emote emoteId, Player *target=nullptr, Trinity::IteratorPair< int32 const * > spellVisualKitIds={}, int32 sequenceVariation=0)
Definition: Unit.cpp:1598
Map * GetMap() const
Definition: Object.h:624
InstanceScript * GetInstanceScript() const
Definition: Object.cpp:1042
TempSummon * SummonCreature(uint32 entry, Position const &pos, TempSummonType despawnType=TEMPSUMMON_MANUAL_DESPAWN, Milliseconds despawnTime=0s, uint32 vehId=0, uint32 spellId=0, ObjectGuid privateObjectOwner=ObjectGuid::Empty)
Definition: Object.cpp:2025
Creature * SummonTrigger(float x, float y, float z, float ang, Milliseconds despawnTime, CreatureAI *(*GetAI)(Creature *)=nullptr)
Definition: Object.cpp:2106
GameObject * SummonGameObject(uint32 entry, Position const &pos, QuaternionData const &rot, Seconds respawnTime, GOSummonType summonType=GO_SUMMON_TIMED_OR_CORPSE_DESPAWN)
Definition: Object.cpp:2065
CreatureAI * GetAI(Creature *creature) const override
Definition: gnomeregan.cpp:508
CreatureAI * GetAI(Creature *creature) const override
Definition: gnomeregan.cpp:93
const Position SpawnPosition[]
Definition: gnomeregan.cpp:64
void AddSC_gnomeregan()
Definition: gnomeregan.cpp:543
BlastmasterEmi
Definition: gnomeregan.cpp:37
@ SAY_BLASTMASTER_4
Definition: gnomeregan.cpp:42
@ SAY_GRUBBIS
Definition: gnomeregan.cpp:59
@ SAY_BLASTMASTER_0
Definition: gnomeregan.cpp:38
@ SAY_BLASTMASTER_6
Definition: gnomeregan.cpp:44
@ SAY_BLASTMASTER_15
Definition: gnomeregan.cpp:53
@ SAY_BLASTMASTER_1
Definition: gnomeregan.cpp:39
@ SAY_BLASTMASTER_10
Definition: gnomeregan.cpp:48
@ SAY_BLASTMASTER_12
Definition: gnomeregan.cpp:50
@ SAY_BLASTMASTER_14
Definition: gnomeregan.cpp:52
@ SAY_BLASTMASTER_5
Definition: gnomeregan.cpp:43
@ SAY_BLASTMASTER_2
Definition: gnomeregan.cpp:40
@ SAY_BLASTMASTER_19
Definition: gnomeregan.cpp:57
@ SAY_BLASTMASTER_7
Definition: gnomeregan.cpp:45
@ SAY_BLASTMASTER_13
Definition: gnomeregan.cpp:51
@ PATH_ESCORT_BLASTMASTER_EMI
Definition: gnomeregan.cpp:61
@ SAY_BLASTMASTER_9
Definition: gnomeregan.cpp:47
@ SAY_BLASTMASTER_8
Definition: gnomeregan.cpp:46
@ SAY_BLASTMASTER_3
Definition: gnomeregan.cpp:41
@ SAY_BLASTMASTER_18
Definition: gnomeregan.cpp:56
@ SAY_BLASTMASTER_16
Definition: gnomeregan.cpp:54
@ SAY_BLASTMASTER_11
Definition: gnomeregan.cpp:49
@ SAY_BLASTMASTER_17
Definition: gnomeregan.cpp:55
@ NPC_CAVERNDEEP_AMBUSHER
Definition: gnomeregan.h:36
@ NPC_GRUBBIS
Definition: gnomeregan.h:37
@ NPC_CHOMPER
Definition: gnomeregan.h:39
@ GO_RED_ROCKET
Definition: gnomeregan.h:30
@ DATA_GO_CAVE_IN_LEFT
Definition: gnomeregan.h:58
@ DATA_GO_CAVE_IN_RIGHT
Definition: gnomeregan.h:59
@ DATA_BLASTMASTER_EVENT
Definition: gnomeregan.h:47
TC_GAME_API GameObject * GetGameObject(WorldObject const &u, ObjectGuid const &guid)
TC_GAME_API Creature * GetCreature(WorldObject const &u, ObjectGuid const &guid)
void Start(bool isActiveAttacker=true, ObjectGuid playerGUID=ObjectGuid::Empty, Quest const *quest=nullptr, bool instantRespawn=false, bool canLoopPath=false)
bool HasEscortState(uint32 escortState)
void LoadPath(uint32 pathId)
Player * GetPlayerForEscort()
void SetEscortPaused(bool on)
static QuaternionData fromEulerAnglesZYX(float Z, float Y, float X)
Definition: GameObject.cpp:118
void AddThreat(Unit *victim, float amount, Unit *who=nullptr)
void JustDied(Unit *) override
Definition: gnomeregan.cpp:530
boss_grubbisAI(Creature *creature)
Definition: gnomeregan.cpp:515
void SetData(uint32 uiI, uint32 uiValue) override
Definition: gnomeregan.cpp:273
void NextStep(uint32 uiTimerStep, bool bNextStep=true, uint8 uiPhaseStep=0)
Definition: gnomeregan.cpp:149
void WaypointReached(uint32 waypointId, uint32) override
Definition: gnomeregan.cpp:229
bool OnGossipSelect(Player *player, uint32, uint32 gossipListId) override
Definition: gnomeregan.cpp:134