49662e1ac95f5632b03b34e53af6eecec9c2b011
[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 const SummonPropertiesEntry* const m_Properties;
64 private:
65 TempSummonType m_type;
66 uint32 m_timer;
67 uint32 m_lifetime;
68 ObjectGuid m_summonerGUID;
69 };
70
71 class TC_GAME_API Minion : public TempSummon
72 {
73 public:
74 Minion(SummonPropertiesEntry const* properties, Unit* owner, bool isWorldObject);
75 void InitStats(uint32 duration) override;
76 void RemoveFromWorld() override;
77 Unit* GetOwner() const { return m_owner; }
78 float GetFollowAngle() const override { return m_followAngle; }
79 void SetFollowAngle(float angle) { m_followAngle = angle; }
80
81 // Warlock pets
82 bool IsPetImp() const { return GetEntry() == PET_IMP; }
83 bool IsPetFelhunter() const { return GetEntry() == PET_FEL_HUNTER; }
84 bool IsPetVoidwalker() const { return GetEntry() == PET_VOID_WALKER; }
85 bool IsPetSuccubus() const { return GetEntry() == PET_SUCCUBUS; }
86 bool IsPetDoomguard() const { return GetEntry() == PET_DOOMGUARD; }
87 bool IsPetFelguard() const { return GetEntry() == PET_FELGUARD; }
88
89 // Death Knight pets
90 bool IsPetGhoul() const { return GetEntry() == PET_GHOUL; } // Ghoul may be guardian or pet
91 bool IsPetAbomination() const { return GetEntry() == PET_ABOMINATION; } // Sludge Belcher dk talent
92
93 // Shaman pet
94 bool IsSpiritWolf() const { return GetEntry() == PET_SPIRIT_WOLF; } // Spirit wolf from feral spirits
95
96 bool IsGuardianPet() const;
97 protected:
98 Unit* const m_owner;
99 float m_followAngle;
100 };
101
102 class TC_GAME_API Guardian : public Minion
103 {
104 public:
105 Guardian(SummonPropertiesEntry const* properties, Unit* owner, bool isWorldObject);
106 void InitStats(uint32 duration) override;
107 bool InitStatsForLevel(uint8 level);
108 void InitSummon() override;
109
110 bool UpdateStats(Stats stat) override;
111 bool UpdateAllStats() override;
112 void UpdateResistances(uint32 school) override;
113 void UpdateArmor() override;
114 void UpdateMaxHealth() override;
115 void UpdateMaxPower(Powers power) override;
116 void UpdateAttackPowerAndDamage(bool ranged = false) override;
117 void UpdateDamagePhysical(WeaponAttackType attType) override;
118
119 int32 GetBonusDamage() const { return m_bonusSpellDamage; }
120 void SetBonusDamage(int32 damage);
121 protected:
122 int32 m_bonusSpellDamage;
123 float m_statFromOwner[MAX_STATS];
124 };
125
126 class TC_GAME_API Puppet : public Minion
127 {
128 public:
129 Puppet(SummonPropertiesEntry const* properties, Unit* owner);
130 void InitStats(uint32 duration) override;
131 void InitSummon() override;
132 void Update(uint32 time) override;
133 void RemoveFromWorld() override;
134 };
135
136 class TC_GAME_API ForcedUnsummonDelayEvent : public BasicEvent
137 {
138 public:
139 ForcedUnsummonDelayEvent(TempSummon& owner) : BasicEvent(), m_owner(owner) { }
140 bool Execute(uint64 e_time, uint32 p_time) override;
141
142 private:
143 TempSummon& m_owner;
144 };
145 #endif