コード例 #1
0
ファイル: QuestState.java プロジェクト: Skunkk/l2j-universe
  public void giveItems(int itemId, long count, Element element, int power) {
    Player player = getPlayer();
    if (player == null) {
      return;
    }

    if (count <= 0) {
      count = 1;
    }

    // Get template of item
    ItemTemplate template = ItemHolder.getInstance().getTemplate(itemId);
    if (template == null) {
      return;
    }

    for (int i = 0; i < count; i++) {
      ItemInstance item = ItemFunctions.createItem(itemId);

      if (element != Element.NONE) {
        item.setAttributeElement(element, power);
      }

      // Add items to player's inventory
      player.getInventory().addItem(item);
    }

    player.sendPacket(SystemMessage2.obtainItems(template.getItemId(), count, 0));
    player.sendChanges();
  }
コード例 #2
0
  private int getCond(Player player) {
    FortressSiegeEvent event = getEvent(FortressSiegeEvent.class);
    if (event == null) {
      return COND_POWER;
    }

    SpawnExObject object = event.getFirstObject(FortressSiegeEvent.OUT_POWER_UNITS);

    boolean allPowerDisabled = true;
    for (int i = 0; i < 4; i++) {
      Spawner spawn = object.getSpawns().get(i);
      if (spawn.getFirstSpawned() != null) {
        allPowerDisabled = false;
      }
    }

    if (allPowerDisabled) {
      if (player.getInventory().getCountOf(ITEM_ID) > 0) {
        return COND_CAN_OPEN;
      } else {
        return COND_NO_ITEM;
      }
    } else {
      return COND_POWER;
    }
  }
コード例 #3
0
ファイル: QuestState.java プロジェクト: Skunkk/l2j-universe
  /**
   * Destroy element used by quest when quest is exited
   *
   * @param repeatable
   * @return QuestState
   */
  public QuestState exitCurrentQuest(boolean repeatable) {
    Player player = getPlayer();
    if (player == null) {
      return this;
    }

    removePlayerOnKillListener();
    // Clean drops
    for (int itemId : _quest.getItems()) {
      // Get [item from] / [presence of the item in] the inventory of the player
      ItemInstance item = player.getInventory().getItemByItemId(itemId);
      if ((item == null) || (itemId == 57)) {
        continue;
      }
      long count = item.getCount();
      // If player has the item in inventory, destroy it (if not gold)
      player.getInventory().destroyItemByItemId(itemId, count);
      player.getWarehouse().destroyItemByItemId(itemId, count); // TODO [G1ta0] analyze this
    }

    // If quest is repeatable, delete quest from list of quest of the player and from database
    // (quest CAN be created again => repeatable)
    if (repeatable) {
      player.removeQuestState(_quest.getName());
      Quest.deleteQuestInDb(this);
      _vars.clear();
    } else { // Otherwise, delete variables for quest and update database (quest CANNOT be created
             // again => not repeatable)
      for (String var : _vars.keySet()) {
        if (var != null) {
          unset(var);
        }
      }
      setState(Quest.COMPLETED);
      Quest.updateQuestInDb(this); // FIXME: оно вроде не нужно?
    }
    if (isCompleted()) {
      // WorldStatisticsManager.getInstance().updateStat(player, CategoryType.QUESTS_COMPLETED,0,
      // 1);
    }
    player.sendPacket(new QuestList(player));
    return this;
  }
コード例 #4
0
ファイル: QuestState.java プロジェクト: Skunkk/l2j-universe
 public long getSumQuestItemsCount(int... itemIds) {
   Player player = getPlayer();
   if (player == null) {
     return 0;
   }
   long count = 0;
   for (int itemId : itemIds) {
     count += player.getInventory().getCountOf(itemId);
   }
   return count;
 }
コード例 #5
0
ファイル: QuestState.java プロジェクト: Skunkk/l2j-universe
 public boolean checkQuestItemsCount(int... itemIds) {
   Player player = getPlayer();
   if (player == null) {
     return false;
   }
   for (int itemId : itemIds) {
     if (player.getInventory().getCountOf(itemId) <= 0) {
       return false;
     }
   }
   return true;
 }
