Code Coupons + Worldmap update + Mini-games + Player Interaction wrap
Fixed several cases on the Cash Shop that would freeze some player actions when triggered, requiring exit Cash Shop to unstuck. Implemented Code Coupons, supporting several items bundled on the same code, and also devised a way to automate code generation. Added a current status on-demand option on the Buyback command. Info such as "current fee" or "time remaining" are available now. Reviewed several cases where non-owned items would get stacked with owner-tagged items. Added Door support for Happyville, Crimsonwood Keep. Added worldmap tooltip support for some maps in Masteria's C. Keep and H. House. Added Masteria region to the world map. C. Keep interiors no longer relocates players to entrance after actions such as logout. Overhauled minigame mechanics: from player boxes tooltip and in-match improvements to deploy different minigame types, accordingly with item description or player choice. Fixed Amoria outskirts not relocating players to city after getting KO'ed. Fixed issues with pets, rings and cash items being assigned the same cash unique ids leading to some quirks on the cash shop inventory. Fixed an issue with the recently added HP/MP ratio update, arbitrarily taking off 1 point in certain cases. Answer positions on the explorer's 3rd job quiz are now randomed. Fixed several issues that showed up when the bcrypt system is disabled. DOT from maps such as El Nath and Aqua Road now procs at a 5sec interval, GMS-like. Improved performance of Whodrops and Search commands. Concurrently protected player interaction handlers, thus mitigating several exploits on these lines. Adjusted several expedition timers, such as Horntail, now having a more sane deadline. Concurrently protected chair modules. Fixed "seduce" debuff not working on chairs.
This commit is contained in:
@@ -43,7 +43,7 @@ public class AssignSPProcessor {
|
||||
c.lockClient();
|
||||
try {
|
||||
if (skillid == Aran.HIDDEN_FULL_DOUBLE || skillid == Aran.HIDDEN_FULL_TRIPLE || skillid == Aran.HIDDEN_OVER_DOUBLE || skillid == Aran.HIDDEN_OVER_TRIPLE) {
|
||||
c.getSession().write(MaplePacketCreator.enableActions());
|
||||
c.announce(MaplePacketCreator.enableActions());
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -21,16 +21,13 @@ package client.processor;
|
||||
|
||||
import client.MapleClient;
|
||||
import client.MapleCharacter;
|
||||
import client.MapleStat;
|
||||
import java.awt.Point;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import server.maps.MapleMap;
|
||||
import server.movement.AbsoluteLifeMovement;
|
||||
import server.movement.LifeMovementFragment;
|
||||
import tools.MaplePacketCreator;
|
||||
import tools.Pair;
|
||||
|
||||
/**
|
||||
*
|
||||
|
||||
@@ -345,167 +345,171 @@ public class DueyProcessor {
|
||||
}
|
||||
|
||||
public static void dueySendItem(MapleClient c, byte inventId, short itemPos, short amount, int mesos, String recipient) {
|
||||
c.lockClient();
|
||||
try {
|
||||
final int fee = 5000;
|
||||
final long sendMesos = (long) mesos + fee;
|
||||
if (mesos < 0 || sendMesos > Integer.MAX_VALUE || (amount < 1 && mesos == 0)) {
|
||||
AutobanFactory.PACKET_EDIT.alert(c.getPlayer(), c.getPlayer().getName() + " tried to packet edit with duey.");
|
||||
FilePrinter.printError(FilePrinter.EXPLOITS + c.getPlayer().getName() + ".txt", c.getPlayer().getName() + " tried to use duey with mesos " + mesos + " and amount " + amount + "\r\n");
|
||||
c.disconnect(true, false);
|
||||
return;
|
||||
}
|
||||
|
||||
int finalcost = mesos + fee;
|
||||
if (c.getPlayer().getMeso() >= finalcost) {
|
||||
int accid = getAccIdFromCNAME(recipient, true);
|
||||
if (accid != -1) {
|
||||
if (accid == c.getAccID()) {
|
||||
c.announce(MaplePacketCreator.sendDueyMSG(DueyProcessor.Actions.TOCLIENT_SEND_SAMEACC_ERROR.getCode()));
|
||||
if (c.tryacquireClient()) {
|
||||
try {
|
||||
final int fee = 5000;
|
||||
final long sendMesos = (long) mesos + fee;
|
||||
if (mesos < 0 || sendMesos > Integer.MAX_VALUE || (amount < 1 && mesos == 0)) {
|
||||
AutobanFactory.PACKET_EDIT.alert(c.getPlayer(), c.getPlayer().getName() + " tried to packet edit with duey.");
|
||||
FilePrinter.printError(FilePrinter.EXPLOITS + c.getPlayer().getName() + ".txt", c.getPlayer().getName() + " tried to use duey with mesos " + mesos + " and amount " + amount + "\r\n");
|
||||
c.disconnect(true, false);
|
||||
return;
|
||||
}
|
||||
|
||||
int finalcost = mesos + fee;
|
||||
if (c.getPlayer().getMeso() >= finalcost) {
|
||||
int accid = getAccIdFromCNAME(recipient, true);
|
||||
if (accid != -1) {
|
||||
if (accid == c.getAccID()) {
|
||||
c.announce(MaplePacketCreator.sendDueyMSG(DueyProcessor.Actions.TOCLIENT_SEND_SAMEACC_ERROR.getCode()));
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
c.announce(MaplePacketCreator.sendDueyMSG(DueyProcessor.Actions.TOCLIENT_SEND_NAME_DOES_NOT_EXIST.getCode()));
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
c.announce(MaplePacketCreator.sendDueyMSG(DueyProcessor.Actions.TOCLIENT_SEND_NAME_DOES_NOT_EXIST.getCode()));
|
||||
c.announce(MaplePacketCreator.sendDueyMSG(DueyProcessor.Actions.TOCLIENT_SEND_NOT_ENOUGH_MESOS.getCode()));
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
c.announce(MaplePacketCreator.sendDueyMSG(DueyProcessor.Actions.TOCLIENT_SEND_NOT_ENOUGH_MESOS.getCode()));
|
||||
return;
|
||||
}
|
||||
|
||||
MapleClient rClient = null;
|
||||
int channel = c.getWorldServer().find(recipient);
|
||||
if (channel > -1) {
|
||||
Channel rcserv = c.getWorldServer().getChannel(channel);
|
||||
if(rcserv != null) {
|
||||
MapleCharacter rChr = rcserv.getPlayerStorage().getCharacterByName(recipient);
|
||||
if(rChr != null) {
|
||||
rClient = rChr.getClient();
|
||||
MapleClient rClient = null;
|
||||
int channel = c.getWorldServer().find(recipient);
|
||||
if (channel > -1) {
|
||||
Channel rcserv = c.getWorldServer().getChannel(channel);
|
||||
if(rcserv != null) {
|
||||
MapleCharacter rChr = rcserv.getPlayerStorage().getCharacterByName(recipient);
|
||||
if(rChr != null) {
|
||||
rClient = rChr.getClient();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (inventId > 0) {
|
||||
MapleInventoryType inv = MapleInventoryType.getByType(inventId);
|
||||
Item item = c.getPlayer().getInventory(inv).getItem(itemPos);
|
||||
if (item != null && c.getPlayer().getItemQuantity(item.getItemId(), false) >= amount) {
|
||||
c.getPlayer().gainMeso(-finalcost, false);
|
||||
c.announce(MaplePacketCreator.sendDueyMSG(DueyProcessor.Actions.TOCLIENT_SEND_SUCCESSFULLY_SENT.getCode()));
|
||||
|
||||
if (ItemConstants.isRechargeable(item.getItemId())) {
|
||||
MapleInventoryManipulator.removeFromSlot(c, inv, itemPos, item.getQuantity(), true);
|
||||
if (inventId > 0) {
|
||||
MapleInventoryType inv = MapleInventoryType.getByType(inventId);
|
||||
Item item = c.getPlayer().getInventory(inv).getItem(itemPos);
|
||||
if (item != null && c.getPlayer().getItemQuantity(item.getItemId(), false) >= amount) {
|
||||
c.getPlayer().gainMeso(-finalcost, false);
|
||||
c.announce(MaplePacketCreator.sendDueyMSG(DueyProcessor.Actions.TOCLIENT_SEND_SUCCESSFULLY_SENT.getCode()));
|
||||
|
||||
if (ItemConstants.isRechargeable(item.getItemId())) {
|
||||
MapleInventoryManipulator.removeFromSlot(c, inv, itemPos, item.getQuantity(), true);
|
||||
} else {
|
||||
MapleInventoryManipulator.removeFromSlot(c, inv, itemPos, amount, true, false);
|
||||
}
|
||||
|
||||
MapleKarmaManipulator.toggleKarmaFlagToUntradeable(item);
|
||||
addItemToDB(item, amount, mesos - getFee(mesos), c.getPlayer().getName(), getAccIdFromCNAME(recipient, false));
|
||||
} else {
|
||||
MapleInventoryManipulator.removeFromSlot(c, inv, itemPos, amount, true, false);
|
||||
if (item != null) {
|
||||
c.announce(MaplePacketCreator.sendDueyMSG(DueyProcessor.Actions.TOCLIENT_SEND_INCORRECT_REQUEST.getCode()));
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
MapleKarmaManipulator.toggleKarmaFlagToUntradeable(item);
|
||||
addItemToDB(item, amount, mesos - getFee(mesos), c.getPlayer().getName(), getAccIdFromCNAME(recipient, false));
|
||||
} else {
|
||||
if (item != null) {
|
||||
c.announce(MaplePacketCreator.sendDueyMSG(DueyProcessor.Actions.TOCLIENT_SEND_INCORRECT_REQUEST.getCode()));
|
||||
}
|
||||
return;
|
||||
c.getPlayer().gainMeso(-finalcost, false);
|
||||
c.announce(MaplePacketCreator.sendDueyMSG(DueyProcessor.Actions.TOCLIENT_SEND_SUCCESSFULLY_SENT.getCode()));
|
||||
|
||||
addMesoToDB(mesos - getFee(mesos), c.getPlayer().getName(), getAccIdFromCNAME(recipient, false));
|
||||
}
|
||||
} else {
|
||||
c.getPlayer().gainMeso(-finalcost, false);
|
||||
c.announce(MaplePacketCreator.sendDueyMSG(DueyProcessor.Actions.TOCLIENT_SEND_SUCCESSFULLY_SENT.getCode()));
|
||||
|
||||
addMesoToDB(mesos - getFee(mesos), c.getPlayer().getName(), getAccIdFromCNAME(recipient, false));
|
||||
if (rClient != null && rClient.isLoggedIn() && !rClient.getPlayer().isAwayFromWorld()) {
|
||||
showDueyNotification(rClient, rClient.getPlayer());
|
||||
}
|
||||
} finally {
|
||||
c.releaseClient();
|
||||
}
|
||||
|
||||
if (rClient != null && rClient.isLoggedIn() && !rClient.getPlayer().isAwayFromWorld()) {
|
||||
showDueyNotification(rClient, rClient.getPlayer());
|
||||
}
|
||||
} finally {
|
||||
c.unlockClient();
|
||||
}
|
||||
}
|
||||
|
||||
public static void dueyRemovePackage(MapleClient c, int packageid) {
|
||||
c.lockClient();
|
||||
try {
|
||||
removeItemFromDB(packageid);
|
||||
c.announce(MaplePacketCreator.removeItemFromDuey(true, packageid));
|
||||
} finally {
|
||||
c.unlockClient();
|
||||
if (c.tryacquireClient()) {
|
||||
try {
|
||||
removeItemFromDB(packageid);
|
||||
c.announce(MaplePacketCreator.removeItemFromDuey(true, packageid));
|
||||
} finally {
|
||||
c.releaseClient();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void dueyClaimPackage(MapleClient c, int packageid) {
|
||||
c.lockClient();
|
||||
try {
|
||||
List<DueyPackages> packages = new LinkedList<>();
|
||||
DueyPackages dp = null;
|
||||
Connection con = null;
|
||||
if (c.tryacquireClient()) {
|
||||
try {
|
||||
con = DatabaseConnection.getConnection();
|
||||
DueyPackages dueypack;
|
||||
try (PreparedStatement ps = con.prepareStatement("SELECT * FROM dueypackages LEFT JOIN dueyitems USING (PackageId) WHERE PackageId = ?")) {
|
||||
ps.setInt(1, packageid);
|
||||
try (ResultSet rs = ps.executeQuery()) {
|
||||
dueypack = null;
|
||||
if (rs.next()) {
|
||||
dueypack = getItemByPID(rs);
|
||||
dueypack.setSender(rs.getString("SenderName"));
|
||||
dueypack.setMesos(rs.getInt("Mesos"));
|
||||
dueypack.setSentTime(rs.getString("TimeStamp"));
|
||||
List<DueyPackages> packages = new LinkedList<>();
|
||||
DueyPackages dp = null;
|
||||
Connection con = null;
|
||||
try {
|
||||
con = DatabaseConnection.getConnection();
|
||||
DueyPackages dueypack;
|
||||
try (PreparedStatement ps = con.prepareStatement("SELECT * FROM dueypackages LEFT JOIN dueyitems USING (PackageId) WHERE PackageId = ?")) {
|
||||
ps.setInt(1, packageid);
|
||||
try (ResultSet rs = ps.executeQuery()) {
|
||||
dueypack = null;
|
||||
if (rs.next()) {
|
||||
dueypack = getItemByPID(rs);
|
||||
dueypack.setSender(rs.getString("SenderName"));
|
||||
dueypack.setMesos(rs.getInt("Mesos"));
|
||||
dueypack.setSentTime(rs.getString("TimeStamp"));
|
||||
|
||||
packages.add(dueypack);
|
||||
packages.add(dueypack);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
dp = dueypack;
|
||||
if(dp == null) {
|
||||
c.announce(MaplePacketCreator.sendDueyMSG(Actions.TOCLIENT_RECV_UNKNOWN_ERROR.getCode()));
|
||||
FilePrinter.printError(FilePrinter.EXPLOITS + c.getPlayer().getName() + ".txt", c.getPlayer().getName() + " tried to receive package from duey with id " + packageid + "\r\n");
|
||||
return;
|
||||
}
|
||||
|
||||
if (dp.getItem() != null) {
|
||||
if (!MapleInventoryManipulator.checkSpace(c, dp.getItem().getItemId(), dp.getItem().getQuantity(), dp.getItem().getOwner())) {
|
||||
int itemid = dp.getItem().getItemId();
|
||||
if(MapleItemInformationProvider.getInstance().isPickupRestricted(itemid) && c.getPlayer().getInventory(ItemConstants.getInventoryType(itemid)).findById(itemid) != null) {
|
||||
c.announce(MaplePacketCreator.sendDueyMSG(Actions.TOCLIENT_RECV_RECEIVER_WITH_UNIQUE.getCode()));
|
||||
} else {
|
||||
c.announce(MaplePacketCreator.sendDueyMSG(Actions.TOCLIENT_RECV_NO_FREE_SLOTS.getCode()));
|
||||
}
|
||||
|
||||
dp = dueypack;
|
||||
if(dp == null) {
|
||||
c.announce(MaplePacketCreator.sendDueyMSG(Actions.TOCLIENT_RECV_UNKNOWN_ERROR.getCode()));
|
||||
FilePrinter.printError(FilePrinter.EXPLOITS + c.getPlayer().getName() + ".txt", c.getPlayer().getName() + " tried to receive package from duey with id " + packageid + "\r\n");
|
||||
return;
|
||||
} else {
|
||||
MapleInventoryManipulator.addFromDrop(c, dp.getItem(), false);
|
||||
}
|
||||
|
||||
if (dp.getItem() != null) {
|
||||
if (!MapleInventoryManipulator.checkSpace(c, dp.getItem().getItemId(), dp.getItem().getQuantity(), dp.getItem().getOwner())) {
|
||||
int itemid = dp.getItem().getItemId();
|
||||
if(MapleItemInformationProvider.getInstance().isPickupRestricted(itemid) && c.getPlayer().getInventory(ItemConstants.getInventoryType(itemid)).findById(itemid) != null) {
|
||||
c.announce(MaplePacketCreator.sendDueyMSG(Actions.TOCLIENT_RECV_RECEIVER_WITH_UNIQUE.getCode()));
|
||||
} else {
|
||||
c.announce(MaplePacketCreator.sendDueyMSG(Actions.TOCLIENT_RECV_NO_FREE_SLOTS.getCode()));
|
||||
}
|
||||
|
||||
return;
|
||||
} else {
|
||||
MapleInventoryManipulator.addFromDrop(c, dp.getItem(), false);
|
||||
}
|
||||
}
|
||||
|
||||
long gainmesos;
|
||||
long totalmesos = (long) dp.getMesos() + c.getPlayer().getMeso();
|
||||
|
||||
if (totalmesos < 0 || dp.getMesos() < 0) {
|
||||
gainmesos = 0;
|
||||
} else {
|
||||
totalmesos = Math.min(totalmesos, Integer.MAX_VALUE);
|
||||
gainmesos = totalmesos - c.getPlayer().getMeso();
|
||||
}
|
||||
|
||||
c.getPlayer().gainMeso((int)gainmesos, false);
|
||||
|
||||
removeItemFromDB(packageid);
|
||||
c.announce(MaplePacketCreator.removeItemFromDuey(false, packageid));
|
||||
|
||||
con.close();
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
long gainmesos;
|
||||
long totalmesos = (long) dp.getMesos() + c.getPlayer().getMeso();
|
||||
|
||||
if (totalmesos < 0 || dp.getMesos() < 0) {
|
||||
gainmesos = 0;
|
||||
} else {
|
||||
totalmesos = Math.min(totalmesos, Integer.MAX_VALUE);
|
||||
gainmesos = totalmesos - c.getPlayer().getMeso();
|
||||
}
|
||||
|
||||
c.getPlayer().gainMeso((int)gainmesos, false);
|
||||
|
||||
removeItemFromDB(packageid);
|
||||
c.announce(MaplePacketCreator.removeItemFromDuey(false, packageid));
|
||||
|
||||
con.close();
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
c.releaseClient();
|
||||
}
|
||||
} finally {
|
||||
c.unlockClient();
|
||||
}
|
||||
}
|
||||
|
||||
public static void dueySendTalk(MapleClient c) {
|
||||
c.lockClient();
|
||||
try {
|
||||
c.announce(MaplePacketCreator.sendDuey((byte) 8, loadItems(c.getPlayer())));
|
||||
} finally {
|
||||
c.unlockClient();
|
||||
if (c.tryacquireClient()) {
|
||||
try {
|
||||
c.announce(MaplePacketCreator.sendDuey((byte) 8, loadItems(c.getPlayer())));
|
||||
} finally {
|
||||
c.releaseClient();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -70,42 +70,43 @@ public class FredrickProcessor {
|
||||
}
|
||||
|
||||
public static void fredrickRetrieveItems(MapleClient c) { // thanks Gustav for pointing out the dupe on Fredrick handling
|
||||
c.lockClient();
|
||||
try {
|
||||
MapleCharacter chr = c.getPlayer();
|
||||
|
||||
List<Pair<Item, MapleInventoryType>> items;
|
||||
if (c.tryacquireClient()) {
|
||||
try {
|
||||
items = ItemFactory.MERCHANT.loadItems(chr.getId(), false);
|
||||
if (!canRetrieveFromFredrick(chr, items)) {
|
||||
chr.announce(MaplePacketCreator.fredrickMessage((byte) 0x21));
|
||||
return;
|
||||
}
|
||||
MapleCharacter chr = c.getPlayer();
|
||||
|
||||
chr.withdrawMerchantMesos();
|
||||
|
||||
if (deleteFredrickItems(chr.getId())) {
|
||||
MapleHiredMerchant merchant = chr.getHiredMerchant();
|
||||
|
||||
if(merchant != null)
|
||||
merchant.clearItems();
|
||||
|
||||
for (Pair<Item, MapleInventoryType> it : items) {
|
||||
Item item = it.getLeft();
|
||||
MapleInventoryManipulator.addFromDrop(chr.getClient(), item, false);
|
||||
String itemName = MapleItemInformationProvider.getInstance().getName(item.getItemId());
|
||||
FilePrinter.print(FilePrinter.FREDRICK + chr.getName() + ".txt", chr.getName() + " gained " + item.getQuantity() + " " + itemName + " (" + item.getItemId() + ")\r\n");
|
||||
List<Pair<Item, MapleInventoryType>> items;
|
||||
try {
|
||||
items = ItemFactory.MERCHANT.loadItems(chr.getId(), false);
|
||||
if (!canRetrieveFromFredrick(chr, items)) {
|
||||
chr.announce(MaplePacketCreator.fredrickMessage((byte) 0x21));
|
||||
return;
|
||||
}
|
||||
|
||||
chr.announce(MaplePacketCreator.fredrickMessage((byte) 0x1E));
|
||||
} else {
|
||||
chr.message("An unknown error has occured.");
|
||||
chr.withdrawMerchantMesos();
|
||||
|
||||
if (deleteFredrickItems(chr.getId())) {
|
||||
MapleHiredMerchant merchant = chr.getHiredMerchant();
|
||||
|
||||
if(merchant != null)
|
||||
merchant.clearItems();
|
||||
|
||||
for (Pair<Item, MapleInventoryType> it : items) {
|
||||
Item item = it.getLeft();
|
||||
MapleInventoryManipulator.addFromDrop(chr.getClient(), item, false);
|
||||
String itemName = MapleItemInformationProvider.getInstance().getName(item.getItemId());
|
||||
FilePrinter.print(FilePrinter.FREDRICK + chr.getName() + ".txt", chr.getName() + " gained " + item.getQuantity() + " " + itemName + " (" + item.getItemId() + ")\r\n");
|
||||
}
|
||||
|
||||
chr.announce(MaplePacketCreator.fredrickMessage((byte) 0x1E));
|
||||
} else {
|
||||
chr.message("An unknown error has occured.");
|
||||
}
|
||||
} catch (SQLException ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
} catch (SQLException ex) {
|
||||
ex.printStackTrace();
|
||||
} finally {
|
||||
c.releaseClient();
|
||||
}
|
||||
} finally {
|
||||
c.unlockClient();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,7 +26,6 @@ import client.inventory.MapleInventoryType;
|
||||
import constants.ItemConstants;
|
||||
import constants.ServerConstants;
|
||||
import client.inventory.manipulator.MapleInventoryManipulator;
|
||||
import constants.EquipType;
|
||||
import constants.GameConstants;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.LinkedList;
|
||||
@@ -47,168 +46,169 @@ public class MakerProcessor {
|
||||
private static MapleItemInformationProvider ii = MapleItemInformationProvider.getInstance();
|
||||
|
||||
public static void makerAction(SeekableLittleEndianAccessor slea, MapleClient c) {
|
||||
c.lockClient();
|
||||
try {
|
||||
int type = slea.readInt();
|
||||
int toCreate = slea.readInt();
|
||||
int toDisassemble = -1, pos = -1;
|
||||
boolean makerSucceeded = true;
|
||||
if (c.tryacquireClient()) {
|
||||
try {
|
||||
int type = slea.readInt();
|
||||
int toCreate = slea.readInt();
|
||||
int toDisassemble = -1, pos = -1;
|
||||
boolean makerSucceeded = true;
|
||||
|
||||
MakerItemFactory.MakerItemCreateEntry recipe;
|
||||
Map<Integer, Short> reagentids = new LinkedHashMap<>();
|
||||
int stimulantid = -1;
|
||||
MakerItemFactory.MakerItemCreateEntry recipe;
|
||||
Map<Integer, Short> reagentids = new LinkedHashMap<>();
|
||||
int stimulantid = -1;
|
||||
|
||||
if(type == 3) { // building monster crystal
|
||||
int fromLeftover = toCreate;
|
||||
toCreate = ii.getMakerCrystalFromLeftover(toCreate);
|
||||
if(toCreate == -1) {
|
||||
c.announce(MaplePacketCreator.serverNotice(1, ii.getName(toCreate) + " is unavailable for Monster Crystal conversion."));
|
||||
return;
|
||||
}
|
||||
if(type == 3) { // building monster crystal
|
||||
int fromLeftover = toCreate;
|
||||
toCreate = ii.getMakerCrystalFromLeftover(toCreate);
|
||||
if(toCreate == -1) {
|
||||
c.announce(MaplePacketCreator.serverNotice(1, ii.getName(toCreate) + " is unavailable for Monster Crystal conversion."));
|
||||
return;
|
||||
}
|
||||
|
||||
recipe = MakerItemFactory.generateLeftoverCrystalEntry(fromLeftover);
|
||||
} else if(type == 4) { // disassembling
|
||||
slea.readInt(); // 1... probably inventory type
|
||||
pos = slea.readInt();
|
||||
recipe = MakerItemFactory.generateLeftoverCrystalEntry(fromLeftover);
|
||||
} else if(type == 4) { // disassembling
|
||||
slea.readInt(); // 1... probably inventory type
|
||||
pos = slea.readInt();
|
||||
|
||||
Item it = c.getPlayer().getInventory(MapleInventoryType.EQUIP).getItem((short) pos);
|
||||
if(it != null && it.getItemId() == toCreate) {
|
||||
Pair<Integer, Integer> p;
|
||||
Item it = c.getPlayer().getInventory(MapleInventoryType.EQUIP).getItem((short) pos);
|
||||
if(it != null && it.getItemId() == toCreate) {
|
||||
Pair<Integer, Integer> p;
|
||||
|
||||
if((p = generateDisassemblyInfo(toCreate)) != null) {
|
||||
recipe = MakerItemFactory.generateDisassemblyCrystalEntry(p.getLeft(), p.getRight());
|
||||
toDisassemble = toCreate;
|
||||
toCreate = ii.getMakerCrystalFromEquip(toCreate);
|
||||
if((p = generateDisassemblyInfo(toCreate)) != null) {
|
||||
recipe = MakerItemFactory.generateDisassemblyCrystalEntry(p.getLeft(), p.getRight());
|
||||
toDisassemble = toCreate;
|
||||
toCreate = ii.getMakerCrystalFromEquip(toCreate);
|
||||
} else {
|
||||
c.announce(MaplePacketCreator.serverNotice(1, ii.getName(toCreate) + " is unavailable for Monster Crystal disassembly."));
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
c.announce(MaplePacketCreator.serverNotice(1, ii.getName(toCreate) + " is unavailable for Monster Crystal disassembly."));
|
||||
c.announce(MaplePacketCreator.serverNotice(1, "An unknown error occurred when trying to apply that item for disassembly."));
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
c.announce(MaplePacketCreator.serverNotice(1, "An unknown error occurred when trying to apply that item for disassembly."));
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
if(ItemConstants.isEquipment(toCreate)) { // only equips uses stimulant and reagents
|
||||
if(slea.readByte() != 0) { // stimulant
|
||||
stimulantid = ii.getMakerStimulant(toCreate);
|
||||
if(!c.getAbstractPlayerInteraction().haveItem(stimulantid)) {
|
||||
stimulantid = -1;
|
||||
}
|
||||
}
|
||||
|
||||
int reagents = Math.min(slea.readInt(), getMakerReagentSlots(toCreate));
|
||||
for(int i = 0; i < reagents; i++) { // crystals
|
||||
int reagentid = slea.readInt();
|
||||
if(ItemConstants.isMakerReagent(reagentid)) {
|
||||
Short rs = reagentids.get(reagentid);
|
||||
if(rs == null) {
|
||||
reagentids.put(reagentid, (short) 1);
|
||||
} else {
|
||||
reagentids.put(reagentid, (short) (rs + 1));
|
||||
if(ItemConstants.isEquipment(toCreate)) { // only equips uses stimulant and reagents
|
||||
if(slea.readByte() != 0) { // stimulant
|
||||
stimulantid = ii.getMakerStimulant(toCreate);
|
||||
if(!c.getAbstractPlayerInteraction().haveItem(stimulantid)) {
|
||||
stimulantid = -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
List<Pair<Integer, Short>> toUpdate = new LinkedList<>();
|
||||
for(Map.Entry<Integer, Short> r : reagentids.entrySet()) {
|
||||
int qty = c.getAbstractPlayerInteraction().getItemQuantity(r.getKey());
|
||||
|
||||
if(qty < r.getValue()) {
|
||||
toUpdate.add(new Pair<>(r.getKey(), (short) qty));
|
||||
}
|
||||
}
|
||||
|
||||
// remove those not present on player inventory
|
||||
if(!toUpdate.isEmpty()) {
|
||||
for(Pair<Integer, Short> rp : toUpdate) {
|
||||
if(rp.getRight() > 0) {
|
||||
reagentids.put(rp.getLeft(), rp.getRight());
|
||||
} else {
|
||||
reagentids.remove(rp.getLeft());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(!reagentids.isEmpty()) {
|
||||
if(!removeOddMakerReagents(toCreate, reagentids)) {
|
||||
c.announce(MaplePacketCreator.serverNotice(1, "You can only use WATK and MATK Strengthening Gems on weapon items."));
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
recipe = MakerItemFactory.getItemCreateEntry(toCreate, stimulantid, reagentids);
|
||||
}
|
||||
|
||||
short createStatus = getCreateStatus(c, recipe);
|
||||
|
||||
switch(createStatus) {
|
||||
case -1:// non-available for Maker itemid has been tried to forge
|
||||
FilePrinter.printError(FilePrinter.EXPLOITS, "Player " + c.getPlayer().getName() + " tried to craft itemid " + toCreate + " using the Maker skill.");
|
||||
c.announce(MaplePacketCreator.serverNotice(1, "The requested item could not be crafted on this operation."));
|
||||
break;
|
||||
|
||||
case 1: // no items
|
||||
c.announce(MaplePacketCreator.serverNotice(1, "You don't have all required items in your inventory to make " + recipe.getRewardAmount() + " " + ii.getName(toCreate) + "."));
|
||||
break;
|
||||
|
||||
case 2: // no meso
|
||||
c.announce(MaplePacketCreator.serverNotice(1, "You don't have enough mesos (" + GameConstants.numberWithCommas(recipe.getCost()) + ") to complete this operation."));
|
||||
break;
|
||||
|
||||
case 3: // no req level
|
||||
c.announce(MaplePacketCreator.serverNotice(1, "You don't have enough level to complete this operation."));
|
||||
break;
|
||||
|
||||
case 4: // no req skill level
|
||||
c.announce(MaplePacketCreator.serverNotice(1, "You don't have enough Maker level to complete this operation."));
|
||||
break;
|
||||
|
||||
default:
|
||||
if (MapleInventoryManipulator.checkSpace(c, toCreate, (short) recipe.getRewardAmount(), "")) {
|
||||
for (Pair<Integer, Integer> p : recipe.getReqItems()) {
|
||||
c.getAbstractPlayerInteraction().gainItem(p.getLeft(), (short) -p.getRight());
|
||||
}
|
||||
|
||||
if(toDisassemble != -1) {
|
||||
MapleInventoryManipulator.removeFromSlot(c, MapleInventoryType.EQUIP, (short) pos, (short) 1, false);
|
||||
c.announce(MaplePacketCreator.getShowItemGain(toDisassemble, (short) -1, true));
|
||||
}
|
||||
|
||||
int cost = recipe.getCost();
|
||||
if(stimulantid == -1 && reagentids.isEmpty()) {
|
||||
if(cost > 0) c.getPlayer().gainMeso(-cost);
|
||||
|
||||
c.getPlayer().setCS(true);
|
||||
c.getAbstractPlayerInteraction().gainItem(toCreate, (short) recipe.getRewardAmount());
|
||||
c.getPlayer().setCS(false);
|
||||
} else {
|
||||
if(stimulantid != -1) c.getAbstractPlayerInteraction().gainItem(stimulantid, (short) -1);
|
||||
if(!reagentids.isEmpty()) {
|
||||
for(Map.Entry<Integer, Short> r : reagentids.entrySet()) {
|
||||
c.getAbstractPlayerInteraction().gainItem(r.getKey(), (short) (-1 * r.getValue()));
|
||||
int reagents = Math.min(slea.readInt(), getMakerReagentSlots(toCreate));
|
||||
for(int i = 0; i < reagents; i++) { // crystals
|
||||
int reagentid = slea.readInt();
|
||||
if(ItemConstants.isMakerReagent(reagentid)) {
|
||||
Short rs = reagentids.get(reagentid);
|
||||
if(rs == null) {
|
||||
reagentids.put(reagentid, (short) 1);
|
||||
} else {
|
||||
reagentids.put(reagentid, (short) (rs + 1));
|
||||
}
|
||||
}
|
||||
|
||||
if(cost > 0) c.getPlayer().gainMeso(-cost);
|
||||
makerSucceeded = addBoostedMakerItem(c, toCreate, stimulantid, reagentids);
|
||||
}
|
||||
|
||||
if(makerSucceeded) c.announce(MaplePacketCreator.serverNotice(1, "You have successfully created " + recipe.getRewardAmount() + " " + ii.getName(toCreate) + "."));
|
||||
else c.getPlayer().dropMessage(5, "The Maker skill lights up, but the skill winds up as if nothing happened.");
|
||||
List<Pair<Integer, Short>> toUpdate = new LinkedList<>();
|
||||
for(Map.Entry<Integer, Short> r : reagentids.entrySet()) {
|
||||
int qty = c.getAbstractPlayerInteraction().getItemQuantity(r.getKey());
|
||||
|
||||
c.announce(MaplePacketCreator.showMakerEffect(makerSucceeded));
|
||||
c.getPlayer().getMap().broadcastMessage(c.getPlayer(), MaplePacketCreator.showForeignMakerEffect(c.getPlayer().getId(), makerSucceeded), false);
|
||||
|
||||
if(toCreate == 4260003 && c.getPlayer().getQuestStatus(6033) == 1) {
|
||||
c.getAbstractPlayerInteraction().setQuestProgress(6033, 1);
|
||||
if(qty < r.getValue()) {
|
||||
toUpdate.add(new Pair<>(r.getKey(), (short) qty));
|
||||
}
|
||||
}
|
||||
|
||||
// remove those not present on player inventory
|
||||
if(!toUpdate.isEmpty()) {
|
||||
for(Pair<Integer, Short> rp : toUpdate) {
|
||||
if(rp.getRight() > 0) {
|
||||
reagentids.put(rp.getLeft(), rp.getRight());
|
||||
} else {
|
||||
reagentids.remove(rp.getLeft());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(!reagentids.isEmpty()) {
|
||||
if(!removeOddMakerReagents(toCreate, reagentids)) {
|
||||
c.announce(MaplePacketCreator.serverNotice(1, "You can only use WATK and MATK Strengthening Gems on weapon items."));
|
||||
return;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
c.announce(MaplePacketCreator.serverNotice(1, "Your inventory is full."));
|
||||
}
|
||||
|
||||
recipe = MakerItemFactory.getItemCreateEntry(toCreate, stimulantid, reagentids);
|
||||
}
|
||||
|
||||
short createStatus = getCreateStatus(c, recipe);
|
||||
|
||||
switch(createStatus) {
|
||||
case -1:// non-available for Maker itemid has been tried to forge
|
||||
FilePrinter.printError(FilePrinter.EXPLOITS, "Player " + c.getPlayer().getName() + " tried to craft itemid " + toCreate + " using the Maker skill.");
|
||||
c.announce(MaplePacketCreator.serverNotice(1, "The requested item could not be crafted on this operation."));
|
||||
break;
|
||||
|
||||
case 1: // no items
|
||||
c.announce(MaplePacketCreator.serverNotice(1, "You don't have all required items in your inventory to make " + recipe.getRewardAmount() + " " + ii.getName(toCreate) + "."));
|
||||
break;
|
||||
|
||||
case 2: // no meso
|
||||
c.announce(MaplePacketCreator.serverNotice(1, "You don't have enough mesos (" + GameConstants.numberWithCommas(recipe.getCost()) + ") to complete this operation."));
|
||||
break;
|
||||
|
||||
case 3: // no req level
|
||||
c.announce(MaplePacketCreator.serverNotice(1, "You don't have enough level to complete this operation."));
|
||||
break;
|
||||
|
||||
case 4: // no req skill level
|
||||
c.announce(MaplePacketCreator.serverNotice(1, "You don't have enough Maker level to complete this operation."));
|
||||
break;
|
||||
|
||||
default:
|
||||
if (MapleInventoryManipulator.checkSpace(c, toCreate, (short) recipe.getRewardAmount(), "")) {
|
||||
for (Pair<Integer, Integer> p : recipe.getReqItems()) {
|
||||
c.getAbstractPlayerInteraction().gainItem(p.getLeft(), (short) -p.getRight());
|
||||
}
|
||||
|
||||
if(toDisassemble != -1) {
|
||||
MapleInventoryManipulator.removeFromSlot(c, MapleInventoryType.EQUIP, (short) pos, (short) 1, false);
|
||||
c.announce(MaplePacketCreator.getShowItemGain(toDisassemble, (short) -1, true));
|
||||
}
|
||||
|
||||
int cost = recipe.getCost();
|
||||
if(stimulantid == -1 && reagentids.isEmpty()) {
|
||||
if(cost > 0) c.getPlayer().gainMeso(-cost);
|
||||
|
||||
c.getPlayer().setCS(true);
|
||||
c.getAbstractPlayerInteraction().gainItem(toCreate, (short) recipe.getRewardAmount());
|
||||
c.getPlayer().setCS(false);
|
||||
} else {
|
||||
if(stimulantid != -1) c.getAbstractPlayerInteraction().gainItem(stimulantid, (short) -1);
|
||||
if(!reagentids.isEmpty()) {
|
||||
for(Map.Entry<Integer, Short> r : reagentids.entrySet()) {
|
||||
c.getAbstractPlayerInteraction().gainItem(r.getKey(), (short) (-1 * r.getValue()));
|
||||
}
|
||||
}
|
||||
|
||||
if(cost > 0) c.getPlayer().gainMeso(-cost);
|
||||
makerSucceeded = addBoostedMakerItem(c, toCreate, stimulantid, reagentids);
|
||||
}
|
||||
|
||||
if(makerSucceeded) c.announce(MaplePacketCreator.serverNotice(1, "You have successfully created " + recipe.getRewardAmount() + " " + ii.getName(toCreate) + "."));
|
||||
else c.getPlayer().dropMessage(5, "The Maker skill lights up, but the skill winds up as if nothing happened.");
|
||||
|
||||
c.announce(MaplePacketCreator.showMakerEffect(makerSucceeded));
|
||||
c.getPlayer().getMap().broadcastMessage(c.getPlayer(), MaplePacketCreator.showForeignMakerEffect(c.getPlayer().getId(), makerSucceeded), false);
|
||||
|
||||
if(toCreate == 4260003 && c.getPlayer().getQuestStatus(6033) == 1) {
|
||||
c.getAbstractPlayerInteraction().setQuestProgress(6033, 1);
|
||||
}
|
||||
} else {
|
||||
c.announce(MaplePacketCreator.serverNotice(1, "Your inventory is full."));
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
c.releaseClient();
|
||||
}
|
||||
} finally {
|
||||
c.unlockClient();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -40,60 +40,61 @@ public class SpawnPetProcessor {
|
||||
private static MapleDataProvider dataRoot = MapleDataProviderFactory.getDataProvider(new File(System.getProperty("wzpath") + "/Item.wz"));
|
||||
|
||||
public static void processSpawnPet(MapleClient c, byte slot, boolean lead) {
|
||||
c.lockClient();
|
||||
try {
|
||||
MapleCharacter chr = c.getPlayer();
|
||||
MaplePet pet = chr.getInventory(MapleInventoryType.CASH).getItem(slot).getPet();
|
||||
if (pet == null) return;
|
||||
if (c.tryacquireClient()) {
|
||||
try {
|
||||
MapleCharacter chr = c.getPlayer();
|
||||
MaplePet pet = chr.getInventory(MapleInventoryType.CASH).getItem(slot).getPet();
|
||||
if (pet == null) return;
|
||||
|
||||
int petid = pet.getItemId();
|
||||
if (petid == 5000028 || petid == 5000047) //Handles Dragon AND Robos
|
||||
{
|
||||
if (chr.haveItem(petid + 1)) {
|
||||
chr.dropMessage(5, "You can't hatch your " + (petid == 5000028 ? "Dragon egg" : "Robo egg") + " if you already have a Baby " + (petid == 5000028 ? "Dragon." : "Robo."));
|
||||
c.announce(MaplePacketCreator.enableActions());
|
||||
return;
|
||||
} else {
|
||||
int evolveid = MapleDataTool.getInt("info/evol1", dataRoot.getData("Pet/" + petid + ".img"));
|
||||
int petId = MaplePet.createPet(evolveid);
|
||||
if (petId == -1) {
|
||||
int petid = pet.getItemId();
|
||||
if (petid == 5000028 || petid == 5000047) //Handles Dragon AND Robos
|
||||
{
|
||||
if (chr.haveItem(petid + 1)) {
|
||||
chr.dropMessage(5, "You can't hatch your " + (petid == 5000028 ? "Dragon egg" : "Robo egg") + " if you already have a Baby " + (petid == 5000028 ? "Dragon." : "Robo."));
|
||||
c.announce(MaplePacketCreator.enableActions());
|
||||
return;
|
||||
} else {
|
||||
int evolveid = MapleDataTool.getInt("info/evol1", dataRoot.getData("Pet/" + petid + ".img"));
|
||||
int petId = MaplePet.createPet(evolveid);
|
||||
if (petId == -1) {
|
||||
return;
|
||||
}
|
||||
long expiration = chr.getInventory(MapleInventoryType.CASH).getItem(slot).getExpiration();
|
||||
MapleInventoryManipulator.removeById(c, MapleInventoryType.CASH, petid, (short) 1, false, false);
|
||||
MapleInventoryManipulator.addById(c, evolveid, (short) 1, null, petId, expiration);
|
||||
pet.deleteFromDb();
|
||||
|
||||
c.announce(MaplePacketCreator.enableActions());
|
||||
return;
|
||||
}
|
||||
long expiration = chr.getInventory(MapleInventoryType.CASH).getItem(slot).getExpiration();
|
||||
MapleInventoryManipulator.removeById(c, MapleInventoryType.CASH, petid, (short) 1, false, false);
|
||||
MapleInventoryManipulator.addById(c, evolveid, (short) 1, null, petId, expiration);
|
||||
pet.deleteFromDb();
|
||||
|
||||
}
|
||||
if (chr.getPetIndex(pet) != -1) {
|
||||
chr.unequipPet(pet, true);
|
||||
} else {
|
||||
if (chr.getSkillLevel(SkillFactory.getSkill(8)) == 0 && chr.getPet(0) != null) {
|
||||
chr.unequipPet(chr.getPet(0), false);
|
||||
}
|
||||
if (lead) {
|
||||
chr.shiftPetsRight();
|
||||
}
|
||||
Point pos = chr.getPosition();
|
||||
pos.y -= 12;
|
||||
pet.setPos(pos);
|
||||
pet.setFh(chr.getMap().getFootholds().findBelow(pet.getPos()).getId());
|
||||
pet.setStance(0);
|
||||
pet.setSummoned(true);
|
||||
pet.saveToDb();
|
||||
chr.addPet(pet);
|
||||
chr.getMap().broadcastMessage(c.getPlayer(), MaplePacketCreator.showPet(c.getPlayer(), pet, false, false), true);
|
||||
c.announce(MaplePacketCreator.petStatUpdate(c.getPlayer()));
|
||||
c.announce(MaplePacketCreator.enableActions());
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (chr.getPetIndex(pet) != -1) {
|
||||
chr.unequipPet(pet, true);
|
||||
} else {
|
||||
if (chr.getSkillLevel(SkillFactory.getSkill(8)) == 0 && chr.getPet(0) != null) {
|
||||
chr.unequipPet(chr.getPet(0), false);
|
||||
}
|
||||
if (lead) {
|
||||
chr.shiftPetsRight();
|
||||
}
|
||||
Point pos = chr.getPosition();
|
||||
pos.y -= 12;
|
||||
pet.setPos(pos);
|
||||
pet.setFh(chr.getMap().getFootholds().findBelow(pet.getPos()).getId());
|
||||
pet.setStance(0);
|
||||
pet.setSummoned(true);
|
||||
pet.saveToDb();
|
||||
chr.addPet(pet);
|
||||
chr.getMap().broadcastMessage(c.getPlayer(), MaplePacketCreator.showPet(c.getPlayer(), pet, false, false), true);
|
||||
c.announce(MaplePacketCreator.petStatUpdate(c.getPlayer()));
|
||||
c.announce(MaplePacketCreator.enableActions());
|
||||
|
||||
chr.commitExcludedItems();
|
||||
chr.getClient().getWorldServer().registerPetHunger(chr, chr.getPetIndex(pet));
|
||||
chr.commitExcludedItems();
|
||||
chr.getClient().getWorldServer().registerPetHunger(chr, chr.getPetIndex(pet));
|
||||
}
|
||||
} finally {
|
||||
c.releaseClient();
|
||||
}
|
||||
} finally {
|
||||
c.unlockClient();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -54,123 +54,124 @@ public class StorageProcessor {
|
||||
return;
|
||||
}
|
||||
|
||||
c.lockClient();
|
||||
try {
|
||||
if (mode == 4) { // take out
|
||||
byte type = slea.readByte();
|
||||
byte slot = slea.readByte();
|
||||
if (slot < 0 || slot > storage.getSlots()) { // removal starts at zero
|
||||
AutobanFactory.PACKET_EDIT.alert(c.getPlayer(), c.getPlayer().getName() + " tried to packet edit with storage.");
|
||||
FilePrinter.print(FilePrinter.EXPLOITS + c.getPlayer().getName() + ".txt", c.getPlayer().getName() + " tried to work with storage slot " + slot + "\r\n");
|
||||
c.disconnect(true, false);
|
||||
return;
|
||||
}
|
||||
slot = storage.getSlot(MapleInventoryType.getByType(type), slot);
|
||||
Item item = storage.getItem(slot);
|
||||
if (item != null) {
|
||||
if (MapleItemInformationProvider.getInstance().isPickupRestricted(item.getItemId()) && chr.haveItemWithId(item.getItemId(), true)) {
|
||||
c.announce(MaplePacketCreator.getStorageError((byte) 0x0C));
|
||||
if (c.tryacquireClient()) {
|
||||
try {
|
||||
if (mode == 4) { // take out
|
||||
byte type = slea.readByte();
|
||||
byte slot = slea.readByte();
|
||||
if (slot < 0 || slot > storage.getSlots()) { // removal starts at zero
|
||||
AutobanFactory.PACKET_EDIT.alert(c.getPlayer(), c.getPlayer().getName() + " tried to packet edit with storage.");
|
||||
FilePrinter.print(FilePrinter.EXPLOITS + c.getPlayer().getName() + ".txt", c.getPlayer().getName() + " tried to work with storage slot " + slot + "\r\n");
|
||||
c.disconnect(true, false);
|
||||
return;
|
||||
}
|
||||
|
||||
int takeoutFee = storage.getTakeOutFee();
|
||||
if (chr.getMeso() < takeoutFee) {
|
||||
slot = storage.getSlot(MapleInventoryType.getByType(type), slot);
|
||||
Item item = storage.getItem(slot);
|
||||
if (item != null) {
|
||||
if (MapleItemInformationProvider.getInstance().isPickupRestricted(item.getItemId()) && chr.haveItemWithId(item.getItemId(), true)) {
|
||||
c.announce(MaplePacketCreator.getStorageError((byte) 0x0C));
|
||||
return;
|
||||
}
|
||||
|
||||
int takeoutFee = storage.getTakeOutFee();
|
||||
if (chr.getMeso() < takeoutFee) {
|
||||
c.announce(MaplePacketCreator.getStorageError((byte) 0x0B));
|
||||
return;
|
||||
} else {
|
||||
chr.gainMeso(-takeoutFee, false);
|
||||
}
|
||||
|
||||
if (MapleInventoryManipulator.checkSpace(c, item.getItemId(), item.getQuantity(), item.getOwner())) {
|
||||
item = storage.takeOut(slot);//actually the same but idc
|
||||
String itemName = MapleItemInformationProvider.getInstance().getName(item.getItemId());
|
||||
FilePrinter.print(FilePrinter.STORAGE + c.getAccountName() + ".txt", c.getPlayer().getName() + " took out " + item.getQuantity() + " " + itemName + " (" + item.getItemId() + ")\r\n");
|
||||
chr.setUsedStorage();
|
||||
MapleKarmaManipulator.toggleKarmaFlagToUntradeable(item);
|
||||
MapleInventoryManipulator.addFromDrop(c, item, false);
|
||||
storage.sendTakenOut(c, item.getInventoryType());
|
||||
} else {
|
||||
c.announce(MaplePacketCreator.getStorageError((byte) 0x0A));
|
||||
}
|
||||
}
|
||||
} else if (mode == 5) { // store
|
||||
short slot = slea.readShort();
|
||||
int itemId = slea.readInt();
|
||||
short quantity = slea.readShort();
|
||||
MapleInventoryType slotType = ItemConstants.getInventoryType(itemId);
|
||||
MapleInventory Inv = chr.getInventory(slotType);
|
||||
if (slot < 1 || slot > Inv.getSlotLimit()) { //player inv starts at one
|
||||
AutobanFactory.PACKET_EDIT.alert(c.getPlayer(), c.getPlayer().getName() + " tried to packet edit with storage.");
|
||||
FilePrinter.print(FilePrinter.EXPLOITS + c.getPlayer().getName() + ".txt", c.getPlayer().getName() + " tried to store item at slot " + slot + "\r\n");
|
||||
c.disconnect(true, false);
|
||||
return;
|
||||
}
|
||||
if (quantity < 1 || chr.getItemQuantity(itemId, false) < quantity) {
|
||||
c.announce(MaplePacketCreator.enableActions());
|
||||
return;
|
||||
}
|
||||
if (storage.isFull()) {
|
||||
c.announce(MaplePacketCreator.getStorageError((byte) 0x11));
|
||||
return;
|
||||
}
|
||||
|
||||
int storeFee = storage.getStoreFee();
|
||||
if (chr.getMeso() < storeFee) {
|
||||
c.announce(MaplePacketCreator.getStorageError((byte) 0x0B));
|
||||
} else {
|
||||
MapleInventoryType invType = ItemConstants.getInventoryType(itemId);
|
||||
Item item = chr.getInventory(invType).getItem(slot).copy();
|
||||
if (item != null && item.getItemId() == itemId && (item.getQuantity() >= quantity || ItemConstants.isRechargeable(itemId))) {
|
||||
if (ItemConstants.isRechargeable(itemId)) {
|
||||
quantity = item.getQuantity();
|
||||
}
|
||||
|
||||
chr.gainMeso(-storeFee, false, true, false);
|
||||
MapleKarmaManipulator.toggleKarmaFlagToUntradeable(item);
|
||||
MapleInventoryManipulator.removeFromSlot(c, invType, slot, quantity, false);
|
||||
item.setQuantity(quantity);
|
||||
storage.store(item);
|
||||
storage.sendStored(c, ItemConstants.getInventoryType(itemId));
|
||||
String itemName = MapleItemInformationProvider.getInstance().getName(item.getItemId());
|
||||
FilePrinter.print(FilePrinter.STORAGE + c.getAccountName() + ".txt", c.getPlayer().getName() + " stored " + item.getQuantity() + " " + itemName + " (" + item.getItemId() + ")\r\n");
|
||||
chr.setUsedStorage();
|
||||
}
|
||||
}
|
||||
} else if (mode == 6) { // arrange items
|
||||
if(ServerConstants.USE_STORAGE_ITEM_SORT) storage.arrangeItems(c);
|
||||
c.announce(MaplePacketCreator.enableActions());
|
||||
} else if (mode == 7) { // meso
|
||||
int meso = slea.readInt();
|
||||
int storageMesos = storage.getMeso();
|
||||
int playerMesos = chr.getMeso();
|
||||
if ((meso > 0 && storageMesos >= meso) || (meso < 0 && playerMesos >= -meso)) {
|
||||
if (meso < 0 && (storageMesos - meso) < 0) {
|
||||
meso = Integer.MIN_VALUE + storageMesos;
|
||||
if (meso < playerMesos) {
|
||||
c.announce(MaplePacketCreator.enableActions());
|
||||
return;
|
||||
}
|
||||
} else if (meso > 0 && (playerMesos + meso) < 0) {
|
||||
meso = Integer.MAX_VALUE - playerMesos;
|
||||
if (meso > storageMesos) {
|
||||
c.announce(MaplePacketCreator.enableActions());
|
||||
return;
|
||||
}
|
||||
}
|
||||
storage.setMeso(storageMesos - meso);
|
||||
chr.gainMeso(meso, false, true, false);
|
||||
FilePrinter.print(FilePrinter.STORAGE + c.getPlayer().getName() + ".txt", c.getPlayer().getName() + (meso > 0 ? " took out " : " stored ") + Math.abs(meso) + " mesos\r\n");
|
||||
chr.setUsedStorage();
|
||||
} else {
|
||||
c.announce(MaplePacketCreator.enableActions());
|
||||
return;
|
||||
} else {
|
||||
chr.gainMeso(-takeoutFee, false);
|
||||
}
|
||||
|
||||
if (MapleInventoryManipulator.checkSpace(c, item.getItemId(), item.getQuantity(), item.getOwner())) {
|
||||
item = storage.takeOut(slot);//actually the same but idc
|
||||
String itemName = MapleItemInformationProvider.getInstance().getName(item.getItemId());
|
||||
FilePrinter.print(FilePrinter.STORAGE + c.getAccountName() + ".txt", c.getPlayer().getName() + " took out " + item.getQuantity() + " " + itemName + " (" + item.getItemId() + ")\r\n");
|
||||
chr.setUsedStorage();
|
||||
MapleKarmaManipulator.toggleKarmaFlagToUntradeable(item);
|
||||
MapleInventoryManipulator.addFromDrop(c, item, false);
|
||||
storage.sendTakenOut(c, item.getInventoryType());
|
||||
} else {
|
||||
c.announce(MaplePacketCreator.getStorageError((byte) 0x0A));
|
||||
}
|
||||
storage.sendMeso(c);
|
||||
} else if (mode == 8) {// close
|
||||
storage.close();
|
||||
}
|
||||
} else if (mode == 5) { // store
|
||||
short slot = slea.readShort();
|
||||
int itemId = slea.readInt();
|
||||
short quantity = slea.readShort();
|
||||
MapleInventoryType slotType = ItemConstants.getInventoryType(itemId);
|
||||
MapleInventory Inv = chr.getInventory(slotType);
|
||||
if (slot < 1 || slot > Inv.getSlotLimit()) { //player inv starts at one
|
||||
AutobanFactory.PACKET_EDIT.alert(c.getPlayer(), c.getPlayer().getName() + " tried to packet edit with storage.");
|
||||
FilePrinter.print(FilePrinter.EXPLOITS + c.getPlayer().getName() + ".txt", c.getPlayer().getName() + " tried to store item at slot " + slot + "\r\n");
|
||||
c.disconnect(true, false);
|
||||
return;
|
||||
}
|
||||
if (quantity < 1 || chr.getItemQuantity(itemId, false) < quantity) {
|
||||
c.announce(MaplePacketCreator.enableActions());
|
||||
return;
|
||||
}
|
||||
if (storage.isFull()) {
|
||||
c.announce(MaplePacketCreator.getStorageError((byte) 0x11));
|
||||
return;
|
||||
}
|
||||
|
||||
int storeFee = storage.getStoreFee();
|
||||
if (chr.getMeso() < storeFee) {
|
||||
c.announce(MaplePacketCreator.getStorageError((byte) 0x0B));
|
||||
} else {
|
||||
MapleInventoryType invType = ItemConstants.getInventoryType(itemId);
|
||||
Item item = chr.getInventory(invType).getItem(slot).copy();
|
||||
if (item != null && item.getItemId() == itemId && (item.getQuantity() >= quantity || ItemConstants.isRechargeable(itemId))) {
|
||||
if (ItemConstants.isRechargeable(itemId)) {
|
||||
quantity = item.getQuantity();
|
||||
}
|
||||
|
||||
chr.gainMeso(-storeFee, false, true, false);
|
||||
MapleKarmaManipulator.toggleKarmaFlagToUntradeable(item);
|
||||
MapleInventoryManipulator.removeFromSlot(c, invType, slot, quantity, false);
|
||||
item.setQuantity(quantity);
|
||||
storage.store(item);
|
||||
storage.sendStored(c, ItemConstants.getInventoryType(itemId));
|
||||
String itemName = MapleItemInformationProvider.getInstance().getName(item.getItemId());
|
||||
FilePrinter.print(FilePrinter.STORAGE + c.getAccountName() + ".txt", c.getPlayer().getName() + " stored " + item.getQuantity() + " " + itemName + " (" + item.getItemId() + ")\r\n");
|
||||
chr.setUsedStorage();
|
||||
}
|
||||
}
|
||||
} else if (mode == 6) { // arrange items
|
||||
if(ServerConstants.USE_STORAGE_ITEM_SORT) storage.arrangeItems(c);
|
||||
c.announce(MaplePacketCreator.enableActions());
|
||||
} else if (mode == 7) { // meso
|
||||
int meso = slea.readInt();
|
||||
int storageMesos = storage.getMeso();
|
||||
int playerMesos = chr.getMeso();
|
||||
if ((meso > 0 && storageMesos >= meso) || (meso < 0 && playerMesos >= -meso)) {
|
||||
if (meso < 0 && (storageMesos - meso) < 0) {
|
||||
meso = -2147483648 + storageMesos;
|
||||
if (meso < playerMesos) {
|
||||
c.announce(MaplePacketCreator.enableActions());
|
||||
return;
|
||||
}
|
||||
} else if (meso > 0 && (playerMesos + meso) < 0) {
|
||||
meso = 2147483647 - playerMesos;
|
||||
if (meso > storageMesos) {
|
||||
c.announce(MaplePacketCreator.enableActions());
|
||||
return;
|
||||
}
|
||||
}
|
||||
storage.setMeso(storageMesos - meso);
|
||||
chr.gainMeso(meso, false, true, false);
|
||||
FilePrinter.print(FilePrinter.STORAGE + c.getPlayer().getName() + ".txt", c.getPlayer().getName() + (meso > 0 ? " took out " : " stored ") + Math.abs(meso) + " mesos\r\n");
|
||||
chr.setUsedStorage();
|
||||
} else {
|
||||
c.announce(MaplePacketCreator.enableActions());
|
||||
return;
|
||||
}
|
||||
storage.sendMeso(c);
|
||||
} else if (mode == 8) {// close
|
||||
storage.close();
|
||||
} finally {
|
||||
c.releaseClient();
|
||||
}
|
||||
} finally {
|
||||
c.unlockClient();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user