Пример #1
0
  @Override
  public String onKill(L2Npc npc, L2PcInstance killer, boolean isPet) {
    // Retrieve individual mob informations.
    final LevelingInfo npcInfo = SoulCrystalsTable.getNpcInfos().get(npc.getNpcId());
    if (npcInfo == null) return null;

    // Handle npc leveling info type.
    switch (npcInfo.getAbsorbCrystalType()) {
      case FULL_PARTY:
        final L2Attackable mob = (L2Attackable) npc;
        final int chance = Rnd.get(100);

        for (L2PcInstance player : getPartyMembersState(killer, npc, Quest.STATE_STARTED))
          tryToStageCrystal(player, mob, npcInfo, chance);
        break;

      case PARTY_ONE_RANDOM:
        final L2PcInstance player = getRandomPartyMemberState(killer, npc, Quest.STATE_STARTED);
        if (player != null) tryToStageCrystal(player, (L2Attackable) npc, npcInfo, Rnd.get(100));
        break;

      case LAST_HIT:
        if (checkPlayerState(killer, npc, Quest.STATE_STARTED) != null)
          tryToStageCrystal(killer, (L2Attackable) npc, npcInfo, Rnd.get(100));
        break;
    }

    return null;
  }
Пример #2
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);
  }
  private void rewards(QuestState st, int npcId) {
    switch (npcId) {
      case ORVEN:
        if (st.hasQuestItems(CRUCIFIX)) {
          st.set("success", "1");
          st.takeItems(CRUCIFIX, -1);

          final int chance = Rnd.get(100);
          if (chance < 80) st.giveItems(1875, 19);
          else if (chance < 95) st.giveItems(952, 5);
          else st.giveItems(2437, 1);
        }
        break;

      case GARVARENTZ:
        if (st.hasQuestItems(OLD_TOTEM)) {
          st.set("success", "1");
          st.takeItems(OLD_TOTEM, -1);

          final int chance = Rnd.get(100);
          if (chance < 55) st.giveItems(1882, 70);
          else if (chance < 99) st.giveItems(1881, 50);
          else st.giveItems(191, 1);
        }
        break;

      case KAIEN:
        if (st.hasQuestItems(OLD_HILT)) {
          st.set("success", "1");
          st.takeItems(OLD_HILT, -1);

          final int chance = Rnd.get(100);
          if (chance < 60) st.giveItems(1874, 25);
          else if (chance < 85) st.giveItems(1887, 10);
          else if (chance < 99) st.giveItems(951, 1);
          else st.giveItems(133, 1);
        }
        break;

      case RODEMAI:
        if (st.hasQuestItems(OLD_KEY)) {
          st.set("success", "1");
          st.takeItems(OLD_KEY, -1);

          final int chance = Rnd.get(100);
          if (chance < 80) st.giveItems(1879, 55);
          else if (chance < 95) st.giveItems(951, 1);
          else st.giveItems(885, 1);
        }
        break;
    }
  }
  @Override
  public String onAdvEvent(String event, L2Npc npc, L2PcInstance player) {
    String htmltext = event;
    QuestState st = player.getQuestState(qn);
    if (st == null) return htmltext;

    if (event.equalsIgnoreCase("30754-04.htm")) {
      st.setState(STATE_STARTED);
      st.set("cond", "1");
      st.playSound(QuestState.SOUND_ACCEPT);
    } else if (event.equalsIgnoreCase("30754-07.htm")) {
      if (st.get("success") != null) {
        st.set("cond", "1");
        st.unset("success");
        st.playSound(QuestState.SOUND_MIDDLE);
      }
    } else if (event.equalsIgnoreCase("30754-08.htm")) {
      st.playSound(QuestState.SOUND_FINISH);
      st.exitQuest(true);
    } else if (event.equalsIgnoreCase("30754-06.htm")) {
      if (!st.hasQuestItems(ARTICLE_DEAD_HERO)) htmltext = "30754-06a.htm";
      else {
        final int amount = st.getQuestItemsCount(ARTICLE_DEAD_HERO);

        st.takeItems(ARTICLE_DEAD_HERO, -1);
        st.giveItems(57, amount * 60);

        // Special item, % based on actual number of qItems.
        if (Rnd.get(1000) < Math.min(10, Math.max(1, amount / 10))) htmltext = "30754-10.htm";
      }
    } else if (event.equalsIgnoreCase("30754-11.htm")) {
      final int random = Rnd.get(4);
      if (random < 1) {
        htmltext = "30754-12.htm";
        st.giveItems(OLD_KEY, 1);
      } else if (random < 2) {
        htmltext = "30754-13.htm";
        st.giveItems(OLD_HILT, 1);
      } else if (random < 3) {
        htmltext = "30754-14.htm";
        st.giveItems(OLD_TOTEM, 1);
      } else st.giveItems(CRUCIFIX, 1);

      st.set("cond", "2");
      st.playSound(QuestState.SOUND_MIDDLE);
    }

    return htmltext;
  }
