@Override
  public String onKill(L2Npc npc, L2PcInstance killer, boolean isSummon) {
    final List<L2PcInstance> randomList = new ArrayList<>();
    final QuestState st = killer.getQuestState(getName());
    if ((st != null) && st.isStarted()) {
      randomList.add(killer);
      randomList.add(killer);
    }

    final int monsterChance = MONSTER_DROP_CHANCES.get(npc.getId());
    if (killer.isInParty()) {
      for (L2PcInstance member : killer.getParty().getMembers()) {
        final QuestState qs = member.getQuestState(getName());
        if ((qs != null) && qs.isStarted()) {
          randomList.add(member);
        }
      }
    }

    if (!randomList.isEmpty()) {
      final L2PcInstance player = randomList.get(getRandom(randomList.size()));
      if ((getRandom(1000) < monsterChance) && Util.checkIfInRange(1500, npc, player, true)) {
        giveItems(player, REMNANTS_OF_OLD_DWARVES_DREAMS, 1);
        playSound(player, QuestSound.ITEMSOUND_QUEST_ITEMGET);
      }
    }
    return super.onKill(npc, killer, isSummon);
  }
Exemple #2
0
  @Override
  public void onStart(BuffInfo info) {
    if ((info.getEffector() == null)
        || (info.getEffected() == null)
        || !info.getEffector().isPlayer()
        || !info.getEffected().isAttackable()) {
      return;
    }

    final L2PcInstance player = info.getEffector().getActingPlayer();
    final L2Attackable monster = (L2Attackable) info.getEffected();
    if (!monster.checkSpoilOwner(player, false)) {
      return;
    }

    if (!player
        .getInventory()
        .checkInventorySlotsAndWeight(monster.getSpoilLootItems(), false, false)) {
      return;
    }

    final Collection<ItemHolder> items = monster.takeSweep();
    if (items != null) {
      for (ItemHolder item : items) {
        if (player.isInParty()) {
          player.getParty().distributeItem(player, item, true, monster);
        } else {
          player.addItem("Sweeper", item, info.getEffected(), true);
        }
      }
    }
  }
  @Override
  public boolean useBypass(String command, L2PcInstance player, L2Character bypassOrigin) {
    final QuestState qs = getQuestState(player, false);
    if ((qs != null)
        || (player.getLevel() < MIN_LEVEL)
        || (player.getLevel() > MAX_LEVEL)
        || (player.getRace() == Race.ERTHEIA)
        || !command.equals("Q10390_Teleport")) {
      return false;
    }

    if (player.isInParty()) {
      player.sendPacket(
          new ExShowScreenMessage("You cannot teleport when you are in party.", 5000));
    } else if (player.isInCombat()) {
      player.sendPacket(
          new ExShowScreenMessage("You cannot teleport when you are in combat.", 5000));
    } else if (player.isInDuel()) {
      player.sendPacket(
          new ExShowScreenMessage("You cannot teleport when you are in a duel.", 5000));
    } else if (player.isInOlympiadMode()) {
      player.sendPacket(
          new ExShowScreenMessage("You cannot teleport when you are in Olympiad.", 5000));
    } else if (player.isInVehicle()) {
      player.sendPacket(
          new ExShowScreenMessage(
              "You cannot teleport when you are in any vehicle or mount.", 5000));
    } else {
      player.getAI().setIntention(CtrlIntention.AI_INTENTION_IDLE);
      player.teleToLocation(TP_LOCS[player.getRace().ordinal()]);
    }
    return true;
  }
 @Override
 public String onKill(L2Npc npc, L2PcInstance killer, boolean isSummon) {
   if (killer.isInParty()) {
     for (L2PcInstance member : killer.getParty().getMembers()) {
       giveItem(npc, member);
     }
   } else {
     giveItem(npc, killer);
   }
   return super.onKill(npc, killer, isSummon);
 }
  @Override
  public String onKill(L2Npc npc, L2PcInstance player, boolean isSummon) {
    final L2PcInstance partyMember = getRandomPartyMember(player, 1);
    if (partyMember == null) {
      return super.onKill(npc, player, isSummon);
    }
    final QuestState st = getQuestState(partyMember, false);

    switch (npc.getId()) {
      case GORGOLOS:
        {
          st.giveItems(CET_1_SHEET, 1);
          st.playSound(QuestSound.ITEMSOUND_QUEST_ITEMGET);
          break;
        }
      case LAST_TITAN_UTENUS:
        {
          st.giveItems(CET_2_SHEET, 1);
          st.playSound(QuestSound.ITEMSOUND_QUEST_ITEMGET);
          break;
        }
      case GIANT_MARPANAK:
        {
          st.giveItems(CET_3_SHEET, 1);
          st.playSound(QuestSound.ITEMSOUND_QUEST_ITEMGET);
          break;
        }
      case HEKATON_PRIME:
        {
          if (player.isInParty()) {
            for (L2PcInstance pl : player.getParty().getMembers()) {
              final QuestState qs = getQuestState(pl, false);

              if ((qs != null) && qs.isCond(1)) {
                qs.setCond(2, true);
              }
            }
            saveGlobalQuestVar(
                "Respawn", Long.toString(System.currentTimeMillis() + RESPAWN_DELAY));
          }
          break;
        }
    }
    return super.onKill(npc, player, isSummon);
  }
  @Override
  public String onFactionCall(L2Npc npc, L2Npc caller, L2PcInstance attacker, boolean isPet) {
    L2Character originalAttackTarget = (isPet ? attacker.getPet() : attacker);
    if (attacker.isInParty() && attacker.getParty().isInDimensionalRift()) {
      byte riftType = attacker.getParty().getDimensionalRift().getType();
      byte riftRoom = attacker.getParty().getDimensionalRift().getCurrentRoom();

      if (caller instanceof L2RiftInvaderInstance
          && !DimensionalRiftManager.getInstance()
              .getRoom(riftType, riftRoom)
              .checkIfInZone(npc.getX(), npc.getY(), npc.getZ())) {
        return null;
      }
    }

    // By default, when a faction member calls for help, attack the caller's attacker.
    // Notify the AI with EVT_AGGRESSION
    npc.getAI().notifyEvent(CtrlEvent.EVT_AGGRESSION, originalAttackTarget, 1);

    return null;
  }
