public static void removeById( final MapleClient c, final MapleInventoryType type, final int Id, final int quantity, final boolean fromDrop, final boolean consume) { List<IItem> items = c.getPlayer().getInventory(type).listById(Id); int remremove = quantity; for (IItem item : items) { if (remremove <= item.getQuantity()) { removeFromSlot(c, type, item.getPosition(), (short) remremove, fromDrop, consume); remremove = 0; break; } else { remremove -= item.getQuantity(); removeFromSlot(c, type, item.getPosition(), item.getQuantity(), fromDrop, consume); } } if (remremove > 0) { throw new RuntimeException( "[h4x] Not enough items available (" + Id + ", " + (quantity - remremove) + "/" + quantity + ")"); } }
public static void removeFromSlot( final MapleClient c, final MapleInventoryType type, final short slot, final short quantity, final boolean fromDrop, final boolean consume) { final IItem item = c.getPlayer().getInventory(type).getItem(slot); final boolean allowZero = consume && InventoryConstants.isRechargable(item.getId()); c.getPlayer().getInventory(type).removeItem(slot, quantity, allowZero); if (item.getQuantity() == 0 && !allowZero) { c.announce(InventoryFactory.clearInventoryItem(type, item.getPosition(), fromDrop)); } else { c.announce(InventoryFactory.updateInventorySlot(type, (Item) item, fromDrop)); } }
public final void handlePacket(SeekableLittleEndianAccessor slea, MapleClient c) { if (!c.getPlayer().getCashShop().isOpened()) { return; } if (slea.available() > 0) { byte op = slea.readByte(); if (op == 2) { // put item up for sale byte itemtype = slea.readByte(); int itemid = slea.readInt(); slea.readShort(); slea.skip(7); short stars = 1; if (itemtype == 1) { slea.skip(32); } else { stars = slea.readShort(); } slea.readMapleAsciiString(); // another useless thing (owner) if (itemtype == 1) { slea.skip(32); } else { slea.readShort(); } byte slot = 1; short quantity = 1; if (itemtype != 1) { if (itemid / 10000 == 207 || itemid / 10000 == 233) { slea.skip(8); } slot = (byte) slea.readInt(); } else { slot = (byte) slea.readInt(); } if (itemtype != 1) { if (itemid / 10000 == 207 || itemid / 10000 == 233) { quantity = stars; slea.skip(4); } else { quantity = (short) slea.readInt(); } } else { quantity = (byte) slea.readInt(); } int price = slea.readInt(); if (itemtype == 1) { quantity = 1; } if (quantity < 0 || price < 110 || c.getPlayer().getItemQuantity(itemid, false) < quantity) { return; } MapleInventoryType type = MapleItemInformationProvider.getInstance().getInventoryType(itemid); IItem i = c.getPlayer().getInventory(type).getItem(slot).copy(); if (i != null && c.getPlayer().getMeso() >= 5000) { Connection con = DatabaseConnection.getConnection(); try { PreparedStatement ps = con.prepareStatement("SELECT COUNT(*) FROM mts_items WHERE seller = ?"); ps.setInt(1, c.getPlayer().getId()); ResultSet rs = ps.executeQuery(); if (rs.next()) { if (rs.getInt(1) > 10) { // They have more than 10 // items up for sale // already! c.getPlayer().dropMessage(1, "You already have 10 items up for auction!"); c.announce(getMTS(1, 0, 0)); c.announce( MaplePacketCreator.transferInventory(getTransfer(c.getPlayer().getId()))); c.announce(MaplePacketCreator.notYetSoldInv(getNotYetSold(c.getPlayer().getId()))); rs.close(); ps.close(); return; } } rs.close(); ps.close(); Calendar calendar = Calendar.getInstance(); int year = 2008; int month = 6; int day = 17; int oldmax = calendar.getActualMaximum(Calendar.DAY_OF_MONTH); int oldday = calendar.get(Calendar.DAY_OF_MONTH) + 7; if (oldmax < oldday) { if (calendar.get(Calendar.MONTH) + 2 > 12) { year = calendar.get(Calendar.YEAR) + 1; month = 1; calendar.set(year, month, 1); day = oldday - oldmax; } else { month = calendar.get(Calendar.MONTH) + 2; year = calendar.get(Calendar.YEAR); calendar.set(year, month, 1); day = oldday - oldmax; } } else { day = calendar.get(Calendar.DAY_OF_MONTH) + 7; month = calendar.get(Calendar.MONTH); year = calendar.get(Calendar.YEAR); } String date = year + "-"; if (month < 10) { date += "0" + month + "-"; } else { date += month + "-"; } if (day < 10) { date += "0" + day; } else { date += day + ""; } if (i.getType() == 2) { Item item = (Item) i; ps = con.prepareStatement( "INSERT INTO mts_items (tab, type, itemid, quantity, seller, price, owner, sellername, sell_ends) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)"); ps.setInt(1, 1); ps.setInt(2, (int) type.getType()); ps.setInt(3, item.getItemId()); ps.setInt(4, quantity); ps.setInt(5, c.getPlayer().getId()); ps.setInt(6, price); ps.setString(7, item.getOwner()); ps.setString(8, c.getPlayer().getName()); ps.setString(9, date); } else { Equip equip = (Equip) i; ps = con.prepareStatement( "INSERT INTO mts_items (tab, type, itemid, quantity, seller, price, upgradeslots, level, str, dex, `int`, luk, hp, mp, watk, matk, wdef, mdef, acc, avoid, hands, speed, jump, locked, owner, sellername, sell_ends, vicious, flag) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"); ps.setInt(1, 1); ps.setInt(2, (int) type.getType()); ps.setInt(3, equip.getItemId()); ps.setInt(4, quantity); ps.setInt(5, c.getPlayer().getId()); ps.setInt(6, price); ps.setInt(7, equip.getUpgradeSlots()); ps.setInt(8, equip.getLevel()); ps.setInt(9, equip.getStr()); ps.setInt(10, equip.getDex()); ps.setInt(11, equip.getInt()); ps.setInt(12, equip.getLuk()); ps.setInt(13, equip.getHp()); ps.setInt(14, equip.getMp()); ps.setInt(15, equip.getWatk()); ps.setInt(16, equip.getMatk()); ps.setInt(17, equip.getWdef()); ps.setInt(18, equip.getMdef()); ps.setInt(19, equip.getAcc()); ps.setInt(20, equip.getAvoid()); ps.setInt(21, equip.getHands()); ps.setInt(22, equip.getSpeed()); ps.setInt(23, equip.getJump()); ps.setInt(24, 0); ps.setString(25, equip.getOwner()); ps.setString(26, c.getPlayer().getName()); ps.setString(27, date); ps.setInt(28, equip.getVicious()); ps.setInt(29, equip.getFlag()); } ps.executeUpdate(); ps.close(); MapleInventoryManipulator.removeFromSlot(c, type, slot, quantity, false); } catch (SQLException e) { } c.getPlayer().gainMeso(-5000, false); c.announce(MaplePacketCreator.MTSConfirmSell()); c.announce(getMTS(1, 0, 0)); c.announce(MaplePacketCreator.enableCSUse()); c.announce(MaplePacketCreator.transferInventory(getTransfer(c.getPlayer().getId()))); c.announce(MaplePacketCreator.notYetSoldInv(getNotYetSold(c.getPlayer().getId()))); } } else if (op == 3) { // send offer for wanted item } else if (op == 4) { // list wanted item slea.readInt(); slea.readInt(); slea.readInt(); slea.readShort(); slea.readMapleAsciiString(); } else if (op == 5) { // change page int tab = slea.readInt(); int type = slea.readInt(); int page = slea.readInt(); c.getPlayer().changePage(page); if (tab == 4 && type == 0) { c.announce(getCart(c.getPlayer().getId())); } else if (tab == c.getPlayer().getCurrentTab() && type == c.getPlayer().getCurrentType() && c.getPlayer().getSearch() != null) { c.announce( getMTSSearch( tab, type, c.getPlayer().getCurrentCI(), c.getPlayer().getSearch(), page)); } else { c.getPlayer().setSearch(null); c.announce(getMTS(tab, type, page)); } c.getPlayer().changeTab(tab); c.getPlayer().changeType(type); c.announce(MaplePacketCreator.enableCSUse()); c.announce(MaplePacketCreator.transferInventory(getTransfer(c.getPlayer().getId()))); c.announce(MaplePacketCreator.notYetSoldInv(getNotYetSold(c.getPlayer().getId()))); } else if (op == 6) { // search int tab = slea.readInt(); int type = slea.readInt(); slea.readInt(); int ci = slea.readInt(); String search = slea.readMapleAsciiString(); c.getPlayer().setSearch(search); c.getPlayer().changeTab(tab); c.getPlayer().changeType(type); c.getPlayer().changeCI(ci); c.announce(MaplePacketCreator.enableCSUse()); c.announce(MaplePacketCreator.enableActions()); c.announce(getMTSSearch(tab, type, ci, search, c.getPlayer().getCurrentPage())); c.announce(MaplePacketCreator.showMTSCash(c.getPlayer())); c.announce(MaplePacketCreator.transferInventory(getTransfer(c.getPlayer().getId()))); c.announce(MaplePacketCreator.notYetSoldInv(getNotYetSold(c.getPlayer().getId()))); } else if (op == 7) { // cancel sale int id = slea.readInt(); // id of the item Connection con = DatabaseConnection.getConnection(); try { PreparedStatement ps = con.prepareStatement("UPDATE mts_items SET transfer = 1 WHERE id = ? AND seller = ?"); ps.setInt(1, id); ps.setInt(2, c.getPlayer().getId()); ps.executeUpdate(); ps.close(); ps = con.prepareStatement("DELETE FROM mts_cart WHERE itemid = ?"); ps.setInt(1, id); ps.executeUpdate(); ps.close(); } catch (SQLException e) { e.printStackTrace(); } c.announce(MaplePacketCreator.enableCSUse()); c.announce( getMTS( c.getPlayer().getCurrentTab(), c.getPlayer().getCurrentType(), c.getPlayer().getCurrentPage())); c.announce(MaplePacketCreator.notYetSoldInv(getNotYetSold(c.getPlayer().getId()))); c.announce(MaplePacketCreator.transferInventory(getTransfer(c.getPlayer().getId()))); } else if (op == 8) { // transfer item from transfer inv. int id = slea.readInt(); // id of the item Connection con = DatabaseConnection.getConnection(); PreparedStatement ps; ResultSet rs; try { ps = con.prepareStatement( "SELECT * FROM mts_items WHERE seller = ? AND transfer = 1 AND id= ? ORDER BY id DESC"); ps.setInt(1, c.getPlayer().getId()); ps.setInt(2, id); rs = ps.executeQuery(); if (rs.next()) { IItem i; if (rs.getInt("type") != 1) { Item ii = new Item(rs.getInt("itemid"), (byte) 0, (short) rs.getInt("quantity")); ii.setOwner(rs.getString("owner")); ii.setPosition( c.getPlayer() .getInventory( MapleItemInformationProvider.getInstance() .getInventoryType(rs.getInt("itemid"))) .getNextFreeSlot()); i = ii.copy(); } else { Equip equip = new Equip(rs.getInt("itemid"), (byte) rs.getInt("position"), -1); equip.setOwner(rs.getString("owner")); equip.setQuantity((short) 1); equip.setAcc((short) rs.getInt("acc")); equip.setAvoid((short) rs.getInt("avoid")); equip.setDex((short) rs.getInt("dex")); equip.setHands((short) rs.getInt("hands")); equip.setHp((short) rs.getInt("hp")); equip.setInt((short) rs.getInt("int")); equip.setJump((short) rs.getInt("jump")); equip.setLuk((short) rs.getInt("luk")); equip.setMatk((short) rs.getInt("matk")); equip.setMdef((short) rs.getInt("mdef")); equip.setMp((short) rs.getInt("mp")); equip.setSpeed((short) rs.getInt("speed")); equip.setStr((short) rs.getInt("str")); equip.setWatk((short) rs.getInt("watk")); equip.setWdef((short) rs.getInt("wdef")); equip.setUpgradeSlots((byte) rs.getInt("upgradeslots")); equip.setLevel((byte) rs.getInt("level")); equip.setVicious((byte) rs.getInt("vicious")); equip.setFlag((byte) rs.getInt("flag")); equip.setPosition( c.getPlayer() .getInventory( MapleItemInformationProvider.getInstance() .getInventoryType(rs.getInt("itemid"))) .getNextFreeSlot()); i = equip.copy(); } PreparedStatement pse = con.prepareStatement( "DELETE FROM mts_items WHERE id = ? AND seller = ? AND transfer = 1"); pse.setInt(1, id); pse.setInt(2, c.getPlayer().getId()); pse.executeUpdate(); pse.close(); MapleInventoryManipulator.addFromDrop(c, i, false); c.announce(MaplePacketCreator.enableCSUse()); c.announce(getCart(c.getPlayer().getId())); c.announce( getMTS( c.getPlayer().getCurrentTab(), c.getPlayer().getCurrentType(), c.getPlayer().getCurrentPage())); c.announce(MaplePacketCreator.MTSConfirmTransfer(i.getQuantity(), i.getPosition())); c.announce(MaplePacketCreator.transferInventory(getTransfer(c.getPlayer().getId()))); } rs.close(); ps.close(); } catch (SQLException e) { Output.print("MTS Transfer error: " + e); } } else if (op == 9) { // add to cart int id = slea.readInt(); // id of the item Connection con = DatabaseConnection.getConnection(); try { PreparedStatement ps1 = con.prepareStatement("SELECT * FROM mts_items WHERE id = ? AND seller <> ?"); ps1.setInt(1, id); // Previene que agregues al cart tus // propios items ps1.setInt(2, c.getPlayer().getId()); ResultSet rs1 = ps1.executeQuery(); if (rs1.next()) { PreparedStatement ps = con.prepareStatement("SELECT * FROM mts_cart WHERE cid = ? AND itemid = ?"); ps.setInt(1, c.getPlayer().getId()); ps.setInt(2, id); ResultSet rs = ps.executeQuery(); if (!rs.next()) { PreparedStatement pse = con.prepareStatement("INSERT INTO mts_cart (cid, itemid) VALUES (?, ?)"); pse.setInt(1, c.getPlayer().getId()); pse.setInt(2, id); pse.executeUpdate(); pse.close(); } rs.close(); } rs1.close(); } catch (SQLException e) { e.printStackTrace(); } c.announce( getMTS( c.getPlayer().getCurrentTab(), c.getPlayer().getCurrentType(), c.getPlayer().getCurrentPage())); c.announce(MaplePacketCreator.enableCSUse()); c.announce(MaplePacketCreator.enableActions()); c.announce(MaplePacketCreator.transferInventory(getTransfer(c.getPlayer().getId()))); c.announce(MaplePacketCreator.notYetSoldInv(getNotYetSold(c.getPlayer().getId()))); } else if (op == 10) { // delete from cart int id = slea.readInt(); // id of the item Connection con = DatabaseConnection.getConnection(); try { PreparedStatement ps = con.prepareStatement("DELETE FROM mts_cart WHERE itemid = ? AND cid = ?"); ps.setInt(1, id); ps.setInt(2, c.getPlayer().getId()); ps.executeUpdate(); ps.close(); } catch (SQLException e) { e.printStackTrace(); } c.announce(getCart(c.getPlayer().getId())); c.announce(MaplePacketCreator.enableCSUse()); c.announce(MaplePacketCreator.transferInventory(getTransfer(c.getPlayer().getId()))); c.announce(MaplePacketCreator.notYetSoldInv(getNotYetSold(c.getPlayer().getId()))); } else if (op == 12) { // put item up for auction } else if (op == 13) { // cancel wanted cart thing } else if (op == 14) { // buy auction item now } else if (op == 16) { // buy int id = slea.readInt(); // id of the item Connection con = DatabaseConnection.getConnection(); PreparedStatement ps; ResultSet rs; try { ps = con.prepareStatement("SELECT * FROM mts_items WHERE id = ? ORDER BY id DESC"); ps.setInt(1, id); rs = ps.executeQuery(); if (rs.next()) { int price = rs.getInt("price") + 100 + (int) (rs.getInt("price") * 0.1); // taxes if (c.getPlayer().getCashShop().getCash(4) >= price) { // FIX boolean alwaysnull = true; for (Channel cserv : Server.getInstance().getAllChannels()) { MapleCharacter victim = cserv.getPlayerStorage().getCharacterById(rs.getInt("seller")); if (victim != null) { victim.getCashShop().gainCash(4, rs.getInt("price")); alwaysnull = false; } } if (alwaysnull) { PreparedStatement pse = con.prepareStatement("SELECT accountid FROM characters WHERE id = ?"); pse.setInt(1, rs.getInt("seller")); ResultSet rse = pse.executeQuery(); if (rse.next()) { PreparedStatement psee = con.prepareStatement( "UPDATE accounts SET nxPrepaid = nxPrepaid + ? WHERE id = ?"); psee.setInt(1, rs.getInt("price")); psee.setInt(2, rse.getInt("accountid")); psee.executeUpdate(); psee.close(); } pse.close(); rse.close(); } PreparedStatement pse = con.prepareStatement( "UPDATE mts_items SET seller = ?, transfer = 1 WHERE id = ?"); pse.setInt(1, c.getPlayer().getId()); pse.setInt(2, id); pse.executeUpdate(); pse.close(); pse = con.prepareStatement("DELETE FROM mts_cart WHERE itemid = ?"); pse.setInt(1, id); pse.executeUpdate(); pse.close(); c.getPlayer().getCashShop().gainCash(4, -price); c.announce(MaplePacketCreator.enableCSUse()); c.announce( getMTS( c.getPlayer().getCurrentTab(), c.getPlayer().getCurrentType(), c.getPlayer().getCurrentPage())); c.announce(MaplePacketCreator.MTSConfirmBuy()); c.announce(MaplePacketCreator.showMTSCash(c.getPlayer())); c.announce(MaplePacketCreator.transferInventory(getTransfer(c.getPlayer().getId()))); c.announce(MaplePacketCreator.notYetSoldInv(getNotYetSold(c.getPlayer().getId()))); c.announce(MaplePacketCreator.enableActions()); } else { c.announce(MaplePacketCreator.MTSFailBuy()); } } rs.close(); ps.close(); } catch (SQLException e) { c.announce(MaplePacketCreator.MTSFailBuy()); } } else if (op == 17) { // buy from cart int id = slea.readInt(); // id of the item Connection con = DatabaseConnection.getConnection(); PreparedStatement ps; ResultSet rs; try { ps = con.prepareStatement("SELECT * FROM mts_items WHERE id = ? ORDER BY id DESC"); ps.setInt(1, id); rs = ps.executeQuery(); if (rs.next()) { int price = rs.getInt("price") + 100 + (int) (rs.getInt("price") * 0.1); if (c.getPlayer().getCashShop().getCash(4) >= price) { for (Channel cserv : Server.getInstance().getAllChannels()) { MapleCharacter victim = cserv.getPlayerStorage().getCharacterById(rs.getInt("seller")); if (victim != null) { victim.getCashShop().gainCash(4, rs.getInt("price")); } else { PreparedStatement pse = con.prepareStatement("SELECT accountid FROM characters WHERE id = ?"); pse.setInt(1, rs.getInt("seller")); ResultSet rse = pse.executeQuery(); if (rse.next()) { PreparedStatement psee = con.prepareStatement( "UPDATE accounts SET nxPrepaid = nxPrepaid + ? WHERE id = ?"); psee.setInt(1, rs.getInt("price")); psee.setInt(2, rse.getInt("accountid")); psee.executeUpdate(); psee.close(); } pse.close(); rse.close(); } } PreparedStatement pse = con.prepareStatement( "UPDATE mts_items SET seller = ?, transfer = 1 WHERE id = ?"); pse.setInt(1, c.getPlayer().getId()); pse.setInt(2, id); pse.executeUpdate(); pse.close(); pse = con.prepareStatement("DELETE FROM mts_cart WHERE itemid = ?"); pse.setInt(1, id); pse.executeUpdate(); pse.close(); c.getPlayer().getCashShop().gainCash(4, -price); c.announce(getCart(c.getPlayer().getId())); c.announce(MaplePacketCreator.enableCSUse()); c.announce(MaplePacketCreator.MTSConfirmBuy()); c.announce(MaplePacketCreator.showMTSCash(c.getPlayer())); c.announce(MaplePacketCreator.transferInventory(getTransfer(c.getPlayer().getId()))); c.announce(MaplePacketCreator.notYetSoldInv(getNotYetSold(c.getPlayer().getId()))); } else { c.announce(MaplePacketCreator.MTSFailBuy()); } } rs.close(); ps.close(); } catch (SQLException e) { c.announce(MaplePacketCreator.MTSFailBuy()); } } else { System.out.println("Unhandled OP(MTS): " + op + " Packet: " + slea.toString()); } } else { c.announce(MaplePacketCreator.showMTSCash(c.getPlayer())); } }
public final void handlePacket(SeekableLittleEndianAccessor slea, MapleClient c) { slea.readInt(); // whatever... byte slot = (byte) slea.readShort(); byte dst = (byte) slea.readShort(); byte ws = (byte) slea.readShort(); boolean whiteScroll = false; // white scroll being used? boolean legendarySpirit = false; // legendary spirit skill if ((ws & 2) == 2) { whiteScroll = true; } MapleItemInformationProvider ii = MapleItemInformationProvider.getInstance(); IEquip toScroll = (IEquip) c.getPlayer().getInventory(MapleInventoryType.EQUIPPED).getItem(dst); ISkill LegendarySpirit = SkillFactory.getSkill(1003); if (c.getPlayer().getSkillLevel(LegendarySpirit) > 0 && dst >= 0) { legendarySpirit = true; toScroll = (IEquip) c.getPlayer().getInventory(MapleInventoryType.EQUIP).getItem(dst); } byte oldLevel = toScroll.getLevel(); if (((IEquip) toScroll).getUpgradeSlots() < 1) { c.announce(MaplePacketCreator.getInventoryFull()); return; } MapleInventory useInventory = c.getPlayer().getInventory(MapleInventoryType.USE); IItem scroll = useInventory.getItem(slot); IItem wscroll = null; List<Integer> scrollReqs = ii.getScrollReqs(scroll.getItemId()); if (scrollReqs.size() > 0 && !scrollReqs.contains(toScroll.getItemId())) { c.announce(MaplePacketCreator.getInventoryFull()); return; } if (whiteScroll) { wscroll = useInventory.findById(2340000); if (wscroll == null || wscroll.getItemId() != 2340000) { whiteScroll = false; } } if (scroll.getItemId() != 2049100 && !isCleanSlate(scroll.getItemId())) { if (!canScroll(scroll.getItemId(), toScroll.getItemId())) { return; } } if (scroll.getQuantity() < 1) { return; } try { IEquip scrolled = null; ScrollResult scrollSuccess = null; int sExpAdd = 0; Enchantment enchantment = (Enchantment) c.getPlayer().getPowerSkill(PowerSkillType.ENCHANTMENT); boolean isMultiScroll = enchantment.getMultiScrollChance() > Randomizer.nextFloat(); int scrollMulti = 1 + (isMultiScroll ? enchantment.getMultiScrollAmount() : 0); if (scrollMulti > 1) sExpAdd += Randomizer.rand(0, 4); boolean removeSlot = enchantment.getNoSlotUse() > Randomizer.nextFloat(); if (scrollMulti > scroll.getQuantity()) { scrollMulti = scroll.getQuantity(); } int scrollCount = 0; while (scroll.getQuantity() > 0 && scrollMulti > 0) { scrollMulti--; scrollCount++; int scrollRerolls = enchantment.getRerolls(); sExpAdd += scrollRerolls; float statMultiplier = 1 + enchantment.getExtraStats(); if (statMultiplier > 1) sExpAdd++; scrolled = (IEquip) ii.scrollEquipWithId( toScroll, scroll.getItemId(), whiteScroll, removeSlot, scrollRerolls, statMultiplier, c.getPlayer().isGM()); if (scrolled != null && enchantment.getDoubleScroll() > Randomizer.nextFloat()) { scrolled = (IEquip) ii.scrollEquipWithId( scrolled, scroll.getItemId(), whiteScroll, removeSlot, scrollRerolls, statMultiplier, c.getPlayer().isGM()); } scrollSuccess = IEquip.ScrollResult.FAIL; // fail if (scrolled == null) { scrollSuccess = IEquip.ScrollResult.CURSE; } else if (scrolled.getLevel() > oldLevel || (isCleanSlate(scroll.getItemId()) && scrolled.getLevel() == oldLevel + 1)) { scrollSuccess = IEquip.ScrollResult.SUCCESS; } useInventory.removeItem(scroll.getPosition(), (short) 1, false); if (whiteScroll) { useInventory.removeItem(wscroll.getPosition(), (short) 1, false); if (wscroll.getQuantity() < 1) { c.announce( MaplePacketCreator.clearInventoryItem( MapleInventoryType.USE, wscroll.getPosition(), false)); } else { c.announce( MaplePacketCreator.updateInventorySlot(MapleInventoryType.USE, (Item) wscroll)); } } c.getPlayer() .getMap() .broadcastMessage( MaplePacketCreator.getScrollEffect( c.getPlayer().getId(), scrollSuccess, legendarySpirit)); if (scrollSuccess == IEquip.ScrollResult.CURSE) { break; } } if (scrollSuccess == IEquip.ScrollResult.CURSE) { scrollMulti = 0; c.announce(MaplePacketCreator.scrolledItem(scroll, toScroll, true)); if (dst < 0) { c.getPlayer() .getInventory(MapleInventoryType.EQUIPPED) .removeItem(toScroll.getPosition()); } else { c.getPlayer().getInventory(MapleInventoryType.EQUIP).removeItem(toScroll.getPosition()); } } else { c.announce(MaplePacketCreator.scrolledItem(scroll, scrolled, false)); } if (dst < 0 && (scrollSuccess == IEquip.ScrollResult.SUCCESS || scrollSuccess == IEquip.ScrollResult.CURSE)) { c.getPlayer().equipChanged(); } // sExpAdd /= initMulti; if (scrollCount > 1) c.getPlayer().message("You have successfully multi-scrolled " + scrollCount + " times!"); c.getPlayer().addPowerSkillExp(PowerSkillType.ENCHANTMENT, sExpAdd + Randomizer.nextInt(4)); } catch (Exception ex) { ex.printStackTrace(); } }