TrinityCore
Loading...
Searching...
No Matches
pet_dk.cpp
Go to the documentation of this file.
1/*
2 * This file is part of the TrinityCore Project. See AUTHORS file for Copyright information
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by the
6 * Free Software Foundation; either version 2 of the License, or (at your
7 * option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12 * more details.
13 *
14 * You should have received a copy of the GNU General Public License along
15 * with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18/*
19 * Ordered alphabetically using scriptname.
20 * Scriptnames of files in this file should be prefixed with "npc_pet_dk_".
21 */
22
23#include "ScriptMgr.h"
24#include "CellImpl.h"
25#include "CombatAI.h"
26#include "GridNotifiersImpl.h"
27#include "MotionMaster.h"
28
37
38// 28017 - Bloodworm
40{
41 npc_pet_dk_bloodworm(Creature* creature) : AggressorAI(creature) { }
42
43 bool CanAIAttack(Unit const* target) const override
44 {
45 Unit* owner = me->GetOwner();
46 if (owner && !target->IsInCombatWith(owner))
47 return false;
48 return AggressorAI::CanAIAttack(target);
49 }
50};
51
53{
54 npc_pet_dk_ebon_gargoyle(Creature* creature) : CasterAI(creature) { }
55
56 void InitializeAI() override
57 {
59 ObjectGuid ownerGuid = me->GetOwnerGUID();
60 if (!ownerGuid)
61 return;
62
63 // Find victim of Summon Gargoyle spell
64 std::list<Unit*> targets;
67 Cell::VisitAllObjects(me, searcher, 30.0f);
68 for (Unit* target : targets)
69 {
70 if (target->HasAura(SPELL_DK_SUMMON_GARGOYLE_1, ownerGuid))
71 {
72 me->Attack(target, false);
73 break;
74 }
75 }
76 }
77
78 void JustDied(Unit* /*killer*/) override
79 {
80 // Stop Feeding Gargoyle when it dies
81 if (Unit* owner = me->GetOwner())
82 owner->RemoveAurasDueToSpell(SPELL_DK_SUMMON_GARGOYLE_2);
83 }
84
85 // Fly away when dismissed
86 void SpellHit(WorldObject* caster, SpellInfo const* spellInfo) override
87 {
88 if (spellInfo->Id != SPELL_DK_DISMISS_GARGOYLE || !me->IsAlive())
89 return;
90
91 Unit* owner = me->GetOwner();
92 if (!owner || owner != caster)
93 return;
94
95 // Stop Fighting
97
98 // Sanctuary
101
103 // Fly Away
104 me->SetCanFly(true);
105 me->SetSpeedRate(MOVE_FLIGHT, 0.75f);
106 me->SetSpeedRate(MOVE_RUN, 0.75f);
107 float x = me->GetPositionX() + 20 * std::cos(me->GetOrientation());
108 float y = me->GetPositionY() + 20 * std::sin(me->GetOrientation());
109 float z = me->GetPositionZ() + 40;
111 me->GetMotionMaster()->MovePoint(0, x, y, z);
112
113 // Despawn as soon as possible
115 }
116};
117
118// 26125 - Risen Ghoul
120{
121 npc_pet_dk_risen_ghoul(Creature* creature) : AggressorAI(creature) { }
122
123 bool CanAIAttack(Unit const* target) const override
124 {
125 Unit* owner = me->GetOwner();
126 if (owner && !target->IsInCombatWith(owner))
127 return false;
128 return AggressorAI::CanAIAttack(target);
129 }
130
135};
136
std::chrono::seconds Seconds
Seconds shorthand typedef.
Definition Duration.h:28
#define RegisterCreatureAI(ai_name)
Definition ScriptMgr.h:1392
@ TRIGGERED_IGNORE_CAST_IN_PROGRESS
Will not check if a current cast is in progress.
@ TRIGGERED_DONT_REPORT_CAST_ERROR
Will return SPELL_FAILED_DONT_REPORT in CheckCast functions.
@ MOVE_FLIGHT
@ MOVE_RUN
@ REACT_PASSIVE
@ UNIT_FLAG_NON_ATTACKABLE
void InitializeAI() override
Definition CombatAI.cpp:118
Creature *const me
Definition CreatureAI.h:63
void SetReactState(ReactStates st)
Definition Creature.h:174
void DespawnOrUnsummon(Milliseconds timeToDespawn=0s, Seconds forceRespawnTime=0s)
void MovePoint(uint32 id, Position const &pos, bool generatePath=true, Optional< float > finalOrient={}, Optional< float > speed={}, MovementWalkRunSpeedSelectionMode speedSelectionMode=MovementWalkRunSpeedSelectionMode::Default, Optional< float > closeEnoughDistance={}, Optional< MovementFadeObject > fadeObject={}, Scripting::v2::ActionResultSetter< MovementStopReason > &&scriptResult={})
uint32 const Id
Definition SpellInfo.h:328
virtual bool CanAIAttack(Unit const *) const
Definition UnitAI.h:58
Definition Unit.h:635
ObjectGuid GetOwnerGUID() const override
Definition Unit.h:1191
MotionMaster * GetMotionMaster()
Definition Unit.h:1723
bool IsAlive() const
Definition Unit.h:1185
bool IsInCombatWith(Unit const *who) const
Definition Unit.h:1059
bool Attack(Unit *victim, bool meleeAttack)
Definition Unit.cpp:5853
bool SetCanFly(bool enable)
Definition Unit.cpp:13459
void SetSpeedRate(UnitMoveType mtype, float rate)
Definition Unit.cpp:8942
void SetUnitFlag(UnitFlags flags)
Definition Unit.h:846
SpellCastResult CastSpell(CastSpellTargetArg const &targets, uint32 spellId, CastSpellExtraArgs const &args={ })
Definition Object.cpp:2217
Unit * GetOwner() const
Definition Object.cpp:1598
DeathKnightSpells
Definition pet_dk.cpp:30
@ SPELL_DK_BIRTH
Definition pet_dk.cpp:31
@ SPELL_DK_SUMMON_GARGOYLE_2
Definition pet_dk.cpp:33
@ SPELL_DK_SUMMON_GARGOYLE_1
Definition pet_dk.cpp:32
@ SPELL_DK_SANCTUARY
Definition pet_dk.cpp:35
@ SPELL_DK_DISMISS_GARGOYLE
Definition pet_dk.cpp:34
void AddSC_deathknight_pet_scripts()
Definition pet_dk.cpp:137
static void VisitAllObjects(WorldObject const *obj, T &visitor, float radius, bool dont_load=true)
Definition CellImpl.h:203
constexpr float GetPositionX() const
Definition Position.h:87
constexpr float GetPositionY() const
Definition Position.h:88
constexpr float GetOrientation() const
Definition Position.h:90
constexpr float GetPositionZ() const
Definition Position.h:89
npc_pet_dk_bloodworm(Creature *creature)
Definition pet_dk.cpp:41
bool CanAIAttack(Unit const *target) const override
Definition pet_dk.cpp:43
void InitializeAI() override
Definition pet_dk.cpp:56
void JustDied(Unit *) override
Definition pet_dk.cpp:78
void SpellHit(WorldObject *caster, SpellInfo const *spellInfo) override
Definition pet_dk.cpp:86
npc_pet_dk_ebon_gargoyle(Creature *creature)
Definition pet_dk.cpp:54
void JustAppeared() override
Definition pet_dk.cpp:131
bool CanAIAttack(Unit const *target) const override
Definition pet_dk.cpp:123
npc_pet_dk_risen_ghoul(Creature *creature)
Definition pet_dk.cpp:121