Пример #5
0
  @Override
  public String onKill(L2Npc npc, L2PcInstance player, boolean isPet) {
    QuestState st = checkPlayerState(player, npc, STATE_STARTED);
    if (st == null) return null;

    if (Rnd.get(100) < 50) {
      st.giveItems(WIND_SHARD, 1);
      st.playSound(QuestState.SOUND_ITEMGET);
    }

    return null;
  }
Пример #6
0
  /**
   * This method selects a random player.<br>
   * Player can't be dead and isn't an hidden GM aswell.
   *
   * @param npc to check.
   * @return the random player.
   */
  public static L2PcInstance getRandomPlayer(L2Npc npc) {
    List<L2PcInstance> result = new ArrayList<>();

    for (L2PcInstance player : npc.getKnownList().getKnownType(L2PcInstance.class)) {
      if (player.isDead()) continue;

      if (player.isGM() && player.getAppearance().getInvisible()) continue;

      result.add(player);
    }

    return (result.isEmpty()) ? null : result.get(Rnd.get(result.size()));
  }
Пример #7
0
  public void updateStatus(L2RaidBossInstance boss, boolean isBossDead) {
    if (!_storedInfo.containsKey(boss.getNpcId())) return;

    final StatsSet info = _storedInfo.get(boss.getNpcId());

    if (isBossDead) {
      boss.setRaidStatus(StatusEnum.DEAD);

      // getRespawnMinDelay() is used as fixed timer, while getRespawnMaxDelay() is used as random
      // timer.
      final int respawnDelay =
          boss.getSpawn().getRespawnMinDelay()
              + Rnd.get(
                  -boss.getSpawn().getRespawnMaxDelay(), boss.getSpawn().getRespawnMaxDelay());
      final long respawnTime = Calendar.getInstance().getTimeInMillis() + (respawnDelay * 3600000);

      info.set("currentHP", boss.getMaxHp());
      info.set("currentMP", boss.getMaxMp());
      info.set("respawnTime", respawnTime);

      if (!_schedules.containsKey(boss.getNpcId())) {
        final Calendar time = Calendar.getInstance();
        time.setTimeInMillis(respawnTime);
        _log.info(
            "RaidBoss: "
                + boss.getName()
                + " - "
                + Util.formatDate(time.getTime(), "d MMM yyyy HH:mm")
                + " ("
                + respawnDelay
                + "h).");

        _schedules.put(
            boss.getNpcId(),
            ThreadPoolManager.getInstance()
                .scheduleGeneral(new spawnSchedule(boss.getNpcId()), respawnDelay * 3600000));
        updateDb();
      }
    } else {
      boss.setRaidStatus(StatusEnum.ALIVE);

      info.set("currentHP", boss.getCurrentHp());
      info.set("currentMP", boss.getCurrentMp());
      info.set("respawnTime", 0L);
    }

    _storedInfo.put(boss.getNpcId(), info);
  }
Пример #8
0
  public boolean checkDrop(L2Attackable attackable, L2PcInstance player) {
    if (Rnd.get(1000000) < _dropRate) {
      // Drop the item.
      dropFromMob(attackable, player);

      // Start timers.
      _endTime = System.currentTimeMillis() + _duration * 3600000L;
      _overallTimerTask =
          ThreadPoolManager.getInstance()
              .scheduleGeneralAtFixedRate(new OverallTimerTask(), 60000L, 60000L);
      _dropTimerTask =
          ThreadPoolManager.getInstance().scheduleGeneral(new DropTimerTask(), 3600000L);

      return true;
    }
    return false;
  }
