From 5c60913583311ac00111591226264efe94bb3e49 Mon Sep 17 00:00:00 2001 From: Paul Coene Date: Sat, 2 Jul 2022 23:02:43 -0400 Subject: [PATCH] [Feature] Add humanoid and non-wielded restrictions to pick pocket (#2276) * Add humanoid and non-wielded restructions to pick pocket * Use constants for message string and char color * Fixed more magic #s * Fix to include valie bodytypes * Fix incorrect scope of final else * My extra message was not needed. Client handles based on packet reply * Removed string ID I added - issued by client * Use existing pick pocket reply function / clean up --- zone/client_packet.cpp | 31 +++++++++++++------------------ zone/npc.cpp | 2 +- 2 files changed, 14 insertions(+), 19 deletions(-) diff --git a/zone/client_packet.cpp b/zone/client_packet.cpp index ea945ad30..38d222766 100644 --- a/zone/client_packet.cpp +++ b/zone/client_packet.cpp @@ -11074,35 +11074,30 @@ 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."); + Message(Chat::White, "You catch yourself red-handed."); } else if (victim->GetOwnerID()) { - Message(0, "You cannot steal from pets!"); + Message(Chat::White, "You cannot steal from pets!"); + } + else if (victim->IsClient()) { + Message(Chat::White, "Stealing from clients not yet supported."); } else if (Distance(GetPosition(), victim->GetPosition()) > 20) { Message(Chat::Red, "Attempt to pickpocket out of range detected."); database.SetMQDetectionFlag(AccountName(), GetName(), "OP_PickPocket was sent from outside combat range.", zone->GetShortName()); } else if (victim->IsNPC()) { - safe_delete(outapp); - victim->CastToNPC()->PickPocket(this); - return; + auto body = victim->GetBodyType(); + if (body == BT_Humanoid || body == BT_Monster || body == BT_Giant || + body == BT_Lycanthrope) { + victim->CastToNPC()->PickPocket(this); + return; + } } - else { - Message(0, "Stealing from clients not yet supported."); - } - QueuePacket(outapp); - safe_delete(outapp); + + SendPickPocketResponse(victim, 0, PickPocketFailed); } void Client::Handle_OP_PopupResponse(const EQApplicationPacket *app) diff --git a/zone/npc.cpp b/zone/npc.cpp index 0a14947b4..ea8cfab71 100644 --- a/zone/npc.cpp +++ b/zone/npc.cpp @@ -1867,7 +1867,7 @@ void NPC::PickPocket(Client* thief) continue; auto item_test = database.GetItem(item_iter->item_id); - if (item_test->Magic || !item_test->NoDrop || item_test->IsClassBag() || thief->CheckLoreConflict(item_test)) + if (item_test->Magic || !item_test->NoDrop || item_test->IsClassBag() || thief->CheckLoreConflict(item_test) || item_iter->equip_slot != EQ::invslot::SLOT_INVALID) continue; loot_selection.push_back(std::make_pair(item_test, ((item_test->Stackable) ? (1) : (item_iter->charges))));