Project SkyFire Core
SkyFire 5.4.8 server core API documentation
Toggle main menu visibility
Loading...
Searching...
No Matches
Totem.cpp
Go to the documentation of this file.
1
/*
2
* This file is part of Project SkyFire https://www.projectskyfire.org.
3
* See LICENSE.md file for Copyright information
4
*/
5
6
#include "
Group.h
"
7
#include "
Log.h
"
8
#include "
ObjectMgr.h
"
9
#include "
Opcodes.h
"
10
#include "
Player.h
"
11
#include "
SpellInfo.h
"
12
#include "
SpellMgr.h
"
13
#include "
Totem.h
"
14
#include "
WorldPacket.h
"
15
16
Totem::Totem
(
SummonPropertiesEntry
const
* properties,
Unit
* owner) :
Minion
(properties, owner, false),
m_duration
(0)
17
{
18
m_unitTypeMask
|=
UNIT_MASK_TOTEM
;
19
m_type
=
TOTEM_PASSIVE
;
20
}
21
22
void
Totem::Update
(
uint32
time)
23
{
24
if
(!
GetOwner
()->
IsAlive
() || !
IsAlive
())
25
{
26
UnSummon
();
// remove self
27
return
;
28
}
29
30
if
(
m_duration
<= time)
31
{
32
UnSummon
();
// remove self
33
return
;
34
}
35
else
36
m_duration
-= time;
37
38
Creature::Update
(time);
39
}
40
41
void
Totem::InitStats
(
uint32
duration)
42
{
43
// client requires SMSG_TOTEM_CREATED to be sent before adding to world and before removing old totem
44
if
(
GetOwner
()->
GetTypeId
() ==
TypeID::TYPEID_PLAYER
&&
m_Properties
->Slot >=
SUMMON_SLOT_TOTEM
&&
m_Properties
->Slot <
MAX_TOTEM_SLOT
)
45
{
46
ObjectGuid
TotemGUID =
GetGUID
();
47
uint32
SpellID =
GetUInt32Value
(
UNIT_FIELD_CREATED_BY_SPELL
);
48
uint8
Slot =
uint8
(
m_Properties
->Slot - 1);
49
GetOwner
()->
ToPlayer
()->
GetSession
()->
SendTotemCreated
(TotemGUID, duration, SpellID, Slot);
50
51
// set display id depending on caster's race
52
SetDisplayId
(
GetOwner
()->
GetModelForTotem
(
PlayerTotemType
(
m_Properties
->Id)));
53
}
54
55
Minion::InitStats
(duration);
56
57
// Get spell cast by totem
58
if
(
SpellInfo
const
* totemSpell =
sSpellMgr
->GetSpellInfo(
GetSpell
()))
59
if
(totemSpell->CalcCastTime(
getLevel
()))
// If spell has cast time -> its an active totem
60
m_type
=
TOTEM_ACTIVE
;
61
62
m_duration
= duration;
63
64
SetLevel
(
GetOwner
()->
getLevel
());
65
}
66
67
void
Totem::InitSummon
()
68
{
69
if
(
m_type
==
TOTEM_PASSIVE
&&
GetSpell
())
70
CastSpell
(
this
,
GetSpell
(),
true
);
71
72
// Some totems can have both instant effect and passive spell
73
if
(
GetSpell
(1))
74
CastSpell
(
this
,
GetSpell
(1),
true
);
75
}
76
77
void
Totem::UnSummon
(
uint32
msTime)
78
{
79
if
(msTime)
80
{
81
m_Events
.AddEvent(
new
ForcedUnsummonDelayEvent
(*
this
),
m_Events
.CalculateTime(msTime));
82
return
;
83
}
84
85
CombatStop
();
86
RemoveAurasDueToSpell
(
GetSpell
(),
GetGUID
());
87
88
// clear owner's totem slot
89
for
(
uint8
i =
SUMMON_SLOT_TOTEM
; i <
MAX_TOTEM_SLOT
; ++i)
90
{
91
if
(
GetOwner
()->
m_SummonSlot
[i] ==
GetGUID
())
92
{
93
GetOwner
()->
m_SummonSlot
[i] = 0;
94
break
;
95
}
96
}
97
98
GetOwner
()->
RemoveAurasDueToSpell
(
GetSpell
(),
GetGUID
());
99
100
// remove aura all party members too
101
if
(
Player
* owner =
GetOwner
()->
ToPlayer
())
102
{
103
owner->SendAutoRepeatCancel(
this
);
104
105
if
(
SpellInfo
const
* spell =
sSpellMgr
->GetSpellInfo(
GetUInt32Value
(
UNIT_FIELD_CREATED_BY_SPELL
)))
106
owner->SendCooldownEvent(spell, 0, NULL,
false
);
107
108
if
(
Group
* group = owner->GetGroup())
109
{
110
for
(
GroupReference
* itr = group->GetFirstMember(); itr != NULL; itr = itr->
next
())
111
{
112
Player
* target = itr->GetSource();
113
if
(target && group->SameSubGroup(owner, target))
114
target->
RemoveAurasDueToSpell
(
GetSpell
(),
GetGUID
());
115
}
116
}
117
}
118
119
AddObjectToRemoveList
();
120
}
121
122
bool
Totem::IsImmunedToSpellEffect
(
SpellInfo
const
* spellInfo,
uint32
index)
const
123
{
125
if
(
GetEntry
() == 5925)
126
return
false
;
127
128
switch
(spellInfo->
Effects
[index].
ApplyAuraName
)
129
{
130
case
SPELL_AURA_PERIODIC_DAMAGE
:
131
case
SPELL_AURA_PERIODIC_LEECH
:
132
case
SPELL_AURA_MOD_FEAR
:
133
case
SPELL_AURA_TRANSFORM
:
134
return
true
;
135
default
:
136
break
;
137
}
138
139
return
Creature::IsImmunedToSpellEffect
(spellInfo, index);
140
}
uint8
std::uint8_t uint8
Definition
Define.h:79
uint32
std::uint32_t uint32
Definition
Define.h:77
Group.h
Log.h
TypeID::TYPEID_PLAYER
@ TYPEID_PLAYER
Definition
Object.h:55
ObjectMgr.h
Opcodes.h
Player.h
SPELL_AURA_PERIODIC_DAMAGE
@ SPELL_AURA_PERIODIC_DAMAGE
Definition
SpellAuraDefines.h:50
SPELL_AURA_MOD_FEAR
@ SPELL_AURA_MOD_FEAR
Definition
SpellAuraDefines.h:54
SPELL_AURA_TRANSFORM
@ SPELL_AURA_TRANSFORM
Definition
SpellAuraDefines.h:103
SPELL_AURA_PERIODIC_LEECH
@ SPELL_AURA_PERIODIC_LEECH
Definition
SpellAuraDefines.h:100
SpellInfo.h
SpellMgr.h
sSpellMgr
#define sSpellMgr
Definition
SpellMgr.h:744
Totem.h
TOTEM_ACTIVE
@ TOTEM_ACTIVE
Definition
Totem.h:14
TOTEM_PASSIVE
@ TOTEM_PASSIVE
Definition
Totem.h:13
UNIT_MASK_TOTEM
@ UNIT_MASK_TOTEM
Definition
Unit.h:808
SUMMON_SLOT_TOTEM
#define SUMMON_SLOT_TOTEM
Definition
Unit.h:1340
MAX_TOTEM_SLOT
#define MAX_TOTEM_SLOT
Definition
Unit.h:1341
PlayerTotemType
PlayerTotemType
Definition
Unit.h:1349
UNIT_FIELD_CREATED_BY_SPELL
@ UNIT_FIELD_CREATED_BY_SPELL
Definition
UpdateFields.h:106
WorldPacket.h
Creature::IsImmunedToSpellEffect
bool IsImmunedToSpellEffect(SpellInfo const *spellInfo, uint32 index) const OVERRIDE
Definition
Creature.cpp:1627
Creature::SetDisplayId
void SetDisplayId(uint32 modelId) OVERRIDE
Definition
Creature.cpp:2615
Creature::Update
void Update(uint32 time) OVERRIDE
Definition
Creature.cpp:446
ForcedUnsummonDelayEvent
Definition
TemporarySummon.h:105
Group
Definition
Group.h:147
GroupReference
Definition
GroupReference.h:15
GroupReference::next
GroupReference * next()
Definition
GroupReference.h:24
Minion::GetOwner
Unit * GetOwner() const
Definition
TemporarySummon.h:58
Minion::InitStats
void InitStats(uint32 duration) OVERRIDE
Definition
TemporarySummon.cpp:282
Minion::Minion
Minion(SummonPropertiesEntry const *properties, Unit *owner, bool isWorldObject)
Definition
TemporarySummon.cpp:272
Object::GetGUID
uint64 GetGUID() const
Definition
Object.h:119
Object::GetUInt32Value
uint32 GetUInt32Value(uint16 index) const
Definition
Object.cpp:325
Object::ToPlayer
Player * ToPlayer()
Definition
Object.h:204
Object::GetTypeId
TypeID GetTypeId() const
Definition
Object.h:131
Object::GetEntry
uint32 GetEntry() const
Definition
Object.h:125
Player
Definition
Player.h:1289
Player::GetSession
WorldSession * GetSession() const
Definition
Player.h:2417
SpellEffectInfo::ApplyAuraName
uint32 ApplyAuraName
Definition
SpellInfo.h:90
SpellInfo
Definition
SpellInfo.h:158
SpellInfo::Effects
SpellEffectInfo Effects[MAX_SPELL_EFFECTS]
Definition
SpellInfo.h:255
TempSummon::m_Properties
const SummonPropertiesEntry *const m_Properties
Definition
TemporarySummon.h:44
Totem::m_duration
uint32 m_duration
Definition
Totem.h:45
Totem::GetSpell
uint32 GetSpell(uint8 slot=0) const
Definition
Totem.h:27
Totem::InitSummon
void InitSummon() OVERRIDE
Definition
Totem.cpp:67
Totem::InitStats
void InitStats(uint32 duration) OVERRIDE
Definition
Totem.cpp:41
Totem::m_type
TotemType m_type
Definition
Totem.h:44
Totem::Update
void Update(uint32 time) OVERRIDE
Definition
Totem.cpp:22
Totem::IsImmunedToSpellEffect
bool IsImmunedToSpellEffect(SpellInfo const *spellInfo, uint32 index) const OVERRIDE
Definition
Totem.cpp:122
Totem::Totem
Totem(SummonPropertiesEntry const *properties, Unit *owner)
Definition
Totem.cpp:16
Totem::UnSummon
void UnSummon(uint32 msTime=0) OVERRIDE
Definition
Totem.cpp:77
Unit
Definition
Unit.h:1367
Unit::CombatStop
void CombatStop(bool includingCast=false)
Definition
UnitCombatState.cpp:217
Unit::CastSpell
void CastSpell(SpellCastTargets const &targets, SpellInfo const *spellInfo, CustomSpellValues const *value, TriggerCastFlags triggerFlags=TRIGGERED_NONE, Item *castItem=NULL, AuraEffect const *triggeredByAura=NULL, uint64 originalCaster=0)
Definition
UnitCombat.cpp:324
Unit::RemoveAurasDueToSpell
void RemoveAurasDueToSpell(uint32 spellId, uint64 casterGUID=0, uint32 reqEffMask=0, AuraRemoveMode removeMode=AURA_REMOVE_BY_DEFAULT)
Definition
UnitAuraState.cpp:532
Unit::m_SummonSlot
uint64 m_SummonSlot[MAX_SUMMON_SLOT]
Definition
Unit.h:2374
Unit::IsAlive
bool IsAlive() const
Definition
Unit.h:2032
Unit::m_unitTypeMask
uint32 m_unitTypeMask
Definition
Unit.h:2935
Unit::m_Events
EventProcessor m_Events
Definition
Unit.h:2396
Unit::GetModelForTotem
uint32 GetModelForTotem(uint32 totemType) const
Definition
Unit.cpp:7989
Unit::getLevel
uint8 getLevel() const
Definition
Unit.h:1528
Unit::SetLevel
void SetLevel(uint8 lvl)
Definition
Unit.cpp:5150
WorldObject::AddObjectToRemoveList
void AddObjectToRemoveList()
Definition
Object.cpp:2550
WorldSession::SendTotemCreated
void SendTotemCreated(ObjectGuid TotemGUID, uint32 Duration, uint32 SpellID, uint8 Slot)
Definition
SpellHandler.cpp:1921
ObjectGuid
Definition
ByteBuffer.h:66
SummonPropertiesEntry
Definition
DBCStructure.h:2707
src
server
game
Entities
Totem
Totem.cpp
Generated on
for Project SkyFire Core by
1.17.0