TrinityCore
TemporarySummon.h
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#ifndef TRINITYCORE_TEMPSUMMON_H
19#define TRINITYCORE_TEMPSUMMON_H
20
21#include "Creature.h"
22
24{
25 // Warlock pets
26 PET_IMP = 416,
31 PET_FELGUARD = 30146,
32 PET_INCUBUS = 184600,
33
34 // Death Knight pets
35 PET_GHOUL = 26125,
37
38 // Shaman pet
39 PET_SPIRIT_WOLF = 29264
40};
41
43
45{
46 public:
47 explicit TempSummon(SummonPropertiesEntry const* properties, WorldObject* owner, bool isWorldObject);
48 virtual ~TempSummon();
49 void Update(uint32 diff) override;
50 virtual void InitStats(WorldObject* summoner, Milliseconds duration);
51 virtual void InitSummon(WorldObject* summoner);
52 void UpdateObjectVisibilityOnCreate() override;
53 void UpdateObjectVisibilityOnDestroy() override;
54 virtual void UnSummon(uint32 msTime = 0);
55 void RemoveFromWorld() override;
56 void SetTempSummonType(TempSummonType type);
57 void SaveToDB(uint32 /*mapid*/, std::vector<Difficulty> const& /*spawnDifficulties*/) override { }
58 WorldObject* GetSummoner() const;
59 Unit* GetSummonerUnit() const;
60 Creature* GetSummonerCreatureBase() const;
61 GameObject* GetSummonerGameObject() const;
62 ObjectGuid GetSummonerGUID() const { return m_summonerGUID; }
63 TempSummonType GetSummonType() const { return m_type; }
64 Milliseconds GetTimer() const { return m_timer; }
65 void RefreshTimer() { m_timer = m_lifetime; }
66 void ModifyTimer(Milliseconds mod) { m_timer += mod; m_lifetime += mod; }
67 Optional<uint32> GetCreatureIdVisibleToSummoner() const { return m_creatureIdVisibleToSummoner; }
68 Optional<uint32> GetDisplayIdVisibleToSummoner() const { return m_displayIdVisibleToSummoner; }
69 bool CanFollowOwner() const { return m_canFollowOwner; }
70 void SetCanFollowOwner(bool can) { m_canFollowOwner = can; }
71
73 void SetDontDismissOnFlyingMount(bool dontDismissOnFlyingMount) { _staticFlags.ApplyFlag(CREATURE_STATIC_FLAG_5_DONT_DISMISS_ON_FLYING_MOUNT, dontDismissOnFlyingMount); }
74
76 void SetDontAutoResummon(bool dontAutoResummon) { _staticFlags.ApplyFlag(CREATURE_STATIC_FLAG_6_DO_NOT_AUTO_RESUMMON, dontAutoResummon); }
77
79
80 std::string GetDebugInfo() const override;
81
82 protected:
83 std::ptrdiff_t FindUsableTotemSlot(Unit const* summoner) const;
84
85 private:
86 bool IsSharingTotemSlotWith(ObjectGuid objectGuid) const;
94};
95
97{
98 public:
99 Minion(SummonPropertiesEntry const* properties, Unit* owner, bool isWorldObject);
100 void InitStats(WorldObject* summoner, Milliseconds duration) override;
101 void RemoveFromWorld() override;
102 void setDeathState(DeathState s) override;
103 Unit* GetOwner() const { return m_owner; }
104 float GetFollowAngle() const override { return m_followAngle; }
105 void SetFollowAngle(float angle) { m_followAngle = angle; }
106
107 // Warlock pets
108 bool IsPetImp() const { return GetEntry() == PET_IMP; }
109 bool IsPetFelhunter() const { return GetEntry() == PET_FEL_HUNTER; }
110 bool IsPetVoidwalker() const { return GetEntry() == PET_VOID_WALKER; }
111 bool IsPetSayaad() const { return GetEntry() == PET_SUCCUBUS || GetEntry() == PET_INCUBUS; }
112 bool IsPetDoomguard() const { return GetEntry() == PET_DOOMGUARD; }
113 bool IsPetFelguard() const { return GetEntry() == PET_FELGUARD; }
114 bool IsWarlockPet() const { return IsPetImp() || IsPetFelhunter() || IsPetVoidwalker() || IsPetSayaad() || IsPetDoomguard() || IsPetFelguard(); }
115
116 // Death Knight pets
117 bool IsPetGhoul() const { return GetEntry() == PET_GHOUL; } // Ghoul may be guardian or pet
118 bool IsPetAbomination() const { return GetEntry() == PET_ABOMINATION; } // Sludge Belcher dk talent
119
120 // Shaman pet
121 bool IsSpiritWolf() const { return GetEntry() == PET_SPIRIT_WOLF; } // Spirit wolf from feral spirits
122
123 bool IsGuardianPet() const;
124
125 std::string GetDebugInfo() const override;
126 protected:
127 Unit* const m_owner;
129};
130
132{
133 public:
134 Guardian(SummonPropertiesEntry const* properties, Unit* owner, bool isWorldObject);
135 void InitStats(WorldObject* summoner, Milliseconds duration) override;
136 bool InitStatsForLevel(uint8 level);
137 void InitSummon(WorldObject* summoner) override;
138
139 bool UpdateStats(Stats stat) override;
140 bool UpdateAllStats() override;
141 void UpdateResistances(uint32 school) override;
142 void UpdateArmor() override;
143 void UpdateMaxHealth() override;
144 void UpdateMaxPower(Powers power) override;
145 void UpdateAttackPowerAndDamage(bool ranged = false) override;
146 void UpdateDamagePhysical(WeaponAttackType attType) override;
147
148 int32 GetBonusDamage() const { return m_bonusSpellDamage; }
149 float GetBonusStatFromOwner(Stats stat) const { return m_statFromOwner[stat]; }
150 void SetBonusDamage(int32 damage);
151 std::string GetDebugInfo() const override;
152 protected:
154 float m_statFromOwner[MAX_STATS];
155};
156
158{
159 public:
160 Puppet(SummonPropertiesEntry const* properties, Unit* owner);
161 void InitStats(WorldObject* summoner, Milliseconds duration) override;
162 void InitSummon(WorldObject* summoner) override;
163 void Update(uint32 time) override;
164};
165
167{
168public:
169 ForcedUnsummonDelayEvent(TempSummon& owner) : BasicEvent(), m_owner(owner) { }
170 bool Execute(uint64 e_time, uint32 p_time) override;
171
172private:
174};
175#endif
@ CREATURE_STATIC_FLAG_6_DO_NOT_AUTO_RESUMMON
Definition: CreatureData.h:228
@ CREATURE_STATIC_FLAG_5_DONT_DISMISS_ON_FLYING_MOUNT
Definition: CreatureData.h:199
#define TC_GAME_API
Definition: Define.h:123
uint8_t uint8
Definition: Define.h:144
int32_t int32
Definition: Define.h:138
uint64_t uint64
Definition: Define.h:141
uint32_t uint32
Definition: Define.h:142
std::chrono::milliseconds Milliseconds
Milliseconds shorthand typedef.
Definition: Duration.h:29
TempSummonType
Definition: ObjectDefines.h:62
std::optional< T > Optional
Optional helper class to wrap optional values within.
Definition: Optional.h:25
#define MAX_STATS
WeaponAttackType
Powers
Stats
PetEntry
@ PET_FEL_HUNTER
@ PET_ABOMINATION
@ PET_GHOUL
@ PET_SUCCUBUS
@ PET_SPIRIT_WOLF
@ PET_DOOMGUARD
@ PET_VOID_WALKER
@ PET_IMP
@ PET_FELGUARD
@ PET_INCUBUS
DeathState
Definition: Unit.h:245
void setDeathState(DeathState s) override
Definition: Creature.cpp:2197
bool UpdateAllStats() override
Definition: StatSystem.cpp:902
void Update(uint32 time) override
Definition: Creature.cpp:709
bool UpdateStats(Stats stat) override
Definition: StatSystem.cpp:897
void RemoveFromWorld() override
Definition: Creature.cpp:349
void UpdateAttackPowerAndDamage(bool ranged=false) override
Definition: StatSystem.cpp:966
void UpdateArmor() override
Definition: StatSystem.cpp:916
bool HasFlag(CreatureStaticFlags flag) const
Definition: Creature.h:454
void UpdateMaxPower(Powers power) override
Definition: StatSystem.cpp:951
std::string GetDebugInfo() const override
Definition: Creature.cpp:3667
void UpdateMaxHealth() override
Definition: StatSystem.cpp:923
ForcedUnsummonDelayEvent(TempSummon &owner)
float GetBonusStatFromOwner(Stats stat) const
int32 m_bonusSpellDamage
int32 GetBonusDamage() const
float m_followAngle
bool IsPetDoomguard() const
bool IsPetImp() const
void SetFollowAngle(float angle)
Unit * GetOwner() const
bool IsPetFelhunter() const
bool IsSpiritWolf() const
Unit *const m_owner
bool IsPetSayaad() const
bool IsWarlockPet() const
float GetFollowAngle() const override
bool IsPetFelguard() const
bool IsPetAbomination() const
bool IsPetVoidwalker() const
bool IsPetGhoul() const
uint32 GetEntry() const
Definition: Object.h:161
Optional< uint32 > GetCreatureIdVisibleToSummoner() const
Milliseconds m_timer
Optional< uint32 > GetDisplayIdVisibleToSummoner() const
TempSummonType GetSummonType() const
ObjectGuid GetSummonerGUID() const
void SaveToDB(uint32, std::vector< Difficulty > const &) override
void SetDontAutoResummon(bool dontAutoResummon)
void SetCanFollowOwner(bool can)
bool CanFollowOwner() const
SummonPropertiesEntry const *const m_Properties
void SetDontDismissOnFlyingMount(bool dontDismissOnFlyingMount)
Optional< uint32 > m_displayIdVisibleToSummoner
ObjectGuid m_summonerGUID
bool IsDismissedOnFlyingMount() const
TempSummonType m_type
Optional< uint32 > m_creatureIdVisibleToSummoner
void RefreshTimer()
bool IsAutoResummoned() const
Milliseconds GetTimer() const
bool m_canFollowOwner
virtual ~TempSummon()
void ModifyTimer(Milliseconds mod)
Milliseconds m_lifetime
Definition: Unit.h:627
virtual void UpdateResistances(uint32 school)
Definition: Unit.cpp:9264
virtual void UpdateDamagePhysical(WeaponAttackType attType)
Definition: StatSystem.cpp:64
virtual void UpdateObjectVisibilityOnDestroy()
Definition: Object.h:724
virtual void UpdateObjectVisibilityOnCreate()
Definition: Object.h:723