@Override
  public String onAdvEvent(final String event, final L2Npc npc, final L2PcInstance player) {
    String htmltext = event;
    final QuestState st = player.getQuestState(qn);
    if (st == null) return htmltext;

    if ("31377-03.htm".equalsIgnoreCase(event)) {
      if (player.getLevel() >= 74 && player.getAllianceWithVarkaKetra() <= -1) {
        st.set("cond", "1");
        st.setState(QuestState.STARTED);
        st.playSound(QuestState.SOUND_ACCEPT);
      } else {
        htmltext = "31377-02.htm";
        st.exitQuest(true);
      }
    } else if ("31377-07.htm".equalsIgnoreCase(event)) {
      if (st.getQuestItemsCount(Molar) >= 100) {
        st.takeItems(Molar, 100);
        st.giveItems(Seed, 20);
        st.playSound(QuestState.SOUND_ITEMGET);
      } else htmltext = "31377-08.htm";
    } else if ("31377-09.htm".equalsIgnoreCase(event)) {
      st.takeItems(Molar, -1);
      st.exitQuest(true);
    }

    return htmltext;
  }
  @Override
  public String onKill(final L2Npc npc, final L2PcInstance player, final boolean isPet) {
    final L2PcInstance partyMember = getRandomPartyMember(player, npc, "1");
    if (partyMember != null)
      partyMember.getQuestState(qn).dropQuestItems(HONEY_POUCH, 1, 100, 500000);

    return null;
  }
Example #3
0
 public SellListProcure(L2PcInstance player, int castleId) {
   _money = player.getAdena();
   _activeChar = player;
   _castle = castleId;
   _procureList = CastleManager.getInstance().getCastleById(_castle).getCropProcure(0);
   for (CropProcure c : _procureList) {
     L2ItemInstance item = _activeChar.getInventory().getItemByItemId(c.getId());
     if (item != null && c.getAmount() > 0) _sellList.put(item, c.getAmount());
   }
 }
 @Override
 public String onTalk(final L2Npc npc, final L2PcInstance player) {
   if (player.isSubClassActive()) return null;
   if (player.getRace().ordinal() == 3) {
     if (player.getClassId().getId() == 47) return "30513-01.htm";
     else if (player.getClassId().getId() == 45) return "30513-05.htm";
     else if (player.getClassId().getId() == 50) return "30513-09.htm";
     else if (player.getClassId().level() == 0) return "30513-33.htm";
     else if (player.getClassId().level() >= 2) return "30513-32.htm";
   } else return "30513-34.htm";
   return null;
 }
  @Override
  public String onTalk(final L2Npc npc, final L2PcInstance player) {
    final QuestState st = player.getQuestState(qn);
    String htmltext = getNoQuestMsg();
    if (st == null) return htmltext;

    switch (st.getState()) {
      case QuestState.CREATED:
        if (player.getLevel() >= 34 && player.getLevel() <= 40) htmltext = "30620-0.htm";
        else {
          htmltext = "30620-0a.htm";
          st.exitQuest(true);
        }
        break;

      case QuestState.STARTED:
        final int cond = st.getInt("cond");
        switch (npc.getNpcId()) {
          case EMILY:
            if (cond == 1) htmltext = "30620-1a.htm";
            else if (cond == 2) {
              if (st.getQuestItemsCount(HONEY_POUCH) >= 100) htmltext = "30620-2.htm";
              else {
                htmltext = "30620-2a.htm";
                st.exitQuest(true);
              }
            } else if (cond == 3) htmltext = "30620-3a.htm";
            else if (cond == 4) {
              if (st.getQuestItemsCount(AVELLAN_SPICE) >= 1) htmltext = "30620-4.htm";
              else {
                htmltext = "30620-4a.htm";
                st.exitQuest(true);
              }
            } else if (cond == 5) htmltext = "30620-5a.htm";
            else if (cond == 6) htmltext = "30620-6.htm";
            break;

          case LARA:
            if (cond == 3) htmltext = "30063-0.htm";
            else if (cond >= 4) htmltext = "30063-1a.htm";
            break;

          case BRIGHT:
            if (cond == 5) htmltext = "30466-0.htm";
            else if (cond >= 6) htmltext = "30466-1a.htm";
            break;
        }
        break;
    }

    return htmltext;
  }
