TrinityCore
Loading...
Searching...
No Matches
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, 898, 1719, 2458, 4921, 6981,
22SDCategory: Barrens
23EndScriptData */
24
25/* ContentData
26npc_beaten_corpse
27npc_gilthares
28npc_sputtervalve
29npc_taskmaster_fizzule
30npc_twiggy_flathead
31npc_wizzlecrank_shredder
32EndContentData */
33
34#include "ScriptMgr.h"
35#include "MotionMaster.h"
36#include "ObjectAccessor.h"
37#include "Player.h"
38#include "ScriptedEscortAI.h"
39#include "ScriptedGossip.h"
40#include "SpellInfo.h"
41#include "TemporarySummon.h"
42
43/*######
44# npc_gilthares
45######*/
46
61
62static constexpr uint32 PATH_ESCORT_GILTHARES = 27722;
63
65{
66public:
67 npc_gilthares() : CreatureScript("npc_gilthares") { }
68
69 struct npc_giltharesAI : public EscortAI
70 {
71 npc_giltharesAI(Creature* creature) : EscortAI(creature) { }
72
73 void Reset() override { }
74
75 void WaypointReached(uint32 waypointId, uint32 /*pathId*/) override
76 {
77 Player* player = GetPlayerForEscort();
78 if (!player)
79 return;
80
81 switch (waypointId)
82 {
83 case 16:
84 Talk(SAY_GIL_AT_LAST, player);
85 break;
86 case 17:
87 Talk(SAY_GIL_PROCEED, player);
88 break;
89 case 18:
91 break;
92 case 37:
93 Talk(SAY_GIL_ALMOST, player);
94 break;
95 case 47:
96 Talk(SAY_GIL_SWEET, player);
97 break;
98 case 53:
99 Talk(SAY_GIL_FREED, player);
101 break;
102 }
103 }
104
105 void JustEngagedWith(Unit* who) override
106 {
107 //not always use
108 if (rand32() % 4)
109 return;
110
111 //only aggro text if not player and only in this area
113 {
114 //appears to be pretty much random (possible only if escorter not in combat with who yet?)
115 Talk(SAY_GIL_AGGRO, who);
116 }
117 }
118
119 void OnQuestAccept(Player* player, Quest const* quest) override
120 {
121 if (quest->GetQuestId() == QUEST_FREE_FROM_HOLD)
122 {
125
126 Talk(SAY_GIL_START, player);
128 Start(false, player->GetGUID(), quest);
129 }
130 }
131 };
132
133 CreatureAI* GetAI(Creature* creature) const override
134 {
135 return new npc_giltharesAI(creature);
136 }
137};
138
139/*######
140## npc_taskmaster_fizzule
141######*/
142
144{
145 SPELL_FLARE = 10113,
146 SPELL_FOLLY = 10137,
147};
148
150{
151public:
152 npc_taskmaster_fizzule() : CreatureScript("npc_taskmaster_fizzule") { }
153
154 CreatureAI* GetAI(Creature* creature) const override
155 {
156 return new npc_taskmaster_fizzuleAI(creature);
157 }
158
160 {
162 {
163 Initialize();
164 factionNorm = creature->GetFaction();
165 }
166
168 {
169 IsFriend = false;
170 ResetTimer = 120000;
171 FlareCount = 0;
172 }
173
178
179 void Reset() override
180 {
181 Initialize();
183 }
184
197
198 void SpellHit(WorldObject* /*caster*/, SpellInfo const* spellInfo) override
199 {
200 if (spellInfo->Id == SPELL_FLARE || spellInfo->Id == SPELL_FOLLY)
201 {
202 ++FlareCount;
203
204 if (FlareCount >= 2)
205 IsFriend = true;
206 }
207 }
208
209 void JustEngagedWith(Unit* /*who*/) override { }
210
211 void UpdateAI(uint32 diff) override
212 {
213 if (IsFriend)
214 {
215 if (ResetTimer <= diff)
216 {
218 return;
219 } else ResetTimer -= diff;
220 }
221
222 if (!UpdateVictim())
223 return;
224
226 }
227
228 void ReceiveEmote(Player* /*player*/, uint32 emote) override
229 {
230 if (emote == TEXT_EMOTE_SALUTE)
231 {
232 if (FlareCount >= 2)
233 {
235 return;
236
237 DoFriend();
238 }
239 }
240 }
241 };
242
243};
244
245/*#####
246## npc_twiggy_flathead
247#####*/
248
260
262{
263 {-1683.0f, -4326.0f, 2.79f, 0.0f},
264 {-1682.0f, -4329.0f, 2.79f, 0.0f},
265 {-1683.0f, -4330.0f, 2.79f, 0.0f},
266 {-1680.0f, -4334.0f, 2.79f, 1.49f},
267 {-1674.0f, -4326.0f, 2.79f, 3.49f},
268 {-1677.0f, -4334.0f, 2.79f, 1.66f}
269};
270
272{
273public:
274 npc_twiggy_flathead() : CreatureScript("npc_twiggy_flathead") { }
275
276 CreatureAI* GetAI(Creature* creature) const override
277 {
278 return new npc_twiggy_flatheadAI(creature);
279 }
280
282 {
284 {
285 Initialize();
286 }
287
289 {
290 EventInProgress = false;
291 EventGrate = false;
292 EventBigWill = false;
293 WaveTimer = 600000;
295 Wave = 0;
297
298 for (uint8 i = 0; i < 6; ++i)
299 {
301 ChallengerDown[i] = false;
302 }
303 BigWill.Clear();
304 }
305
316
317 void Reset() override
318 {
319 Initialize();
320 }
321
322 void MoveInLineOfSight(Unit* who) override
323 {
324 if (!who || !who->IsAlive() || EventInProgress)
325 return;
326
327 if (who->GetTypeId() == TYPEID_PLAYER && me->IsWithinDistInMap(who, 10.0f))
328 if (Player* player = who->ToPlayer())
329 if (player->GetQuestStatus(1719) == QUEST_STATUS_INCOMPLETE)
330 {
331 PlayerGUID = who->GetGUID();
332 EventInProgress = true;
333 }
334 }
335
336 void UpdateAI(uint32 diff) override
337 {
338 if (EventInProgress)
339 {
340 Player* warrior = nullptr;
341
342 if (!PlayerGUID.IsEmpty())
344
345 if (!warrior)
346 return;
347
348 if (!warrior->IsAlive() && warrior->GetQuestStatus(1719) == QUEST_STATUS_INCOMPLETE)
349 {
351 warrior->FailQuest(1719);
352
353 for (uint8 i = 0; i < 6; ++i) // unsummon challengers
354 {
355 if (!AffrayChallenger[i].IsEmpty())
356 {
358 if (creature && creature->IsAlive())
359 creature->DisappearAndDie();
360 }
361 }
362
363 if (!BigWill.IsEmpty()) // unsummon bigWill
364 {
366 if (creature && creature->IsAlive())
367 creature->DisappearAndDie();
368 }
369 Reset();
370 }
371
373 {
374 float x, y, z;
375 warrior->GetPosition(x, y, z);
376
377 if (x >= -1684 && x <= -1674 && y >= -4334 && y <= -4324)
378 {
379 warrior->AreaExploredOrEventHappens(1719);
381
382 for (uint8 i = 0; i < 6; ++i)
383 {
385 if (!creature)
386 continue;
387 creature->SetFaction(35);
391 AffrayChallenger[i] = creature->GetGUID();
392 }
393 WaveTimer = 5000;
394 ChallengerChecker = 1000;
395 EventGrate = true;
396 }
397 }
398 else if (EventInProgress)
399 {
400 if (ChallengerChecker <= diff)
401 {
402 for (uint8 i = 0; i < 6; ++i)
403 {
404 if (!AffrayChallenger[i].IsEmpty())
405 {
407 if ((!creature || (!creature->IsAlive())) && !ChallengerDown[i])
408 {
410 ChallengerDown[i] = true;
411 }
412 }
413 }
414 ChallengerChecker = 1000;
415 } else ChallengerChecker -= diff;
416
417 if (WaveTimer <= diff)
418 {
419 if (Wave < 6 && !AffrayChallenger[Wave].IsEmpty() && !EventBigWill)
420 {
423 if (creature && (creature->IsAlive()))
424 {
428 creature->SetFaction(14);
429 creature->AI()->AttackStart(warrior);
430 ++Wave;
431 WaveTimer = 20000;
432 }
433 }
434 else if (Wave >= 6 && !EventBigWill)
435 {
436 if (Creature* creature = me->SummonCreature(NPC_BIG_WILL, -1722, -4341, 6.12f, 6.26f, TEMPSUMMON_TIMED_OR_DEAD_DESPAWN, 8min))
437 {
438 BigWill = creature->GetGUID();
439 //creature->GetMotionMaster()->MovePoint(0, -1693, -4343, 4.32f);
440 //creature->GetMotionMaster()->MovePoint(1, -1684, -4333, 2.78f);
441 creature->GetMotionMaster()->MovePoint(2, -1682, -4329, 2.79f);
442 creature->HandleEmoteCommand(EMOTE_STATE_READY_UNARMED);
443 EventBigWill = true;
444 WaveTimer = 1000;
445 }
446 }
447 else if (Wave >= 6 && EventBigWill && !BigWill.IsEmpty())
448 {
450 if (!creature || !creature->IsAlive())
451 {
453 Reset();
454 }
455 else // Makes BIG WILL attackable.
456 {
460 creature->SetFaction(14);
461 creature->AI()->AttackStart(warrior);
462 }
463 }
464 } else WaveTimer -= diff;
465 }
466 }
467 }
468 };
469
470};
471
473{
474 new npc_gilthares();
477}
uint8_t uint8
Definition Define.h:135
uint32_t uint32
Definition Define.h:133
@ TEMPSUMMON_TIMED_OR_DEAD_DESPAWN
@ TYPEID_PLAYER
Definition ObjectGuid.h:39
@ QUEST_STATUS_INCOMPLETE
Definition QuestDef.h:107
uint32 rand32()
Definition Random.cpp:70
@ EMOTE_STATE_READY_UNARMED
@ EMOTE_ONESHOT_ROAR
@ EMOTE_ONESHOT_SALUTE
@ TEXT_EMOTE_SALUTE
@ FACTION_FRIENDLY
@ FACTION_ESCORTEE_H_NEUTRAL_ACTIVE
@ UNIT_STAND_STATE_STAND
Definition UnitDefines.h:34
@ UNIT_FLAG_NON_ATTACKABLE
@ UNIT_FLAG_UNINTERACTIBLE
bool UpdateVictim()
Creature *const me
Definition CreatureAI.h:82
void EngagementOver()
virtual void EnterEvadeMode(EvadeReason why=EVADE_REASON_OTHER)
CreatureAI * AI() const
Definition Creature.h:154
void DisappearAndDie()
Definition Creature.h:73
bool IsEmpty() const
Definition ObjectGuid.h:172
void Clear()
Definition ObjectGuid.h:150
TypeID GetTypeId() const
Definition Object.h:93
static ObjectGuid GetGUID(Object const *o)
Definition Object.h:78
static Player * ToPlayer(Object *o)
Definition Object.h:180
void GroupEventHappens(uint32 questId, WorldObject const *pEventObject)
Definition Player.cpp:16032
void AreaExploredOrEventHappens(uint32 questId)
Definition Player.cpp:16008
QuestStatus GetQuestStatus(uint32 quest_id) const
Definition Player.cpp:15642
void FailQuest(uint32 quest_id)
Definition Player.cpp:15040
uint32 GetQuestId() const
Definition QuestDef.h:229
uint32 Id
Definition SpellInfo.h:289
void DoMeleeAttackIfReady()
Definition UnitAI.cpp:54
virtual void AttackStart(Unit *)
Definition UnitAI.cpp:30
Definition Unit.h:769
void SetFaction(uint32 faction) override
Definition Unit.h:974
void StopMoving(bool force=false)
Definition Unit.cpp:10312
MotionMaster * GetMotionMaster()
Definition Unit.h:1667
bool IsAlive() const
Definition Unit.h:1234
uint32 GetFaction() const override
Definition Unit.h:973
void HandleEmoteCommand(Emote emoteId)
Definition Unit.cpp:1568
void SetStandState(UnitStandStateType state)
Definition Unit.cpp:10363
void RemoveAllAuras()
Definition Unit.cpp:4157
void CombatStop(bool includingCast=false, bool mutualPvP=true)
Definition Unit.cpp:5691
void SetUnitFlag(UnitFlags flags)
Definition Unit.h:954
void RemoveUnitFlag(UnitFlags flags)
Definition Unit.h:955
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
bool IsWithinDistInMap(WorldObject const *obj, float dist2compare, bool is3D=true, bool incOwnRadius=true, bool incTargetRadius=true) const
Definition Object.cpp:1192
uint32 GetAreaId() const
Definition Object.h:374
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 LoadPath(uint32 pathId)
Player * GetPlayerForEscort()
void GetPosition(float &x, float &y) const
Definition Position.h:84
Definition hyjalAI.h:47
void OnQuestAccept(Player *player, Quest const *quest) override
void WaypointReached(uint32 waypointId, uint32) override
void JustEngagedWith(Unit *who) override
void ReceiveEmote(Player *, uint32 emote) override
void SpellHit(WorldObject *, SpellInfo const *spellInfo) override
Position const AffrayChallengerLoc[6]
TaskmasterFizzule
@ SPELL_FOLLY
@ SPELL_FLARE
void AddSC_the_barrens()
@ SAY_GIL_AGGRO
@ QUEST_FREE_FROM_HOLD
@ SAY_GIL_SWEET
@ SAY_GIL_AT_LAST
@ SAY_GIL_PROCEED
@ SAY_GIL_START
@ AREA_MERCHANT_COAST
@ SAY_GIL_FREEBOOTERS
@ SAY_GIL_FREED
@ SAY_GIL_ALMOST
@ 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
static constexpr uint32 PATH_ESCORT_GILTHARES