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
+10 -1
View File
@@ -151,6 +151,15 @@ namespace Framework.Constants
CombatMove = 0x40 //Prevents combat movement if cast successful. Allows movement on range, OOM, LOS CombatMove = 0x40 //Prevents combat movement if cast successful. Allows movement on range, OOM, LOS
} }
public enum SmartActionSummonCreatureFlags
{
None = 0,
PersonalSpawn = 1,
PreferUnit = 2,
All = PersonalSpawn | PreferUnit,
}
public enum SmartEvents public enum SmartEvents
{ {
UpdateIc = 0, // Initialmin, Initialmax, Repeatmin, Repeatmax UpdateIc = 0, // Initialmin, Initialmax, Repeatmin, Repeatmax
@@ -257,7 +266,7 @@ namespace Framework.Constants
ActivateGobject = 9, // ActivateGobject = 9, //
RandomEmote = 10, // Emoteid1, Emoteid2, Emoteid3... RandomEmote = 10, // Emoteid1, Emoteid2, Emoteid3...
Cast = 11, // Spellid, Castflags, TriggeredFlags Cast = 11, // Spellid, Castflags, TriggeredFlags
SummonCreature = 12, // Creatureid, Summontype, Duration In Ms, Storageid, Attackinvoker, SummonCreature = 12, // Creatureid, Summontype, Duration In Ms, Storageid, Attackinvoker, flags(SmartActionSummonCreatureFlags)
ThreatSinglePct = 13, // Threat% ThreatSinglePct = 13, // Threat%
ThreatAllPct = 14, // Threat% ThreatAllPct = 14, // Threat%
CallAreaexploredoreventhappens = 15, // Questid CallAreaexploredoreventhappens = 15, // Questid
@@ -2492,6 +2492,7 @@ namespace Game.AI
public uint duration; public uint duration;
public uint storageID; public uint storageID;
public uint attackInvoker; public uint attackInvoker;
public uint flags; // SmartActionSummonCreatureFlags
} }
public struct ThreatPCT public struct ThreatPCT
{ {
+11 -7
View File
@@ -678,10 +678,10 @@ namespace Game.AI
break; break;
// If invoker was pet or charm // If invoker was pet or charm
Player player = unit.GetCharmerOrOwnerPlayerOrPlayerItself(); Player playerCharmed = unit.GetCharmerOrOwnerPlayerOrPlayerItself();
if (player && GetBaseObject() != null) 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}", Log.outDebug(LogFilter.ScriptsAi, "SmartScript.ProcessAction: SMART_ACTION_CALL_GROUPEVENTHAPPENS: Player {0}, group credit for quest {1}",
unit.GetGUID().ToString(), e.Action.quest.questId); unit.GetGUID().ToString(), e.Action.quest.questId);
} }
@@ -1086,10 +1086,14 @@ namespace Game.AI
} }
case SmartActions.SummonCreature: 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) if (summoner == null)
break; break;
bool personalSpawn = flags.HasAnyFlag(SmartActionSummonCreatureFlags.PersonalSpawn);
float x, y, z, o; float x, y, z, o;
foreach (var target in targets) foreach (var target in targets)
{ {
@@ -1098,7 +1102,7 @@ namespace Game.AI
y += e.Target.y; y += e.Target.y;
z += e.Target.z; z += e.Target.z;
o += e.Target.o; 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 (summon != null)
if (e.Action.summonCreature.attackInvoker != 0) if (e.Action.summonCreature.attackInvoker != 0)
summon.GetAI().AttackStart(target.ToUnit()); summon.GetAI().AttackStart(target.ToUnit());
@@ -1107,7 +1111,7 @@ namespace Game.AI
if (e.GetTargetType() != SmartTargets.Position) if (e.GetTargetType() != SmartTargets.Position)
break; 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 (summon1 != null)
if (unit != null && e.Action.summonCreature.attackInvoker != 0) if (unit != null && e.Action.summonCreature.attackInvoker != 0)
summon1.GetAI().AttackStart(unit); summon1.GetAI().AttackStart(unit);