mirror of
https://github.com/2006-Scape/2006Scape.git
synced 2026-07-06 08:39:06 +00:00
Set custom prices
This commit is contained in:
@@ -64,9 +64,10 @@ public class Bot {
|
||||
if(botClient.bankItems[slot] > 0)
|
||||
items.add(botClient.bankItems[slot] - 1);
|
||||
}
|
||||
if (items.size() <= 0) return;
|
||||
int item_id = Misc.randomArrayListItem(items);
|
||||
String item_name = ItemAssistant.getItemName(item_id);
|
||||
int value = Math.max(1, botClient.getShopAssistant().getItemShopValue(item_id, 0, false));
|
||||
int value = Math.max(1, BotHandler.getItemPrice(botClient.myShopId, item_id));
|
||||
botClient.forcedChat("Selling " + item_name + " " + formatSellPrice(value) + " ea");
|
||||
/*
|
||||
Real chat - Disabled for now, can't get it to function correctly
|
||||
|
||||
@@ -36,15 +36,23 @@ public class BotHandler
|
||||
ShopHandler.createPlayerShop(playerShop.getBotClient());
|
||||
}
|
||||
|
||||
|
||||
playerShop.getBotClient().getPlayerAssistant().movePlayer(player.getX(), player.getY(), player.getH());
|
||||
playerShop.getBotClient().getItemAssistant().removeAllItems();
|
||||
Client client = playerShop.getBotClient();
|
||||
client.getPlayerAssistant().movePlayer(player.getX(), player.getY(), player.getH());
|
||||
client.getItemAssistant().removeAllItems();
|
||||
// Set bot to same level as player
|
||||
int i = 0;
|
||||
for (int level : player.playerLevel) {
|
||||
playerShop.getBotClient().playerXP[i] = player.getPlayerAssistant().getXPForLevel(level) + 5;
|
||||
playerShop.getBotClient().playerLevel[i] = level;
|
||||
playerShop.getBotClient().getPlayerAssistant().refreshSkill(i);
|
||||
playerShop.getBotClient().getPlayerAssistant().levelUp(i);
|
||||
client.playerXP[i] = player.getPlayerAssistant().getXPForLevel(level) + 5;
|
||||
client.playerLevel[i] = level;
|
||||
client.getPlayerAssistant().refreshSkill(i);
|
||||
client.getPlayerAssistant().levelUp(i);
|
||||
i++;
|
||||
}
|
||||
// Dress the bot the same as the player
|
||||
i = 0;
|
||||
for (int item_id : player.playerEquipment) {
|
||||
client.playerEquipment[i] = item_id;
|
||||
client.playerEquipmentN[i] = 1;
|
||||
i++;
|
||||
}
|
||||
}
|
||||
@@ -66,26 +74,49 @@ public class BotHandler
|
||||
return null;
|
||||
}
|
||||
|
||||
public static void addTobank(int shop_id, int item_id, int amount){
|
||||
private static Client getPlayerShop(int shop_id){
|
||||
for(Bot bot : botList) {
|
||||
if(bot != null && bot.getBotClient() != null) {
|
||||
Client botClient = bot.getBotClient();
|
||||
if(botClient.myShopId == shop_id) {
|
||||
botClient.getItemAssistant().addItemToBank(item_id, amount);
|
||||
return;
|
||||
return botClient;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static void addTobank(int shop_id, int item_id, int amount){
|
||||
Client shop = getPlayerShop(shop_id);
|
||||
if (shop == null) return;
|
||||
shop.getItemAssistant().addItemToBank(item_id, amount);
|
||||
}
|
||||
|
||||
public static void removeFrombank(int shop_id, int item_id, int amount){
|
||||
for(Bot bot : botList) {
|
||||
if(bot != null && bot.getBotClient() != null) {
|
||||
Client botClient = bot.getBotClient();
|
||||
if(botClient.myShopId == shop_id) {
|
||||
botClient.getItemAssistant().removeitemFromBank(item_id, amount);
|
||||
return;
|
||||
}
|
||||
Client shop = getPlayerShop(shop_id);
|
||||
if (shop == null) return;
|
||||
shop.getItemAssistant().removeitemFromBank(item_id, amount);
|
||||
}
|
||||
|
||||
public static int getItemPrice(int shop_id, int item_id){
|
||||
item_id++;
|
||||
Client shop = getPlayerShop(shop_id);
|
||||
if (shop == null) return 1;
|
||||
for (int slot = 0; slot < ShopHandler.MaxShopItems; slot++) {
|
||||
if (shop.bankItems[slot] == item_id) {
|
||||
return Math.max(1, shop.bankItemsV[slot]);
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
public static void setPrice(int shop_id, int item_id, int amount){
|
||||
item_id++;
|
||||
Client shop = getPlayerShop(shop_id);
|
||||
if (shop == null) return;
|
||||
for (int slot = 0; slot < ShopHandler.MaxShopItems; slot++) {
|
||||
if (shop.bankItems[slot] == item_id) {
|
||||
shop.bankItemsV[slot] = amount;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -732,6 +732,8 @@ public abstract class Player {
|
||||
public int playerItemsN[] = new int[28];
|
||||
public int bankItems[] = new int[Constants.BANK_SIZE];
|
||||
public int bankItemsN[] = new int[Constants.BANK_SIZE];
|
||||
// used for player owned shops
|
||||
public int bankItemsV[] = new int[Constants.BANK_SIZE];
|
||||
public boolean bankNotes = false;
|
||||
public boolean shouldSave = false;
|
||||
|
||||
|
||||
@@ -59,7 +59,7 @@ public class PlayerSave {
|
||||
token = token.trim();
|
||||
token2 = line.substring(spot + 1);
|
||||
token2 = token2.trim();
|
||||
token3 = token2.split("\t");
|
||||
token3 = token2.split("\t+");
|
||||
switch (ReadMode) {
|
||||
case 1:
|
||||
if (!doRealLogin)
|
||||
@@ -422,13 +422,14 @@ public class PlayerSave {
|
||||
case 6:
|
||||
if (token.equals("character-item")) {
|
||||
player.playerItems[Integer.parseInt(token3[0])] = Integer.parseInt(token3[1]);
|
||||
player.playerItemsN[Integer.parseInt(token3[0])] = Integer .parseInt(token3[2]);
|
||||
player.playerItemsN[Integer.parseInt(token3[0])] = Integer.parseInt(token3[2]);
|
||||
}
|
||||
break;
|
||||
case 7:
|
||||
if (token.equals("character-bank")) {
|
||||
player.bankItems[Integer.parseInt(token3[0])] = Integer.parseInt(token3[1]);
|
||||
player.bankItemsN[Integer.parseInt(token3[0])] = Integer.parseInt(token3[2]);
|
||||
player.bankItemsV[Integer.parseInt(token3[0])] = token3.length > 3 ? Integer.parseInt(token3[3]) : 1;
|
||||
}
|
||||
break;
|
||||
case 8:
|
||||
@@ -1048,15 +1049,13 @@ public class PlayerSave {
|
||||
characterfile.newLine();
|
||||
for (int i = 0; i < player.bankItems.length; i++) {
|
||||
if (player.bankItems[i] > 0) {
|
||||
characterfile.write("character-bank = ", 0, 17);
|
||||
characterfile.write(Integer.toString(i), 0, Integer
|
||||
.toString(i).length());
|
||||
characterfile.write(" ", 0, 1);
|
||||
characterfile.write(Integer.toString(player.bankItems[i]),
|
||||
0, Integer.toString(player.bankItems[i]).length());
|
||||
characterfile.write(" ", 0, 1);
|
||||
characterfile.write(Integer.toString(player.bankItemsN[i]),
|
||||
0, Integer.toString(player.bankItemsN[i]).length());
|
||||
String lineItem = "character-bank = " + i;
|
||||
lineItem += "\t" + player.bankItems[i];
|
||||
lineItem += "\t" + player.bankItemsN[i];
|
||||
// this is for player owned stores
|
||||
if (player.isBot)
|
||||
lineItem += "\t" + player.bankItemsV[i];
|
||||
characterfile.write(lineItem);
|
||||
characterfile.newLine();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -126,25 +126,28 @@ public class ShopAssistant {
|
||||
* buy item from shop (Shop Price)
|
||||
**/
|
||||
|
||||
public void buyFromShopPrice(int removeId, int removeSlot) {
|
||||
int ShopValue = (int) Math.floor(getItemShopValue(removeId, 0, false));
|
||||
int SpecialValue = getTokkulValue(removeId);
|
||||
public void buyFromShopPrice(int itemID) {
|
||||
int ShopValue = (int) Math.floor(getItemShopValue(itemID, 0, false));
|
||||
int SpecialValue = getTokkulValue(itemID);
|
||||
String ShopAdd = "";
|
||||
// player owned shop
|
||||
if (ShopHandler.ShopBModifier[player.myShopId] == 0) {
|
||||
ShopValue = BotHandler.getItemPrice(player.myShopId, itemID);
|
||||
}
|
||||
if (player.myShopId == 138 || player.myShopId == 139 || player.myShopId == 58) {
|
||||
player.getActionSender().sendMessage(
|
||||
ItemAssistant.getItemName(removeId) + ": currently costs " + SpecialValue + " tokkul.");
|
||||
player.getActionSender().sendMessage(ItemAssistant.getItemName(itemID) + ": currently costs " + SpecialValue + " tokkul.");
|
||||
return;
|
||||
}
|
||||
if (player.myShopId == PEST_SHOP) {
|
||||
player.getActionSender().sendMessage(ItemAssistant.getItemName(removeId)+": currently costs " + getPestItemValue(removeId) + " pest control points.");
|
||||
player.getActionSender().sendMessage(ItemAssistant.getItemName(itemID)+": currently costs " + getPestItemValue(itemID) + " pest control points.");
|
||||
return;
|
||||
}
|
||||
if (player.myShopId == CASTLE_SHOP) {
|
||||
player.getActionSender().sendMessage(ItemAssistant.getItemName(removeId)+": currently costs " + getCastleItemValue(removeId) + " castle wars tickets.");
|
||||
player.getActionSender().sendMessage(ItemAssistant.getItemName(itemID)+": currently costs " + getCastleItemValue(itemID) + " castle wars tickets.");
|
||||
return;
|
||||
}
|
||||
if (player.myShopId == RANGE_SHOP) {
|
||||
player.getActionSender().sendMessage(ItemAssistant.getItemName(removeId)+": currently costs " + getRGItemValue(removeId) + " archery tickets.");
|
||||
player.getActionSender().sendMessage(ItemAssistant.getItemName(itemID)+": currently costs " + getRGItemValue(itemID) + " archery tickets.");
|
||||
return;
|
||||
}
|
||||
if (ShopValue >= 1000 && ShopValue < 1000000) {
|
||||
@@ -152,9 +155,7 @@ public class ShopAssistant {
|
||||
} else if (ShopValue >= 1000000) {
|
||||
ShopAdd = " (" + ShopValue / 1000000 + " million)";
|
||||
}
|
||||
player.getActionSender().sendMessage(
|
||||
ItemAssistant.getItemName(removeId) + ": currently costs "
|
||||
+ ShopValue + " coins" + ShopAdd);
|
||||
player.getActionSender().sendMessage(ItemAssistant.getItemName(itemID) + ": currently costs " + ShopValue + " coins" + ShopAdd);
|
||||
}
|
||||
|
||||
public int getCastleItemValue(int id) {
|
||||
@@ -376,6 +377,20 @@ public class ShopAssistant {
|
||||
player.getActionSender().sendMessage("You can't sell " + ItemAssistant.getItemName(itemID).toLowerCase() + " to this store.");
|
||||
return false;
|
||||
}
|
||||
// player owned store, setting item price
|
||||
if (ShopHandler.ShopName[player.myShopId].equalsIgnoreCase(player.properName + "'s Store")) {
|
||||
// No items in stock, we are adding 1 and setting the price
|
||||
if (ShopHandler.getStock(player.myShopId, itemID) <= 0){
|
||||
player.getItemAssistant().deleteItem(itemID, 1);
|
||||
BotHandler.addTobank(player.myShopId, itemID, 1);
|
||||
BotHandler.setPrice(player.myShopId, itemID, amount);
|
||||
addShopItem(itemID, 1);
|
||||
player.getItemAssistant().resetItems(3823);
|
||||
resetShop(player.myShopId);
|
||||
updatePlayerShop();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (amount > inventoryAmount) {
|
||||
amount = inventoryAmount;
|
||||
}
|
||||
@@ -489,7 +504,11 @@ public class ShopAssistant {
|
||||
}
|
||||
int value = 0; // Item Value
|
||||
int currency = 995; // currency this shop uses
|
||||
if (player.myShopId == 138 || player.myShopId == 58 || player.myShopId == 139) {
|
||||
// player owned shop
|
||||
if (ShopHandler.ShopBModifier[player.myShopId] == 0) {
|
||||
value = BotHandler.getItemPrice(player.myShopId, itemID);
|
||||
currency = 995; // gp
|
||||
} else if (player.myShopId == 138 || player.myShopId == 58 || player.myShopId == 139) {
|
||||
value = getTokkulValue(itemID);
|
||||
currency = 6529; // Tokkul
|
||||
} else if (player.myShopId == RANGE_SHOP) {
|
||||
|
||||
@@ -213,8 +213,6 @@ public class ShopHandler {
|
||||
public static int getStock(int shop_id, int item_id){
|
||||
item_id++;
|
||||
for (int j = 0; j < MaxShopItems; j++) {
|
||||
if (ShopItems[shop_id][j] > 0)
|
||||
System.out.println("item " + item_id + " = " + ShopItemsN[shop_id][j]);
|
||||
if (ShopItems[shop_id][j] == item_id) {
|
||||
return ShopItemsN[shop_id][j];
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@ public class BankAll implements PacketType {
|
||||
int removeId = player.getInStream().readUnsignedWordA();
|
||||
player.endCurrentTask();
|
||||
switch (interfaceId) {
|
||||
// buy x
|
||||
case 3900:
|
||||
player.outStream.createFrame(27);
|
||||
player.xRemoveSlot = removeSlot;
|
||||
@@ -26,11 +27,11 @@ public class BankAll implements PacketType {
|
||||
player.xInterfaceId = interfaceId;
|
||||
break;
|
||||
|
||||
// sell x
|
||||
case 3823:
|
||||
if(!player.getItemAssistant().playerHasItem(removeId)) {
|
||||
return;
|
||||
}
|
||||
|
||||
player.outStream.createFrame(27);
|
||||
player.xRemoveSlot = removeSlot;
|
||||
player.xRemoveId = removeId;
|
||||
|
||||
@@ -22,9 +22,7 @@ public class BankX1 implements PacketType {
|
||||
}
|
||||
else {
|
||||
if (c.xInterfaceId == 7423) {
|
||||
c.getItemAssistant().bankItem(c.xRemoveId, c.xRemoveSlot,
|
||||
Xamount);// Depo
|
||||
// 1
|
||||
c.getItemAssistant().bankItem(c.xRemoveId, c.xRemoveSlot, Xamount);// Depo 1
|
||||
c.getItemAssistant().resetItems(7423);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,8 +40,7 @@ public class BankX2 implements PacketType {
|
||||
if (player.storing) {
|
||||
return;
|
||||
}
|
||||
player.getItemAssistant().bankItem(player.playerItems[player.xRemoveSlot],
|
||||
player.xRemoveSlot, Xamount);
|
||||
player.getItemAssistant().bankItem(player.playerItems[player.xRemoveSlot], player.xRemoveSlot, Xamount);
|
||||
player.getItemAssistant().resetItems(7423);
|
||||
break;
|
||||
|
||||
@@ -64,7 +63,7 @@ public class BankX2 implements PacketType {
|
||||
break;
|
||||
|
||||
case 3900:
|
||||
player.getShopAssistant().buyItem(player.xRemoveId, player.xRemoveSlot, Xamount);
|
||||
player.getShopAssistant().buyItem(player.xRemoveId, player.xRemoveSlot, Xamount);
|
||||
break;
|
||||
|
||||
case 3823:
|
||||
|
||||
@@ -60,7 +60,7 @@ public class RemoveItem implements PacketType {
|
||||
break;
|
||||
|
||||
case 3900:
|
||||
c.getShopAssistant().buyFromShopPrice(removeId, removeSlot);
|
||||
c.getShopAssistant().buyFromShopPrice(removeId);
|
||||
break;
|
||||
|
||||
case 3823:
|
||||
|
||||
Reference in New Issue
Block a user