コード例 #6
0
ファイル: Coffer.java プロジェクト: Skunkk/l2j-universe
 /*
  * Выбирает 1 предмет из группы
  */
 public void getGroupItem(Player activeChar, RewardData[] dropData, Map<Integer, Long> report) {
   ItemInstance item;
   long count = 0;
   for (RewardData d : dropData)
     if (Rnd.get(1, RewardList.MAX_CHANCE)
         <= d.getChance() * Config.EVENT_COFFER_OF_SHADOWS_REWARD_RATE) {
       count = Rnd.get(d.getMinDrop(), d.getMaxDrop());
       item = ItemFunctions.createItem(d.getItemId());
       item.setCount(count);
       activeChar.getInventory().addItem(item);
       Long old = report.get(d.getItemId());
       report.put(d.getItemId(), old != null ? old + count : count);
     }
 }
コード例 #7
0
ファイル: QuestState.java プロジェクト: Skunkk/l2j-universe
  /**
   * Удаляет указанные предметы из инвентаря игрока, и обновляет инвентарь
   *
   * @param itemId : id удаляемого предмета
   * @param count : число удаляемых предметов<br>
   *     Если count передать -1, то будут удалены все указанные предметы.
   * @return Количество удаленных предметов
   */
  public long takeItems(int itemId, long count) {
    Player player = getPlayer();
    if (player == null) {
      return 0;
    }

    // Get object item from player's inventory list
    ItemInstance item = player.getInventory().getItemByItemId(itemId);
    if (item == null) {
      return 0;
    }
    // Tests on count value in order not to have negative value
    if ((count < 0) || (count > item.getCount())) {
      count = item.getCount();
    }

    // Destroy the quantity of items wanted
    player.getInventory().destroyItemByItemId(itemId, count);
    // Send message of destruction to client
    player.sendPacket(SystemMessage2.removeItems(itemId, count));

    return count;
  }
コード例 #8
0
  @Override
  public void onBypassFeedback(Player player, String command) {
    if (!canBypassCheck(player, this)) return;

    StringTokenizer st = new StringTokenizer(command, " ");
    String actualCommand = st.nextToken();
    boolean condition = validateCondition(player);

    if (actualCommand.equalsIgnoreCase("RideHelp")) {
      NpcHtmlMessage html = new NpcHtmlMessage(player, this);
      html.setFile("wyvern/help_ride.htm");
      html.replace("%npcname%", "Wyvern Manager " + getName());
      player.sendPacket(html);
      player.sendActionFailed();
    }
    if (condition) {
      if (actualCommand.equalsIgnoreCase("RideWyvern") && player.isClanLeader())
        if (!player.isRiding() || !PetDataTable.isStrider(player.getMountNpcId())) {
          NpcHtmlMessage html = new NpcHtmlMessage(player, this);
          html.setFile("wyvern/not_ready.htm");
          html.replace("%npcname%", "Wyvern Manager " + getName());
          player.sendPacket(html);
        } else if (player.getInventory().getItemByItemId(1460) == null
            || player.getInventory().getItemByItemId(1460).getCount() < 25) {
          NpcHtmlMessage html = new NpcHtmlMessage(player, this);
          html.setFile("wyvern/havenot_cry.htm");
          html.replace("%npcname%", "Wyvern Manager " + getName());
          player.sendPacket(html);
        } else if (player.getInventory().destroyItemByItemId(1460, 25L)) {
          player.setMount(PetDataTable.WYVERN_ID, player.getMountObjId(), player.getMountLevel());
          NpcHtmlMessage html = new NpcHtmlMessage(player, this);
          html.setFile("wyvern/after_ride.htm");
          html.replace("%npcname%", "Wyvern Manager " + getName());
          player.sendPacket(html);
        }
    } else super.onBypassFeedback(player, command);
  }
コード例 #9
0
ファイル: ibcougar.java プロジェクト: magistor/My_La2
  public void evolve() {
    Player player = getSelf();
    NpcInstance npc = getNpc();
    if (player == null || npc == null) {
      return;
    }
    Summon pl_pet = player.getPet();
    if (player.getInventory().getItemByItemId(BABY_COUGAR_CHIME) == null) {
      show("scripts/services/petevolve/no_item.htm", player, npc);
      return;
    }
    if (pl_pet == null || pl_pet.isDead()) {
      show("scripts/services/petevolve/evolve_no.htm", player, npc);
      return;
    }
    if (pl_pet.getNpcId() != BABY_COUGAR) {
      show("scripts/services/petevolve/no_pet.htm", player, npc);
      return;
    }
    if (pl_pet.getLevel() < 55) {
      show("scripts/services/petevolve/no_level.htm", player, npc);
      return;
    }

    int controlItemId = player.getPet().getControlItemObjId();
    player.getPet().unSummon();

    ItemInstance control = player.getInventory().getItemByObjectId(controlItemId);
    control.setItemId(IN_COUGAR_CHIME);
    control.setEnchantLevel(L2Pet.IMPROVED_BABY_COUGAR.getMinLevel());
    control.setJdbcState(JdbcEntityState.UPDATED);
    control.update();
    player.sendItemList(false);

    show("scripts/services/petevolve/yes_pet.htm", player, npc);
  }
