@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;
  }
  @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)) {
      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(TELE_LOCATION);
    }
    return true;
  }
  @Override
  protected void runImpl() {
    final L2PcInstance activeChar = getClient().getActiveChar();
    if (activeChar == null) {
      return;
    }

    final EnchantItemRequest request = activeChar.getRequest(EnchantItemRequest.class);
    if ((request == null) || request.isProcessing()) {
      return;
    }

    request.setEnchantingItem(_objectId);

    final L2ItemInstance item = request.getEnchantingItem();
    final L2ItemInstance scroll = request.getEnchantingScroll();
    if ((item == null) || (scroll == null)) {
      return;
    }

    final EnchantScroll scrollTemplate = EnchantItemData.getInstance().getEnchantScroll(scroll);
    if ((scrollTemplate == null) || !scrollTemplate.isValid(item, null)) {
      activeChar.sendPacket(SystemMessageId.DOES_NOT_FIT_STRENGTHENING_CONDITIONS_OF_THE_SCROLL);
      activeChar.removeRequest(request.getClass());
      activeChar.sendPacket(new ExPutEnchantTargetItemResult(0));
      if (scrollTemplate == null) {
        _log.log(
            Level.WARNING,
            getClass().getSimpleName() + ": Undefined scroll have been used id: " + scroll.getId());
      }
      return;
    }
    request.setTimestamp(System.currentTimeMillis());
    activeChar.sendPacket(new ExPutEnchantTargetItemResult(_objectId));
  }
Beispiel #4
0
  @Override
  public final boolean useBypass(String command, L2PcInstance activeChar, L2Character target) {
    try {
      final L2Npc olymanager = activeChar.getLastFolkNPC();

      if (command.startsWith(COMMANDS[0])) // list
      {
        if (!Olympiad.getInstance().inCompPeriod()) {
          activeChar.sendPacket(SystemMessageId.THE_OLYMPIAD_GAMES_ARE_NOT_CURRENTLY_IN_PROGRESS);
          return false;
        }

        activeChar.sendPacket(new ExOlympiadMatchList());
      } else {
        if ((olymanager == null) || !(olymanager instanceof L2OlympiadManagerInstance)) {
          return false;
        }

        if (!activeChar.inObserverMode()
            && !activeChar.isInsideRadius(olymanager, 300, false, false)) {
          return false;
        }

        if (OlympiadManager.getInstance().isRegisteredInComp(activeChar)) {
          activeChar.sendPacket(
              SystemMessageId
                  .YOU_MAY_NOT_OBSERVE_A_OLYMPIAD_GAMES_MATCH_WHILE_YOU_ARE_ON_THE_WAITING_LIST);
          return false;
        }

        if (!Olympiad.getInstance().inCompPeriod()) {
          activeChar.sendPacket(SystemMessageId.THE_OLYMPIAD_GAMES_ARE_NOT_CURRENTLY_IN_PROGRESS);
          return false;
        }

        if (activeChar.isOnEvent()) {
          activeChar.sendMessage("You can not observe games while registered on an event");
          return false;
        }

        final int arenaId = Integer.parseInt(command.substring(12).trim());
        final OlympiadGameTask nextArena =
            OlympiadGameManager.getInstance().getOlympiadTask(arenaId);
        if (nextArena != null) {
          activeChar.enterOlympiadObserverMode(
              nextArena.getZone().getSpectatorSpawns().get(0), arenaId);
          activeChar.setInstanceId(
              OlympiadGameManager.getInstance().getOlympiadTask(arenaId).getZone().getInstanceId());
        }
      }
      return true;
    } catch (Exception e) {
      _log.log(Level.WARNING, "Exception in " + getClass().getSimpleName(), e);
    }
    return false;
  }
