TrinityCore
zone_the_barrens.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/* ScriptData
19SDName: The_Barrens
20SD%Complete: 90
21SDComment: Quest support: 863
22SDCategory: Barrens
23EndScriptData */
24
25/* ContentData
26npc_wizzlecrank_shredder
27EndContentData */
28
29#include "ScriptMgr.h"
30#include "MotionMaster.h"
31#include "ObjectAccessor.h"
32#include "Player.h"
33#include "ScriptedEscortAI.h"
34#include "SpellInfo.h"
35#include "TemporarySummon.h"
36
37/*######
38## npc_taskmaster_fizzule
39######*/
40
42{
43 SPELL_FLARE = 10113,
44 SPELL_FOLLY = 10137,
45};
46
48{
49public:
50 npc_taskmaster_fizzule() : CreatureScript("npc_taskmaster_fizzule") { }
51
52 CreatureAI* GetAI(Creature* creature) const override
53 {
54 return new npc_taskmaster_fizzuleAI(creature);
55 }
56
58 {
60 {
61 Initialize();
62 factionNorm = creature->GetFaction();
63 }
64
66 {
67 IsFriend = false;
68 ResetTimer = 120000;
69 FlareCount = 0;
70 }
71
76
77 void Reset() override
78 {
79 Initialize();
81 }
82
83 void DoFriend()
84 {
86 me->CombatStop(true);
87 me->StopMoving();
88
90
94 }
95
96 void SpellHit(WorldObject* /*caster*/, SpellInfo const* spellInfo) override
97 {
98 if (spellInfo->Id == SPELL_FLARE || spellInfo->Id == SPELL_FOLLY)
99 {
100 ++FlareCount;
101
102 if (FlareCount >= 2)
103 IsFriend = true;
104 }
105 }
106
107 void JustEngagedWith(Unit* /*who*/) override { }
108
109 void UpdateAI(uint32 diff) override
110 {
111 if (IsFriend)
112 {
113 if (ResetTimer <= diff)
114 {
116 return;
117 } else ResetTimer -= diff;
118 }
119
120 if (!UpdateVictim())
121 return;
122 }
123
124 void ReceiveEmote(Player* /*player*/, uint32 emote) override
125 {
126 if (emote == TEXT_EMOTE_SALUTE)
127 {
128 if (FlareCount >= 2)
129 {
131 return;
132
133 DoFriend();
134 }
135 }
136 }
137 };
138
139};
140
141/*#####
142## npc_twiggy_flathead
143#####*/
144
146{
149
156
158{
159 {-1683.0f, -4326.0f, 2.79f, 0.0f},
160 {-1682.0f, -4329.0f, 2.79f, 0.0f},
161 {-1683.0f, -4330.0f, 2.79f, 0.0f},
162 {-1680.0f, -4334.0f, 2.79f, 1.49f},
163 {-1674.0f, -4326.0f, 2.79f, 3.49f},
164 {-1677.0f, -4334.0f, 2.79f, 1.66f}
165};
166
168{
169public:
170 npc_twiggy_flathead() : CreatureScript("npc_twiggy_flathead") { }
171
172 CreatureAI* GetAI(Creature* creature) const override
173 {
174 return new npc_twiggy_flatheadAI(creature);
175 }
176
178 {
180 {
181 Initialize();
182 }
183
185 {
186 EventInProgress = false;
187 EventGrate = false;
188 EventBigWill = false;
189 WaveTimer = 600000;
191 Wave = 0;
193
194 for (uint8 i = 0; i < 6; ++i)
195 {
197 ChallengerDown[i] = false;
198 }
199 BigWill.Clear();
200 }
201
212
213 void Reset() override
214 {
215 Initialize();
216 }
217
218 void MoveInLineOfSight(Unit* who) override
219 {
220 if (!who || !who->IsAlive() || EventInProgress)
221 return;
222
223 if (who->GetTypeId() == TYPEID_PLAYER && me->IsWithinDistInMap(who, 10.0f))
224 if (Player* player = who->ToPlayer())
225 if (player->GetQuestStatus(1719) == QUEST_STATUS_INCOMPLETE)
226 {
227 PlayerGUID = who->GetGUID();
228 EventInProgress = true;
229 }
230 }
231
232 void UpdateAI(uint32 diff) override
233 {
234 if (EventInProgress)
235 {
236 Player* warrior = nullptr;
237
238 if (!PlayerGUID.IsEmpty())
240
241 if (!warrior)
242 return;
243
244 if (!warrior->IsAlive() && warrior->GetQuestStatus(1719) == QUEST_STATUS_INCOMPLETE)
245 {
247 warrior->FailQuest(1719);
248
249 for (uint8 i = 0; i < 6; ++i) // unsummon challengers
250 {
251 if (!AffrayChallenger[i].IsEmpty())
252 {
254 if (creature && creature->IsAlive())
255 creature->DisappearAndDie();
256 }
257 }
258
259 if (!BigWill.IsEmpty()) // unsummon bigWill
260 {
262 if (creature && creature->IsAlive())
263 creature->DisappearAndDie();
264 }
265 Reset();
266 }
267
269 {
270 float x, y, z;
271 warrior->GetPosition(x, y, z);
272
273 if (x >= -1684 && x <= -1674 && y >= -4334 && y <= -4324)
274 {
275 warrior->AreaExploredOrEventHappens(1719);
277
278 for (uint8 i = 0; i < 6; ++i)
279 {
281 if (!creature)
282 continue;
283 creature->SetFaction(35);
284 creature->SetUninteractible(true);
287 AffrayChallenger[i] = creature->GetGUID();
288 }
289 WaveTimer = 5000;
290 ChallengerChecker = 1000;
291 EventGrate = true;
292 }
293 }
294 else if (EventInProgress)
295 {
296 if (ChallengerChecker <= diff)
297 {
298 for (uint8 i = 0; i < 6; ++i)
299 {
300 if (!AffrayChallenger[i].IsEmpty())
301 {
303 if ((!creature || (!creature->IsAlive())) && !ChallengerDown[i])
304 {
306 ChallengerDown[i] = true;
307 }
308 }
309 }
310 ChallengerChecker = 1000;
311 } else ChallengerChecker -= diff;
312
313 if (WaveTimer <= diff)
314 {
315 if (Wave < 6 && !AffrayChallenger[Wave].IsEmpty() && !EventBigWill)
316 {
319 if (creature && (creature->IsAlive()))
320 {
321 creature->SetUninteractible(false);
324 creature->SetFaction(14);
325 creature->AI()->AttackStart(warrior);
326 ++Wave;
327 WaveTimer = 20000;
328 }
329 }
330 else if (Wave >= 6 && !EventBigWill)
331 {
332 if (Creature* creature = me->SummonCreature(NPC_BIG_WILL, -1722, -4341, 6.12f, 6.26f, TEMPSUMMON_TIMED_OR_DEAD_DESPAWN, 8min))
333 {
334 BigWill = creature->GetGUID();
335 //creature->GetMotionMaster()->MovePoint(0, -1693, -4343, 4.32f);
336 //creature->GetMotionMaster()->MovePoint(1, -1684, -4333, 2.78f);
337 creature->GetMotionMaster()->MovePoint(2, -1682, -4329, 2.79f);
338 creature->HandleEmoteCommand(EMOTE_STATE_READY_UNARMED);
339 EventBigWill = true;
340 WaveTimer = 1000;
341 }
342 }
343 else if (Wave >= 6 && EventBigWill && !BigWill.IsEmpty())
344 {
346 if (!creature || !creature->IsAlive())
347 {
349 Reset();
350 }
351 else // Makes BIG WILL attackable.
352 {
353 creature->SetUninteractible(false);
356 creature->SetFaction(14);
357 creature->AI()->AttackStart(warrior);
358 }
359 }
360 } else WaveTimer -= diff;
361 }
362 }
363 }
364 };
365
366};
367
368/*#####
369## npc_wizzlecrank_shredder
370#####*/
371
373{
382
386
388};
389
391{
392public:
393 npc_wizzlecrank_shredder() : CreatureScript("npc_wizzlecrank_shredder") { }
394
396 {
398 {
399 IsPostEvent = false;
400 PostEventTimer = 1000;
401 PostEventCount = 0;
403 }
404
408
409 void WaypointReached(uint32 waypointId, uint32 /*pathId*/) override
410 {
411 switch (waypointId)
412 {
413 case 0:
415 break;
416 case 17:
417 if (Creature* temp = me->SummonCreature(NPC_MERCENARY, 1128.489f, -3037.611f, 92.701f, 1.472f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 2min))
418 {
419 temp->AI()->Talk(SAY_MERCENARY);
420 me->SummonCreature(NPC_MERCENARY, 1160.172f, -2980.168f, 97.313f, 3.690f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 2min);
421 }
422 break;
423 case 24:
424 IsPostEvent = true;
425 break;
426 }
427 }
428
429 void WaypointStarted(uint32 PointId, uint32 /*pathId*/) override
430 {
431 Player* player = GetPlayerForEscort();
432
433 if (!player)
434 return;
435
436 switch (PointId)
437 {
438 case 9:
439 Talk(SAY_STARTUP2, player);
440 break;
441 case 18:
442 Talk(SAY_PROGRESS_1, player);
443 break;
444 }
445 }
446
447 void JustSummoned(Creature* summoned) override
448 {
449 if (summoned->GetEntry() == NPC_PILOT_WIZZ)
451
452 if (summoned->GetEntry() == NPC_MERCENARY)
453 summoned->AI()->AttackStart(me);
454 }
455
456 void UpdateEscortAI(uint32 Diff) override
457 {
458 if (UpdateVictim())
459 return;
460
461 if (!IsPostEvent)
462 return;
463
464 if (PostEventTimer > Diff)
465 {
466 PostEventTimer -= Diff;
467 return;
468 }
469
470 switch (PostEventCount)
471 {
472 case 0:
474 break;
475 case 1:
477 break;
478 case 2:
479 Talk(SAY_END);
480 break;
481 case 3:
482 if (Player* player = GetPlayerForEscort())
483 {
484 player->GroupEventHappens(QUEST_ESCAPE, me);
485 me->DespawnOrUnsummon(5min);
486 me->SummonCreature(NPC_PILOT_WIZZ, 0.0f, 0.0f, 0.0f, 0.0f, TEMPSUMMON_TIMED_DESPAWN, 3min);
487 }
488 break;
489 }
490
492 PostEventTimer = 5000;
493 }
494
495 void OnQuestAccept(Player* player, Quest const* quest) override
496 {
497 if (quest->GetQuestId() == QUEST_ESCAPE)
498 {
501 SetDespawnAtEnd(false);
503 Start(true, player->GetGUID());
504 }
505 }
506 };
507
508 CreatureAI* GetAI(Creature* creature) const override
509 {
510 return new npc_wizzlecrank_shredderAI(creature);
511 }
512
513};
514
516{
518}
uint8_t uint8
Definition: Define.h:144
uint32_t uint32
Definition: Define.h:142
@ TEMPSUMMON_TIMED_DESPAWN
Definition: ObjectDefines.h:65
@ TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT
Definition: ObjectDefines.h:66
@ TEMPSUMMON_TIMED_OR_DEAD_DESPAWN
Definition: ObjectDefines.h:63
@ TYPEID_PLAYER
Definition: ObjectGuid.h:41
@ QUEST_STATUS_INCOMPLETE
Definition: QuestDef.h:145
@ EMOTE_STATE_READY_UNARMED
@ EMOTE_ONESHOT_ROAR
@ EMOTE_ONESHOT_SALUTE
@ TEXT_EMOTE_SALUTE
@ FACTION_RATCHET
@ FACTION_FRIENDLY
@ REACT_DEFENSIVE
Definition: UnitDefines.h:507
@ UNIT_STAND_STATE_DEAD
Definition: UnitDefines.h:49
@ UNIT_FLAG_NON_ATTACKABLE
Definition: UnitDefines.h:145
virtual void EnterEvadeMode(EvadeReason why=EvadeReason::Other)
Definition: CreatureAI.cpp:219
void Talk(uint8 id, WorldObject const *whisperTarget=nullptr)
Definition: CreatureAI.cpp:56
bool UpdateVictim()
Definition: CreatureAI.cpp:245
void AttackStart(Unit *victim) override
== Triggered Actions Requested ==================
Definition: CreatureAI.cpp:328
Creature *const me
Definition: CreatureAI.h:61
void EngagementOver()
Definition: CreatureAI.cpp:287
void SetReactState(ReactStates st)
Definition: Creature.h:160
void DespawnOrUnsummon(Milliseconds timeToDespawn=0s, Seconds forceRespawnTime=0s)
Definition: Creature.cpp:2415
CreatureAI * AI() const
Definition: Creature.h:214
void DisappearAndDie()
Definition: Creature.h:83
bool IsEmpty() const
Definition: ObjectGuid.h:319
void Clear()
Definition: ObjectGuid.h:286
TypeID GetTypeId() const
Definition: Object.h:173
uint32 GetEntry() const
Definition: Object.h:161
static ObjectGuid GetGUID(Object const *o)
Definition: Object.h:159
static Player * ToPlayer(Object *o)
Definition: Object.h:213
void AreaExploredOrEventHappens(uint32 questId)
Definition: Player.cpp:16577
QuestStatus GetQuestStatus(uint32 quest_id) const
Definition: Player.cpp:16050
void FailQuest(uint32 quest_id)
Definition: Player.cpp:15446
uint32 GetQuestId() const
Definition: QuestDef.h:587
uint32 const Id
Definition: SpellInfo.h:325
Definition: Unit.h:627
void CombatStop(bool includingCast=false, bool mutualPvP=true, bool(*unitFilter)(Unit const *otherUnit)=nullptr)
Definition: Unit.cpp:5827
void SetStandState(UnitStandStateType state, uint32 animKitID=0)
Definition: Unit.cpp:10100
void SetFaction(uint32 faction) override
Definition: Unit.h:859
MotionMaster * GetMotionMaster()
Definition: Unit.h:1652
bool IsAlive() const
Definition: Unit.h:1164
void StopMoving()
Definition: Unit.cpp:10049
void SetUninteractible(bool apply)
Definition: Unit.cpp:8147
uint32 GetFaction() const override
Definition: Unit.h:858
void RemoveAllAuras()
Definition: Unit.cpp:4242
void HandleEmoteCommand(Emote emoteId, Player *target=nullptr, Trinity::IteratorPair< int32 const * > spellVisualKitIds={}, int32 sequenceVariation=0)
Definition: Unit.cpp:1598
void SetUnitFlag(UnitFlags flags)
Definition: Unit.h:833
void RemoveUnitFlag(UnitFlags flags)
Definition: Unit.h:834
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
bool IsWithinDistInMap(WorldObject const *obj, float dist2compare, bool is3D=true, bool incOwnRadius=true, bool incTargetRadius=true) const
Definition: Object.cpp:1147
CreatureAI * GetAI(Creature *creature) const override
CreatureAI * GetAI(Creature *creature) const override
CreatureAI * GetAI(Creature *creature) const override
TC_GAME_API Player * GetPlayer(Map const *, 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)
void SetDespawnAtEnd(bool despawn)
void LoadPath(uint32 pathId)
Player * GetPlayerForEscort()
constexpr void GetPosition(float &x, float &y) const
Definition: Position.h:81
Definition: hyjalAI.h:47
void ReceiveEmote(Player *, uint32 emote) override
void SpellHit(WorldObject *, SpellInfo const *spellInfo) override
void WaypointStarted(uint32 PointId, uint32) override
== Waypoints system =============================
void OnQuestAccept(Player *player, Quest const *quest) override
void WaypointReached(uint32 waypointId, uint32) override
Position const AffrayChallengerLoc[6]
TaskmasterFizzule
@ SPELL_FOLLY
@ SPELL_FLARE
void AddSC_the_barrens()
TwiggyFlathead
@ SAY_TWIGGY_FLATHEAD_DOWN
@ SAY_TWIGGY_FLATHEAD_FRAY
@ SAY_TWIGGY_FLATHEAD_BEGIN
@ NPC_BIG_WILL
@ SAY_BIG_WILL_READY
@ NPC_AFFRAY_CHALLENGER
@ SAY_TWIGGY_FLATHEAD_OVER
@ SAY_STARTUP2
@ SAY_PROGRESS_3
@ SAY_START
@ SAY_STARTUP1
@ NPC_MERCENARY
@ SAY_END
@ SAY_PROGRESS_2
@ NPC_PILOT_WIZZ
@ QUEST_ESCAPE
@ SAY_PROGRESS_1
@ PATH_ESCORT_WIZZLECRANK
@ SAY_MERCENARY