From 32ea5a96f5cd7f609ab03fff7dc66baa4b31fb15 Mon Sep 17 00:00:00 2001 From: hondacrx Date: Sun, 22 Jan 2023 23:41:15 -0500 Subject: [PATCH] Core/Player: Vertical "Say" distance Port From (https://github.com/TrinityCore/TrinityCore/commit/ab77b1d99254855d690670a4654cacec8b12daf6) --- Source/Game/Entities/Player/Player.cs | 8 ++++---- Source/Game/Maps/GridNotifiers.cs | 11 +++++++---- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/Source/Game/Entities/Player/Player.cs b/Source/Game/Entities/Player/Player.cs index 8ec167d1a..e0df7cce7 100644 --- a/Source/Game/Entities/Player/Player.cs +++ b/Source/Game/Entities/Player/Player.cs @@ -5737,13 +5737,13 @@ namespace Game.Entities Cell.VisitWorldObjects(this, notifier, dist); } - void SendMessageToSetInRange(ServerPacket data, float dist, bool self, bool own_team_only) + void SendMessageToSetInRange(ServerPacket data, float dist, bool self, bool own_team_only, bool required3dDist = false) { if (self) SendPacket(data); PacketSenderRef sender = new(data); - var notifier = new MessageDistDeliverer(this, sender, dist, own_team_only); + var notifier = new MessageDistDeliverer(this, sender, dist, own_team_only, null, required3dDist); Cell.VisitWorldObjects(this, notifier, dist); } @@ -6000,7 +6000,7 @@ namespace Game.Entities localizer.Invoke(this); // Send to players - MessageDistDeliverer notifier = new(this, localizer, range); + MessageDistDeliverer notifier = new(this, localizer, range, false, null, true); Cell.VisitWorldObjects(this, notifier, range); } @@ -6026,7 +6026,7 @@ namespace Game.Entities ChatPkt data = new(); data.Initialize(ChatMsg.Emote, Language.Universal, this, this, text); - SendMessageToSetInRange(data, WorldConfig.GetFloatValue(WorldCfg.ListenRangeTextemote), !GetSession().HasPermission(RBACPermissions.TwoSideInteractionChat)); + SendMessageToSetInRange(data, WorldConfig.GetFloatValue(WorldCfg.ListenRangeTextemote), true, !GetSession().HasPermission(RBACPermissions.TwoSideInteractionChat), true); } public override void TextEmote(uint textId, WorldObject target = null, bool isBossEmote = false) { diff --git a/Source/Game/Maps/GridNotifiers.cs b/Source/Game/Maps/GridNotifiers.cs index b405bdfd0..174bed823 100644 --- a/Source/Game/Maps/GridNotifiers.cs +++ b/Source/Game/Maps/GridNotifiers.cs @@ -1,6 +1,7 @@ // Copyright (c) CypherCore All rights reserved. // Licensed under the GNU GENERAL PUBLIC LICENSE. See LICENSE file in the project root for full license information. +using Bgs.Protocol.Notification.V1; using Framework.Constants; using Game.Chat; using Game.Entities; @@ -394,8 +395,9 @@ namespace Game.Maps float i_distSq; Team team; Player skipped_receiver; + bool required3dDist; - public MessageDistDeliverer(WorldObject src, T packetSender, float dist, bool own_team_only = false, Player skipped = null) + public MessageDistDeliverer(WorldObject src, T packetSender, float dist, bool own_team_only = false, Player skipped = null, bool req3dDist = false) { i_source = src; i_packetSender = packetSender; @@ -405,6 +407,7 @@ namespace Game.Maps team = src.ToPlayer().GetEffectiveTeam(); skipped_receiver = skipped; + required3dDist = req3dDist; } public override void Visit(IList objs) @@ -415,7 +418,7 @@ namespace Game.Maps if (!player.InSamePhase(i_phaseShift)) continue; - if (player.GetExactDist2dSq(i_source.GetPosition()) > i_distSq) + if ((!required3dDist ? player.GetExactDist2dSq(i_source) : player.GetExactDistSq(i_source)) > i_distSq) continue; // Send packet to all who are sharing the player's vision @@ -439,7 +442,7 @@ namespace Game.Maps if (!creature.InSamePhase(i_phaseShift)) continue; - if (creature.GetExactDist2dSq(i_source.GetPosition()) > i_distSq) + if ((!required3dDist ? creature.GetExactDist2dSq(i_source) : creature.GetExactDistSq(i_source)) > i_distSq) continue; // Send packet to all who are sharing the creature's vision @@ -460,7 +463,7 @@ namespace Game.Maps if (!dynamicObject.InSamePhase(i_phaseShift)) continue; - if (dynamicObject.GetExactDist2dSq(i_source.GetPosition()) > i_distSq) + if ((!required3dDist ? dynamicObject.GetExactDist2dSq(i_source) : dynamicObject.GetExactDistSq(i_source)) > i_distSq) continue; // Send packet back to the caster if the caster has vision of dynamic object