/** * 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); }
/** * Increase the number of kills.<br> * In case actual counter reaches the number generated to reach next stage, than rank up the CW. */ public void increaseKills() { if (_player != null && _player.isOnline()) { _nbKills++; _hungryTime = _durationLost * 60; _player.setPkKills(_player.getPkKills() + 1); _player.sendPacket(new UserInfo(_player)); // If current number of kills is >= to the given number, than rankUp the weapon. if (_nbKills >= _numberBeforeNextStage) { // Reset the number of kills to 0. _nbKills = 0; // Setup the new random number. _numberBeforeNextStage = Rnd.get((int) Math.round(_stageKills * 0.5), (int) Math.round(_stageKills * 1.5)); // Rank up the CW. rankUp(); } } }
private void adminModifyCharacter(L2PcInstance activeChar, String modifications) { L2Object target = activeChar.getTarget(); if (!(target instanceof L2PcInstance)) return; L2PcInstance player = (L2PcInstance) target; StringTokenizer st = new StringTokenizer(modifications); if (st.countTokens() != 6) { editCharacter(player); return; } String hp = st.nextToken(); String mp = st.nextToken(); String cp = st.nextToken(); String pvpflag = st.nextToken(); String pvpkills = st.nextToken(); String pkkills = st.nextToken(); int hpval = Integer.parseInt(hp); int mpval = Integer.parseInt(mp); int cpval = Integer.parseInt(cp); int pvpflagval = Integer.parseInt(pvpflag); int pvpkillsval = Integer.parseInt(pvpkills); int pkkillsval = Integer.parseInt(pkkills); // Common character information L2CoreMessage cm = new L2CoreMessage(MessageTable.Messages[30]); cm.addNumber(hpval); cm.addNumber(mpval); cm.addNumber(cpval); cm.addNumber(pvpflagval); cm.addNumber(pvpkillsval); cm.addNumber(pkkillsval); cm.sendMessage(player); player.setCurrentHp(hpval); player.setCurrentMp(mpval); player.setCurrentCp(cpval); player.setPvpFlag(pvpflagval); player.setPvpKills(pvpkillsval); player.setPkKills(pkkillsval); // Save the changed parameters to the database. player.store(); StatusUpdate su = new StatusUpdate(player.getObjectId()); su.addAttribute(StatusUpdate.CUR_HP, hpval); su.addAttribute(StatusUpdate.MAX_HP, player.getMaxHp()); su.addAttribute(StatusUpdate.CUR_MP, mpval); su.addAttribute(StatusUpdate.MAX_MP, player.getMaxMp()); su.addAttribute(StatusUpdate.CUR_CP, cpval); su.addAttribute(StatusUpdate.MAX_CP, player.getMaxCp()); player.sendPacket(su); // Admin information cm = new L2CoreMessage(MessageTable.Messages[70]); cm.addString(player.getName()); cm.addNumber(hpval); cm.addNumber(mpval); cm.addNumber(cpval); cm.addNumber(pvpflagval); cm.addNumber(pvpkillsval); cm.addNumber(pkkillsval); cm.sendMessage(activeChar); if (Config.DEBUG) _log.fine( "[GM]" + activeChar.getName() + " changed stats of " + player.getName() + ". " + " HP: " + hpval + " MP: " + mpval + " CP: " + cpval + " PvP: " + pvpflagval + " / " + pvpkillsval); showCharacterInfo(activeChar, null); // Back to start player.broadcastPacket(new CharInfo(player)); player.sendPacket(new UserInfo(player)); player.broadcastPacket(new ExBrExtraUserInfo(player)); player.getAI().setIntention(CtrlIntention.AI_INTENTION_IDLE); player.decayMe(); player.spawnMe(activeChar.getX(), activeChar.getY(), activeChar.getZ()); }
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())); }
/** * This method is used to destroy a CW.<br> * It manages following states : * * <ul> * <li><u>item on a online player</u> : drops the CW from inventory, and set back ancient * pk/karma values. * <li><u>item on a offline player</u> : make SQL operations in order to drop item from * inventory. * <li><u>item on ground</u> : destroys the item directly. * </ul> * * For all cases, a message is broadcasted, and the different states are reinitialized. */ public void endOfLife() { if (_isActivated) { // Player is online ; unequip weapon && destroy it. if (_player != null && _player.isOnline()) { _log.info(_name + " being removed online."); _player.abortAttack(); _player.setKarma(_playerKarma); _player.setPkKills(_playerPkKills); _player.setCursedWeaponEquippedId(0); removeDemonicSkills(); // Unequip && remove. _player.useEquippableItem(_item, true); _player.destroyItemByItemId("CW", _itemId, 1, _player, false); _player.broadcastUserInfo(); _player.store(); } // Player is offline ; make only SQL operations. else { _log.info(_name + " being removed offline."); try (Connection con = L2DatabaseFactory.getInstance().getConnection()) { // Delete the item PreparedStatement statement = con.prepareStatement("DELETE FROM items WHERE owner_id=? AND item_id=?"); statement.setInt(1, _playerId); statement.setInt(2, _itemId); if (statement.executeUpdate() != 1) _log.warning("Error while deleting itemId " + _itemId + " from userId " + _playerId); statement.close(); // Restore the karma and PK kills. statement = con.prepareStatement("UPDATE characters SET karma=?, pkkills=? WHERE obj_id=?"); statement.setInt(1, _playerKarma); statement.setInt(2, _playerPkKills); statement.setInt(3, _playerId); if (statement.executeUpdate() != 1) _log.warning("Error while updating karma & pkkills for userId " + _playerId); statement.close(); } catch (Exception e) { _log.log(Level.WARNING, "Could not delete : " + e.getMessage(), e); } } } else { // This CW is in the inventory of someone who has another cursed weapon equipped. if (_player != null && _player.getInventory().getItemByItemId(_itemId) != null) { _player.destroyItemByItemId("CW", _itemId, 1, _player, false); _log.info(_name + " item has been assimilated."); } // This CW is on the ground. else if (_item != null) { _item.decayMe(); _log.info(_name + " item has been removed from world."); } } // Drop tasks. cancelDailyTimerTask(); cancelOverallTimerTask(); cancelDropTimerTask(); // Delete infos from table, if any. removeFromDb(); // Inform all ppl. Broadcast.toAllOnlinePlayers( SystemMessage.getSystemMessage(SystemMessageId.S1_HAS_DISAPPEARED).addItemName(_itemId)); // Reset state. _player = null; _item = null; _isActivated = false; _isDropped = false; _nbKills = 0; _currentStage = 1; _numberBeforeNextStage = 0; _hungryTime = 0; _endTime = 0; _playerId = 0; _playerKarma = 0; _playerPkKills = 0; }