コード例 #1
0
ファイル: QuestState.java プロジェクト: Skunkk/l2j-universe
  public Object setStateAndNotSave(int state) {
    Player player = getPlayer();
    if (player == null) {
      return null;
    }

    _state = state;

    if (getQuest().isVisible(player) && isStarted()) {
      player.sendPacket(new ExShowQuestMark(getQuest().getQuestIntId()));
    }

    player.sendPacket(new QuestList(player));
    return state;
  }
コード例 #2
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();
  }
コード例 #3
0
ファイル: QuestState.java プロジェクト: Skunkk/l2j-universe
 public void showTutorialHTML(String html, int type) {
   Player player = getPlayer();
   if (player == null) {
     return;
   }
   String text = html;
   if (type == 1) {
     text = HtmCache.getInstance().getNotNull("quests/_255_Tutorial/" + html, player);
   }
   player.sendPacket(new TutorialShowHtml(text, type));
 }
コード例 #4
0
ファイル: QuestState.java プロジェクト: Skunkk/l2j-universe
  public String setCond(int newCond, boolean store) {
    if (newCond == getCond()) {
      return String.valueOf(newCond);
    }

    int oldCond = getInt(VAR_COND);
    _cond = newCond;

    if ((oldCond & 0x80000000) != 0) {
      // уже используется второй формат
      if (newCond > 2) // Если этап меньше 3 то возвращаемся к первому варианту.
      {
        oldCond &= 0x80000001 | ((1 << newCond) - 1);
        newCond = oldCond | (1 << (newCond - 1));
      }
    } else {
      // Второй вариант теперь используется всегда если этап больше 2
      if (newCond > 2) {
        newCond = 0x80000001 | (1 << (newCond - 1)) | ((1 << oldCond) - 1);
      }
    }

    final String sVal = String.valueOf(newCond);
    final String result = set(VAR_COND, sVal, false);
    if (store) {
      Quest.updateQuestVarInDb(this, VAR_COND, sVal);
    }

    final Player player = getPlayer();
    if (player != null) {
      player.sendPacket(new QuestList(player));
      if ((newCond != 0) && getQuest().isVisible(player) && isStarted()) {
        player.sendPacket(new ExShowQuestMark(getQuest().getQuestIntId()));
      }
    }
    return result;
  }
コード例 #5
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;
  }
コード例 #6
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;
  }
コード例 #7
0
ファイル: QuestState.java プロジェクト: Skunkk/l2j-universe
 public void showTutorialHTML(String html) {
   Player player = getPlayer();
   if (player == null) return;
   String text = HtmCache.getInstance().getNotNull("quests/_255_Tutorial/" + html, player);
   player.sendPacket(new TutorialShowHtml(TutorialShowHtml.TYPE_HTML, text));
 }
コード例 #8
0
ファイル: QuestState.java プロジェクト: Skunkk/l2j-universe
 public void showQuestionMark(int number) {
   Player player = getPlayer();
   if (player != null) {
     player.sendPacket(new TutorialShowQuestionMark(number));
   }
 }
コード例 #9
0
ファイル: QuestState.java プロジェクト: Skunkk/l2j-universe
 public void onTutorialClientEvent(int number) {
   Player player = getPlayer();
   if (player != null) {
     player.sendPacket(new TutorialEnableClientEvent(number));
   }
 }
コード例 #10
0
ファイル: QuestState.java プロジェクト: Skunkk/l2j-universe
 public void playTutorialVoice(String voice) {
   Player player = getPlayer();
   if (player != null) {
     player.sendPacket(new PlaySound(PlaySound.Type.VOICE, voice, 0, 0, player.getLoc()));
   }
 }
コード例 #11
0
ファイル: QuestState.java プロジェクト: Skunkk/l2j-universe
 /**
  * Send a packet in order to play sound at client terminal
  *
  * @param sound
  */
 public void playSound(String sound) {
   Player player = getPlayer();
   if (player != null) {
     player.sendPacket(new PlaySound(sound));
   }
 }
コード例 #12
0
ファイル: QuestState.java プロジェクト: Skunkk/l2j-universe
 public void showTutorialClientHTML(String html) {
   Player player = getPlayer();
   if (player != null) {
     player.sendPacket(new TutorialShowHtml(html, TutorialShowHtml.TYPE_WINDOW));
   }
 }