Project SkyFire Core
SkyFire 5.4.8 server core API documentation
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
16Totem::Totem(SummonPropertiesEntry const* properties, Unit* owner) : Minion(properties, owner, false), m_duration(0)
17{
20}
21
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
42{
43 // client requires SMSG_TOTEM_CREATED to be sent before adding to world and before removing old totem
45 {
46 ObjectGuid TotemGUID = GetGUID();
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
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
61
62 m_duration = duration;
63
65}
66
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
78{
79 if (msTime)
80 {
81 m_Events.AddEvent(new ForcedUnsummonDelayEvent(*this), m_Events.CalculateTime(msTime));
82 return;
83 }
84
85 CombatStop();
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
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))
115 }
116 }
117 }
118
120}
121
122bool Totem::IsImmunedToSpellEffect(SpellInfo const* spellInfo, uint32 index) const
123{
125 if (GetEntry() == 5925)
126 return false;
127
128 switch (spellInfo->Effects[index].ApplyAuraName)
129 {
134 return true;
135 default:
136 break;
137 }
138
139 return Creature::IsImmunedToSpellEffect(spellInfo, index);
140}
std::uint8_t uint8
Definition Define.h:79
std::uint32_t uint32
Definition Define.h:77
@ TYPEID_PLAYER
Definition Object.h:55
@ SPELL_AURA_PERIODIC_DAMAGE
@ SPELL_AURA_MOD_FEAR
@ SPELL_AURA_TRANSFORM
@ SPELL_AURA_PERIODIC_LEECH
#define sSpellMgr
Definition SpellMgr.h:744
@ TOTEM_ACTIVE
Definition Totem.h:14
@ TOTEM_PASSIVE
Definition Totem.h:13
@ UNIT_MASK_TOTEM
Definition Unit.h:808
#define SUMMON_SLOT_TOTEM
Definition Unit.h:1340
#define MAX_TOTEM_SLOT
Definition Unit.h:1341
PlayerTotemType
Definition Unit.h:1349
@ UNIT_FIELD_CREATED_BY_SPELL
bool IsImmunedToSpellEffect(SpellInfo const *spellInfo, uint32 index) const OVERRIDE
void SetDisplayId(uint32 modelId) OVERRIDE
void Update(uint32 time) OVERRIDE
Definition Creature.cpp:446
Definition Group.h:147
GroupReference * next()
Unit * GetOwner() const
void InitStats(uint32 duration) OVERRIDE
Minion(SummonPropertiesEntry const *properties, Unit *owner, bool isWorldObject)
uint64 GetGUID() const
Definition Object.h:119
uint32 GetUInt32Value(uint16 index) const
Definition Object.cpp:325
Player * ToPlayer()
Definition Object.h:204
TypeID GetTypeId() const
Definition Object.h:131
uint32 GetEntry() const
Definition Object.h:125
WorldSession * GetSession() const
Definition Player.h:2417
uint32 ApplyAuraName
Definition SpellInfo.h:90
SpellEffectInfo Effects[MAX_SPELL_EFFECTS]
Definition SpellInfo.h:255
const SummonPropertiesEntry *const m_Properties
uint32 m_duration
Definition Totem.h:45
uint32 GetSpell(uint8 slot=0) const
Definition Totem.h:27
void InitSummon() OVERRIDE
Definition Totem.cpp:67
void InitStats(uint32 duration) OVERRIDE
Definition Totem.cpp:41
TotemType m_type
Definition Totem.h:44
void Update(uint32 time) OVERRIDE
Definition Totem.cpp:22
bool IsImmunedToSpellEffect(SpellInfo const *spellInfo, uint32 index) const OVERRIDE
Definition Totem.cpp:122
Totem(SummonPropertiesEntry const *properties, Unit *owner)
Definition Totem.cpp:16
void UnSummon(uint32 msTime=0) OVERRIDE
Definition Totem.cpp:77
Definition Unit.h:1367
void CombatStop(bool includingCast=false)
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)
void RemoveAurasDueToSpell(uint32 spellId, uint64 casterGUID=0, uint32 reqEffMask=0, AuraRemoveMode removeMode=AURA_REMOVE_BY_DEFAULT)
uint64 m_SummonSlot[MAX_SUMMON_SLOT]
Definition Unit.h:2374
bool IsAlive() const
Definition Unit.h:2032
uint32 m_unitTypeMask
Definition Unit.h:2935
EventProcessor m_Events
Definition Unit.h:2396
uint32 GetModelForTotem(uint32 totemType) const
Definition Unit.cpp:7989
uint8 getLevel() const
Definition Unit.h:1528
void SetLevel(uint8 lvl)
Definition Unit.cpp:5150
void AddObjectToRemoveList()
Definition Object.cpp:2550
void SendTotemCreated(ObjectGuid TotemGUID, uint32 Duration, uint32 SpellID, uint8 Slot)