Пример #1
0
  /**
   * @param addNoble if true, will add also Advanced headquarters.
   * @return an array with siege skills.
   */
  public L2Skill[] getSiegeSkills(boolean addNoble) {
    L2Skill[] temp = new L2Skill[2 + (addNoble ? 1 : 0)];
    int i = 0;

    temp[i++] = _skills.get(SkillTable.getSkillHashCode(246, 1));
    temp[i++] = _skills.get(SkillTable.getSkillHashCode(247, 1));

    if (addNoble) temp[i++] = _skills.get(SkillTable.getSkillHashCode(326, 1));

    return temp;
  }
Пример #2
0
  @Override
  public boolean onStart() {
    if (getSkill() instanceof L2SkillSignet)
      _skill = SkillTable.getInstance().getInfo(((L2SkillSignet) getSkill()).effectId, getLevel());
    else if (getSkill() instanceof L2SkillSignetCasttime)
      _skill =
          SkillTable.getInstance()
              .getInfo(((L2SkillSignetCasttime) getSkill()).effectId, getLevel());

    _actor = (L2EffectPointInstance) getEffected();
    _srcInArena = getEffector().isInArena();
    return true;
  }
Пример #3
0
  @Override
  public String onSpawn(L2Npc npc) {
    for (L2PcInstance target : npc.getKnownList().getKnownType(L2PcInstance.class)) {
      if (!target.isDead()
          && GeoData.getInstance().canSeeTarget(npc, target)
          && Util.checkIfInRange(npc.getAggroRange(), npc, target, true)) {
        if (target.getActiveWeaponInstance() != null
            && !npc.isInCombat()
            && npc.getTarget() == null) {
          npc.setTarget(target);
          npc.broadcastNpcSay(
              ((target.getAppearance().getSex()) ? "Sister " : "Brother ")
                  + target.getName()
                  + ", move your weapon away!");

          switch (npc.getNpcId()) {
            case 22124:
            case 22126:
            case 22127:
              npc.doCast(SkillTable.getInstance().getInfo(4589, 8));
              break;

            default:
              attack(((L2Attackable) npc), target);
              break;
          }
        }
      }
    }
    return super.onSpawn(npc);
  }
Пример #4
0
  /**
   * This method displays EnchantSkillList to the player.
   *
   * @param player The player who requested the method.
   * @param npc The L2Npc linked to the request.
   * @param classId The classId asked. Used to sort available enchant skill list.
   */
  public static void showEnchantSkillList(L2PcInstance player, L2Npc npc, ClassId classId) {
    if (((L2NpcInstance) npc).getClassesToTeach() == null) {
      NpcHtmlMessage html = new NpcHtmlMessage(npc.getObjectId());
      final String sb =
          StringUtil.concat(
              "<html><body>I cannot teach you. My class list is empty.<br>Your admin needs to add me teachTo informations.<br>NpcId:",
              String.valueOf(npc.getTemplate().getNpcId()),
              ", your classId:",
              String.valueOf(player.getClassId().getId()),
              "</body></html>");
      html.setHtml(sb);
      player.sendPacket(html);
      return;
    }

    if (!npc.getTemplate().canTeach(classId)) {
      NpcHtmlMessage html = new NpcHtmlMessage(npc.getObjectId());
      html.setFile("data/html/trainer/" + npc.getTemplate().getNpcId() + "-noskills.htm");
      player.sendPacket(html);
      return;
    }

    if (player.getClassId().level() < 3) {
      NpcHtmlMessage html = new NpcHtmlMessage(npc.getObjectId());
      html.setHtml("<html><body> You must have 3rd class change quest completed.</body></html>");
      player.sendPacket(html);
      return;
    }

    ExEnchantSkillList esl = new ExEnchantSkillList();
    boolean empty = true;

    List<L2EnchantSkillLearn> esll = SkillTreeTable.getInstance().getAvailableEnchantSkills(player);
    for (L2EnchantSkillLearn skill : esll) {
      L2Skill sk = SkillTable.getInstance().getInfo(skill.getId(), skill.getLevel());
      if (sk == null) continue;

      L2EnchantSkillData data =
          SkillTreeTable.getInstance().getEnchantSkillData(skill.getEnchant());
      if (data == null) continue;

      esl.addSkill(skill.getId(), skill.getLevel(), data.getCostSp(), data.getCostExp());
      empty = false;
    }

    if (empty) {
      player.sendPacket(SystemMessageId.THERE_IS_NO_SKILL_THAT_ENABLES_ENCHANT);

      if (player.getLevel() < 74)
        player.sendPacket(
            SystemMessage.getSystemMessage(SystemMessageId.DO_NOT_HAVE_FURTHER_SKILLS_TO_LEARN_S1)
                .addNumber(74));
      else player.sendPacket(SystemMessageId.NO_MORE_SKILLS_TO_LEARN);
    } else player.sendPacket(esl);

    player.sendPacket(ActionFailed.STATIC_PACKET);
  }