Beispiel #5
0
  /**
   * Is called when a player is killed<br>
   * <br>
   *
   * @param killerCharacter as L2Character<br>
   * @param killedPlayerInstance as L2PcInstance<br>
   */
  public static void onKill(L2Character killerCharacter, L2PcInstance killedPlayerInstance) {
    if ((killedPlayerInstance == null) || !isStarted()) {
      return;
    }

    final byte killedTeamId = getParticipantTeamId(killedPlayerInstance.getObjectId());

    if (killedTeamId == -1) {
      return;
    }

    new TvTEventTeleporter(
        killedPlayerInstance, _teams[killedTeamId].getCoordinates(), false, false);

    if (killerCharacter == null) {
      return;
    }

    L2PcInstance killerPlayerInstance = null;

    if ((killerCharacter instanceof L2PetInstance)
        || (killerCharacter instanceof L2ServitorInstance)) {
      killerPlayerInstance = ((L2Summon) killerCharacter).getOwner();

      if (killerPlayerInstance == null) {
        return;
      }
    } else if (killerCharacter instanceof L2PcInstance) {
      killerPlayerInstance = (L2PcInstance) killerCharacter;
    } else {
      return;
    }

    final byte killerTeamId = getParticipantTeamId(killerPlayerInstance.getObjectId());

    if ((killerTeamId != -1) && (killedTeamId != -1) && (killerTeamId != killedTeamId)) {
      final TvTEventTeam killerTeam = _teams[killerTeamId];

      killerTeam.increasePoints();

      final CreatureSay cs =
          new CreatureSay(
              killerPlayerInstance.getObjectId(),
              ChatType.WHISPER,
              killerPlayerInstance.getName(),
              "I have killed " + killedPlayerInstance.getName() + "!");

      for (L2PcInstance playerInstance : _teams[killerTeamId].getParticipatedPlayers().values()) {
        if (playerInstance != null) {
          playerInstance.sendPacket(cs);
        }
      }

      // Notify to scripts.
      EventDispatcher.getInstance()
          .notifyEventAsync(
              new OnTvTEventKill(killerPlayerInstance, killedPlayerInstance, killerTeam));
    }
  }
Beispiel #6
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);
    }
  }
Beispiel #7
0
  @Override
  public boolean useBypass(String command, L2PcInstance activeChar, L2Character target) {
    if (!target.isNpc()) {
      return false;
    }

    activeChar.sendPacket(new ExShowBaseAttributeCancelWindow(activeChar));
    return true;
  }
Beispiel #8
0
 private static final String checkConditions(L2Npc npc, L2PcInstance player) {
   final L2Party party = player.getParty();
   // player must be in party
   if (party == null) {
     player.sendPacket(SystemMessageId.YOU_ARE_NOT_CURRENTLY_IN_A_PARTY_SO_YOU_CANNOT_ENTER);
     return "32330-05.html";
   }
   // ...and be party leader
   if (party.getLeader() != player) {
     player.sendPacket(SystemMessageId.ONLY_A_PARTY_LEADER_CAN_MAKE_THE_REQUEST_TO_ENTER);
     return "32330-08.html";
   }
   boolean _kamael = false;
   // for each party member
   for (L2PcInstance partyMember : party.getMembers()) {
     // player level must be in range
     if (partyMember.getLevel() > INSTANCE_LVL_MAX) {
       final SystemMessage sm =
           SystemMessage.getSystemMessage(
               SystemMessageId.C1_S_LEVEL_DOES_NOT_CORRESPOND_TO_THE_REQUIREMENTS_FOR_ENTRY);
       sm.addPcName(partyMember);
       player.sendPacket(sm);
       return "32330-06.html";
     }
     if (partyMember.getLevel() < INSTANCE_LVL_MIN) {
       final SystemMessage sm =
           SystemMessage.getSystemMessage(
               SystemMessageId.C1_S_LEVEL_DOES_NOT_CORRESPOND_TO_THE_REQUIREMENTS_FOR_ENTRY);
       sm.addPcName(partyMember);
       player.sendPacket(sm);
       return "32330-07.html";
     }
     if (partyMember.getClassId().level() != 0) {
       final SystemMessage sm =
           SystemMessage.getSystemMessage(
               SystemMessageId.C1_S_LEVEL_DOES_NOT_CORRESPOND_TO_THE_REQUIREMENTS_FOR_ENTRY);
       sm.addPcName(partyMember);
       player.sendPacket(sm);
       return "32330-06.html";
     }
     // player must be near party leader
     if (!partyMember.isInsideRadius(player, 500, true, true)) {
       final SystemMessage sm =
           SystemMessage.getSystemMessage(
               SystemMessageId
                   .C1_IS_IN_A_LOCATION_WHICH_CANNOT_BE_ENTERED_THEREFORE_IT_CANNOT_BE_PROCESSED);
       sm.addPcName(partyMember);
       player.sendPacket(sm);
       return "32330-08.html";
     }
     if (partyMember.getRace().ordinal() == 5) {
       _kamael = true;
     }
   }
   if (!_kamael) {
     return "32330-08.html";
   }
   return "ok";
 }
