[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;
}
if (!IsPetOwnerClient()) {
if (!IsPetOwnerClient() && !IsCharmedPet()) {
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();
auto o = GetOwner() && GetOwner()->IsClient() ? GetOwner()->CastToClient() : nullptr;
@ -4297,7 +4299,7 @@ bool NPC::CanPetTakeItem(const EQ::ItemInstance *inst)
for (const auto &c : checks) {
if (c.condition) {
if (o) {
o->Message(Chat::PetResponse, c.message.c_str());
o->Message(Chat::PetResponse, fmt::format("{} says '{}'", GetCleanName(), c.message).c_str());
}
return false;
}

View File

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