[Fix] Item Handins to Pets (#4687)

* [Fix] Item handins to pets

* Update npc.cpp
This commit is contained in:
Chris Miles 2025-02-15 17:07:40 -06:00 committed by GitHub
parent e88ea24966
commit 8201175c2c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 9 additions and 7 deletions

View File

@ -4272,11 +4272,13 @@ bool NPC::CanPetTakeItem(const EQ::ItemInstance *inst)
return false; return false;
} }
if (!IsPetOwnerClient()) { if (!IsPetOwnerClient() && !IsCharmedPet()) {
return false; return false;
} }
const bool can_take_nodrop = RuleB(Pets, CanTakeNoDrop) || inst->GetItem()->NoDrop != 0; const bool can_take_nodrop = (RuleB(Pets, CanTakeNoDrop) || inst->GetItem()->NoDrop != 0)
|| inst->GetItem()->NoRent == 0;
const bool is_charmed_with_attuned = IsCharmed() && inst->IsAttuned(); const bool is_charmed_with_attuned = IsCharmed() && inst->IsAttuned();
auto o = GetOwner() && GetOwner()->IsClient() ? GetOwner()->CastToClient() : nullptr; auto o = GetOwner() && GetOwner()->IsClient() ? GetOwner()->CastToClient() : nullptr;
@ -4297,7 +4299,7 @@ bool NPC::CanPetTakeItem(const EQ::ItemInstance *inst)
for (const auto &c : checks) { for (const auto &c : checks) {
if (c.condition) { if (c.condition) {
if (o) { if (o) {
o->Message(Chat::PetResponse, c.message.c_str()); o->Message(Chat::PetResponse, fmt::format("{} says '{}'", GetCleanName(), c.message).c_str());
} }
return false; return false;
} }

View File

@ -549,10 +549,10 @@ void Client::FinishTrade(Mob* tradingWith, bool finalizer, void* event_entry, st
} }
} }
auto with = tradingWith->CastToNPC(); auto with = tradingWith->CastToNPC();
const EQ::ItemData *item = inst->GetItem(); const EQ::ItemData *item = inst->GetItem();
const bool is_pet = with->IsPetOwnerClient() || with->IsCharmedPet();
if (with->IsPetOwnerClient() && with->CanPetTakeItem(inst)) { if (is_pet && with->CanPetTakeItem(inst)) {
// pets need to look inside bags and try to equip items found there // pets need to look inside bags and try to equip items found there
if (item->IsClassBag() && item->BagSlots > 0) { if (item->IsClassBag() && item->BagSlots > 0) {
// if an item inside the bag can't be given to the pet, keep the bag // if an item inside the bag can't be given to the pet, keep the bag