Пример #5
0
 public void loadAllSkills(final TIntObjectHashMap<L2Skill> allSkills) {
   int count = 0;
   for (File file : _skillFiles) {
     List<L2Skill> s = loadSkills(file);
     if (s == null) continue;
     for (L2Skill skill : s) {
       allSkills.put(SkillTable.getSkillHashCode(skill), skill);
       count++;
     }
   }
   _log.info("SkillsEngine: Loaded " + count + " skill templates from XML files.");
 }
Пример #6
0
  /**
   * This method displays SkillList to the player.
   *
   * @param player The player who requested the method.
   * @param npc The L2Npc linked to the request.
   * @param classId The classId asked. Used to sort available skill list.
   */
  public static void showSkillList(L2PcInstance player, L2Npc npc, ClassId classId) {
    if (((L2NpcInstance) npc).getClassesToTeach() == null) {
      NpcHtmlMessage html = new NpcHtmlMessage(npc.getObjectId());
      final String sb =
          StringUtil.concat(
              "<html><body>I cannot teach you. My class list is empty.<br>Your admin needs to add me teachTo informations.<br>NpcId:",
              String.valueOf(npc.getTemplate().getNpcId()),
              ", your classId:",
              String.valueOf(player.getClassId().getId()),
              "</body></html>");
      html.setHtml(sb);
      player.sendPacket(html);
      return;
    }

    if (!npc.getTemplate().canTeach(classId)) {
      NpcHtmlMessage html = new NpcHtmlMessage(npc.getObjectId());
      html.setFile("data/html/trainer/" + npc.getTemplate().getNpcId() + "-noskills.htm");
      player.sendPacket(html);
      return;
    }

    AcquireSkillList asl = new AcquireSkillList(AcquireSkillList.SkillType.Usual);
    boolean empty = true;

    for (L2SkillLearn sl : SkillTreeTable.getInstance().getAvailableSkills(player, classId)) {
      L2Skill sk = SkillTable.getInstance().getInfo(sl.getId(), sl.getLevel());
      if (sk == null) continue;

      asl.addSkill(sl.getId(), sl.getLevel(), sl.getLevel(), sl.getSpCost(), 0);
      empty = false;
    }

    if (empty) {
      int minlevel = SkillTreeTable.getInstance().getMinLevelForNewSkill(player, classId);

      if (minlevel > 0)
        player.sendPacket(
            SystemMessage.getSystemMessage(SystemMessageId.DO_NOT_HAVE_FURTHER_SKILLS_TO_LEARN_S1)
                .addNumber(minlevel));
      else player.sendPacket(SystemMessageId.NO_MORE_SKILLS_TO_LEARN);
    } else player.sendPacket(asl);

    player.sendPacket(ActionFailed.STATIC_PACKET);
  }
  public void removeSkills() {
    // Double Slasher (up to 4 levels)
    getPlayer().removeSkill(SkillTable.getInstance().getInfo(572, 4), false);
    // Earthquake (up to 4 levels)
    getPlayer().removeSkill(SkillTable.getInstance().getInfo(573, 4), false);
    // Bomb Installation (up to 4 levels)
    getPlayer().removeSkill(SkillTable.getInstance().getInfo(574, 4), false);
    // Steel Cutter (up to 4 levels)
    getPlayer().removeSkill(SkillTable.getInstance().getInfo(575, 4), false);
    // Decrease Bow/Crossbow Attack Speed
    getPlayer().removeSkill(SkillTable.getInstance().getInfo(5491, 1), false);
    // Transfrom Dispel
    getPlayer().removeSkill(SkillTable.getInstance().getInfo(619, 1), false);

    getPlayer().setTransformAllowedSkills(new int[] {});
  }
 public void removeSkills() {
   // Double Slasher
   this.getPlayer().removeSkill(SkillTable.getInstance().getInfo(572, 4), false);
   // Earthquake
   this.getPlayer().removeSkill(SkillTable.getInstance().getInfo(573, 4), false);
   // Bomb Installation
   this.getPlayer().removeSkill(SkillTable.getInstance().getInfo(574, 4), false);
   // Steel Cutter
   this.getPlayer().removeSkill(SkillTable.getInstance().getInfo(575, 4), false);
   // Transfrom Dispel
   this.getPlayer().removeSkill(SkillTable.getInstance().getInfo(619, 1), false);
   // Decrease Bow/Crossbow Attack Speed
   this.getPlayer().removeSkill(SkillTable.getInstance().getInfo(5491, 1), false);
   // Send a Server->Client packet StatusUpdate to the L2PcInstance.
   this.getPlayer().sendSkillList();
 }
