Player/NPC Shop patch + Fredrick/Duey patch + Loot w. time GMS-like
Reading approximated unitPrice value from WZ in such a fashion that the new double value can be represented in float point without losing too much data. Fixed rechargeables with quantity 0 set on the playershop/hiredmerchant being handed back to the owner with quantity 1. Solved many concurrecy issues related with items on the field and playershop/hiredmerchant. Fixed anomalies with waiting time before picking up other players items, now acting GMS-like. Added/patched copyleft claims in files that are from my own authorship. Please see backtrack_licenses/readme.txt for more info about this move. Fixed issues with item retrieval when using bundles on playershop/hiredmerchant. Fixed some exploits with playershop/hiredmerchant. Fixed a glitch with npcshop when trying to recharge/buy items without having enough mesos. Added portal sound effect for some scripted portals that still lacked it. Fixed some exploits with NPCs Fredrick and Duey. Fixed Body Pressure not displaying damage to other players. Added a flag that permits town scrolls to act like a "banish" for players. This renders the antibanish scroll effect available.
This commit is contained in:
@@ -421,6 +421,41 @@ public class MapleItemInformationProvider {
|
||||
return pEntry;
|
||||
}
|
||||
|
||||
private static double getRoundedUnitPrice(double unitPrice, int max) {
|
||||
double intPart = Math.floor(unitPrice);
|
||||
double fractPart = unitPrice - intPart;
|
||||
if(fractPart == 0.0) return intPart;
|
||||
|
||||
double fractMask = 0.0;
|
||||
double lastFract, curFract = 1.0;
|
||||
int i = 1;
|
||||
|
||||
do {
|
||||
lastFract = curFract;
|
||||
curFract /= 2;
|
||||
|
||||
if(fractPart == curFract) {
|
||||
break;
|
||||
} else if(fractPart > curFract) {
|
||||
fractMask += curFract;
|
||||
fractPart -= curFract;
|
||||
}
|
||||
|
||||
i++;
|
||||
} while(i <= max);
|
||||
|
||||
if(i > max) {
|
||||
lastFract = curFract;
|
||||
curFract = 0.0;
|
||||
}
|
||||
|
||||
if(Math.abs(fractPart - curFract) < Math.abs(fractPart - lastFract)) {
|
||||
return intPart + fractMask + curFract;
|
||||
} else {
|
||||
return intPart + fractMask + lastFract;
|
||||
}
|
||||
}
|
||||
|
||||
private Pair<Integer, Double> getItemPriceData(int itemId) {
|
||||
MapleData item = getItemData(itemId);
|
||||
if (item == null) {
|
||||
@@ -439,7 +474,7 @@ public class MapleItemInformationProvider {
|
||||
pData = item.getChildByPath("info/unitPrice");
|
||||
if (pData != null) {
|
||||
try {
|
||||
fEntry = MapleDataTool.getDouble(pData);
|
||||
fEntry = getRoundedUnitPrice(MapleDataTool.getDouble(pData), 5);
|
||||
} catch (Exception e) {
|
||||
fEntry = (double) MapleDataTool.getInt(pData);
|
||||
}
|
||||
@@ -472,7 +507,7 @@ public class MapleItemInformationProvider {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if(!ItemConstants.isRechargable(itemId)) {
|
||||
if(!ItemConstants.isRechargeable(itemId)) {
|
||||
retPrice *= quantity;
|
||||
} else {
|
||||
retPrice += Math.ceil(quantity * getUnitPrice(itemId));
|
||||
@@ -481,38 +516,6 @@ public class MapleItemInformationProvider {
|
||||
return retPrice;
|
||||
}
|
||||
|
||||
public static boolean canSell(Item item, short quantity) {
|
||||
if (item == null) { //Basic check
|
||||
return false;
|
||||
}
|
||||
|
||||
short iQuant = item.getQuantity();
|
||||
if (iQuant == 0xFFFF) {
|
||||
iQuant = 1;
|
||||
} else if(iQuant < 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!ItemConstants.isRechargable(item.getItemId())) {
|
||||
if (iQuant == 0 || quantity > iQuant) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public static short getSellingQuantity(Item item, short quantity) {
|
||||
if (ItemConstants.isRechargable(item.getItemId())) {
|
||||
quantity = item.getQuantity();
|
||||
if (quantity == 0xFFFF) {
|
||||
quantity = 1;
|
||||
}
|
||||
}
|
||||
|
||||
return quantity;
|
||||
}
|
||||
|
||||
protected String getEquipmentSlot(int itemId) {
|
||||
if (equipmentSlotCache.containsKey(itemId)) {
|
||||
return equipmentSlotCache.get(itemId);
|
||||
|
||||
Reference in New Issue
Block a user