TrinityCore
Loading...
Searching...
No Matches
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 "SpellScript.h"
35#include "TemporarySummon.h"
36
64
66{
67 {-557.630f, -114.514f, -152.209f, 0.641f},
68 {-555.263f, -113.802f, -152.737f, 0.311f},
69 {-552.154f, -112.476f, -153.349f, 0.621f},
70 {-548.692f, -111.089f, -154.090f, 0.621f},
71 {-546.905f, -108.340f, -154.877f, 0.729f},
72 {-547.736f, -105.154f, -155.176f, 0.372f},
73 {-547.274f, -114.109f, -153.952f, 0.735f},
74 {-552.534f, -110.012f, -153.577f, 0.747f},
75 {-550.708f, -116.436f, -153.103f, 0.679f},
76 {-554.030f, -115.983f, -152.635f, 0.695f},
77 {-494.595f, -87.516f, -149.116f, 3.344f},
78 {-493.349f, -90.845f, -148.882f, 3.717f},
79 {-491.995f, -87.619f, -148.197f, 3.230f},
80 {-490.732f, -90.739f, -148.091f, 3.230f},
81 {-490.554f, -89.114f, -148.055f, 3.230f},
82 {-495.240f, -90.808f, -149.493f, 3.238f},
83 {-494.195f, -89.553f, -149.131f, 3.254f},
84 {-511.3304f, -139.9622f, -152.4761f, 0.7504908f},
85 {-510.6754f, -139.4371f, -152.6167f, 3.33359f},
86 {-511.8976f, -139.3562f, -152.4785f, 3.961899f}
87};
88
90{
91public:
92 npc_blastmaster_emi_shortfuse() : CreatureScript("npc_blastmaster_emi_shortfuse") { }
93
94 CreatureAI* GetAI(Creature* creature) const override
95 {
96 return GetGnomereganAI<npc_blastmaster_emi_shortfuseAI>(creature);
97 }
98
100 {
102 {
103 instance = creature->GetInstanceScript();
104 creature->RestoreFaction();
105 Initialize();
106 }
107
109 {
110 uiTimer = 0;
111 uiPhase = 0;
112 }
113
115
118
121
122 void Reset() override
123 {
125 {
126 Initialize();
127
128 RestoreAll();
129
131 GoSummonList.clear();
132 }
133 }
134
135 bool OnGossipSelect(Player* player, uint32 /*menuId*/, uint32 gossipListId) override
136 {
137 if (gossipListId == 0)
138 {
140 Start(true, player->GetGUID());
141
142 me->SetFaction(player->GetFaction());
143 SetData(1, 0);
144
146 }
147 return false;
148 }
149
150 void NextStep(uint32 uiTimerStep, bool bNextStep = true, uint8 uiPhaseStep = 0)
151 {
152 uiTimer = uiTimerStep;
153 if (bNextStep)
154 ++uiPhase;
155 else
156 uiPhase = uiPhaseStep;
157 }
158
159 void CaveDestruction(bool isRight)
160 {
161 if (GoSummonList.empty())
162 return;
163
164 for (GuidList::const_iterator itr = GoSummonList.begin(); itr != GoSummonList.end(); ++itr)
165 {
167 {
168 if (Creature* trigger = go->SummonTrigger(go->GetPositionX(), go->GetPositionY(), go->GetPositionZ(), 0, 1ms))
169 {
170 //visual effects are not working!
171 trigger->CastSpell(trigger, 11542, true);
172 trigger->CastSpell(trigger, 35470, true);
173 }
174 go->RemoveFromWorld();
175 //go->CastSpell(me, 12158); makes all die?!
176 }
177 }
178
181 }
182
188
190 {
193
196
197 if (!GoSummonList.empty())
198 for (GuidList::const_iterator itr = GoSummonList.begin(); itr != GoSummonList.end(); ++itr)
199 {
201 go->RemoveFromWorld();
202 }
203
204 if (!SummonList.empty())
205 for (GuidList::const_iterator itr = SummonList.begin(); itr != SummonList.end(); ++itr)
206 {
207 if (Creature* summon = ObjectAccessor::GetCreature(*me, *itr))
208 {
209 summon->DespawnOrUnsummon();
210 }
211 }
212 }
213
215 {
216 Map::PlayerList const& PlList = me->GetMap()->GetPlayers();
217 for (Map::PlayerList::const_iterator i = PlList.begin(); i != PlList.end(); ++i)
218 {
219 if (Player* player = i->GetSource())
220 {
221 if (player->IsGameMaster())
222 continue;
223
224 if (player->IsAlive())
225 AddThreat(player, 0.0f, temp);
226 }
227 }
228 }
229
230 void WaypointReached(uint32 waypointId, uint32 /*pathId*/) override
231 {
232 //just in case
233 if (GetPlayerForEscort())
234 if (me->GetFaction() != GetPlayerForEscort()->GetFaction())
235 me->SetFaction(GetPlayerForEscort()->GetFaction());
236
237 switch (waypointId)
238 {
239 case 3:
240 SetEscortPaused(true);
241 NextStep(2000, false, 3);
242 break;
243 case 7:
244 SetEscortPaused(true);
245 NextStep(2000, false, 4);
246 break;
247 case 9:
248 NextStep(1000, false, 8);
249 break;
250 case 10:
251 NextStep(25000, false, 10);
252 break;
253 case 11:
254 SetEscortPaused(true);
255 SetInFace(true);
256 NextStep(1000, false, 11);
257 break;
258 case 12:
259 NextStep(25000, false, 18);
260 break;
261 case 13:
262 Summon(6);
263 NextStep(25000, false, 19);
264 break;
265 case 14:
266 SetInFace(false);
268 SetEscortPaused(true);
269 NextStep(5000, false, 20);
270 break;
271 }
272 }
273
274 void SetData(uint32 uiI, uint32 uiValue) override
275 {
276 switch (uiI)
277 {
278 case 1:
279 SetEscortPaused(true);
281 NextStep(2000, true);
282 break;
283 case 2:
284 switch (uiValue)
285 {
286 case 1:
288 break;
289 case 2:
291 NextStep(5000, false, 22);
292 break;
293 }
294 break;
295 }
296 }
297
298 void Summon(uint8 uiCase)
299 {
300 switch (uiCase)
301 {
302 case 1:
313 break;
314 case 2:
315 if (GameObject* go = me->SummonGameObject(183410, -533.140f, -105.322f, -156.016f, 0.f, QuaternionData(), 1s))
316 {
317 GoSummonList.push_back(go->GetGUID());
318 go->SetFlag(GO_FLAG_NOT_SELECTABLE); //We can't use it!
319 }
320 Summon(3);
321 break;
322 case 3:
328 break;
329 case 4:
330 if (GameObject* go = me->SummonGameObject(183410, -542.199f, -96.854f, -155.790f, 0.f, QuaternionData(), 1s))
331 {
332 GoSummonList.push_back(go->GetGUID());
333 go->SetFlag(GO_FLAG_NOT_SELECTABLE);
334 }
335 break;
336 case 5:
342 break;
343 case 6:
344 if (GameObject* go = me->SummonGameObject(183410, -507.820f, -103.333f, -151.353f, 0.f, QuaternionData(), 1s))
345 {
346 GoSummonList.push_back(go->GetGUID());
347 go->SetFlag(GO_FLAG_NOT_SELECTABLE); //We can't use it!
348 Summon(5);
349 }
350 break;
351 case 7:
352 if (GameObject* go = me->SummonGameObject(183410, -511.829f, -86.249f, -151.431f, 0.f, QuaternionData(), 1s))
353 {
354 GoSummonList.push_back(go->GetGUID());
355 go->SetFlag(GO_FLAG_NOT_SELECTABLE); //We can't use it!
356 }
357 break;
358 case 8:
360 grubbis->AI()->Talk(SAY_GRUBBIS);
362 break;
363 case 9:
367 break;
368 }
369 }
370
371 void UpdateEscortAI(uint32 uiDiff) override
372 {
373 if (uiPhase)
374 {
375 if (uiTimer <= uiDiff)
376 {
377 switch (uiPhase)
378 {
379 case 1:
381 NextStep(2000, true);
382 break;
383 case 2:
384 SetEscortPaused(false);
385 NextStep(0, false, 0);
386 break;
387 case 3:
389 SetEscortPaused(false);
390 NextStep(0, false, 0);
391 break;
392 case 4:
394 NextStep(3000, true);
395 break;
396 case 5:
398 NextStep(3000, true);
399 break;
400 case 6:
401 SetInFace(true);
403 Summon(1);
406 NextStep(3000, true);
407 break;
408 case 7:
410 SetEscortPaused(false);
411 NextStep(0, false, 0);
412 break;
413 case 8:
415 NextStep(25000, true);
416 break;
417 case 9:
418 Summon(2);
419 NextStep(0, false);
420 break;
421 case 10:
422 Summon(4);
424 NextStep(0, false);
425 break;
426 case 11:
428 NextStep(5000, true);
429 break;
430 case 12:
432 NextStep(5000, true);
433 break;
434 case 13:
436 CaveDestruction(true);
437 NextStep(8000, true);
438 break;
439 case 14:
441 NextStep(8500, true);
442 break;
443 case 15:
445 NextStep(2000, true);
446 break;
447 case 16:
449 SetInFace(false);
452 NextStep(2000, true);
453 break;
454 case 17:
455 SetEscortPaused(false);
457 Summon(5);
458 NextStep(0, false);
459 break;
460 case 18:
461 Summon(6);
462 NextStep(0, false);
463 break;
464 case 19:
465 SetInFace(false);
466 Summon(7);
468 NextStep(0, false);
469 break;
470 case 20:
472 NextStep(2000, true);
473 break;
474 case 21:
475 Summon(8);
476 NextStep(0, false);
477 break;
478 case 22:
479 CaveDestruction(false);
481 NextStep(3000, true);
482 break;
483 case 23:
484 Summon(9);
486 NextStep(0, false);
487 break;
488 }
489 } else uiTimer -= uiDiff;
490 }
491
492 if (!UpdateVictim())
493 return;
494
496 }
497
498 void JustSummoned(Creature* summon) override
499 {
500 SummonList.push_back(summon->GetGUID());
501 AggroAllPlayers(summon);
502 }
503 };
504
505};
506
508{
509public:
510 boss_grubbis() : CreatureScript("boss_grubbis") { }
511
512 CreatureAI* GetAI(Creature* creature) const override
513 {
514 return GetGnomereganAI<boss_grubbisAI>(creature);
515 }
516
518 {
519 boss_grubbisAI(Creature* creature) : ScriptedAI(creature)
520 {
522 }
523
525 {
526 if (!me->IsSummon())
527 return;
528
529 if (Unit* summon = me->ToTempSummon()->GetSummonerUnit())
530 if (Creature* creature = summon->ToCreature())
531 creature->AI()->SetData(2, 1);
532 }
533
534 void UpdateAI(uint32 /*diff*/) override
535 {
536 if (!UpdateVictim())
537 return;
538
540 }
541
542 void JustDied(Unit* /*killer*/) override
543 {
544 if (!me->IsSummon())
545 return;
546
547 if (Unit* summoner = me->ToTempSummon()->GetSummonerUnit())
548 if (Creature* creature = summoner->ToCreature())
549 creature->AI()->SetData(2, 2);
550 }
551 };
552
553};
554
555// 12709 - Collecting Fallout
557{
558 public:
559 spell_collecting_fallout() : SpellScriptLoader("spell_collecting_fallout") { }
560
588
589 SpellScript* GetSpellScript() const override
590 {
592 }
593};
594
596{
598 new boss_grubbis();
599
601}
uint8_t uint8
Definition Define.h:135
uint32_t uint32
Definition Define.h:133
@ IN_PROGRESS
@ DONE
@ TEMPSUMMON_CORPSE_TIMED_DESPAWN
std::list< ObjectGuid > GuidList
Definition ObjectGuid.h:261
bool roll_chance_i(int chance)
Definition Random.h:59
@ STATE_ESCORT_ESCORTING
SpellEffIndex
@ EFFECT_1
@ EFFECT_0
@ SPELL_EFFECT_TRIGGER_SPELL
@ EMOTE_STATE_USE_STANDING
@ GO_FLAG_NOT_SELECTABLE
#define SpellEffectFn(F, I, N)
bool UpdateVictim()
Creature *const me
Definition CreatureAI.h:82
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()
iterator begin()
PlayerList const & GetPlayers() const
Definition Map.h:448
static ObjectGuid const Empty
Definition ObjectGuid.h:140
static Creature * ToCreature(Object *o)
Definition Object.h:186
void SetFlag(uint16 index, uint32 newFlag)
Definition Object.cpp:760
static ObjectGuid GetGUID(Object const *o)
Definition Object.h:78
void SendCloseGossip()
PlayerMenu * PlayerTalkClass
Definition Player.h:1969
void PreventHitDefaultEffect(SpellEffIndex effIndex)
HookList< EffectHandler > OnEffectLaunch
bool empty() const
iterator begin()
iterator end()
Unit * GetSummonerUnit() const
void DoMeleeAttackIfReady()
Definition UnitAI.cpp:54
Definition Unit.h:769
void RestoreFaction()
Definition Unit.cpp:11776
void SetFaction(uint32 faction) override
Definition Unit.h:974
TempSummon * ToTempSummon()
Definition Unit.h:1794
void SetFacingToObject(WorldObject const *object, bool force=true, uint32 movementId=EVENT_FACE)
Definition Unit.cpp:13259
bool IsSummon() const
Definition Unit.h:882
uint32 GetFaction() const override
Definition Unit.h:973
void HandleEmoteCommand(Emote emoteId)
Definition Unit.cpp:1568
Map * GetMap() const
Definition Object.h:449
InstanceScript * GetInstanceScript() const
Definition Object.cpp:1087
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:1992
Creature * SummonTrigger(float x, float y, float z, float ang, Milliseconds despawnTime, CreatureAI *(*GetAI)(Creature *)=nullptr)
Definition Object.cpp:2057
GameObject * SummonGameObject(uint32 entry, Position const &pos, QuaternionData const &rot, Seconds respawnTime, GOSummonType summonType=GO_SUMMON_TIMED_OR_CORPSE_DESPAWN)
Definition Object.cpp:2015
CreatureAI * GetAI(Creature *creature) const override
CreatureAI * GetAI(Creature *creature) const override
PrepareSpellScript(spell_collecting_fallout_SpellScript)
SpellScript * GetSpellScript() const override
const Position SpawnPosition[]
void AddSC_gnomeregan()
BlastmasterEmi
@ SAY_BLASTMASTER_4
@ SAY_GRUBBIS
@ SAY_BLASTMASTER_0
@ SAY_BLASTMASTER_6
@ 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
@ PATH_ESCORT_BLASTMASTER_EMI
@ SAY_BLASTMASTER_9
@ SAY_BLASTMASTER_8
@ SAY_BLASTMASTER_3
@ SAY_BLASTMASTER_18
@ SAY_BLASTMASTER_16
@ SAY_BLASTMASTER_11
@ SAY_BLASTMASTER_17
@ 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)
void AddThreat(Unit *victim, float amount, Unit *who=nullptr)
void JustDied(Unit *) override
void UpdateAI(uint32) override
boss_grubbisAI(Creature *creature)
void SetData(uint32 uiI, uint32 uiValue) override
void NextStep(uint32 uiTimerStep, bool bNextStep=true, uint8 uiPhaseStep=0)
void WaypointReached(uint32 waypointId, uint32) override
bool OnGossipSelect(Player *player, uint32, uint32 gossipListId) override