Beispiel #9
0
  @Override
  public boolean useBypass(String command, L2PcInstance activeChar, L2Character target) {
    if (!target.isNpc()) {
      return false;
    }

    try {
      switch (Integer.parseInt(command.substring(8, 9).trim())) {
        case 1:
          {
            activeChar.sendPacket(ExShowVariationMakeWindow.STATIC_PACKET);
            return true;
          }
        case 2:
          {
            activeChar.sendPacket(ExShowVariationCancelWindow.STATIC_PACKET);
            return true;
          }
      }
    } catch (Exception e) {
      _log.log(Level.WARNING, "Exception in " + getClass().getSimpleName(), e);
    }
    return false;
  }
Beispiel #10
0
  private static final void showWithdrawWindow(
      L2PcInstance player, WarehouseListType itemtype, byte sortorder) {
    player.sendPacket(ActionFailed.STATIC_PACKET);

    if (!player.hasClanPrivilege(ClanPrivilege.CL_VIEW_WAREHOUSE)) {
      player.sendPacket(SystemMessageId.YOU_DO_NOT_HAVE_THE_RIGHT_TO_USE_THE_CLAN_WAREHOUSE);
      return;
    }

    player.setActiveWarehouse(player.getClan().getWarehouse());

    if (player.getActiveWarehouse().getSize() == 0) {
      player.sendPacket(SystemMessageId.YOU_HAVE_NOT_DEPOSITED_ANY_ITEMS_IN_YOUR_WAREHOUSE);
      return;
    }

    for (L2ItemInstance i : player.getActiveWarehouse().getItems()) {
      if (i.isTimeLimitedItem() && (i.getRemainingTime() <= 0)) {
        player.getActiveWarehouse().destroyItem("L2ItemInstance", i, player, null);
      }
    }
    if (itemtype != null) {
      player.sendPacket(
          new SortedWareHouseWithdrawalList(
              player, WareHouseWithdrawalList.CLAN, itemtype, sortorder));
    } else {
      player.sendPacket(new WareHouseWithdrawalList(player, WareHouseWithdrawalList.CLAN));
    }

    if (Config.DEBUG) {
      _log.fine(
          "Source: L2WarehouseInstance.java; Player: "
              + player.getName()
              + "; Command: showRetrieveWindowClan; Message: Showing stored items.");
    }
  }
  @Override
  public String onAdvEvent(String event, L2Npc npc, L2PcInstance player) {
    final QuestState qs = getQuestState(player, false);
    if (qs == null) {
      return null;
    }

    String htmltext = null;
    switch (event) {
      case "32975-03.htm":
        {
          qs.startQuest();
          qs.setCond(2); // show arrow hack
          qs.setCond(1);
          player.sendPacket(
              new TutorialShowHtml(
                  npc.getObjectId(),
                  "..\\L2Text\\QT_027_Quest_01.htm",
                  TutorialShowHtml.LARGE_WINDOW));
          htmltext = event;
          break;
        }
      case "32975-02.htm":
        {
          htmltext = event;
          break;
        }
      case "32974-02.html":
        {
          giveAdena(player, 50, true);
          addExpAndSp(player, 40, 5);
          qs.exitQuest(false, true);
          Broadcast.toKnownPlayers(
              npc,
              new NpcSay(
                  npc.getObjectId(),
                  ChatType.NPC_GENERAL,
                  npc.getTemplate().getDisplayId(),
                  NpcStringId.HM_DON_T_JUST_GO_I_STILL_HAVE_TONS_TO_TEACH_YOU));
          htmltext = event;
          break;
        }
    }
    return htmltext;
  }
