diff options
Diffstat (limited to 'src/game/TemporarySummon.cpp')
-rw-r--r-- | src/game/TemporarySummon.cpp | 50 |
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() { } |