Core/Spells: Implemented personal summons (#19231)
[trinitycore] / src / server / game / Entities / Creature / TemporarySummon.h
1 /*
2 * Copyright (C) 2008-2018 TrinityCore <https://www.trinitycore.org/>
3 * Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/>
4 *
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License as published by the
7 * Free Software Foundation; either version 2 of the License, or (at your
8 * option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 * more details.
14 *
15 * You should have received a copy of the GNU General Public License along
16 * with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19 #ifndef TRINITYCORE_TEMPSUMMON_H
20 #define TRINITYCORE_TEMPSUMMON_H
21
22 #include "Creature.h"
23
24 enum PetEntry
25 {
26 // Warlock pets
27 PET_IMP = 416,
28 PET_FEL_HUNTER = 691,
29 PET_VOID_WALKER = 1860,
30 PET_SUCCUBUS = 1863,
31 PET_DOOMGUARD = 18540,
32 PET_FELGUARD = 30146,
33
34 // Death Knight pets
35 PET_GHOUL = 26125,
36 PET_ABOMINATION = 106848,
37
38 // Shaman pet
39 PET_SPIRIT_WOLF = 29264
40 };
41
42 struct SummonPropertiesEntry;
43
44 class TC_GAME_API TempSummon : public Creature
45 {
46 public:
47 explicit TempSummon(SummonPropertiesEntry const* properties, Unit* owner, bool isWorldObject);
48 virtual ~TempSummon() { }
49 void Update(uint32 time) override;
50 virtual void InitStats(uint32 lifetime);
51 virtual void InitSummon();
52 void UpdateObjectVisibilityOnCreate() override;
53 virtual void UnSummon(uint32 msTime = 0);
54 void RemoveFromWorld() override;
55 void SetTempSummonType(TempSummonType type);
56 void SaveToDB(uint32 /*mapid*/, uint64 /*spawnMask*/) override { }
57 Unit* GetSummoner() const;
58 Creature* GetSummonerCreatureBase() const;
59 ObjectGuid GetSummonerGUID() const { return m_summonerGUID; }
60 TempSummonType const& GetSummonType() { return m_type; }
61 uint32 GetTimer() const { return m_timer; }
62
63 void SetVisibleBySummonerOnly(bool visibleBySummonerOnly) { m_visibleBySummonerOnly = visibleBySummonerOnly; }
64 bool IsVisibleBySummonerOnly() const { return m_visibleBySummonerOnly; }
65
66 const SummonPropertiesEntry* const m_Properties;
67 private:
68 TempSummonType m_type;
69 uint32 m_timer;
70 uint32 m_lifetime;
71 ObjectGuid m_summonerGUID;
72 bool m_visibleBySummonerOnly;
73 };
74
75 class TC_GAME_API Minion : public TempSummon
76 {
77 public:
78 Minion(SummonPropertiesEntry const* properties, Unit* owner, bool isWorldObject);
79 void InitStats(uint32 duration) override;
80 void RemoveFromWorld() override;
81 Unit* GetOwner() const { return m_owner; }
82 float GetFollowAngle() const override { return m_followAngle; }
83 void SetFollowAngle(float angle) { m_followAngle = angle; }
84
85 // Warlock pets
86 bool IsPetImp() const { return GetEntry() == PET_IMP; }
87 bool IsPetFelhunter() const { return GetEntry() == PET_FEL_HUNTER; }
88 bool IsPetVoidwalker() const { return GetEntry() == PET_VOID_WALKER; }
89 bool IsPetSuccubus() const { return GetEntry() == PET_SUCCUBUS; }
90 bool IsPetDoomguard() const { return GetEntry() == PET_DOOMGUARD; }
91 bool IsPetFelguard() const { return GetEntry() == PET_FELGUARD; }
92
93 // Death Knight pets
94 bool IsPetGhoul() const { return GetEntry() == PET_GHOUL; } // Ghoul may be guardian or pet
95 bool IsPetAbomination() const { return GetEntry() == PET_ABOMINATION; } // Sludge Belcher dk talent
96
97 // Shaman pet
98 bool IsSpiritWolf() const { return GetEntry() == PET_SPIRIT_WOLF; } // Spirit wolf from feral spirits
99
100 bool IsGuardianPet() const;
101 protected:
102 Unit* const m_owner;
103 float m_followAngle;
104 };
105
106 class TC_GAME_API Guardian : public Minion
107 {
108 public:
109 Guardian(SummonPropertiesEntry const* properties, Unit* owner, bool isWorldObject);
110 void InitStats(uint32 duration) override;
111 bool InitStatsForLevel(uint8 level);
112 void InitSummon() override;
113
114 bool UpdateStats(Stats stat) override;
115 bool UpdateAllStats() override;
116 void UpdateResistances(uint32 school) override;
117 void UpdateArmor() override;
118 void UpdateMaxHealth() override;
119 void UpdateMaxPower(Powers power) override;
120 void UpdateAttackPowerAndDamage(bool ranged = false) override;
121 void UpdateDamagePhysical(WeaponAttackType attType) override;
122
123 int32 GetBonusDamage() const { return m_bonusSpellDamage; }
124 void SetBonusDamage(int32 damage);
125 protected:
126 int32 m_bonusSpellDamage;
127 float m_statFromOwner[MAX_STATS];
128 };
129
130 class TC_GAME_API Puppet : public Minion
131 {
132 public:
133 Puppet(SummonPropertiesEntry const* properties, Unit* owner);
134 void InitStats(uint32 duration) override;
135 void InitSummon() override;
136 void Update(uint32 time) override;
137 void RemoveFromWorld() override;
138 };
139
140 class TC_GAME_API ForcedUnsummonDelayEvent : public BasicEvent
141 {
142 public:
143 ForcedUnsummonDelayEvent(TempSummon& owner) : BasicEvent(), m_owner(owner) { }
144 bool Execute(uint64 e_time, uint32 p_time) override;
145
146 private:
147 TempSummon& m_owner;
148 };
149 #endif