/**
   * Cast a skill for active summon.<br>
   * Target is specified as a parameter but can be overwrited or ignored depending on skill type.
   *
   * @param skillId the skill Id to be casted by the summon
   * @param target the target to cast the skill on, overwritten or ignored depending on skill type
   * @param pet if {@code true} it'll validate a pet, if {@code false} it will validate a servitor
   */
  private void useSkill(int skillId, L2Object target, boolean pet) {
    final L2PcInstance activeChar = getActiveChar();
    if (activeChar == null) {
      return;
    }

    if (pet) {
      final L2Summon summon = activeChar.getPet();
      if (!validateSummon(summon, pet)) {
        return;
      }

      if (!canControl(summon)) {
        return;
      }

      final int lvl =
          PetDataTable.getInstance()
              .getPetData(summon.getId())
              .getAvailableLevel(skillId, summon.getLevel());

      if (lvl > 0) {
        summon.setTarget(target);
        summon.useMagic(
            SkillData.getInstance().getSkill(skillId, lvl), _ctrlPressed, _shiftPressed);
      }

      if (skillId == SWITCH_STANCE_ID) {
        summon.switchMode();
      }
    } else {
      final L2Summon servitor = activeChar.getAnyServitor();
      if (!validateSummon(servitor, pet)) {
        return;
      }

      final int lvl = SummonSkillsTable.getInstance().getAvailableLevel(servitor, skillId);

      if (lvl > 0) {
        servitor.setTarget(target);
        servitor.useMagic(
            SkillData.getInstance().getSkill(skillId, lvl), _ctrlPressed, _shiftPressed);
      }
    }
  }
Beispiel #2
0
  @Override
  public void setLevel(byte value) {
    getActiveChar()
        .setPetData(
            PetDataTable.getInstance()
                .getPetLevelData(getActiveChar().getTemplate().getId(), value));
    if (getActiveChar().getPetLevelData() == null) {
      throw new IllegalArgumentException(
          "No pet data for npc: " + getActiveChar().getTemplate().getId() + " level: " + value);
    }
    getActiveChar().stopFeed();
    super.setLevel(value);

    getActiveChar().startFeed();

    if (getActiveChar().getControlItem() != null) {
      getActiveChar().getControlItem().setEnchantLevel(getLevel());
    }
  }
Beispiel #3
0
 @Override
 public final long getExpForLevel(int level) {
   try {
     return PetDataTable.getInstance()
         .getPetLevelData(getActiveChar().getId(), level)
         .getPetMaxExp();
   } catch (NullPointerException e) {
     if (getActiveChar() != null) {
       _log.warning(
           "Pet objectId:"
               + getActiveChar().getObjectId()
               + ", NpcId:"
               + getActiveChar().getId()
               + ", level:"
               + level
               + " is missing data from pets_stats table!");
     }
     throw e;
   }
 }