From 86d479a087a7260af49f3620fa7b51d02cf1f950 Mon Sep 17 00:00:00 2001 From: Ovahlord Date: Fri, 31 Jan 2020 07:46:43 +0100 Subject: [PATCH] Core/Spells: expand personal spawn handling for summons to all kind of summons * personal summon target checks for spells will now always happen instead of only if a player is the caster --- src/server/game/Spells/Spell.h | 2 +- src/server/game/Spells/SpellEffects.cpp | 14 +++++++------- src/server/game/Spells/SpellInfo.cpp | 7 +++---- 3 files changed, 11 insertions(+), 12 deletions(-) diff --git a/src/server/game/Spells/Spell.h b/src/server/game/Spells/Spell.h index 84e056bd1dd..568d55f962f 100644 --- a/src/server/game/Spells/Spell.h +++ b/src/server/game/Spells/Spell.h @@ -735,7 +735,7 @@ class TC_GAME_API Spell HitTriggerSpellList m_hitTriggerSpells; // effect helpers - void SummonGuardian(uint32 i, uint32 entry, SummonPropertiesEntry const* properties, uint32 numSummons); + void SummonGuardian(uint32 i, uint32 entry, SummonPropertiesEntry const* properties, uint32 numSummons, bool visibleBySummonerOnly = false); void CalculateJumpSpeeds(uint8 i, float dist, float & speedxy, float & speedz); void UpdateSpellCastDataTargets(WorldPackets::Spells::SpellHitInfo& data); diff --git a/src/server/game/Spells/SpellEffects.cpp b/src/server/game/Spells/SpellEffects.cpp index b59ccb96de2..4a84fa7ff54 100644 --- a/src/server/game/Spells/SpellEffects.cpp +++ b/src/server/game/Spells/SpellEffects.cpp @@ -1885,7 +1885,7 @@ void Spell::EffectSummonType(SpellEffIndex effIndex) case SUMMON_CATEGORY_UNK: if (properties->Flags & 512) { - SummonGuardian(effIndex, entry, properties, numSummons); + SummonGuardian(effIndex, entry, properties, numSummons, personalSpawn); break; } switch (properties->Title) @@ -1894,12 +1894,12 @@ void Spell::EffectSummonType(SpellEffIndex effIndex) case SUMMON_TYPE_GUARDIAN: case SUMMON_TYPE_GUARDIAN2: case SUMMON_TYPE_MINION: - SummonGuardian(effIndex, entry, properties, numSummons); + SummonGuardian(effIndex, entry, properties, numSummons, personalSpawn); break; // Summons a vehicle, but doesn't force anyone to enter it (see SUMMON_CATEGORY_VEHICLE) case SUMMON_TYPE_VEHICLE: case SUMMON_TYPE_VEHICLE2: - summon = m_caster->GetMap()->SummonCreature(entry, *destTarget, properties, duration, m_originalCaster, m_spellInfo->Id); + summon = m_caster->GetMap()->SummonCreature(entry, *destTarget, properties, duration, m_originalCaster, m_spellInfo->Id, 0, personalSpawn); break; case SUMMON_TYPE_LIGHTWELL: case SUMMON_TYPE_TOTEM: @@ -1964,7 +1964,7 @@ void Spell::EffectSummonType(SpellEffIndex effIndex) }//switch break; case SUMMON_CATEGORY_PET: - SummonGuardian(effIndex, entry, properties, numSummons); + SummonGuardian(effIndex, entry, properties, numSummons, personalSpawn); break; case SUMMON_CATEGORY_PUPPET: summon = m_caster->GetMap()->SummonCreature(entry, *destTarget, properties, duration, m_originalCaster, m_spellInfo->Id, 0, personalSpawn); @@ -1972,7 +1972,7 @@ void Spell::EffectSummonType(SpellEffIndex effIndex) case SUMMON_CATEGORY_VEHICLE: // Summoning spells (usually triggered by npc_spellclick) that spawn a vehicle and that cause the clicker // to cast a ride vehicle spell on the summoned unit. - summon = m_originalCaster->GetMap()->SummonCreature(entry, *destTarget, properties, duration, m_caster, m_spellInfo->Id); + summon = m_originalCaster->GetMap()->SummonCreature(entry, *destTarget, properties, duration, m_caster, m_spellInfo->Id, 0, personalSpawn); if (!summon || !summon->IsVehicle()) return; @@ -5315,7 +5315,7 @@ void Spell::EffectGameObjectSetDestructionState(SpellEffIndex effIndex) gameObjTarget->SetDestructibleState(GameObjectDestructibleState(m_spellInfo->Effects[effIndex].MiscValue), player, true); } -void Spell::SummonGuardian(uint32 i, uint32 entry, SummonPropertiesEntry const* properties, uint32 numGuardians) +void Spell::SummonGuardian(uint32 i, uint32 entry, SummonPropertiesEntry const* properties, uint32 numGuardians, bool visibleBySummonerOny /*= false*/) { Unit* caster = m_originalCaster; if (!caster) @@ -5352,7 +5352,7 @@ void Spell::SummonGuardian(uint32 i, uint32 entry, SummonPropertiesEntry const* // randomize position for multiple summons pos = m_caster->GetRandomPoint(*destTarget, radius); - TempSummon* summon = map->SummonCreature(entry, pos, properties, duration, caster, m_spellInfo->Id); + TempSummon* summon = map->SummonCreature(entry, pos, properties, duration, caster, m_spellInfo->Id, 0, visibleBySummonerOny); if (!summon) return; diff --git a/src/server/game/Spells/SpellInfo.cpp b/src/server/game/Spells/SpellInfo.cpp index d7214469424..75eaf7f90bb 100644 --- a/src/server/game/Spells/SpellInfo.cpp +++ b/src/server/game/Spells/SpellInfo.cpp @@ -1923,10 +1923,9 @@ SpellCastResult SpellInfo::CheckTarget(Unit const* caster, WorldObject const* ta if (HasEffect(SPELL_EFFECT_SELF_RESURRECT) || HasEffect(SPELL_EFFECT_RESURRECT) || HasEffect(SPELL_EFFECT_RESURRECT_NEW)) return SPELL_FAILED_TARGET_CANNOT_BE_RESURRECTED; - if (caster->GetTypeId() == TYPEID_PLAYER) - if (TempSummon const* summon = unitTarget->ToTempSummon()) - if (summon->IsVisibleBySummonerOnly() && summon->GetSummonerGUID() != caster->GetGUID()) - return SPELL_FAILED_BAD_TARGETS; + if (TempSummon const* summon = unitTarget->ToTempSummon()) + if (summon->IsVisibleBySummonerOnly() && summon->GetSummonerGUID() != caster->GetGUID()) + return SPELL_FAILED_BAD_TARGETS; return SPELL_CAST_OK; }