Package com.l2jfrozen.gameserver.model.actor.instance

Examples of com.l2jfrozen.gameserver.model.actor.instance.L2PetInstance


   
    if (!getClient().getFloodProtectors().getUseItem().tryPerformAction("pet use item"))
      return;


    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);
      }
    }
View Full Code Here


    {
      sendPacket(new SystemMessage(SystemMessageId.ITEM_NOT_FOR_PETS));
      return;
    }

    L2PetInstance pet = (L2PetInstance) player.getPet();

    if(pet.isDead())
    {
      sendPacket(new SystemMessage(SystemMessageId.CANNOT_GIVE_ITEMS_TO_DEAD_PET));
      return;
    }

    if(_amount < 0)
      return;

    if(player.transferItem("Transfer", _objectId, _amount, pet.getInventory(), pet) == null)
    {
      _log.warning("Invalid item transfer request: " + pet.getName() + "(pet) --> " + player.getName());
    }
  }
View Full Code Here

    {
      sendPacket(ActionFailed.STATIC_PACKET);
      return;
    }

    L2PetInstance pet = (L2PetInstance) getClient().getActiveChar().getPet();

    if(pet == null || pet.isDead() || pet.isOutOfControl())
    {
      sendPacket(ActionFailed.STATIC_PACKET);
      return;
    }

    pet.getAI().setIntention(CtrlIntention.AI_INTENTION_PICK_UP, item);
  }