Пример #9
0
  private void makeCast(EffectChanceSkillTrigger effect, L2Character target) {
    try {
      if (effect == null || !effect.triggersChanceSkill()) return;

      L2Skill triggered =
          SkillTable.getInstance()
              .getInfo(effect.getTriggeredChanceId(), effect.getTriggeredChanceLevel());
      if (triggered == null) return;
      L2Character caster =
          triggered.getTargetType() == L2Skill.SkillTargetType.TARGET_SELF
              ? _owner
              : effect.getEffector();

      if (caster == null
          || triggered.getSkillType() == L2SkillType.NOTDONE
          || caster.isSkillDisabled(triggered)) return;

      if (triggered.getReuseDelay() > 0) caster.disableSkill(triggered, triggered.getReuseDelay());

      L2Object[] targets = triggered.getTargetList(caster, false, target);

      if (targets.length == 0) return;

      L2Character firstTarget = (L2Character) targets[0];

      ISkillHandler handler = SkillHandler.getInstance().getSkillHandler(triggered.getSkillType());

      _owner.broadcastPacket(
          new MagicSkillLaunched(_owner, triggered.getId(), triggered.getLevel(), targets));
      _owner.broadcastPacket(
          new MagicSkillUse(_owner, firstTarget, triggered.getId(), triggered.getLevel(), 0, 0));

      // Launch the magic skill and calculate its effects
      // TODO: once core will support all possible effects, use effects (not handler)
      if (handler != null) handler.useSkill(caster, triggered, targets);
      else triggered.useSkill(caster, targets);
    } catch (Exception e) {
      _log.log(Level.WARNING, "", e);
    }
  }
Пример #10
0
  private void makeCast(L2Skill skill, L2Character target) {
    try {
      if (skill.getWeaponDependancy(_owner) && skill.checkCondition(_owner, target, false)) {
        if (skill
            .triggersChanceSkill()) // skill will trigger another skill, but only if its not chance
                                    // skill
        {
          skill =
              SkillTable.getInstance()
                  .getInfo(skill.getTriggeredChanceId(), skill.getTriggeredChanceLevel());
          if (skill == null || skill.getSkillType() == L2SkillType.NOTDONE) return;
        }

        if (_owner.isSkillDisabled(skill)) return;

        if (skill.getReuseDelay() > 0) _owner.disableSkill(skill, skill.getReuseDelay());

        L2Object[] targets = skill.getTargetList(_owner, false, target);

        if (targets.length == 0) return;

        L2Character firstTarget = (L2Character) targets[0];

        ISkillHandler handler = SkillHandler.getInstance().getSkillHandler(skill.getSkillType());

        _owner.broadcastPacket(
            new MagicSkillLaunched(_owner, skill.getId(), skill.getLevel(), targets));
        _owner.broadcastPacket(
            new MagicSkillUse(_owner, firstTarget, skill.getId(), skill.getLevel(), 0, 0));

        // Launch the magic skill and calculate its effects
        // TODO: once core will support all possible effects, use effects (not handler)
        if (handler != null) handler.useSkill(_owner, skill, targets);
        else skill.useSkill(_owner, targets);
      }
    } catch (Exception e) {
      _log.log(Level.WARNING, "", e);
    }
  }
