コード例 #1
0
  public void load() {
    _skillTrees.clear();
    int count = 0;
    try (Connection con = ConnectionFactory.getInstance().getConnection();
        Statement s = con.createStatement();
        ResultSet rs =
            s.executeQuery("SELECT templateId, minLvl, skillId, skillLvl FROM pets_skills")) {
      while (rs.next()) {
        final int npcId = rs.getInt("templateId");
        Map<Integer, L2PetSkillLearn> skillTree = _skillTrees.get(npcId);
        if (skillTree == null) {
          skillTree = new HashMap<>();
          _skillTrees.put(npcId, skillTree);
        }

        int id = rs.getInt("skillId");
        int lvl = rs.getInt("skillLvl");
        skillTree.put(
            SkillData.getSkillHashCode(id, lvl + 1),
            new L2PetSkillLearn(id, lvl, rs.getInt("minLvl")));
        count++;
      }
    } catch (Exception e) {
      LOGGER.log(
          Level.SEVERE, getClass().getSimpleName() + ": Error while loading pet skill tree:", e);
    }
    LOGGER.info(getClass().getSimpleName() + ": Loaded " + count + " skills.");
  }
コード例 #2
0
  @Override
  protected void runImpl() {
    // Get the current L2PcInstance of the player
    final L2PcInstance activeChar = getClient().getActiveChar();
    if (activeChar == null) {
      return;
    }

    // Get the level of the used skill
    int level = activeChar.getSkillLevel(_skillId);
    if (level <= 0) {
      activeChar.sendPacket(ActionFailed.STATIC_PACKET);
      return;
    }

    // Get the L2Skill template corresponding to the skillID received from the client
    Skill skill = SkillData.getInstance().getSkill(_skillId, level);

    // Check the validity of the skill
    if (skill != null) {
      activeChar.setCurrentSkillWorldPosition(new Location(_x, _y, _z));

      // normally magicskilluse packet turns char client side but for these skills, it doesn't (even
      // with correct target)
      activeChar.setHeading(
          Util.calculateHeadingFrom(activeChar.getX(), activeChar.getY(), _x, _y));
      Broadcast.toKnownPlayers(activeChar, new ValidateLocation(activeChar));

      activeChar.useMagic(skill, _ctrlPressed, _shiftPressed);
    } else {
      activeChar.sendPacket(ActionFailed.STATIC_PACKET);
      _log.warning("No skill found with id " + _skillId + " and level " + level + " !!");
    }
  }
コード例 #3
0
  public static void showFishSkillList(L2PcInstance player) {
    final List<L2SkillLearn> skills =
        SkillTreesData.getInstance().getAvailableFishingSkills(player);
    final AcquireSkillList asl = new AcquireSkillList(AcquireSkillType.FISHING);

    int count = 0;

    for (L2SkillLearn s : skills) {
      final Skill sk = SkillData.getInstance().getSkill(s.getSkillId(), s.getSkillLevel());

      if (sk == null) {
        continue;
      }
      count++;
      asl.addSkill(s.getSkillId(), s.getSkillLevel(), s.getSkillLevel(), s.getLevelUpSp(), 1);
    }

    if (count == 0) {
      final int minlLevel =
          SkillTreesData.getInstance()
              .getMinLevelForNewSkill(player, SkillTreesData.getInstance().getFishingSkillTree());
      if (minlLevel > 0) {
        SystemMessage sm =
            SystemMessage.getSystemMessage(SystemMessageId.DO_NOT_HAVE_FURTHER_SKILLS_TO_LEARN_S1);
        sm.addInt(minlLevel);
        player.sendPacket(sm);
      } else {
        player.sendPacket(SystemMessageId.NO_MORE_SKILLS_TO_LEARN);
      }
    } else {
      player.sendPacket(asl);
    }
  }