Example #6
0
  public boolean endActivePetition(L2PcInstance player) {
    if (!player.isGM()) return false;

    for (Petition currPetition : getPendingPetitions().values()) {
      if (currPetition == null) continue;

      if (currPetition.getResponder() != null
          && currPetition.getResponder().getObjectId() == player.getObjectId())
        return (currPetition.endPetitionConsultation(PetitionState.Completed));
    }

    return false;
  }
Example #7
0
  public boolean cancelActivePetition(L2PcInstance player) {
    for (Petition currPetition : getPendingPetitions().values()) {
      if (currPetition.getPetitioner() != null
          && currPetition.getPetitioner().getObjectId() == player.getObjectId())
        return (currPetition.endPetitionConsultation(PetitionState.Petitioner_Cancel));

      if (currPetition.getResponder() != null
          && currPetition.getResponder().getObjectId() == player.getObjectId())
        return (currPetition.endPetitionConsultation(PetitionState.Responder_Cancel));
    }

    return false;
  }
Example #8
0
  public int submitPetition(L2PcInstance petitioner, String petitionText, int petitionType) {
    // Create a new petition instance and add it to the list of pending petitions.
    Petition newPetition = new Petition(petitioner, petitionText, petitionType);
    int newPetitionId = newPetition.getId();
    getPendingPetitions().put(newPetitionId, newPetition);

    // Notify all GMs that a new petition has been submitted.
    String msgContent =
        petitioner.getName() + " has submitted a new petition."; // (ID: " + newPetitionId + ").";
    GmListTable.broadcastToGMs(
        new CreatureSay(petitioner.getObjectId(), 17, "Petition System", msgContent));

    return newPetitionId;
  }
Example #9
0
  public void checkPetitionMessages(L2PcInstance petitioner) {
    if (petitioner != null)
      for (Petition currPetition : getPendingPetitions().values()) {
        if (currPetition == null) continue;

        if (currPetition.getPetitioner() != null
            && currPetition.getPetitioner().getObjectId() == petitioner.getObjectId()) {
          for (CreatureSay logMessage : currPetition.getLogMessages())
            petitioner.sendPacket(logMessage);

          return;
        }
      }
  }
Example #10
0
  public boolean isPlayerInConsultation(L2PcInstance player) {
    if (player != null)
      for (Petition currPetition : getPendingPetitions().values()) {
        if (currPetition == null) continue;

        if (currPetition.getState() != PetitionState.In_Process) continue;

        if ((currPetition.getPetitioner() != null
                && currPetition.getPetitioner().getObjectId() == player.getObjectId())
            || (currPetition.getResponder() != null
                && currPetition.getResponder().getObjectId() == player.getObjectId())) return true;
      }

    return false;
  }
  @Override
  public String onTalk(final L2Npc npc, final L2PcInstance player) {
    final QuestState st = player.getQuestState(qn);
    String htmltext = getNoQuestMsg();
    if (st == null) return htmltext;

    switch (st.getState()) {
      case QuestState.CREATED:
        if (player.getRace().ordinal() == 1) {
          if (player.getLevel() >= 12 && player.getLevel() <= 18) htmltext = "30154-03.htm";
          else {
            htmltext = "30154-02.htm";
            st.exitQuest(true);
          }
        } else {
          htmltext = "30154-00.htm";
          st.exitQuest(true);
        }
        break;

      case QuestState.STARTED:
        final int cond = st.getInt("cond");
        if (cond == 1) htmltext = "30154-05.htm";
        else if (cond == 2) {
          st.set("cond", "3");
          htmltext = "30154-06.htm";
          st.takeItems(PLAGUE_DUST, -1);
          st.takeItems(HYACINTH_CHARM1, -1);
          st.giveItems(HYACINTH_CHARM2, 1);
          st.playSound(QuestState.SOUND_MIDDLE);
        } else if (cond == 3) htmltext = "30154-07.htm";
        else if (cond == 4) {
          htmltext = "30154-08.htm";
          st.takeItems(PLAGUE_DUST, -1);
          st.takeItems(HYACINTH_CHARM2, -1);
          st.rewardItems(ADENA, 18250);
          st.playSound(QuestState.SOUND_FINISH);
          st.exitQuest(false);
        }
        break;

      case QuestState.COMPLETED:
        htmltext = Quest.getAlreadyCompletedMsg();
        break;
    }

    return htmltext;
  }
