diff --git a/Source/Game/Entities/Conversation.cs b/Source/Game/Entities/Conversation.cs index 426a2b6e8..092a2efc2 100644 --- a/Source/Game/Entities/Conversation.cs +++ b/Source/Game/Entities/Conversation.cs @@ -80,7 +80,7 @@ namespace Game.Entities base.Update(diff); } - void Remove() + public void Remove() { if (IsInWorld) { diff --git a/Source/Game/Maps/GridNotifiers.cs b/Source/Game/Maps/GridNotifiers.cs index 3c04a1599..770abecd3 100644 --- a/Source/Game/Maps/GridNotifiers.cs +++ b/Source/Game/Maps/GridNotifiers.cs @@ -1341,6 +1341,7 @@ namespace Game.Maps WorldObject _searcher; ICheck i_check; } + public class WorldObjectListSearcher : Notifier { public WorldObjectListSearcher(WorldObject searcher, List objects, ICheck check, GridMapTypeMask mapTypeMask = GridMapTypeMask.All) @@ -2642,6 +2643,23 @@ namespace Game.Maps ObjectGuid _casterGUID; } + class ObjectEntryAndPrivateOwnerIfExistsCheck : ICheck + { + ObjectGuid _ownerGUID; + uint _entry; + + public ObjectEntryAndPrivateOwnerIfExistsCheck(ObjectGuid ownerGUID, uint entry) + { + _ownerGUID = ownerGUID; + _entry = entry; + } + + public bool Invoke(WorldObject obj) + { + return obj.GetEntry() == _entry && (!obj.IsPrivateObject() || obj.GetPrivateObjectOwner() == _ownerGUID); + } + } + class GameObjectFocusCheck : ICheck { public GameObjectFocusCheck(WorldObject caster, uint focusId) diff --git a/Source/Game/Spells/SpellEffects.cs b/Source/Game/Spells/SpellEffects.cs index 7d4ac74b6..b92aab8ae 100644 --- a/Source/Game/Spells/SpellEffects.cs +++ b/Source/Game/Spells/SpellEffects.cs @@ -5336,6 +5336,28 @@ namespace Game.Spells Conversation.CreateConversation((uint)effectInfo.MiscValue, unitCaster, destTarget.GetPosition(), ObjectGuid.Empty, GetSpellInfo()); } + [SpellEffectHandler(SpellEffectName.CancelConversation)] + void EffectCancelConversation() + { + if (effectHandleMode != SpellEffectHandleMode.HitTarget) + return; + + if (!unitTarget) + return; + + List objs = new(); + ObjectEntryAndPrivateOwnerIfExistsCheck check = new(unitTarget.GetGUID(), (uint)effectInfo.MiscValue); + WorldObjectListSearcher checker = new(unitTarget, objs, check, GridMapTypeMask.Conversation); + Cell.VisitGridObjects(unitTarget, checker, 100.0f); + + foreach (WorldObject obj in objs) + { + Conversation convo = obj.ToConversation(); + if (convo != null) + convo.Remove(); + } + } + [SpellEffectHandler(SpellEffectName.AddGarrisonFollower)] void EffectAddGarrisonFollower() {