Project SkyFire Core
SkyFire 5.4.8 server core API documentation
Toggle main menu visibility
Loading...
Searching...
No Matches
pet_dk.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
/*
7
* Ordered alphabetically using scriptname.
8
* Scriptnames of files in this file should be prefixed with "npc_pet_dk_".
9
*/
10
11
#include "
ScriptMgr.h
"
12
#include "
ScriptedCreature.h
"
13
#include "
CombatAI.h
"
14
#include "
Cell.h
"
15
#include "
CellImpl.h
"
16
#include "
GridNotifiers.h
"
17
#include "
GridNotifiersImpl.h
"
18
19
enum
DeathKnightSpells
20
{
21
SPELL_DK_SUMMON_GARGOYLE_1
= 49206,
22
SPELL_DK_SUMMON_GARGOYLE_2
= 50514,
23
SPELL_DK_DISMISS_GARGOYLE
= 50515,
24
SPELL_DK_SANCTUARY
= 54661
25
};
26
27
class
npc_pet_dk_ebon_gargoyle
:
public
CreatureScript
28
{
29
public
:
30
npc_pet_dk_ebon_gargoyle
() :
CreatureScript
(
"npc_pet_dk_ebon_gargoyle"
) { }
31
32
struct
npc_pet_dk_ebon_gargoyleAI
:
CasterAI
33
{
34
npc_pet_dk_ebon_gargoyleAI
(
Creature
* creature) :
CasterAI
(creature) { }
35
36
void
InitializeAI
()
OVERRIDE
37
{
38
CasterAI::InitializeAI
();
39
uint64
ownerGuid =
me
->GetOwnerGUID();
40
if
(!ownerGuid)
41
return
;
42
43
// Not needed to be despawned now
44
_despawnTimer
= 0;
45
// Find victim of Summon Gargoyle spell
46
std::list<Unit*> targets;
47
Skyfire::AnyUnfriendlyUnitInObjectRangeCheck
u_check(
me
,
me
, 30.0f);
48
Skyfire::UnitListSearcher<Skyfire::AnyUnfriendlyUnitInObjectRangeCheck>
searcher(
me
, targets, u_check);
49
me
->VisitNearbyObject(30.0f, searcher);
50
for
(std::list<Unit*>::const_iterator iter = targets.begin(); iter != targets.end(); ++iter)
51
if
((*iter)->GetAura(
SPELL_DK_SUMMON_GARGOYLE_1
, ownerGuid))
52
{
53
me
->Attack((*iter),
false
);
54
break
;
55
}
56
}
57
58
void
JustDied
(
Unit
*
/*killer*/
)
OVERRIDE
59
{
60
// Stop Feeding Gargoyle when it dies
61
if
(
Unit
* owner =
me
->GetOwner())
62
owner->RemoveAurasDueToSpell(
SPELL_DK_SUMMON_GARGOYLE_2
);
63
}
64
65
// Fly away when dismissed
66
void
SpellHit
(
Unit
* source,
SpellInfo
const
* spell)
OVERRIDE
67
{
68
if
(spell->Id !=
SPELL_DK_DISMISS_GARGOYLE
|| !
me
->IsAlive())
69
return
;
70
71
Unit
* owner =
me
->GetOwner();
72
if
(!owner || owner != source)
73
return
;
74
75
// Stop Fighting
76
me
->ApplyModFlag(
UNIT_FIELD_FLAGS
,
UNIT_FLAG_NON_ATTACKABLE
,
true
);
77
78
// Sanctuary
79
me
->CastSpell(
me
,
SPELL_DK_SANCTUARY
,
true
);
80
me
->SetReactState(
REACT_PASSIVE
);
81
83
// Fly Away
84
me
->SetCanFly(
true
);
85
me
->SetSpeed(
MOVE_FLIGHT
, 0.75f,
true
);
86
me
->SetSpeed(
MOVE_RUN
, 0.75f,
true
);
87
float
x =
me
->GetPositionX() + 20 * std::cos(
me
->GetOrientation());
88
float
y =
me
->GetPositionY() + 20 * std::sin(
me
->GetOrientation());
89
float
z =
me
->GetPositionZ() + 40;
90
me
->GetMotionMaster()->Clear(
false
);
91
me
->GetMotionMaster()->MovePoint(0, x, y, z);
92
93
// Despawn as soon as possible
94
_despawnTimer
= 4 *
IN_MILLISECONDS
;
95
}
96
97
void
UpdateAI
(
uint32
diff)
OVERRIDE
98
{
99
if
(
_despawnTimer
> 0)
100
{
101
if
(
_despawnTimer
> diff)
102
_despawnTimer
-= diff;
103
else
104
me
->DespawnOrUnsummon();
105
return
;
106
}
107
108
CasterAI::UpdateAI
(diff);
109
}
110
111
private
:
112
uint32
_despawnTimer
;
113
};
114
115
CreatureAI
*
GetAI
(
Creature
* creature)
const
OVERRIDE
116
{
117
return
new
npc_pet_dk_ebon_gargoyleAI
(creature);
118
}
119
};
120
121
void
AddSC_deathknight_pet_scripts
()
122
{
123
new
npc_pet_dk_ebon_gargoyle
();
124
}
Cell.h
CellImpl.h
CombatAI.h
IN_MILLISECONDS
@ IN_MILLISECONDS
Definition
Common.h:125
uint32
std::uint32_t uint32
Definition
Define.h:77
OVERRIDE
#define OVERRIDE
Definition
Define.h:60
uint64
std::uint64_t uint64
Definition
Define.h:76
GridNotifiers.h
GridNotifiersImpl.h
ScriptMgr.h
ScriptedCreature.h
MOVE_FLIGHT
@ MOVE_FLIGHT
Definition
Unit.h:561
MOVE_RUN
@ MOVE_RUN
Definition
Unit.h:556
REACT_PASSIVE
@ REACT_PASSIVE
Definition
Unit.h:1156
UNIT_FLAG_NON_ATTACKABLE
@ UNIT_FLAG_NON_ATTACKABLE
Definition
Unit.h:626
UNIT_FIELD_FLAGS
@ UNIT_FIELD_FLAGS
Definition
UpdateFields.h:82
CasterAI::InitializeAI
void InitializeAI() OVERRIDE
Definition
CombatAI.cpp:111
CasterAI::UpdateAI
void UpdateAI(uint32 diff) OVERRIDE
== Triggered Actions Requested ==================
Definition
CombatAI.cpp:147
CasterAI::CasterAI
CasterAI(Creature *c)
Definition
CombatAI.h:46
CreatureAI
Definition
CreatureAI.h:54
CreatureAI::me
Creature *const me
Definition
CreatureAI.h:56
Creature
Definition
Creature.h:427
CreatureScript::CreatureScript
CreatureScript(const char *name)
Definition
ScriptMgr.cpp:1436
Skyfire::AnyUnfriendlyUnitInObjectRangeCheck
Definition
GridNotifiers.h:796
SpellInfo
Definition
SpellInfo.h:158
Unit
Definition
Unit.h:1367
npc_pet_dk_ebon_gargoyle
Definition
pet_dk.cpp:28
npc_pet_dk_ebon_gargoyle::GetAI
CreatureAI * GetAI(Creature *creature) const OVERRIDE
Definition
pet_dk.cpp:115
npc_pet_dk_ebon_gargoyle::npc_pet_dk_ebon_gargoyle
npc_pet_dk_ebon_gargoyle()
Definition
pet_dk.cpp:30
DeathKnightSpells
DeathKnightSpells
Definition
pet_dk.cpp:20
SPELL_DK_SUMMON_GARGOYLE_2
@ SPELL_DK_SUMMON_GARGOYLE_2
Definition
pet_dk.cpp:22
SPELL_DK_SUMMON_GARGOYLE_1
@ SPELL_DK_SUMMON_GARGOYLE_1
Definition
pet_dk.cpp:21
SPELL_DK_SANCTUARY
@ SPELL_DK_SANCTUARY
Definition
pet_dk.cpp:24
SPELL_DK_DISMISS_GARGOYLE
@ SPELL_DK_DISMISS_GARGOYLE
Definition
pet_dk.cpp:23
AddSC_deathknight_pet_scripts
void AddSC_deathknight_pet_scripts()
Definition
pet_dk.cpp:121
Skyfire::UnitListSearcher
Definition
GridNotifiers.h:397
npc_pet_dk_ebon_gargoyle::npc_pet_dk_ebon_gargoyleAI
Definition
pet_dk.cpp:33
npc_pet_dk_ebon_gargoyle::npc_pet_dk_ebon_gargoyleAI::SpellHit
void SpellHit(Unit *source, SpellInfo const *spell) OVERRIDE
Definition
pet_dk.cpp:66
npc_pet_dk_ebon_gargoyle::npc_pet_dk_ebon_gargoyleAI::InitializeAI
void InitializeAI() OVERRIDE
Definition
pet_dk.cpp:36
npc_pet_dk_ebon_gargoyle::npc_pet_dk_ebon_gargoyleAI::npc_pet_dk_ebon_gargoyleAI
npc_pet_dk_ebon_gargoyleAI(Creature *creature)
Definition
pet_dk.cpp:34
npc_pet_dk_ebon_gargoyle::npc_pet_dk_ebon_gargoyleAI::JustDied
void JustDied(Unit *) OVERRIDE
Definition
pet_dk.cpp:58
npc_pet_dk_ebon_gargoyle::npc_pet_dk_ebon_gargoyleAI::_despawnTimer
uint32 _despawnTimer
Definition
pet_dk.cpp:112
npc_pet_dk_ebon_gargoyle::npc_pet_dk_ebon_gargoyleAI::UpdateAI
void UpdateAI(uint32 diff) OVERRIDE
== Triggered Actions Requested ==================
Definition
pet_dk.cpp:97
src
server
scripts
Pet
pet_dk.cpp
Generated on
for Project SkyFire Core by
1.17.0