Project SkyFire Core
SkyFire 5.4.8 server core API documentation
Toggle main menu visibility
Loading...
Searching...
No Matches
pet_warlock.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_sha_".
9
*/
10
11
#include "
Pet.h
"
12
#include "
ScriptMgr.h
"
13
#include "
ScriptedCreature.h
"
14
15
enum
ShamanSpells
16
{
17
SPELL_WARLOCK_FIREBOLT
= 104318,
18
SPELL_WARLOCK_MOLTEN_CORE_AURA
= 122351,
19
SPELL_WARLOCK_MOLTEN_CORE
= 122355,
20
};
21
22
class
npc_wild_imp
:
public
CreatureScript
23
{
24
public
:
25
npc_wild_imp
() :
CreatureScript
(
"npc_wild_imp"
) { }
26
27
struct
npc_wild_impAI
:
public
ScriptedAI
28
{
29
uint32
charges
;
30
31
npc_wild_impAI
(
Creature
* creature) :
ScriptedAI
(creature)
32
{
33
charges
= 10;
34
me
->SetReactState(
REACT_ASSIST
);
35
}
36
37
void
Reset
()
38
{
39
me
->SetReactState(
REACT_ASSIST
);
40
41
if
(
me
->GetOwner())
42
if
(
me
->GetOwner()->GetVictim())
43
AttackStart
(
me
->GetOwner()->GetVictim());
44
}
45
46
void
UpdateAI
(
uint32
diff)
47
{
48
if
(
me
->GetReactState() !=
REACT_ASSIST
)
49
me
->SetReactState(
REACT_ASSIST
);
50
51
if
(!
me
->GetOwner())
52
return
;
53
54
if
(!
me
->GetOwner()->ToPlayer())
55
return
;
56
57
if
(
me
->HasUnitState(
UNIT_STATE_CASTING
))
58
return
;
59
60
if
(!
charges
)
61
{
62
me
->DespawnOrUnsummon();
63
return
;
64
}
65
66
if
((
me
->GetVictim() ||
me
->GetOwner()->getAttackerForHelper()))
67
{
68
me
->CastSpell(
me
->GetVictim() ?
me
->GetVictim() :
me
->GetOwner()->getAttackerForHelper(),
SPELL_WARLOCK_FIREBOLT
,
false
);
69
me
->GetOwner()->EnergizeBySpell(
me
->GetOwner(),
SPELL_WARLOCK_FIREBOLT
, 5,
POWER_DEMONIC_FURY
);
70
charges
--;
71
72
if
(
me
->GetOwner()->HasAura(
SPELL_WARLOCK_MOLTEN_CORE_AURA
))
73
if
(
roll_chance_i
(8))
74
me
->GetOwner()->CastSpell(
me
->GetOwner(),
SPELL_WARLOCK_MOLTEN_CORE
,
true
);
75
}
76
else
if
(
Pet
* pet =
me
->GetOwner()->ToPlayer()->GetPet())
77
{
78
if
(pet->getAttackerForHelper())
79
{
80
me
->CastSpell(
me
->GetVictim() ?
me
->GetVictim() : pet->getAttackerForHelper(),
SPELL_WARLOCK_FIREBOLT
,
false
);
81
me
->GetOwner()->EnergizeBySpell(
me
->GetOwner(),
SPELL_WARLOCK_FIREBOLT
, 5,
POWER_DEMONIC_FURY
);
82
charges
--;
83
84
if
(
me
->GetOwner()->HasAura(
SPELL_WARLOCK_MOLTEN_CORE_AURA
))
85
if
(
roll_chance_i
(8))
86
me
->GetOwner()->CastSpell(
me
->GetOwner(),
SPELL_WARLOCK_MOLTEN_CORE
,
true
);
87
}
88
}
89
}
90
};
91
92
CreatureAI
*
GetAI
(
Creature
* creature)
const
93
{
94
return
new
npc_wild_impAI
(creature);
95
}
96
};
97
98
void
AddSC_warlock_pet_scripts
()
99
{
100
new
npc_wild_imp
();
101
}
uint32
std::uint32_t uint32
Definition
Define.h:77
Pet.h
ScriptMgr.h
ScriptedCreature.h
POWER_DEMONIC_FURY
@ POWER_DEMONIC_FURY
Definition
SharedDefines.h:230
UNIT_STATE_CASTING
@ UNIT_STATE_CASTING
Definition
Unit.h:527
REACT_ASSIST
@ REACT_ASSIST
Definition
Unit.h:1159
roll_chance_i
bool roll_chance_i(int chance)
Definition
Util.h:89
CreatureAI
Definition
CreatureAI.h:54
Creature
Definition
Creature.h:427
CreatureScript::CreatureScript
CreatureScript(const char *name)
Definition
ScriptMgr.cpp:1436
Pet
Definition
Pet.h:28
npc_wild_imp
Definition
pet_warlock.cpp:23
npc_wild_imp::npc_wild_imp
npc_wild_imp()
Definition
pet_warlock.cpp:25
npc_wild_imp::GetAI
CreatureAI * GetAI(Creature *creature) const
Definition
pet_warlock.cpp:92
ShamanSpells
ShamanSpells
Definition
pet_shaman.cpp:15
AddSC_warlock_pet_scripts
void AddSC_warlock_pet_scripts()
Definition
pet_warlock.cpp:98
SPELL_WARLOCK_FIREBOLT
@ SPELL_WARLOCK_FIREBOLT
Definition
pet_warlock.cpp:17
SPELL_WARLOCK_MOLTEN_CORE
@ SPELL_WARLOCK_MOLTEN_CORE
Definition
pet_warlock.cpp:19
SPELL_WARLOCK_MOLTEN_CORE_AURA
@ SPELL_WARLOCK_MOLTEN_CORE_AURA
Definition
pet_warlock.cpp:18
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_wild_imp::npc_wild_impAI
Definition
pet_warlock.cpp:28
npc_wild_imp::npc_wild_impAI::UpdateAI
void UpdateAI(uint32 diff)
== Triggered Actions Requested ==================
Definition
pet_warlock.cpp:46
npc_wild_imp::npc_wild_impAI::npc_wild_impAI
npc_wild_impAI(Creature *creature)
Definition
pet_warlock.cpp:31
npc_wild_imp::npc_wild_impAI::charges
uint32 charges
Definition
pet_warlock.cpp:29
npc_wild_imp::npc_wild_impAI::Reset
void Reset()
Definition
pet_warlock.cpp:37
src
server
scripts
Pet
pet_warlock.cpp
Generated on
for Project SkyFire Core by
1.17.0