Beispiel #1
0
  /**
   * This method is used to drop the CW from player.<br>
   * It drops the item on ground, and reset player stats.
   *
   * @param killer : The player who killed CW owner.
   */
  private void dropFromPlayer(L2Character killer) {
    _player.abortAttack();

    // Prevent item from being removed by ItemsAutoDestroy
    _item.setDestroyProtected(true);
    _player.dropItem("DieDrop", _item, killer, true);

    _isActivated = false;
    _isDropped = true;

    _player.setKarma(_playerKarma);
    _player.setPkKills(_playerPkKills);
    _player.setCursedWeaponEquippedId(0);
    removeDemonicSkills();

    // Cancel the daily timer. It will be reactivated when someone will pickup the weapon.
    cancelDailyTimerTask();

    // Activate the "1h dropped CW" timer.
    _dropTimerTask = ThreadPoolManager.getInstance().scheduleGeneral(new DropTimerTask(), 3600000L);

    // Reset current stage to 1.
    _currentStage = 1;

    // Drop infos from database.
    removeFromDb();

    SystemMessage sm =
        SystemMessage.getSystemMessage(SystemMessageId.S2_WAS_DROPPED_IN_THE_S1_REGION);
    sm.addZoneName(_player.getX(), _player.getY(), _player.getZ());
    sm.addItemName(_itemId);

    Broadcast.toAllOnlinePlayers(sm);
  }
Beispiel #2
0
  public void activate(L2PcInstance player, ItemInstance item) {
    // if the player is mounted, attempt to unmount first and pick it if successful.
    if (player.isMounted() && !player.dismount()) {
      player.sendPacket(
          SystemMessage.getSystemMessage(SystemMessageId.FAILED_TO_PICKUP_S1)
              .addItemName(item.getItemId()));
      item.setDestroyProtected(true);
      player.dropItem("InvDrop", item, null, true);
      return;
    }

    _isActivated = true;

    // Hold player data.
    _player = player;
    _playerId = _player.getObjectId();
    _playerKarma = _player.getKarma();
    _playerPkKills = _player.getPkKills();

    _item = item;

    // Generate a random number for next stage.
    _numberBeforeNextStage =
        Rnd.get((int) Math.round(_stageKills * 0.5), (int) Math.round(_stageKills * 1.5));

    // Renew hungry time.
    _hungryTime = _durationLost * 60;

    // Activate the daily timer.
    _dailyTimerTask =
        ThreadPoolManager.getInstance()
            .scheduleGeneralAtFixedRate(new DailyTimerTask(), 60000L, 60000L);

    // Cancel the "1h dropped CW" timer.
    cancelDropTimerTask();

    insertData();

    // Change player stats
    _player.setCursedWeaponEquippedId(_itemId);
    _player.setKarma(9999999);
    _player.setPkKills(0);

    if (_player.isInParty()) _player.getParty().removePartyMember(_player, MessageType.Expelled);

    // Disable active toggles
    for (L2Effect effect : _player.getAllEffects()) {
      if (effect.getSkill().isToggle()) effect.exit();
    }

    // Add CW skills
    giveDemonicSkills();

    // Equip the weapon
    _player.useEquippableItem(_item, true);

    // Fully heal player
    _player.setCurrentHpMp(_player.getMaxHp(), _player.getMaxMp());
    _player.setCurrentCp(_player.getMaxCp());

    // Refresh player stats
    _player.broadcastUserInfo();

    // _player.broadcastPacket(new SocialAction(_player, 17));
    Broadcast.toAllOnlinePlayers(
        SystemMessage.getSystemMessage(
                SystemMessageId.THE_OWNER_OF_S2_HAS_APPEARED_IN_THE_S1_REGION)
            .addZoneName(_player.getX(), _player.getY(), _player.getZ())
            .addItemName(_item.getItemId()));
  }