Core/SAI: Added new Flags argument for SMART_ACTION_SUMMON_CREATURE

Port From (https://github.com/TrinityCore/TrinityCore/commit/e0278f05379ed470be8264d3f362360a52b3454d)
This commit is contained in:
hondacrx
2021-02-13 20:57:06 -05:00
parent 593ac992bc
commit 834d2fa270
3 changed files with 22 additions and 8 deletions
+11 -7
View File
@@ -678,10 +678,10 @@ namespace Game.AI
break;
// If invoker was pet or charm
Player player = unit.GetCharmerOrOwnerPlayerOrPlayerItself();
if (player && GetBaseObject() != null)
Player playerCharmed = unit.GetCharmerOrOwnerPlayerOrPlayerItself();
if (playerCharmed && GetBaseObject() != null)
{
player.GroupEventHappens(e.Action.quest.questId, GetBaseObject());
playerCharmed.GroupEventHappens(e.Action.quest.questId, GetBaseObject());
Log.outDebug(LogFilter.ScriptsAi, "SmartScript.ProcessAction: SMART_ACTION_CALL_GROUPEVENTHAPPENS: Player {0}, group credit for quest {1}",
unit.GetGUID().ToString(), e.Action.quest.questId);
}
@@ -1086,10 +1086,14 @@ namespace Game.AI
}
case SmartActions.SummonCreature:
{
WorldObject summoner = GetBaseObjectOrUnit(unit);
SmartActionSummonCreatureFlags flags = (SmartActionSummonCreatureFlags)e.Action.summonCreature.flags;
bool preferUnit = flags.HasAnyFlag(SmartActionSummonCreatureFlags.PreferUnit);
WorldObject summoner = preferUnit ? unit : GetBaseObjectOrUnit(unit);
if (summoner == null)
break;
bool personalSpawn = flags.HasAnyFlag(SmartActionSummonCreatureFlags.PersonalSpawn);
float x, y, z, o;
foreach (var target in targets)
{
@@ -1098,7 +1102,7 @@ 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, e.Action.summonCreature.duration);
Creature summon = summoner.SummonCreature(e.Action.summonCreature.creature, x, y, z, o, (TempSummonType)e.Action.summonCreature.type, e.Action.summonCreature.duration, personalSpawn);
if (summon != null)
if (e.Action.summonCreature.attackInvoker != 0)
summon.GetAI().AttackStart(target.ToUnit());
@@ -1107,7 +1111,7 @@ namespace Game.AI
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, e.Action.summonCreature.duration);
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, e.Action.summonCreature.duration, personalSpawn);
if (summon1 != null)
if (unit != null && e.Action.summonCreature.attackInvoker != 0)
summon1.GetAI().AttackStart(unit);