if(_objectId == pet.getControlItemObjId())
{
activeChar.sendActionFailed();
return;
}
PetInventory petInventory = pet.getInventory();
PcInventory playerInventory = activeChar.getInventory();
L2ItemInstance playerItem = playerInventory.getItemByObjectId(_objectId);
if(playerItem == null || playerItem.getObjectId() == pet.getControlItemObjId() || PetDataTable.isPetControlItem(playerItem))
{
activeChar.sendActionFailed();
return;
}
if(pet.getInventory().getTotalWeight() + playerItem.getItem().getWeight() * _amount >= pet.getMaxLoad())
{
activeChar.sendPacket(Msg.EXCEEDED_PET_INVENTORYS_WEIGHT_LIMIT);
return;
}
if(!playerItem.canBeDropped(activeChar, false))
{
activeChar.sendActionFailed();
return;
}
if(_amount >= playerItem.getCount())
{
playerInventory.dropItem(_objectId, playerItem.getCount(), false);
playerItem.setCustomFlags(playerItem.getCustomFlags() | L2ItemInstance.FLAG_PET_EQUIPPED, true);
petInventory.addItem(playerItem);
}
else
{
L2ItemInstance newPetItem = playerInventory.dropItem(_objectId, _amount, false);
petInventory.addItem(newPetItem);
}
pet.sendItemList();
pet.broadcastPetInfo();
Log.LogItem(activeChar, pet, Log.GiveItemToPet, playerItem);
}