Skip to content

Commit

Permalink
[11073] Prevent applying SPELLMOD_DURATION for summons with unlimited…
Browse files Browse the repository at this point in the history
… duration.

Fixes summon duration of spell 70908 in combination with talent 44557 and ranks.
  • Loading branch information
Lynx3d committed Jan 26, 2011
1 parent d2a41c8 commit 097bbbf
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 15 deletions.
2 changes: 2 additions & 0 deletions src/game/Pet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1908,6 +1908,8 @@ bool Pet::IsPermanentPetFor(Player* owner)
case SUMMON_PET:
switch(owner->getClass())
{
// oddly enough, Mage's Water Elemental is still treated as temporary pet with Glyph of Eternal Water
// i.e. does not unsummon at mounting, gets dismissed at teleport etc.
case CLASS_WARLOCK:
return GetCreatureInfo()->type == CREATURE_TYPE_DEMON;
case CLASS_DEATH_KNIGHT:
Expand Down
31 changes: 17 additions & 14 deletions src/game/SpellEffects.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4328,8 +4328,9 @@ void Spell::DoSummon(SpellEffectIndex eff_idx)
Pet* spawnCreature = new Pet(SUMMON_PET);

int32 duration = GetSpellDuration(m_spellInfo);
if(Player* modOwner = m_caster->GetSpellModOwner())
modOwner->ApplySpellMod(m_spellInfo->Id, SPELLMOD_DURATION, duration);
if (duration > 0)
if (Player* modOwner = m_caster->GetSpellModOwner())
modOwner->ApplySpellMod(m_spellInfo->Id, SPELLMOD_DURATION, duration);

if (m_caster->GetTypeId()==TYPEID_PLAYER && spawnCreature->LoadPetFromDB((Player*)m_caster,pet_entry))
{
Expand Down Expand Up @@ -4801,12 +4802,13 @@ void Spell::DoSummonGuardian(SpellEffectIndex eff_idx, uint32 forceFaction)

float radius = GetSpellRadius(sSpellRadiusStore.LookupEntry(m_spellInfo->EffectRadiusIndex[eff_idx]));
int32 duration = GetSpellDuration(m_spellInfo);
if(Player* modOwner = m_caster->GetSpellModOwner())
modOwner->ApplySpellMod(m_spellInfo->Id, SPELLMOD_DURATION, duration);
if (duration > 0)
if (Player* modOwner = m_caster->GetSpellModOwner())
modOwner->ApplySpellMod(m_spellInfo->Id, SPELLMOD_DURATION, duration);

int32 amount = damage > 0 ? damage : 1;

for(int32 count = 0; count < amount; ++count)
for (int32 count = 0; count < amount; ++count)
{
Pet* spawnCreature = new Pet(petType);

Expand Down Expand Up @@ -7276,7 +7278,7 @@ void Spell::DoSummonTotem(SpellEffectIndex eff_idx, uint8 slot_dbc)
int slot = slot_dbc ? slot_dbc - 1 : TOTEM_SLOT_NONE;

// unsummon old totem
if(slot < MAX_TOTEM_SLOT)
if (slot < MAX_TOTEM_SLOT)
if (Totem *OldTotem = m_caster->GetTotem(TotemSlot(slot)))
OldTotem->UnSummon();

Expand All @@ -7286,8 +7288,8 @@ void Spell::DoSummonTotem(SpellEffectIndex eff_idx, uint8 slot_dbc)

Totem* pTotem = new Totem;

if(!pTotem->Create(sObjectMgr.GenerateLowGuid(HIGHGUID_UNIT), m_caster->GetMap(), m_caster->GetPhaseMask(),
m_spellInfo->EffectMiscValue[eff_idx], team ))
if (!pTotem->Create(sObjectMgr.GenerateLowGuid(HIGHGUID_UNIT), m_caster->GetMap(), m_caster->GetPhaseMask(),
m_spellInfo->EffectMiscValue[eff_idx], team))
{
delete pTotem;
return;
Expand All @@ -7306,7 +7308,7 @@ void Spell::DoSummonTotem(SpellEffectIndex eff_idx, uint8 slot_dbc)
m_caster->GetClosePoint(x, y, z, pTotem->GetObjectBoundingRadius(), 2.0f, angle);

// totem must be at same Z in case swimming caster and etc.
if( fabs( z - m_caster->GetPositionZ() ) > 5 )
if (fabs( z - m_caster->GetPositionZ() ) > 5)
z = m_caster->GetPositionZ();

pTotem->Relocate(x, y, z, m_caster->GetOrientation());
Expand All @@ -7320,8 +7322,9 @@ void Spell::DoSummonTotem(SpellEffectIndex eff_idx, uint8 slot_dbc)
pTotem->SetTypeBySummonSpell(m_spellInfo); // must be after Create call where m_spells initialized

int32 duration=GetSpellDuration(m_spellInfo);
if (Player* modOwner = m_caster->GetSpellModOwner())
modOwner->ApplySpellMod(m_spellInfo->Id, SPELLMOD_DURATION, duration);
if (duration > 0)
if (Player* modOwner = m_caster->GetSpellModOwner())
modOwner->ApplySpellMod(m_spellInfo->Id, SPELLMOD_DURATION, duration);
pTotem->SetDuration(duration);

if (damage) // if not spell info, DB values used
Expand All @@ -7332,13 +7335,13 @@ void Spell::DoSummonTotem(SpellEffectIndex eff_idx, uint8 slot_dbc)

pTotem->SetUInt32Value(UNIT_CREATED_BY_SPELL, m_spellInfo->Id);

if(m_caster->GetTypeId() == TYPEID_PLAYER)
if (m_caster->GetTypeId() == TYPEID_PLAYER)
pTotem->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PVP_ATTACKABLE);

if(m_caster->IsPvP())
if (m_caster->IsPvP())
pTotem->SetPvP(true);

if(m_caster->IsFFAPvP())
if (m_caster->IsFFAPvP())
pTotem->SetFFAPvP(true);

pTotem->Summon(m_caster);
Expand Down
2 changes: 1 addition & 1 deletion src/shared/revision_nr.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#ifndef __REVISION_NR_H__
#define __REVISION_NR_H__
#define REVISION_NR "11072"
#define REVISION_NR "11073"
#endif // __REVISION_NR_H__

0 comments on commit 097bbbf

Please sign in to comment.