예제 #1
0
  @Override
  public L2Object[] getTargetList(
      Skill skill, L2Character activeChar, boolean onlyFirst, L2Character target) {
    List<L2Character> targetList = new ArrayList<>();
    if ((target != null) && target.isDead()) {
      final L2PcInstance player;
      if (activeChar.isPlayer()) {
        player = activeChar.getActingPlayer();
      } else {
        player = null;
      }

      final L2PcInstance targetPlayer;
      if (target.isPlayer()) {
        targetPlayer = target.getActingPlayer();
      } else {
        targetPlayer = null;
      }

      final L2PetInstance targetPet;
      if (target.isPet()) {
        targetPet = (L2PetInstance) target;
      } else {
        targetPet = null;
      }

      if ((player != null) && ((targetPlayer != null) || (targetPet != null))) {
        boolean condGood = true;

        if (skill.hasEffectType(L2EffectType.RESURRECTION)) {
          if (targetPlayer != null) {
            // check target is not in a active siege zone
            if (targetPlayer.isInsideZone(ZoneId.SIEGE) && !targetPlayer.isInSiege()) {
              condGood = false;
              activeChar.sendPacket(
                  SystemMessageId
                      .IT_IS_NOT_POSSIBLE_TO_RESURRECT_IN_BATTLEGROUNDS_WHERE_A_SIEGE_WAR_IS_TAKING_PLACE);
            }
          }
        }

        if (condGood) {
          if (!onlyFirst) {
            targetList.add(target);
            return targetList.toArray(new L2Character[targetList.size()]);
          }
          return new L2Character[] {target};
        }
      }
    }
    activeChar.sendPacket(SystemMessageId.THAT_IS_AN_INCORRECT_TARGET);
    return EMPTY_TARGET_LIST;
  }