Exemple #7
0
  @Override
  public L2Object[] getTargetList(
      Skill skill, L2Character activeChar, boolean onlyFirst, L2Character target) {
    List<L2Character> targetList = new ArrayList<>();
    if (onlyFirst) {
      return new L2Character[] {activeChar};
    }

    final L2PcInstance player = activeChar.getActingPlayer();

    if (player == null) {
      return EMPTY_TARGET_LIST;
    }

    targetList.add(player);

    final int radius = skill.getAffectRange();
    final boolean hasClan = player.getClan() != null;
    final boolean hasParty = player.isInParty();

    if (Skill.addPet(activeChar, player, radius, false)) {
      targetList.add(player.getPet());
    }

    player
        .getServitors()
        .values()
        .forEach(
            s -> {
              if (Skill.addCharacter(activeChar, s, radius, false)) {
                targetList.add(s);
              }
            });

    // if player in clan and not in party
    if (!(hasClan || hasParty)) {
      return targetList.toArray(new L2Character[targetList.size()]);
    }

    // Get all visible objects in a spherical area near the L2Character
    final Collection<L2PcInstance> objs = activeChar.getKnownList().getKnownPlayersInRadius(radius);
    int maxTargets = skill.getAffectLimit();
    for (L2PcInstance obj : objs) {
      if (obj == null) {
        continue;
      }

      // olympiad mode - adding only own side
      if (player.isInOlympiadMode()) {
        if (!obj.isInOlympiadMode()) {
          continue;
        }
        if (player.getOlympiadGameId() != obj.getOlympiadGameId()) {
          continue;
        }
        if (player.getOlympiadSide() != obj.getOlympiadSide()) {
          continue;
        }
      }

      if (player.isInDuel()) {
        if (player.getDuelId() != obj.getDuelId()) {
          continue;
        }

        if (hasParty
            && obj.isInParty()
            && (player.getParty().getLeaderObjectId() != obj.getParty().getLeaderObjectId())) {
          continue;
        }
      }

      if (!((hasClan && (obj.getClanId() == player.getClanId()))
          || (hasParty
              && obj.isInParty()
              && (player.getParty().getLeaderObjectId() == obj.getParty().getLeaderObjectId())))) {
        continue;
      }

      // Don't add this target if this is a Pc->Pc pvp
      // casting and pvp condition not met
      if (!player.checkPvpSkill(obj, skill)) {
        continue;
      }

      if (!TvTEvent.checkForTvTSkill(player, obj, skill)) {
        continue;
      }

      if (Skill.addPet(activeChar, obj, radius, false)) {
        targetList.add(obj.getPet());
      }

      obj.getServitors()
          .values()
          .forEach(
              s -> {
                if (Skill.addCharacter(activeChar, s, radius, false)) {
                  targetList.add(s);
                }
              });

      if (!Skill.addCharacter(activeChar, obj, radius, false)) {
        continue;
      }

      if ((maxTargets > 0) && (targetList.size() >= maxTargets)) {
        break;
      }

      targetList.add(obj);
    }
    return targetList.toArray(new L2Character[targetList.size()]);
  }
