diff options
author | jackpoz <giacomopoz@gmail.com> | 2021-06-17 19:47:50 +0200 |
---|---|---|
committer | Shauren <shauren.trinity@gmail.com> | 2022-03-11 10:43:08 +0100 |
commit | 40416d62f354c2a49f6acf9fac094401e25d3db8 (patch) | |
tree | 6dcc3432033e446ea73f49f0004bd41073eb305c /src | |
parent | cc38710adbdc60b937ec8705adb3165e74f3c572 (diff) |
Core/SAI: Allow SMART_ACTION_SUMMON_CREATURE to summon more than 1 creature
Add 6th parameter "count" to SMART_ACTION_SUMMON_CREATURE action to summon more than 1 creature. For backward compatibility, a value of 0 will be treated as 1.
(cherry picked from commit 5628ca7f7cf2fdc053551d3f5e90ad466f3db2e6)
Diffstat (limited to 'src')
-rw-r--r-- | src/server/game/AI/SmartScripts/SmartScript.cpp | 19 | ||||
-rw-r--r-- | src/server/game/AI/SmartScripts/SmartScriptMgr.h | 1 |
2 files changed, 14 insertions, 6 deletions
diff --git a/src/server/game/AI/SmartScripts/SmartScript.cpp b/src/server/game/AI/SmartScripts/SmartScript.cpp index 27efa4ec609..2a3bd046992 100644 --- a/src/server/game/AI/SmartScripts/SmartScript.cpp +++ b/src/server/game/AI/SmartScripts/SmartScript.cpp @@ -1291,6 +1291,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u ObjectGuid privateObjectOwner; if (flags.HasFlag(SmartActionSummonCreatureFlags::PersonalSpawn)) privateObjectOwner = summoner->IsPrivateObject() ? summoner->GetPrivateObjectOwner() : summoner->GetGUID(); + uint32 spawnsCount = std::max(e.action.summonCreature.count, 1u); float x, y, z, o; for (WorldObject* target : targets) @@ -1300,17 +1301,23 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u y += e.target.y; z += e.target.z; o += e.target.o; - if (Creature* summon = summoner->SummonCreature(e.action.summonCreature.creature, x, y, z, o, (TempSummonType)e.action.summonCreature.type, Milliseconds(e.action.summonCreature.duration), privateObjectOwner)) - if (e.action.summonCreature.attackInvoker) - summon->AI()->AttackStart(target->ToUnit()); + for (uint32 counter = 0; counter < spawnsCount; counter++) + { + if (Creature* summon = summoner->SummonCreature(e.action.summonCreature.creature, x, y, z, o, (TempSummonType)e.action.summonCreature.type, Milliseconds(e.action.summonCreature.duration), privateObjectOwner)) + if (e.action.summonCreature.attackInvoker) + summon->AI()->AttackStart(target->ToUnit()); + } } if (e.GetTargetType() != SMART_TARGET_POSITION) break; - if (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, Milliseconds(e.action.summonCreature.duration), privateObjectOwner)) - if (unit && e.action.summonCreature.attackInvoker) - summon->AI()->AttackStart(unit); + for (uint32 counter = 0; counter < spawnsCount; counter++) + { + if (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, Milliseconds(e.action.summonCreature.duration), privateObjectOwner)) + if (unit && e.action.summonCreature.attackInvoker) + summon->AI()->AttackStart(unit); + } break; } case SMART_ACTION_SUMMON_GO: diff --git a/src/server/game/AI/SmartScripts/SmartScriptMgr.h b/src/server/game/AI/SmartScripts/SmartScriptMgr.h index b960afd8e4c..da9edeb6f22 100644 --- a/src/server/game/AI/SmartScripts/SmartScriptMgr.h +++ b/src/server/game/AI/SmartScripts/SmartScriptMgr.h @@ -727,6 +727,7 @@ struct SmartAction uint32 duration; uint32 attackInvoker; uint32 flags; // SmartActionSummonCreatureFlags + uint32 count; } summonCreature; struct |