Пример #9
0
  public void reduceHp(
      double value, L2Character attacker, boolean awake, boolean isDOT, boolean isHPConsumption) {
    if (getActiveChar().isDead()) return;

    // invul handling
    if (getActiveChar().isInvul()) {
      // other chars can't damage
      if (attacker != getActiveChar()) return;

      // only DOT and HP consumption allowed for damage self
      if (!isDOT && !isHPConsumption) return;
    }

    if (attacker != null) {
      final L2PcInstance attackerPlayer = attacker.getActingPlayer();
      if (attackerPlayer != null
          && attackerPlayer.isGM()
          && !attackerPlayer.getAccessLevel().canGiveDamage()) return;
    }

    if (!isDOT && !isHPConsumption) {
      getActiveChar().stopEffectsOnDamage(awake);

      if (getActiveChar().isStunned() && Rnd.get(10) == 0) getActiveChar().stopStunning(true);

      if (getActiveChar().isImmobileUntilAttacked())
        getActiveChar().stopImmobileUntilAttacked(null);
    }

    if (value > 0) // Reduce Hp if any
    setCurrentHp(Math.max(getCurrentHp() - value, 0));

    // Die if character is mortal
    if (getActiveChar().getCurrentHp() < 0.5 && getActiveChar().isMortal()) {
      getActiveChar().abortAttack();
      getActiveChar().abortCast();

      getActiveChar().doDie(attacker);
    }
  }
Пример #10
0
  /**
   * Increase the number of kills.<br>
   * In case actual counter reaches the number generated to reach next stage, than rank up the CW.
   */
  public void increaseKills() {
    if (_player != null && _player.isOnline()) {
      _nbKills++;
      _hungryTime = _durationLost * 60;

      _player.setPkKills(_player.getPkKills() + 1);
      _player.sendPacket(new UserInfo(_player));

      // If current number of kills is >= to the given number, than rankUp the weapon.
      if (_nbKills >= _numberBeforeNextStage) {
        // Reset the number of kills to 0.
        _nbKills = 0;

        // Setup the new random number.
        _numberBeforeNextStage =
            Rnd.get((int) Math.round(_stageKills * 0.5), (int) Math.round(_stageKills * 1.5));

        // Rank up the CW.
        rankUp();
      }
    }
  }
Пример #11
0
 /**
  * This method checks if the CW is dropped or simply dissapears.
  *
  * @param killer : The killer of CW's owner.
  */
 public void dropIt(L2Character killer) {
   // Remove it
   if (Rnd.get(100) <= _disapearChance) endOfLife();
   // Unequip & Drop
   else dropFromPlayer(killer);
 }