Example #12
0
  @Override
  public String onAdvEvent(final String event, final L2Npc npc, final L2PcInstance player) {
    final String htmltext = event;
    final QuestState st = player.getQuestState(qn);
    if (st == null) return htmltext;

    if ("30533-02.htm".equalsIgnoreCase(event)) {
      st.set("cond", "1");
      st.setState(QuestState.STARTED);
      st.playSound(QuestState.SOUND_ACCEPT);
    } else if ("30520-02.htm".equalsIgnoreCase(event)) {
      st.set("cond", "2");
      st.giveItems(VeryExpensiveNecklace, 1);
      st.playSound(QuestState.SOUND_MIDDLE);
    } else if ("30650-02.htm".equalsIgnoreCase(event)) {
      st.set("cond", "3");
      st.takeItems(VeryExpensiveNecklace, 1);
      st.playSound(QuestState.SOUND_MIDDLE);
    } else if ("30520-04.htm".equalsIgnoreCase(event)) {
      st.set("cond", "4");
      st.playSound(QuestState.SOUND_MIDDLE);
    } else if ("30533-05.htm".equalsIgnoreCase(event)) {
      st.giveItems(ScrollOfEscapeGiran, 1);
      st.rewardItems(MarkOfTraveler, 1);
      st.playSound(QuestState.SOUND_FINISH);
      st.exitQuest(false);
    }

    return htmltext;
  }
  @Override
  public String onAdvEvent(final String event, final L2Npc npc, final L2PcInstance player) {
    final String htmltext = event;
    final QuestState st = player.getQuestState(qn);
    if (st == null) return htmltext;

    if ("31517-2.htm".equalsIgnoreCase(event)) {
      st.set("cond", "1");
      st.setState(QuestState.STARTED);
      st.giveItems(CRYSTAL_OF_SEAL, 5);
      st.playSound(QuestState.SOUND_ACCEPT);
    } else if ("31512-1.htm".equalsIgnoreCase(event)) {
      st.set("cond", "2");
      st.takeItems(CRYSTAL_OF_SEAL, 1);
      st.playSound(QuestState.SOUND_MIDDLE);
    } else if ("31513-1.htm".equalsIgnoreCase(event)) {
      st.set("cond", "3");
      st.takeItems(CRYSTAL_OF_SEAL, 1);
      st.playSound(QuestState.SOUND_MIDDLE);
    } else if ("31514-1.htm".equalsIgnoreCase(event)) {
      st.set("cond", "4");
      st.takeItems(CRYSTAL_OF_SEAL, 1);
      st.playSound(QuestState.SOUND_MIDDLE);
    } else if ("31515-1.htm".equalsIgnoreCase(event)) {
      st.set("cond", "5");
      st.takeItems(CRYSTAL_OF_SEAL, 1);
      st.playSound(QuestState.SOUND_MIDDLE);
    } else if ("31516-1.htm".equalsIgnoreCase(event)) {
      st.set("cond", "6");
      st.takeItems(CRYSTAL_OF_SEAL, 1);
      st.playSound(QuestState.SOUND_MIDDLE);
    }

    return htmltext;
  }
Example #14
0
  public void viewPetition(L2PcInstance activeChar, int petitionId) {
    if (!activeChar.isGM()) return;

    if (!isValidPetition(petitionId)) return;

    Petition currPetition = getPendingPetitions().get(petitionId);
    TextBuilder htmlContent = new TextBuilder("<html><body>");
    SimpleDateFormat dateFormat = new SimpleDateFormat("EEE dd MMM HH:mm z");

    htmlContent
        .append("<center><br><font color=\"LEVEL\">Petition #")
        .append(currPetition.getId())
        .append("</font><br1>");
    htmlContent.append("<img src=\"L2UI.SquareGray\" width=\"200\" height=\"1\"></center><br>");
    htmlContent
        .append("Submit Time: ")
        .append(dateFormat.format(new Date(currPetition.getSubmitTime())))
        .append("<br1>");
    htmlContent
        .append("Petitioner: ")
        .append(currPetition.getPetitioner().getName())
        .append("<br1>");
    htmlContent
        .append("Petition Type: ")
        .append(currPetition.getTypeAsString())
        .append("<br>")
        .append(currPetition.getContent())
        .append("<br>");
    htmlContent
        .append("<center><button value=\"Accept\" action=\"bypass -h admin_accept_petition ")
        .append(currPetition.getId())
        .append("\"")
        .append("width=\"50\" height=\"15\" back=\"sek.cbui94\" fore=\"sek.cbui92\"><br1>");
    htmlContent
        .append("<button value=\"Reject\" action=\"bypass -h admin_reject_petition ")
        .append(currPetition.getId())
        .append("\" ")
        .append("width=\"50\" height=\"15\" back=\"sek.cbui94\" fore=\"sek.cbui92\"><br>");
    htmlContent.append(
        "<button value=\"Back\" action=\"bypass -h admin_view_petitions\" width=\"40\" height=\"15\" back=\"sek.cbui94\" "
            + "fore=\"sek.cbui92\"></center>");
    htmlContent.append("</body></html>");

    NpcHtmlMessage htmlMsg = new NpcHtmlMessage(0);
    htmlMsg.setHtml(htmlContent.toString());
    activeChar.sendPacket(htmlMsg);
  }