Beispiel #12
0
  @Override
  public void run() {
    if (_player != null) {
      double reduceHp = _player.getMaxHp() / 100.0;

      if (reduceHp < 1) {
        reduceHp = 1;
      }

      _player.reduceCurrentHp(reduceHp, _player, false, false, null);
      // reduced hp, becouse not rest
      final SystemMessage sm =
          SystemMessage.getSystemMessage(
              SystemMessageId.YOU_HAVE_TAKEN_S1_DAMAGE_BECAUSE_YOU_WERE_UNABLE_TO_BREATHE);
      sm.addInt((int) reduceHp);
      _player.sendPacket(sm);
    }
  }
 @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);
     }
   }
 }
Beispiel #14
0
  @Override
  public boolean useBypass(String command, L2PcInstance activeChar, L2Character target) {
    if (!(target instanceof L2MerchantInstance)) {
      return false;
    }

    if (!Config.ALLOW_RENTPET) {
      return false;
    }

    if (!Config.LIST_PET_RENT_NPC.contains(target.getId())) {
      return false;
    }

    try {
      final StringTokenizer st = new StringTokenizer(command, " ");
      st.nextToken();

      if (st.countTokens() < 1) {
        final NpcHtmlMessage msg = new NpcHtmlMessage(((L2Npc) target).getObjectId());
        msg.setHtml(
            "<html><body>Pet Manager:<br>"
                + "You can rent a wyvern or strider for adena.<br>My prices:<br1>"
                + "<table border=0><tr><td>Ride</td></tr>"
                + "<tr><td>Wyvern</td><td>Strider</td></tr>"
                + "<tr><td><a action=\"bypass -h npc_%objectId%_RentPet 1\">30 sec/1800 adena</a></td><td><a action=\"bypass -h npc_%objectId%_RentPet 11\">30 sec/900 adena</a></td></tr>"
                + "<tr><td><a action=\"bypass -h npc_%objectId%_RentPet 2\">1 min/7200 adena</a></td><td><a action=\"bypass -h npc_%objectId%_RentPet 12\">1 min/3600 adena</a></td></tr>"
                + "<tr><td><a action=\"bypass -h npc_%objectId%_RentPet 3\">10 min/720000 adena</a></td><td><a action=\"bypass -h npc_%objectId%_RentPet 13\">10 min/360000 adena</a></td></tr>"
                + "<tr><td><a action=\"bypass -h npc_%objectId%_RentPet 4\">30 min/6480000 adena</a></td><td><a action=\"bypass -h npc_%objectId%_RentPet 14\">30 min/3240000 adena</a></td></tr>"
                + "</table>"
                + "</body></html>");
        msg.replace("%objectId%", String.valueOf(((L2Npc) target).getObjectId()));
        activeChar.sendPacket(msg);
      } else {
        tryRentPet(activeChar, Integer.parseInt(st.nextToken()));
      }

      return true;
    } catch (Exception e) {
      _log.info("Exception in " + getClass().getSimpleName());
    }
    return false;
  }
