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.
This commit is contained in:
jackpoz
2021-06-17 19:47:50 +02:00
parent 38a661b8db
commit 5628ca7f7c
2 changed files with 14 additions and 6 deletions

View File

@@ -1266,6 +1266,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
break;
bool personalSpawn = flags.HasFlag(SmartActionSummonCreatureFlags::PersonalSpawn);
uint32 spawnsCount = std::max(e.action.summonCreature.count, 1u);
float x, y, z, o;
for (WorldObject* target : targets)
@@ -1275,17 +1276,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), personalSpawn))
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), personalSpawn))
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), personalSpawn))
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), personalSpawn))
if (unit && e.action.summonCreature.attackInvoker)
summon->AI()->AttackStart(unit);
}
break;
}
case SMART_ACTION_SUMMON_GO:

View File

@@ -710,6 +710,7 @@ struct SmartAction
uint32 duration;
uint32 attackInvoker;
uint32 flags; // SmartActionSummonCreatureFlags
uint32 count;
} summonCreature;
struct