Пример #11
0
  @Override
  public String onAdvEvent(String event, L2Npc npc, L2PcInstance player) {
    String htmltext = getNoQuestMsg();
    QuestState st = player.getQuestState(getName());
    if (st == null) return htmltext;

    if (Util.isDigit(event)) {
      final int eventId = Integer.parseInt(event);
      if (eventId >= 0 && eventId <= 7) {
        if (st.getQuestItemsCount(HORN) >= BUFF[eventId - 1][2]) {
          st.takeItems(HORN, BUFF[eventId - 1][2]);
          npc.setTarget(player);
          npc.doCast(SkillTable.getInstance().getInfo(BUFF[eventId - 1][0], BUFF[eventId - 1][1]));
          npc.setCurrentHpMp(npc.getMaxHp(), npc.getMaxMp());
          htmltext = "31372-4.htm";
        }
      }
    } else if (event.equals("Withdraw")) {
      if (player.getWarehouse().getSize() == 0) htmltext = "31374-0.htm";
      else {
        player.sendPacket(ActionFailed.STATIC_PACKET);
        player.setActiveWarehouse(player.getWarehouse());
        player.sendPacket(new WareHouseWithdrawalList(player, 1));
      }
    } else if (event.equals("Teleport")) {
      switch (player.getAllianceWithVarkaKetra()) {
        case 4:
          htmltext = "31376-4.htm";
          break;
        case 5:
          htmltext = "31376-5.htm";
          break;
      }
    }

    return htmltext;
  }
Пример #12
0
  @Override
  public String onAggroRangeEnter(L2Npc npc, L2PcInstance player, boolean isPet) {
    if (!npc.isInCombat()) {
      if (player.getActiveWeaponInstance() != null) {
        npc.setTarget(player);
        npc.broadcastNpcSay(
            ((player.getAppearance().getSex()) ? "Sister " : "Brother ")
                + player.getName()
                + ", move your weapon away!");

        switch (npc.getNpcId()) {
          case 22124:
          case 22126:
            npc.doCast(SkillTable.getInstance().getInfo(4589, 8));
            break;

          default:
            attack(((L2Attackable) npc), player);
            break;
        }
      } else if (((L2Attackable) npc).getMostHated() == null) return null;
    }
    return super.onAggroRangeEnter(npc, player, isPet);
  }
  public void removeSkills() {
    // Divine Punishment
    getPlayer()
        .removeSkill(SkillTable.getInstance().getInfo(1523, getPlayer().getLevel() - 43), false);
    // Divine Flash
    getPlayer()
        .removeSkill(SkillTable.getInstance().getInfo(1528, getPlayer().getLevel() - 43), false);
    // Surrender to the Holy
    getPlayer()
        .removeSkill(SkillTable.getInstance().getInfo(1524, getPlayer().getLevel() - 43), false);
    // Divine Curse
    getPlayer()
        .removeSkill(SkillTable.getInstance().getInfo(1525, getPlayer().getLevel() - 43), false);
    // Decrease Bow/Crossbow Attack Speed
    getPlayer().removeSkill(SkillTable.getInstance().getInfo(5491, 1), false);
    // Switch Stance
    getPlayer().removeSkill(SkillTable.getInstance().getInfo(838, 1), false);

    getPlayer().setTransformAllowedSkills(new int[] {});
  }
 public void transformedSkills() {
   if (getPlayer().getLevel() > 43) {
     // Divine Punishment
     getPlayer()
         .addSkill(SkillTable.getInstance().getInfo(1523, getPlayer().getLevel() - 43), false);
     // Divine Flash
     getPlayer()
         .addSkill(SkillTable.getInstance().getInfo(1528, getPlayer().getLevel() - 43), false);
     // Surrender to the Holy
     getPlayer()
         .addSkill(SkillTable.getInstance().getInfo(1524, getPlayer().getLevel() - 43), false);
     // Divine Curse
     getPlayer()
         .addSkill(SkillTable.getInstance().getInfo(1525, getPlayer().getLevel() - 43), false);
     getPlayer()
         .setTransformAllowedSkills(
             new int[] {838, 5491, 1523, 1528, 1524, 1525, 1430, 1043, 1042, 1400, 1418});
   } else
     getPlayer().setTransformAllowedSkills(new int[] {838, 5491, 1430, 1043, 1042, 1400, 1418});
   // Decrease Bow/Crossbow Attack Speed
   getPlayer().addSkill(SkillTable.getInstance().getInfo(5491, 1), false);
   // Switch Stance
   getPlayer().addSkill(SkillTable.getInstance().getInfo(838, 1), false);
 }
