This commit is contained in:
dginovker
2019-11-03 22:07:57 -05:00
8 changed files with 200 additions and 112 deletions
+8
View File
@@ -111,6 +111,14 @@ public final class RSInterface {
rsInterface.actions[l3] = null;
}
}
if(rsInterface.parentID == 3822) {
rsInterface.actions[2] = "Sell 10";
rsInterface.actions[3] = "Sell X";
}
if(rsInterface.id == 3900) {
rsInterface.actions[2] = "Buy 10";
rsInterface.actions[3] = "Buy X";
}
}
if (rsInterface.type == 3) {
rsInterface.aBoolean227 = stream.readUnsignedByte() == 1;
@@ -22,7 +22,7 @@ public abstract class Player {
public ArrayList<String> killedPlayers = new ArrayList<String>();
public ArrayList<Integer> attackedPlayers = new ArrayList<Integer>();
public ArrayList<String> lastKilledPlayers = new ArrayList<String>();
public int CraftInt, Dcolor, FletchInt, clanId = -1;
public int[][] barrowCrypt = {
@@ -970,32 +970,9 @@ public abstract class Player {
wQueueWritePtr = next;
// }
}
public boolean goodDistance(int objectX, int objectY, int playerX,
int playerY, int distance) {
for (int i = 0; i <= distance; i++) {
for (int j = 0; j <= distance; j++) {
if (objectId == 2282 || objectId == 10883 || objectId == 2322
|| objectId == 4493 || objectId == 12164
|| objectId == 1721 || objectId == 1722
|| objectId == 4304 && playerX == 2619
&& playerY == 3667) {
return true;
}
if (objectX + i == playerX
&& (objectY + j == playerY || objectY - j == playerY || objectY == playerY)) {
return true;
} else if (objectX - i == playerX
&& (objectY + j == playerY || objectY - j == playerY || objectY == playerY)) {
return true;
} else if (objectX == playerX
&& (objectY + j == playerY || objectY - j == playerY || objectY == playerY)) {
return true;
}
}
}
return false;
}
public boolean goodDistance(int objectX, int objectY, int playerX, int playerY, int distance) {
return ((objectX-playerX <= distance && objectX-playerX >= -distance) && (objectY-playerY <= distance && objectY-playerY >= -distance));
}
public int getNextWalkingDirection() {
if (wQueueReadPtr == wQueueWritePtr) {
@@ -252,7 +252,10 @@ public class Trading {
if (o == null) {
return false;
}
if (!(player.playerItems[fromSlot] == itemID + 1 && player.playerItemsN[fromSlot] >= amount)) {
player.getActionSender().sendMessage("amount: " + amount);
player.getActionSender().sendMessage("player.playerItems[fromSlot]: " + player.playerItems[fromSlot]);
player.getActionSender().sendMessage("itemID + 1: " + itemID + 1);
if (!(player.playerItems[fromSlot] == itemID + 1 )){//&& player.playerItemsN[fromSlot] >= amount)) { I removed this check to permit trading max amount of item in inventory even when amount is higher than quantity in inventory.
player.getActionSender().sendMessage("You don't have that amount!");
return false;
}
@@ -7,7 +7,6 @@ import redone.game.items.ItemDefinitions;
import redone.game.players.Client;
import redone.game.players.Player;
import redone.game.players.PlayerHandler;
import redone.net.ActionSender;
import redone.util.GameLogger;
@@ -68,13 +67,13 @@ public class ShopAssistant {
public void resetShop(int ShopID) {
synchronized (player) {
int TotalItems = 0;
for (int i = 0; i < ShopHandler.MaxShopItems; i++) {
for (int i = 0; i < ShopHandler.MaxShopItems; i++) { //adds items in store when items are sold until max value.
if (ShopHandler.ShopItems[ShopID][i] > 0) {
TotalItems++;
}
}
if (TotalItems > ShopHandler.MaxShopItems) {
TotalItems = ShopHandler.MaxShopItems;
TotalItems = ShopHandler.MaxShopItems; //sets the stack of item sold to max value if the resulting amount is higher than max value.
}
player.getOutStream().createFrameVarSizeWord(53);
player.getOutStream().writeWord(3900);
@@ -334,6 +333,7 @@ public class ShopAssistant {
}
public boolean sellItem(int itemID, int fromSlot, int amount) {
player.getItemAssistant();
for (int i : Constants.ITEM_SELLABLE) {
if (i == itemID) {
player.getItemAssistant();
@@ -364,14 +364,11 @@ public class ShopAssistant {
return false;
}
}
if (amount > player.playerItemsN[fromSlot] && (ItemDefinitions.getDef()[player.playerItems[fromSlot] - 1].isNoteable == true || ItemDefinitions.getDef()[player.playerItems[fromSlot] - 1].isStackable == true)) {
amount = player.playerItemsN[fromSlot];
} else if (amount > player.getItemAssistant().getItemAmount(itemID) && ItemDefinitions.getDef()[player.playerItems[fromSlot] - 1].isNoteable == false && ItemDefinitions.getDef()[player.playerItems[fromSlot] - 1].isStackable == false) {
amount = player.getItemAssistant().getItemAmount(itemID);
}
// double ShopValue;
// double TotPrice;
String itemName = ItemAssistant.getItemName(itemID).toLowerCase();
int TotPrice2 = 0;
if (player.myShopId == 138 || player.myShopId == 58 || player.myShopId == 139) {
@@ -381,9 +378,13 @@ public class ShopAssistant {
}
if (player.getItemAssistant().freeSlots() > 0 || player.getItemAssistant().playerHasItem(995) || player.getItemAssistant().playerHasItem(6529)) { //Checks to see if player has room for coins.
if (!ItemDefinitions.getDef()[itemID].isNoteable) { //Check to see if its notable.
player.getItemAssistant().deleteItem(itemID, player.getItemAssistant().getItemSlot(itemID), amount); //don't really understand if the item isn't notable why it still needs to find the slot.
player.getItemAssistant().deleteItem2(itemID, amount);
} else {
player.getItemAssistant().deleteItem(itemID, fromSlot, amount);
player.getItemAssistant().deleteItem2(itemID, amount);
String ItemNameUnNotedItem = ItemAssistant.getItemName(itemID - 1).toLowerCase();
if (itemName.contains(ItemNameUnNotedItem)) {
itemID = itemID - 1; //Replace the noted item by it's un-noted version.
}
}
if (player.myShopId == 138 || player.myShopId == 139 || player.myShopId == 58) {
player.getItemAssistant().addItem(6529, TotPrice2); //Add the tokkul to your inventory.
@@ -401,7 +402,7 @@ public class ShopAssistant {
player.getItemAssistant().resetItems(3823);
resetShop(player.myShopId);
updatePlayerShop();
player.getActionSender().sendMessage("You sold " + amount + " " +itemName + " for " + TotPrice2 + " gp." );
player.getActionSender().sendMessage("You sold " + amount + " " +itemName + " for " + TotPrice2 + " coins." );
return true;
}
return true;
@@ -437,10 +438,50 @@ public class ShopAssistant {
private static final int FISHING_ITEMS[] = {383, 371, 377, 359, 321, 341, 353, 345, 327, 317};
public boolean buyItem(int itemID, int fromSlot, int amount) {
int iValue = 0;
int boughtQty = 0;
boolean boughtItem = false;
if (amount > 0) {
if (amount > ShopHandler.ShopItemsN[player.myShopId][fromSlot]) {
//S4
if (ShopHandler.ShopItemsN[player.myShopId][fromSlot] == 0) {
player.getActionSender().sendMessage("You can't buy that right now!");
return false;
}
if (amount > ShopHandler.ShopItemsN[player.myShopId][fromSlot] && ShopHandler.ShopItemsN[player.myShopId][fromSlot] > 0) {
amount = ShopHandler.ShopItemsN[player.myShopId][fromSlot];
}
if (amount % 23 == 0) {
amount = amount / 23;
iValue = 23; }
else if (amount % 19 == 0) {
amount = amount / 19;
iValue = 19;
} else if (amount % 17 == 0) {
amount = amount / 17;
iValue = 17;
} else if (amount % 13 == 0) {
amount = amount / 13;
iValue = 13;
} else if (amount % 11 == 0) {
amount = amount / 11;
iValue = 11;
} else if (amount % 7 == 0) {
amount = amount / 7;
iValue = 7;
} else if (amount % 5 == 0) {
amount = amount / 5;
iValue = 5;
}
else if (amount % 3 == 0) {
amount = amount / 3;
iValue = 3;
} else if (amount % 2 == 0) {
amount = amount / 2;
iValue = 2;
} else{
iValue = 1;
}
if(!player.isShopping) {
return false;
}
@@ -456,15 +497,13 @@ public class ShopAssistant {
if (!shopSellsItem(itemID)) {
return false;
}
// double ShopValue;
// double TotPrice;
int TotPrice2 = 0;
// int Overstock;
int Slot = 0;
int tokkulSlot = 0;// Tokkul
int TotPrice2 = 0; //ShopPrice
int RemainingToBuy; //Remaining of item to buy to fill the order. It's the remaining that can't fit in the loop. It has to be processed by itself after the loop.
int Slot = 0; //gp (995)
int tokkulSlot = 0;
int rangeSlot = 0;
int castleSlot = 0;
for (int i = amount; i > 0; i--) {
for (int i = amount; iValue > 0; iValue--) {
if (player.myShopId != 138 && player.myShopId != 58 && player.myShopId != 139 && player.myShopId != RANGE_SHOP && player.myShopId != PEST_SHOP && player.myShopId != CASTLE_SHOP) {
TotPrice2 = (int) Math.floor(getItemShopValue(itemID, 0, false));
} else if (player.myShopId == 138 || player.myShopId == 58 || player.myShopId == 139) {
@@ -577,34 +616,93 @@ public class ShopAssistant {
}
}
} else {
if (player.playerItemsN[Slot] >= TotPrice2) {
if (player.getItemAssistant().freeSlots() > 0 || (player.getItemAssistant().playerHasItem(itemID) && ItemDefinitions.getDef()[itemID].isStackable)) {
if (player.playerItemsN[Slot] >= TotPrice2 * amount) {
if (player.getItemAssistant().freeSlots() >= amount || (player.getItemAssistant().playerHasItem(itemID) && ItemDefinitions.getDef()[itemID].isStackable) || player.getItemAssistant().freeSlots() >= 1 && ItemDefinitions.getDef()[itemID].isStackable) {
player.getItemAssistant().deleteItem(995,
player.getItemAssistant().getItemSlot(995),
TotPrice2);
player.getItemAssistant().addItem(itemID, 1);
ShopHandler.ShopItemsN[player.myShopId][fromSlot] -= 1;
ShopHandler.ShopItemsDelay[player.myShopId][fromSlot] = 0;
TotPrice2 * amount);
player.getItemAssistant().addItem(itemID, amount); //All of these actions are performed in a loop. We are in the loop right now.
boughtQty+=amount;
ShopHandler.ShopItemsN[player.myShopId][fromSlot] -= amount; //Delete X item from shop at the slot the item is.
ShopHandler.ShopItemsDelay[player.myShopId][fromSlot] = 0; //Shit ass delay
if (fromSlot + 1 > ShopHandler.ShopItemsStandard[player.myShopId]) {
ShopHandler.ShopItems[player.myShopId][fromSlot] = 0;
ShopHandler.ShopItems[player.myShopId][fromSlot] = itemID + 1;
}
} else {
player.getActionSender()
.sendMessage(
"You don't have enough space in your inventory.");
if (player.getItemAssistant().freeSlots() == 0) {
player.getActionSender().sendMessage(
"You don't have enough space in your inventory.");
} else {
//Buys the remaining item to fill the inventory slots.
RemainingToBuy = player.getItemAssistant().freeSlots();
amount = RemainingToBuy;
player.getItemAssistant().deleteItem(995,
player.getItemAssistant().getItemSlot(995),
TotPrice2 * amount);
player.getItemAssistant().addItem(itemID, amount);
boughtQty+=amount;
ShopHandler.ShopItemsN[player.myShopId][fromSlot] -= amount;
ShopHandler.ShopItemsDelay[player.myShopId][fromSlot] = 0;
if (fromSlot + 1 > ShopHandler.ShopItemsStandard[player.myShopId]) {
ShopHandler.ShopItems[player.myShopId][fromSlot] = itemID + 1;
}
}
break;
}
boughtItem = true;
} else {
player.getActionSender().sendMessage(
"You don't have enough coins.");
break;
if (player.playerItemsN[Slot] / TotPrice2 > 0) {
amount = (int)Math.floor(player.playerItemsN[Slot] / TotPrice2);
} else {
player.getActionSender().sendMessage("You don't have enough coins.");
player.getItemAssistant().resetItems(3823);
resetShop(player.myShopId);
updatePlayerShop();
return false;
}
if (player.getItemAssistant().freeSlots() >= amount || (player.getItemAssistant().playerHasItem(itemID) && ItemDefinitions.getDef()[itemID].isStackable) || player.getItemAssistant().freeSlots() >= 1 && ItemDefinitions.getDef()[itemID].isStackable) {
player.getItemAssistant().deleteItem(995,
player.getItemAssistant().getItemSlot(995),
TotPrice2 * amount);
player.getItemAssistant().addItem(itemID, amount); //All of these actions are performed in a loop. We are in the loop right now.
boughtQty+=amount;
ShopHandler.ShopItemsN[player.myShopId][fromSlot] -= amount; //Delete X item from shop at the slot the item is.
ShopHandler.ShopItemsDelay[player.myShopId][fromSlot] = 0; //Shit ass delay
if (fromSlot + 1 > ShopHandler.ShopItemsStandard[player.myShopId]) {
ShopHandler.ShopItems[player.myShopId][fromSlot] = itemID + 1;
}
} else {
if (player.getItemAssistant().freeSlots() == 0) {
player.getActionSender().sendMessage(
"You don't have enough space in your inventory.");
} else {
//Buys the remaining item to fill the inventory slots.
RemainingToBuy = player.getItemAssistant().freeSlots();
amount = RemainingToBuy;
player.getItemAssistant().deleteItem(995,
player.getItemAssistant().getItemSlot(995),
TotPrice2 * amount);
player.getItemAssistant().addItem(itemID, amount);
boughtQty+=amount;
ShopHandler.ShopItemsN[player.myShopId][fromSlot] -= amount;
ShopHandler.ShopItemsDelay[player.myShopId][fromSlot] = 0;
if (fromSlot + 1 > ShopHandler.ShopItemsStandard[player.myShopId]) {
ShopHandler.ShopItems[player.myShopId][fromSlot] = itemID + 1;
}
}
break;
}
boughtItem = true;
}
}
}
if (boughtItem) {
player.getActionSender().sendMessage("You bought " + boughtQty + " " + ItemAssistant.getItemName(itemID).toLowerCase() + " for " + TotPrice2 * boughtQty + " coins." );
}
player.getItemAssistant().resetItems(3823);
resetShop(player.myShopId);
updatePlayerShop();
return true;
return true; //return TRUE / FALSE Update = shop&Inventory / Doesnt Update
}
return false;
}
@@ -24,7 +24,7 @@ public class Bank5 implements PacketType {
JewelryMaking.mouldItem(player, removeId, 5);
break;
case 3900:
player.getShopAssistant().buyItem(removeId, removeSlot, 1);
player.getShopAssistant().buyItem(removeId, removeSlot, 1); //this says 1 in BANKx5 but it's banking 5 for real... strange shit.
break;
case 3823:
@@ -20,15 +20,21 @@ public class BankAll implements PacketType {
player.endCurrentTask();
switch (interfaceId) {
case 3900:
player.getShopAssistant().buyItem(removeId, removeSlot, 10);
player.outStream.createFrame(27);
player.xRemoveSlot = removeSlot;
player.xRemoveId = removeId;
player.xInterfaceId = interfaceId;
break;
case 3823:
if(!player.getItemAssistant().playerHasItem(removeId)) {
return;
}
player.getShopAssistant().sellItem(removeId,
removeSlot, player.playerItemsN[removeSlot] );
player.outStream.createFrame(27);
player.xRemoveSlot = removeSlot;
player.xRemoveId = removeId;
player.xInterfaceId = interfaceId;
break;
case 7423:
@@ -20,14 +20,7 @@ public class BankX1 implements PacketType {
c.xInterfaceId = c.getInStream().readUnsignedWordA();
c.xRemoveId = c.getInStream().readSignedWordBigEndian();
}
if (c.xInterfaceId == 3900) {
c.getShopAssistant().buyItem(c.xRemoveId, c.xRemoveSlot, 20);// buy
// 20
c.xRemoveSlot = 0;
c.xInterfaceId = 0;
c.xRemoveId = 0;
return;
} else {
else {
if (c.xInterfaceId == 7423) {
c.getItemAssistant().bankItem(c.xRemoveId, c.xRemoveSlot,
Xamount);// Depo
@@ -35,7 +28,6 @@ public class BankX1 implements PacketType {
c.getItemAssistant().resetItems(7423);
}
}
if (packetType == PART1) {
synchronized (c) {
c.getOutStream().createFrame(27);
@@ -20,52 +20,56 @@ public class BankX2 implements PacketType {
Xamount = 1;
}
switch (player.xInterfaceId) {
case 5064:
/*if(!player.getItemAssistant().playerHasItem(player.playerItems[player.xRemoveSlot], Xamount))
return;*/
if (player.inPartyRoom) {
PartyRoom.depositItem(player, player.xRemoveId, player.getItemAssistant().itemAmount(player.playerItems[player.xRemoveSlot]));
case 5064:
if (player.inPartyRoom) {
PartyRoom.depositItem(player, player.xRemoveId, player.getItemAssistant().itemAmount(player.playerItems[player.xRemoveSlot]));
break;
}
if (player.inTrade) {
player.getActionSender().sendMessage("You can't store items while trading!");
return;
}
player.getItemAssistant().bankItem(player.playerItems[player.xRemoveSlot], player.xRemoveSlot, Xamount);
break;
}
if (player.inTrade) {
player.getActionSender().sendMessage("You can't store items while trading!");
return;
}
player.getItemAssistant().bankItem(player.playerItems[player.xRemoveSlot], player.xRemoveSlot, Xamount);
break;
case 5382:
/*if(!player.getItemAssistant().playerHasItem(player.playerItems[player.xRemoveSlot], Xamount))
return;*/
player.getItemAssistant().fromBank(player.bankItems[player.xRemoveSlot], player.xRemoveSlot, Xamount);
break;
case 5382:
player.getItemAssistant().fromBank(player.bankItems[player.xRemoveSlot], player.xRemoveSlot, Xamount);
break;
case 7423:
if (player.storing) {
return;
}
player.getItemAssistant().bankItem(player.playerItems[player.xRemoveSlot],
player.xRemoveSlot, Xamount);
player.getItemAssistant().resetItems(7423);
break;
case 7423:
if (player.storing) {
return;
}
player.getItemAssistant().bankItem(player.playerItems[player.xRemoveSlot],
player.xRemoveSlot, Xamount);
player.getItemAssistant().resetItems(7423);
break;
case 3322:
if (player.duelStatus <= 0) {
player.getTrading().tradeItem(player.xRemoveId, player.xRemoveSlot, Xamount);
} else {
player.getDueling().stakeItem(player.xRemoveId, player.xRemoveSlot, Xamount);
}
break;
case 3322:
if (player.duelStatus <= 0) {
player.getTrading().tradeItem(player.xRemoveId, player.xRemoveSlot, Xamount);
} else {
player.getDueling().stakeItem(player.xRemoveId, player.xRemoveSlot, Xamount);
}
break;
case 3415:
if (player.duelStatus <= 0) {
player.getTrading().fromTrade(player.xRemoveId, player.xRemoveSlot, Xamount);
}
break;
case 3415:
if (player.duelStatus <= 0) {
player.getTrading().fromTrade(player.xRemoveId, player.xRemoveSlot, Xamount);
}
break;
case 6669:
player.getDueling().fromDuel(player.xRemoveId, player.xRemoveSlot, Xamount);
break;
case 6669:
player.getDueling().fromDuel(player.xRemoveId, player.xRemoveSlot, Xamount);
break;
case 3900:
player.getShopAssistant().buyItem(player.xRemoveId, player.xRemoveSlot, Xamount);
break;
case 3823:
player.getShopAssistant().sellItem(player.xRemoveId, player.xRemoveSlot, Xamount);
break;
}
}
}