コード例 #4
0
ファイル: Race.java プロジェクト: rukhavi/l2j-mobius
  @Override
  public boolean eventBypass(L2PcInstance activeChar, String bypass) {
    if (bypass.startsWith("skill")) {
      if (_isRaceStarted) {
        activeChar.sendMessage("Race already started, you cannot change transform skill now");
      } else {
        int _number = Integer.valueOf(bypass.substring(5));
        Skill _sk = SkillData.getInstance().getSkill(_number, 1);
        if (_sk != null) {
          _skill = _number;
          activeChar.sendMessage("Transform skill set to:");
          activeChar.sendMessage(_sk.getName());
        } else {
          activeChar.sendMessage("Error while changing transform skill");
        }
      }

    } else if (bypass.startsWith("tele")) {
      if ((Integer.valueOf(bypass.substring(4)) > 0) && (_randspawn != null)) {
        activeChar.teleToLocation(_randspawn[0], _randspawn[1], _randspawn[2]);
      } else {
        activeChar.teleToLocation(18429, 145861, -3090);
      }
    }
    showMenu(activeChar);
    return true;
  }
コード例 #5
0
  /**
   * 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);
      }
    }
  }
コード例 #6
0
ファイル: Race.java プロジェクト: rukhavi/l2j-mobius
  private void transformPlayer(L2PcInstance player) {
    if (player.isTransformed() || player.isInStance()) {
      player.untransform();
    }
    if (player.isSitting()) {
      player.standUp();
    }

    player.getEffectList().stopSkillEffects(true, AbnormalType.SPEED_UP);
    player.stopSkillEffects(true, 268);
    player.stopSkillEffects(true, 298); // Rabbit Spirit Totem
    SkillData.getInstance().getSkill(_skill, 1).applyEffects(player, player);
  }
コード例 #7
0
  public int getAvailableLevel(L2Summon cha, int skillId) {
    int lvl = 0;
    if (!_skillTrees.containsKey(cha.getId())) {
      LOGGER.warning(
          getClass().getSimpleName()
              + ": Pet id "
              + cha.getId()
              + " does not have any skills assigned.");
      return lvl;
    }
    Collection<L2PetSkillLearn> skills = _skillTrees.get(cha.getId()).values();
    for (L2PetSkillLearn temp : skills) {
      if (temp.getId() != skillId) {
        continue;
      }
      if (temp.getLevel() == 0) {
        if (cha.getLevel() < 70) {
          lvl = (cha.getLevel() / 10);
          if (lvl <= 0) {
            lvl = 1;
          }
        } else {
          lvl = (7 + ((cha.getLevel() - 70) / 5));
        }

        // formula usable for skill that have 10 or more skill levels
        int maxLvl = SkillData.getInstance().getMaxLevel(temp.getId());
        if (lvl > maxLvl) {
          lvl = maxLvl;
        }
        break;
      } else if (temp.getMinLevel() <= cha.getLevel()) {
        if (temp.getLevel() > lvl) {
          lvl = temp.getLevel();
        }
      }
    }
    return lvl;
  }
コード例 #8
0
  /**
   * Cast a skill for all active summon.<br>
   * Target is retrieved from owner's target
   *
   * @param skillId the skill Id to use
   */
  private void useServitorsSkill(int skillId) {
    final L2PcInstance activeChar = getActiveChar();
    if (activeChar == null) {
      return;
    }

    activeChar
        .getServitors()
        .values()
        .forEach(
            servitor -> {
              if (!validateSummon(servitor, false)) {
                return;
              }

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

              if (lvl > 0) {
                servitor.setTarget(activeChar.getTarget());
                servitor.useMagic(
                    SkillData.getInstance().getSkill(skillId, lvl), _ctrlPressed, _shiftPressed);
              }
            });
  }
