Package l2p.gameserver.model.instances

Examples of l2p.gameserver.model.instances.L2PetInstance$FeedTask


    L2Player activeChar = getClient().getActiveChar();
    if(activeChar == null)
    {
      return;
    }
    L2PetInstance pet = (L2PetInstance) activeChar.getPet();
    if(pet == null || pet.isDead())
    {
      sendPacket(Msg.CANNOT_GIVE_ITEMS_TO_A_DEAD_PET);
      return;
    }
    if(activeChar.getPrivateStoreType() != L2Player.STORE_PRIVATE_NONE)
    {
      sendPacket(Msg.WHILE_OPERATING_A_PRIVATE_STORE_OR_WORKSHOP_YOU_CANNOT_DISCARD_DESTROY_OR_TRADE_AN_ITEM);
      return;
    }
    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);
  }
View Full Code Here


    L2Player activeChar = getClient().getActiveChar();
    if(activeChar == null)
    {
      return;
    }
    L2PetInstance pet = (L2PetInstance) activeChar.getPet();
    if(pet == null)
    {
      return;
    }
    L2ItemInstance item = pet.getInventory().getItemByObjectId(_objectId);
    if(item == null || item.getCount() <= 0)
    {
      return;
    }
    if(activeChar.isAlikeDead() || pet.isDead())
    {
      activeChar.sendPacket(new SystemMessage(SystemMessage.S1_CANNOT_BE_USED_DUE_TO_UNSUITABLE_TERMS).addItemName(item.getItemId()));
      return;
    }
    if(pet.tryEquipItem(item, true))
    {
      return;
    }
    // manual pet feeding
    if(pet.tryFeedItem(item))
    {
      return;
    }
    L2Skill[] skills = item.getItem().getAttachedSkills();
    if(skills != null && skills.length > 0)
    {
      for(L2Skill skill : skills)
      {
        // Отсеиваем все что пету не положено
        if(skill.getHitTime() > 1000)
        {
          activeChar.sendPacket(Msg.ITEM_NOT_AVAILABLE_FOR_PETS);
          return;
        }
        switch(skill.getSkillType())
        {
          case BUFF:
          case CANCEL:
          case HEAL:
          case HEAL_PERCENT:
          case HOT:
          case MANAHEAL:
          case MANAHEAL_PERCENT:
          case NEGATE_EFFECTS:
          case NEGATE_STATS:
            L2Character aimingTarget = skill.getAimingTarget(pet, pet.getTarget());
            if(skill.checkCondition(pet, aimingTarget, false, false, true))
            {
              pet.getAI().Cast(skill, aimingTarget, false, false);
            }
            break;
          default:
            activeChar.sendPacket(Msg.ITEM_NOT_AVAILABLE_FOR_PETS);
            return;
View Full Code Here

TOP

Related Classes of l2p.gameserver.model.instances.L2PetInstance$FeedTask

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.