From 6bf5608cf3daf9bff26d2df541174dd688fa7208 Mon Sep 17 00:00:00 2001 From: Natedog2012 Date: Mon, 3 Jan 2022 21:26:37 -0600 Subject: [PATCH] [Bug Fix] Add range check to OP_PickPocket (#1912) * [Bug Fix] Add range check to OP_PickPocket * Pickpocket distance is 15 constant according to Mackal * Re-add wiggle room for distance check due to pathing --- zone/client_packet.cpp | 47 +++++++++++++++--------------------------- 1 file changed, 17 insertions(+), 30 deletions(-) diff --git a/zone/client_packet.cpp b/zone/client_packet.cpp index d23353494..6db486f78 100644 --- a/zone/client_packet.cpp +++ b/zone/client_packet.cpp @@ -11066,48 +11066,35 @@ void Client::Handle_OP_PickPocket(const EQApplicationPacket *app) return; p_timers.Start(pTimerBeggingPickPocket, 8); + auto outapp = new EQApplicationPacket(OP_PickPocket, sizeof(sPickPocket_Struct)); + sPickPocket_Struct* pick_out = (sPickPocket_Struct*)outapp->pBuffer; + pick_out->coin = 0; + pick_out->from = victim->GetID(); + pick_out->to = GetID(); + pick_out->myskill = GetSkill(EQ::skills::SkillPickPockets); + pick_out->type = 0; + //if we do not send this packet the client will lock up and require the player to relog. + if (victim == this) { Message(0, "You catch yourself red-handed."); - auto outapp = new EQApplicationPacket(OP_PickPocket, sizeof(sPickPocket_Struct)); - sPickPocket_Struct* pick_out = (sPickPocket_Struct*)outapp->pBuffer; - pick_out->coin = 0; - pick_out->from = victim->GetID(); - pick_out->to = GetID(); - pick_out->myskill = GetSkill(EQ::skills::SkillPickPockets); - pick_out->type = 0; - //if we do not send this packet the client will lock up and require the player to relog. - QueuePacket(outapp); - safe_delete(outapp); } else if (victim->GetOwnerID()) { Message(0, "You cannot steal from pets!"); - auto outapp = new EQApplicationPacket(OP_PickPocket, sizeof(sPickPocket_Struct)); - sPickPocket_Struct* pick_out = (sPickPocket_Struct*)outapp->pBuffer; - pick_out->coin = 0; - pick_out->from = victim->GetID(); - pick_out->to = GetID(); - pick_out->myskill = GetSkill(EQ::skills::SkillPickPockets); - pick_out->type = 0; - //if we do not send this packet the client will lock up and require the player to relog. - QueuePacket(outapp); - safe_delete(outapp); + } + else if (Distance(GetPosition(), victim->GetPosition()) > 20) { + Message(Chat::Red, "Attempt to pickpocket out of range detected."); + database.SetMQDetectionFlag(this->AccountName(), this->GetName(), "OP_PickPocket was sent from outside combat range.", zone->GetShortName()); } else if (victim->IsNPC()) { + safe_delete(outapp); victim->CastToNPC()->PickPocket(this); + return; } else { Message(0, "Stealing from clients not yet supported."); - auto outapp = new EQApplicationPacket(OP_PickPocket, sizeof(sPickPocket_Struct)); - sPickPocket_Struct* pick_out = (sPickPocket_Struct*)outapp->pBuffer; - pick_out->coin = 0; - pick_out->from = victim->GetID(); - pick_out->to = GetID(); - pick_out->myskill = GetSkill(EQ::skills::SkillPickPockets); - pick_out->type = 0; - //if we do not send this packet the client will lock up and require the player to relog. - QueuePacket(outapp); - safe_delete(outapp); } + QueuePacket(outapp); + safe_delete(outapp); } void Client::Handle_OP_PopupResponse(const EQApplicationPacket *app)