L2PetInstance pet = (L2PetInstance)activeChar.getPet();
if (pet == null)
return;
L2ItemInstance item = pet.getInventory().getItemByObjectId(_objectId);
if (item == null)
return;
if (item.isWear())
return;
int itemId = item.getItemId();
if (activeChar.isAlikeDead() || pet.isDead())
{
SystemMessage sm = new SystemMessage(SystemMessageId.S1_CANNOT_BE_USED);
sm.addItemName(item.getItemId());
activeChar.sendPacket(sm);
sm = null;
return;
}
if (Config.DEBUG)
_log.finest(activeChar.getObjectId()+": pet use item " + _objectId);
//check if the item matches the pet
if (item.isEquipable())
{
if (L2PetDataTable.isWolf(pet.getNpcId()) && // wolf
item.getItem().isForWolf())
{
useItem(pet, item, activeChar);
return;
}
else if (L2PetDataTable.isHatchling(pet.getNpcId()) && // hatchlings
item.getItem().isForHatchling())
{
useItem(pet, item, activeChar);
return;
}
else if (L2PetDataTable.isStrider(pet.getNpcId()) && // striders
item.getItem().isForStrider())
{
useItem(pet, item, activeChar);
return;
}
else if (L2PetDataTable.isBaby(pet.getNpcId()) && // baby pets (buffalo, cougar, kookaboora)
item.getItem().isForBabyPet())
{
useItem(pet, item, activeChar);
return;
}
else
{
activeChar.sendPacket(new SystemMessage(SystemMessageId.ITEM_NOT_FOR_PETS));
return;
}
}
else if (L2PetDataTable.isPetFood(itemId))
{
if (L2PetDataTable.isWolf(pet.getNpcId()) && L2PetDataTable.isWolfFood(itemId))
{
feed(activeChar, pet, item);
return;
}
if (L2PetDataTable.isSinEater(pet.getNpcId()) && L2PetDataTable.isSinEaterFood(itemId))
{
feed(activeChar, pet, item);
return;
}
else if (L2PetDataTable.isHatchling(pet.getNpcId()) && L2PetDataTable.isHatchlingFood(itemId))
{
feed(activeChar, pet, item);
return;
}
else if (L2PetDataTable.isStrider(pet.getNpcId()) && L2PetDataTable.isStriderFood(itemId))
{
feed(activeChar, pet, item);
return;
}
else if (L2PetDataTable.isWyvern(pet.getNpcId()) && L2PetDataTable.isWyvernFood(itemId))
{
feed(activeChar, pet, item);
return;
}
else if (L2PetDataTable.isBaby(pet.getNpcId()) && L2PetDataTable.isBabyFood(itemId))
{
feed(activeChar, pet, item);
}
}
IItemHandler handler = ItemHandler.getInstance().getItemHandler(item.getItemId());
if (handler != null)
{
useItem(pet, item, activeChar);
}