Beispiel #15
0
  private static final void tryRentPet(L2PcInstance player, int val) {
    if ((player == null)
        || player.hasSummon()
        || player.isMounted()
        || player.isRentedPet()
        || player.isTransformed()
        || player.isCursedWeaponEquipped()) {
      return;
    }
    if (!player.disarmWeapons()) {
      return;
    }

    int petId;
    double price = 1;
    final int cost[] = {1800, 7200, 720000, 6480000};
    final int ridetime[] = {30, 60, 600, 1800};

    if (val > 10) {
      petId = 12526;
      val -= 10;
      price /= 2;
    } else {
      petId = 12621;
    }

    if ((val < 1) || (val > 4)) {
      return;
    }

    price *= cost[val - 1];
    final int time = ridetime[val - 1];

    if (!player.reduceAdena("Rent", (long) price, player.getLastFolkNPC(), true)) {
      return;
    }

    player.mount(petId, 0, false);
    final SetupGauge sg = new SetupGauge(3, time * 1000);
    player.sendPacket(sg);
    player.startRentPet(time);
  }
  @Override
  protected void runImpl() {
    final L2PcInstance activeChar = getClient().getActiveChar();
    if (activeChar == null) {
      return;
    }

    final EnchantItemRequest request = activeChar.getRequest(EnchantItemRequest.class);
    if ((request == null) || request.isProcessing()) {
      return;
    }

    final L2ItemInstance supportItem = request.getSupportItem();
    if ((supportItem == null) || (supportItem.getCount() < 1)) {
      request.setSupportItem(L2PcInstance.ID_NONE);
    }

    request.setTimestamp(System.currentTimeMillis());
    activeChar.sendPacket(ExRemoveEnchantSupportItemResult.STATIC_PACKET);
  }
Beispiel #17
0
  private void showGroupList(L2PcInstance activeChar) {
    final MobGroup[] mobGroupList = MobGroupTable.getInstance().getGroups();

    activeChar.sendMessage("======= <Mob Groups> =======");

    for (MobGroup mobGroup : mobGroupList) {
      activeChar.sendMessage(
          mobGroup.getGroupId()
              + ": "
              + mobGroup.getActiveMobCount()
              + " alive out of "
              + mobGroup.getMaxMobCount()
              + " of NPC ID "
              + mobGroup.getTemplate().getId()
              + " ("
              + mobGroup.getStatus()
              + ")");
    }

    activeChar.sendPacket(SystemMessageId.EMPTY3);
  }
Beispiel #18
0
 private void doAnimation(L2PcInstance activeChar) {
   Broadcast.toSelfAndKnownPlayersInRadius(
       activeChar, new MagicSkillUse(activeChar, 1008, 1, 4000, 0), 1500);
   activeChar.sendPacket(new SetupGauge(0, 4000));
 }
Beispiel #19
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;
  }
