Core/SAI: Implemented action type SMART_ACTION_DESTROY_CONVERSATION

Port From (https://github.com/TrinityCore/TrinityCore/commit/e9e7059a23618e58e57dc3b24eb218505ca3f746)
This commit is contained in:
Hondacrx
2025-09-03 21:27:53 -04:00
parent f1f6c4055b
commit 9f05b762ad
3 changed files with 46 additions and 2 deletions
+23 -2
View File
@@ -821,6 +821,7 @@ namespace Game.AI
SmartActions.DoAction => Marshal.SizeOf(typeof(SmartAction.DoAction)),
SmartActions.CompleteQuest => Marshal.SizeOf(typeof(SmartAction.Quest)),
SmartActions.CreditQuestObjectiveTalkTo => 0,
SmartActions.DestroyConversation => Marshal.SizeOf(typeof(SmartAction.DestroyConversation)),
SmartActions.EnterVehicle => Marshal.SizeOf(typeof(SmartAction.EnterVehicle)),
SmartActions.BoardPassenger => Marshal.SizeOf(typeof(SmartAction.EnterVehicle)),
SmartActions.ExitVehicle => 0,
@@ -870,7 +871,7 @@ namespace Game.AI
}
return false;
};
}
if (!actionUsesStringParam() && !e.Action.param_string.IsEmpty())
Log.outWarn(LogFilter.Sql, $"SmartAIMgr: {e} has unused action_param_string with value {e.Action.param_string}, it should be NULL.");
@@ -1804,7 +1805,7 @@ namespace Game.AI
}
return true;
};
}
if (e.Action.equip.slot1 != 0 && !isValidEquipmentSlot(e.Action.equip.slot1, 0))
return false;
@@ -2234,6 +2235,17 @@ namespace Game.AI
}
break;
}
case SmartActions.DestroyConversation:
{
if (Global.ConversationDataStorage.GetConversationTemplate(e.Action.destroyConversation.id) == null)
{
Log.outError(LogFilter.Sql, $"SmartAIMgr: SMART_ACTION_DESTROY_CONVERSATION {e} uses invalid entry {e.Action.destroyConversation.id}, skipped.");
return false;
}
TC_SAI_IS_BOOLEAN_VALID(e, e.Action.destroyConversation.isPrivate);
break;
}
// No longer supported
case SmartActions.CallAreaexploredoreventhappens:
case SmartActions.CallGroupeventhappens:
@@ -3276,6 +3288,9 @@ namespace Game.AI
[FieldOffset(4)]
public DoAction doAction;
[FieldOffset(4)]
public DestroyConversation destroyConversation;
[FieldOffset(4)]
public EnterVehicle enterVehicle;
@@ -3833,6 +3848,12 @@ namespace Game.AI
{
public uint actionId;
}
public struct DestroyConversation
{
public uint id;
public uint isPrivate;
public uint range;
}
public struct EnterVehicle
{
public uint seatId;
@@ -2708,6 +2708,28 @@ namespace Game.AI
}
break;
}
case SmartActions.DestroyConversation:
{
void work(Conversation conversation)
{
if (conversation.GetEntry() != e.Action.destroyConversation.id)
return;
if (conversation.IsPrivateObject())
{
if (e.Action.destroyConversation.isPrivate == 0 || !targets.Any(target => target.GetGUID() == conversation.GetPrivateObjectOwner()))
return;
}
else if (e.Action.destroyConversation.isPrivate != 0)
return;
conversation.Remove();
}
ConversationWorker worker = new(PhasingHandler.GetAlwaysVisiblePhaseShift(), work);
Cell.VisitGridObjects(GetBaseObject(), worker, e.Action.destroyConversation.range);
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;