コード例 #9
0
  @Override
  public final String onAdvEvent(String event, L2Npc npc, L2PcInstance player) {
    String htmltext = event;

    // Timer. Spawns Naia Lock
    if (event.equalsIgnoreCase("spawn_lock")) {
      htmltext = null;
      _lock = (L2MonsterInstance) addSpawn(LOCK, 16409, 244438, 11620, -1048, false, 0, false);
      _counter = 90;
    }

    // Timer. Depending of _challengeState despans all spawned spores, or spores, reached assembly
    // point
    else if (event.equalsIgnoreCase("despawn_total")) {
      // Spores is not attacked too long - despawn them all, reinit values
      if (_challengeState == STATE_SPORE_IDLE_TOO_LONG) {
        for (L2Npc spore : _sporeSpawn) {
          if ((spore != null) && !spore.isDead()) {
            spore.deleteMe();
          }
        }
        _sporeSpawn.clear();
        initSporeChallenge();
      }
      // Spores are moving to assembly point. Despawn all reached, check for reached spores count.
      else if ((_challengeState == STATE_SPORE_CHALLENGE_SUCCESSFULL) && (_winIndex >= 0)) {
        // Requirements are met, despawn all spores, spawn Epidos
        if ((_despawnedSporesCount >= 10) || _sporeSpawn.isEmpty()) {
          if (!_sporeSpawn.isEmpty()) {
            for (L2Npc spore : _sporeSpawn) {
              if ((spore != null) && !spore.isDead()) {
                spore.deleteMe();
              }
            }
          }
          _sporeSpawn.clear();
          _despawnedSporesCount = 0;
          int[] coords = SPORES_MERGE_POSITION[_winIndex];
          addSpawn(EPIDOSES[_winIndex], coords[0], coords[1], coords[2], 0, false, 0, false);
          initSporeChallenge();
        }
        // Requirements aren't met, despawn reached spores
        else {
          Iterator<L2Npc> it = _sporeSpawn.iterator();
          while (it.hasNext()) {
            L2Npc spore = it.next();
            if ((spore != null)
                && !spore.isDead()
                && (spore.getX() == spore.getSpawn().getX())
                && (spore.getY() == spore.getSpawn().getY())) {
              spore.deleteMe();
              it.remove();
              _despawnedSporesCount++;
            }
          }

          startQuestTimer("despawn_total", 3000, null, null);
        }
      }
    }

    if (npc == null) {
      return null;
    }

    final int npcId = npc.getId();

    if (event.equalsIgnoreCase("despawn_spore")
        && !npc.isDead()
        && (_challengeState == STATE_SPORE_CHALLENGE_IN_PROGRESS)) {
      htmltext = null;

      _sporeSpawn.remove(npc);
      npc.deleteMe();

      if (npcId == SPORE_BASIC) {
        spawnRandomSpore();
        spawnRandomSpore();
      } else if ((npcId >= SPORE_FIRE) && (npcId <= SPORE_EARTH)) {
        _despawnedSporesCount++;

        if (_despawnedSporesCount < SELF_DESPAWN_LIMIT) {
          spawnOppositeSpore(npcId);
        } else {
          _challengeState = STATE_SPORE_IDLE_TOO_LONG;
          startQuestTimer("despawn_total", 60000, null, null);
        }
      }
    } else if (event.equalsIgnoreCase("18492-05.htm")) {
      if ((_lock == null) || (_lock.getCurrentHp() > (_lock.getMaxHp() / 10))) {
        htmltext = null;
        if (_lock != null) {
          _lock.deleteMe();
          _lock = null;
        }
        cancelQuestTimers("spawn_lock");
        startQuestTimer("spawn_lock", 300000, null, null);
        npc.setTarget(player);
        npc.doCast(SkillData.getInstance().getSkill(5527, 1));
      }
    } else if (event.equalsIgnoreCase("teleport") && (_lock != null)) {
      htmltext = null;
      L2Party party = player.getParty();
      if (party != null) {
        if (Util.checkIfInRange(3000, party.getLeader(), npc, true)) {
          for (L2PcInstance partyMember : party.getMembers()) {
            if (Util.checkIfInRange(2000, partyMember, npc, true)) {
              partyMember.teleToLocation(-47271, 246098, -9120, true);
            }
          }
          _lock.deleteMe();
          _lock = null;
          cancelQuestTimers("spawn_lock");
          startQuestTimer("spawn_lock", 1200000, null, null);
        } else {
          npc.setTarget(player);
          npc.doCast(SkillData.getInstance().getSkill(5527, 1));
        }
      } else {
        player.teleToLocation(-47271, 246098, -9120);
        _lock.deleteMe();
        _lock = null;
        cancelQuestTimers("spawn_lock");
        startQuestTimer("spawn_lock", 1200000, null, null);
      }
    } else if (event.equalsIgnoreCase("go")
        && _activeRooms.containsKey(npcId)
        && !_activeRooms.get(npcId)) {
      htmltext = null;
      L2Party party = player.getParty();

      if (party != null) {
        removeForeigners(npcId, party);
        startRoom(npcId);
        ThreadPoolManager.getInstance().scheduleGeneral(new StopRoomTask(npcId), 300000);
      } else {
        player.sendPacket(SystemMessageId.CAN_OPERATE_MACHINE_WHEN_IN_PARTY);
      }
    }
    return htmltext;
  }