TrinityCore
Loading...
Searching...
No Matches
lunar_festival.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 "GameObject.h"
19#include "ScriptMgr.h"
20#include "MotionMaster.h"
21#include "ObjectAccessor.h"
22#include "Player.h"
23#include "ScriptedCreature.h"
24#include "SpellInfo.h"
25#include "SpellMgr.h"
26#include "SpellScript.h"
27#include "TemporarySummon.h"
28
30{
31 NPC_OMEN = 15467,
45
59
67
81
84};
85
86Position omenSummonPos = {7558.993f, -2839.999f, 450.0214f, 4.46f};
87
88struct npc_firework : public ScriptedAI
89{
90 npc_firework(Creature* creature) : ScriptedAI(creature) { }
91
92 bool isCluster()
93 {
94 switch (me->GetEntry())
95 {
108 return false;
109 case NPC_CLUSTER_BLUE:
112 case NPC_CLUSTER_RED:
122 default:
123 return true;
124 }
125 }
126
128 {
129 GameObject* launcher = nullptr;
130
131 if (isCluster())
132 {
137
138 if (launcher1)
139 launcher = launcher1;
140 else if (launcher2)
141 launcher = launcher2;
142 else if (launcher3)
143 launcher = launcher3;
144 else if (launcher4)
145 launcher = launcher4;
146 }
147 else
148 {
152
153 if (launcher1)
154 launcher = launcher1;
155 else if (launcher2)
156 launcher = launcher2;
157 else if (launcher3)
158 launcher = launcher3;
159 }
160
161 return launcher;
162 }
163
165 {
166 switch (entry)
167 {
169 return SPELL_ROCKET_BLUE;
171 return SPELL_ROCKET_GREEN;
173 return SPELL_ROCKET_PURPLE;
174 case NPC_FIREWORK_RED:
175 return SPELL_ROCKET_RED;
177 return SPELL_ROCKET_YELLOW;
179 return SPELL_ROCKET_WHITE;
192 default:
193 return 0;
194 }
195 }
196
198 {
199 uint32 spellId = 0;
200
201 switch (me->GetEntry())
202 {
203 case NPC_CLUSTER_BLUE:
205 break;
208 break;
211 break;
212 case NPC_CLUSTER_RED:
214 break;
217 break;
220 break;
223 break;
226 break;
229 break;
232 break;
235 break;
238 break;
241 break;
242 }
243
244 SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellId);
245
246 if (spellInfo && spellInfo->GetEffect(EFFECT_0).Effect == SPELL_EFFECT_SUMMON_OBJECT_WILD)
247 return spellInfo->GetEffect(EFFECT_0).MiscValue;
248
249 return 0;
250 }
251
252 void Reset() override
253 {
254 if (GameObject* launcher = FindNearestLauncher())
255 {
256 launcher->SendCustomAnim(ANIM_GO_LAUNCH_FIREWORK);
257 me->SetOrientation(launcher->GetOrientation() + float(M_PI) / 2);
258 }
259 else
260 return;
261
262 if (isCluster())
263 {
264 // Check if we are near Elune'ara lake south, if so try to summon Omen or a minion
265 if (me->GetZoneId() == ZONE_MOONGLADE)
266 {
268 {
269 switch (urand(0, 9))
270 {
271 case 0:
272 case 1:
273 case 2:
274 case 3:
275 if (Creature* minion = me->SummonCreature(NPC_MINION_OF_OMEN, me->GetPositionX()+frand(-5.0f, 5.0f), me->GetPositionY()+frand(-5.0f, 5.0f), me->GetPositionZ(), 0.0f, TEMPSUMMON_CORPSE_TIMED_DESPAWN, 20s))
276 minion->AI()->AttackStart(me->SelectNearestPlayer(20.0f));
277 break;
278 case 9:
280 break;
281 }
282 }
283 }
284 if (me->GetEntry() == NPC_CLUSTER_ELUNE)
286
287 float displacement = 0.7f;
288 for (uint8 i = 0; i < 4; i++)
289 me->SummonGameObject(GetFireworkGameObjectId(), me->GetPositionX() + (i % 2 == 0 ? displacement : -displacement), me->GetPositionY() + (i > 1 ? displacement : -displacement), me->GetPositionZ() + 4.0f, me->GetOrientation(), QuaternionData(), 1s);
290 }
291 else
292 //me->CastSpell(me, GetFireworkSpell(me->GetEntry()), true);
294 }
295};
296
297/*####
298# npc_omen
299####*/
300
315
316struct npc_omen : public ScriptedAI
317{
318 npc_omen(Creature* creature) : ScriptedAI(creature)
319 {
320 me->SetImmuneToPC(true);
321 me->GetMotionMaster()->MovePoint(1, 7549.977f, -2855.137f, 456.9678f);
322 }
323
325
326 void MovementInform(uint32 type, uint32 pointId) override
327 {
328 if (type != POINT_MOTION_TYPE)
329 return;
330
331 if (pointId == 1)
332 {
334 me->SetImmuneToPC(false);
335 if (Player* player = me->SelectNearestPlayer(40.0f))
336 AttackStart(player);
337 }
338 }
339
340 void JustEngagedWith(Unit* /*attacker*/) override
341 {
342 events.Reset();
345 }
346
347 void JustDied(Unit* /*killer*/) override
348 {
350 }
351
352 void SpellHit(WorldObject* /*caster*/, SpellInfo const* spellInfo) override
353 {
354 if (spellInfo->Id == SPELL_ELUNE_CANDLE)
355 {
358
360 }
361 }
362
363 void UpdateAI(uint32 diff) override
364 {
365 if (!UpdateVictim())
366 return;
367
368 events.Update(diff);
369
370 switch (events.ExecuteEvent())
371 {
375 break;
380 break;
381 }
382
384 }
385};
386
388{
389 npc_giant_spotlight(Creature* creature) : ScriptedAI(creature) { }
390
392
393 void Reset() override
394 {
395 events.Reset();
397 }
398
399 void UpdateAI(uint32 diff) override
400 {
401 events.Update(diff);
402
404 {
406 trap->RemoveFromWorld();
407
409 trap->RemoveFromWorld();
410
411 if (Creature* omen = me->FindNearestCreature(NPC_OMEN, 5.0f, false))
412 omen->DespawnOrUnsummon();
413
415 }
416 }
417};
418
427
428// 26374 - Elune's Candle
430{
432
444
445 void HandleScript(SpellEffIndex /*effIndex*/)
446 {
447 uint32 spellId = 0;
448
449 if (GetHitUnit()->GetEntry() == NPC_OMEN)
450 {
451 switch (urand(0, 3))
452 {
453 case 0:
455 break;
456 case 1:
458 break;
459 case 2:
461 break;
462 case 3:
464 break;
465 }
466 }
467 else
469
470 GetCaster()->CastSpell(GetHitUnit(), spellId, true);
471 }
472
477};
478
483
484// 26393 - Elune's Blessing
504
#define M_PI
Definition Common.h:72
uint8_t uint8
Definition Define.h:135
uint32_t uint32
Definition Define.h:133
@ POINT_MOTION_TYPE
@ TEMPSUMMON_CORPSE_TIMED_DESPAWN
float frand(float min, float max)
Definition Random.cpp:55
uint32 urand(uint32 min, uint32 max)
Definition Random.cpp:42
#define RegisterCreatureAI(ai_name)
Definition ScriptMgr.h:1139
#define RegisterSpellScript(spell_script)
Definition ScriptMgr.h:1128
GameObject * GetClosestGameObjectWithEntry(WorldObject *source, uint32 entry, float maxSearchRange, bool spawnedOnly=true)
SpellEffIndex
@ EFFECT_1
@ EFFECT_0
@ SPELL_EFFECT_DUMMY
@ SPELL_EFFECT_SCRIPT_EFFECT
@ SPELL_EFFECT_SUMMON_OBJECT_WILD
#define sSpellMgr
Definition SpellMgr.h:738
#define SpellEffectFn(F, I, N)
bool UpdateVictim()
Creature *const me
Definition CreatureAI.h:82
void SetHomePosition(float x, float y, float z, float o)
Definition Creature.h:293
void SetImmuneToPC(bool apply) override
Definition Creature.h:129
void DespawnOrUnsummon(Milliseconds timeToDespawn=0s, Seconds forceRespawnTime=0s)
void Update(uint32 time)
Definition EventMap.h:67
EventId ExecuteEvent()
Definition EventMap.cpp:73
void RescheduleEvent(EventId eventId, Milliseconds time, GroupIndex group=0u, PhaseIndex phase=0u)
Definition EventMap.cpp:52
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={})
uint32 GetEntry() const
Definition Object.h:81
SpellEffects Effect
Definition SpellInfo.h:210
uint32 Id
Definition SpellInfo.h:289
SpellEffectInfo const & GetEffect(SpellEffIndex index) const
Definition SpellInfo.h:483
Unit * GetCaster() const
Unit * GetHitUnit() const
HookList< EffectHandler > OnEffectHitTarget
void DoMeleeAttackIfReady()
Definition UnitAI.cpp:54
SpellCastResult DoCastVictim(uint32 spellId, CastSpellExtraArgs const &args={})
Definition UnitAI.cpp:166
Unit * SelectTarget(SelectTargetMethod targetType, uint32 offset=0, float dist=0.0f, bool playerOnly=false, bool withTank=true, int32 aura=0)
Definition UnitAI.cpp:96
SpellCastResult DoCast(uint32 spellId)
Definition UnitAI.cpp:106
Definition Unit.h:769
MotionMaster * GetMotionMaster()
Definition Unit.h:1667
bool HasAura(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, ObjectGuid itemCasterGUID=ObjectGuid::Empty, uint8 reqEffMask=0) const
Definition Unit.cpp:4535
void RemoveAurasDueToSpell(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, uint8 reqEffMask=0, AuraRemoveMode removeMode=AURA_REMOVE_BY_DEFAULT)
Definition Unit.cpp:3784
GameObject * FindNearestGameObject(uint32 entry, float range, bool spawnedOnly=true) const
Definition Object.cpp:2121
Player * SelectNearestPlayer(float distance) const
Definition Object.cpp:2161
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
float GetDistance2d(WorldObject const *obj) const
Definition Object.cpp:1141
GameObject * SummonGameObject(uint32 entry, Position const &pos, QuaternionData const &rot, Seconds respawnTime, GOSummonType summonType=GO_SUMMON_TIMED_OR_CORPSE_DESPAWN)
Definition Object.cpp:2015
Creature * FindNearestCreature(uint32 entry, float range, bool alive=true) const
Definition Object.cpp:2099
uint32 GetZoneId() const
Definition Object.h:373
static bool ValidateSpellInfo(std::initializer_list< uint32 > spellIds)
PrepareSpellScript(spell_lunar_festival_elune_candle)
bool Validate(SpellInfo const *) override
PrepareSpellScript(spell_lunar_festival_elunes_blessing)
bool Validate(SpellInfo const *) override
ElunesBlessing
@ SPELL_ELUNES_BLESSING_QUEST_CREDIT
Fireworks
@ SPELL_ROCKET_BIG_RED
@ ANIM_GO_LAUNCH_FIREWORK
@ NPC_FIREWORK_BIG_YELLOW
@ NPC_FIREWORK_BIG_WHITE
@ NPC_FIREWORK_BIG_GREEN
@ NPC_FIREWORK_GREEN
@ NPC_CLUSTER_RED
@ NPC_FIREWORK_BIG_RED
@ ZONE_MOONGLADE
@ SPELL_ROCKET_YELLOW
@ GO_CLUSTER_LAUNCHER_1
@ GO_CLUSTER_LAUNCHER_3
@ NPC_CLUSTER_WHITE
@ GO_FIREWORK_LAUNCHER_2
@ GO_FIREWORK_LAUNCHER_1
@ NPC_FIREWORK_BIG_PURPLE
@ NPC_CLUSTER_BIG_YELLOW
@ NPC_CLUSTER_PURPLE
@ NPC_OMEN
@ NPC_CLUSTER_YELLOW
@ NPC_FIREWORK_WHITE
@ GO_CLUSTER_LAUNCHER_2
@ NPC_CLUSTER_BIG_WHITE
@ NPC_CLUSTER_GREEN
@ NPC_FIREWORK_RED
@ NPC_FIREWORK_PURPLE
@ NPC_FIREWORK_BIG_BLUE
@ NPC_CLUSTER_BIG_PURPLE
@ SPELL_ROCKET_BIG_WHITE
@ SPELL_ROCKET_RED
@ SPELL_LUNAR_FORTUNE
@ NPC_FIREWORK_YELLOW
@ GO_CLUSTER_LAUNCHER_4
@ NPC_CLUSTER_BIG_GREEN
@ SPELL_ROCKET_PURPLE
@ SPELL_ROCKET_BLUE
@ NPC_CLUSTER_BLUE
@ SPELL_ROCKET_BIG_YELLOW
@ NPC_MINION_OF_OMEN
@ SPELL_ROCKET_WHITE
@ SPELL_ROCKET_BIG_BLUE
@ NPC_FIREWORK_BLUE
@ SPELL_ROCKET_GREEN
@ SPELL_ROCKET_BIG_GREEN
@ NPC_CLUSTER_BIG_BLUE
@ NPC_CLUSTER_BIG_RED
@ GO_FIREWORK_LAUNCHER_3
@ SPELL_ROCKET_BIG_PURPLE
@ NPC_CLUSTER_ELUNE
void AddSC_event_lunar_festival()
Position omenSummonPos
@ SPELL_OMEN_SUMMON_SPOTLIGHT
@ SPELL_ELUNE_CANDLE
@ EVENT_DESPAWN
@ SPELL_OMEN_CLEAVE
@ GO_ELUNE_TRAP_1
@ EVENT_CAST_STARFALL
@ GO_ELUNE_TRAP_2
@ SPELL_OMEN_STARFALL
@ EVENT_CAST_CLEAVE
EluneCandle
@ SPELL_ELUNE_CANDLE_OMEN_HAND_R
@ SPELL_ELUNE_CANDLE_NORMAL
@ SPELL_ELUNE_CANDLE_OMEN_HEAD
@ SPELL_ELUNE_CANDLE_OMEN_CHEST
@ SPELL_ELUNE_CANDLE_OMEN_HAND_L
float GetPositionZ() const
Definition Position.h:81
float GetOrientation() const
Definition Position.h:82
void SetOrientation(float orientation)
Definition Position.h:74
float GetPositionX() const
Definition Position.h:79
void GetPosition(float &x, float &y) const
Definition Position.h:84
float GetPositionY() const
Definition Position.h:80
void AttackStart(Unit *) override
GameObject * FindNearestLauncher()
uint32 GetFireworkGameObjectId()
uint32 GetFireworkSpell(uint32 entry)
void Reset() override
npc_firework(Creature *creature)
npc_giant_spotlight(Creature *creature)
void Reset() override
void UpdateAI(uint32 diff) override
void JustDied(Unit *) override
void SpellHit(WorldObject *, SpellInfo const *spellInfo) override
void MovementInform(uint32 type, uint32 pointId) override
void JustEngagedWith(Unit *) override
npc_omen(Creature *creature)
EventMap events
void UpdateAI(uint32 diff) override