Пример #12
0
  public void activate(L2PcInstance player, ItemInstance item) {
    // if the player is mounted, attempt to unmount first and pick it if successful.
    if (player.isMounted() && !player.dismount()) {
      player.sendPacket(
          SystemMessage.getSystemMessage(SystemMessageId.FAILED_TO_PICKUP_S1)
              .addItemName(item.getItemId()));
      item.setDestroyProtected(true);
      player.dropItem("InvDrop", item, null, true);
      return;
    }

    _isActivated = true;

    // Hold player data.
    _player = player;
    _playerId = _player.getObjectId();
    _playerKarma = _player.getKarma();
    _playerPkKills = _player.getPkKills();

    _item = item;

    // Generate a random number for next stage.
    _numberBeforeNextStage =
        Rnd.get((int) Math.round(_stageKills * 0.5), (int) Math.round(_stageKills * 1.5));

    // Renew hungry time.
    _hungryTime = _durationLost * 60;

    // Activate the daily timer.
    _dailyTimerTask =
        ThreadPoolManager.getInstance()
            .scheduleGeneralAtFixedRate(new DailyTimerTask(), 60000L, 60000L);

    // Cancel the "1h dropped CW" timer.
    cancelDropTimerTask();

    insertData();

    // Change player stats
    _player.setCursedWeaponEquippedId(_itemId);
    _player.setKarma(9999999);
    _player.setPkKills(0);

    if (_player.isInParty()) _player.getParty().removePartyMember(_player, MessageType.Expelled);

    // Disable active toggles
    for (L2Effect effect : _player.getAllEffects()) {
      if (effect.getSkill().isToggle()) effect.exit();
    }

    // Add CW skills
    giveDemonicSkills();

    // Equip the weapon
    _player.useEquippableItem(_item, true);

    // Fully heal player
    _player.setCurrentHpMp(_player.getMaxHp(), _player.getMaxMp());
    _player.setCurrentCp(_player.getMaxCp());

    // Refresh player stats
    _player.broadcastUserInfo();

    // _player.broadcastPacket(new SocialAction(_player, 17));
    Broadcast.toAllOnlinePlayers(
        SystemMessage.getSystemMessage(
                SystemMessageId.THE_OWNER_OF_S2_HAS_APPEARED_IN_THE_S1_REGION)
            .addZoneName(_player.getX(), _player.getY(), _player.getZ())
            .addItemName(_item.getItemId()));
  }
  public String onAdvEvent(String event, L2Npc npc, L2PcInstance player) {
    String htmltext = "";
    QuestState st = player.getQuestState(getName());

    htmltext = event;
    if (event.equalsIgnoreCase("c_grade_pin")) {
      if (st.getQuestItemsCount(13898) > 0) {
        if (st.getQuestItemsCount(57) > 3200) {
          if (Rnd.get(100) < 30) {
            st.takeItems(57, 3200);
            st.takeItems(13898, 1);
            st.giveItems(PINS_C[st.getRandom((PINS_C).length)], 1);
          } else {
            st.takeItems(57, 3200);
            st.takeItems(13898, 1);
            npc.broadcastPacket(
                new NpcSay(npc.getObjectId(), 0, npc.getNpcId(), "真是狼狽不堪啊...力氣大,果然不好控制。"));
          }
          return null;
        } else htmltext = npc.getNpcId() + "-5.htm";
      } else htmltext = npc.getNpcId() + "-4.htm";
      st.exitQuest(true);
    } else if (event.equalsIgnoreCase("b_grade_pin")) {
      if (st.getQuestItemsCount(13899) > 0) {
        if (st.getQuestItemsCount(57) > 11800) {
          if (Rnd.get(100) < 25) {
            st.takeItems(57, 11800);
            st.takeItems(13899, 1);
            st.giveItems(PINS_B[st.getRandom((PINS_B).length)], 1);
          } else {
            st.takeItems(57, 11800);
            st.takeItems(13899, 1);
            npc.broadcastPacket(
                new NpcSay(npc.getObjectId(), 0, npc.getNpcId(), "真是狼狽不堪啊...力氣大,果然不好控制。"));
          }
          return null;
        } else htmltext = npc.getNpcId() + "-5.htm";
      } else htmltext = npc.getNpcId() + "-4.htm";
      st.exitQuest(true);
    } else if (event.equalsIgnoreCase("a_grade_pin")) {
      if (st.getQuestItemsCount(13900) > 0) {
        if (st.getQuestItemsCount(57) > 26500) {
          if (Rnd.get(100) < 20) {
            st.takeItems(57, 26500);
            st.takeItems(13900, 1);
            st.giveItems(PINS_A[st.getRandom((PINS_A).length)], 1);
          } else {
            st.takeItems(57, 26500);
            st.takeItems(13900, 1);
            npc.broadcastPacket(
                new NpcSay(npc.getObjectId(), 0, npc.getNpcId(), "真是狼狽不堪啊...力氣大,果然不好控制。"));
          }
          return null;
        } else htmltext = npc.getNpcId() + "-5.htm";
      } else htmltext = npc.getNpcId() + "-4.htm";
      st.exitQuest(true);
    } else if (event.equalsIgnoreCase("s_grade_pin")) {
      if (st.getQuestItemsCount(13901) > 0) {
        if (st.getQuestItemsCount(57) > 136600) {
          if (Rnd.get(100) < 15) {
            st.takeItems(57, 136600);
            st.takeItems(13901, 1);
            st.giveItems(PINS_S[st.getRandom((PINS_S).length)], 1);
          } else {
            st.takeItems(57, 136600);
            st.takeItems(13901, 1);
            npc.broadcastPacket(
                new NpcSay(npc.getObjectId(), 0, npc.getNpcId(), "真是狼狽不堪啊...力氣大,果然不好控制。"));
          }
          return null;
        } else htmltext = npc.getNpcId() + "-5.htm";
      } else htmltext = npc.getNpcId() + "-4.htm";
      st.exitQuest(true);
    } else if (event.equalsIgnoreCase("c_grade_pouch")) {
      if (st.getQuestItemsCount(13918) > 0) {
        if (st.getQuestItemsCount(57) > 2600) {
          if (Rnd.get(100) < 30) {
            st.takeItems(57, 2600);
            st.takeItems(13918, 1);
            st.giveItems(POUCHS_C[st.getRandom((POUCHS_C).length)], 1);
          } else {
            st.takeItems(57, 2600);
            st.takeItems(13918, 1);
            npc.broadcastPacket(
                new NpcSay(npc.getObjectId(), 0, npc.getNpcId(), "真是狼狽不堪啊...力氣大,果然不好控制。"));
          }
          return null;
        } else htmltext = npc.getNpcId() + "-5.htm";
      } else htmltext = npc.getNpcId() + "-4.htm";
      st.exitQuest(true);
    } else if (event.equalsIgnoreCase("b_grade_pouch")) {
      if (st.getQuestItemsCount(13919) > 0) {
        if (st.getQuestItemsCount(57) > 9400) {
          if (Rnd.get(100) < 25) {
            st.takeItems(57, 9400);
            st.takeItems(13919, 1);
            st.giveItems(POUCHS_B[st.getRandom((POUCHS_B).length)], 1);
          } else {
            st.takeItems(57, 9400);
            st.takeItems(13919, 1);
            npc.broadcastPacket(
                new NpcSay(npc.getObjectId(), 0, npc.getNpcId(), "真是狼狽不堪啊...力氣大,果然不好控制。"));
          }
          return null;
        } else htmltext = npc.getNpcId() + "-5.htm";
      } else htmltext = npc.getNpcId() + "-4.htm";
      st.exitQuest(true);
    } else if (event.equalsIgnoreCase("a_grade_pouch")) {
      if (st.getQuestItemsCount(13920) > 0) {
        if (st.getQuestItemsCount(57) > 21200) {
          if (Rnd.get(100) < 20) {
            st.takeItems(57, 21200);
            st.takeItems(13920, 1);
            st.giveItems(POUCHS_A[st.getRandom((POUCHS_A).length)], 1);
          } else {
            st.takeItems(57, 21200);
            st.takeItems(13920, 1);
            npc.broadcastPacket(
                new NpcSay(npc.getObjectId(), 0, npc.getNpcId(), "真是狼狽不堪啊...力氣大,果然不好控制。"));
          }
          return null;
        } else htmltext = npc.getNpcId() + "-5.htm";
      } else htmltext = npc.getNpcId() + "-4.htm";
      st.exitQuest(true);
    } else if (event.equalsIgnoreCase("s_grade_pouch")) {
      if (st.getQuestItemsCount(13921) > 0) {
        if (st.getQuestItemsCount(57) > 109300) {
          if (Rnd.get(100) < 15) {
            st.takeItems(57, 109300);
            st.takeItems(13921, 1);
            st.giveItems(POUCHS_S[st.getRandom((POUCHS_S).length)], 1);
          } else {
            st.takeItems(57, 109300);
            st.takeItems(13921, 1);
            npc.broadcastPacket(
                new NpcSay(npc.getObjectId(), 0, npc.getNpcId(), "真是狼狽不堪啊...力氣大,果然不好控制。"));
          }
          return null;
        } else htmltext = npc.getNpcId() + "-5.htm";
      } else htmltext = npc.getNpcId() + "-4.htm";
      st.exitQuest(true);
    }

    return htmltext;
  }