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 PlayCinematic = 135, // entry, cinematic
SetMovementSpeed = 136, // movementType, speedInteger, speedFraction SetMovementSpeed = 136, // movementType, speedInteger, speedFraction
PlaySpellVisualKit = 137, // spellVisualKitId, kitType (unknown values, copypaste from packet dumps), duration PlaySpellVisualKit = 137, // spellVisualKitId, kitType (unknown values, copypaste from packet dumps), duration
OverrideLight = 138, // zoneId, lightId, fadeInTime OverrideLight = 138, // zoneId, overrideLightID, transitionMilliseconds
OverrideWeather = 139, // zoneId, weatherId, weatherGrade OverrideWeather = 139, // zoneId, weatherId, intensity
CreateConversation = 143, // conversation_template.id 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 public enum SmartTargets
@@ -1584,6 +1584,7 @@ namespace Game.AI
case SmartActions.RemoveAllGameobjects: case SmartActions.RemoveAllGameobjects:
case SmartActions.SpawnSpawngroup: case SmartActions.SpawnSpawngroup:
case SmartActions.DespawnSpawngroup: case SmartActions.DespawnSpawngroup:
case SmartActions.AddToStoredTargetList:
break; break;
default: 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); 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)] [FieldOffset(4)]
public Conversation conversation; public Conversation conversation;
[FieldOffset(4)]
public AddToStoredTargets addToStoredTargets;
[FieldOffset(4)] [FieldOffset(4)]
public Raw raw; public Raw raw;
@@ -3160,6 +3164,10 @@ namespace Game.AI
{ {
public uint id; public uint id;
} }
public struct AddToStoredTargets
{
public uint id;
}
public struct Raw public struct Raw
{ {
public uint param1; public uint param1;
+22 -1
View File
@@ -2477,6 +2477,17 @@ namespace Game.AI
} }
break; 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: 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()); 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; break;
@@ -2913,7 +2924,7 @@ namespace Game.AI
} }
case SmartTargets.ClosestCreature: case SmartTargets.ClosestCreature:
{ {
WorldObject refObj = baseObject; WorldObject refObj = baseObject;
if (refObj == null) if (refObj == null)
refObj = scriptTrigger; refObj = scriptTrigger;
@@ -4303,6 +4314,14 @@ namespace Game.AI
_storedTargets.Add(id, new ObjectGuidList(targets)); _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) public List<WorldObject> GetStoredTargetList(uint id, WorldObject obj)
{ {
var list = _storedTargets.LookupByKey(id); var list = _storedTargets.LookupByKey(id);
@@ -4452,6 +4471,8 @@ namespace Game.AI
return _objectList; return _objectList;
} }
public void AddGuid(ObjectGuid guid) { _guidList.Add(guid); }
//sanitize vector using _guidVector //sanitize vector using _guidVector
void UpdateObjects(WorldObject obj) void UpdateObjects(WorldObject obj)
{ {