Ejemplo n.º 1
0
  /**
   * Method activate.
   *
   * @param player Player
   * @param item ItemInstance
   */
  public void activate(Player player, ItemInstance item) {
    if ((player == null) || player.isInOlympiadMode()) {
      return;
    }

    CursedWeapon cw = _cursedWeaponsMap.get(item.getId());

    if (cw == null) {
      return;
    }

    if (player.isCursedWeaponEquipped()) {
      if (player.getCursedWeaponEquippedId() != item.getId()) {
        CursedWeapon cw2 = _cursedWeaponsMap.get(player.getCursedWeaponEquippedId());
        cw2.setNbKills(cw2.getStageKills() - 1);
        cw2.increaseKills();
      }

      endOfLife(cw);
      player.getInventory().destroyItem(item, 1);
    } else if (cw.getTimeLeft() > 0) {
      cw.activate(player, item);
      saveData(cw);
      announce(
          new SystemMessage(SystemMessage.THE_OWNER_OF_S2_HAS_APPEARED_IN_THE_S1_REGION)
              .addZoneName(player.getLoc())
              .addString(cw.getName()));
    } else {
      endOfLife(cw);
      player.getInventory().destroyItem(item, 1);
    }
  }
 public ExPutItemResultForVariationCancel(ItemInstance item) {
   _itemObjectId = item.getObjectId();
   _itemId = item.getId();
   _aug1 = 0x0000FFFF & item.getAugmentationId();
   _aug2 = item.getAugmentationId() >> 16;
   _price = RequestRefineCancel.getRemovalPrice(item.getTemplate());
 }
Ejemplo n.º 3
0
  /**
   * Method checkPlayer.
   *
   * @param player Player
   * @param item ItemInstance
   */
  public void checkPlayer(Player player, ItemInstance item) {
    if ((player == null) || (item == null) || player.isInOlympiadMode()) {
      return;
    }

    CursedWeapon cw = _cursedWeaponsMap.get(item.getId());

    if (cw == null) {
      return;
    }

    if ((player.getObjectId() == cw.getPlayerId()) || (cw.getPlayerId() == 0) || cw.isDropped()) {
      activate(player, item);
      showUsageTime(player, cw);
    } else {
      _log.warn("CursedWeaponsManager: " + player + " tried to obtain " + item + " in wrong way");
      player.getInventory().destroyItem(item, item.getCount());
    }
  }