Core/SAI: added new action type SMART_ACTION_ADD_TO_STORED_TARGET_LIST

Port From (https://github.com/TrinityCore/TrinityCore/commit/bc4e285c2104993f9eb8c0dc03e0eba800df1a88)
This commit is contained in:
hondacrx
2022-01-07 13:40:09 -05:00
parent e0340e7c07
commit 49f32780dc
3 changed files with 38 additions and 4 deletions
+8 -3
View File
@@ -392,10 +392,15 @@ namespace Framework.Constants
PlayCinematic = 135, // entry, cinematic
SetMovementSpeed = 136, // movementType, speedInteger, speedFraction
PlaySpellVisualKit = 137, // spellVisualKitId, kitType (unknown values, copypaste from packet dumps), duration
OverrideLight = 138, // zoneId, lightId, fadeInTime
OverrideWeather = 139, // zoneId, weatherId, weatherGrade
OverrideLight = 138, // zoneId, overrideLightID, transitionMilliseconds
OverrideWeather = 139, // zoneId, weatherId, intensity
CreateConversation = 143, // conversation_template.id
End = 144
SetImmunePC = 144, // 0/1
SetImmuneNPC = 145, // 0/1
SetUninteractible = 146, // 0/1
ActivateGameobject = 147, // GameObjectActions
AddToStoredTargetList = 148, // varID
End
}
public enum SmartTargets
@@ -1584,6 +1584,7 @@ namespace Game.AI
case SmartActions.RemoveAllGameobjects:
case SmartActions.SpawnSpawngroup:
case SmartActions.DespawnSpawngroup:
case SmartActions.AddToStoredTargetList:
break;
default:
Log.outError(LogFilter.ScriptsAi, "SmartAIMgr: Not handled action_type({0}), event_type({1}), Entry {2} SourceType {3} Event {4}, skipped.", e.GetActionType(), e.GetEventType(), e.EntryOrGuid, e.GetScriptType(), e.EventId);
@@ -2617,6 +2618,9 @@ namespace Game.AI
[FieldOffset(4)]
public Conversation conversation;
[FieldOffset(4)]
public AddToStoredTargets addToStoredTargets;
[FieldOffset(4)]
public Raw raw;
@@ -3160,6 +3164,10 @@ namespace Game.AI
{
public uint id;
}
public struct AddToStoredTargets
{
public uint id;
}
public struct Raw
{
public uint param1;
+22 -1
View File
@@ -2477,6 +2477,17 @@ namespace Game.AI
}
break;
}
case SmartActions.AddToStoredTargetList:
{
if (!targets.Empty())
AddToStoredTargetList(targets, e.Action.addToStoredTargets.id);
else
{
WorldObject baseObject = GetBaseObject();
Log.outWarn(LogFilter.ScriptsAi, $"SmartScript::ProcessAction:: SMART_ACTION_ADD_TO_STORED_TARGET_LIST: var {e.Action.addToStoredTargets.id}, baseObject {(baseObject == null ? "" : baseObject.GetName())}, event {e.EventId} - tried to add no targets to stored target list");
}
break;
}
default:
Log.outError(LogFilter.Sql, "SmartScript.ProcessAction: Entry {0} SourceType {1}, Event {2}, Unhandled Action type {3}", e.EntryOrGuid, e.GetScriptType(), e.EventId, e.GetActionType());
break;
@@ -2913,7 +2924,7 @@ namespace Game.AI
}
case SmartTargets.ClosestCreature:
{
WorldObject refObj = baseObject;
WorldObject refObj = baseObject;
if (refObj == null)
refObj = scriptTrigger;
@@ -4303,6 +4314,14 @@ namespace Game.AI
_storedTargets.Add(id, new ObjectGuidList(targets));
}
void AddToStoredTargetList(List<WorldObject> targets, uint id)
{
var inserted = _storedTargets.TryAdd(id, new ObjectGuidList(targets));
if (!inserted)
foreach (WorldObject obj in targets)
_storedTargets[id].AddGuid(obj.GetGUID());
}
public List<WorldObject> GetStoredTargetList(uint id, WorldObject obj)
{
var list = _storedTargets.LookupByKey(id);
@@ -4452,6 +4471,8 @@ namespace Game.AI
return _objectList;
}
public void AddGuid(ObjectGuid guid) { _guidList.Add(guid); }
//sanitize vector using _guidVector
void UpdateObjects(WorldObject obj)
{