From a84536cd058ca6884ba84e11b03326c8d5c220fe Mon Sep 17 00:00:00 2001 From: splose Date: Sun, 21 Nov 2021 10:16:20 -0500 Subject: [PATCH] [Bug Fix] Autofire attacking yourself (#1776) * Fix being able to attack yourself with autofire if Combat:MinRangedAttackDist == 0 * requested changes * 2 --- zone/client_packet.cpp | 7 +++++++ zone/client_process.cpp | 4 ++++ zone/special_attacks.cpp | 2 ++ 3 files changed, 13 insertions(+) diff --git a/zone/client_packet.cpp b/zone/client_packet.cpp index 227193a7c..c2b44842e 100644 --- a/zone/client_packet.cpp +++ b/zone/client_packet.cpp @@ -3386,6 +3386,13 @@ void Client::Handle_OP_AutoFire(const EQApplicationPacket *app) DumpPacket(app); return; } + + if (GetTarget() == this) { + MessageString(Chat::TooFarAway, TRY_ATTACKING_SOMEONE); + auto_fire = false; + return; + } + bool *af = (bool*)app->pBuffer; auto_fire = *af; if(!RuleB(Character, EnableRangerAutoFire)) diff --git a/zone/client_process.cpp b/zone/client_process.cpp index c014c5f0e..0134ce3f4 100644 --- a/zone/client_process.cpp +++ b/zone/client_process.cpp @@ -302,6 +302,10 @@ bool Client::Process() { } if (AutoFireEnabled()) { + if (GetTarget() == this) { + MessageString(Chat::TooFarAway, TRY_ATTACKING_SOMEONE); + auto_fire = false; + } EQ::ItemInstance *ranged = GetInv().GetItem(EQ::invslot::slotRange); if (ranged) { diff --git a/zone/special_attacks.cpp b/zone/special_attacks.cpp index 6f99acc9e..f6003a8d2 100644 --- a/zone/special_attacks.cpp +++ b/zone/special_attacks.cpp @@ -645,6 +645,8 @@ void Client::RangedAttack(Mob* other, bool CanDoubleAttack) { //conditions to use an attack checked before we are called if (!other) return; + else if (other == this) + return; //make sure the attack and ranged timers are up //if the ranged timer is disabled, then they have no ranged weapon and shouldent be attacking anyhow if(!CanDoubleAttack && ((attack_timer.Enabled() && !attack_timer.Check(false)) || (ranged_timer.Enabled() && !ranged_timer.Check()))) {