Exemple #8
0
  @Override
  protected void runImpl() {
    L2PcInstance activeChar = getClient().getActiveChar();
    L2PcInstance targetChar = L2World.getInstance().getPlayer(_player);
    if (activeChar == null) {
      return;
    }
    if (targetChar == null) {
      activeChar.sendPacket(
          SystemMessageId.THERE_IS_NO_OPPONENT_TO_RECEIVE_YOUR_CHALLENGE_FOR_A_DUEL);
      return;
    }
    if (activeChar == targetChar) {
      activeChar.sendPacket(
          SystemMessageId.THERE_IS_NO_OPPONENT_TO_RECEIVE_YOUR_CHALLENGE_FOR_A_DUEL);
      return;
    }

    // Check if duel is possible
    if (!activeChar.canDuel()) {
      activeChar.sendPacket(SystemMessageId.YOU_ARE_UNABLE_TO_REQUEST_A_DUEL_AT_THIS_TIME);
      return;
    } else if (!targetChar.canDuel()) {
      activeChar.sendPacket(targetChar.getNoDuelReason());
      return;
    }
    // Players may not be too far apart
    else if (!activeChar.isInsideRadius(targetChar, 250, false, false)) {
      SystemMessage msg =
          SystemMessage.getSystemMessage(
              SystemMessageId.C1_IS_TOO_FAR_AWAY_TO_RECEIVE_A_DUEL_CHALLENGE);
      msg.addString(targetChar.getName());
      activeChar.sendPacket(msg);
      return;
    } else if (Config.FACTION_SYSTEM_ENABLED
        && ((activeChar.isEvil() && targetChar.isGood())
            || (activeChar.isGood() && targetChar.isEvil()))) {
      activeChar.sendPacket(SystemMessageId.YOU_ARE_UNABLE_TO_REQUEST_A_DUEL_AT_THIS_TIME);
      return;
    }

    // Duel is a party duel
    if (_partyDuel == 1) {
      // Player must be in a party & the party leader
      if (!activeChar.isInParty() || !activeChar.getParty().isLeader(activeChar)) {
        activeChar.sendMessage(
            "You have to be the leader of a party in order to request a party duel.");
        return;
      }
      // Target must be in a party
      else if (!targetChar.isInParty()) {
        activeChar.sendPacket(
            SystemMessageId
                .SINCE_THE_PERSON_YOU_CHALLENGED_IS_NOT_CURRENTLY_IN_A_PARTY_THEY_CANNOT_DUEL_AGAINST_YOUR_PARTY);
        return;
      }
      // Target may not be of the same party
      else if (activeChar.getParty().containsPlayer(targetChar)) {
        activeChar.sendMessage("This player is a member of your own party.");
        return;
      }

      // Check if every player is ready for a duel
      for (L2PcInstance temp : activeChar.getParty().getMembers()) {
        if (!temp.canDuel()) {
          activeChar.sendMessage("Not all the members of your party are ready for a duel.");
          return;
        }
      }
      L2PcInstance partyLeader = null; // snatch party leader of targetChar's party
      for (L2PcInstance temp : targetChar.getParty().getMembers()) {
        if (partyLeader == null) {
          partyLeader = temp;
        }
        if (!temp.canDuel()) {
          activeChar.sendPacket(
              SystemMessageId
                  .THE_OPPOSING_PARTY_IS_CURRENTLY_UNABLE_TO_ACCEPT_A_CHALLENGE_TO_A_DUEL);
          return;
        }
      }

      // Send request to targetChar's party leader
      if (partyLeader != null) {
        if (!partyLeader.isProcessingRequest()) {
          activeChar.onTransactionRequest(partyLeader);
          partyLeader.sendPacket(new ExDuelAskStart(activeChar.getName(), _partyDuel));

          if (Config.DEBUG) {
            _log.fine(activeChar.getName() + " requested a duel with " + partyLeader.getName());
          }

          SystemMessage msg =
              SystemMessage.getSystemMessage(
                  SystemMessageId.C1_S_PARTY_HAS_BEEN_CHALLENGED_TO_A_DUEL);
          msg.addString(partyLeader.getName());
          activeChar.sendPacket(msg);

          msg =
              SystemMessage.getSystemMessage(
                  SystemMessageId.C1_S_PARTY_HAS_CHALLENGED_YOUR_PARTY_TO_A_DUEL);
          msg.addString(activeChar.getName());
          targetChar.sendPacket(msg);
        } else {
          SystemMessage msg =
              SystemMessage.getSystemMessage(
                  SystemMessageId.C1_IS_ON_ANOTHER_TASK_PLEASE_TRY_AGAIN_LATER);
          msg.addString(partyLeader.getName());
          activeChar.sendPacket(msg);
        }
      }
    } else
    // 1vs1 duel
    {
      if (!targetChar.isProcessingRequest()) {
        activeChar.onTransactionRequest(targetChar);
        targetChar.sendPacket(new ExDuelAskStart(activeChar.getName(), _partyDuel));

        if (Config.DEBUG) {
          _log.fine(activeChar.getName() + " requested a duel with " + targetChar.getName());
        }

        SystemMessage msg =
            SystemMessage.getSystemMessage(SystemMessageId.C1_HAS_BEEN_CHALLENGED_TO_A_DUEL);
        msg.addString(targetChar.getName());
        activeChar.sendPacket(msg);

        msg = SystemMessage.getSystemMessage(SystemMessageId.C1_HAS_CHALLENGED_YOU_TO_A_DUEL);
        msg.addString(activeChar.getName());
        targetChar.sendPacket(msg);
      } else {
        SystemMessage msg =
            SystemMessage.getSystemMessage(
                SystemMessageId.C1_IS_ON_ANOTHER_TASK_PLEASE_TRY_AGAIN_LATER);
        msg.addString(targetChar.getName());
        activeChar.sendPacket(msg);
      }
    }
  }
  public synchronized void start(L2PcInstance player, byte type, L2Npc npc) {
    boolean canPass = true;
    if (!player.isInParty()) {
      showHtmlFile(player, "data/html/seven_signs/rift/NoParty.htm", npc);
      return;
    }

    if (player.getParty().getPartyLeaderOID() != player.getObjectId()) {
      showHtmlFile(player, "data/html/seven_signs/rift/NotPartyLeader.htm", npc);
      return;
    }

    if (player.getParty().isInDimensionalRift()) {
      handleCheat(player, npc);
      return;
    }

    if (player.getParty().getMemberCount() < Config.RIFT_MIN_PARTY_SIZE) {
      NpcHtmlMessage html = new NpcHtmlMessage(npc.getObjectId());
      html.setFile(player.getHtmlPrefix(), "data/html/seven_signs/rift/SmallParty.htm");
      html.replace("%npc_name%", npc.getName());
      html.replace("%count%", Integer.toString(Config.RIFT_MIN_PARTY_SIZE));
      player.sendPacket(html);
      return;
    }

    // max parties inside is rooms count - 1
    if (!isAllowedEnter(type)) {
      player.sendMessage("Rift is full. Try later.");
      return;
    }

    for (L2PcInstance p : player.getParty().getPartyMembers())
      if (!checkIfInPeaceZone(p.getX(), p.getY(), p.getZ())) {
        canPass = false;
        break;
      }

    if (!canPass) {
      showHtmlFile(player, "data/html/seven_signs/rift/NotInWaitingRoom.htm", npc);
      return;
    }

    L2ItemInstance i;
    int count = getNeededItems(type);
    for (L2PcInstance p : player.getParty().getPartyMembers()) {
      i = p.getInventory().getItemByItemId(DIMENSIONAL_FRAGMENT_ITEM_ID);

      if (i == null) {
        canPass = false;
        break;
      }

      if (i.getCount() > 0) {
        if (i.getCount() < getNeededItems(type)) {
          canPass = false;
          break;
        }
      } else {
        canPass = false;
        break;
      }
    }

    if (!canPass) {
      NpcHtmlMessage html = new NpcHtmlMessage(npc.getObjectId());
      html.setFile(player.getHtmlPrefix(), "data/html/seven_signs/rift/NoFragments.htm");
      html.replace("%npc_name%", npc.getName());
      html.replace("%count%", Integer.toString(count));
      player.sendPacket(html);
      return;
    }

    for (L2PcInstance p : player.getParty().getPartyMembers()) {
      i = p.getInventory().getItemByItemId(DIMENSIONAL_FRAGMENT_ITEM_ID);
      if (!p.destroyItem("RiftEntrance", i, count, null, false)) {
        NpcHtmlMessage html = new NpcHtmlMessage(npc.getObjectId());
        html.setFile(player.getHtmlPrefix(), "data/html/seven_signs/rift/NoFragments.htm");
        html.replace("%npc_name%", npc.getName());
        html.replace("%count%", Integer.toString(count));
        player.sendPacket(html);
        return;
      }
    }

    byte room;
    FastList<Byte> emptyRooms;
    do {
      emptyRooms = getFreeRooms(type);
      room = emptyRooms.get(Rnd.get(1, emptyRooms.size()) - 1);
    }
    // find empty room
    while (_rooms.get(type).get(room).ispartyInside());
    new DimensionalRift(player.getParty(), type, room);
  }