예제 #2
0
파일: Duel.java 프로젝트: 3mRe/L2Java
  /**
   * Did a situation occur in which the duel has to be ended?
   *
   * @return DuelResult duel status
   */
  public DuelResult checkEndDuelCondition() {
    // one of the players might leave during duel
    if ((_playerA == null) || (_playerB == null)) {
      return DuelResult.Canceled;
    }

    // got a duel surrender request?
    if (_surrenderRequest != 0) {
      if (_surrenderRequest == 1) {
        return DuelResult.Team1Surrender;
      }
      return DuelResult.Team2Surrender;
    }
    // duel timed out
    else if (getRemainingTime() <= 0) {
      return DuelResult.Timeout;
    }
    // Has a player been declared winner yet?
    else if (_playerA.getDuelState() == DUELSTATE_WINNER) {
      // If there is a Winner already there should be no more fighting going on
      stopFighting();
      return DuelResult.Team1Win;
    } else if (_playerB.getDuelState() == DUELSTATE_WINNER) {
      // If there is a Winner already there should be no more fighting going on
      stopFighting();
      return DuelResult.Team2Win;
    }

    // More end duel conditions for 1on1 duels
    else if (!_partyDuel) {
      // Duel was interrupted e.g.: player was attacked by mobs / other players
      if ((_playerA.getDuelState() == DUELSTATE_INTERRUPTED)
          || (_playerB.getDuelState() == DUELSTATE_INTERRUPTED)) {
        return DuelResult.Canceled;
      }

      // Are the players too far apart?
      if (!_playerA.isInsideRadius(_playerB, 1600, false, false)) {
        return DuelResult.Canceled;
      }

      // Did one of the players engage in PvP combat?
      if (isDuelistInPvp(true)) {
        return DuelResult.Canceled;
      }

      // is one of the players in a Siege, Peace or PvP zone?
      if (_playerA.isInsideZone(ZoneId.PEACE)
          || _playerB.isInsideZone(ZoneId.PEACE)
          || _playerA.isInsideZone(ZoneId.SIEGE)
          || _playerB.isInsideZone(ZoneId.SIEGE)
          || _playerA.isInsideZone(ZoneId.PVP)
          || _playerB.isInsideZone(ZoneId.PVP)) {
        return DuelResult.Canceled;
      }
    }

    return DuelResult.Continue;
  }
  @Override
  protected void runImpl() {
    L2PcInstance player = getClient().getActiveChar();
    if (player == null) {
      return;
    }

    if (_items == null) {
      player.setPrivateStoreType(PrivateStoreType.NONE);
      player.broadcastUserInfo();
      return;
    }

    if (!player.getAccessLevel().allowTransaction()) {
      player.sendPacket(SystemMessageId.YOU_ARE_NOT_AUTHORIZED_TO_DO_THAT);
      return;
    }

    if (AttackStanceTaskManager.getInstance().hasAttackStanceTask(player) || player.isInDuel()) {
      player.sendPacket(
          SystemMessageId
              .WHILE_YOU_ARE_ENGAGED_IN_COMBAT_YOU_CANNOT_OPERATE_A_PRIVATE_STORE_OR_PRIVATE_WORKSHOP);
      player.sendPacket(new PrivateStoreManageListBuy(player));
      player.sendPacket(ActionFailed.STATIC_PACKET);
      return;
    }

    if (player.isInsideZone(ZoneId.NO_STORE)) {
      player.sendPacket(new PrivateStoreManageListBuy(player));
      player.sendPacket(SystemMessageId.YOU_CANNOT_OPEN_A_PRIVATE_STORE_HERE);
      player.sendPacket(ActionFailed.STATIC_PACKET);
      return;
    }

    if (!player.canOpenPrivateStore()) {
      player.sendPacket(new PrivateStoreManageListBuy(player));
      player.sendPacket(ActionFailed.STATIC_PACKET);
      return;
    }

    TradeList tradeList = player.getBuyList();
    tradeList.clear();

    // Check maximum number of allowed slots for pvt shops
    if (_items.length > player.getPrivateBuyStoreLimit()) {
      player.sendPacket(new PrivateStoreManageListBuy(player));
      player.sendPacket(SystemMessageId.YOU_HAVE_EXCEEDED_THE_QUANTITY_THAT_CAN_BE_INPUTTED);
      return;
    }

    long totalCost = 0;
    for (Item i : _items) {
      if (!i.addToTradeList(tradeList)) {
        Util.handleIllegalPlayerAction(
            player,
            "Warning!! Character "
                + player.getName()
                + " of account "
                + player.getAccountName()
                + " tried to set price more than "
                + MAX_ADENA
                + " adena in Private Store - Buy.",
            Config.DEFAULT_PUNISH);
        return;
      }

      totalCost += i.getCost();
      if (totalCost > MAX_ADENA) {
        Util.handleIllegalPlayerAction(
            player,
            "Warning!! Character "
                + player.getName()
                + " of account "
                + player.getAccountName()
                + " tried to set total price more than "
                + MAX_ADENA
                + " adena in Private Store - Buy.",
            Config.DEFAULT_PUNISH);
        return;
      }
    }

    // Check for available funds
    if (totalCost > player.getAdena()) {
      player.sendPacket(new PrivateStoreManageListBuy(player));
      player.sendPacket(
          SystemMessageId
              .THE_PURCHASE_PRICE_IS_HIGHER_THAN_THE_AMOUNT_OF_MONEY_THAT_YOU_HAVE_AND_SO_YOU_CANNOT_OPEN_A_PERSONAL_STORE);
      return;
    }

    player.sitDown();
    player.setPrivateStoreType(PrivateStoreType.BUY);
    player.broadcastUserInfo();
    player.broadcastPacket(new PrivateStoreMsgBuy(player));
  }
  @Override
  protected void runImpl() {
    L2PcInstance player = getClient().getActiveChar();
    if (player == null) return;

    if (_items == null) {
      player.setPrivateStoreType(L2PcInstance.STORE_PRIVATE_NONE);
      player.broadcastUserInfo();
      return;
    }

    if (AttackStanceTaskManager.getInstance().getAttackStanceTask(player) || player.isInDuel()) {
      player.sendPacket(
          SystemMessage.getSystemMessage(SystemMessageId.CANT_OPERATE_PRIVATE_STORE_DURING_COMBAT));
      player.sendPacket(ActionFailed.STATIC_PACKET);
      return;
    }

    if (player.isInsideZone(L2Character.ZONE_NOSTORE)) {
      player.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.NO_PRIVATE_WORKSHOP_HERE));
      player.sendPacket(ActionFailed.STATIC_PACKET);
      return;
    }

    L2ManufactureList createList = new L2ManufactureList();

    List<L2RecipeList> dwarfRecipes = Arrays.asList(player.getDwarvenRecipeBook());
    List<L2RecipeList> commonRecipes = Arrays.asList(player.getCommonRecipeBook());

    for (Recipe i : _items) {
      L2RecipeList list = RecipeController.getInstance().getRecipeList(i.getRecipeId());

      if (!dwarfRecipes.contains(list) && !commonRecipes.contains(list)) {
        Util.handleIllegalPlayerAction(
            player,
            "Warning!! Player "
                + player.getName()
                + " of account "
                + player.getAccountName()
                + " tried to set recipe which he dont have.",
            Config.DEFAULT_PUNISH);
        return;
      }

      if (!i.addToList(createList)) {
        Util.handleIllegalPlayerAction(
            player,
            "Warning!! Character "
                + player.getName()
                + " of account "
                + player.getAccountName()
                + " tried to set price more than "
                + MAX_ADENA
                + " adena in Private Manufacture.",
            Config.DEFAULT_PUNISH);
        return;
      }
    }

    createList.setStoreName(
        player.getCreateList() != null ? player.getCreateList().getStoreName() : "");
    player.setCreateList(createList);

    player.setPrivateStoreType(L2PcInstance.STORE_PRIVATE_MANUFACTURE);
    player.sitDown();
    player.broadcastUserInfo();
    player.sendPacket(new RecipeShopMsg(player));
    player.broadcastPacket(new RecipeShopMsg(player));
  }