diff options
| author | megamage <none@none> | 2009-02-20 12:05:58 -0600 |
|---|---|---|
| committer | megamage <none@none> | 2009-02-20 12:05:58 -0600 |
| commit | 1b587c0fe3355567173918d7a0b56141c6bcd1b2 (patch) | |
| tree | fd8b03d40861ec08c1fd3d47744131032f7398bd /src/game/SpellEffects.cpp | |
| parent | 187cd928ea6a02df715c349ec970d5899ef6274f (diff) | |
| parent | 956c828bf56f06b5c25ff20d760ad41be2642a51 (diff) | |
*Merge.
--HG--
branch : trunk
Diffstat (limited to 'src/game/SpellEffects.cpp')
| -rw-r--r-- | src/game/SpellEffects.cpp | 77 |
1 files changed, 27 insertions, 50 deletions
diff --git a/src/game/SpellEffects.cpp b/src/game/SpellEffects.cpp index 1686c8b607f..83ae7de09cf 100644 --- a/src/game/SpellEffects.cpp +++ b/src/game/SpellEffects.cpp @@ -3732,9 +3732,16 @@ void Spell::EffectSummonGuardian(uint32 i) return; } - // trigger - if(!m_originalCaster || m_originalCaster->GetTypeId() != TYPEID_PLAYER - && !((Creature*)m_originalCaster)->isTotem()/*m_spellInfo->Id == 40276*/) + Player *caster = NULL; + if(m_originalCaster) + { + if(m_originalCaster->GetTypeId() == TYPEID_PLAYER) + caster = (Player*)m_originalCaster; + else if(((Creature*)m_originalCaster)->isTotem()) + caster = m_originalCaster->GetCharmerOrOwnerPlayerOrPlayerItself(); + } + + if(!caster) { EffectSummonWild(i); return; @@ -3746,20 +3753,20 @@ void Spell::EffectSummonGuardian(uint32 i) // Search old Guardian only for players (if casted spell not have duration or cooldown) // FIXME: some guardians have control spell applied and controlled by player and anyway player can't summon in this time // so this code hack in fact - if( m_originalCaster->GetTypeId() == TYPEID_PLAYER && (duration <= 0 || GetSpellRecoveryTime(m_spellInfo)==0) ) - if(((Player*)m_originalCaster)->HasGuardianWithEntry(pet_entry)) + if(duration <= 0 || GetSpellRecoveryTime(m_spellInfo)==0) + if(caster->HasGuardianWithEntry(pet_entry)) return; // find old guardian, ignore summon // in another case summon new - uint32 level = m_originalCaster->getLevel(); + uint32 level = caster->getLevel(); // level of pet summoned using engineering item based at engineering skill level - if(m_originalCaster->GetTypeId()==TYPEID_PLAYER && m_CastItem) + if(m_CastItem) { ItemPrototype const *proto = m_CastItem->GetProto(); if(proto && proto->RequiredSkill == SKILL_ENGINERING) { - uint16 skill202 = ((Player*)m_originalCaster)->GetSkillValue(SKILL_ENGINERING); + uint16 skill202 = caster->GetSkillValue(SKILL_ENGINERING); if(skill202) { level = skill202/5; @@ -3778,18 +3785,6 @@ void Spell::EffectSummonGuardian(uint32 i) for(int32 count = 0; count < amount; ++count) { - Pet* spawnCreature = new Pet(GUARDIAN_PET); - spawnCreature->setActive(m_caster->isActive()); - - Map *map = m_caster->GetMap(); - uint32 pet_number = objmgr.GeneratePetNumber(); - if(!spawnCreature->Create(objmgr.GenerateLowGuid(HIGHGUID_PET), map,m_caster->GetPhaseMask(), - m_spellInfo->EffectMiscValue[i], pet_number)) - { - sLog.outError("no such creature entry %u",m_spellInfo->EffectMiscValue[i]); - delete spawnCreature; - return; - } float px, py, pz; // If dest location if present @@ -3808,47 +3803,27 @@ void Spell::EffectSummonGuardian(uint32 i) } // Summon if dest location not present near caster else - m_caster->GetClosePoint(px,py,pz,spawnCreature->GetObjectSize()); + m_caster->GetClosePoint(px,py,pz,m_caster->GetObjectSize()); - spawnCreature->Relocate(px,py,pz,m_caster->GetOrientation()); - - if(!spawnCreature->IsPositionValid()) - { - sLog.outError("ERROR: Pet (guidlow %d, entry %d) not created base at creature. Suggested coordinates isn't valid (X: %f Y: %f)", - spawnCreature->GetGUIDLow(), spawnCreature->GetEntry(), spawnCreature->GetPositionX(), spawnCreature->GetPositionY()); - delete spawnCreature; + Pet *spawnCreature = caster->SummonPet(m_spellInfo->EffectMiscValue[i], px, py, pz, m_caster->GetOrientation(), GUARDIAN_PET, duration); + if(!spawnCreature) return; - } - if(duration > 0) - spawnCreature->SetDuration(duration); - - spawnCreature->SetOwnerGUID(m_originalCaster->GetGUID()); spawnCreature->setPowerType(POWER_MANA); spawnCreature->SetUInt32Value(UNIT_NPC_FLAGS , 0); - spawnCreature->SetUInt32Value(UNIT_FIELD_FACTIONTEMPLATE,m_originalCaster->getFaction()); spawnCreature->SetUInt32Value(UNIT_FIELD_FLAGS,0); spawnCreature->SetUInt32Value(UNIT_FIELD_BYTES_1,0); spawnCreature->SetUInt32Value(UNIT_FIELD_PET_NAME_TIMESTAMP,0); - spawnCreature->SetCreatorGUID(m_originalCaster->GetGUID()); spawnCreature->SetUInt32Value(UNIT_CREATED_BY_SPELL, m_spellInfo->Id); spawnCreature->InitStatsForLevel(level); - spawnCreature->GetCharmInfo()->SetPetNumber(pet_number, false); - - spawnCreature->AIM_Initialize(); - - if(m_originalCaster->GetTypeId()==TYPEID_PLAYER) - ((Player*)m_originalCaster)->AddGuardian(spawnCreature); - - map->Add((Creature*)spawnCreature); } } void Spell::EffectSummonPossessed(uint32 i) { - uint32 creatureEntry = m_spellInfo->EffectMiscValue[i]; - if(!creatureEntry) + uint32 entry = m_spellInfo->EffectMiscValue[i]; + if(!entry) return; if(m_caster->GetTypeId() != TYPEID_PLAYER) @@ -3856,15 +3831,17 @@ void Spell::EffectSummonPossessed(uint32 i) uint32 level = m_caster->getLevel(); - float px, py, pz; - m_caster->GetClosePoint(px, py, pz, DEFAULT_WORLD_OBJECT_SIZE); + float x, y, z; + m_caster->GetClosePoint(x, y, z, DEFAULT_WORLD_OBJECT_SIZE); int32 duration = GetSpellDuration(m_spellInfo); - TempSummonType summonType = (duration == 0) ? TEMPSUMMON_DEAD_DESPAWN : TEMPSUMMON_TIMED_OR_DEAD_DESPAWN; + Pet* pet = ((Player*)m_caster)->SummonPet(entry, x, y, z, m_caster->GetOrientation(), POSSESSED_PET, duration); + if(!pet) + return; - Creature* c = m_caster->SummonCreature(creatureEntry, px, py, pz, m_caster->GetOrientation(), summonType, duration); - if(c) c->SetCharmedOrPossessedBy(m_caster, true); + pet->SetUInt32Value(UNIT_CREATED_BY_SPELL, m_spellInfo->Id); + pet->SetCharmedOrPossessedBy(m_caster, true); } void Spell::EffectTeleUnitsFaceCaster(uint32 i) |