Пример #15
0
 /**
  * Rebind the passive skill belonging to the CursedWeapon. Invoke this method if the weapon owner
  * switches to a subclass.
  */
 public void giveDemonicSkills() {
   _player.addSkill(SkillTable.getInstance().getInfo(_skillId, _currentStage), false);
   _player.sendSkillList();
 }
Пример #16
0
/**
 * Primeval Isle AIs. This script controls following behaviors :
 *
 * <ul>
 *   <li>Sprigant : casts a spell if you enter in aggro range, finish task if die or none around.
 *   <li>Ancient Egg : call all NPCs in a 2k range if attacked.
 *   <li>Pterosaurs and Tyrannosaurus : can see through Silent Move.
 * </ul>
 */
public class PrimevalIsle extends AbstractNpcAI {
  private static final int[] SPRIGANTS = {18345, 18346};

  private static final int[] MOBIDS = {22199, 22215, 22216, 22217};

  private static final int ANCIENT_EGG = 18344;

  private static final L2Skill ANESTHESIA = SkillTable.getInstance().getInfo(5085, 1);
  private static final L2Skill POISON = SkillTable.getInstance().getInfo(5086, 1);

  public PrimevalIsle() {
    super("ai/group");

    for (L2Spawn npc : SpawnTable.getInstance().getSpawnTable())
      if (Util.contains(MOBIDS, npc.getNpcId())
          && npc.getLastSpawn() != null
          && npc.getLastSpawn() instanceof L2Attackable)
        ((L2Attackable) npc.getLastSpawn()).seeThroughSilentMove(true);

    registerMobs(SPRIGANTS, EventType.ON_AGGRO, EventType.ON_KILL);
    addAttackId(ANCIENT_EGG);
    addSpawnId(MOBIDS);
  }

  @Override
  public String onAdvEvent(String event, L2Npc npc, L2PcInstance player) {
    if (!(npc instanceof L2Attackable)) return null;

    if (event.equalsIgnoreCase("skill")) {
      int playableCounter = 0;
      for (L2Playable playable :
          npc.getKnownList().getKnownTypeInRadius(L2Playable.class, npc.getAggroRange())) {
        if (!playable.isDead()) playableCounter++;
      }

      // If no one is inside aggro range, drop the task.
      if (playableCounter == 0) {
        cancelQuestTimer("skill", npc, null);
        return null;
      }

      npc.setTarget(npc);
      npc.doCast((npc.getNpcId() == 18345) ? ANESTHESIA : POISON);
    }
    return null;
  }

  @Override
  public String onAggro(L2Npc npc, L2PcInstance player, boolean isPet) {
    if (player == null) return null;

    // Instant use
    npc.setTarget(npc);
    npc.doCast((npc.getNpcId() == 18345) ? ANESTHESIA : POISON);

    // Launch a task every 15sec.
    if (getQuestTimer("skill", npc, null) == null) startQuestTimer("skill", 15000, npc, null, true);

    return super.onAggro(npc, player, isPet);
  }

  @Override
  public String onKill(L2Npc npc, L2PcInstance killer, boolean isPet) {
    if (getQuestTimer("skill", npc, null) != null) cancelQuestTimer("skill", npc, null);

    return super.onKill(npc, killer, isPet);
  }

  @Override
  public String onAttack(L2Npc npc, L2PcInstance player, int damage, boolean isPet) {
    if (player == null) return null;

    // Retrieve the attacker.
    final L2Character originalAttacker = (isPet ? player.getPet() : player);

    // Make all mobs found in a radius 2k aggressive towards attacker.
    for (L2Attackable obj : player.getKnownList().getKnownTypeInRadius(L2Attackable.class, 2000)) {
      if (obj.isDead() || obj == npc) continue;

      obj.getAI().notifyEvent(CtrlEvent.EVT_AGGRESSION, originalAttacker, 1);
    }

    return null;
  }

  @Override
  public String onSpawn(L2Npc npc) {
    if (npc instanceof L2Attackable) ((L2Attackable) npc).seeThroughSilentMove(true);

    return super.onSpawn(npc);
  }
}
Пример #17
0
 public CursedWeapon(int itemId, int skillId, String name) {
   _name = name;
   _itemId = itemId;
   _skillId = skillId;
   _skillMaxLevel = SkillTable.getInstance().getMaxLevel(_skillId);
 }