Пример #1
0
  /**
   * This method is used to drop the CW from a monster.<br>
   * It drops the item on ground, and broadcast earthquake && red sky animations.
   *
   * @param attackable : The monster who dropped CW.
   * @param player : The player who killed the monster.
   */
  private void dropFromMob(L2Attackable attackable, L2PcInstance player) {
    _isActivated = false;

    // get position
    int x = attackable.getX() + Rnd.get(-70, 70);
    int y = attackable.getY() + Rnd.get(-70, 70);
    int z = GeoData.getInstance().getHeight(x, y, attackable.getZ());

    // create item and drop it
    _item = ItemTable.getInstance().createItem("CursedWeapon", _itemId, 1, player, attackable);
    _item.setDestroyProtected(true);
    _item.dropMe(attackable, x, y, z);

    // RedSky and Earthquake
    Broadcast.toAllOnlinePlayers(new ExRedSky(10));
    Broadcast.toAllOnlinePlayers(new Earthquake(x, y, z, 14, 3));

    _isDropped = true;

    SystemMessage sm =
        SystemMessage.getSystemMessage(SystemMessageId.S2_WAS_DROPPED_IN_THE_S1_REGION);
    sm.addZoneName(player.getX(), player.getY(), player.getZ());
    sm.addItemName(_itemId);

    Broadcast.toAllOnlinePlayers(sm);
  }
Пример #2
0
  @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;
  }
Пример #3
0
  @Override
  public String onItemUse(ItemInstance item, L2PcInstance user, L2Object target) {
    // Caster is dead.
    if (user.isDead()) return null;

    // No target, or target isn't an L2Attackable.
    if (target == null || !(target instanceof L2Attackable)) return null;

    final L2Attackable mob = ((L2Attackable) target);

    // Mob is dead or not registered in _npcInfos.
    if (mob.isDead() || !SoulCrystalsTable.getNpcInfos().containsKey(mob.getNpcId())) return null;

    // Add user to mob's absorber list.
    mob.addAbsorber(user, item);

    return null;
  }
Пример #4
0
 /**
  * Monster runs and attacks the playable.
  *
  * @param npc The npc to use.
  * @param playable The victim.
  * @param aggro The aggro to add, 999 if not given.
  */
 public static void attack(L2Attackable npc, L2Playable playable, int aggro) {
   npc.setIsRunning(true);
   npc.addDamageHate(playable, 0, (aggro <= 0) ? 999 : aggro);
   npc.getAI().setIntention(CtrlIntention.ATTACK, playable);
 }
Пример #5
0
  /**
   * Define the Soul Crystal and try to stage it. Checks for quest enabled, crystal(s) in inventory,
   * required usage of crystal, mob's ability to level crystal and mob vs player level gap.
   *
   * @param player : The player to make checks on.
   * @param mob : The mob to make checks on.
   * @param npcInfo : The mob's leveling informations.
   * @param chance : Input variable used to determine keep/stage/break of the crystal.
   * @return Returns true only, when crystal is staged or broken (aka any type of crystal change is
   *     made), else returns false.
   */
  private void tryToStageCrystal(
      L2PcInstance player, L2Attackable mob, LevelingInfo npcInfo, int chance) {
    SoulCrystalData crystalData = null;
    ItemInstance crystalItem = null;

    // Iterate through player's inventory to find crystal(s).
    for (ItemInstance item : player.getInventory().getItems()) {
      SoulCrystalData data = SoulCrystalsTable.getSoulCrystalInfos().get(item.getItemId());
      if (data == null) continue;

      // More crystals found.
      if (crystalData != null) {
        // Leveling requires soul crystal being used?
        if (npcInfo.skillRequired()) {
          // Absorb list contains killer and his AbsorbInfo is registered.
          final AbsorbInfo ai = mob.getAbsorbInfo(player.getObjectId());
          if (ai != null && ai.isRegistered())
            player.sendPacket(SystemMessageId.SOUL_CRYSTAL_ABSORBING_FAILED_RESONATION);
        } else player.sendPacket(SystemMessageId.SOUL_CRYSTAL_ABSORBING_FAILED_RESONATION);

        return;
      }

      crystalData = data;
      crystalItem = item;
    }

    // No crystal found, return without any notification.
    if (crystalData == null || crystalItem == null) return;

    // Leveling requires soul crystal being used?
    if (npcInfo.skillRequired()) {
      // Absorb list doesn't contain killer or his AbsorbInfo is not registered.
      final AbsorbInfo ai = mob.getAbsorbInfo(player.getObjectId());
      if (ai == null || !ai.isRegistered()) return;

      // Check if Absorb list contains valid crystal and whether it was used properly.
      if (!ai.isValid(crystalItem.getObjectId())) {
        player.sendPacket(SystemMessageId.SOUL_CRYSTAL_ABSORBING_REFUSED);
        return;
      }
    }

    // Check, if npc stages this type of crystal.
    if (!npcInfo.isInLevelList(crystalData.getLevel())) {
      player.sendPacket(SystemMessageId.SOUL_CRYSTAL_ABSORBING_REFUSED);
      return;
    }

    // Check level difference limitation, dark blue monsters does not stage.
    if (player.getLevel() - mob.getLevel() > 8) {
      player.sendPacket(SystemMessageId.SOUL_CRYSTAL_ABSORBING_REFUSED);
      return;
    }

    // Lucky, crystal successfully stages.
    if (chance < npcInfo.getChanceStage()) exchangeCrystal(player, crystalData, true);
    // Bad luck, crystal accidentally breaks.
    else if (chance < (npcInfo.getChanceStage() + npcInfo.getChanceBreak()))
      exchangeCrystal(player, crystalData, false);
    // Bad luck, crystal doesn't stage.
    else player.sendPacket(SystemMessageId.SOUL_CRYSTAL_ABSORBING_FAILED);
  }
Пример #6
0
  @Override
  public String onSpawn(L2Npc npc) {
    if (npc instanceof L2Attackable) ((L2Attackable) npc).seeThroughSilentMove(true);

    return super.onSpawn(npc);
  }