Пример #1
0
  private void load() {
    final File dir = new File("./data/xml/skills");

    for (File file : dir.listFiles()) {
      DocumentSkill doc = new DocumentSkill(file);
      doc.parse();

      for (L2Skill skill : doc.getSkills()) _skills.put(getSkillHashCode(skill), skill);
    }

    _log.info("SkillTable: Loaded " + _skills.size() + " skills.");

    // Stores max level of skills in a map for future uses.
    for (final L2Skill skill : _skills.values()) {
      // Only non-enchanted skills
      final int skillLvl = skill.getLevel();
      if (skillLvl < 99) {
        final int skillId = skill.getId();
        final int maxLvl = getMaxLevel(skillId);

        if (skillLvl > maxLvl) _skillMaxLevel.put(skillId, skillLvl);
      }
    }

    // Loading FrequentSkill enumeration values
    for (FrequentSkill sk : FrequentSkill.values()) sk._skill = getInfo(sk._id, sk._level);

    for (int i = 0; i < _heroSkillsId.length; i++) _heroSkills[i] = getInfo(_heroSkillsId[i], 1);

    for (int i = 0; i < _nobleSkills.length; i++) _nobleSkills[i] = getInfo(_nobleSkillsId[i], 1);
  }
Пример #2
0
  @Override
  public boolean onActionTime() {
    if (_skill == null) return true;

    int mpConsume = _skill.getMpConsume();
    if (mpConsume > getEffector().getCurrentMp()) {
      getEffector()
          .sendPacket(SystemMessage.getSystemMessage(SystemMessageId.SKILL_REMOVED_DUE_LACK_MP));
      return false;
    }
    getEffector().reduceCurrentMp(mpConsume);

    List<L2Character> targets = new ArrayList<>();
    for (L2Character cha :
        _actor
            .getKnownList()
            .getKnownTypeInRadius(L2Character.class, getSkill().getSkillRadius())) {
      if (_skill.isOffensive()
          && !L2Skill.checkForAreaOffensiveSkills(getEffector(), cha, _skill, _srcInArena))
        continue;

      // there doesn't seem to be a visible effect with MagicSkillLaunched packet...
      _actor.broadcastPacket(
          new MagicSkillUse(_actor, cha, _skill.getId(), _skill.getLevel(), 0, 0));
      targets.add(cha);
    }

    if (!targets.isEmpty())
      getEffector().callSkill(_skill, targets.toArray(new L2Character[targets.size()]));

    return true;
  }
 public void onTransform() {
   // Disable all character skills.
   for (L2Skill sk : this.getPlayer().getAllSkills()) {
     if (sk != null && !sk.isPassive()) this.getPlayer().removeSkill(sk, false);
   }
   if (this.getPlayer().transformId() > 0 && !this.getPlayer().isCursedWeaponEquipped()) {
     // give transformation skills
     transformedSkills();
     return;
   }
   // give transformation skills
   transformedSkills();
 }
Пример #4
0
  @Override
  public void useSkill(L2Character activeChar, L2Skill skill, L2Object[] targets) {
    if (!(activeChar instanceof L2PcInstance)) return;

    if (targets == null) return;

    for (L2Object tgt : targets) {
      if (!(tgt instanceof L2MonsterInstance)) continue;

      final L2MonsterInstance target = (L2MonsterInstance) tgt;
      if (target.isDead()) continue;

      if (target.getSpoilerId() != 0) {
        activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.ALREADY_SPOILED));
        continue;
      }

      if (Formulas.calcMagicSuccess(activeChar, (L2Character) tgt, skill)) {
        target.setSpoilerId(activeChar.getObjectId());
        activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.SPOIL_SUCCESS));
      } else
        activeChar.sendPacket(
            SystemMessage.getSystemMessage(SystemMessageId.S1_RESISTED_YOUR_S2)
                .addCharName(target)
                .addSkillName(skill.getId()));

      target.getAI().notifyEvent(CtrlEvent.EVT_ATTACKED, activeChar);
    }
  }
Пример #5
0
  @Override
  public String onSkillSee(
      L2Npc npc, L2PcInstance caster, L2Skill skill, L2Object[] targets, boolean isPet) {
    // Caster is an allied.
    if (caster.isAlliedWithKetra()) {
      // Caster's skill is a positive effect ? Go further.
      switch (skill.getSkillType()) {
        case BUFF:
        case HEAL:
        case HEAL_PERCENT:
        case HEAL_STATIC:
        case BALANCE_LIFE:
        case HOT:
          for (L2Character target : (L2Character[]) targets) {
            // Character isn't existing, is dead or is current caster, we drop check.
            if (target == null || target.isDead() || target == caster) continue;

            // Target isn't a summon nor a player, we drop check.
            if (!(target instanceof L2Playable)) continue;

            // Retrieve the player behind that target.
            final L2PcInstance player = target.getActingPlayer();

            // If player is neutral or enemy, go further.
            if (!(player.isAlliedWithKetra())) {
              // If the NPC got that player registered in aggro list, go further.
              if (((L2Attackable) npc).containsTarget(player)) {
                // Save current target for future use.
                final L2Object oldTarget = npc.getTarget();

                // Curse the heretic or his pet.
                npc.setTarget((isPet && player.getPet() != null) ? caster.getPet() : caster);
                npc.doCast(FrequentSkill.VARKA_KETRA_PETRIFICATION.getSkill());

                // Revert to old target && drop the loop.
                npc.setTarget(oldTarget);
                break;
              }
            }
          }
          break;
      }
    }

    // Continue normal behavior.
    return super.onSkillSee(npc, caster, skill, targets, isPet);
  }
Пример #6
0
 @Override
 public String onSkillSee(
     L2Npc npc, L2PcInstance caster, L2Skill skill, L2Object[] targets, boolean isPet) {
   if (skill.getSkillType() == L2SkillType.AGGDAMAGE && targets.length != 0) {
     for (L2Object obj : targets) {
       if (obj.equals(npc)) {
         npc.broadcastNpcSay(
             ((caster.getAppearance().getSex()) ? "Sister " : "Brother ")
                 + caster.getName()
                 + ", move your weapon away!");
         attack(((L2Attackable) npc), caster);
         break;
       }
     }
   }
   return super.onSkillSee(npc, caster, skill, targets, isPet);
 }
Пример #7
0
  @Override
  public String onSpellFinished(L2Npc npc, L2PcInstance player, L2Skill skill) {
    if (skill.getId() == 4589) attack(((L2Attackable) npc), player);

    return super.onSpellFinished(npc, player, skill);
  }
Пример #8
0
 public ConfirmDlg addSkillName(L2Skill skill) {
   return addSkillName(skill.getId(), skill.getLevel());
 }
Пример #9
0
 /**
  * Provides the skill hash
  *
  * @param skill The L2Skill to be hashed
  * @return SkillTable.getSkillHashCode(skill.getId(), skill.getLevel())
  */
 public static int getSkillHashCode(L2Skill skill) {
   return getSkillHashCode(skill.getId(), skill.getLevel());
 }