コード例 #10
0
ファイル: Account.java プロジェクト: Skunkk/l2j-universe
 public void NewAccount(String[] name) {
   Player player = getSelf();
   if (player == null) return;
   if (player.getInventory().getCountOf(ACC_MOVE_ITEM) < ACC_MOVE_PRICE) {
     player.sendMessage(
         "У вас нету "
             + ACC_MOVE_PRICE
             + " "
             + ItemHolder.getInstance().getTemplate(ACC_MOVE_ITEM));
     CharToAcc();
     return;
   }
   String _name = name[0];
   Connection con = null;
   Connection conGS = null;
   PreparedStatement offline = null;
   Statement statement = null;
   ResultSet rs = null;
   try {
     con = DatabaseFactory.getInstance().getConnection();
     offline = con.prepareStatement("SELECT `login` FROM `accounts` WHERE `login` = ?");
     offline.setString(1, _name);
     rs = offline.executeQuery();
     if (rs.next()) {
       removeItem(player, ACC_MOVE_ITEM, ACC_MOVE_PRICE);
       conGS = DatabaseFactory.getInstance().getConnection();
       statement = conGS.createStatement();
       statement.executeUpdate(
           "UPDATE `characters` SET `account_name` = '"
               + _name
               + "' WHERE `char_name` = '"
               + player.getName()
               + "'");
       player.sendMessage("Персонаж успешно перенесен.");
       player.logout();
     } else {
       player.sendMessage("Введенный аккаунт не найден.");
       CharToAcc();
     }
   } catch (Exception e) {
     e.printStackTrace();
     return;
   } finally {
     DbUtils.closeQuietly(con, offline, rs);
     DbUtils.closeQuietly(conGS, statement);
   }
 }
コード例 #11
0
ファイル: Coffer.java プロジェクト: Skunkk/l2j-universe
  @Override
  public boolean useItem(Playable playable, ItemInstance item, boolean ctrl) {
    if (!playable.isPlayer()) return false;
    Player activeChar = playable.getPlayer();

    if (!activeChar.isQuestContinuationPossible(true)) return false;

    Map<Integer, Long> items = new HashMap<Integer, Long>();
    long count = 0;
    do {
      count++;
      getGroupItem(activeChar, _dropmats, items);
      getGroupItem(activeChar, _dropacc, items);
      getGroupItem(activeChar, _dropevents, items);
      getGroupItem(activeChar, _dropench, items);
    } while (ctrl && item.getCount() > count && activeChar.isQuestContinuationPossible(false));

    activeChar.getInventory().destroyItem(item, count); // FIXME [G1ta0] item-API
    activeChar.sendPacket(SystemMessage2.removeItems(item.getItemId(), count));
    for (Entry<Integer, Long> e : items.entrySet())
      activeChar.sendPacket(SystemMessage2.obtainItems(e.getKey(), e.getValue(), 0));
    return true;
  }
コード例 #12
0
ファイル: NoblessSell.java プロジェクト: magistor/My_La2
  public void get() {
    Player player = getSelf();

    if (player.isNoble()) {
      return;
    }

    if (player.getSubLevel() < 75) {
      player.sendMessage("You must make sub class level 75 first.");
      return;
    }

    if (player
        .getInventory()
        .destroyItemByItemId(
            Config.SERVICES_NOBLESS_SELL_ITEM, Config.SERVICES_NOBLESS_SELL_PRICE)) {
      makeSubQuests();
      becomeNoble();
    } else if (Config.SERVICES_NOBLESS_SELL_ITEM == 57) {
      player.sendPacket(Msg.YOU_DO_NOT_HAVE_ENOUGH_ADENA);
    } else {
      player.sendPacket(SystemMsg.INCORRECT_ITEM_COUNT);
    }
  }