Example #15
0
  @Override
  protected void runImpl() {
    final L2PcInstance activeChar = getClient().getActiveChar();
    if (activeChar == null) return;

    // should be always 0, log it if isn't 0 for future research
    if (_bossId != 0)
      log.info("C5: RequestGetBossRecord: d: " + _bossId + " ActiveChar: " + activeChar);

    int points = RaidBossPointsManager.getInstance().getPointsByOwnerId(activeChar.getObjectId());
    int ranking = RaidBossPointsManager.getInstance().calculateRanking(activeChar.getObjectId());

    Map<Integer, Integer> list = RaidBossPointsManager.getInstance().getList(activeChar);

    // trigger packet
    activeChar.sendPacket(new ExGetBossRecord(ranking, points, list));
  }
Example #16
0
  @Override
  public boolean useAdminCommand(final String command, final L2PcInstance activeChar) {
    if (command.startsWith("admin_ride")) {
      // command disabled if CW is worn. Warn user.
      if (activeChar.isCursedWeaponEquipped()) {
        activeChar.sendChatMessage(
            0, Say2.ALL, "SYS", "You can't use //ride owning a Cursed Weapon.");
        return false;
      }

      String mount = "";
      final StringTokenizer st = new StringTokenizer(command, " ");
      st.nextToken(); // skip command

      if (st.hasMoreTokens()) {
        mount = st.nextToken();

        switch (mount) {
          case "wyvern":
          case "2":
            _petRideId = 12621;
            break;
          case "strider":
          case "1":
            _petRideId = 12526;
            break;
          default:
            activeChar.sendChatMessage(
                0, Say2.ALL, "SYS", "Parameter '" + mount + "' isn't recognized for that command.");
            return false;
        }
      } else {
        activeChar.sendChatMessage(
            0, Say2.ALL, "SYS", "You must enter a parameter for that command.");
        return false;
      }

      // If code reached that place, it means _petRideId has been filled.
      if (activeChar.isMounted()) activeChar.dismount();
      else if (activeChar.getPet() != null) activeChar.getPet().unSummon(activeChar);

      activeChar.mount(_petRideId, 0, false);
    } else if ("admin_unride".equals(command)) activeChar.dismount();

    return true;
  }
Example #17
0
  @Override
  public String onTalk(final L2Npc npc, final L2PcInstance player) {
    String htmltext = getNoQuestMsg();
    final QuestState st = player.getQuestState(qn);
    if (st == null) return htmltext;

    switch (st.getState()) {
      case QuestState.CREATED:
        htmltext =
            player.getLevel() >= 3 && player.getLevel() <= 10 && player.getRace().ordinal() == 4
                ? "30533-01.htm"
                : "30533-01a.htm";
        break;

      case QuestState.STARTED:
        final int cond = st.getInt("cond");
        switch (npc.getNpcId()) {
          case Balanki:
            if (cond >= 1 && cond <= 3) htmltext = "30533-03.htm";
            else if (cond == 4) htmltext = "30533-04.htm";
            break;

          case Reed:
            if (cond == 1) htmltext = "30520-01.htm";
            else if (cond == 2) htmltext = "30520-02a.htm";
            else if (cond == 3) htmltext = "30520-03.htm";
            else if (cond == 4) htmltext = "30520-04a.htm";
            break;

          case Gerald:
            if (cond == 2) htmltext = "30650-01.htm";
            else if (cond >= 3) htmltext = "30650-04.htm";
            break;
        }
        break;

      case QuestState.COMPLETED:
        htmltext = Quest.getAlreadyCompletedMsg();
        break;
    }

    return htmltext;
  }