Beispiel #20
0
  private final synchronized String enterInstance(L2Npc npc, L2PcInstance player) {
    InstanceWorld world = InstanceManager.getInstance().getPlayerWorld(player);
    if (world != null) {
      if (!(world instanceof NornilsWorld) || (world.getTemplateId() != TEMPLATE_ID)) {
        player.sendPacket(
            SystemMessageId
                .YOU_HAVE_ENTERED_ANOTHER_INSTANT_ZONE_THEREFORE_YOU_CANNOT_ENTER_CORRESPONDING_DUNGEON);
        return null;
      }
      // check for level difference again on reenter
      if ((player.getLevel() > INSTANCE_LVL_MAX) || (player.getLevel() < INSTANCE_LVL_MIN)) {
        final SystemMessage sm =
            SystemMessage.getSystemMessage(
                SystemMessageId.C1_S_LEVEL_DOES_NOT_CORRESPOND_TO_THE_REQUIREMENTS_FOR_ENTRY);
        sm.addPcName(player);
        player.sendPacket(sm);
        return null;
      }
      // check what instance still exist
      final Instance inst = InstanceManager.getInstance().getInstance(world.getInstanceId());
      if (inst != null) {
        teleportPlayer(player, SPAWN_PPL, world.getInstanceId());
      }
      return null;
    }
    // Creating new instance
    final String result = checkConditions(npc, player);
    if (!(result.equalsIgnoreCase("ok"))) {
      return result;
    }

    final int instanceId = InstanceManager.getInstance().createDynamicInstance("NornilsGarden.xml");
    final Instance inst = InstanceManager.getInstance().getInstance(instanceId);

    inst.setName(InstanceManager.getInstance().getInstanceIdName(TEMPLATE_ID));
    inst.setExitLoc(new Location(player));
    inst.setAllowSummon(false);
    inst.setDuration(DURATION_TIME * 60000);
    inst.setEmptyDestroyTime(EMPTY_DESTROY_TIME * 60000);
    world = new NornilsWorld();
    world.setInstanceId(instanceId);
    world.setTemplateId(TEMPLATE_ID);
    InstanceManager.getInstance().addWorld(world);
    _log.info(
        "Nornils Garden: started, Instance: "
            + instanceId
            + " created by player: "
            + player.getName());

    prepareInstance((NornilsWorld) world);

    // and finally teleport party into instance
    final L2Party party = player.getParty();
    if (party != null) {
      for (L2PcInstance partyMember : party.getMembers()) {
        world.addAllowed(partyMember.getObjectId());
        teleportPlayer(partyMember, SPAWN_PPL, instanceId);
      }
    }
    return null;
  }
  @Override
  public void runImpl() {
    final L2PcInstance activeChar = getClient().getActiveChar();
    if ((activeChar == null) || !Config.ALLOW_MAIL || !Config.ALLOW_ATTACHMENTS) {
      return;
    }

    if (!getClient().getFloodProtectors().getTransaction().tryPerformAction("cancelpost")) {
      return;
    }

    final Message msg = MailManager.getInstance().getMessage(_msgId);
    if (msg == null) {
      return;
    }
    if (msg.getSenderId() != activeChar.getObjectId()) {
      Util.handleIllegalPlayerAction(
          activeChar,
          "Player " + activeChar.getName() + " tried to cancel not own post!",
          Config.DEFAULT_PUNISH);
      return;
    }

    if (!activeChar.isInsideZone(ZoneId.PEACE)) {
      activeChar.sendPacket(SystemMessageId.YOU_CANNOT_CANCEL_IN_A_NON_PEACE_ZONE_LOCATION);
      return;
    }

    if (activeChar.getActiveTradeList() != null) {
      activeChar.sendPacket(SystemMessageId.YOU_CANNOT_CANCEL_DURING_AN_EXCHANGE);
      return;
    }

    if (activeChar.hasItemRequest()) {
      activeChar.sendPacket(
          SystemMessageId.YOU_CANNOT_CANCEL_DURING_AN_ITEM_ENHANCEMENT_OR_ATTRIBUTE_ENHANCEMENT);
      return;
    }

    if (activeChar.getPrivateStoreType() != PrivateStoreType.NONE) {
      activeChar.sendPacket(
          SystemMessageId.YOU_CANNOT_CANCEL_BECAUSE_THE_PRIVATE_STORE_OR_WORKSHOP_IS_IN_PROGRESS);
      return;
    }

    if (!msg.hasAttachments()) {
      activeChar.sendPacket(
          SystemMessageId.YOU_CANNOT_CANCEL_SENT_MAIL_SINCE_THE_RECIPIENT_RECEIVED_IT);
      return;
    }

    final ItemContainer attachments = msg.getAttachments();
    if ((attachments == null) || (attachments.getSize() == 0)) {
      activeChar.sendPacket(
          SystemMessageId.YOU_CANNOT_CANCEL_SENT_MAIL_SINCE_THE_RECIPIENT_RECEIVED_IT);
      return;
    }

    int weight = 0;
    int slots = 0;

    for (L2ItemInstance item : attachments.getItems()) {
      if (item == null) {
        continue;
      }

      if (item.getOwnerId() != activeChar.getObjectId()) {
        Util.handleIllegalPlayerAction(
            activeChar,
            "Player "
                + activeChar.getName()
                + " tried to get not own item from cancelled attachment!",
            Config.DEFAULT_PUNISH);
        return;
      }

      if (item.getItemLocation() != ItemLocation.MAIL) {
        Util.handleIllegalPlayerAction(
            activeChar,
            "Player " + activeChar.getName() + " tried to get items not from mail !",
            Config.DEFAULT_PUNISH);
        return;
      }

      if (item.getLocationSlot() != msg.getId()) {
        Util.handleIllegalPlayerAction(
            activeChar,
            "Player " + activeChar.getName() + " tried to get items from different attachment!",
            Config.DEFAULT_PUNISH);
        return;
      }

      weight += item.getCount() * item.getItem().getWeight();
      if (!item.isStackable()) {
        slots += item.getCount();
      } else if (activeChar.getInventory().getItemByItemId(item.getId()) == null) {
        slots++;
      }
    }

    if (!activeChar.getInventory().validateCapacity(slots)) {
      activeChar.sendPacket(
          SystemMessageId.YOU_COULD_NOT_CANCEL_RECEIPT_BECAUSE_YOUR_INVENTORY_IS_FULL);
      return;
    }

    if (!activeChar.getInventory().validateWeight(weight)) {
      activeChar.sendPacket(
          SystemMessageId.YOU_COULD_NOT_CANCEL_RECEIPT_BECAUSE_YOUR_INVENTORY_IS_FULL);
      return;
    }

    // Proceed to the transfer
    final InventoryUpdate playerIU = Config.FORCE_INVENTORY_UPDATE ? null : new InventoryUpdate();
    for (L2ItemInstance item : attachments.getItems()) {
      if (item == null) {
        continue;
      }

      final long count = item.getCount();
      final L2ItemInstance newItem =
          attachments.transferItem(
              attachments.getName(),
              item.getObjectId(),
              count,
              activeChar.getInventory(),
              activeChar,
              null);
      if (newItem == null) {
        return;
      }

      if (playerIU != null) {
        if (newItem.getCount() > count) {
          playerIU.addModifiedItem(newItem);
        } else {
          playerIU.addNewItem(newItem);
        }
      }
      final SystemMessage sm =
          SystemMessage.getSystemMessage(SystemMessageId.YOU_HAVE_ACQUIRED_S2_S1);
      sm.addItemName(item.getId());
      sm.addLong(count);
      activeChar.sendPacket(sm);
    }

    msg.removeAttachments();

    // Send updated item list to the player
    if (playerIU != null) {
      activeChar.sendPacket(playerIU);
    } else {
      activeChar.sendPacket(new ItemList(activeChar, false));
    }

    // Update current load status on player
    activeChar.sendPacket(new ExUserInfoInvenWeight(activeChar));

    final L2PcInstance receiver = L2World.getInstance().getPlayer(msg.getReceiverId());
    if (receiver != null) {
      final SystemMessage sm =
          SystemMessage.getSystemMessage(SystemMessageId.S1_CANCELED_THE_SENT_MAIL);
      sm.addCharName(activeChar);
      receiver.sendPacket(sm);
      receiver.sendPacket(new ExChangePostState(true, _msgId, Message.DELETED));
    }

    MailManager.getInstance().deleteMessageInDb(_msgId);

    activeChar.sendPacket(new ExChangePostState(false, _msgId, Message.DELETED));
    activeChar.sendPacket(SystemMessageId.MAIL_SUCCESSFULLY_CANCELLED);
  }
Beispiel #22
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);
  }