Project SkyFire Core
SkyFire 5.4.8 server core API documentation
Toggle main menu visibility
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
21
enum
Omen
22
{
23
NPC_OMEN
= 15467,
24
25
SPELL_OMEN_CLEAVE
= 15284,
26
SPELL_OMEN_STARFALL
= 26540,
27
SPELL_OMEN_SUMMON_SPOTLIGHT
= 26392,
28
SPELL_ELUNE_CANDLE
= 26374,
29
30
GO_ELUNE_TRAP_1
= 180876,
31
GO_ELUNE_TRAP_2
= 180877,
32
33
EVENT_CAST_CLEAVE
= 1,
34
EVENT_CAST_STARFALL
= 2,
35
EVENT_DESPAWN
= 3,
36
};
37
38
class
npc_omen
:
public
CreatureScript
39
{
40
public
:
41
npc_omen
() :
CreatureScript
(
"npc_omen"
) { }
42
43
struct
npc_omenAI
:
public
ScriptedAI
44
{
45
npc_omenAI
(
Creature
* creature) :
ScriptedAI
(creature)
46
{
47
me
->SetFlag(
UNIT_FIELD_FLAGS
,
UNIT_FLAG_IMMUNE_TO_PC
);
48
me
->GetMotionMaster()->MovePoint(1, 7549.977f, -2855.137f, 456.9678f);
49
}
50
51
EventMap
events
;
52
53
void
MovementInform
(
uint32
type,
uint32
pointId)
OVERRIDE
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());
61
me
->RemoveFlag(
UNIT_FIELD_FLAGS
,
UNIT_FLAG_IMMUNE_TO_PC
);
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
{
76
DoCast
(
SPELL_OMEN_SUMMON_SPOTLIGHT
);
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
90
void
UpdateAI
(
uint32
diff)
OVERRIDE
91
{
92
if
(!
UpdateVictim
())
93
return
;
94
95
events
.Update(diff);
96
97
switch
(
events
.ExecuteEvent())
98
{
99
case
EVENT_CAST_CLEAVE
:
100
DoCastVictim
(
SPELL_OMEN_CLEAVE
);
101
events
.ScheduleEvent(
EVENT_CAST_CLEAVE
, std::rand() % 10000 + 8000);
102
break
;
103
case
EVENT_CAST_STARFALL
:
104
if
(
Unit
* target =
SelectTarget
(
SELECT_TARGET_RANDOM
, 0))
105
DoCast
(target,
SPELL_OMEN_STARFALL
);
106
events
.ScheduleEvent(
EVENT_CAST_STARFALL
, std::rand() % 16000 + 14000);
107
break
;
108
}
109
110
DoMeleeAttackIfReady
();
111
}
112
};
113
114
CreatureAI
*
GetAI
(
Creature
* creature)
const
OVERRIDE
115
{
116
return
new
npc_omenAI
(creature);
117
}
118
};
119
120
class
npc_giant_spotlight
:
public
CreatureScript
121
{
122
public
:
123
npc_giant_spotlight
() :
CreatureScript
(
"npc_giant_spotlight"
) { }
124
125
struct
npc_giant_spotlightAI
:
public
ScriptedAI
126
{
127
npc_giant_spotlightAI
(
Creature
* creature) :
ScriptedAI
(creature) { }
128
129
EventMap
events
;
130
131
void
Reset
()
OVERRIDE
132
{
133
events
.Reset();
134
events
.ScheduleEvent(
EVENT_DESPAWN
, 5*
MINUTE
*
IN_MILLISECONDS
);
135
}
136
137
void
UpdateAI
(
uint32
diff)
OVERRIDE
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
157
CreatureAI
*
GetAI
(
Creature
* creature)
const
OVERRIDE
158
{
159
return
new
npc_giant_spotlightAI
(creature);
160
}
161
};
162
163
void
AddSC_moonglade
()
164
{
165
new
npc_omen
();
166
new
npc_giant_spotlight
();
167
}
Cell.h
CellImpl.h
IN_MILLISECONDS
@ IN_MILLISECONDS
Definition
Common.h:125
MINUTE
@ MINUTE
Definition
Common.h:119
uint32
std::uint32_t uint32
Definition
Define.h:77
OVERRIDE
#define OVERRIDE
Definition
Define.h:60
GridNotifiers.h
GridNotifiersImpl.h
POINT_MOTION_TYPE
@ POINT_MOTION_TYPE
Definition
MotionMaster.h:33
Player.h
ScriptMgr.h
ScriptedCreature.h
ScriptedEscortAI.h
ScriptedGossip.h
SpellInfo.h
UNIT_FLAG_IMMUNE_TO_PC
@ UNIT_FLAG_IMMUNE_TO_PC
Definition
Unit.h:633
SELECT_TARGET_RANDOM
@ SELECT_TARGET_RANDOM
Definition
UnitAI.h:23
UNIT_FIELD_FLAGS
@ UNIT_FIELD_FLAGS
Definition
UpdateFields.h:82
CreatureAI
Definition
CreatureAI.h:54
CreatureAI::UpdateVictim
bool UpdateVictim()
Definition
CreatureAI.cpp:192
Creature
Definition
Creature.h:427
CreatureScript::CreatureScript
CreatureScript(const char *name)
Definition
ScriptMgr.cpp:1436
EventMap
Definition
CreatureAIImpl.h:304
GameObject
Definition
GameObject.h:629
Player
Definition
Player.h:1289
SpellInfo
Definition
SpellInfo.h:158
UnitAI::DoMeleeAttackIfReady
void DoMeleeAttackIfReady()
Definition
UnitAI.cpp:28
UnitAI::DoCast
void DoCast(uint32 spellId)
Definition
UnitAI.cpp:110
UnitAI::SelectTarget
Unit * SelectTarget(SelectAggroTarget targetType, uint32 position=0, float dist=0.0f, bool playerOnly=false, int32 aura=0)
Definition
UnitAI.cpp:66
UnitAI::DoCastVictim
void DoCastVictim(uint32 spellId, bool triggered=false)
Definition
UnitAI.cpp:168
Unit
Definition
Unit.h:1367
npc_giant_spotlight
Definition
zone_moonglade.cpp:121
npc_giant_spotlight::GetAI
CreatureAI * GetAI(Creature *creature) const OVERRIDE
Definition
zone_moonglade.cpp:157
npc_giant_spotlight::npc_giant_spotlight
npc_giant_spotlight()
Definition
zone_moonglade.cpp:123
npc_omen
Definition
zone_moonglade.cpp:39
npc_omen::GetAI
CreatureAI * GetAI(Creature *creature) const OVERRIDE
Definition
zone_moonglade.cpp:114
npc_omen::npc_omen
npc_omen()
Definition
zone_moonglade.cpp:41
ScriptedAI::me
Creature * me
Definition
ScriptedCreature.h:182
ScriptedAI::ScriptedAI
ScriptedAI(Creature *creature)
Definition
ScriptedCreature.cpp:85
ScriptedAI::AttackStart
void AttackStart(Unit *) OVERRIDE
Definition
ScriptedCreature.cpp:118
npc_giant_spotlight::npc_giant_spotlightAI
Definition
zone_moonglade.cpp:126
npc_giant_spotlight::npc_giant_spotlightAI::events
EventMap events
Definition
zone_moonglade.cpp:129
npc_giant_spotlight::npc_giant_spotlightAI::UpdateAI
void UpdateAI(uint32 diff) OVERRIDE
== Triggered Actions Requested ==================
Definition
zone_moonglade.cpp:137
npc_giant_spotlight::npc_giant_spotlightAI::Reset
void Reset() OVERRIDE
Definition
zone_moonglade.cpp:131
npc_giant_spotlight::npc_giant_spotlightAI::npc_giant_spotlightAI
npc_giant_spotlightAI(Creature *creature)
Definition
zone_moonglade.cpp:127
npc_omen::npc_omenAI
Definition
zone_moonglade.cpp:44
npc_omen::npc_omenAI::npc_omenAI
npc_omenAI(Creature *creature)
Definition
zone_moonglade.cpp:45
npc_omen::npc_omenAI::UpdateAI
void UpdateAI(uint32 diff) OVERRIDE
== Triggered Actions Requested ==================
Definition
zone_moonglade.cpp:90
npc_omen::npc_omenAI::SpellHit
void SpellHit(Unit *, const SpellInfo *spell) OVERRIDE
Definition
zone_moonglade.cpp:79
npc_omen::npc_omenAI::MovementInform
void MovementInform(uint32 type, uint32 pointId) OVERRIDE
Definition
zone_moonglade.cpp:53
npc_omen::npc_omenAI::EnterCombat
void EnterCombat(Unit *) OVERRIDE
Definition
zone_moonglade.cpp:67
npc_omen::npc_omenAI::events
EventMap events
Definition
zone_moonglade.cpp:51
npc_omen::npc_omenAI::JustDied
void JustDied(Unit *) OVERRIDE
Definition
zone_moonglade.cpp:74
EVENT_DESPAWN
@ EVENT_DESPAWN
Definition
zone_azuremyst_isle.cpp:677
Omen
Omen
Definition
zone_moonglade.cpp:22
SPELL_OMEN_SUMMON_SPOTLIGHT
@ SPELL_OMEN_SUMMON_SPOTLIGHT
Definition
zone_moonglade.cpp:27
SPELL_ELUNE_CANDLE
@ SPELL_ELUNE_CANDLE
Definition
zone_moonglade.cpp:28
EVENT_DESPAWN
@ EVENT_DESPAWN
Definition
zone_moonglade.cpp:35
SPELL_OMEN_CLEAVE
@ SPELL_OMEN_CLEAVE
Definition
zone_moonglade.cpp:25
GO_ELUNE_TRAP_1
@ GO_ELUNE_TRAP_1
Definition
zone_moonglade.cpp:30
EVENT_CAST_STARFALL
@ EVENT_CAST_STARFALL
Definition
zone_moonglade.cpp:34
NPC_OMEN
@ NPC_OMEN
Definition
zone_moonglade.cpp:23
GO_ELUNE_TRAP_2
@ GO_ELUNE_TRAP_2
Definition
zone_moonglade.cpp:31
SPELL_OMEN_STARFALL
@ SPELL_OMEN_STARFALL
Definition
zone_moonglade.cpp:26
EVENT_CAST_CLEAVE
@ EVENT_CAST_CLEAVE
Definition
zone_moonglade.cpp:33
AddSC_moonglade
void AddSC_moonglade()
Definition
zone_moonglade.cpp:163
src
server
scripts
Kalimdor
zone_moonglade.cpp
Generated on
for Project SkyFire Core by
1.17.0