View Full Code Here

          else
          {
            // if it is a pet and not a summon
            if(pet instanceof L2PetInstance)
            {
              L2PetInstance petInst = (L2PetInstance) pet;

              // if the pet is more than 40% fed
              if(petInst.getCurrentFed() > petInst.getMaxFed() * 0.40)
              {
                pet.unSummon(activeChar);
              }
              else
              {
 
View Full Code Here

          if(target instanceof L2PcInstance)
          {
            targetPlayer = (L2PcInstance) target;
          }

          L2PetInstance targetPet = null;

          if(target instanceof L2PetInstance)
          {
            targetPet = (L2PetInstance) target;
          }

          if(player != null && (targetPlayer != null || targetPet != null))
          {
            boolean condGood = true;

            if(getSkillType() == SkillType.RESURRECT)
            {
              // check target is not in a active siege zone
              if(target.isInsideZone(L2Character.ZONE_SIEGE))
              {
                condGood = false;
                player.sendPacket(new SystemMessage(SystemMessageId.CANNOT_BE_RESURRECTED_DURING_SIEGE));
              }

              if(targetPlayer != null)
              {
                if(targetPlayer.isReviveRequested())
                {
                  if(targetPlayer.isRevivingPet())
                  {
                    player.sendPacket(new SystemMessage(SystemMessageId.MASTER_CANNOT_RES)); // While a pet is attempting to resurrect, it cannot help in resurrecting its master.
                  }
                  else
                  {
                    player.sendPacket(new SystemMessage(SystemMessageId.RES_HAS_ALREADY_BEEN_PROPOSED)); // Resurrection is already been proposed.
                  }
                  condGood = false;
                }
              }
              else if(targetPet != null)
              {
                if(targetPet.getOwner() != player)
                {
                  condGood = false;
                  player.sendMessage("You are not the owner of this pet");
                }
              }
View Full Code Here

       
        // check for summon item validity
        if (_item == null || _item.getOwnerId() != _activeChar.getObjectId() || _item.getLocation() != L2ItemInstance.ItemLocation.INVENTORY)
          return;
       
        L2PetInstance petSummon = L2PetInstance.spawnPet(_npcTemplate, _activeChar, _item);
       
        if (petSummon == null)
          return;
       
        petSummon.setTitle(_activeChar.getName());
       
        if (!petSummon.isRespawned())
        {
          petSummon.setCurrentHp(petSummon.getMaxHp());
          petSummon.setCurrentMp(petSummon.getMaxMp());
          petSummon.getStat().setExp(petSummon.getExpForThisLevel());
          petSummon.setCurrentFed(petSummon.getMaxFed());
        }
       
        petSummon.setRunning();
       
        if (!petSummon.isRespawned())
        {
          petSummon.store();
        }
       
        _activeChar.setPet(petSummon);
       
        L2World.getInstance().storeObject(petSummon);
        petSummon.spawnMe(_activeChar.getX() + 50, _activeChar.getY() + 100, _activeChar.getZ());
        _activeChar.sendPacket(new PetInfo(petSummon));
        petSummon.startFeed(false);
        _item.setEnchantLevel(petSummon.getLevel());
       
        if (petSummon.getCurrentFed() <= 0)
        {
          ThreadPoolManager.getInstance().scheduleGeneral(new PetSummonFeedWait(_activeChar, petSummon), 60000);
        }
        else
        {
          petSummon.startFeed(false);
        }
       
        petSummon.setFollowStatus(true);
        petSummon.setShowSummonAnimation(false);
        petSummon.broadcastStatusUpdate();
      }
      catch (Throwable e)
      {
        if (Config.ENABLE_ALL_EXCEPTIONS)
          e.printStackTrace();
View Full Code Here

      {
        L2Object target = activeChar.getTarget();
       
        if (target instanceof L2PetInstance)
        {
          L2PetInstance targetPet = (L2PetInstance) target;
          targetPet.setCurrentFed(targetPet.getMaxFed());
          targetPet.getOwner().sendPacket(new SetSummonRemainTime(targetPet.getMaxFed(), targetPet.getCurrentFed()));
          targetPet = null;
        }
        else
        {
          activeChar.sendPacket(new SystemMessage(SystemMessageId.INCORRECT_TARGET));
          return false;
        }
       
        target = null;
        return true;
      }
      case admin_remclanwait:
      {
        L2Object target = activeChar.getTarget();
        L2PcInstance player = null;
       
        if (target instanceof L2PcInstance)
        {
          player = (L2PcInstance) target;
        }
        else
        {
          activeChar.sendMessage("You have to select a player!");
          return false;
        }
        target = null;
       
        if (player.getClan() == null)
        {
          player.setClanJoinExpiryTime(0);
          player.sendMessage("A GM Has reset your clan wait time, You may now join another clan.");
          activeChar.sendMessage("You have reset " + player.getName() + "'s wait time to join another clan.");
        }
        else
        {
          activeChar.sendMessage("Sorry, but " + player.getName() + " must not be in a clan. Player must leave clan before the wait limit can be reset.");
          return false;
        }
       
        player = null;
        return true;
       
      }
      case admin_setcp:
      {     
        String val = "";
        int value = 0;
       
        if (st.hasMoreTokens())
        {
         
          val = st.nextToken();
         
          try
          {
            value = Integer.parseInt(val);
          }
          catch (NumberFormatException e)
          {
            activeChar.sendMessage("Value must be an integer");
            activeChar.sendMessage("Usage: //setcp <new_value>");
            return false;
          }       
        }
        else
        {
          activeChar.sendMessage("Usage: //setcp <new_value>");
          return false;
        }
       
        activeChar.getStatus().setCurrentCp(value);
       
        return true;
       
      }
      case admin_sethp:
      {
        String val = "";
        int value = 0;
       
        if (st.hasMoreTokens())
        {
         
          val = st.nextToken();
         
          try
          {
            value = Integer.parseInt(val);
          }
          catch (NumberFormatException e)
          {
            activeChar.sendMessage("Value must be an integer");
            activeChar.sendMessage("Usage: //sethp <new_value>");
            return false;
          }     
        }
        else
        {
          activeChar.sendMessage("Usage: //sethp <new_value>");
          return false;
        }
       
        activeChar.getStatus().setCurrentHp(value);
       
        return true;     
      }
      case admin_setmp:
      {     
        String val = "";
        int value = 0;
       
        if (st.hasMoreTokens())
        {       
          val = st.nextToken();
         
          try
          {
            value = Integer.parseInt(val);
          }
          catch (NumberFormatException e)
          {
            activeChar.sendMessage("Value must be an integer");
            activeChar.sendMessage("Usage: //setmp <new_value>");
            return false;
          }   
        }
        else
        {
          activeChar.sendMessage("Usage: //setmp <new_value>");
          return false;
        }
       
        activeChar.getStatus().setCurrentMp(value);
       
        return true;
      }
      case admin_setchar_cp:
      {   
        String val = "";
        int value = 0;
       
        if (st.hasMoreTokens())
        {
         
          val = st.nextToken();
         
          try
          {
            value = Integer.parseInt(val);
          }
          catch (NumberFormatException e)
          {
            activeChar.sendMessage("Value must be an integer");
            activeChar.sendMessage("Usage: //setchar_cp <new_value>");
            return false;
          }       
        }
        else
        {
          activeChar.sendMessage("Usage: //setchar_cp <new_value>");
          return false;
        }
       
        if (activeChar.getTarget() instanceof L2PcInstance)
        {
          L2PcInstance pc = (L2PcInstance) activeChar.getTarget();
          pc.getStatus().setCurrentCp(value);
          pc = null;
        }
        else if (activeChar.getTarget() instanceof L2PetInstance)
        {
          L2PetInstance pet = (L2PetInstance) activeChar.getTarget();
          pet.getStatus().setCurrentCp(value);
          pet = null;
        }
        else
        {
          activeChar.getStatus().setCurrentCp(value);
        }
       
        return true;
      }
      case admin_setchar_hp:
      {
        String val = "";
        int value = 0;
       
        if (st.hasMoreTokens())
        {       
          val = st.nextToken();
         
          try
          {
            value = Integer.parseInt(val);
          }
          catch (NumberFormatException e)
          {
            activeChar.sendMessage("Value must be an integer");
            activeChar.sendMessage("Usage: //setchar_hp <new_value>");
            return false;
          }       
        }
        else
        {
          activeChar.sendMessage("Usage: //setchar_hp <new_value>");
          return false;
        }
       
        if (activeChar.getTarget() instanceof L2PcInstance)
        {
          L2PcInstance pc = (L2PcInstance) activeChar.getTarget();
          pc.getStatus().setCurrentHp(value);
          pc = null;
        }
        else if (activeChar.getTarget() instanceof L2PetInstance)
        {
          L2PetInstance pet = (L2PetInstance) activeChar.getTarget();
          pet.getStatus().setCurrentHp(value);
          pet = null;
        }
        else
        {
          activeChar.getStatus().setCurrentHp(value);
        }
       
        return true;
      }
      case admin_setchar_mp:
      {
        String val = "";
        int value = 0;
       
        if (st.hasMoreTokens())
        {       
          val = st.nextToken();
         
          try
          {
            value = Integer.parseInt(val);
          }
          catch (NumberFormatException e)
          {
            activeChar.sendMessage("Value must be an integer");
            activeChar.sendMessage("Usage: //setchar_mp <new_value>");
            return false;
          }       
        }
        else
        {
          activeChar.sendMessage("Usage: //setchar_mp <new_value>");
          return false;
        }
       
        if (activeChar.getTarget() instanceof L2PcInstance)
        {
          L2PcInstance pc = (L2PcInstance) activeChar.getTarget();
          pc.getStatus().setCurrentMp(value);
          pc = null;
        }
        else if (activeChar.getTarget() instanceof L2PetInstance)
        {
          L2PetInstance pet = (L2PetInstance) activeChar.getTarget();
          pet.getStatus().setCurrentMp(value);
          pet = null;
        }
        else
        {
          activeChar.getStatus().setCurrentMp(value);
View Full Code Here

      activeChar = null;
     
    }
    else if (playable instanceof L2PetInstance)
    {
      L2PetInstance activeChar;
      activeChar = ((L2PetInstance) playable);
      int itemId = item.getItemId();
      switch (itemId)
      {
      // MANA POTIONS
        case 728: // mana_potion, xml: 2005
          usePotion(activeChar, 2005, 1);
          break;
       
        // HEALING AND SPEED POTIONS
        case 1060: // lesser_healing_potion,
        case 1073: // beginner's potion, xml: 2031
          if (!isEffectReplaceable(playable, L2Effect.EffectType.HEAL_OVER_TIME, itemId))
            return;
          usePotion(activeChar, 2031, 1);
          break;
        case 1061: // healing_potion, xml: 2032
          if (!isEffectReplaceable(playable, L2Effect.EffectType.HEAL_OVER_TIME, itemId))
            return;
          usePotion(activeChar, 2032, 1);
          break;
        case 1062: // haste_potion, xml: 2011
          usePotion(activeChar, 2011, 1);
          break;
        case 1539:
          if (!isEffectReplaceable(playable, L2Effect.EffectType.HEAL_OVER_TIME, itemId))
            return;
          usePotion(activeChar, 2037, 1);
          break;
        case 6035: // Magic Haste Potion, xml: 2169
          usePotion(activeChar, 2169, 1);
          break;
        default:
          activeChar.getOwner().sendMessage("You can't use " + ItemTable.getInstance().getTemplate(itemId).getName() + " on summon.");
      }
     
      activeChar = null;
    }
    else
View Full Code Here

        }
      }
    }
    else if (player instanceof L2PetInstance)
    {
      L2PetInstance activeChar = (L2PetInstance) player;
      L2Skill skill = SkillTable.getInstance().getInfo(magicId, level);
      if (skill != null)
      {
        // Return false if potion is in reuse
        // so is not destroyed from inventory
        if (activeChar.isSkillDisabled(skill.getId()))
        {
          if (!(skill.getId() == 2166))
          {
            SystemMessage sm = new SystemMessage(SystemMessageId.S1_PREPARED_FOR_REUSE);
            sm.addSkillName(skill.getId(), skill.getLevel());
            activeChar.sendPacket(sm);
          }
          return false;
        }
       
        activeChar.doCast(skill);
       
        if (!(!skill.isPotion()))
          return true;
      }
    }
View Full Code Here

      if (target instanceof L2PcInstance)
      {
        targetPlayer = (L2PcInstance) target;
      }
     
      L2PetInstance targetPet = null;
      if (target instanceof L2PetInstance)
      {
        targetPet = (L2PetInstance) target;
      }
     
      target = null;
     
      if (targetPlayer != null || targetPet != null)
      {
        boolean condGood = true;
       
        // check target is not in a active siege zone
        Castle castle = null;
       
        if (targetPlayer != null)
        {
          castle = CastleManager.getInstance().getCastle(targetPlayer.getX(), targetPlayer.getY(), targetPlayer.getZ());
        }
        else if (targetPet != null)
        {
          castle = CastleManager.getInstance().getCastle(targetPet.getX(), targetPet.getY(), targetPet.getZ());
        }
       
        if (castle != null && castle.getSiege().getIsInProgress())
        {
          condGood = false;
          activeChar.sendPacket(new SystemMessage(SystemMessageId.CANNOT_BE_RESURRECTED_DURING_SIEGE));
        }
       
        castle = null;
       
        if (targetPet != null)
        {
          if (targetPet.getOwner() != activeChar)
          {
            if (targetPet.getOwner().isReviveRequested())
            {
              if (targetPet.getOwner().isRevivingPet())
              {
                activeChar.sendPacket(new SystemMessage(SystemMessageId.RES_HAS_ALREADY_BEEN_PROPOSED)); // Resurrection is already been proposed.
              }
              else
              {
View Full Code Here

TOP

Related Classes of com.l2jfrozen.gameserver.model.actor.instance.L2PetInstance

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.