/** * @param activeChar * @param player */ private void gatherCharacterInfo(L2PcInstance activeChar, L2PcInstance player, String filename) { String ip = "N/A"; String account = "N/A"; try { String clientInfo = player.getClient().toString(); account = clientInfo.substring(clientInfo.indexOf("Account: ") + 9, clientInfo.indexOf(" - IP: ")); ip = clientInfo.substring(clientInfo.indexOf(" - IP: ") + 7, clientInfo.lastIndexOf("]")); } catch (Exception e) { } NpcHtmlMessage adminReply = new NpcHtmlMessage(5); adminReply.setFile("data/html/admin/" + filename); adminReply.replace("%name%", player.getName()); adminReply.replace("%level%", String.valueOf(player.getLevel())); adminReply.replace( "%clan%", String.valueOf(ClanTable.getInstance().getClan(player.getClanId()))); adminReply.replace("%xp%", String.valueOf(player.getExp())); adminReply.replace("%sp%", String.valueOf(player.getSp())); adminReply.replace("%class%", player.getTemplate().className); adminReply.replace("%ordinal%", String.valueOf(player.getClassId().ordinal())); adminReply.replace("%classid%", String.valueOf(player.getClassId())); adminReply.replace("%x%", String.valueOf(player.getX())); adminReply.replace("%y%", String.valueOf(player.getY())); adminReply.replace("%z%", String.valueOf(player.getZ())); adminReply.replace("%currenthp%", String.valueOf((int) player.getCurrentHp())); adminReply.replace("%maxhp%", String.valueOf(player.getMaxHp())); adminReply.replace("%karma%", String.valueOf(player.getKarma())); adminReply.replace("%currentmp%", String.valueOf((int) player.getCurrentMp())); adminReply.replace("%maxmp%", String.valueOf(player.getMaxMp())); adminReply.replace("%pvpflag%", String.valueOf(player.getPvpFlag())); adminReply.replace("%currentcp%", String.valueOf((int) player.getCurrentCp())); adminReply.replace("%maxcp%", String.valueOf(player.getMaxCp())); adminReply.replace("%pvpkills%", String.valueOf(player.getPvpKills())); adminReply.replace("%pkkills%", String.valueOf(player.getPkKills())); adminReply.replace("%currentload%", String.valueOf(player.getCurrentLoad())); adminReply.replace("%maxload%", String.valueOf(player.getMaxLoad())); adminReply.replace( "%percent%", String.valueOf( Util.roundTo( ((float) player.getCurrentLoad() / (float) player.getMaxLoad()) * 100, 2))); adminReply.replace("%patk%", String.valueOf(player.getPAtk(null))); adminReply.replace("%matk%", String.valueOf(player.getMAtk(null, null))); adminReply.replace("%pdef%", String.valueOf(player.getPDef(null))); adminReply.replace("%mdef%", String.valueOf(player.getMDef(null, null))); adminReply.replace("%accuracy%", String.valueOf(player.getAccuracy())); adminReply.replace("%evasion%", String.valueOf(player.getEvasionRate(null))); adminReply.replace("%critical%", String.valueOf(player.getCriticalHit(null, null))); adminReply.replace("%runspeed%", String.valueOf(player.getRunSpeed())); adminReply.replace("%patkspd%", String.valueOf(player.getPAtkSpd())); adminReply.replace("%matkspd%", String.valueOf(player.getMAtkSpd())); adminReply.replace("%access%", String.valueOf(player.getAccessLevel().getLevel())); adminReply.replace("%account%", account); adminReply.replace("%ip%", ip); activeChar.sendPacket(adminReply); }
private void setTargetKarma(L2PcInstance activeChar, int newKarma) { // function to change karma of selected char L2Object target = activeChar.getTarget(); L2PcInstance player = null; if (target instanceof L2PcInstance) player = (L2PcInstance) target; else return; if (newKarma >= 0) { // for display int oldKarma = player.getKarma(); // update karma player.setKarma(newKarma); // Common character information player.sendPacket( new SystemMessage(SystemMessageId.YOUR_KARMA_HAS_BEEN_CHANGED_TO) .addString(String.valueOf(newKarma))); // Admin information L2CoreMessage cm = new L2CoreMessage(MessageTable.Messages[275]); cm.addString(player.getName()); cm.addNumber(oldKarma); cm.addNumber(newKarma); cm.sendMessage(activeChar); if (Config.DEBUG) _log.fine( "[SET KARMA] [GM]" + activeChar.getName() + " Changed karma for " + player.getName() + " from (" + oldKarma + ") to (" + newKarma + ")."); } else { // tell admin of mistake activeChar.sendMessage(569); if (Config.DEBUG) _log.fine( "[SET KARMA] ERROR: [GM]" + activeChar.getName() + " entered an incorrect value for new karma: " + newKarma + " for " + player.getName() + "."); } }
@Override protected void runImpl() { if (_items == null || _items.isEmpty() || !Config.ALLOW_FREIGHT) return; final L2PcInstance player = getClient().getActiveChar(); if (player == null) return; // player attempts to send freight to the different account if (!player.getAccountChars().containsKey(_objectID)) return; final PcFreight freight = player.getDepositedFreight(_objectID); player.setActiveWarehouse(freight); final ItemContainer warehouse = player.getActiveWarehouse(); if (warehouse == null) return; final L2Npc manager = player.getCurrentFolkNPC(); if ((manager == null || !player.isInsideRadius(manager, L2Npc.INTERACTION_DISTANCE, false, false)) && !player.isGM()) return; if (warehouse instanceof PcFreight && !player.getAccessLevel().allowTransaction()) { player.sendMessage("Transactions are disabled for your Access Level."); return; } // Alt game - Karma punishment if (!Config.KARMA_PLAYER_CAN_USE_WH && player.getKarma() > 0) return; // Freight price from config or normal price per item slot (30) int fee = _items.size() * Config.ALT_GAME_FREIGHT_PRICE; int currentAdena = player.getAdena(); int slots = 0; for (Item i : _items) { int objectId = i.id; int count = i.count; // Check validity of requested item ItemInstance item = player.checkItemManipulation(objectId, count); if (item == null) { _log.warning( "Error depositing a warehouse object for char " + player.getName() + " (validity check)"); i.id = 0; i.count = 0; continue; } if (!item.isTradable() || item.isQuestItem()) return; // Calculate needed adena and slots if (item.getItemId() == 57) currentAdena -= count; if (!item.isStackable()) slots += count; else if (warehouse.getItemByItemId(item.getItemId()) == null) slots++; } // Item Max Limit Check if (!warehouse.validateCapacity(slots)) { sendPacket( SystemMessage.getSystemMessage( SystemMessageId.YOU_HAVE_EXCEEDED_QUANTITY_THAT_CAN_BE_INPUTTED)); return; } // Check if enough adena and charge the fee if (currentAdena < fee || !player.reduceAdena("Warehouse", fee, player.getCurrentFolkNPC(), false)) { sendPacket(SystemMessage.getSystemMessage(SystemMessageId.YOU_NOT_ENOUGH_ADENA)); return; } // Proceed to the transfer InventoryUpdate playerIU = new InventoryUpdate(); for (Item i : _items) { int objectId = i.id; int count = i.count; // check for an invalid item if (objectId == 0 && count == 0) continue; ItemInstance oldItem = player.getInventory().getItemByObjectId(objectId); if (oldItem == null) { _log.warning( "Error depositing a warehouse object for char " + player.getName() + " (olditem == null)"); continue; } if (oldItem.isHeroItem()) continue; ItemInstance newItem = player .getInventory() .transferItem( "Warehouse", objectId, count, warehouse, player, player.getCurrentFolkNPC()); if (newItem == null) { _log.warning( "Error depositing a warehouse object for char " + player.getName() + " (newitem == null)"); continue; } if (oldItem.getCount() > 0 && oldItem != newItem) playerIU.addModifiedItem(oldItem); else playerIU.addRemovedItem(oldItem); } // Send updated item list to the player player.sendPacket(playerIU); // Update current load status on player StatusUpdate su = new StatusUpdate(player); su.addAttribute(StatusUpdate.CUR_LOAD, player.getCurrentLoad()); player.sendPacket(su); }
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())); }
@Override protected void runImpl() { if (_items == null) return; final L2PcInstance player = getClient().getActiveChar(); if (player == null) return; if (player.isProcessingTransaction()) { player.sendPacket(SystemMessageId.ALREADY_TRADING); return; } if (player.getActiveEnchantItem() != null) { player.setActiveEnchantItem(null); player.sendPacket(EnchantResult.CANCELLED); player.sendPacket(SystemMessageId.ENCHANT_SCROLL_CANCELLED); } final ItemContainer warehouse = player.getActiveWarehouse(); if (warehouse == null) return; final boolean isPrivate = warehouse instanceof PcWarehouse; final L2Npc manager = player.getCurrentFolkNPC(); if ((manager == null || !manager.isWarehouse() || !manager.canInteract(player)) && !player.isGM()) return; if (!isPrivate && !player.getAccessLevel().allowTransaction()) { player.sendMessage("Transactions are disabled for your Access Level."); return; } // Alt game - Karma punishment if (!Config.KARMA_PLAYER_CAN_USE_WH && player.getKarma() > 0) return; // Freight price from config or normal price per item slot (30) final int fee = _items.length * 30; int currentAdena = player.getAdena(); int slots = 0; for (WarehouseItem i : _items) { ItemInstance item = player.checkItemManipulation(i.getObjectId(), i.getCount()); if (item == null) { _log.warning( "Error depositing a warehouse object for char " + player.getName() + " (validity check)"); return; } // Calculate needed adena and slots if (item.getItemId() == ADENA_ID) currentAdena -= i.getCount(); if (!item.isStackable()) slots += i.getCount(); else if (warehouse.getItemByItemId(item.getItemId()) == null) slots++; } // Item Max Limit Check if (!warehouse.validateCapacity(slots)) { sendPacket( SystemMessage.getSystemMessage( SystemMessageId.YOU_HAVE_EXCEEDED_QUANTITY_THAT_CAN_BE_INPUTTED)); return; } // Check if enough adena and charge the fee if (currentAdena < fee || !player.reduceAdena(warehouse.getName(), fee, manager, false)) { sendPacket(SystemMessage.getSystemMessage(SystemMessageId.YOU_NOT_ENOUGH_ADENA)); return; } // get current tradelist if any if (player.getActiveTradeList() != null) return; // Proceed to the transfer InventoryUpdate playerIU = new InventoryUpdate(); for (WarehouseItem i : _items) { // Check validity of requested item ItemInstance oldItem = player.checkItemManipulation(i.getObjectId(), i.getCount()); if (oldItem == null) { _log.warning( "Error depositing a warehouse object for char " + player.getName() + " (olditem == null)"); return; } if (!oldItem.isDepositable(isPrivate) || !oldItem.isAvailable(player, true, isPrivate)) continue; final ItemInstance newItem = player .getInventory() .transferItem( warehouse.getName(), i.getObjectId(), i.getCount(), warehouse, player, manager); if (newItem == null) { _log.warning( "Error depositing a warehouse object for char " + player.getName() + " (newitem == null)"); continue; } if (oldItem.getCount() > 0 && oldItem != newItem) playerIU.addModifiedItem(oldItem); else playerIU.addRemovedItem(oldItem); } // Send updated item list to the player player.sendPacket(playerIU); // Update current load status on player StatusUpdate su = new StatusUpdate(player); su.addAttribute(StatusUpdate.CUR_LOAD, player.getCurrentLoad()); player.sendPacket(su); }
@Override public String onFirstTalk(L2Npc npc, L2PcInstance player) { String htmltext = getNoQuestMsg(); QuestState st = player.getQuestState(qn); if (st == null) st = newQuestState(player); final int allianceLevel = player.getAllianceWithVarkaKetra(); switch (npc.getNpcId()) { case KADUN: if (allianceLevel > 0) htmltext = "31370-friend.htm"; else htmltext = "31370-no.htm"; break; case WAHKAN: if (allianceLevel > 0) htmltext = "31371-friend.htm"; else htmltext = "31371-no.htm"; break; case ASEFA: st.setState(STATE_STARTED); if (allianceLevel < 1) htmltext = "31372-3.htm"; else if (allianceLevel < 3 && allianceLevel > 0) htmltext = "31372-1.htm"; else if (allianceLevel > 2) { if (st.hasQuestItems(HORN)) htmltext = "31372-4.htm"; else htmltext = "31372-2.htm"; } break; case ATAN: if (player.getKarma() >= 1) htmltext = "31373-pk.htm"; else if (allianceLevel <= 0) htmltext = "31373-no.htm"; else if (allianceLevel == 1 || allianceLevel == 2) htmltext = "31373-1.htm"; else htmltext = "31373-2.htm"; break; case JAFF: switch (allianceLevel) { case 1: htmltext = "31374-1.htm"; break; case 2: case 3: htmltext = "31374-2.htm"; break; default: if (allianceLevel <= 0) htmltext = "31374-no.htm"; else if (player.getWarehouse().getSize() == 0) htmltext = "31374-3.htm"; else htmltext = "31374-4.htm"; break; } break; case JUMARA: switch (allianceLevel) { case 2: htmltext = "31375-1.htm"; break; case 3: case 4: htmltext = "31375-2.htm"; break; case 5: htmltext = "31375-3.htm"; break; default: htmltext = "31375-no.htm"; break; } break; case KURFA: if (allianceLevel <= 0) htmltext = "31376-no.htm"; else if (allianceLevel > 0 && allianceLevel < 4) htmltext = "31376-1.htm"; else if (allianceLevel == 4) htmltext = "31376-2.htm"; else htmltext = "31376-3.htm"; break; } return htmltext; }