Пример #1
0
  /**
   * Claims the hero status for the given player.
   *
   * @param player the player to become hero
   */
  public void claimHero(L2PcInstance player) {
    _heroes.get(player.getObjectId()).set(CLAIMED, true);

    final L2Clan clan = player.getClan();
    if ((clan != null) && (clan.getLevel() >= 5)) {
      clan.addReputationScore(Config.HERO_POINTS, true);
      final SystemMessage sm =
          SystemMessage.getSystemMessage(
              SystemMessageId.CLAN_MEMBER_C1_BECAME_HERO_AND_GAINED_S2_REPUTATION_POINTS);
      sm.addString(CharNameTable.getInstance().getNameById(player.getObjectId()));
      sm.addInt(Config.HERO_POINTS);
      clan.broadcastToOnlineMembers(sm);
    }

    player.setHero(true);
    player.broadcastPacket(new SocialAction(player.getObjectId(), 20016)); // Hero Animation
    player.sendPacket(new UserInfo(player));
    player.sendPacket(new ExBrExtraUserInfo(player));
    player.broadcastUserInfo();
    // Set Gained hero and reload data
    setHeroGained(player.getObjectId());
    loadFights(player.getObjectId());
    loadDiary(player.getObjectId());
    _heroMessage.put(player.getObjectId(), "");

    updateHeroes(false);
  }
Пример #2
0
  public synchronized void computeNewHeroes(List<StatsSet> newHeroes) {
    updateHeroes(true);

    for (Integer objectId : _heroes.keySet()) {
      final L2PcInstance player = L2World.getInstance().getPlayer(objectId);
      if (player == null) {
        continue;
      }

      player.setHero(false);

      for (int i = 0; i < Inventory.PAPERDOLL_TOTALSLOTS; i++) {
        L2ItemInstance equippedItem = player.getInventory().getPaperdollItem(i);
        if ((equippedItem != null) && equippedItem.isHeroItem()) {
          player.getInventory().unEquipItemInSlot(i);
        }
      }

      final InventoryUpdate iu = new InventoryUpdate();
      for (L2ItemInstance item : player.getInventory().getAvailableItems(false, false, false)) {
        if ((item != null) && item.isHeroItem()) {
          player.destroyItem("Hero", item, null, true);
          iu.addRemovedItem(item);
        }
      }

      if (!iu.getItems().isEmpty()) {
        player.sendPacket(iu);
      }

      player.broadcastUserInfo();
    }

    if (newHeroes.isEmpty()) {
      _heroes.clear();
      return;
    }

    Map<Integer, StatsSet> heroes = new FastMap<>();

    for (StatsSet hero : newHeroes) {
      int charId = hero.getInt(Olympiad.CHAR_ID);

      if ((_completeHeroes != null) && _completeHeroes.containsKey(charId)) {
        StatsSet oldHero = _completeHeroes.get(charId);
        int count = oldHero.getInt(COUNT);
        oldHero.set(COUNT, count + 1);
        oldHero.set(PLAYED, 1);
        oldHero.set(CLAIMED, false);
        heroes.put(charId, oldHero);
      } else {
        StatsSet newHero = new StatsSet();
        newHero.set(Olympiad.CHAR_NAME, hero.getString(Olympiad.CHAR_NAME));
        newHero.set(Olympiad.CLASS_ID, hero.getInt(Olympiad.CLASS_ID));
        newHero.set(COUNT, 1);
        newHero.set(PLAYED, 1);
        newHero.set(CLAIMED, false);
        heroes.put(charId, newHero);
      }
    }

    deleteItemsInDb();

    _heroes.clear();
    _heroes.putAll(heroes);

    heroes.clear();

    updateHeroes(false);
  }