Project SkyFire Core
SkyFire 5.4.8 server core API documentation
Loading...
Searching...
No Matches
zone_moonglade.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#include "ScriptMgr.h"
7#include "ScriptedCreature.h"
8#include "ScriptedEscortAI.h"
9#include "ScriptedGossip.h"
10#include "Player.h"
11#include "SpellInfo.h"
12#include "GridNotifiers.h"
13#include "GridNotifiersImpl.h"
14#include "Cell.h"
15#include "CellImpl.h"
16
17/*####
18# npc_omen
19####*/
20
37
39{
40public:
41 npc_omen() : CreatureScript("npc_omen") { }
42
43 struct npc_omenAI : public ScriptedAI
44 {
45 npc_omenAI(Creature* creature) : ScriptedAI(creature)
46 {
48 me->GetMotionMaster()->MovePoint(1, 7549.977f, -2855.137f, 456.9678f);
49 }
50
52
54 {
55 if (type != POINT_MOTION_TYPE)
56 return;
57
58 if (pointId == 1)
59 {
60 me->SetHomePosition(me->GetPositionX(), me->GetPositionY(), me->GetPositionZ(), me->GetOrientation());
62 if (Player* player = me->SelectNearestPlayer(40.0f))
63 AttackStart(player);
64 }
65 }
66
67 void EnterCombat(Unit* /*attacker*/) OVERRIDE
68 {
69 events.Reset();
70 events.ScheduleEvent(EVENT_CAST_CLEAVE, std::rand() % 5000 + 3000);
71 events.ScheduleEvent(EVENT_CAST_STARFALL, std::rand() % 10000 + 8000);
72 }
73
74 void JustDied(Unit* /*killer*/) OVERRIDE
75 {
77 }
78
79 void SpellHit(Unit* /*caster*/, const SpellInfo* spell) OVERRIDE
80 {
81 if (spell->Id == SPELL_ELUNE_CANDLE)
82 {
83 if (me->HasAura(SPELL_OMEN_STARFALL))
84 me->RemoveAurasDueToSpell(SPELL_OMEN_STARFALL);
85
86 events.RescheduleEvent(EVENT_CAST_STARFALL, std::rand() % 16000 + 14000);
87 }
88 }
89
91 {
92 if (!UpdateVictim())
93 return;
94
95 events.Update(diff);
96
97 switch (events.ExecuteEvent())
98 {
101 events.ScheduleEvent(EVENT_CAST_CLEAVE, std::rand() % 10000 + 8000);
102 break;
104 if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0))
106 events.ScheduleEvent(EVENT_CAST_STARFALL, std::rand() % 16000 + 14000);
107 break;
108 }
109
111 }
112 };
113
115 {
116 return new npc_omenAI(creature);
117 }
118};
119
121{
122public:
123 npc_giant_spotlight() : CreatureScript("npc_giant_spotlight") { }
124
126 {
127 npc_giant_spotlightAI(Creature* creature) : ScriptedAI(creature) { }
128
130
132 {
133 events.Reset();
134 events.ScheduleEvent(EVENT_DESPAWN, 5*MINUTE*IN_MILLISECONDS);
135 }
136
138 {
139 events.Update(diff);
140
141 if (events.ExecuteEvent() == EVENT_DESPAWN)
142 {
143 if (GameObject* trap = me->FindNearestGameObject(GO_ELUNE_TRAP_1, 5.0f))
144 trap->RemoveFromWorld();
145
146 if (GameObject* trap = me->FindNearestGameObject(GO_ELUNE_TRAP_2, 5.0f))
147 trap->RemoveFromWorld();
148
149 if (Creature* omen = me->FindNearestCreature(NPC_OMEN, 5.0f, false))
150 omen->DespawnOrUnsummon();
151
152 me->DespawnOrUnsummon();
153 }
154 }
155 };
156
158 {
159 return new npc_giant_spotlightAI(creature);
160 }
161};
162
164{
165 new npc_omen();
167}
@ IN_MILLISECONDS
Definition Common.h:125
@ MINUTE
Definition Common.h:119
std::uint32_t uint32
Definition Define.h:77
#define OVERRIDE
Definition Define.h:60
@ POINT_MOTION_TYPE
@ UNIT_FLAG_IMMUNE_TO_PC
Definition Unit.h:633
@ SELECT_TARGET_RANDOM
Definition UnitAI.h:23
@ UNIT_FIELD_FLAGS
bool UpdateVictim()
CreatureScript(const char *name)
void DoMeleeAttackIfReady()
Definition UnitAI.cpp:28
void DoCast(uint32 spellId)
Definition UnitAI.cpp:110
Unit * SelectTarget(SelectAggroTarget targetType, uint32 position=0, float dist=0.0f, bool playerOnly=false, int32 aura=0)
Definition UnitAI.cpp:66
void DoCastVictim(uint32 spellId, bool triggered=false)
Definition UnitAI.cpp:168
Definition Unit.h:1367
CreatureAI * GetAI(Creature *creature) const OVERRIDE
CreatureAI * GetAI(Creature *creature) const OVERRIDE
Creature * me
ScriptedAI(Creature *creature)
void AttackStart(Unit *) OVERRIDE
void UpdateAI(uint32 diff) OVERRIDE
== Triggered Actions Requested ==================
npc_omenAI(Creature *creature)
void UpdateAI(uint32 diff) OVERRIDE
== Triggered Actions Requested ==================
void SpellHit(Unit *, const SpellInfo *spell) OVERRIDE
void MovementInform(uint32 type, uint32 pointId) OVERRIDE
void EnterCombat(Unit *) OVERRIDE
void JustDied(Unit *) OVERRIDE
@ SPELL_OMEN_SUMMON_SPOTLIGHT
@ SPELL_ELUNE_CANDLE
@ EVENT_DESPAWN
@ SPELL_OMEN_CLEAVE
@ GO_ELUNE_TRAP_1
@ EVENT_CAST_STARFALL
@ NPC_OMEN
@ GO_ELUNE_TRAP_2
@ SPELL_OMEN_STARFALL
@ EVENT_CAST_CLEAVE
void AddSC_moonglade()