コード例 #13
0
ファイル: SumielInstance.java プロジェクト: magistor/My_La2
  @Override
  public void onBypassFeedback(Player player, String command) {
    if (command.equals("teleport")) {
      showChatWindow(player, "event/monastyre/minigame_instructor006.htm");
    } else if (command.equals("teleport1")) {
      switch (getAISpawnParam()) {
        case 1:
          player.teleToLocation(110705, -81328, -1600);
          break;
        case 2:
          player.teleToLocation(114866, -71627, -560);
          break;
      }
    } else if (command.equals("teleport2")) {
      player.teleToLocation(110712, -81352, -2688);
    } else if (command.equals("start")) {
      if (player.getInventory().getCountOf(15540) == 0) {
        showChatWindow(player, "event/monastyre/minigame_instructor005.htm");
      } else if (c_ai1 != player) {
        showChatWindow(player, "event/monastyre/minigame_instructor004.htm");
      } else if (c_ai1 == player) {
        switch (getAISpawnParam()) {
          case 1:
            if (HURRY_UP_1 != null) {
              HURRY_UP_1.cancel(false);
              HURRY_UP_1 = null;
            }
            if (HURRY_UP2_1 != null) {
              HURRY_UP2_1.cancel(false);
              HURRY_UP2_1 = null;
            }
            break;
          case 2:
            if (HURRY_UP_2 != null) {
              HURRY_UP_2.cancel(false);
              HURRY_UP_2 = null;
            }
            if (HURRY_UP2_2 != null) {
              HURRY_UP2_2.cancel(false);
              HURRY_UP2_2 = null;
            }
            break;
        }

        player.getInventory().destroyItemByItemId(15540, 1);
        player.getInventory().addItem(15485, 1);
        Functions.npcShout(this, NpcString.FURNFACE1);
        i_ai1 = Rnd.get(9) + 1;
        i_ai2 = Rnd.get(9) + 1;
        i_ai3 = Rnd.get(9) + 1;
        i_ai4 = Rnd.get(9) + 1;
        i_ai5 = Rnd.get(9) + 1;
        i_ai6 = Rnd.get(9) + 1;
        i_ai7 = Rnd.get(9) + 1;
        i_ai8 = Rnd.get(9) + 1;
        i_ai9 = Rnd.get(9) + 1;
        c_ai0 = player;
        if (i_quest9 == 1) {}

        switch (getAISpawnParam()) {
          case 1:
            HURRY_UP_1 = ThreadPoolManager.getInstance().schedule(new HURRY_UP(), 2 * 60 * 1000);
            break;
          case 2:
            HURRY_UP_2 = ThreadPoolManager.getInstance().schedule(new HURRY_UP(), 2 * 60 * 1000);
            break;
        }
        GAME_TIME =
            ThreadPoolManager.getInstance().schedule(new GAME_TIME(), 3 * 60 * 1000 + 10 * 1000);
        TIMER_0 = ThreadPoolManager.getInstance().schedule(new TIMER_0(), 1 * 1000);
      } else if (command.equals("restart")) {
        i_quest1 = 1;
        i_ai1 = Rnd.get(9) + 1;
        i_ai2 = Rnd.get(9) + 1;
        i_ai3 = Rnd.get(9) + 1;
        i_ai4 = Rnd.get(9) + 1;
        i_ai5 = Rnd.get(9) + 1;
        i_ai6 = Rnd.get(9) + 1;
        i_ai7 = Rnd.get(9) + 1;
        i_ai8 = Rnd.get(9) + 1;
        i_ai9 = Rnd.get(9) + 1;
        c_ai0 = player;
        if (i_quest9 == 1) {}
        TIMER_0 = ThreadPoolManager.getInstance().schedule(new TIMER_0(), 1 * 1000);
      }
    } else {
      super.onBypassFeedback(player, command);
    }
  }
コード例 #14
0
ファイル: QuestState.java プロジェクト: Skunkk/l2j-universe
 /**
  * Return the quantity of one sort of item hold by the player
  *
  * @param itemId : ID of the item wanted to be count
  * @return int
  */
 public long getQuestItemsCount(int itemId) {
   Player player = getPlayer();
   return player == null ? 0 : player.getInventory().getCountOf(itemId);
 }
コード例 #15
0
ファイル: QuestState.java プロジェクト: Skunkk/l2j-universe
 public boolean hasQuestItems(int itemId) {
   return _player.getInventory().getItemByItemId(itemId) != null;
 }