aboutsummaryrefslogtreecommitdiff
path: root/src/game/TemporarySummon.cpp
diff options
context:
space:
mode:
authorXTZGZoReX <none@none>2009-03-20 15:17:58 +0100
committerXTZGZoReX <none@none>2009-03-20 15:17:58 +0100
commitd1adac0d11847c893b2df0778b81dbbbb79b20ee (patch)
treebef465fd25746ed1e276ede2238f155b1a347a4a /src/game/TemporarySummon.cpp
parent3c713189fb6ac6666e6d8e7faa2e1fec6b425725 (diff)
parent4d7ee8208e0e1762ca70d1cee253e51d3c517551 (diff)
* Merge.
--HG-- branch : trunk
Diffstat (limited to 'src/game/TemporarySummon.cpp')
-rw-r--r--src/game/TemporarySummon.cpp50
1 files changed, 42 insertions, 8 deletions
diff --git a/src/game/TemporarySummon.cpp b/src/game/TemporarySummon.cpp
index bd655ef144f..110549fb6e0 100644
--- a/src/game/TemporarySummon.cpp
+++ b/src/game/TemporarySummon.cpp
@@ -23,12 +23,14 @@
#include "ObjectAccessor.h"
#include "CreatureAI.h"
-TemporarySummon::TemporarySummon( uint64 summoner ) :
+TempSummon::TempSummon( uint64 summoner ) :
Creature(), m_type(TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN), m_timer(0), m_lifetime(0), m_summoner(summoner)
+, m_properties(NULL)
{
+ m_isSummon = true;
}
-void TemporarySummon::Update( uint32 diff )
+void TempSummon::Update( uint32 diff )
{
if (m_deathState == DEAD)
{
@@ -157,7 +159,7 @@ void TemporarySummon::Update( uint32 diff )
Creature::Update( diff );
}
-void TemporarySummon::Summon(TempSummonType type, uint32 lifetime)
+void TempSummon::Summon(TempSummonType type, uint32 lifetime)
{
m_type = type;
m_timer = lifetime;
@@ -168,19 +170,51 @@ void TemporarySummon::Summon(TempSummonType type, uint32 lifetime)
AIM_Initialize();
}
-void TemporarySummon::UnSummon()
+void TempSummon::UnSummon()
{
CleanupsBeforeDelete();
AddObjectToRemoveList();
- Unit* sum = m_summoner ? ObjectAccessor::GetUnit(*this, m_summoner) : NULL;
- if (sum && sum->GetTypeId() == TYPEID_UNIT && ((Creature*)sum)->IsAIEnabled)
+ Unit* owner = GetSummoner();
+ if(owner)
{
- ((Creature*)sum)->AI()->SummonedCreatureDespawn(this);
+ if(owner->GetTypeId() == TYPEID_UNIT && ((Creature*)owner)->IsAIEnabled)
+ ((Creature*)owner)->AI()->SummonedCreatureDespawn(this);
+ if(uint32 slot = m_properties->Slot)
+ {
+ --slot;
+ owner->m_TotemSlot[slot] = 0;
+ }
+ }
+}
+
+void TempSummon::SetSummonProperties(SummonPropertiesEntry const *properties)
+{
+ if(!properties)
+ return;
+
+ m_properties = properties;
+
+ if(uint32 slot = m_properties->Slot)
+ {
+ --slot;
+ Unit* owner = GetSummoner();
+ if(owner)
+ {
+ if(owner->m_TotemSlot[slot] && owner->m_TotemSlot[slot] != GetGUID())
+ {
+ Creature *OldTotem = ObjectAccessor::GetCreature(*this, owner->m_TotemSlot[slot]);
+ if(OldTotem && OldTotem->isSummon())
+ ((TempSummon*)OldTotem)->UnSummon();
+ }
+ owner->m_TotemSlot[slot] = GetGUID();
+ }
}
+
+ AIM_Initialize();
}
-void TemporarySummon::SaveToDB()
+void TempSummon::SaveToDB()
{
}