diff options
Diffstat (limited to 'src/game/SpellEffects.cpp')
| -rw-r--r-- | src/game/SpellEffects.cpp | 338 |
1 files changed, 141 insertions, 197 deletions
diff --git a/src/game/SpellEffects.cpp b/src/game/SpellEffects.cpp index e1fcae5f1a0..80885d05575 100644 --- a/src/game/SpellEffects.cpp +++ b/src/game/SpellEffects.cpp @@ -3238,6 +3238,38 @@ void Spell::EffectSummonType(uint32 i) return; } + if(!m_originalCaster) + return; + + int32 duration = GetSpellDuration(m_spellInfo); + if(Player* modOwner = m_originalCaster->GetSpellModOwner()) + modOwner->ApplySpellMod(m_spellInfo->Id, SPELLMOD_DURATION, duration); + + float x, y, z; + GetSummonPosition(x, y, z); + + /*//totem must be at same Z in case swimming caster and etc. + if( fabs( z - m_caster->GetPositionZ() ) > 5 ) + z = m_caster->GetPositionZ(); + + uint32 level = m_caster->getLevel(); + + // level of creature summoned using engineering item based at engineering skill level + if(m_caster->GetTypeId()==TYPEID_PLAYER && m_CastItem) + { + ItemPrototype const *proto = m_CastItem->GetProto(); + if(proto && proto->RequiredSkill == SKILL_ENGINERING) + { + uint16 skill202 = ((Player*)m_caster)->GetSkillValue(SKILL_ENGINERING); + if(skill202) + { + level = skill202/5; + } + } + }*/ + + TempSummon *summon = NULL; + switch(properties->Category) { default: @@ -3250,28 +3282,130 @@ void Spell::EffectSummonType(uint32 i) break; case SUMMON_TYPE_VEHICLE: case SUMMON_TYPE_VEHICLE2: - SummonVehicle(entry, properties); + { + Vehicle *vehicle = m_caster->SummonVehicle(entry, x, y, z, m_caster->GetOrientation()); + if(!vehicle) + return; + + vehicle->SetUInt64Value(UNIT_FIELD_SUMMONEDBY, m_caster->GetGUID()); + vehicle->SetUInt32Value(UNIT_CREATED_BY_SPELL, m_spellInfo->Id); break; + } case SUMMON_TYPE_TOTEM: - SummonTotem(entry, properties); + { + summon = m_caster->GetMap()->SummonCreature(entry, x, y, z, m_caster->GetOrientation(), properties, duration, m_originalCaster); + if(!summon || !summon->isTotem()) + return; + + summon->SetOwner(m_originalCaster, true); + + if(damage) // if not spell info, DB values used + { + summon->SetMaxHealth(damage); + summon->SetHealth(damage); + } + + if(m_originalCaster->GetTypeId() == TYPEID_PLAYER + && properties->Slot >= SUMMON_SLOT_TOTEM + && properties->Slot < MAX_TOTEM_SLOT) + { + WorldPacket data(SMSG_TOTEM_CREATED, 1+8+4+4); + data << uint8(properties->Slot-1); + data << uint64(m_originalCaster->GetGUID()); + data << uint32(duration); + data << uint32(m_spellInfo->Id); + ((Player*)m_originalCaster)->SendDirectMessage(&data); + } break; + } case SUMMON_TYPE_MINIPET: - EffectSummonCritter(i); + { + summon = m_caster->GetMap()->SummonCreature(entry, x, y, z, m_caster->GetOrientation(), properties, duration, m_originalCaster); + if(!summon) + return; + + summon->SetOwner(m_originalCaster, true); + summon->SetCreatorGUID(m_originalCaster->GetGUID()); + summon->setFaction(m_originalCaster->getFaction()); + + //summon->InitPetCreateSpells(); // e.g. disgusting oozeling has a create spell as summon... + summon->SetMaxHealth(1); + summon->SetHealth(1); + summon->SetLevel(1); + + summon->SetReactState(REACT_PASSIVE); + summon->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); + + summon->GetMotionMaster()->MoveTargetedHome(); + + std::string name = m_originalCaster->GetName(); + name.append(petTypeSuffix[3]); + summon->SetName( name ); break; + } default: - EffectSummonWild(i); + { + float radius = GetSpellRadiusForHostile(sSpellRadiusStore.LookupEntry(m_spellInfo->EffectRadiusIndex[i])); + + int32 amount = damage > 0 ? damage : 1; + + for(int32 count = 0; count < amount; ++count) + { + float px, py, pz; + GetSummonPosition(px, py, pz, radius, count); + + TempSummonType summonType = (duration == 0) ? TEMPSUMMON_DEAD_DESPAWN : TEMPSUMMON_TIMED_DESPAWN; + + m_originalCaster->SummonCreature(entry,px,py,pz,m_caster->GetOrientation(),summonType,duration); + } break; - } + } + }//switch break; case SUMMON_CATEGORY_PET: SummonGuardian(entry, properties); break; case SUMMON_CATEGORY_POSSESSED: - SummonPossessed(entry, properties); + { + if(m_caster->GetTypeId() != TYPEID_PLAYER) + return; + + float x, y, z; + m_caster->GetClosePoint(x, y, z, DEFAULT_WORLD_OBJECT_SIZE); + + int32 duration = GetSpellDuration(m_spellInfo); + + Pet* pet = ((Player*)m_caster)->SummonPet(entry, x, y, z, m_caster->GetOrientation(), POSSESSED_PET, duration); + if(!pet) + return; + + pet->SetUInt32Value(UNIT_CREATED_BY_SPELL, m_spellInfo->Id); + pet->SetCharmedOrPossessedBy(m_caster, true); break; + } case SUMMON_CATEGORY_VEHICLE: - SummonVehicle(entry, properties); + { + float x, y, z; + m_caster->GetClosePoint(x, y, z, DEFAULT_WORLD_OBJECT_SIZE); + Vehicle *vehicle = m_caster->SummonVehicle(entry, x, y, z, m_caster->GetOrientation()); + if(!vehicle) + return; + + vehicle->SetUInt64Value(UNIT_FIELD_SUMMONEDBY, m_caster->GetGUID()); + vehicle->SetUInt32Value(UNIT_CREATED_BY_SPELL, m_spellInfo->Id); + + if(damage) + { + m_caster->CastSpell(vehicle, damage, true); + m_caster->EnterVehicle(vehicle); + } break; + } + } + + if(summon) + { + summon->SetUInt32Value(UNIT_CREATED_BY_SPELL, m_spellInfo->Id); } } @@ -3504,48 +3638,6 @@ void Spell::EffectAddFarsight(uint32 i) ((Player*)m_caster)->UpdateVisibilityOf(dynObj); } -void Spell::EffectSummonWild(uint32 i) -{ - uint32 creature_entry = m_spellInfo->EffectMiscValue[i]; - if(!creature_entry) - return; - - uint32 level = m_caster->getLevel(); - - // level of creature summoned using engineering item based at engineering skill level - if(m_caster->GetTypeId()==TYPEID_PLAYER && m_CastItem) - { - ItemPrototype const *proto = m_CastItem->GetProto(); - if(proto && proto->RequiredSkill == SKILL_ENGINERING) - { - uint16 skill202 = ((Player*)m_caster)->GetSkillValue(SKILL_ENGINERING); - if(skill202) - { - level = skill202/5; - } - } - } - - float radius = GetSpellRadiusForHostile(sSpellRadiusStore.LookupEntry(m_spellInfo->EffectRadiusIndex[i])); - - int32 amount = damage > 0 ? damage : 1; - - for(int32 count = 0; count < amount; ++count) - { - float px, py, pz; - GetSummonPosition(px, py, pz, radius, count); - - int32 duration = GetSpellDuration(m_spellInfo); - - TempSummonType summonType = (duration == 0) ? TEMPSUMMON_DEAD_DESPAWN : TEMPSUMMON_TIMED_DESPAWN; - - if(m_originalCaster) - m_originalCaster->SummonCreature(creature_entry,px,py,pz,m_caster->GetOrientation(),summonType,duration); - else - m_caster->SummonCreature(creature_entry,px,py,pz,m_caster->GetOrientation(),summonType,duration); - } -} - void Spell::EffectTeleUnitsFaceCaster(uint32 i) { if(!unitTarget) @@ -5723,44 +5815,6 @@ void Spell::EffectCharge(uint32 /*i*/) m_caster->Attack(target, true); } -void Spell::EffectSummonCritter(uint32 i) -{ - if(m_caster->GetTypeId() != TYPEID_PLAYER) - return; - Player* player = (Player*)m_caster; - - uint32 pet_entry = m_spellInfo->EffectMiscValue[i]; - if(!pet_entry) - return; - - float x,y,z; - GetSummonPosition(x, y, z); - - int32 duration = GetSpellDuration(m_spellInfo); - TempSummon *critter = m_caster->GetMap()->SummonCreature(pet_entry, x, y, z, m_caster->GetOrientation(), sSummonPropertiesStore.LookupEntry(m_spellInfo->EffectMiscValueB[i]), duration, m_caster); - if(!critter) - return; - - critter->SetOwner(m_caster, true); - critter->SetCreatorGUID(m_caster->GetGUID()); - critter->SetUInt32Value(UNIT_FIELD_FACTIONTEMPLATE,m_caster->getFaction()); - critter->SetUInt32Value(UNIT_CREATED_BY_SPELL, m_spellInfo->Id); - - //critter->InitPetCreateSpells(); // e.g. disgusting oozeling has a create spell as critter... - critter->SetMaxHealth(1); - critter->SetHealth(1); - critter->SetLevel(1); - - critter->SetReactState(REACT_PASSIVE); - critter->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); - - critter->GetMotionMaster()->MoveTargetedHome(); - - std::string name = player->GetName(); - name.append(petTypeSuffix[3]); - critter->SetName( name ); -} - void Spell::EffectKnockBack(uint32 i) { if(!unitTarget) @@ -6366,78 +6420,6 @@ void Spell::EffectRedirectThreat(uint32 /*i*/) m_caster->SetReducedThreatPercent((uint32)damage, unitTarget->GetGUID()); } -void Spell::SummonTotem(uint32 entry, SummonPropertiesEntry const *properties) -{ - int8 slot = (int8)properties->Slot; - - if(slot >= SUMMON_SLOT_TOTEM && slot < MAX_TOTEM_SLOT) - { - uint64 guid = m_caster->m_SummonSlot[slot]; - if(guid != 0) - { - Creature *OldTotem = m_caster->GetMap()->GetCreature(guid); - if(OldTotem && OldTotem->isTotem()) - ((Totem*)OldTotem)->UnSummon(); - } - } - - uint32 team = 0; - if (m_caster->GetTypeId()==TYPEID_PLAYER) - team = ((Player*)m_caster)->GetTeam(); - - Totem* pTotem = new Totem(properties, m_caster); - - if(!pTotem->Create(objmgr.GenerateLowGuid(HIGHGUID_UNIT), m_caster->GetMap(), m_caster->GetPhaseMask(), - entry, team )) - { - delete pTotem; - return; - } - - float x,y,z; - GetSummonPosition(x, y, z); - - // totem must be at same Z in case swimming caster and etc. - if( fabs( z - m_caster->GetPositionZ() ) > 5 ) - z = m_caster->GetPositionZ(); - - pTotem->Relocate(x, y, z, m_caster->GetOrientation()); - - if(slot >= SUMMON_SLOT_TOTEM && slot < MAX_TOTEM_SLOT) - m_caster->m_SummonSlot[slot] = pTotem->GetGUID(); - - pTotem->SetOwner(m_caster); - pTotem->SetTypeBySummonSpell(m_spellInfo); // must be after Create call where m_spells initilized - - int32 duration=GetSpellDuration(m_spellInfo); - 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 - { - pTotem->SetMaxHealth(damage); - pTotem->SetHealth(damage); - } - - pTotem->SetUInt32Value(UNIT_CREATED_BY_SPELL,m_spellInfo->Id); - - if(m_caster->GetTypeId() == TYPEID_PLAYER) - pTotem->SetFlag(UNIT_FIELD_FLAGS,UNIT_FLAG_PVP_ATTACKABLE); - - pTotem->Summon(m_caster); - - if(slot >= SUMMON_SLOT_TOTEM && slot < MAX_TOTEM_SLOT && m_caster->GetTypeId() == TYPEID_PLAYER) - { - WorldPacket data(SMSG_TOTEM_CREATED, 1+8+4+4); - data << uint8(slot-1); - data << uint64(pTotem->GetGUID()); - data << uint32(duration); - data << uint32(m_spellInfo->Id); - ((Player*)m_caster)->SendDirectMessage(&data); - } -} - void Spell::SummonGuardian(uint32 entry, SummonPropertiesEntry const *properties) { Unit *caster = m_originalCaster; @@ -6486,44 +6468,6 @@ void Spell::SummonGuardian(uint32 entry, SummonPropertiesEntry const *properties } } -void Spell::SummonPossessed(uint32 entry, SummonPropertiesEntry const *properties) -{ - if(m_caster->GetTypeId() != TYPEID_PLAYER) - return; - - uint32 level = m_caster->getLevel(); - - float x, y, z; - m_caster->GetClosePoint(x, y, z, DEFAULT_WORLD_OBJECT_SIZE); - - int32 duration = GetSpellDuration(m_spellInfo); - - Pet* pet = ((Player*)m_caster)->SummonPet(entry, x, y, z, m_caster->GetOrientation(), POSSESSED_PET, duration); - if(!pet) - return; - - pet->SetUInt32Value(UNIT_CREATED_BY_SPELL, m_spellInfo->Id); - pet->SetCharmedOrPossessedBy(m_caster, true); -} - -void Spell::SummonVehicle(uint32 entry, SummonPropertiesEntry const *properties) -{ - float x, y, z; - m_caster->GetClosePoint(x, y, z, DEFAULT_WORLD_OBJECT_SIZE); - Vehicle *vehicle = m_caster->SummonVehicle(entry, x, y, z, m_caster->GetOrientation()); - if(!vehicle) - return; - - vehicle->SetUInt64Value(UNIT_FIELD_SUMMONEDBY, m_caster->GetGUID()); - vehicle->SetUInt32Value(UNIT_CREATED_BY_SPELL, m_spellInfo->Id); - - if(damage) - { - m_caster->CastSpell(vehicle, damage, true); - m_caster->EnterVehicle(vehicle); - } -} - void Spell::GetSummonPosition(float &x, float &y, float &z, float radius, uint32 count) { if (m_targets.m_targetMask & TARGET_FLAG_DEST_LOCATION) |
