[Bug Fix] Autofire attacking yourself (#1776)

* Fix being able to attack yourself with autofire if Combat:MinRangedAttackDist == 0

* requested changes

* 2
This commit is contained in:
splose 2021-11-21 10:16:20 -05:00 committed by GitHub
parent 0a34809bb3
commit a84536cd05
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 0 deletions

View File

@ -3386,6 +3386,13 @@ void Client::Handle_OP_AutoFire(const EQApplicationPacket *app)
DumpPacket(app); DumpPacket(app);
return; return;
} }
if (GetTarget() == this) {
MessageString(Chat::TooFarAway, TRY_ATTACKING_SOMEONE);
auto_fire = false;
return;
}
bool *af = (bool*)app->pBuffer; bool *af = (bool*)app->pBuffer;
auto_fire = *af; auto_fire = *af;
if(!RuleB(Character, EnableRangerAutoFire)) if(!RuleB(Character, EnableRangerAutoFire))

View File

@ -302,6 +302,10 @@ bool Client::Process() {
} }
if (AutoFireEnabled()) { if (AutoFireEnabled()) {
if (GetTarget() == this) {
MessageString(Chat::TooFarAway, TRY_ATTACKING_SOMEONE);
auto_fire = false;
}
EQ::ItemInstance *ranged = GetInv().GetItem(EQ::invslot::slotRange); EQ::ItemInstance *ranged = GetInv().GetItem(EQ::invslot::slotRange);
if (ranged) if (ranged)
{ {

View File

@ -645,6 +645,8 @@ void Client::RangedAttack(Mob* other, bool CanDoubleAttack) {
//conditions to use an attack checked before we are called //conditions to use an attack checked before we are called
if (!other) if (!other)
return; return;
else if (other == this)
return;
//make sure the attack and ranged timers are up //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 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()))) { if(!CanDoubleAttack && ((attack_timer.Enabled() && !attack_timer.Check(false)) || (ranged_timer.Enabled() && !ranged_timer.Check()))) {