/** Method clearMe. */
 private void clearMe() {
   HandysBlockCheckerManager.getInstance().clearPaticipantQueueByArenaId(_arena);
   for (Player player : _holder.getAllPlayers()) {
     if (player == null) {
       continue;
     }
     player.removeListener(_listener);
   }
   _holder.clearPlayers();
   _blueTeamPoints.clear();
   _redTeamPoints.clear();
   HandysBlockCheckerManager.getInstance().setArenaFree(_arena);
   for (SimpleSpawner spawn : _spawns) {
     spawn.deleteAll();
   }
   _spawns.clear();
   for (ItemInstance item : _drops) {
     if (item == null) {
       continue;
     }
     if (!item.isVisible() || (item.getOwnerId() != 0)) {
       continue;
     }
     item.deleteMe();
   }
   _drops.clear();
 }
 /** Method runImpl. */
 @Override
 protected final void runImpl() {
   final Player activeChar = getClient().getActiveChar();
   if (activeChar == null) {
     return;
   }
   ItemInstance adena = activeChar.getInventory().getItemByItemId(57);
   if ((_bid < 0) || (_bid > adena.getCount())) {
     return;
   }
   final ItemAuctionInstance instance =
       ItemAuctionManager.getInstance().getManagerInstance(_instanceId);
   NpcInstance broker = activeChar.getLastNpc();
   if ((broker == null)
       || (broker.getNpcId() != _instanceId)
       || (activeChar.getDistance(broker.getX(), broker.getY()) > Creature.INTERACTION_DISTANCE)) {
     return;
   }
   if (instance != null) {
     final ItemAuction auction = instance.getCurrentAuction();
     if (auction != null) {
       auction.registerBid(activeChar, _bid);
     }
   }
 }
  /**
   * 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());
 }
Example #5
0
 @Override
 public void dropItem(Player player, ItemInstance item, long count, Location loc) {
   if (item.isEquipped()) {
     player.getInventory().unEquipItem(item);
     player.sendUserInfo();
   }
   item = player.getInventory().removeItemByObjectId(item.getObjectId(), count);
   if (item == null) {
     player.sendActionFailed();
     return;
   }
   Log.LogItem(player, Log.Drop, item);
   item.dropToTheGround(player, loc);
   player.disableDrop(1000);
   player.sendChanges();
 }
  /**
   * 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());
    }
  }
Example #7
0
 /**
  * Method useVoicedCommand.
  *
  * @param command String
  * @param player Player
  * @param args String
  * @return boolean * @see
  *     lineage2.gameserver.handler.voicecommands.IVoicedCommandHandler#useVoicedCommand(String,
  *     Player, String)
  */
 @Override
 public boolean useVoicedCommand(String command, Player player, String args) {
   Creature target = null;
   double hpRegen = Formulas.calcHpRegen(player);
   double cpRegen = Formulas.calcCpRegen(player);
   double mpRegen = Formulas.calcMpRegen(player);
   double hpDrain = player.calcStat(Stats.ABSORB_DAMAGE_PERCENT, 0., target, null);
   double mpDrain = player.calcStat(Stats.ABSORB_DAMAGEMP_PERCENT, 0., target, null);
   double hpGain = player.calcStat(Stats.HEAL_EFFECTIVNESS, 100., target, null);
   double mpGain = player.calcStat(Stats.MANAHEAL_EFFECTIVNESS, 100., target, null);
   double critPerc = 2 * player.calcStat(Stats.CRITICAL_DAMAGE, target, null);
   double critStatic = player.calcStat(Stats.CRITICAL_DAMAGE_STATIC, target, null);
   double mCritDmg = player.calcStat(Stats.MCRITICAL_DAMAGE, target, null);
   double blowRate = player.calcStat(Stats.FATALBLOW_RATE, target, null);
   ItemInstance shld = player.getSecondaryWeaponInstance();
   boolean shield = (shld != null) && (shld.getItemType() == WeaponType.NONE);
   double shieldDef =
       shield
           ? player.calcStat(
               Stats.SHIELD_DEFENCE, player.getTemplate().getBaseShldDef(), target, null)
           : 0.;
   double shieldRate = shield ? player.calcStat(Stats.SHIELD_RATE, target, null) : 0.;
   double xpRate = player.getRateExp();
   double spRate = player.getRateSp();
   double dropRate = player.getRateItems();
   double adenaRate = player.getRateAdena();
   double spoilRate = player.getRateSpoil();
   double fireResist = player.calcStat(Element.FIRE.getDefence(), 0., target, null);
   double windResist = player.calcStat(Element.WIND.getDefence(), 0., target, null);
   double waterResist = player.calcStat(Element.WATER.getDefence(), 0., target, null);
   double earthResist = player.calcStat(Element.EARTH.getDefence(), 0., target, null);
   double holyResist = player.calcStat(Element.HOLY.getDefence(), 0., target, null);
   double unholyResist = player.calcStat(Element.UNHOLY.getDefence(), 0., target, null);
   double bleedPower = player.calcStat(Stats.BLEED_POWER, target, null);
   double bleedResist = player.calcStat(Stats.BLEED_RESIST, target, null);
   double poisonPower = player.calcStat(Stats.POISON_POWER, target, null);
   double poisonResist = player.calcStat(Stats.POISON_RESIST, target, null);
   double stunPower = player.calcStat(Stats.STUN_POWER, target, null);
   double stunResist = player.calcStat(Stats.STUN_RESIST, target, null);
   double rootPower = player.calcStat(Stats.ROOT_POWER, target, null);
   double rootResist = player.calcStat(Stats.ROOT_RESIST, target, null);
   double sleepPower = player.calcStat(Stats.SLEEP_POWER, target, null);
   double sleepResist = player.calcStat(Stats.SLEEP_RESIST, target, null);
   double paralyzePower = player.calcStat(Stats.PARALYZE_POWER, target, null);
   double paralyzeResist = player.calcStat(Stats.PARALYZE_RESIST, target, null);
   double mentalPower = player.calcStat(Stats.MENTAL_POWER, target, null);
   double mentalResist = player.calcStat(Stats.MENTAL_RESIST, target, null);
   double debuffPower = player.calcStat(Stats.DEBUFF_POWER, target, null);
   double debuffResist = player.calcStat(Stats.DEBUFF_RESIST, target, null);
   double cancelPower = player.calcStat(Stats.CANCEL_POWER, target, null);
   double cancelResist = player.calcStat(Stats.CANCEL_RESIST, target, null);
   double swordResist = 100. - player.calcStat(Stats.SWORD_WPN_VULNERABILITY, target, null);
   double dualResist = 100. - player.calcStat(Stats.DUAL_WPN_VULNERABILITY, target, null);
   double bluntResist = 100. - player.calcStat(Stats.BLUNT_WPN_VULNERABILITY, target, null);
   double daggerResist = 100. - player.calcStat(Stats.DAGGER_WPN_VULNERABILITY, target, null);
   double bowResist = 100. - player.calcStat(Stats.BOW_WPN_VULNERABILITY, target, null);
   double crossbowResist = 100. - player.calcStat(Stats.CROSSBOW_WPN_VULNERABILITY, target, null);
   double poleResist = 100. - player.calcStat(Stats.POLE_WPN_VULNERABILITY, target, null);
   double fistResist = 100. - player.calcStat(Stats.FIST_WPN_VULNERABILITY, target, null);
   double critChanceResist = 100. - player.calcStat(Stats.CRIT_CHANCE_RECEPTIVE, target, null);
   double critDamResistStatic = player.calcStat(Stats.CRIT_DAMAGE_RECEPTIVE, target, null);
   double critDamResist =
       100.
           - (100
               * (player.calcStat(Stats.CRIT_DAMAGE_RECEPTIVE, 1., target, null)
                   - critDamResistStatic));
   String dialog = HtmCache.getInstance().getNotNull("command/whoami.htm", player);
   NumberFormat df = NumberFormat.getInstance(Locale.ENGLISH);
   df.setMaximumFractionDigits(1);
   df.setMinimumFractionDigits(1);
   StrBuilder sb = new StrBuilder(dialog);
   sb.replaceFirst("%hpRegen%", df.format(hpRegen));
   sb.replaceFirst("%cpRegen%", df.format(cpRegen));
   sb.replaceFirst("%mpRegen%", df.format(mpRegen));
   sb.replaceFirst("%hpDrain%", df.format(hpDrain));
   sb.replaceFirst("%mpDrain%", df.format(mpDrain));
   sb.replaceFirst("%hpGain%", df.format(hpGain));
   sb.replaceFirst("%mpGain%", df.format(mpGain));
   sb.replaceFirst("%critPerc%", df.format(critPerc));
   sb.replaceFirst("%critStatic%", df.format(critStatic));
   sb.replaceFirst("%mCritDmg%", df.format(mCritDmg));
   sb.replaceFirst("%blowRate%", df.format(blowRate));
   sb.replaceFirst("%shieldDef%", df.format(shieldDef));
   sb.replaceFirst("%shieldRate%", df.format(shieldRate));
   sb.replaceFirst("%xpRate%", df.format(xpRate));
   sb.replaceFirst("%spRate%", df.format(spRate));
   sb.replaceFirst("%dropRate%", df.format(dropRate));
   sb.replaceFirst("%adenaRate%", df.format(adenaRate));
   sb.replaceFirst("%spoilRate%", df.format(spoilRate));
   sb.replaceFirst("%fireResist%", df.format(fireResist));
   sb.replaceFirst("%windResist%", df.format(windResist));
   sb.replaceFirst("%waterResist%", df.format(waterResist));
   sb.replaceFirst("%earthResist%", df.format(earthResist));
   sb.replaceFirst("%holyResist%", df.format(holyResist));
   sb.replaceFirst("%darkResist%", df.format(unholyResist));
   sb.replaceFirst("%bleedPower%", df.format(bleedPower));
   sb.replaceFirst("%bleedResist%", df.format(bleedResist));
   sb.replaceFirst("%poisonPower%", df.format(poisonPower));
   sb.replaceFirst("%poisonResist%", df.format(poisonResist));
   sb.replaceFirst("%stunPower%", df.format(stunPower));
   sb.replaceFirst("%stunResist%", df.format(stunResist));
   sb.replaceFirst("%rootPower%", df.format(rootPower));
   sb.replaceFirst("%rootResist%", df.format(rootResist));
   sb.replaceFirst("%sleepPower%", df.format(sleepPower));
   sb.replaceFirst("%sleepResist%", df.format(sleepResist));
   sb.replaceFirst("%paralyzePower%", df.format(paralyzePower));
   sb.replaceFirst("%paralyzeResist%", df.format(paralyzeResist));
   sb.replaceFirst("%mentalPower%", df.format(mentalPower));
   sb.replaceFirst("%mentalResist%", df.format(mentalResist));
   sb.replaceFirst("%debuffPower%", df.format(debuffPower));
   sb.replaceFirst("%debuffResist%", df.format(debuffResist));
   sb.replaceFirst("%cancelPower%", df.format(cancelPower));
   sb.replaceFirst("%cancelResist%", df.format(cancelResist));
   sb.replaceFirst("%swordResist%", df.format(swordResist));
   sb.replaceFirst("%dualResist%", df.format(dualResist));
   sb.replaceFirst("%bluntResist%", df.format(bluntResist));
   sb.replaceFirst("%daggerResist%", df.format(daggerResist));
   sb.replaceFirst("%bowResist%", df.format(bowResist));
   sb.replaceFirst("%crossbowResist%", df.format(crossbowResist));
   sb.replaceFirst("%fistResist%", df.format(fistResist));
   sb.replaceFirst("%poleResist%", df.format(poleResist));
   sb.replaceFirst("%critChanceResist%", df.format(critChanceResist));
   sb.replaceFirst("%critDamResist%", df.format(critDamResist));
   NpcHtmlMessage msg = new NpcHtmlMessage(0);
   msg.setHtml(Strings.bbParse(sb.toString()));
   player.sendPacket(msg);
   return true;
 }