Project SkyFire Core
SkyFire 5.4.8 server core API documentation
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
21
23{
24public:
25 npc_wild_imp() : CreatureScript("npc_wild_imp") { }
26
27 struct npc_wild_impAI : public ScriptedAI
28 {
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
99{
100 new npc_wild_imp();
101}
std::uint32_t uint32
Definition Define.h:77
@ POWER_DEMONIC_FURY
@ UNIT_STATE_CASTING
Definition Unit.h:527
@ REACT_ASSIST
Definition Unit.h:1159
bool roll_chance_i(int chance)
Definition Util.h:89
CreatureScript(const char *name)
Definition Pet.h:28
CreatureAI * GetAI(Creature *creature) const
ShamanSpells
void AddSC_warlock_pet_scripts()
@ SPELL_WARLOCK_FIREBOLT
@ SPELL_WARLOCK_MOLTEN_CORE
@ SPELL_WARLOCK_MOLTEN_CORE_AURA
Creature * me
ScriptedAI(Creature *creature)
void AttackStart(Unit *) OVERRIDE
void UpdateAI(uint32 diff)
== Triggered Actions Requested ==================
npc_wild_impAI(Creature *creature)