TrinityCore
Loading...
Searching...
No Matches
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,
36
37 // Shaman pet
38 PET_SPIRIT_WOLF = 29264
39};
40
42
44{
45 public:
46 explicit TempSummon(SummonPropertiesEntry const* properties, WorldObject* owner, bool isWorldObject);
47 virtual ~TempSummon();
48 void Update(uint32 diff) override;
49 virtual void InitStats(WorldObject* summoner, Milliseconds duration);
50 virtual void InitSummon(WorldObject* summoner);
51 void UpdateObjectVisibilityOnCreate() override;
52 void UpdateObjectVisibilityOnDestroy() override;
53 virtual void UnSummon(uint32 msTime = 0);
54 void RemoveFromWorld() override;
55 void SetTempSummonType(TempSummonType type);
56 void SaveToDB(uint32 /*mapid*/, std::vector<Difficulty> const& /*spawnDifficulties*/) override { }
57 WorldObject* GetSummoner() const;
58 Unit* GetSummonerUnit() const;
59 Creature* GetSummonerCreatureBase() const;
60 GameObject* GetSummonerGameObject() const;
61 ObjectGuid GetSummonerGUID() const { return m_summonerGUID; }
62 TempSummonType GetSummonType() const { return m_type; }
63 Milliseconds GetTimer() const { return m_timer; }
64 void RefreshTimer() { m_timer = m_lifetime; }
65 void ModifyTimer(Milliseconds mod) { m_timer += mod; m_lifetime += mod; }
66 Optional<uint32> GetCreatureIdVisibleToSummoner() const { return m_creatureIdVisibleToSummoner; }
67 Optional<uint32> GetDisplayIdVisibleToSummoner() const { return m_displayIdVisibleToSummoner; }
68 bool CanFollowOwner() const { return m_canFollowOwner; }
69 void SetCanFollowOwner(bool can) { m_canFollowOwner = can; }
70
72 void SetDontDismissOnFlyingMount(bool dontDismissOnFlyingMount) { _staticFlags.ApplyFlag(CREATURE_STATIC_FLAG_5_DONT_DISMISS_ON_FLYING_MOUNT, dontDismissOnFlyingMount); }
73
75 void SetDontAutoResummon(bool dontAutoResummon) { _staticFlags.ApplyFlag(CREATURE_STATIC_FLAG_6_DO_NOT_AUTO_RESUMMON_THIS_COMPANION_CREATURE, dontAutoResummon); }
76
78
79 std::string GetDebugInfo() const override;
80
81 protected:
82 std::ptrdiff_t FindUsableTotemSlot(Unit const* summoner) const;
83
84 private:
85 bool IsSharingTotemSlotWith(ObjectGuid objectGuid) const;
93};
94
96{
97 public:
98 Minion(SummonPropertiesEntry const* properties, Unit* owner, bool isWorldObject);
99 void InitStats(WorldObject* summoner, Milliseconds duration) override;
100 void RemoveFromWorld() override;
101 void setDeathState(DeathState s) override;
102 Unit* GetOwner() const { return m_owner; }
103 float GetFollowAngle() const override { return m_followAngle; }
104 void SetFollowAngle(float angle) { m_followAngle = angle; }
105
106 // Warlock pets
107 bool IsPetImp() const { return GetEntry() == PET_IMP; }
108 bool IsPetFelhunter() const { return GetEntry() == PET_FEL_HUNTER; }
109 bool IsPetVoidwalker() const { return GetEntry() == PET_VOID_WALKER; }
110 bool IsPetSayaad() const { return GetEntry() == PET_SUCCUBUS || GetEntry() == PET_INCUBUS; }
111 bool IsPetDoomguard() const { return GetEntry() == PET_DOOMGUARD; }
112 bool IsPetFelguard() const { return GetEntry() == PET_FELGUARD; }
113 bool IsWarlockPet() const { return IsPetImp() || IsPetFelhunter() || IsPetVoidwalker() || IsPetSayaad() || IsPetDoomguard() || IsPetFelguard(); }
114
115 // Death Knight pets
116 bool IsPetGhoul() const { return GetEntry() == PET_GHOUL; } // Ghoul may be guardian or pet
117
118 // Shaman pet
119 bool IsSpiritWolf() const { return GetEntry() == PET_SPIRIT_WOLF; } // Spirit wolf from feral spirits
120
121 bool IsGuardianPet() const;
122
123 std::string GetDebugInfo() const override;
124 protected:
125 Unit* const m_owner;
127};
128
130{
131 public:
132 Guardian(SummonPropertiesEntry const* properties, Unit* owner, bool isWorldObject);
133 void InitStats(WorldObject* summoner, Milliseconds duration) override;
134 bool InitStatsForLevel(uint8 level);
135 void InitSummon(WorldObject* summoner) override;
136
137 bool UpdateStats(Stats stat) override;
138 bool UpdateAllStats() override;
139 void UpdateResistances(uint32 school) override;
140 void UpdateArmor() override;
141 void UpdateMaxHealth() override;
142 void UpdateMaxPower(Powers power) override;
143 void UpdateAttackPowerAndDamage(bool ranged = false) override;
144 void UpdateDamagePhysical(WeaponAttackType attType) override;
145
146 int32 GetBonusDamage() const { return m_bonusSpellDamage; }
147 float GetBonusStatFromOwner(Stats stat) const { return m_statFromOwner[stat]; }
148 void SetBonusDamage(int32 damage);
149 std::string GetDebugInfo() const override;
150 protected:
152 float m_statFromOwner[MAX_STATS];
153};
154
156{
157 public:
158 Puppet(SummonPropertiesEntry const* properties, Unit* owner);
159 void InitStats(WorldObject* summoner, Milliseconds duration) override;
160 void InitSummon(WorldObject* summoner) override;
161 void Update(uint32 time) override;
162};
163
164#endif
@ CREATURE_STATIC_FLAG_6_DO_NOT_AUTO_RESUMMON_THIS_COMPANION_CREATURE
@ CREATURE_STATIC_FLAG_5_DONT_DISMISS_ON_FLYING_MOUNT
#define TC_GAME_API
Definition Define.h:129
uint8_t uint8
Definition Define.h:156
int32_t int32
Definition Define.h:150
uint32_t uint32
Definition Define.h:154
std::chrono::milliseconds Milliseconds
Milliseconds shorthand typedef.
Definition Duration.h:24
TempSummonType
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_GHOUL
@ PET_SUCCUBUS
@ PET_SPIRIT_WOLF
@ PET_DOOMGUARD
@ PET_VOID_WALKER
@ PET_IMP
@ PET_FELGUARD
@ PET_INCUBUS
DeathState
Definition Unit.h:251
void setDeathState(DeathState s) override
bool UpdateAllStats() override
void Update(uint32 time) override
Definition Creature.cpp:752
bool UpdateStats(Stats stat) override
void RemoveFromWorld() override
Definition Creature.cpp:367
void UpdateAttackPowerAndDamage(bool ranged=false) override
void UpdateArmor() override
bool HasFlag(CreatureStaticFlags flag) const
Definition Creature.h:472
void UpdateMaxPower(Powers power) override
std::string GetDebugInfo() const override
void UpdateMaxHealth() override
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 IsPetVoidwalker() const
bool IsPetGhoul() const
uint32 GetEntry() const
Definition Object.h:89
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:635
virtual void UpdateResistances(uint32 school)
Definition Unit.cpp:9891
virtual void UpdateDamagePhysical(WeaponAttackType attType)
virtual void UpdateObjectVisibilityOnDestroy()
Definition Object.h:511
virtual void UpdateObjectVisibilityOnCreate()
Definition Object.h:510