From afe10147230e9e9f6b483aecce095aee99191cf5 Mon Sep 17 00:00:00 2001 From: Sevi Date: Mon, 28 Aug 2023 08:21:48 +0200 Subject: [PATCH 1/2] Core/Spells: implement a way for TARGET_DEST_NEARBY_ENTRY_2 to select more as one possible summon position that is fix and not a random point. Summons without TARGET_DEST_NEARBY_ENTRY_2 and more as 1 summon use now the random point generated position to summon the creatures. --- src/server/game/Spells/SpellEffects.cpp | 32 +++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/src/server/game/Spells/SpellEffects.cpp b/src/server/game/Spells/SpellEffects.cpp index 49c726be26..cfb3eec043 100644 --- a/src/server/game/Spells/SpellEffects.cpp +++ b/src/server/game/Spells/SpellEffects.cpp @@ -2009,17 +2009,45 @@ void Spell::EffectSummonType(SpellEffIndex effIndex) } } + /* + TARGET_DEST_NEARBY_ENTRY_2 -> is mostly used by summon spells for more as one summon with fix spawn positions + */ + std::vector targetList; + bool _foundMoreTargets = false; + uint8 _targetCounter = 0; + if (summonCount > 1 && m_spellInfo->Effects[effIndex].TargetB.GetTarget() == TARGET_DEST_NEARBY_ENTRY_2) + { + ConditionContainer* condList = m_spellInfo->Effects[effIndex].ImplicitTargetConditions; + SpellImplicitTargetInfo const& targetType = m_spellInfo->Effects[effIndex].TargetB; + + std::list tempTargets; + SearchAreaTargets(tempTargets, m_spellInfo->Effects[effIndex].CalcRadius(), destTarget, m_caster, targetType.GetObjectType(), targetType.GetCheckType(), condList); + + for (auto& itr : tempTargets) + { + _foundMoreTargets = true; + ++_targetCounter; + targetList.push_back(itr); + } + + if (_targetCounter >= 1) + _targetCounter -= 1; + + // Shuffle Targets to get randomize points. + Trinity::Containers::RandomShuffle(targetList); + } + for (uint32 i = 0; i < summonCount; ++i) { Position dest = *destTarget; - if (summonCount > 1) + if (summonCount > 1 && m_spellInfo->Effects[effIndex].TargetB.GetTarget() != TARGET_DEST_NEARBY_ENTRY_2) { // Multiple summons are summoned at random points within the destination radius float radius = m_spellInfo->Effects[effIndex].CalcRadius(); dest = caster->GetRandomPoint(*destTarget, radius); } - if (TempSummon* summon = caster->GetMap()->SummonCreature(entry, *destTarget, extraArgs)) + if (TempSummon* summon = caster->GetMap()->SummonCreature(entry, !_foundMoreTargets ? dest : *targetList[_targetCounter], extraArgs)) { ExecuteLogEffectSummonObject(effIndex, summon); From 42dd588797311b3b573e00982d73e31e16a85aa6 Mon Sep 17 00:00:00 2001 From: Sevi Date: Mon, 28 Aug 2023 08:23:30 +0200 Subject: [PATCH 2/2] Core/Spells: add missing file save --- src/server/game/Spells/SpellEffects.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/server/game/Spells/SpellEffects.cpp b/src/server/game/Spells/SpellEffects.cpp index cfb3eec043..8a87b5e2cd 100644 --- a/src/server/game/Spells/SpellEffects.cpp +++ b/src/server/game/Spells/SpellEffects.cpp @@ -2049,6 +2049,7 @@ void Spell::EffectSummonType(SpellEffIndex effIndex) if (TempSummon* summon = caster->GetMap()->SummonCreature(entry, !_foundMoreTargets ? dest : *targetList[_targetCounter], extraArgs)) { + --_targetCounter; ExecuteLogEffectSummonObject(effIndex, summon); if (summonCount == 1 && summon->IsVehicle())