Example #18
0
  public boolean isPlayerPetitionPending(L2PcInstance petitioner) {
    if (petitioner != null)
      for (Petition currPetition : getPendingPetitions().values()) {
        if (currPetition == null) continue;

        if (currPetition.getPetitioner() != null
            && currPetition.getPetitioner().getObjectId() == petitioner.getObjectId()) return true;
      }

    return false;
  }
Example #19
0
  public int getPlayerTotalPetitionCount(L2PcInstance player) {
    if (player == null) return 0;

    int petitionCount = 0;

    for (Petition currPetition : getPendingPetitions().values()) {
      if (currPetition == null) continue;

      if (currPetition.getPetitioner() != null
          && currPetition.getPetitioner().getObjectId() == player.getObjectId()) petitionCount++;
    }

    for (Petition currPetition : getCompletedPetitions().values()) {
      if (currPetition == null) continue;

      if (currPetition.getPetitioner() != null
          && currPetition.getPetitioner().getObjectId() == player.getObjectId()) petitionCount++;
    }

    return petitionCount;
  }
Example #20
0
  @Override
  public String onKill(final L2Npc npc, final L2PcInstance player, final boolean isPet) {
    final QuestState st = player.getQuestState(qn);
    if (st == null) return null;

    if (st.isStarted() && Rnd.get(10) > 4) {
      st.giveItems(npc.getNpcId() == 20385 ? ORC_AMULET : ORC_NECKLACE, 1);
      st.playSound(QuestState.SOUND_ITEMGET);
    }

    return null;
  }
Example #21
0
  public boolean sendActivePetitionMessage(L2PcInstance player, String messageText) {
    // if (!isPlayerInConsultation(player))
    // return false;

    CreatureSay cs;

    for (Petition currPetition : getPendingPetitions().values()) {
      if (currPetition == null) continue;

      if (currPetition.getPetitioner() != null
          && currPetition.getPetitioner().getObjectId() == player.getObjectId()) {
        cs =
            new CreatureSay(
                player.getObjectId(), Say2.PETITION_PLAYER, player.getName(), messageText);
        currPetition.addLogMessage(cs);

        currPetition.sendResponderPacket(cs);
        currPetition.sendPetitionerPacket(cs);
        return true;
      }

      if (currPetition.getResponder() != null
          && currPetition.getResponder().getObjectId() == player.getObjectId()) {
        cs = new CreatureSay(player.getObjectId(), Say2.PETITION_GM, player.getName(), messageText);
        currPetition.addLogMessage(cs);

        currPetition.sendResponderPacket(cs);
        currPetition.sendPetitionerPacket(cs);
        return true;
      }
    }

    return false;
  }
  @Override
  public String onTalk(final L2Npc npc, final L2PcInstance player) {
    final QuestState st = player.getQuestState(qn);
    String htmltext = getNoQuestMsg();
    if (st == null) return htmltext;

    switch (st.getState()) {
      case QuestState.CREATED:
        if (player.getRace().ordinal() == 2) {
          htmltext = "30147-00.htm";
          st.exitQuest(true);
        } else if (player.getLevel() >= 12 && player.getLevel() <= 21) htmltext = "30147-02.htm";
        else {
          htmltext = "30147-01.htm";
          st.exitQuest(true);
        }
        break;

      case QuestState.STARTED:
        final int cond = st.getInt("cond");
        if (cond == 1) htmltext = "30147-05.htm";
        else if (cond == 2
            && st.getQuestItemsCount(ELF_SKULL) >= 3
            && st.getQuestItemsCount(BONE_FRAGMENT) >= 10) {
          htmltext = "30147-06.htm";
          st.takeItems(ELF_SKULL, -1);
          st.takeItems(BONE_FRAGMENT, -1);
          st.rewardItems(ADENA, 24000);
          st.giveItems(BONE_SHIELD, 1);
          st.exitQuest(false);
          st.playSound(QuestState.SOUND_FINISH);
        }
        break;

      case QuestState.COMPLETED:
        htmltext = Quest.getAlreadyCompletedMsg();
        break;
    }
    return htmltext;
  }
Example #23
0
  @Override
  public void useSkill(L2Character activeChar, L2Object[] targets) {
    if (activeChar instanceof L2PcInstance) {
      // Thanks nbd
      if (!TvTEvent.onEscapeUse(((L2PcInstance) activeChar).getObjectId())) {
        activeChar.sendPacket(ActionFailed.STATIC_PACKET);
        return;
      }
      // Check invalid states.
      if (activeChar.isAfraid()
          || ((L2PcInstance) activeChar).isInOlympiadMode()
          || (GrandBossManager.getInstance().getZone(activeChar) != null && !activeChar.isGM()))
        return;
    }

    for (L2Character target : (L2Character[]) targets) {
      if (target == null) return;

      if (target instanceof L2PcInstance) {
        L2PcInstance targetChar = (L2PcInstance) target;

        // Check invalid states.
        if (targetChar.isFestivalParticipant() || targetChar.isInJail() || targetChar.isInDuel())
          continue;

        if (targetChar != activeChar) {
          if (targetChar.isInOlympiadMode()) continue;

          if (GrandBossManager.getInstance().getZone(targetChar) != null) continue;
        }
      }

      Location loc = null;
      if (getSkillType() == L2SkillType.TELEPORT) {
        if (_loc != null) {
          if (!(target instanceof L2PcInstance) || !target.isFlying()) loc = _loc;
        }
      } else {
        if (_recallType.equalsIgnoreCase("Castle"))
          loc =
              MapRegionData.getInstance()
                  .getTeleToLocation(target, MapRegionData.TeleportWhereType.Castle);
        else if (_recallType.equalsIgnoreCase("ClanHall"))
          loc =
              MapRegionData.getInstance()
                  .getTeleToLocation(target, MapRegionData.TeleportWhereType.ClanHall);
        else
          loc =
              MapRegionData.getInstance()
                  .getTeleToLocation(target, MapRegionData.TeleportWhereType.Town);
      }

      if (loc != null) {
        if (target instanceof L2PcInstance) ((L2PcInstance) target).setIsIn7sDungeon(false);

        target.teleToLocation(loc, true);
      }
    }
  }
  @Override
  public String onKill(final L2Npc npc, final L2PcInstance player, final boolean isPet) {
    final QuestState st = player.getQuestState(qn);
    if (st == null) return null;

    if (st.getInt("cond") == 7 && Rnd.get(10) < 2) {
      st.set("cond", "8");
      st.giveItems(GREY_STAR, 1);
      st.playSound(QuestState.SOUND_ITEMGET);
    }

    return null;
  }
  @Override
  protected void runImpl() {
    final L2PcInstance activeChar = getClient().getActiveChar();
    if (activeChar == null) return;

    final L2PcInstance requestor = activeChar.getActiveRequester();
    if (requestor == null) return;

    if (_answer == 1)
      ClanTable.getInstance().deleteclanswars(requestor.getClanId(), activeChar.getClanId());
    else requestor.sendPacket(SystemMessageId.REQUEST_TO_END_WAR_HAS_BEEN_DENIED);

    activeChar.setActiveRequester(null);
    requestor.onTransactionResponse();
  }
Example #26
0
  /**
   * Add a L2Object in the world.<br>
   * <br>
   * <B><U> Concept</U> :</B><br>
   * <br>
   * L2Object (including L2PcInstance) are identified in <B>_visibleObjects</B> of his current
   * L2WorldRegion and in <B>_knownObjects</B> of other surrounding L2Characters <br>
   * L2PcInstance are identified in <B>_allPlayers</B> of L2World, in <B>_allPlayers</B> of his
   * current L2WorldRegion and in <B>_knownPlayer</B> of other surrounding L2Characters <br>
   * <br>
   * <B><U> Actions</U> :</B><br>
   * <br>
   * <li>Add the L2Object object in _allPlayers* of L2World
   * <li>Add the L2Object object in _gmList** of GmListTable
   * <li>Add object in _knownObjects and _knownPlayer* of all surrounding L2WorldRegion L2Characters
   *     <br>
   * <li>If object is a L2Character, add all surrounding L2Object in its _knownObjects and all
   *     surrounding L2PcInstance in its _knownPlayer <br>
   *     <I>* only if object is a L2PcInstance</I><br>
   *     <I>** only if object is a GM L2PcInstance</I><br>
   *     <br>
   *     <FONT COLOR=#FF0000><B> <U>Caution</U> : This method DOESN'T ADD the object in
   *     _visibleObjects and _allPlayers* of L2WorldRegion (need synchronisation)</B></FONT><br>
   *     <FONT COLOR=#FF0000><B> <U>Caution</U> : This method DOESN'T ADD the object to _allObjects
   *     and _allPlayers* of L2World (need synchronisation)</B></FONT><br>
   *     <br>
   *     <B><U> Example of use </U> :</B><br>
   *     <br>
   * <li>Drop an Item
   * <li>Spawn a L2Character
   * <li>Apply Death Penalty of a L2PcInstance<br>
   *     <br>
   *
   * @param object L2object to add in the world
   * @param newRegion L2WorldRegion in wich the object will be add (not used)
   */
  public void addVisibleObject(L2Object object, L2WorldRegion newRegion) {
    // If selected L2Object is a L2PcIntance, add it in L2ObjectHashSet(L2PcInstance) _allPlayers of
    // L2World
    // XXX TODO: this code should be obsoleted by protection in putObject func...
    if (object instanceof L2PcInstance) {
      L2PcInstance player = (L2PcInstance) object;

      if (!player.isTeleporting()) {
        L2PcInstance tmp = _allPlayers.get(Integer.valueOf(player.getObjectId()));
        if (tmp != null) {
          _log.warn("Duplicate character!? Closing both characters (" + player.getName() + ")");
          player.logout();
          tmp.logout();
          return;
        }
        _allPlayers.put(player.getObjectId(), player);
      }
    }

    if (!newRegion.isActive()) return;

    // Get all visible objects contained in the _visibleObjects of
    // L2WorldRegions in a circular area of 2000 units
    List<L2Object> visibles = getVisibleObjects(object, 2000);

    _log.trace("objects in range:" + visibles.size());

    // tell the player about the surroundings
    // Go through the visible objects contained in the circular area
    for (L2Object visible : visibles) {
      // Add the object in L2ObjectHashSet(L2Object) _knownObjects of the visible L2Character
      // according to conditions :
      // - L2Character is visible
      // - object is not already known
      // - object is in the watch distance
      // If L2Object is a L2PcInstance, add L2Object in L2ObjectHashSet(L2PcInstance) _knownPlayer
      // of the visible
      // L2Character
      visible.getKnownList().addKnownObject(object);

      // Add the visible L2Object in L2ObjectHashSet(L2Object) _knownObjects of the object according
      // to conditions
      // If visible L2Object is a L2PcInstance, add visible L2Object in
      // L2ObjectHashSet(L2PcInstance) _knownPlayer of the
      // object
      object.getKnownList().addKnownObject(visible);
    }
  }
  @Override
  public String onAdvEvent(final String event, final L2Npc npc, final L2PcInstance player) {
    final String htmltext = event;
    final QuestState st = player.getQuestState(qn);
    if (st == null) return htmltext;

    if ("30147-04.htm".equalsIgnoreCase(event)) {
      st.set("cond", "1");
      st.setState(QuestState.STARTED);
      st.playSound(QuestState.SOUND_ACCEPT);
    }

    return htmltext;
  }
Example #28
0
  @Override
  public String onTalk(final L2Npc npc, final L2PcInstance player) {
    String htmltext = Quest.getNoQuestMsg();
    final QuestState st = player.getQuestState(qn);
    if (st == null) return htmltext;

    switch (st.getState()) {
      case QuestState.CREATED:
        if (player.getRace().ordinal() == 2) {
          if (player.getLevel() >= 8 && player.getLevel() <= 16) htmltext = "30346-02.htm";
          else {
            htmltext = "30346-01.htm";
            st.exitQuest(true);
          }
        } else {
          htmltext = "30346-00.htm";
          st.exitQuest(true);
        }
        break;

      case QuestState.STARTED:
        final int amulet = st.getQuestItemsCount(ORC_AMULET);
        final int necklace = st.getQuestItemsCount(ORC_NECKLACE);

        if (amulet == 0 && necklace == 0) htmltext = "30346-04.htm";
        else {
          htmltext = "30346-05.htm";
          st.rewardItems(57, amulet * 20 + necklace * 30);
          st.takeItems(ORC_AMULET, -1);
          st.takeItems(ORC_NECKLACE, -1);
        }
        break;
    }

    return htmltext;
  }
  @Override
  public String onAdvEvent(final String event, final L2Npc npc, final L2PcInstance player) {
    final String htmltext = event;
    final QuestState st = player.getQuestState(qn);
    if (st == null) return htmltext;

    if ("32053-02.htm".equalsIgnoreCase(event)) {
      st.set("cond", "1");
      st.setState(QuestState.STARTED);
      st.playSound(QuestState.SOUND_ACCEPT);
    } else if ("32055-02.htm".equalsIgnoreCase(event)) {
      st.set("cond", "2");
      st.playSound(QuestState.SOUND_MIDDLE);
    } else if ("32052-02.htm".equalsIgnoreCase(event)) {
      st.set("cond", "3");
      st.playSound(QuestState.SOUND_MIDDLE);
    } else if ("32053-04.htm".equalsIgnoreCase(event)) {
      st.set("cond", "4");
      st.playSound(QuestState.SOUND_MIDDLE);
    } else if ("32076-02.htm".equalsIgnoreCase(event)) {
      st.set("cond", "5");
      st.giveItems(ENGRAVED_HAMMER, 1);
      st.playSound(QuestState.SOUND_MIDDLE);
    } else if ("32053-06.htm".equalsIgnoreCase(event)
        && st.getQuestItemsCount(ENGRAVED_HAMMER) == 1) {
      st.set("cond", "6");
      st.playSound(QuestState.SOUND_MIDDLE);
    } else if ("32052-04.htm".equalsIgnoreCase(event)
        && st.getQuestItemsCount(ENGRAVED_HAMMER) == 1) {
      st.set("cond", "7");
      st.playSound(QuestState.SOUND_MIDDLE);
    } else if ("32052-06.htm".equalsIgnoreCase(event) && st.getQuestItemsCount(GREY_STAR) == 1) {
      st.set("cond", "9");
      st.takeItems(GREY_STAR, 1);
      st.playSound(QuestState.SOUND_MIDDLE);
    } else if ("32055-04.htm".equalsIgnoreCase(event)
        && st.getQuestItemsCount(ENGRAVED_HAMMER) == 1) {
      st.set("cond", "10");
      st.takeItems(ENGRAVED_HAMMER, 1);
      st.playSound(QuestState.SOUND_MIDDLE);
    } else if ("32054-03.htm".equalsIgnoreCase(event)) {
      st.addExpAndSp(63591, 0);
      st.playSound(QuestState.SOUND_FINISH);
      st.exitQuest(false);
    }

    return htmltext;
  }
Example #30
0
  public void sendPendingPetitionList(L2PcInstance activeChar) {
    TextBuilder htmlContent =
        new TextBuilder(
            "<html><body>"
                + "<center><font color=\"LEVEL\">Current Petitions</font><br><table width=\"300\">");
    SimpleDateFormat dateFormat = new SimpleDateFormat("dd MMM HH:mm z");

    if (getPendingPetitionCount() == 0)
      htmlContent.append(
          "<tr><td colspan=\"4\">There are no currently pending petitions.</td></tr>");
    else
      htmlContent.append(
          "<tr><td></td><td><font color=\"999999\">Petitioner</font></td>"
              + "<td><font color=\"999999\">Petition Type</font></td><td><font color=\"999999\">Submitted</font></td></tr>");

    for (Petition currPetition : getPendingPetitions().values()) {
      if (currPetition == null) continue;

      htmlContent.append("<tr><td>");

      if (currPetition.getState() != PetitionState.In_Process)
        htmlContent
            .append("<button value=\"View\" action=\"bypass -h admin_view_petition ")
            .append(currPetition.getId())
            .append("\" ")
            .append("width=\"40\" height=\"15\" back=\"sek.cbui94\" fore=\"sek.cbui92\">");
      else htmlContent.append("<font color=\"999999\">In Process</font>");

      htmlContent
          .append("</td><td>")
          .append(currPetition.getPetitioner().getName())
          .append("</td><td>")
          .append(currPetition.getTypeAsString())
          .append("</td><td>")
          .append(dateFormat.format(new Date(currPetition.getSubmitTime())))
          .append("</td></tr>");
    }

    htmlContent.append(
        "</table><br><button value=\"Refresh\" action=\"bypass -h admin_view_petitions\" width=\"50\" "
            + "height=\"15\" back=\"sek.cbui94\" fore=\"sek.cbui92\"><br><button value=\"Back\" action=\"bypass -h admin_admin\" "
            + "width=\"40\" height=\"15\" back=\"sek.cbui94\" fore=\"sek.cbui92\"></center></body></html>");

    NpcHtmlMessage htmlMsg = new NpcHtmlMessage(0);
    htmlMsg.setHtml(htmlContent.toString());
    activeChar.sendPacket(htmlMsg);
  }