TrinityCore
Loading...
Searching...
No Matches
zone_moonglade.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#include "ScriptMgr.h"
19#include "CellImpl.h"
20#include "GridNotifiersImpl.h"
21#include "MotionMaster.h"
22#include "ObjectAccessor.h"
23#include "Player.h"
24#include "ScriptedEscortAI.h"
25#include "ScriptedGossip.h"
26#include "SpellInfo.h"
27#include "TemporarySummon.h"
28
29/*######
30## npc_clintar_spirit
31######*/
32
34{
35 float X;
36 float Y;
37 float Z;
38 float O;
40};
41
43{
44 //pos_x pos_y pos_z orien waitTime
45 {7465.28f, -3115.46f, 439.327f, 0.83f, 4s},
46 {7476.49f, -3101, 443.457f, 0.89f, 0s},
47 {7486.57f, -3085.59f, 439.478f, 1.07f, 0s},
48 {7472.19f, -3085.06f, 443.142f, 3.07f, 0s},
49 {7456.92f, -3085.91f, 438.862f, 3.24f, 0s},
50 {7446.68f, -3083.43f, 438.245f, 2.40f, 0s},
51 {7446.17f, -3080.21f, 439.826f, 1.10f, 6s},
52 {7452.41f, -3085.8f, 438.984f, 5.78f, 0s},
53 {7469.11f, -3084.94f, 443.048f, 6.25f, 0s},
54 {7483.79f, -3085.44f, 439.607f, 6.25f, 0s},
55 {7491.14f, -3090.96f, 439.983f, 5.44f, 0s},
56 {7497.62f, -3098.22f, 436.854f, 5.44f, 0s},
57 {7498.72f, -3113.41f, 434.596f, 4.84f, 0s},
58 {7500.06f, -3122.51f, 434.749f, 5.17f, 0s},
59 {7504.96f, -3131.53f, 434.475f, 4.74f, 0s},
60 {7504.31f, -3133.53f, 435.693f, 3.84f, 6s},
61 {7504.55f, -3133.27f, 435.476f, 0.68f, 15s},
62 {7501.99f, -3126.01f, 434.93f, 1.83f, 0s},
63 {7490.76f, -3114.97f, 434.431f, 2.51f, 0s},
64 {7479.64f, -3105.51f, 431.123f, 1.83f, 0s},
65 {7474.63f, -3086.59f, 428.994f, 1.83f, 2s},
66 {7472.96f, -3074.18f, 427.566f, 1.57f, 0s},
67 {7472.25f, -3063, 428.268f, 1.55f, 0s},
68 {7473.46f, -3054.22f, 427.588f, 0.36f, 0s},
69 {7475.08f, -3053.6f, 428.653f, 0.36f, 6s},
70 {7474.66f, -3053.56f, 428.433f, 3.19f, 4s},
71 {7471.81f, -3058.84f, 427.073f, 4.29f, 0s},
72 {7472.16f, -3064.91f, 427.772f, 4.95f, 0s},
73 {7471.56f, -3085.36f, 428.924f, 4.72f, 0s},
74 {7473.56f, -3093.48f, 429.294f, 5.04f, 0s},
75 {7478.94f, -3104.29f, 430.638f, 5.23f, 0s},
76 {7484.46f, -3109.61f, 432.769f, 5.79f, 0s},
77 {7490.23f, -3111.08f, 434.431f, 0.02f, 0s},
78 {7496.29f, -3108, 434.783f, 1.15f, 0s},
79 {7497.46f, -3100.66f, 436.191f, 1.50f, 0s},
80 {7495.64f, -3093.39f, 438.349f, 2.10f, 0s},
81 {7492.44f, -3086.01f, 440.267f, 1.38f, 0s},
82 {7498.26f, -3076.44f, 440.808f, 0.71f, 0s},
83 {7506.4f, -3067.35f, 443.64f, 0.77f, 0s},
84 {7518.37f, -3057.42f, 445.584f, 0.74f, 0s},
85 {7517.51f, -3056.3f, 444.568f, 2.49f, 4500ms}
86};
87
88Position const AspectRavenSummon = {7472.96f, -3074.18f, 427.566f, 0.0f};
89Position const ClintarSpiritSummon = {7459.2275f, -3122.5632f, 438.9842f, 0.8594f};
90
92{
93 ASPECT_RAVEN = 22915,
94
95 // Texts for JustEngagedWith, the event and the end of the event are missing
97};
98
100{
101public:
102 npc_clintar_spirit() : CreatureScript("npc_clintar_spirit") { }
103
104 CreatureAI* GetAI(Creature* creature) const override
105 {
106 return new npc_clintar_spiritAI(creature);
107 }
108
110 {
111 public:
113 {
114 Initialize();
116 }
117
119 {
120 Step = 0;
121 CurrWP = 0;
122 EventTimer = 0;
124 checkPlayerTimer = 1000;
125 EventOnWait = false;
126 }
127
132
134
136
137 void Reset() override
138 {
139 if (!PlayerGUID)
140 Initialize();
141 }
142
143 void IsSummonedBy(WorldObject* /*summoner*/) override
144 {
145 std::list<Player*> playerOnQuestList;
147 Trinity::PlayerListSearcher<Trinity::AnyPlayerInObjectRangeCheck> searcher(me, playerOnQuestList, checker);
148 Cell::VisitWorldObjects(me, searcher, 5.0f);
149 for (std::list<Player*>::const_iterator itr = playerOnQuestList.begin(); itr != playerOnQuestList.end(); ++itr)
150 {
151 // Check if found player target has active quest
152 if (Player* player = (*itr))
153 {
154 if (player->GetQuestStatus(10965) == QUEST_STATUS_INCOMPLETE)
155 {
156 StartEvent(player);
157 break;
158 }
159 }
160 else
161 break;
162 }
163 }
164
165 void JustDied(Unit* /*killer*/) override
166 {
167 if (!PlayerGUID)
168 return;
169
171 if (player && player->GetQuestStatus(10965) == QUEST_STATUS_INCOMPLETE)
172 {
173 player->FailQuest(10965);
175 Reset();
176 }
177 }
178
179 void EnterEvadeMode(EvadeReason why) override
180 {
182 if (player && player->IsInCombat() && player->getAttackerForHelper())
183 {
185 return;
186 }
188 }
189
190 void StartEvent(Player* player)
191 {
192 if (player && player->GetQuestStatus(10965) == QUEST_STATUS_INCOMPLETE)
193 {
194 for (uint8 i = 0; i < 41; ++i)
195 {
197 }
198 PlayerGUID = player->GetGUID();
199 Start(true, player->GetGUID());
202 }
203 return;
204 }
205
206 void UpdateAI(uint32 diff) override
207 {
208 EscortAI::UpdateAI(diff);
209
210 if (!PlayerGUID)
211 {
213 return;
214 }
215
216 if (!me->IsInCombat() && !EventOnWait)
217 {
218 if (checkPlayerTimer <= diff)
219 {
221 if (player && player->IsInCombat() && player->getAttackerForHelper())
223 checkPlayerTimer = 1000;
224 } else checkPlayerTimer -= diff;
225 }
226
227 if (EventOnWait && EventTimer <= diff)
228 {
230 if (!player || player->GetQuestStatus(10965) == QUEST_STATUS_NONE)
231 {
233 return;
234 }
235
236 switch (CurrWP)
237 {
238 case 0:
239 switch (Step)
240 {
241 case 0:
243 EventTimer = 8000;
244 Step = 1;
245 break;
246 case 1:
247 EventOnWait = false;
248 break;
249 }
250 break;
251 case 6:
252 switch (Step)
253 {
254 case 0:
256 EventTimer = 5000;
257 Step = 1;
258 break;
259 case 1:
261 // Needs text
262 EventOnWait = false;
263 break;
264 }
265 break;
266 case 15:
267 switch (Step)
268 {
269 case 0:
271 EventTimer = 5000;
272 Step = 1;
273 break;
274 case 1:
276 EventOnWait = false;
277 break;
278 }
279 break;
280 case 16:
281 switch (Step)
282 {
283 case 0:
284 // Needs text
285 EventTimer = 15000;
286 Step = 1;
287 break;
288 case 1:
289 EventOnWait = false;
290 break;
291 }
292 break;
293 case 20:
294 switch (Step)
295 {
296 case 0:
298 {
299 AddThreat(me, 10000.0f, mob);
300 mob->AI()->AttackStart(me);
301 }
302 EventTimer = 2000;
303 Step = 1;
304 break;
305 case 1:
306 EventOnWait = false;
307 break;
308 }
309 break;
310 case 24:
311 switch (Step)
312 {
313 case 0:
315 EventTimer = 5000;
316 Step = 1;
317 break;
318 case 1:
320 EventOnWait = false;
321 break;
322 }
323 break;
324 case 25:
325 switch (Step)
326 {
327 case 0:
328 // Needs text
329 EventTimer = 4000;
330 Step = 1;
331 break;
332 case 1:
333 EventOnWait = false;
334 break;
335 }
336 break;
337 case 40:
338 switch (Step)
339 {
340 case 0:
342 // Needs text
343 player->CompleteQuest(10965);
344 EventTimer = 1500;
345 Step = 1;
346 break;
347 case 1:
349 EventTimer = 3000;
350 Step = 2;
351 break;
352 case 2:
353 player->TalkedToCreature(me->GetEntry(), me->GetGUID());
355 Reset();
357 break;
358 }
359 break;
360 default:
361 EventOnWait = false;
362 break;
363 }
364
365 } else if (EventOnWait) EventTimer -= diff;
366 }
367
368 void WaypointReached(uint32 waypointId, uint32 /*pathId*/) override
369 {
370 CurrWP = waypointId;
371 EventTimer = 0;
372 Step = 0;
373 EventOnWait = true;
374 }
375 };
376
377};
378
380{
381 new npc_clintar_spirit();
382}
uint8_t uint8
Definition Define.h:135
uint32_t uint32
Definition Define.h:133
std::chrono::milliseconds Milliseconds
Milliseconds shorthand typedef.
Definition Duration.h:24
@ TEMPSUMMON_CORPSE_TIMED_DESPAWN
@ QUEST_STATUS_INCOMPLETE
Definition QuestDef.h:107
@ QUEST_STATUS_NONE
Definition QuestDef.h:104
@ EMOTE_ONESHOT_BOW
@ EMOTE_ONESHOT_NONE
@ EMOTE_STATE_USE_STANDING_NO_SHEATHE
@ UNIT_FLAG_UNINTERACTIBLE
@ JUST_DIED
Definition Unit.h:212
Creature *const me
Definition CreatureAI.h:82
void setDeathState(DeathState s) override
void SetDisplayId(uint32 modelId) override
CreatureTemplate const * GetCreatureTemplate() const
Definition Creature.h:186
void Clear()
Definition ObjectGuid.h:150
uint32 GetEntry() const
Definition Object.h:81
static ObjectGuid GetGUID(Object const *o)
Definition Object.h:78
void TalkedToCreature(uint32 entry, ObjectGuid guid)
Definition Player.cpp:16306
void CompleteQuest(uint32 quest_id)
Definition Player.cpp:14804
QuestStatus GetQuestStatus(uint32 quest_id) const
Definition Player.cpp:15642
void FailQuest(uint32 quest_id)
Definition Player.cpp:15040
Definition Unit.h:769
Unit * getAttackerForHelper() const
Definition Unit.cpp:5512
void SetEmoteState(Emote emote)
Definition Unit.h:967
bool IsInCombat() const
Definition Unit.h:1144
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
CreatureAI * GetAI(Creature *creature) const override
TC_GAME_API Player * GetPlayer(Map const *, 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)
void AddWaypoint(uint32 id, float x, float y, float z, bool run)
void EnterEvadeMode(EvadeReason=EVADE_REASON_OTHER) override
void UpdateAI(uint32 diff) override
void AttackStart(Unit *) override
void AddThreat(Unit *victim, float amount, Unit *who=nullptr)
Milliseconds waitTime
void EnterEvadeMode(EvadeReason why) override
void WaypointReached(uint32 waypointId, uint32) override
void IsSummonedBy(WorldObject *) override
Position const ClintarSpiritSummon
Waypoint const Clintar_spirit_WP[41]
void AddSC_moonglade()
Position const AspectRavenSummon
ClintarSpirit
@ CLINTAR_SPIRIT_SAY_START
@ ASPECT_RAVEN