Project SkyFire Core
SkyFire 5.4.8 server core API documentation
Loading...
Searching...
No Matches
zone_the_barrens.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/* ScriptData
7SDName: The_Barrens
8SD%Complete: 90
9SDComment: Quest support: 863
10SDCategory: Barrens
11EndScriptData */
12
13/* ContentData
14npc_wizzlecrank_shredder
15EndContentData */
16
17#include "ScriptMgr.h"
18#include "ScriptedCreature.h"
19#include "ScriptedGossip.h"
20#include "ScriptedEscortAI.h"
21#include "Player.h"
22#include "SpellInfo.h"
23
24/*######
25## npc_beaten_corpse
26######*/
27
28#define GOSSIP_CORPSE "Examine corpse in detail..."
29
34
36{
37public:
38 npc_beaten_corpse() : CreatureScript("npc_beaten_corpse") { }
39
40 bool OnGossipSelect(Player* player, Creature* creature, uint32 /*sender*/, uint32 action) OVERRIDE
41 {
42 player->PlayerTalkClass->ClearMenus();
43 if (action == GOSSIP_ACTION_INFO_DEF +1)
44 {
45 player->SEND_GOSSIP_MENU(3558, creature->GetGUID());
46 player->TalkedToCreature(creature->GetEntry(), creature->GetGUID());
47 }
48 return true;
49 }
50
51 bool OnGossipHello(Player* player, Creature* creature) OVERRIDE
52 {
53 if (player->GetQuestStatus(QUEST_LOST_IN_BATTLE) == QUEST_STATUS_INCOMPLETE || player->GetQuestStatus(QUEST_LOST_IN_BATTLE) == QUEST_STATUS_COMPLETE)
55
56 player->SEND_GOSSIP_MENU(3557, creature->GetGUID());
57 return true;
58 }
59};
60
61/*######
62# npc_gilthares
63######*/
64
80
82{
83public:
84 npc_gilthares() : CreatureScript("npc_gilthares") { }
85
86 bool OnQuestAccept(Player* player, Creature* creature, const Quest* quest) OVERRIDE
87 {
88 if (quest->GetQuestId() == QUEST_FREE_FROM_HOLD)
89 {
90 creature->setFaction(FACTION_ESCORTEE);
91 creature->SetStandState(UNIT_STAND_STATE_STAND);
92
93 creature->AI()->Talk(SAY_GIL_START, player);
94
95 if (npc_giltharesAI* pEscortAI = CAST_AI(npc_gilthares::npc_giltharesAI, creature->AI()))
96 pEscortAI->Start(false, false, player->GetGUID(), quest);
97 }
98 return true;
99 }
100
102 {
103 return new npc_giltharesAI(creature);
104 }
105
107 {
108 npc_giltharesAI(Creature* creature) : npc_escortAI(creature) { }
109
110 void Reset() OVERRIDE { }
111
113 {
114 Player* player = GetPlayerForEscort();
115 if (!player)
116 return;
117
118 switch (waypointId)
119 {
120 case 16:
121 Talk(SAY_GIL_AT_LAST, player);
122 break;
123 case 17:
124 Talk(SAY_GIL_PROCEED, player);
125 break;
126 case 18:
127 Talk(SAY_GIL_FREEBOOTERS, player);
128 break;
129 case 37:
130 Talk(SAY_GIL_ALMOST, player);
131 break;
132 case 47:
133 Talk(SAY_GIL_SWEET, player);
134 break;
135 case 53:
136 Talk(SAY_GIL_FREED, player);
138 break;
139 }
140 }
141
143 {
144 //not always use
145 if (rand()%4)
146 return;
147
148 //only aggro text if not player and only in this area
149 if (who->GetTypeId() != TypeID::TYPEID_PLAYER && me->GetAreaId() == AREA_MERCHANT_COAST)
150 {
151 //appears to be pretty much random (possible only if escorter not in combat with who yet?)
152 Talk(SAY_GIL_AGGRO, who);
153 }
154 }
155 };
156};
157
158/*######
159## npc_taskmaster_fizzule
160######*/
161
168
170{
171public:
172 npc_taskmaster_fizzule() : CreatureScript("npc_taskmaster_fizzule") { }
173
175 {
176 return new npc_taskmaster_fizzuleAI(creature);
177 }
178
180 {
182 {
183 factionNorm = creature->getFaction();
184 bool IsFriend = false;
185 uint32 ResetTimer = 0;
186 uint8 FlareCount = 0;
187 }
188
190 {
191 IsFriend = false;
192 ResetTimer = 120000;
193 FlareCount = 0;
194 me->setFaction(factionNorm);
195 }
196
197 void DoFriend()
198 {
199 me->RemoveAllAuras();
200 me->DeleteThreatList();
201 me->CombatStop(true);
202
203 me->StopMoving();
204 me->GetMotionMaster()->MoveIdle();
205
206 me->setFaction(FACTION_FRIENDLY_F);
207 me->HandleEmoteCommand(EMOTE_ONESHOT_SALUTE);
208 }
209
210 void SpellHit(Unit* /*caster*/, const SpellInfo* spell) OVERRIDE
211 {
212 if (spell->Id == SPELL_FLARE || spell->Id == SPELL_FOLLY)
213 {
214 ++FlareCount;
215
216 if (FlareCount >= 2)
217 IsFriend = true;
218 }
219 }
220
221 void EnterCombat(Unit* /*who*/) OVERRIDE { }
222
224 {
225 if (IsFriend)
226 {
227 if (ResetTimer <= diff)
228 {
230 return;
231 } else ResetTimer -= diff;
232 }
233
234 if (!UpdateVictim())
235 return;
236
238 }
239
240 void ReceiveEmote(Player* /*player*/, uint32 emote) OVERRIDE
241 {
242 if (emote == TEXT_EMOTE_SALUTE)
243 {
244 if (FlareCount >= 2)
245 {
246 if (me->getFaction() == FACTION_FRIENDLY_F)
247 return;
248
249 DoFriend();
250 }
251 }
252 }
253
258 };
259};
260
261/*#####
262## npc_twiggy_flathead
263#####*/
264
276
278{
279 {-1683.0f, -4326.0f, 2.79f, 0.0f},
280 {-1682.0f, -4329.0f, 2.79f, 0.0f},
281 {-1683.0f, -4330.0f, 2.79f, 0.0f},
282 {-1680.0f, -4334.0f, 2.79f, 1.49f},
283 {-1674.0f, -4326.0f, 2.79f, 3.49f},
284 {-1677.0f, -4334.0f, 2.79f, 1.66f}
285};
286
288{
289public:
290 npc_twiggy_flathead() : CreatureScript("npc_twiggy_flathead") { }
291
293 {
294 return new npc_twiggy_flatheadAI(creature);
295 }
296
298 {
299 npc_twiggy_flatheadAI(Creature* creature) : ScriptedAI(creature) { }
300
311
313 {
314 EventInProgress = false;
315 EventGrate = false;
316 EventBigWill = false;
317 WaveTimer = 600000;
319 Wave = 0;
320 PlayerGUID = 0;
321
322 for (uint8 i = 0; i < 6; ++i)
323 {
324 AffrayChallenger[i] = 0;
325 ChallengerDown[i] = false;
326 }
327 BigWill = 0;
328 }
329
330 void EnterCombat(Unit* /*who*/) OVERRIDE { }
331
333
334 {
335 if (!who || !who->IsAlive() || EventInProgress)
336 return;
337
338 if (who->GetTypeId() == TypeID::TYPEID_PLAYER && me->IsWithinDistInMap(who, 10.0f))
339 if (Player* player = who->ToPlayer())
340 if (player->GetQuestStatus(1719) == QUEST_STATUS_INCOMPLETE)
341 {
342 PlayerGUID = who->GetGUID();
343 EventInProgress = true;
344 }
345 }
346
347 void KilledUnit(Unit* /*victim*/) OVERRIDE { }
348
350 {
351 if (EventInProgress)
352 {
353 Player* warrior = NULL;
354
355 if (PlayerGUID)
357
358 if (!warrior)
359 return;
360
361 if (!warrior->IsAlive() && warrior->GetQuestStatus(1719) == QUEST_STATUS_INCOMPLETE)
362 {
364 warrior->FailQuest(1719);
365
366 for (uint8 i = 0; i < 6; ++i) // unsummon challengers
367 {
368 if (AffrayChallenger[i])
369 {
370 Creature* creature = Unit::GetCreature((*me), AffrayChallenger[i]);
371 if (creature && creature->IsAlive())
372 creature->DisappearAndDie();
373 }
374 }
375
376 if (BigWill) // unsummon bigWill
377 {
378 Creature* creature = Unit::GetCreature((*me), BigWill);
379 if (creature && creature->IsAlive())
380 creature->DisappearAndDie();
381 }
382 Reset();
383 }
384
386 {
387 float x, y, z;
388 warrior->GetPosition(x, y, z);
389
390 if (x >= -1684 && x <= -1674 && y >= -4334 && y <= -4324)
391 {
392 warrior->AreaExploredOrEventHappens(1719);
394
395 for (uint8 i = 0; i < 6; ++i)
396 {
398 if (!creature)
399 continue;
400 creature->setFaction(35);
404 AffrayChallenger[i] = creature->GetGUID();
405 }
406 WaveTimer = 5000;
407 ChallengerChecker = 1000;
408 EventGrate = true;
409 }
410 }
411 else if (EventInProgress)
412 {
413 if (ChallengerChecker <= diff)
414 {
415 for (uint8 i = 0; i < 6; ++i)
416 {
417 if (AffrayChallenger[i])
418 {
419 Creature* creature = Unit::GetCreature((*me), AffrayChallenger[i]);
420 if ((!creature || (!creature->IsAlive())) && !ChallengerDown[i])
421 {
423 ChallengerDown[i] = true;
424 }
425 }
426 }
427 ChallengerChecker = 1000;
428 } else ChallengerChecker -= diff;
429
430 if (WaveTimer <= diff)
431 {
432 if (Wave < 6 && AffrayChallenger[Wave] && !EventBigWill)
433 {
436 if (creature && (creature->IsAlive()))
437 {
441 creature->setFaction(14);
442 creature->AI()->AttackStart(warrior);
443 ++Wave;
444 WaveTimer = 20000;
445 }
446 }
447 else if (Wave >= 6 && !EventBigWill)
448 {
449 if (Creature* creature = me->SummonCreature(NPC_BIG_WILL, -1722, -4341, 6.12f, 6.26f, TempSummonType::TEMPSUMMON_TIMED_OR_DEAD_DESPAWN, 480000))
450 {
451 BigWill = creature->GetGUID();
452 //creature->GetMotionMaster()->MovePoint(0, -1693, -4343, 4.32f);
453 //creature->GetMotionMaster()->MovePoint(1, -1684, -4333, 2.78f);
454 creature->GetMotionMaster()->MovePoint(2, -1682, -4329, 2.79f);
455 creature->HandleEmoteCommand(EMOTE_STATE_READY_UNARMED);
456 EventBigWill = true;
457 WaveTimer = 1000;
458 }
459 }
460 else if (Wave >= 6 && EventBigWill && BigWill)
461 {
463 if (!creature || !creature->IsAlive())
464 {
466 Reset();
467 }
468 }
469 } else WaveTimer -= diff;
470 }
471 }
472 }
473 };
474};
475
476/*#####
477## npc_wizzlecrank_shredder
478#####*/
479
496
498{
499public:
500 npc_wizzlecrank_shredder() : CreatureScript("npc_wizzlecrank_shredder") { }
501
503 {
505 {
506 IsPostEvent = false;
507 PostEventTimer = 1000;
508 PostEventCount = 0;
509 }
510
514
516 {
518 {
519 if (me->getStandState() == UNIT_STAND_STATE_DEAD)
520 me->SetStandState(UNIT_STAND_STATE_STAND);
521
522 IsPostEvent = false;
523 PostEventTimer = 1000;
524 PostEventCount = 0;
525 }
526 }
527
529 {
530 switch (waypointId)
531 {
532 case 0:
534 break;
535 case 9:
536 SetRun(false);
537 break;
538 case 17:
539 if (Creature* temp = me->SummonCreature(NPC_MERCENARY, 1128.489f, -3037.611f, 92.701f, 1.472f, TempSummonType::TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 120000))
540 {
541 temp->AI()->Talk(SAY_MERCENARY);
542 me->SummonCreature(NPC_MERCENARY, 1160.172f, -2980.168f, 97.313f, 3.690f, TempSummonType::TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 120000);
543 }
544 break;
545 case 24:
546 IsPostEvent = true;
547 break;
548 }
549 }
550
552 {
553 Player* player = GetPlayerForEscort();
554
555 if (!player)
556 return;
557
558 switch (PointId)
559 {
560 case 9:
561 Talk(SAY_STARTUP2, player);
562 break;
563 case 18:
564 Talk(SAY_PROGRESS_1, player);
565 SetRun();
566 break;
567 }
568 }
569
571 {
572 if (summoned->GetEntry() == NPC_PILOT_WIZZ)
573 me->SetStandState(UNIT_STAND_STATE_DEAD);
574
575 if (summoned->GetEntry() == NPC_MERCENARY)
576 summoned->AI()->AttackStart(me);
577 }
578
580 {
581 if (!UpdateVictim())
582 {
583 if (IsPostEvent)
584 {
585 if (PostEventTimer <= Diff)
586 {
587 switch (PostEventCount)
588 {
589 case 0:
591 break;
592 case 1:
594 break;
595 case 2:
596 Talk(SAY_END);
597 break;
598 case 3:
599 if (Player* player = GetPlayerForEscort())
600 {
601 player->GroupEventHappens(QUEST_ESCAPE, me);
602 me->SummonCreature(NPC_PILOT_WIZZ, 0.0f, 0.0f, 0.0f, 0.0f, TempSummonType::TEMPSUMMON_TIMED_DESPAWN, 180000);
603 }
604 break;
605 }
606
608 PostEventTimer = 5000;
609 }
610 else
611 PostEventTimer -= Diff;
612 }
613
614 return;
615 }
616
618 }
619 };
620
621 bool OnQuestAccept(Player* player, Creature* creature, Quest const* quest) OVERRIDE
622 {
623 if (quest->GetQuestId() == QUEST_ESCAPE)
624 {
625 creature->setFaction(FACTION_RATCHET);
627 pEscortAI->Start(true, false, player->GetGUID());
628 }
629 return true;
630 }
631
633 {
634 return new npc_wizzlecrank_shredderAI(creature);
635 }
636};
637
639{
641}
std::uint8_t uint8
Definition Define.h:79
std::uint32_t uint32
Definition Define.h:77
#define OVERRIDE
Definition Define.h:60
std::uint64_t uint64
Definition Define.h:76
@ GOSSIP_ICON_CHAT
Definition GossipDef.h:46
@ TYPEID_PLAYER
Definition Object.h:55
@ TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT
Definition Object.h:71
@ TEMPSUMMON_TIMED_DESPAWN
Definition Object.h:70
@ TEMPSUMMON_TIMED_OR_DEAD_DESPAWN
Definition Object.h:68
@ QUEST_STATUS_INCOMPLETE
Definition QuestDef.h:89
@ QUEST_STATUS_COMPLETE
Definition QuestDef.h:87
#define CAST_AI(a, b)
@ STATE_ESCORT_ESCORTING
@ GOSSIP_SENDER_MAIN
@ GOSSIP_ACTION_INFO_DEF
@ EMOTE_STATE_READY_UNARMED
@ EMOTE_ONESHOT_ROAR
@ EMOTE_ONESHOT_SALUTE
@ TEXT_EMOTE_SALUTE
@ UNIT_STAND_STATE_DEAD
Definition Unit.h:169
@ UNIT_STAND_STATE_STAND
Definition Unit.h:162
@ UNIT_FLAG_NON_ATTACKABLE
Definition Unit.h:626
@ UNIT_FLAG_NOT_SELECTABLE
Definition Unit.h:650
@ UNIT_FIELD_FLAGS
void Talk(uint8 id, WorldObject const *whisperTarget=NULL)
bool UpdateVictim()
virtual void EnterEvadeMode()
CreatureAI * AI() const
Definition Creature.h:483
void DisappearAndDie()
Definition Creature.cpp:206
CreatureScript(const char *name)
static Creature * GetCreature(WorldObject const &u, uint64 guid)
static Player * GetPlayer(WorldObject const &, uint64 guid)
uint64 GetGUID() const
Definition Object.h:119
Player * ToPlayer()
Definition Object.h:204
void SetFlag(uint16 index, uint32 newFlag)
Definition Object.cpp:1261
void RemoveFlag(uint16 index, uint32 oldFlag)
Definition Object.cpp:1280
void GroupEventHappens(uint32 questId, WorldObject const *pEventObject)
void AreaExploredOrEventHappens(uint32 questId)
QuestStatus GetQuestStatus(uint32 quest_id) const
void FailQuest(uint32 quest_id)
void DoMeleeAttackIfReady()
Definition UnitAI.cpp:28
virtual void AttackStart(Unit *)
Definition UnitAI.cpp:16
Definition Unit.h:1367
void setFaction(uint32 faction)
Definition Unit.h:1699
uint32 getFaction() const
Definition Unit.h:1695
bool IsAlive() const
Definition Unit.h:2032
static Creature * GetCreature(WorldObject &object, uint64 guid)
Definition Unit.cpp:4905
void HandleEmoteCommand(uint32 anim_id)
bool OnGossipHello(Player *player, Creature *creature) OVERRIDE
bool OnGossipSelect(Player *player, Creature *creature, uint32, uint32 action) OVERRIDE
bool OnQuestAccept(Player *player, Creature *creature, const Quest *quest) OVERRIDE
CreatureAI * GetAI(Creature *creature) const OVERRIDE
CreatureAI * GetAI(Creature *creature) const OVERRIDE
CreatureAI * GetAI(Creature *creature) const OVERRIDE
bool OnQuestAccept(Player *player, Creature *creature, Quest const *quest) OVERRIDE
CreatureAI * GetAI(Creature *creature) const OVERRIDE
@ SAY_END
void GetPosition(float &x, float &y) const
Definition Object.h:333
Creature * me
ScriptedAI(Creature *creature)
Player * GetPlayerForEscort()
void SetRun(bool on=true)
bool HasEscortState(uint32 escortState) const
npc_escortAI(Creature *creature)
void EnterCombat(Unit *who) OVERRIDE
void WaypointReached(uint32 waypointId) OVERRIDE
void ReceiveEmote(Player *, uint32 emote) OVERRIDE
void UpdateAI(uint32 diff) OVERRIDE
== Triggered Actions Requested ==================
void SpellHit(Unit *, const SpellInfo *spell) OVERRIDE
void UpdateAI(uint32 diff) OVERRIDE
== Triggered Actions Requested ==================
@ SAY_START
Position const AffrayChallengerLoc[6]
@ QUEST_LOST_IN_BATTLE
TaskmasterFizzule
@ FACTION_FRIENDLY_F
@ 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
@ FACTION_ESCORTEE
@ 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
#define GOSSIP_CORPSE
@ FACTION_RATCHET
@ SAY_STARTUP2
@ SAY_PROGRESS_3
@ SAY_STARTUP1
@ NPC_MERCENARY
@ SAY_PROGRESS_2
@ NPC_PILOT_WIZZ
@ QUEST_ESCAPE
@ SAY_PROGRESS_1
@ SAY_MERCENARY