From 750fd7f885a616c1d5e306d24b2789e61c949c2f Mon Sep 17 00:00:00 2001 From: hondacrx Date: Thu, 26 May 2022 21:50:25 -0400 Subject: [PATCH] Core/SAI: Allow SMART_ACTION_SUMMON_CREATURE to summon more than 1 creature Port From (https://github.com/TrinityCore/TrinityCore/commit/40416d62f354c2a49f6acf9fac094401e25d3db8) --- Source/Game/AI/SmartScripts/SmartAIManager.cs | 1 + Source/Game/AI/SmartScripts/SmartScript.cs | 23 ++++++++++++------- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/Source/Game/AI/SmartScripts/SmartAIManager.cs b/Source/Game/AI/SmartScripts/SmartAIManager.cs index 2ac9dabdb..77b8e0139 100644 --- a/Source/Game/AI/SmartScripts/SmartAIManager.cs +++ b/Source/Game/AI/SmartScripts/SmartAIManager.cs @@ -2774,6 +2774,7 @@ namespace Game.AI public uint storageID; public uint attackInvoker; public uint flags; // SmartActionSummonCreatureFlags + public uint count; } public struct ThreatPCT { diff --git a/Source/Game/AI/SmartScripts/SmartScript.cs b/Source/Game/AI/SmartScripts/SmartScript.cs index 75007bc96..79ebb8042 100644 --- a/Source/Game/AI/SmartScripts/SmartScript.cs +++ b/Source/Game/AI/SmartScripts/SmartScript.cs @@ -1200,6 +1200,7 @@ namespace Game.AI ObjectGuid privateObjectOwner = ObjectGuid.Empty; if (flags.HasAnyFlag(SmartActionSummonCreatureFlags.PersonalSpawn)) privateObjectOwner = summoner.IsPrivateObject() ? summoner.GetPrivateObjectOwner() : summoner.GetGUID(); + uint spawnsCount = Math.Max(e.Action.summonCreature.count, 1u); float x, y, z, o; foreach (var target in targets) @@ -1209,19 +1210,25 @@ namespace Game.AI y += e.Target.y; z += e.Target.z; o += e.Target.o; - Creature summon = summoner.SummonCreature(e.Action.summonCreature.creature, x, y, z, o, (TempSummonType)e.Action.summonCreature.type, TimeSpan.FromMilliseconds(e.Action.summonCreature.duration), privateObjectOwner); - if (summon != null) - if (e.Action.summonCreature.attackInvoker != 0) - summon.GetAI().AttackStart(target.ToUnit()); + for (uint counter = 0; counter < spawnsCount; counter++) + { + Creature summon = summoner.SummonCreature(e.Action.summonCreature.creature, x, y, z, o, (TempSummonType)e.Action.summonCreature.type, TimeSpan.FromMilliseconds(e.Action.summonCreature.duration), privateObjectOwner); + if (summon != null) + if (e.Action.summonCreature.attackInvoker != 0) + summon.GetAI().AttackStart(target.ToUnit()); + } } if (e.GetTargetType() != SmartTargets.Position) break; - Creature summon1 = summoner.SummonCreature(e.Action.summonCreature.creature, e.Target.x, e.Target.y, e.Target.z, e.Target.o, (TempSummonType)e.Action.summonCreature.type, TimeSpan.FromMilliseconds(e.Action.summonCreature.duration), privateObjectOwner); - if (summon1 != null) - if (unit != null && e.Action.summonCreature.attackInvoker != 0) - summon1.GetAI().AttackStart(unit); + for (uint counter = 0; counter < spawnsCount; counter++) + { + Creature summon = summoner.SummonCreature(e.Action.summonCreature.creature, e.Target.x, e.Target.y, e.Target.z, e.Target.o, (TempSummonType)e.Action.summonCreature.type, TimeSpan.FromMilliseconds(e.Action.summonCreature.duration), privateObjectOwner); + if (summon != null) + if (unit != null && e.Action.summonCreature.attackInvoker != 0) + summon.GetAI().AttackStart(unit); + } break; } case SmartActions.SummonGo: