@Override
  public boolean action(L2PcInstance activeChar, L2Object target, boolean interact) {
    if (activeChar.getAccessLevel().isGm()) {
      activeChar.setTarget(target);
      final L2DoorInstance door = (L2DoorInstance) target;
      activeChar.sendPacket(new StaticObject(door, activeChar.isGM()));

      final NpcHtmlMessage html = new NpcHtmlMessage();
      html.setFile(activeChar.getHtmlPrefix(), "html/admin/doorinfo.htm");
      html.replace("%class%", target.getClass().getSimpleName());
      html.replace("%hp%", String.valueOf((int) door.getCurrentHp()));
      html.replace("%hpmax%", String.valueOf(door.getMaxHp()));
      html.replace("%objid%", String.valueOf(target.getObjectId()));
      html.replace("%doorid%", String.valueOf(door.getId()));

      html.replace("%minx%", String.valueOf(door.getX(0)));
      html.replace("%miny%", String.valueOf(door.getY(0)));
      html.replace("%minz%", String.valueOf(door.getZMin()));

      html.replace("%maxx%", String.valueOf(door.getX(2)));
      html.replace("%maxy%", String.valueOf(door.getY(2)));
      html.replace("%maxz%", String.valueOf(door.getZMax()));
      html.replace(
          "%unlock%",
          door.isOpenableBySkill()
              ? "<font color=00FF00>YES<font>"
              : "<font color=FF0000>NO</font>");

      activeChar.sendPacket(html);
    }
    return true;
  }
Esempio n. 2
0
  private static void rewardTeam(TvTEventTeam team) {
    // Iterate over all participated player instances of the winning team
    for (L2PcInstance playerInstance : team.getParticipatedPlayers().values()) {
      // Check for nullpointer
      if (playerInstance == null) {
        continue;
      }

      SystemMessage systemMessage = null;

      // Iterate over all tvt event rewards
      for (int[] reward : Config.TVT_EVENT_REWARDS) {
        final PcInventory inv = playerInstance.getInventory();

        // Check for stackable item, non stackabe items need to be added one by one
        if (ItemTable.getInstance().getTemplate(reward[0]).isStackable()) {
          inv.addItem("TvT Event", reward[0], reward[1], playerInstance, playerInstance);

          if (reward[1] > 1) {
            systemMessage = SystemMessage.getSystemMessage(SystemMessageId.YOU_HAVE_EARNED_S2_S1_S);
            systemMessage.addItemName(reward[0]);
            systemMessage.addLong(reward[1]);
          } else {
            systemMessage = SystemMessage.getSystemMessage(SystemMessageId.YOU_HAVE_EARNED_S1);
            systemMessage.addItemName(reward[0]);
          }

          playerInstance.sendPacket(systemMessage);
        } else {
          for (int i = 0; i < reward[1]; ++i) {
            inv.addItem("TvT Event", reward[0], 1, playerInstance, playerInstance);
            systemMessage = SystemMessage.getSystemMessage(SystemMessageId.YOU_HAVE_EARNED_S1);
            systemMessage.addItemName(reward[0]);
            playerInstance.sendPacket(systemMessage);
          }
        }
      }

      playerInstance.sendPacket(new ExUserInfoInvenWeight(playerInstance));
      final NpcHtmlMessage npcHtmlMessage = new NpcHtmlMessage();
      npcHtmlMessage.setHtml(
          HtmCache.getInstance().getHtm(playerInstance.getHtmlPrefix(), htmlPath + "Reward.html"));
      playerInstance.sendPacket(npcHtmlMessage);
    }
  }
 @RegisterEvent(EventType.ON_PLAYER_LEVEL_CHANGED)
 @RegisterType(ListenerRegisterType.GLOBAL)
 public void OnPlayerLevelChanged(OnPlayerLevelChanged event) {
   final L2PcInstance player = event.getActiveChar();
   if ((player.getLevel() >= MIN_LEVEL)
       && (player.getLevel() <= MAX_LEVEL)
       && (player.getRace() != Race.ERTHEIA)) {
     final QuestState qs = getQuestState(player, false);
     if (qs == null) {
       final NpcHtmlMessage html = new NpcHtmlMessage(0, 0);
       html.setHtml(
           HtmCache.getInstance()
               .getHtm(
                   player.getHtmlPrefix(),
                   "scripts/quests/Q10404_KekropusLetter_AHiddenMeaning/Announce.html"));
       player.sendPacket(html);
     }
   }
 }
Esempio n. 4
0
  @Override
  public boolean useBypass(String command, L2PcInstance activeChar, L2Character target) {
    if (!(target instanceof L2WarehouseInstance)
        && !(target instanceof L2ClanHallManagerInstance)) {
      return false;
    }

    if (activeChar.hasItemRequest()) {
      return false;
    }

    if (activeChar.getClan() == null) {
      activeChar.sendPacket(SystemMessageId.YOU_DO_NOT_HAVE_THE_RIGHT_TO_USE_THE_CLAN_WAREHOUSE);
      return false;
    }

    if (activeChar.getClan().getLevel() == 0) {
      activeChar.sendPacket(
          SystemMessageId.ONLY_CLANS_OF_CLAN_LEVEL_1_OR_ABOVE_CAN_USE_A_CLAN_WAREHOUSE);
      return false;
    }

    try {
      if (command.toLowerCase().startsWith(COMMANDS[0])) // WithdrawC
      {
        if (Config.L2JMOD_ENABLE_WAREHOUSESORTING_CLAN) {
          final NpcHtmlMessage msg = new NpcHtmlMessage(((L2Npc) target).getObjectId());
          msg.setFile(activeChar.getHtmlPrefix(), "html/mods/WhSortedC.htm");
          msg.replace("%objectId%", String.valueOf(((L2Npc) target).getObjectId()));
          activeChar.sendPacket(msg);
        } else {
          showWithdrawWindow(activeChar, null, (byte) 0);
        }
        return true;
      } else if (command.toLowerCase().startsWith(COMMANDS[1])) // WithdrawSortedC
      {
        final String param[] = command.split(" ");

        if (param.length > 2) {
          showWithdrawWindow(
              activeChar,
              WarehouseListType.valueOf(param[1]),
              SortedWareHouseWithdrawalList.getOrder(param[2]));
        } else if (param.length > 1) {
          showWithdrawWindow(
              activeChar, WarehouseListType.valueOf(param[1]), SortedWareHouseWithdrawalList.A2Z);
        } else {
          showWithdrawWindow(activeChar, WarehouseListType.ALL, SortedWareHouseWithdrawalList.A2Z);
        }
        return true;
      } else if (command.toLowerCase().startsWith(COMMANDS[2])) // DepositC
      {
        activeChar.sendPacket(ActionFailed.STATIC_PACKET);
        activeChar.setActiveWarehouse(activeChar.getClan().getWarehouse());
        activeChar.setInventoryBlockingStatus(true);

        if (Config.DEBUG) {
          _log.fine(
              "Source: L2WarehouseInstance.java; Player: "
                  + activeChar.getName()
                  + "; Command: showDepositWindowClan; Message: Showing items to deposit.");
        }

        activeChar.sendPacket(new WareHouseDepositList(activeChar, WareHouseDepositList.CLAN));
        return true;
      }

      return false;
    } catch (Exception e) {
      _log.log(Level.WARNING, "Exception in " + getClass().getSimpleName(), e);
    }
    return false;
  }
Esempio n. 5
0
  private static void sendNpcDropList(
      L2PcInstance activeChar, L2Npc npc, DropListScope dropListScope, int page) {
    final List<IDropItem> dropList = npc.getTemplate().getDropList(dropListScope);
    if ((dropList == null) || dropList.isEmpty()) {
      return;
    }

    int pages = dropList.size() / DROP_LIST_ITEMS_PER_PAGE;
    if ((DROP_LIST_ITEMS_PER_PAGE * pages) < dropList.size()) {
      pages++;
    }

    final StringBuilder pagesSb = new StringBuilder();
    if (pages > 1) {
      pagesSb.append("<table><tr>");
      for (int i = 0; i < pages; i++) {
        pagesSb.append(
            "<td align=center><button value=\""
                + (i + 1)
                + "\" width=20 height=20 action=\"bypass NpcViewMod dropList "
                + dropListScope
                + " "
                + npc.getObjectId()
                + " "
                + i
                + "\" back=\"L2UI_CT1.Button_DF_Calculator_Down\" fore=\"L2UI_CT1.Button_DF_Calculator\"></td>");
      }
      pagesSb.append("</tr></table>");
    }

    if (page >= pages) {
      page = pages - 1;
    }

    final int start = page > 0 ? page * DROP_LIST_ITEMS_PER_PAGE : 0;

    int end = (page * DROP_LIST_ITEMS_PER_PAGE) + DROP_LIST_ITEMS_PER_PAGE;
    if (end > dropList.size()) {
      end = dropList.size();
    }

    final DecimalFormat amountFormat = new DecimalFormat("#,###");
    final DecimalFormat chanceFormat = new DecimalFormat("0.00##");

    int leftHeight = 0;
    int rightHeight = 0;
    final StringBuilder leftSb = new StringBuilder();
    final StringBuilder rightSb = new StringBuilder();
    for (int i = start; i < end; i++) {
      final StringBuilder sb = new StringBuilder();

      int height = 64;
      final IDropItem dropItem = dropList.get(i);
      if (dropItem instanceof GeneralDropItem) {
        addGeneralDropItem(
            activeChar, npc, amountFormat, chanceFormat, sb, (GeneralDropItem) dropItem);
      } else if (dropItem instanceof GroupedGeneralDropItem) {
        final GroupedGeneralDropItem generalGroupedDropItem = (GroupedGeneralDropItem) dropItem;
        if (generalGroupedDropItem.getItems().size() == 1) {
          final GeneralDropItem generalDropItem = generalGroupedDropItem.getItems().get(0);
          addGeneralDropItem(
              activeChar,
              npc,
              amountFormat,
              chanceFormat,
              sb,
              new GeneralDropItem(
                  generalDropItem.getItemId(),
                  generalDropItem.getMin(),
                  generalDropItem.getMax(),
                  (generalDropItem.getChance(npc, activeChar) * generalGroupedDropItem.getChance())
                      / 100,
                  generalDropItem.getAmountStrategy(),
                  generalDropItem.getChanceStrategy(),
                  generalGroupedDropItem.getPreciseStrategy(),
                  generalGroupedDropItem.getKillerChanceModifierStrategy(),
                  generalDropItem.getDropCalculationStrategy()));
        } else {
          final GroupedGeneralDropItem normalized =
              generalGroupedDropItem.normalizeMe(npc, activeChar);
          sb.append(
              "<table width=332 cellpadding=2 cellspacing=0 background=\"L2UI_CT1.Windows.Windows_DF_TooltipBG\">");
          sb.append(
              "<tr><td width=32 valign=top><img src=\"L2UI_CT1.ICON_DF_premiumItem\" width=32 height=32></td>");
          sb.append(
              "<td fixwidth=300 align=center><font name=\"ScreenMessageSmall\" color=\"CD9000\">One from group</font>");
          sb.append(
              "</td></tr><tr><td width=32></td><td width=300><table width=295 cellpadding=0 cellspacing=0><tr>");
          sb.append(
              "<td width=48 align=right valign=top><font color=\"LEVEL\">Chance:</font></td>");
          sb.append("<td width=247 align=center>");
          sb.append(chanceFormat.format(Math.min(normalized.getChance(), 100)));
          sb.append("%</td></tr></table><br>");

          for (GeneralDropItem generalDropItem : normalized.getItems()) {
            final L2Item item = ItemTable.getInstance().getTemplate(generalDropItem.getItemId());
            sb.append(
                "<table width=291 cellpadding=2 cellspacing=0 background=\"L2UI_CT1.Windows.Windows_DF_TooltipBG\">");
            sb.append("<tr><td width=32 valign=top>");
            String icon = item.getIcon();
            if (icon == null) {
              icon = "icon.etc_question_mark_i00";
            }
            sb.append("<img src=\"" + icon + "\" width=32 height=32>");
            sb.append("</td><td fixwidth=259 align=center><font name=\"hs9\" color=\"CD9000\">");
            sb.append(item.getName());
            sb.append(
                "</font></td></tr><tr><td width=32></td><td width=259><table width=253 cellpadding=0 cellspacing=0>");
            sb.append(
                "<tr><td width=48 align=right valign=top><font color=\"LEVEL\">Amount:</font></td><td width=205 align=center>");
            final MinMax minMax =
                getPreciseMinMax(
                    normalized.getChance(),
                    generalDropItem.getMin(npc, activeChar),
                    generalDropItem.getMax(npc, activeChar),
                    generalDropItem.isPreciseCalculated());
            final long min = minMax.min;
            final long max = minMax.max;
            if (min == max) {
              sb.append(amountFormat.format(min));
            } else {
              sb.append(amountFormat.format(min));
              sb.append(" - ");
              sb.append(amountFormat.format(max));
            }

            sb.append(
                "</td></tr><tr><td width=48 align=right valign=top><font color=\"LEVEL\">Chance:</font></td>");
            sb.append("<td width=205 align=center>");
            sb.append(
                chanceFormat.format(Math.min(generalDropItem.getChance(npc, activeChar), 100)));
            sb.append(
                "%</td></tr></table></td></tr><tr><td width=32></td><td width=259>&nbsp;</td></tr></table>");

            height += 64;
          }

          sb.append("</td></tr><tr><td width=32></td><td width=300>&nbsp;</td></tr></table>");
        }
      }

      if (leftHeight >= (rightHeight + height)) {
        rightSb.append(sb);
        rightHeight += height;
      } else {
        leftSb.append(sb);
        leftHeight += height;
      }
    }

    final StringBuilder bodySb = new StringBuilder();
    bodySb.append("<table><tr>");
    bodySb.append("<td>");
    bodySb.append(leftSb.toString());
    bodySb.append("</td><td>");
    bodySb.append(rightSb.toString());
    bodySb.append("</td>");
    bodySb.append("</tr></table>");

    String html =
        HtmCache.getInstance().getHtm(activeChar.getHtmlPrefix(), "html/mods/NpcView/DropList.htm");
    if (html == null) {
      _log.warning(
          NpcViewMod.class.getSimpleName()
              + ": The html file html/mods/NpcView/DropList.htm could not be found.");
      return;
    }
    html = html.replaceAll("%name%", npc.getName());
    html = html.replaceAll("%dropListButtons%", getDropListButtons(npc));
    html = html.replaceAll("%pages%", pagesSb.toString());
    html = html.replaceAll("%items%", bodySb.toString());
    Util.sendCBHtml(activeChar, html);
  }
Esempio n. 6
0
  public static void sendNpcView(L2PcInstance activeChar, L2Npc npc) {
    final NpcHtmlMessage html = new NpcHtmlMessage();
    html.setFile(activeChar.getHtmlPrefix(), "html/mods/NpcView/Info.htm");
    html.replace("%name%", npc.getName());
    html.replace(
        "%hpGauge%", HtmlUtil.getHpGauge(250, (long) npc.getCurrentHp(), npc.getMaxHp(), false));
    html.replace(
        "%mpGauge%", HtmlUtil.getMpGauge(250, (long) npc.getCurrentMp(), npc.getMaxMp(), false));

    final L2Spawn npcSpawn = npc.getSpawn();
    if ((npcSpawn == null) || (npcSpawn.getRespawnMinDelay() == 0)) {
      html.replace("%respawn%", "None");
    } else {
      TimeUnit timeUnit = TimeUnit.MILLISECONDS;
      long min = Long.MAX_VALUE;
      for (TimeUnit tu : TimeUnit.values()) {
        final long minTimeFromMillis =
            tu.convert(npcSpawn.getRespawnMinDelay(), TimeUnit.MILLISECONDS);
        final long maxTimeFromMillis =
            tu.convert(npcSpawn.getRespawnMaxDelay(), TimeUnit.MILLISECONDS);
        if ((TimeUnit.MILLISECONDS.convert(minTimeFromMillis, tu) == npcSpawn.getRespawnMinDelay())
            && (TimeUnit.MILLISECONDS.convert(maxTimeFromMillis, tu)
                == npcSpawn.getRespawnMaxDelay())) {
          if (min > minTimeFromMillis) {
            min = minTimeFromMillis;
            timeUnit = tu;
          }
        }
      }
      final long minRespawnDelay =
          timeUnit.convert(npcSpawn.getRespawnMinDelay(), TimeUnit.MILLISECONDS);
      final long maxRespawnDelay =
          timeUnit.convert(npcSpawn.getRespawnMaxDelay(), TimeUnit.MILLISECONDS);
      final String timeUnitName =
          timeUnit.name().charAt(0) + timeUnit.name().toLowerCase().substring(1);
      if (npcSpawn.hasRespawnRandom()) {
        html.replace("%respawn%", minRespawnDelay + "-" + maxRespawnDelay + " " + timeUnitName);
      } else {
        html.replace("%respawn%", minRespawnDelay + " " + timeUnitName);
      }
    }

    html.replace("%atktype%", Util.capitalizeFirst(npc.getAttackType().name().toLowerCase()));
    html.replace("%atkrange%", npc.getStat().getPhysicalAttackRange());

    html.replace("%patk%", (int) npc.getPAtk(activeChar));
    html.replace("%pdef%", (int) npc.getPDef(activeChar));

    html.replace("%matk%", (int) npc.getMAtk(activeChar, null));
    html.replace("%mdef%", (int) npc.getMDef(activeChar, null));

    html.replace("%atkspd%", npc.getPAtkSpd());
    html.replace("%castspd%", npc.getMAtkSpd());

    html.replace("%critrate%", npc.getStat().getCriticalHit(activeChar, null));
    html.replace("%evasion%", npc.getEvasionRate(activeChar));

    html.replace("%accuracy%", npc.getStat().getAccuracy());
    html.replace("%speed%", (int) npc.getStat().getMoveSpeed());

    html.replace("%attributeatktype%", Elementals.getElementName(npc.getStat().getAttackElement()));
    html.replace(
        "%attributeatkvalue%",
        npc.getStat().getAttackElementValue(npc.getStat().getAttackElement()));
    html.replace("%attributefire%", npc.getStat().getDefenseElementValue(Elementals.FIRE));
    html.replace("%attributewater%", npc.getStat().getDefenseElementValue(Elementals.WATER));
    html.replace("%attributewind%", npc.getStat().getDefenseElementValue(Elementals.WIND));
    html.replace("%attributeearth%", npc.getStat().getDefenseElementValue(Elementals.EARTH));
    html.replace("%attributedark%", npc.getStat().getDefenseElementValue(Elementals.DARK));
    html.replace("%attributeholy%", npc.getStat().getDefenseElementValue(Elementals.HOLY));

    html.replace("%dropListButtons%", getDropListButtons(npc));

    activeChar.sendPacket(html);
  }