TrinityCore
Loading...
Searching...
No Matches
zone_azuremyst_isle.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: Azuremyst_Isle
20SD%Complete: 75
21SDComment: Quest support: 9283, 9537, 9582, 9554, 9531, ? (special flight path, proper model for mount missing). Injured Draenei cosmetic only, 9582.
22SDCategory: Azuremyst Isle
23EndScriptData */
24
25/* ContentData
26npc_draenei_survivor
27npc_engineer_spark_overgrind
28npc_injured_draenei
29npc_magwin
30npc_geezle
31EndContentData */
32
33#include "ScriptMgr.h"
34#include "CellImpl.h"
35#include "GameObjectAI.h"
36#include "GridNotifiersImpl.h"
37#include "Log.h"
38#include "MotionMaster.h"
39#include "ObjectAccessor.h"
40#include "ScriptedEscortAI.h"
41#include "ScriptedGossip.h"
42#include "SpellScript.h"
43#include "TemporarySummon.h"
44
45/*######
46## npc_draenei_survivor
47######*/
48
56
58{
59public:
60 npc_draenei_survivor() : CreatureScript("npc_draenei_survivor") { }
61
63 {
65 {
66 Initialize();
67 }
68
70 {
71 pCaster.Clear();
72
74 RunAwayTimer = 0;
75 SayHelpTimer = 10000;
76
77 CanSayHelp = true;
78 }
79
81
85
87
88 void Reset() override
89 {
90 Initialize();
91
93
94 me->SetPvP(true);
98 }
99
100 void JustEngagedWith(Unit* /*who*/) override { }
101
102 void MoveInLineOfSight(Unit* who) override
103 {
104 if (CanSayHelp && who->GetTypeId() == TYPEID_PLAYER && me->IsFriendlyTo(who) && me->IsWithinDistInMap(who, 25.0f))
105 {
106 //Random switch between 4 texts
107 Talk(SAY_HELP, who);
108
109 SayHelpTimer = 20000;
110 CanSayHelp = false;
111 }
112 }
113
114 void SpellHit(WorldObject* caster, SpellInfo const* spellInfo) override
115 {
116 if (spellInfo->SpellFamilyFlags[2] & 0x080000000)
117 {
118 me->SetPvP(false);
120
121 DoCast(me, SPELL_STUNNED, true);
122
123 pCaster = caster->GetGUID();
124
125 SayThanksTimer = 5000;
126 }
127 }
128
129 void UpdateAI(uint32 diff) override
130 {
131 if (SayThanksTimer)
132 {
133 if (SayThanksTimer <= diff)
134 {
136
138 {
139 Talk(SAY_HEAL, player);
140
141 player->TalkedToCreature(me->GetEntry(), me->GetGUID());
142 }
143
145 me->GetMotionMaster()->MovePoint(0, -4115.053711f, -13754.831055f, 73.508949f);
146
147 RunAwayTimer = 10000;
148 SayThanksTimer = 0;
149 } else SayThanksTimer -= diff;
150
151 return;
152 }
153
154 if (RunAwayTimer)
155 {
156 if (RunAwayTimer <= diff)
158 else
159 RunAwayTimer -= diff;
160
161 return;
162 }
163
164 if (SayHelpTimer <= diff)
165 {
166 CanSayHelp = true;
167 SayHelpTimer = 20000;
168 } else SayHelpTimer -= diff;
169 }
170 };
171
172 CreatureAI* GetAI(Creature* creature) const override
173 {
174 return new npc_draenei_survivorAI(creature);
175 }
176};
177
178/*######
179## npc_engineer_spark_overgrind
180######*/
181
193
195{
196public:
197 npc_engineer_spark_overgrind() : CreatureScript("npc_engineer_spark_overgrind") { }
198
200 {
202 {
203 Initialize();
204 NormFaction = creature->GetFaction();
205 NpcFlags = creature->GetNpcFlags();
206 }
207
209 {
210 DynamiteTimer = 8000;
211 EmoteTimer = urand(120000, 150000);
212
213 if (me->GetAreaId() == AREA_COVE || me->GetAreaId() == AREA_ISLE)
214 IsTreeEvent = true;
215 else
216 IsTreeEvent = false;
217 }
218
219 void Reset() override
220 {
221 Initialize();
222
225 }
226
227 void JustEngagedWith(Unit* who) override
228 {
229 Talk(ATTACK_YELL, who);
230 }
231
232 bool OnGossipSelect(Player* player, uint32 /*menuId*/, uint32 /*gossipListId*/) override
233 {
234 CloseGossipMenuFor(player);
236 me->Attack(player, true);
237 return false;
238 }
239
240 void UpdateAI(uint32 diff) override
241 {
242 if (!me->IsInCombat() && !IsTreeEvent)
243 {
244 if (EmoteTimer <= diff)
245 {
246 Talk(SAY_TEXT);
248 EmoteTimer = urand(120000, 150000);
249 } else EmoteTimer -= diff;
250 }
251 else if (IsTreeEvent)
252 return;
253
254 if (!UpdateVictim())
255 return;
256
257 if (DynamiteTimer <= diff)
258 {
260 DynamiteTimer = 8000;
261 } else DynamiteTimer -= diff;
262
264 }
265
266 private:
272 };
273
274 CreatureAI* GetAI(Creature* creature) const override
275 {
276 return new npc_engineer_spark_overgrindAI(creature);
277 }
278};
279
280/*######
281## npc_injured_draenei
282######*/
283
285{
286public:
287 npc_injured_draenei() : CreatureScript("npc_injured_draenei") { }
288
290 {
291 npc_injured_draeneiAI(Creature* creature) : ScriptedAI(creature) { }
292
293 void Reset() override
294 {
297 switch (urand(0, 1))
298 {
299 case 0:
301 break;
302
303 case 1:
305 break;
306 }
307 }
308
309 void JustEngagedWith(Unit* /*who*/) override { }
310
311 void MoveInLineOfSight(Unit* /*who*/) override { }
312
313 void UpdateAI(uint32 /*diff*/) override { }
314 };
315
316 CreatureAI* GetAI(Creature* creature) const override
317 {
318 return new npc_injured_draeneiAI(creature);
319 }
320};
321
322/*######
323## npc_magwin
324######*/
325
344
346{
347public:
348 npc_magwin() : CreatureScript("npc_magwin") { }
349
350 struct npc_magwinAI : public EscortAI
351 {
352 npc_magwinAI(Creature* creature) : EscortAI(creature) { }
353
354 void Reset() override
355 {
356 _events.Reset();
357 }
358
359 void JustEngagedWith(Unit* who) override
360 {
361 Talk(SAY_AGGRO, who);
362 }
363
364 void OnQuestAccept(Player* player, Quest const* quest) override
365 {
366 if (quest->GetQuestId() == QUEST_A_CRY_FOR_HELP)
367 {
368 _player = player->GetGUID();
370 }
371 }
372
373 void WaypointReached(uint32 waypointId, uint32 /*pathId*/) override
374 {
375 if (Player* player = GetPlayerForEscort())
376 {
377 switch (waypointId)
378 {
379 case 17:
380 Talk(SAY_PROGRESS, player);
381 break;
382 case 28:
383 player->GroupEventHappens(QUEST_A_CRY_FOR_HELP, me);
385 break;
386 case 29:
387 if (Creature* cowlen = me->FindNearestCreature(NPC_COWLEN, 50.0f, true))
388 Talk(EMOTE_HUG, cowlen);
389 Talk(SAY_END2, player);
390 break;
391 }
392 }
393 }
394
395 void UpdateEscortAI(uint32 diff) override
396 {
397 _events.Update(diff);
398
399 if (uint32 eventId = _events.ExecuteEvent())
400 {
401 switch (eventId)
402 {
405 Talk(SAY_START, player);
408 break;
411 {
413 EscortAI::Start(true, player->GetGUID());
414 }
416 break;
417 case EVENT_STAND: // Remove kneel standstate. Using a separate delayed event because it causes unwanted delay before starting waypoint movement.
419 break;
420 case EVENT_TALK_END:
422 Talk(SAY_END1, player);
424 break;
426 if (Creature* cowlen = me->FindNearestCreature(NPC_COWLEN, 50.0f, true))
427 cowlen->AI()->Talk(SAY_COWLEN);
428 break;
429 }
430 }
431
433 }
434
435 private:
438 };
439
440 CreatureAI* GetAI(Creature* creature) const override
441 {
442 return new npc_magwinAI(creature);
443 }
444};
445
446/*######
447## npc_geezle
448######*/
449
469
470Position const SparkPos = {-5029.91f, -11291.79f, 8.096f, 0.0f};
471
473{
474public:
475 npc_geezle() : CreatureScript("npc_geezle") { }
476
477 struct npc_geezleAI : public ScriptedAI
478 {
479 npc_geezleAI(Creature* creature) : ScriptedAI(creature)
480 {
481 Initialize();
482 }
483
485 {
487 Step = 0;
488 EventStarted = false;
489 SayTimer = 0;
490 }
491
493
496
498
499 void Reset() override
500 {
501 Initialize();
502 StartEvent();
503 }
504
505 void JustEngagedWith(Unit* /*who*/) override { }
506
508 {
509 Step = 0;
510 EventStarted = true;
512 {
513 SparkGUID = Spark->GetGUID();
514 Spark->setActive(true);
515 Spark->RemoveNpcFlag(UNIT_NPC_FLAG_GOSSIP);
516 }
517 SayTimer = 8000;
518 }
519
521 {
523 if (!Spark)
524 return 99999999;
525
526 switch (step)
527 {
528 case 0:
529 Spark->GetMotionMaster()->MovePoint(0, -5080.70f, -11253.61f, 0.56f);
530 me->GetMotionMaster()->MovePoint(0, -5092.26f, -11252, 0.71f);
531 return 9000;
532 case 1:
533 DespawnNagaFlag(true);
534 Spark->AI()->Talk(EMOTE_SPARK);
535 return 1000;
536 case 2:
537 Talk(GEEZLE_SAY_1, Spark);
538 Spark->SetFacingToObject(me);
539 me->SetFacingToObject(Spark);
540 return 5000;
541 case 3:
542 Spark->AI()->Talk(SPARK_SAY_2);
543 return 7000;
544 case 4:
545 Spark->AI()->Talk(SPARK_SAY_3);
546 return 8000;
547 case 5:
548 Talk(GEEZLE_SAY_4, Spark);
549 return 8000;
550 case 6:
551 Spark->AI()->Talk(SPARK_SAY_5);
552 return 9000;
553 case 7:
554 Spark->AI()->Talk(SPARK_SAY_6);
555 return 8000;
556 case 8:
557 Talk(GEEZLE_SAY_7, Spark);
558 return 2000;
559 case 9:
561 Spark->GetMotionMaster()->MovePoint(0, SparkPos);
563 return 9000;
564 case 10:
565 Spark->DisappearAndDie();
566 DespawnNagaFlag(false);
568 [[fallthrough]];
569 default:
570 return 99999999;
571 }
572 }
573
574 // will complete Tree's company quest for all nearby players that are disguised as trees
576 {
577 float radius = 50.0f;
578 std::list<Player*> players;
581 Cell::VisitWorldObjects(me, searcher, radius);
582
583 for (std::list<Player*>::const_iterator itr = players.begin(); itr != players.end(); ++itr)
584 if ((*itr)->GetQuestStatus(QUEST_TREES_COMPANY) == QUEST_STATUS_INCOMPLETE && (*itr)->HasAura(SPELL_TREE_DISGUISE))
585 (*itr)->KilledMonsterCredit(NPC_SPARK);
586 }
587
588 void DespawnNagaFlag(bool despawn)
589 {
590 std::list<GameObject*> FlagList;
592
593 if (!FlagList.empty())
594 {
595 for (std::list<GameObject*>::const_iterator itr = FlagList.begin(); itr != FlagList.end(); ++itr)
596 {
597 if (despawn)
598 (*itr)->SetLootState(GO_JUST_DEACTIVATED);
599 else
600 (*itr)->Respawn();
601 }
602 }
603 }
604
605 void UpdateAI(uint32 diff) override
606 {
607 if (SayTimer <= diff)
608 {
609 if (EventStarted)
611 }
612 else
613 SayTimer -= diff;
614 }
615 };
616
617 CreatureAI* GetAI(Creature* creature) const override
618 {
619 return new npc_geezleAI(creature);
620 }
621};
622
623// 29528 - Inoculate Nestlewood Owlkin
625{
627
628 void PeriodicTick(AuraEffect const* /*aurEff*/)
629 {
630 if (GetTarget()->GetTypeId() != TYPEID_UNIT) // prevent error reports in case ignored player target
632 }
633
638};
639
640/*######
641## Quest 9452: Red Snapper - Very Tasty!
642######*/
643
649
650// 29866 - Cast Fishing Net
670
671/*######
672## Quest 9542: Totem of Vark
673######*/
674
679
680// 30447 - Shadow of the Forest
700
701// 30448 - Shadow of the Forest
728
uint8_t uint8
Definition Define.h:135
uint32_t uint32
Definition Define.h:133
@ GO_JUST_DEACTIVATED
Definition GameObject.h:79
@ TEMPSUMMON_CORPSE_TIMED_DESPAWN
@ TYPEID_UNIT
Definition ObjectGuid.h:38
@ TYPEID_PLAYER
Definition ObjectGuid.h:39
@ QUEST_STATUS_INCOMPLETE
Definition QuestDef.h:107
uint32 urand(uint32 min, uint32 max)
Definition Random.cpp:42
bool roll_chance_i(int chance)
Definition Random.h:59
#define RegisterSpellScript(spell_script)
Definition ScriptMgr.h:1128
void CloseGossipMenuFor(Player *player)
SpellEffIndex
@ EFFECT_0
@ SPELL_EFFECT_DUMMY
@ FACTION_ESCORTEE_N_NEUTRAL_PASSIVE
@ FACTION_MONSTER
AuraEffectHandleModes
@ AURA_EFFECT_HANDLE_REAL
@ SPELL_AURA_TRANSFORM
@ SPELL_AURA_PERIODIC_TRIGGER_SPELL
#define SpellEffectFn(F, I, N)
#define AuraEffectPeriodicFn(F, I, N)
#define AuraEffectApplyFn(F, I, N, M)
#define AuraEffectRemoveFn(F, I, N, M)
@ UNIT_STAND_STATE_SLEEP
Definition UnitDefines.h:37
@ UNIT_STAND_STATE_STAND
Definition UnitDefines.h:34
@ UNIT_STAND_STATE_SIT
Definition UnitDefines.h:35
NPCFlags
Non Player Character flags.
@ UNIT_NPC_FLAG_GOSSIP
@ UNIT_FLAG_IN_COMBAT
void PreventDefaultAction()
HookList< EffectApplyHandler > AfterEffectRemove
HookList< EffectPeriodicHandler > OnEffectPeriodic
HookList< EffectApplyHandler > AfterEffectApply
Unit * GetCaster() const
Unit * GetTarget() const
void Talk(uint8 id, WorldObject const *whisperTarget=nullptr)
bool UpdateVictim()
Creature *const me
Definition CreatureAI.h:82
void DespawnOrUnsummon(Milliseconds timeToDespawn=0s, Seconds forceRespawnTime=0s)
CreatureAI * AI() const
Definition Creature.h:154
void DisappearAndDie()
Definition Creature.h:73
void Update(uint32 time)
Definition EventMap.h:67
EventId ExecuteEvent()
Definition EventMap.cpp:73
void ScheduleEvent(EventId eventId, Milliseconds time, GroupIndex group=0u, PhaseIndex phase=0u)
Definition EventMap.cpp:36
void Reset()
Definition EventMap.cpp:21
void MovePoint(uint32 id, Position const &pos, bool generatePath=true, Optional< float > finalOrient={})
void MoveTargetedHome()
void Clear()
Definition ObjectGuid.h:150
TypeID GetTypeId() const
Definition Object.h:93
uint32 GetEntry() const
Definition Object.h:81
static ObjectGuid GetGUID(Object const *o)
Definition Object.h:78
uint32 GetQuestId() const
Definition QuestDef.h:229
flag96 SpellFamilyFlags
Definition SpellInfo.h:357
Unit * GetCaster() const
HookList< EffectHandler > OnEffectHit
void DoMeleeAttackIfReady()
Definition UnitAI.cpp:54
SpellCastResult DoCastVictim(uint32 spellId, CastSpellExtraArgs const &args={})
Definition UnitAI.cpp:166
SpellCastResult DoCast(uint32 spellId)
Definition UnitAI.cpp:106
Definition Unit.h:769
NPCFlags GetNpcFlags() const
Definition Unit.h:1095
void SetFaction(uint32 faction) override
Definition Unit.h:974
virtual void SetPvP(bool state)
Definition Unit.cpp:11956
MotionMaster * GetMotionMaster()
Definition Unit.h:1667
void SetHealth(uint32 val)
Definition Unit.cpp:9361
void SetFacingToObject(WorldObject const *object, bool force=true, uint32 movementId=EVENT_FACE)
Definition Unit.cpp:13259
bool Attack(Unit *victim, bool meleeAttack)
Definition Unit.cpp:5535
uint32 GetFaction() const override
Definition Unit.h:973
void RemoveAurasDueToSpell(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, uint8 reqEffMask=0, AuraRemoveMode removeMode=AURA_REMOVE_BY_DEFAULT)
Definition Unit.cpp:3784
uint32 CountPctFromMaxHealth(int32 pct) const
Definition Unit.h:922
void SetStandState(UnitStandStateType state)
Definition Unit.cpp:10363
void SetUnitFlag(UnitFlags flags)
Definition Unit.h:954
void ReplaceAllNpcFlags(NPCFlags flags)
Definition Unit.h:1099
bool IsInCombat() const
Definition Unit.h:1144
void GetGameObjectListWithEntryInGrid(Container &gameObjectContainer, uint32 entry, float maxSearchRange=250.0f) const
Definition Object.cpp:3133
SpellCastResult CastSpell(CastSpellTargetArg const &targets, uint32 spellId, CastSpellExtraArgs const &args={ })
Definition Object.cpp:2832
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 * FindNearestCreature(uint32 entry, float range, bool alive=true) const
Definition Object.cpp:2099
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
bool IsFriendlyTo(WorldObject const *target) const
Definition Object.cpp:2801
static bool ValidateSpellInfo(std::initializer_list< uint32 > spellIds)
CreatureAI * GetAI(Creature *creature) const override
CreatureAI * GetAI(Creature *creature) const override
CreatureAI * GetAI(Creature *creature) const override
CreatureAI * GetAI(Creature *creature) const override
CreatureAI * GetAI(Creature *creature) const override
bool Validate(SpellInfo const *) override
PrepareSpellScript(spell_azuremyst_isle_cast_fishing_net)
void AfterApply(AuraEffect const *, AuraEffectHandleModes)
PrepareAuraScript(spell_azuremyst_isle_shadow_of_the_forest_creature)
void AfterRemove(AuraEffect const *, AuraEffectHandleModes)
void AfterApply(AuraEffect const *, AuraEffectHandleModes)
PrepareAuraScript(spell_azuremyst_isle_shadow_of_the_forest_player)
void PeriodicTick(AuraEffect const *)
PrepareAuraScript(spell_inoculate_nestlewood)
TC_GAME_API Player * GetPlayer(Map const *, ObjectGuid const &guid)
TC_GAME_API Creature * GetCreature(WorldObject const &u, ObjectGuid const &guid)
static void VisitWorldObjects(WorldObject const *obj, T &visitor, float radius, bool dont_load=true)
Definition CellImpl.h:180
void Start(bool isActiveAttacker=true, ObjectGuid playerGUID=ObjectGuid::Empty, Quest const *quest=nullptr, bool instantRespawn=false, bool canLoopPath=false)
virtual void UpdateEscortAI(uint32 diff)
void LoadPath(uint32 pathId)
Player * GetPlayerForEscort()
void SpellHit(WorldObject *caster, SpellInfo const *spellInfo) override
bool OnGossipSelect(Player *player, uint32, uint32) override
void UpdateAI(uint32 diff) override
void JustEngagedWith(Unit *) override
void UpdateEscortAI(uint32 diff) override
void OnQuestAccept(Player *player, Quest const *quest) override
void WaypointReached(uint32 waypointId, uint32) override
void JustEngagedWith(Unit *who) override
@ SPELL_IRRIDATION
@ SPELL_STUNNED
Position const SparkPos
@ SPELL_FISHED_UP_RED_SNAPPER
@ SPELL_FISHED_UP_MURLOC
@ QUEST_A_CRY_FOR_HELP
@ EVENT_COWLEN_TALK
@ EVENT_START_ESCORT
@ PATH_ESCORT_MAGWIN
@ EVENT_ACCEPT_QUEST
void AddSC_azuremyst_isle()
@ QUEST_TREES_COMPANY
@ SPELL_TREE_DISGUISE
@ SPELL_SHADOW_OF_THE_FOREST_SI_DND