From 7d5d3cf655b3e701d8a570b03499a388476cbdf9 Mon Sep 17 00:00:00 2001 From: Meji Date: Fri, 7 Apr 2023 20:54:03 +0200 Subject: Core/Units: Prevent backward melee attacks (#28895) --- src/server/game/AI/CoreAI/UnitAI.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/server') diff --git a/src/server/game/AI/CoreAI/UnitAI.cpp b/src/server/game/AI/CoreAI/UnitAI.cpp index 81077ab5565..bf7fe72bd5a 100644 --- a/src/server/game/AI/CoreAI/UnitAI.cpp +++ b/src/server/game/AI/CoreAI/UnitAI.cpp @@ -68,6 +68,10 @@ void UnitAI::DoMeleeAttackIfReady() if (!me->IsWithinMeleeRange(victim)) return; + // Check that the victim is in front of the unit + if (!me->HasInArc(2 * float(M_PI) / 3, victim)) + return; + //Make sure our attack is ready and we aren't currently casting before checking distance if (me->isAttackReady()) { -- cgit v1.2.3