mirror of
https://github.com/2006-Scape/2006Scape.git
synced 2026-07-02 16:49:03 +00:00
Merge branch 'RedSparr0w-bot'
This commit is contained in:
@@ -134,8 +134,7 @@ shop = 133 Gianne's_Restraunt 2 2 2223 10 2225 10 2221 10 2219 10 2227 10 2233 1
|
||||
shop = 134 Gulluck_and_Sons 2 2 882 1000 841 10 39 100 40 100 41 100 42 100 1349 10 1353 10 1369 10 1307 10 1309 10 1311 10 1313 10 1315 10 1317 10
|
||||
shop = 135 Tony's_Pizza_Bases 2 2 2283 10
|
||||
shop = 136 Wilderness_General_Store 1 1 1931 30 1935 10 1735 10 1925 30 1923 10 590 10 1755 10 2347 10 550 10 946 10
|
||||
shop = 137 Neil's_Wilderness_Cape_Shop 2 2 4327 10
|
||||
4347 10 4367 10 4387 10 4407 10
|
||||
shop = 137 Neil's_Wilderness_Cape_Shop 2 2 4327 10 4347 10 4367 10 4387 10 4407 10
|
||||
shop = 138 Tzhaar_Hur_Tel's_Equipment_Store 2 2 6522 10 6523 10 6524 10 6525 10 6526 10 6527 10 6528 10 6568 10
|
||||
shop = 139 Tzhaar_Hur_Lek's_Ore_and_Gem_Store 2 2 438 5 436 5 453 2 1623 1 1621 1 6571 1
|
||||
shop = 140 William's_Wilderness_Cape_Shop 2 2 4315 10 4335 10 4355 10 4375 10 4395 10
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1,5 +1,7 @@
|
||||
#!/bin/bash
|
||||
echo NOTE: This program is meant to be run by the live server admin only!
|
||||
echo You probably don\'t want to run this, even if you\'re developing locally!
|
||||
for
|
||||
rm -rf redone/
|
||||
cp -r ../CompiledServer/production/2006rebotted/redone .
|
||||
java -Xmx15G -cp ".:./libs/*" redone.Server
|
||||
|
||||
@@ -178,7 +178,7 @@ public class Constants {
|
||||
"shade", "skeleton", "skeleton brute", "skeleton thug", "skeleton warload", "summoned zombie",
|
||||
"skorge", "tortured soul", "undead chicken", "undead cow", "undead one", "undead troll", "zombie", "zombie rat", "zogre"
|
||||
};
|
||||
public final static int TIMEOUT = 20;
|
||||
public final static int TIMEOUT = 60;
|
||||
public final static int CYCLE_TIME = 600;
|
||||
public final static int BUFFER_SIZE = 10000;
|
||||
|
||||
|
||||
@@ -0,0 +1,95 @@
|
||||
package redone.game.bots;
|
||||
|
||||
import redone.Server;
|
||||
import redone.game.items.ItemAssistant;
|
||||
import redone.game.players.Client;
|
||||
import redone.util.Misc;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.*;
|
||||
|
||||
import static redone.game.players.PlayerSave.loadPlayerInfo;
|
||||
|
||||
public class Bot {
|
||||
|
||||
private Client botClient;
|
||||
static Timer timer = new Timer();
|
||||
|
||||
public Bot(String username, int x, int y, int z) {
|
||||
botClient = new Client(null);
|
||||
botClient.playerName = username;
|
||||
|
||||
botClient.playerName = username;
|
||||
botClient.playerName2 = botClient.playerName;
|
||||
// TODO: randomize the bot passwords
|
||||
botClient.playerPass = "bot_password";
|
||||
|
||||
botClient.properName = Character.toUpperCase(username.charAt(1)) + username.substring(2);
|
||||
|
||||
botClient.saveFile = true;
|
||||
botClient.saveCharacter = true;
|
||||
botClient.isActive = true;
|
||||
botClient.disconnected = false;
|
||||
botClient.npcCanAttack = false;
|
||||
Server.playerHandler.newPlayerClient(botClient);
|
||||
|
||||
botClient.getPlayerAssistant().movePlayer(x, y, z);
|
||||
|
||||
loadPlayerInfo(botClient, username, "bot_password", false);
|
||||
new TradeChat().run();
|
||||
}
|
||||
|
||||
public Client getBotClient() {
|
||||
return botClient;
|
||||
}
|
||||
|
||||
class TradeChat extends TimerTask {
|
||||
@Override
|
||||
public void run() {
|
||||
sendTradeChat();
|
||||
int delay = (5 + new Random().nextInt(15)) * 1000;
|
||||
timer.schedule(new TradeChat(), delay);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void sendTradeChat() {
|
||||
ArrayList<Integer> items = new ArrayList<Integer>();
|
||||
for (int slot = 0; slot < 40; slot++){
|
||||
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).toLowerCase();
|
||||
int value = BotHandler.getItemPrice(botClient.myShopId, item_id);
|
||||
if (value <= 0) return;
|
||||
|
||||
String _message = "Selling " + item_name + " " + formatSellPrice(value) + " ea - " + botClient.playerName;
|
||||
|
||||
// Disable the force chat for now, maybe use that instead, maybe not
|
||||
//botClient.forcedChat("Selling " + item_name + " " + formatSellPrice(value) + " ea");
|
||||
|
||||
// Normal chat from here down:
|
||||
botClient.setChatTextColor(Misc.random(11));
|
||||
botClient.setChatTextEffects(Misc.random(5));
|
||||
Misc.textPack(botClient.inStream, _message);
|
||||
botClient.setChatTextSize((byte) botClient.inStream.currentOffset);
|
||||
botClient.setChatText(botClient.inStream.buffer);
|
||||
botClient.inStream.currentOffset = 0;
|
||||
botClient.setChatTextUpdateRequired(true);
|
||||
}
|
||||
|
||||
private String formatSellPrice(int price) {
|
||||
DecimalFormat df = new DecimalFormat("#.##");
|
||||
if (price >= 1e9) {
|
||||
return df.format(Math.floor(price / 1e8) / 10) + "b";
|
||||
} else if (price >= 1e6) {
|
||||
return df.format(Math.floor(price / 1e5) / 10) + "m";
|
||||
} else if (price >= 1e3) {
|
||||
return df.format(Math.floor(price / 100) / 10) + "k";
|
||||
} else {
|
||||
return price + "gp";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
package redone.game.bots;
|
||||
|
||||
public class BotConstants {
|
||||
public static final int MAX_BOTS = 100;
|
||||
}
|
||||
@@ -0,0 +1,194 @@
|
||||
package redone.game.bots;
|
||||
|
||||
import io.netty.util.Timeout;
|
||||
import redone.Constants;
|
||||
import redone.game.players.Client;
|
||||
import redone.game.players.PlayerHandler;
|
||||
import redone.game.shops.ShopHandler;
|
||||
import redone.util.Misc;
|
||||
|
||||
import java.security.SecureRandom;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
public class BotHandler
|
||||
{
|
||||
static final List<Bot> botList = new ArrayList<>(BotConstants.MAX_BOTS);
|
||||
static final Random random = new SecureRandom();
|
||||
static final int currency = 995;
|
||||
|
||||
public static Bot connectBot(String username, int x, int y, int z) {
|
||||
Bot bot;
|
||||
if (PlayerHandler.playerCount >= Constants.MAX_PLAYERS) {
|
||||
System.out.println("Bot could not be connected, server is full.");
|
||||
return null;
|
||||
}
|
||||
|
||||
bot = new Bot(username, x, y, z);
|
||||
botList.add(bot);
|
||||
return bot;
|
||||
}
|
||||
|
||||
public static void playerShop(Client player){
|
||||
// Must be in the correct zones
|
||||
if (!player.inPlayerShopArea() && !player.inBankArea()) {
|
||||
player.getActionSender().sendMessage("You need to be in a bank zone or trade area for this.");
|
||||
return;
|
||||
}
|
||||
|
||||
Client playerShop = getPlayerShop(player);
|
||||
|
||||
if (playerShop == null) {
|
||||
String shopName = getShopName(player);
|
||||
Bot bot = connectBot(shopName, player.getX(), player.getY(), player.getH());
|
||||
playerShop = bot.getBotClient();
|
||||
ShopHandler.createPlayerShop(playerShop);
|
||||
}
|
||||
|
||||
Client client = playerShop;
|
||||
client.getPlayerAssistant().movePlayer(player.getX(), player.getY(), player.getH());
|
||||
|
||||
|
||||
client.faceUpdate(player.face);
|
||||
client.turnPlayerTo(player.getX() + Misc.random(-1, 1), player.getY() + Misc.random(-1, 1));
|
||||
int i = 0;
|
||||
// Remove all items except money
|
||||
for (int item_id : client.playerItems) {
|
||||
if (item_id > 0 && item_id != currency + 1){
|
||||
client.playerItems[i] = 0;
|
||||
client.playerItemsN[i] = 0;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
// Set bot to same level as player
|
||||
i = 0;
|
||||
for (int level : player.playerLevel) {
|
||||
client.playerLevel[i] = level;
|
||||
client.getPlayerAssistant().refreshSkill(i);
|
||||
i++;
|
||||
}
|
||||
// Take the appearance of the player
|
||||
i = 0;
|
||||
for (int id : player.playerAppearance) {
|
||||
client.playerAppearance[i] = id;
|
||||
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++;
|
||||
}
|
||||
}
|
||||
|
||||
private static String getShopName(Client player){
|
||||
return "♥" + player.playerName;
|
||||
}
|
||||
|
||||
private static Client getPlayerShop(Client player){
|
||||
String shopName = getShopName(player);
|
||||
for(Bot bot : botList) {
|
||||
if(bot != null && bot.getBotClient() != null) {
|
||||
Client botClient = bot.getBotClient();
|
||||
if(botClient.playerName.equalsIgnoreCase(shopName)) {
|
||||
return botClient;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
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) {
|
||||
return botClient;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static void closeShop(Client player) {
|
||||
Client shop = getPlayerShop(player);
|
||||
if (shop == null) return;
|
||||
shop.getPlayerAssistant().movePlayer(0,0,0);
|
||||
new Thread(() -> {
|
||||
try {
|
||||
Thread.sleep(500);
|
||||
shop.disconnected = true;
|
||||
shop.logout(true);
|
||||
for (int index = 0; index < botList.size(); index++){
|
||||
if (botList.get(index).getBotClient().properName.equalsIgnoreCase(player.properName)) {
|
||||
botList.remove(index);
|
||||
return;
|
||||
}
|
||||
index++;
|
||||
}
|
||||
}
|
||||
catch (Exception e){
|
||||
System.err.println(e);
|
||||
}
|
||||
}).start();
|
||||
}
|
||||
|
||||
public static void addCoins(int shop_id, int amount){
|
||||
Client shop = getPlayerShop(shop_id);
|
||||
if (shop == null) return;
|
||||
shop.getItemAssistant().addItem(currency, amount);
|
||||
}
|
||||
|
||||
public static void takeCoins(Client player){
|
||||
if (!player.getItemAssistant().playerHasItem(currency) && player.getItemAssistant().freeSlots() <= 0) {
|
||||
player.getActionSender().sendMessage("You don't have enough space in your inventory.");
|
||||
return;
|
||||
}
|
||||
Client shop = getPlayerShop(player);
|
||||
if (shop == null) return;
|
||||
if (!shop.getItemAssistant().playerHasItem(currency)) {
|
||||
player.getActionSender().sendMessage("There are no coins to collect.");
|
||||
return;
|
||||
}
|
||||
int totalCoins = shop.getItemAssistant().getItemAmount(currency);
|
||||
player.getItemAssistant().addItem(currency, totalCoins);
|
||||
shop.getItemAssistant().deleteItem(currency, totalCoins);
|
||||
}
|
||||
|
||||
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){
|
||||
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 0;
|
||||
for (int slot = 0; slot < ShopHandler.MaxShopItems; slot++) {
|
||||
if (shop.bankItems[slot] == item_id) {
|
||||
return Math.max(1, shop.bankItemsV[slot]);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
package redone.game.content.combat.range;
|
||||
|
||||
import redone.Constants;
|
||||
import redone.Server;
|
||||
import redone.event.CycleEvent;
|
||||
import redone.event.CycleEventContainer;
|
||||
@@ -356,7 +357,7 @@ public class DwarfCannon {
|
||||
}
|
||||
|
||||
public boolean noSetUpArea() {
|
||||
return (player.absX >= 2024 && player.absX <= 2047 && player.absY >= 2047 && player.absY <= 4542) || player.inBank() || player.inFightCaves() || (player.absX >= 3161 && player.absX <= 3168 && player.absY >= 3486 && player.absY <= 3493);
|
||||
return player.inBank() || player.inFightCaves();
|
||||
}
|
||||
|
||||
private int getHit() {
|
||||
@@ -379,17 +380,6 @@ public class DwarfCannon {
|
||||
if (damage > target.HP) {
|
||||
damage = target.HP;
|
||||
}
|
||||
if (player.inMulti() && target.inMulti()) {
|
||||
cannonProjectile(target);
|
||||
target.hitDiff2 = damage;
|
||||
target.HP -= damage;
|
||||
target.killerId = player.playerId;
|
||||
target.facePlayer(player.playerId);
|
||||
target.hitUpdateRequired2 = true;
|
||||
target.updateRequired = true;
|
||||
myBalls -= 1;
|
||||
player.getPlayerAssistant().addSkillXP(damage * expRate, player.playerRanged);
|
||||
}
|
||||
if (!player.inMulti()) {
|
||||
if (target.underAttackBy > 0 && target.underAttackBy != player.playerId) {
|
||||
return;
|
||||
@@ -397,16 +387,18 @@ public class DwarfCannon {
|
||||
if (player.underAttackBy2 > 0 && player.underAttackBy2 != target.npcId) {
|
||||
return;
|
||||
}
|
||||
cannonProjectile(target);
|
||||
target.hitDiff2 = damage;
|
||||
target.HP -= damage;
|
||||
target.killerId = player.playerId;
|
||||
target.facePlayer(player.playerId);
|
||||
target.hitUpdateRequired2 = true;
|
||||
target.updateRequired = true;
|
||||
myBalls -= 1;
|
||||
player.getPlayerAssistant().addSkillXP(damage * expRate, player.playerRanged);
|
||||
}
|
||||
cannonProjectile(target);
|
||||
target.hitDiff2 = damage;
|
||||
target.HP -= damage;
|
||||
player.globalDamageDealt += damage;
|
||||
target.killerId = player.playerId;
|
||||
target.killedBy = player.playerId;
|
||||
target.facePlayer(player.playerId);
|
||||
target.hitUpdateRequired2 = true;
|
||||
target.updateRequired = true;
|
||||
myBalls -= 1;
|
||||
player.getPlayerAssistant().addSkillXP(damage * Constants.RANGE_EXP_RATE, player.playerRanged);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -16,52 +16,34 @@ public class ImpCatcher {
|
||||
}
|
||||
|
||||
public void showInformation() {
|
||||
for (int i = 8144; i < 8195; i++) {
|
||||
for (int i = 8144; i < 8295; i++) {
|
||||
client.getPlayerAssistant().sendFrame126("", i);
|
||||
}
|
||||
client.getPlayerAssistant().sendFrame126("@dre@Imp Catcher", 8144);
|
||||
client.getPlayerAssistant().sendFrame126("", 8145);
|
||||
if (client.impsC == 0) {
|
||||
client.getPlayerAssistant()
|
||||
.sendFrame126(
|
||||
"I can start this quest by speaking to Wizard Mizgog who is",
|
||||
8147);
|
||||
client.getPlayerAssistant().sendFrame126("in the Wizard's Tower.",
|
||||
8148);
|
||||
client.getPlayerAssistant().sendFrame126( "I can start this quest by speaking to Wizard Mizgog who is", 8147);
|
||||
client.getPlayerAssistant().sendFrame126("in the Wizard's Tower.", 8148);
|
||||
} else if (client.impsC == 1) {
|
||||
client.getPlayerAssistant()
|
||||
.sendFrame126(
|
||||
"@str@I can start this quest by speaking to Wizard Mizgog who is",
|
||||
8147);
|
||||
client.getPlayerAssistant().sendFrame126(
|
||||
"@str@in the Wizard's Tower.", 8148);
|
||||
client.getPlayerAssistant().sendFrame126("@str@I can start this quest by speaking to Wizard Mizgog who is", 8147);
|
||||
client.getPlayerAssistant().sendFrame126("@str@in the Wizard's Tower.", 8148);
|
||||
client.getPlayerAssistant().sendFrame126("", 8149);
|
||||
client.getPlayerAssistant().sendFrame126(
|
||||
"Wizard Mizgog have asked you to get the following items:",
|
||||
8150);
|
||||
client.getPlayerAssistant().sendFrame126("Wizard Mizgog have asked you to get the following items:", 8150);
|
||||
client.getPlayerAssistant().sendFrame126("Red bead", 8151);
|
||||
client.getPlayerAssistant().sendFrame126("Yellow bead", 8152);
|
||||
client.getPlayerAssistant().sendFrame126("Black bead", 8153);
|
||||
client.getPlayerAssistant().sendFrame126("White bead", 8154);
|
||||
} else if (client.impsC == 2) {
|
||||
client.getPlayerAssistant()
|
||||
.sendFrame126(
|
||||
"@str@I can start this quest by speaking to Wizard Mizgog who is",
|
||||
8147);
|
||||
client.getPlayerAssistant().sendFrame126(
|
||||
"@str@in the Wizard's Tower.", 8148);
|
||||
client.getPlayerAssistant().sendFrame126("@str@I can start this quest by speaking to Wizard Mizgog who is", 8147);
|
||||
client.getPlayerAssistant().sendFrame126("@str@in the Wizard's Tower.", 8148);
|
||||
client.getPlayerAssistant().sendFrame126("", 8149);
|
||||
client.getPlayerAssistant()
|
||||
.sendFrame126(
|
||||
"@str@Wizard Mizgog have asked you to get the following items:",
|
||||
8150);
|
||||
client.getPlayerAssistant().sendFrame126("@str@Wizard Mizgog have asked you to get the following items:", 8150);
|
||||
client.getPlayerAssistant().sendFrame126("@str@Red bead", 8151);
|
||||
client.getPlayerAssistant().sendFrame126("@str@Yellow bead", 8152);
|
||||
client.getPlayerAssistant().sendFrame126("@str@Black bead", 8153);
|
||||
client.getPlayerAssistant().sendFrame126("@str@White bead", 8154);
|
||||
client.getPlayerAssistant().sendFrame126("", 8155);
|
||||
client.getPlayerAssistant().sendFrame126(
|
||||
"You have completed this quest!", 8156);
|
||||
client.getPlayerAssistant().sendFrame126("You have completed this quest!", 8156);
|
||||
}
|
||||
client.getPlayerAssistant().showInterface(8134);
|
||||
}
|
||||
|
||||
@@ -227,9 +227,10 @@ public class ItemAssistant {
|
||||
}
|
||||
|
||||
public void addItemToBank(int itemId, int amount) {
|
||||
itemId++;
|
||||
for (int i = 0; i < Constants.BANK_SIZE; i++) {
|
||||
if (c.bankItems[i] <= 0 || c.bankItems[i] == itemId + 1 && c.bankItemsN[i] + amount < Integer.MAX_VALUE) {
|
||||
c.bankItems[i] = itemId + 1;
|
||||
if (c.bankItems[i] <= 0 || c.bankItems[i] == itemId && c.bankItemsN[i] + amount < Integer.MAX_VALUE) {
|
||||
c.bankItems[i] = itemId;
|
||||
c.bankItemsN[i] += amount;
|
||||
resetBank();
|
||||
return;
|
||||
@@ -237,6 +238,22 @@ public class ItemAssistant {
|
||||
}
|
||||
}
|
||||
|
||||
public void removeitemFromBank(int itemId, int amount) {
|
||||
itemId++;
|
||||
for (int i = 0; i < Constants.BANK_SIZE; i++) {
|
||||
if (c.bankItems[i] == itemId) {
|
||||
c.bankItemsN[i] -= amount;
|
||||
if (c.bankItemsN[i] <= 0) {
|
||||
c.bankItems[i] = 0;
|
||||
c.bankItemsN[i] = 0;
|
||||
}
|
||||
resetBank();
|
||||
rearrangeBank();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void resetItems(int WriteFrame) {
|
||||
// synchronized(c) {
|
||||
if (c.getOutStream() != null && c != null) {
|
||||
@@ -1787,9 +1804,11 @@ public class ItemAssistant {
|
||||
for (int j = k; j <= highestSlot; j++) {
|
||||
c.bankItems[j - spots] = c.bankItems[j];
|
||||
c.bankItemsN[j - spots] = c.bankItemsN[j];
|
||||
c.bankItemsV[j - spots] = c.bankItemsV[j];
|
||||
stop = true;
|
||||
c.bankItems[j] = 0;
|
||||
c.bankItemsN[j] = 0;
|
||||
c.bankItemsV[j] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1804,7 +1823,8 @@ public class ItemAssistant {
|
||||
}
|
||||
|
||||
if (totalItems != totalItemsAfter) {
|
||||
c.disconnected = true;
|
||||
if (!c.isBot)
|
||||
c.disconnected = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1826,15 +1846,19 @@ public class ItemAssistant {
|
||||
|
||||
public void resetBank() {
|
||||
synchronized (c) {
|
||||
c.getOutStream().createFrameVarSizeWord(53);
|
||||
c.getOutStream().writeWord(5382); // bank
|
||||
c.getOutStream().writeWord(Constants.BANK_SIZE);
|
||||
if (c.getOutStream() != null) {
|
||||
c.getOutStream().createFrameVarSizeWord(53);
|
||||
c.getOutStream().writeWord(5382); // bank
|
||||
c.getOutStream().writeWord(Constants.BANK_SIZE);
|
||||
}
|
||||
for (int i = 0; i < Constants.BANK_SIZE; i++) {
|
||||
if (c.bankItemsN[i] > 254) {
|
||||
c.getOutStream().writeByte(255);
|
||||
c.getOutStream().writeDWord_v2(c.bankItemsN[i]);
|
||||
} else {
|
||||
c.getOutStream().writeByte(c.bankItemsN[i]);
|
||||
if (c.getOutStream() != null) {
|
||||
if (c.bankItemsN[i] > 254) {
|
||||
c.getOutStream().writeByte(255);
|
||||
c.getOutStream().writeDWord_v2(c.bankItemsN[i]);
|
||||
} else {
|
||||
c.getOutStream().writeByte(c.bankItemsN[i]);
|
||||
}
|
||||
}
|
||||
if (c.bankItemsN[i] < 1) {
|
||||
c.bankItems[i] = 0;
|
||||
@@ -1842,10 +1866,15 @@ public class ItemAssistant {
|
||||
if (c.bankItems[i] > Constants.ITEM_LIMIT || c.bankItems[i] < 0) {
|
||||
c.bankItems[i] = Constants.ITEM_LIMIT;
|
||||
}
|
||||
c.getOutStream().writeWordBigEndianA(c.bankItems[i]);
|
||||
if (c.getOutStream() != null) {
|
||||
c.getOutStream().writeWordBigEndianA(c.bankItems[i]);
|
||||
}
|
||||
}
|
||||
|
||||
if (c.getOutStream() != null) {
|
||||
c.getOutStream().endFrameVarSizeWord();
|
||||
c.flushOutStream();
|
||||
}
|
||||
c.getOutStream().endFrameVarSizeWord();
|
||||
c.flushOutStream();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1857,24 +1886,32 @@ public class ItemAssistant {
|
||||
itemCount = i;
|
||||
}
|
||||
}
|
||||
c.getOutStream().createFrameVarSizeWord(53);
|
||||
c.getOutStream().writeWord(5064);
|
||||
c.getOutStream().writeWord(itemCount + 1);
|
||||
if (c.getOutStream() != null){
|
||||
c.getOutStream().createFrameVarSizeWord(53);
|
||||
c.getOutStream().writeWord(5064);
|
||||
c.getOutStream().writeWord(itemCount + 1);
|
||||
}
|
||||
for (int i = 0; i < itemCount + 1; i++) {
|
||||
if (c.playerItemsN[i] > 254) {
|
||||
c.getOutStream().writeByte(255);
|
||||
c.getOutStream().writeDWord_v2(c.playerItemsN[i]);
|
||||
} else {
|
||||
c.getOutStream().writeByte(c.playerItemsN[i]);
|
||||
|
||||
if (c.getOutStream() != null) {
|
||||
if (c.playerItemsN[i] > 254) {
|
||||
c.getOutStream().writeByte(255);
|
||||
c.getOutStream().writeDWord_v2(c.playerItemsN[i]);
|
||||
} else {
|
||||
c.getOutStream().writeByte(c.playerItemsN[i]);
|
||||
}
|
||||
}
|
||||
if (c.playerItems[i] > Constants.ITEM_LIMIT || c.playerItems[i] < 0) {
|
||||
c.playerItems[i] = Constants.ITEM_LIMIT;
|
||||
}
|
||||
c.getOutStream().writeWordBigEndianA(c.playerItems[i]);
|
||||
if (c.getOutStream() != null) {
|
||||
c.getOutStream().writeWordBigEndianA(c.playerItems[i]);
|
||||
}
|
||||
}
|
||||
if (c.getOutStream() != null) {
|
||||
c.getOutStream().endFrameVarSizeWord();
|
||||
c.flushOutStream();
|
||||
}
|
||||
c.getOutStream().endFrameVarSizeWord();
|
||||
c.flushOutStream();
|
||||
// }
|
||||
}
|
||||
|
||||
public boolean bankItem(int itemID, int fromSlot, int amount) {
|
||||
@@ -2287,18 +2324,20 @@ public class ItemAssistant {
|
||||
|
||||
public void setEquipment(int wearID, int amount, int targetSlot) {
|
||||
// synchronized(c) {
|
||||
c.getOutStream().createFrameVarSizeWord(34);
|
||||
c.getOutStream().writeWord(1688);
|
||||
c.getOutStream().writeByte(targetSlot);
|
||||
c.getOutStream().writeWord(wearID + 1);
|
||||
if (amount > 254) {
|
||||
c.getOutStream().writeByte(255);
|
||||
c.getOutStream().writeDWord(amount);
|
||||
} else {
|
||||
c.getOutStream().writeByte(amount);
|
||||
if (c.getOutStream() != null) {
|
||||
c.getOutStream().createFrameVarSizeWord(34);
|
||||
c.getOutStream().writeWord(1688);
|
||||
c.getOutStream().writeByte(targetSlot);
|
||||
c.getOutStream().writeWord(wearID + 1);
|
||||
if (amount > 254) {
|
||||
c.getOutStream().writeByte(255);
|
||||
c.getOutStream().writeDWord(amount);
|
||||
} else {
|
||||
c.getOutStream().writeByte(amount);
|
||||
}
|
||||
c.getOutStream().endFrameVarSizeWord();
|
||||
c.flushOutStream();
|
||||
}
|
||||
c.getOutStream().endFrameVarSizeWord();
|
||||
c.flushOutStream();
|
||||
c.playerEquipment[targetSlot] = wearID;
|
||||
c.playerEquipmentN[targetSlot] = amount;
|
||||
c.updateRequired = true;
|
||||
@@ -2385,12 +2424,15 @@ public class ItemAssistant {
|
||||
|
||||
c.playerEquipment[j] = -1;
|
||||
c.playerEquipmentN[j] = c.playerEquipmentN[j] - 1;
|
||||
c.getOutStream().createFrame(34);
|
||||
c.getOutStream().writeWord(6);
|
||||
c.getOutStream().writeWord(1688);
|
||||
c.getOutStream().writeByte(j);
|
||||
c.getOutStream().writeWord(0);
|
||||
c.getOutStream().writeByte(0);
|
||||
|
||||
if (c.getOutStream() != null) {
|
||||
c.getOutStream().createFrame(34);
|
||||
c.getOutStream().writeWord(6);
|
||||
c.getOutStream().writeWord(1688);
|
||||
c.getOutStream().writeByte(j);
|
||||
c.getOutStream().writeWord(0);
|
||||
c.getOutStream().writeByte(0);
|
||||
}
|
||||
getBonus();
|
||||
if (j == c.playerWeapon) {
|
||||
sendWeapon(-1, "Unarmed");
|
||||
@@ -2403,17 +2445,23 @@ public class ItemAssistant {
|
||||
}
|
||||
|
||||
public void deleteItem(int id, int amount) {
|
||||
if (id <= 0) {
|
||||
if (id <= 0 || amount <= 0) {
|
||||
return;
|
||||
}
|
||||
for (int j = 0; j < c.playerItems.length; j++) {
|
||||
id++;
|
||||
for (int slot = 0; slot < c.playerItems.length; slot++) {
|
||||
if (amount <= 0) {
|
||||
break;
|
||||
}
|
||||
if (c.playerItems[j] == id + 1) {
|
||||
c.playerItems[j] = 0;
|
||||
c.playerItemsN[j] = 0;
|
||||
amount--;
|
||||
if (c.playerItems[slot] == id) {
|
||||
if (c.playerItemsN[slot] > amount) {
|
||||
c.playerItemsN[slot] -= amount;
|
||||
break;
|
||||
} else {
|
||||
amount -= c.playerItemsN[slot];
|
||||
c.playerItems[slot] = 0;
|
||||
c.playerItemsN[slot] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
resetItems(3214);
|
||||
@@ -2439,9 +2487,6 @@ public class ItemAssistant {
|
||||
public void deleteItem2(int id, int amount) {
|
||||
int am = amount;
|
||||
for (int i = 0; i < c.playerItems.length; i++) {
|
||||
if (am == 0) {
|
||||
break;
|
||||
}
|
||||
if (c.playerItems[i] == id + 1) {
|
||||
if (c.playerItemsN[i] > amount) {
|
||||
c.playerItemsN[i] -= amount;
|
||||
@@ -2449,7 +2494,6 @@ public class ItemAssistant {
|
||||
} else {
|
||||
c.playerItems[i] = 0;
|
||||
c.playerItemsN[i] = 0;
|
||||
am--;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -97,24 +97,27 @@ public class Npc {
|
||||
|
||||
|
||||
public void updateNPCMovement(Stream str) {
|
||||
if (direction == -1) {
|
||||
|
||||
if (updateRequired) {
|
||||
if (str != null) {
|
||||
if (direction == -1) {
|
||||
|
||||
if (updateRequired) {
|
||||
|
||||
str.writeBits(1, 1);
|
||||
str.writeBits(2, 0);
|
||||
} else {
|
||||
str.writeBits(1, 0);
|
||||
}
|
||||
} else {
|
||||
|
||||
str.writeBits(1, 1);
|
||||
str.writeBits(2, 0);
|
||||
} else {
|
||||
str.writeBits(1, 0);
|
||||
}
|
||||
} else {
|
||||
|
||||
str.writeBits(1, 1);
|
||||
str.writeBits(2, 1);
|
||||
str.writeBits(3, Misc.xlateDirectionToClient[direction]);
|
||||
if (updateRequired) {
|
||||
str.writeBits(1, 1);
|
||||
} else {
|
||||
str.writeBits(1, 0);
|
||||
str.writeBits(2, 1);
|
||||
str.writeBits(3, Misc.xlateDirectionToClient[direction]);
|
||||
if (updateRequired) {
|
||||
str.writeBits(1, 1);
|
||||
} else {
|
||||
str.writeBits(1, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -558,7 +558,8 @@ public class NpcHandler {
|
||||
&& npcs[i].needRespawn == false) {
|
||||
npcs[i].updateRequired = true;
|
||||
npcs[i].facePlayer(0);
|
||||
npcs[i].killedBy = NpcData.getNpcKillerId(i);
|
||||
if (npcs[i].killedBy <= 0)
|
||||
npcs[i].killedBy = NpcData.getNpcKillerId(i);
|
||||
npcs[i].animNumber = NpcEmotes.getDeadEmote(i); // dead
|
||||
// emote
|
||||
Client c = (Client) PlayerHandler.players[npcs[i].killedBy];
|
||||
|
||||
@@ -439,6 +439,16 @@ public class Client extends Player {
|
||||
public int timeOutCounter = 0;
|
||||
public int returnCode = 2;
|
||||
|
||||
// used for bots
|
||||
public Client(IoSession s) {
|
||||
super(-1);
|
||||
isBot = true;
|
||||
session = null;
|
||||
inStream = new Stream(new byte[Constants.BUFFER_SIZE]);
|
||||
inStream.currentOffset = 0;
|
||||
buffer = new byte[Constants.BUFFER_SIZE];
|
||||
}
|
||||
|
||||
public Client(IoSession s, int _playerId) {
|
||||
super(_playerId);
|
||||
session = s;
|
||||
@@ -478,7 +488,7 @@ public class Client extends Player {
|
||||
}
|
||||
|
||||
public void flushOutStream() {
|
||||
if (disconnected || outStream.currentOffset == 0) {
|
||||
if (disconnected || outStream == null || outStream.currentOffset == 0) {
|
||||
return;
|
||||
}
|
||||
synchronized (this) {
|
||||
@@ -492,12 +502,14 @@ public class Client extends Player {
|
||||
}
|
||||
|
||||
public void sendClan(String name, String message, String clan, int rights) {
|
||||
outStream.createFrameVarSizeWord(217);
|
||||
outStream.writeString(name);
|
||||
outStream.writeString(message);
|
||||
outStream.writeString(clan);
|
||||
outStream.writeWord(rights);
|
||||
outStream.endFrameVarSize();
|
||||
if (outStream != null) {
|
||||
outStream.createFrameVarSizeWord(217);
|
||||
outStream.writeString(name);
|
||||
outStream.writeString(message);
|
||||
outStream.writeString(clan);
|
||||
outStream.writeWord(rights);
|
||||
outStream.endFrameVarSize();
|
||||
}
|
||||
}
|
||||
|
||||
public static final int PACKET_SIZES[] = { 0, 0, 0, 1, -1, 0, 0, 0, 0, 0, // 0
|
||||
@@ -594,10 +606,6 @@ public class Client extends Player {
|
||||
super.destruct();
|
||||
// PlayerSave.saveGame(this);
|
||||
}
|
||||
|
||||
public static final String[][] data = {
|
||||
{"Andrew", "Andrew1"},
|
||||
};
|
||||
|
||||
@Override
|
||||
public void initialize() {
|
||||
@@ -606,27 +614,19 @@ public class Client extends Player {
|
||||
logout();
|
||||
return;
|
||||
}
|
||||
/*(for (int i = 0; i < data.length; i++) {
|
||||
if (playerRights > 0) {
|
||||
if (playerName != data[0][i]) {
|
||||
Connection.addNameToBanList(playerName);
|
||||
Connection.addNameToFile(playerName);
|
||||
disconnected = true;
|
||||
}
|
||||
}
|
||||
}*/
|
||||
synchronized (this) {
|
||||
outStream.createFrame(249);
|
||||
outStream.writeByteA(membership ? 1 : 0);
|
||||
outStream.writeWordBigEndianA(playerId);
|
||||
for (int j = 0; j < PlayerHandler.players.length; j++) {
|
||||
if (j == playerId) {
|
||||
continue;
|
||||
}
|
||||
if (PlayerHandler.players[j] != null) {
|
||||
if (PlayerHandler.players[j].playerName
|
||||
.equalsIgnoreCase(playerName)) {
|
||||
disconnected = true;
|
||||
if (getOutStream() != null) {
|
||||
outStream.createFrame(249);
|
||||
outStream.writeByteA(membership ? 1 : 0);
|
||||
outStream.writeWordBigEndianA(playerId);
|
||||
for (int j = 0; j < PlayerHandler.players.length; j++) {
|
||||
if (j == playerId) {
|
||||
continue;
|
||||
}
|
||||
if (PlayerHandler.players[j] != null) {
|
||||
if (PlayerHandler.players[j].playerName.equalsIgnoreCase(playerName)) {
|
||||
disconnected = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -820,7 +820,8 @@ public class Client extends Player {
|
||||
getSummon().pickUpClean(this, summonId);
|
||||
}
|
||||
if (forceLogout || System.currentTimeMillis() - logoutDelay > 2500) {
|
||||
outStream.createFrame(109);
|
||||
if (!isBot)
|
||||
outStream.createFrame(109);
|
||||
properLogout = true;
|
||||
} else {
|
||||
getActionSender().sendMessage("You must wait a few seconds from being out of combat to logout.");
|
||||
@@ -1124,7 +1125,8 @@ public class Client extends Player {
|
||||
}
|
||||
|
||||
if (timeOutCounter > Constants.TIMEOUT) {
|
||||
disconnected = true;
|
||||
if (!isBot)
|
||||
logout(true);
|
||||
}
|
||||
|
||||
timeOutCounter++;
|
||||
@@ -1254,10 +1256,12 @@ public class Client extends Player {
|
||||
System.out.println("Playing sound " + c.playerName
|
||||
+ ", Id: " + SOUNDID + ", Vol: "
|
||||
+ c.soundVolume);
|
||||
c.getOutStream().createFrame(174);
|
||||
c.getOutStream().writeWord(SOUNDID);
|
||||
c.getOutStream().writeByte(c.soundVolume);
|
||||
c.getOutStream().writeWord( /* delay */0);
|
||||
if (c.getOutStream() != null) {
|
||||
c.getOutStream().createFrame(174);
|
||||
c.getOutStream().writeWord(SOUNDID);
|
||||
c.getOutStream().writeByte(c.soundVolume);
|
||||
c.getOutStream().writeWord( /* delay */0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,13 +16,17 @@ public class HighscoresHandler {
|
||||
Client player = new Client(null, -1);
|
||||
player.playerName = child.getName().split("\\.")[0];
|
||||
loadPlayerInfo(player, child.getName().split("\\.")[0], "", false);
|
||||
if (player.playerRights >= 2 || // admin or dev
|
||||
player.isBot || player.playerName.startsWith("♥")) { // ignore bots
|
||||
continue;
|
||||
}
|
||||
players.add(player);
|
||||
}
|
||||
}
|
||||
|
||||
public String getRank(Client player, int i, String sortBy) {
|
||||
if (players.size() <= i || player.playerRights >= 2) {
|
||||
return "Nobody";
|
||||
if (players.size() <= i) {
|
||||
return "-----";
|
||||
}
|
||||
|
||||
switch (sortBy) {
|
||||
@@ -32,6 +36,7 @@ public class HighscoresHandler {
|
||||
case "gold":
|
||||
players.sort(new totalGoldComparator());
|
||||
return players.get(i).playerName + ": " + players.get(i).getPlayerAssistant().totalGold() + "gp";
|
||||
case "damage":
|
||||
default:
|
||||
players.sort(new globalDmgComparator());
|
||||
return players.get(i).playerName + ": " + players.get(i).globalDamageDealt;
|
||||
|
||||
@@ -19,7 +19,7 @@ public abstract class Player {
|
||||
|
||||
public String currentTime, date, creationAddress = "", slayerMaster;
|
||||
|
||||
public boolean lostCannon = false, refresh = false;
|
||||
public boolean lostCannon = false, refresh = false, isBot = false;
|
||||
|
||||
public ArrayList<String> killedPlayers = new ArrayList<String>();
|
||||
public ArrayList<Integer> attackedPlayers = new ArrayList<Integer>();
|
||||
@@ -118,7 +118,8 @@ public abstract class Player {
|
||||
teleOtherSlot = -1, tutorialProgress, Cookstage1 = 1,
|
||||
woodcuttingTree, smeltAmount, knightS, otherDirection,
|
||||
brightness = 3, recoilHits, droppedItem = -1,
|
||||
spawnedHealers, cannonX = 0, cannonY = 0;
|
||||
spawnedHealers, cannonX = 0, cannonY = 0,
|
||||
playerShopId;
|
||||
|
||||
public double playerEnergy = 100;
|
||||
|
||||
@@ -620,6 +621,26 @@ public abstract class Player {
|
||||
isInArea(3422,2895,3433,2885) || //Nardah
|
||||
isInArea(3685,3473,3694,3461) || //Phasmatys
|
||||
isInArea(2530,4725,2550,4705) || //Phasmatys
|
||||
isInArea(2834, 10215, 2841, 10204) || // Keldagrim
|
||||
isInArea(2379, 4453, 2386, 4462) || // Zanaris
|
||||
false;
|
||||
}
|
||||
|
||||
public boolean inPlayerShopArea() {
|
||||
return isInArea(2938, 3389, 3059, 3329) || // Falador
|
||||
isInArea(3172, 3449, 3270, 3384) || // Varrock
|
||||
isInArea(3200, 3256, 3237, 3201) || // Lumbridge
|
||||
isInArea(2716, 3498, 2735, 3480) ||
|
||||
isInArea(3075, 3513, 3106, 3466) ||
|
||||
isInArea(3074, 3262, 3102, 3239) ||
|
||||
isInArea(2435, 3101, 2459, 3080) ||
|
||||
isInArea(2618, 3075, 2598, 3108) ||
|
||||
isInArea(2678, 3267, 2601, 3341) ||
|
||||
isInArea(3265, 3157, 3324, 3215) ||
|
||||
isInArea(3386, 3264, 3348, 3286) ||
|
||||
isInArea(2797, 3454, 2838, 3430) ||
|
||||
isInArea(2546, 3157, 2512, 3176) ||
|
||||
isInArea(2451, 3408, 2425, 3437) ||
|
||||
false;
|
||||
}
|
||||
|
||||
@@ -731,6 +752,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;
|
||||
|
||||
@@ -1081,65 +1104,75 @@ public boolean goodDistance(int objectX, int objectY, int playerX, int playerY,
|
||||
}
|
||||
|
||||
public void updateThisPlayerMovement(Stream str) {
|
||||
if (mapRegionDidChange) {
|
||||
str.createFrame(73);
|
||||
str.writeWordA(mapRegionX + 6);
|
||||
str.writeWord(mapRegionY + 6);
|
||||
}
|
||||
|
||||
if (didTeleport) {
|
||||
str.createFrameVarSizeWord(81);
|
||||
str.initBitAccess();
|
||||
str.writeBits(1, 1);
|
||||
str.writeBits(2, 3);
|
||||
str.writeBits(2, heightLevel);
|
||||
str.writeBits(1, 1);
|
||||
str.writeBits(1, updateRequired ? 1 : 0);
|
||||
str.writeBits(7, currentY);
|
||||
str.writeBits(7, currentX);
|
||||
return;
|
||||
}
|
||||
if (str != null) {
|
||||
if (mapRegionDidChange) {
|
||||
str.createFrame(73);
|
||||
str.writeWordA(mapRegionX + 6);
|
||||
str.writeWord(mapRegionY + 6);
|
||||
}
|
||||
|
||||
if (didTeleport) {
|
||||
str.createFrameVarSizeWord(81);
|
||||
str.initBitAccess();
|
||||
str.writeBits(1, 1);
|
||||
str.writeBits(2, 3);
|
||||
str.writeBits(2, heightLevel);
|
||||
str.writeBits(1, 1);
|
||||
str.writeBits(1, updateRequired ? 1 : 0);
|
||||
str.writeBits(7, currentY);
|
||||
str.writeBits(7, currentX);
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (dir1 == -1) {
|
||||
// don't have to update the character position, because we're
|
||||
// just standing
|
||||
str.createFrameVarSizeWord(81);
|
||||
str.initBitAccess();
|
||||
isMoving = false;
|
||||
if (updateRequired) {
|
||||
// tell client there's an update block appended at the end
|
||||
str.writeBits(1, 1);
|
||||
str.writeBits(2, 0);
|
||||
} else {
|
||||
str.writeBits(1, 0);
|
||||
if (str != null){
|
||||
str.createFrameVarSizeWord(81);
|
||||
str.initBitAccess();
|
||||
isMoving = false;
|
||||
if (updateRequired) {
|
||||
// tell client there's an update block appended at the end
|
||||
str.writeBits(1, 1);
|
||||
str.writeBits(2, 0);
|
||||
} else {
|
||||
str.writeBits(1, 0);
|
||||
}
|
||||
}
|
||||
if (DirectionCount < 50) {
|
||||
DirectionCount++;
|
||||
}
|
||||
} else {
|
||||
DirectionCount = 0;
|
||||
str.createFrameVarSizeWord(81);
|
||||
str.initBitAccess();
|
||||
str.writeBits(1, 1);
|
||||
if (str != null) {
|
||||
str.createFrameVarSizeWord(81);
|
||||
str.initBitAccess();
|
||||
str.writeBits(1, 1);
|
||||
}
|
||||
|
||||
if (dir2 == -1) {
|
||||
isMoving = true;
|
||||
str.writeBits(2, 1);
|
||||
str.writeBits(3, Misc.xlateDirectionToClient[dir1]);
|
||||
if (updateRequired) {
|
||||
str.writeBits(1, 1);
|
||||
} else {
|
||||
str.writeBits(1, 0);
|
||||
if (str != null) {
|
||||
str.writeBits(2, 1);
|
||||
str.writeBits(3, Misc.xlateDirectionToClient[dir1]);
|
||||
if (updateRequired) {
|
||||
str.writeBits(1, 1);
|
||||
} else {
|
||||
str.writeBits(1, 0);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
isMoving = true;
|
||||
str.writeBits(2, 2);
|
||||
str.writeBits(3, Misc.xlateDirectionToClient[dir1]);
|
||||
str.writeBits(3, Misc.xlateDirectionToClient[dir2]);
|
||||
if (updateRequired) {
|
||||
str.writeBits(1, 1);
|
||||
} else {
|
||||
str.writeBits(1, 0);
|
||||
if (str != null) {
|
||||
str.writeBits(2, 2);
|
||||
str.writeBits(3, Misc.xlateDirectionToClient[dir1]);
|
||||
str.writeBits(3, Misc.xlateDirectionToClient[dir2]);
|
||||
if (updateRequired) {
|
||||
str.writeBits(1, 1);
|
||||
} else {
|
||||
str.writeBits(1, 0);
|
||||
}
|
||||
}
|
||||
if (playerEnergy > 0 && playerRights < 2) {
|
||||
// calculations from https://oldschool.runescape.wiki/w/Energy
|
||||
@@ -1158,9 +1191,11 @@ public boolean goodDistance(int objectX, int objectY, int playerX, int playerY,
|
||||
}
|
||||
|
||||
public void updatePlayerMovement(Stream str) {
|
||||
if (str == null)
|
||||
return;
|
||||
|
||||
if (dir1 == -1) {
|
||||
if (updateRequired || isChatTextUpdateRequired()) {
|
||||
|
||||
str.writeBits(1, 1);
|
||||
str.writeBits(2, 0);
|
||||
} else {
|
||||
@@ -1171,16 +1206,14 @@ public boolean goodDistance(int objectX, int objectY, int playerX, int playerY,
|
||||
str.writeBits(1, 1);
|
||||
str.writeBits(2, 1);
|
||||
str.writeBits(3, Misc.xlateDirectionToClient[dir1]);
|
||||
str.writeBits(1, updateRequired || isChatTextUpdateRequired() ? 1
|
||||
: 0);
|
||||
str.writeBits(1, updateRequired || isChatTextUpdateRequired() ? 1 : 0);
|
||||
} else {
|
||||
|
||||
str.writeBits(1, 1);
|
||||
str.writeBits(2, 2);
|
||||
str.writeBits(3, Misc.xlateDirectionToClient[dir1]);
|
||||
str.writeBits(3, Misc.xlateDirectionToClient[dir2]);
|
||||
str.writeBits(1, updateRequired || isChatTextUpdateRequired() ? 1
|
||||
: 0);
|
||||
str.writeBits(1, updateRequired || isChatTextUpdateRequired() ? 1 : 0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1191,35 +1224,50 @@ public boolean goodDistance(int objectX, int objectY, int playerX, int playerY,
|
||||
npcInListBitmap[id >> 3] |= 1 << (id & 7);
|
||||
npcList[npcListSize++] = npc;
|
||||
|
||||
str.writeBits(14, id);
|
||||
if (str != null) {
|
||||
str.writeBits(14, id);
|
||||
}
|
||||
|
||||
int z = npc.absY - absY;
|
||||
if (z < 0) {
|
||||
z += 32;
|
||||
}
|
||||
str.writeBits(5, z);
|
||||
|
||||
if (str != null) {
|
||||
str.writeBits(5, z);
|
||||
}
|
||||
|
||||
z = npc.absX - absX;
|
||||
if (z < 0) {
|
||||
z += 32;
|
||||
}
|
||||
str.writeBits(5, z);
|
||||
|
||||
str.writeBits(1, 0);
|
||||
str.writeBits(12, npc.npcType);
|
||||
if (str != null) {
|
||||
str.writeBits(5, z);
|
||||
|
||||
str.writeBits(1, 0);
|
||||
str.writeBits(12, npc.npcType);
|
||||
}
|
||||
|
||||
boolean savedUpdateRequired = npc.updateRequired;
|
||||
npc.updateRequired = true;
|
||||
npc.appendNPCUpdateBlock(updateBlock);
|
||||
npc.updateRequired = savedUpdateRequired;
|
||||
str.writeBits(1, 1);
|
||||
|
||||
if (str != null) {
|
||||
str.writeBits(1, 1);
|
||||
}
|
||||
}
|
||||
|
||||
public void addNewPlayer(Player plr, Stream str, Stream updateBlock) {
|
||||
int id = plr.playerId;
|
||||
playerInListBitmap[id >> 3] |= 1 << (id & 7);
|
||||
playerList[playerListSize++] = plr;
|
||||
str.writeBits(11, id);
|
||||
str.writeBits(1, 1);
|
||||
|
||||
if (str != null) {
|
||||
str.writeBits(11, id);
|
||||
str.writeBits(1, 1);
|
||||
}
|
||||
boolean savedFlag = plr.isAppearanceUpdateRequired();
|
||||
boolean savedUpdateRequired = plr.updateRequired;
|
||||
plr.setAppearanceUpdateRequired(true);
|
||||
@@ -1227,17 +1275,26 @@ public boolean goodDistance(int objectX, int objectY, int playerX, int playerY,
|
||||
plr.appendPlayerUpdateBlock(updateBlock);
|
||||
plr.setAppearanceUpdateRequired(savedFlag);
|
||||
plr.updateRequired = savedUpdateRequired;
|
||||
str.writeBits(1, 1);
|
||||
if (str != null) {
|
||||
str.writeBits(1, 1);
|
||||
}
|
||||
int z = plr.absY - absY;
|
||||
if (z < 0) {
|
||||
z += 32;
|
||||
}
|
||||
str.writeBits(5, z);
|
||||
|
||||
if (str != null) {
|
||||
str.writeBits(5, z);
|
||||
}
|
||||
|
||||
z = plr.absX - absX;
|
||||
if (z < 0) {
|
||||
z += 32;
|
||||
}
|
||||
str.writeBits(5, z);
|
||||
|
||||
if (str != null) {
|
||||
str.writeBits(5, z);
|
||||
}
|
||||
}
|
||||
|
||||
public int headIcon = -1, bountyIcon = 0;
|
||||
@@ -1406,6 +1463,7 @@ public boolean goodDistance(int objectX, int objectY, int playerX, int playerY,
|
||||
private int chatTextEffects = 0;
|
||||
|
||||
protected void appendPlayerChatText(Stream str) {
|
||||
if (str == null) return;
|
||||
str.writeWordBigEndian(((getChatTextColor() & 0xFF) << 8) + (getChatTextEffects() & 0xFF));
|
||||
str.writeByte(playerRights);
|
||||
str.writeByteC(getChatTextSize());
|
||||
@@ -1422,7 +1480,8 @@ public boolean goodDistance(int objectX, int objectY, int playerX, int playerY,
|
||||
public String forcedText = "null";
|
||||
|
||||
public void appendForcedChat(Stream str) {
|
||||
str.writeString(forcedText);
|
||||
if (str != null)
|
||||
str.writeString(forcedText);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1922,8 +1981,7 @@ public boolean goodDistance(int objectX, int objectY, int playerX, int playerY,
|
||||
continue;
|
||||
}
|
||||
if (PlayerHandler.players[j] != null) {
|
||||
if (PlayerHandler.players[j].playerName
|
||||
.equalsIgnoreCase(playerName)) {
|
||||
if (PlayerHandler.players[j].playerName.equalsIgnoreCase(playerName)) {
|
||||
disconnected = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -275,35 +275,40 @@ public class PlayerAssistant {
|
||||
public int backupInvItems[] = new int[28];
|
||||
public int backupInvItemsN[] = new int[28];
|
||||
|
||||
public void otherInv(Client c, Client o) {
|
||||
if (o == c || o == null || c == null)
|
||||
return;
|
||||
for (int i = 0; i < o.playerItems.length; i++) {
|
||||
backupInvItems[i] = c.playerItems[i];
|
||||
c.playerItemsN[i] = c.playerItemsN[i];
|
||||
c.playerItemsN[i] = o.playerItemsN[i];
|
||||
c.playerItems[i] = o.playerItems[i];
|
||||
}
|
||||
c.getItemAssistant().updateInventory();
|
||||
|
||||
for (int i = 0; i < o.playerItems.length; i++) {
|
||||
c.playerItemsN[i] = backupInvItemsN[i];
|
||||
c.playerItems[i] = backupInvItems[i];
|
||||
}
|
||||
}
|
||||
public void otherInv(Client c, Client o) {
|
||||
if (o == c || o == null || c == null)
|
||||
return;
|
||||
for (int i = 0; i < o.playerItems.length; i++) {
|
||||
backupInvItems[i] = c.playerItems[i];
|
||||
backupInvItemsN[i] = c.playerItemsN[i];
|
||||
c.playerItems[i] = o.playerItems[i];
|
||||
c.playerItemsN[i] = o.playerItemsN[i];
|
||||
}
|
||||
c.getItemAssistant().updateInventory();
|
||||
|
||||
for (int i = 0; i < o.playerItems.length; i++) {
|
||||
c.playerItemsN[i] = backupInvItemsN[i];
|
||||
c.playerItems[i] = backupInvItems[i];
|
||||
}
|
||||
}
|
||||
|
||||
public void otherBank(Client c, Client o) {
|
||||
if(o == c || o == null || c == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (int i = 0; i < o.bankItems.length; i++) {
|
||||
backupItems[i] = c.bankItems[i]; backupItemsN[i] = c.bankItemsN[i];
|
||||
c.bankItemsN[i] = o.bankItemsN[i]; c.bankItems[i] = o.bankItems[i];
|
||||
backupItems[i] = c.bankItems[i];
|
||||
backupItemsN[i] = c.bankItemsN[i];
|
||||
c.bankItemsN[i] = o.bankItemsN[i];
|
||||
c.bankItems[i] = o.bankItems[i];
|
||||
}
|
||||
|
||||
openUpBank();
|
||||
|
||||
for (int i = 0; i < o.bankItems.length; i++) {
|
||||
c.bankItemsN[i] = backupItemsN[i]; c.bankItems[i] = backupItems[i];
|
||||
c.bankItemsN[i] = backupItemsN[i];
|
||||
c.bankItems[i] = backupItems[i];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1637,8 +1642,7 @@ public class PlayerAssistant {
|
||||
switch (spellId) {
|
||||
case 1162: // low alch
|
||||
if (player.inTrade) {
|
||||
player.getActionSender().sendMessage(
|
||||
"You can't alch while in trade!");
|
||||
player.getActionSender().sendMessage("You can't alch while in trade!");
|
||||
return;
|
||||
}
|
||||
if (player.isBotting == true) {
|
||||
@@ -1662,7 +1666,7 @@ public class PlayerAssistant {
|
||||
}
|
||||
}
|
||||
if (canAlch) {
|
||||
int value = player.getShopAssistant().getItemShopValue( itemId) / 3;
|
||||
int value = (int) Math.floor(player.getShopAssistant().getItemShopValue(itemId) * 0.4);
|
||||
String itemName = ItemAssistant.getItemName(itemId).toLowerCase();
|
||||
if (player.getPlayerAssistant().isPlayer()) {
|
||||
GameLogger.writeLog(player.playerName, "alchemy", player.playerName + " cast Low Alchemy on " + itemName + " for " + GameLogger.formatCurrency(value) + " coins");
|
||||
@@ -1735,7 +1739,7 @@ public class PlayerAssistant {
|
||||
}
|
||||
}
|
||||
if (canAlch) {
|
||||
int value = (int) (player.getShopAssistant().getItemShopValue(itemId) * .75);
|
||||
int value = (int) Math.floor(player.getShopAssistant().getItemShopValue(itemId) * 0.75);
|
||||
String itemName = ItemAssistant.getItemName(itemId).toLowerCase();
|
||||
if (player.getPlayerAssistant().isPlayer()) {
|
||||
GameLogger.writeLog(player.playerName, "alchemy", player.playerName + " cast High Alchemy on " + itemName + " for" + GameLogger.formatCurrency(value) + " coins");
|
||||
|
||||
@@ -14,7 +14,7 @@ import redone.world.GlobalDropsHandler;
|
||||
public class PlayerHandler {
|
||||
|
||||
public static Player players[] = new Player[Constants.MAX_PLAYERS];
|
||||
public static int playerCount = 0;
|
||||
public static int playerCount = 0, playerBotCount = 0;
|
||||
public static String playersCurrentlyOn[] = new String[Constants.MAX_PLAYERS];
|
||||
public static boolean updateAnnounced;
|
||||
public static boolean updateRunning;
|
||||
@@ -43,8 +43,7 @@ public class PlayerHandler {
|
||||
client1.playerId = slot;
|
||||
players[slot] = client1;
|
||||
players[slot].isActive = true;
|
||||
players[slot].connectedFrom = ((InetSocketAddress) client1.getSession()
|
||||
.getRemoteAddress()).getAddress().getHostAddress();
|
||||
players[slot].connectedFrom = client1.isBot ? "127.0.0.1" : ((InetSocketAddress) client1.getSession().getRemoteAddress()).getAddress().getHostAddress();
|
||||
if (Constants.SERVER_DEBUG) {
|
||||
Misc.println("Player Slot " + slot + " slot 0 " + players[0]
|
||||
+ " Player Hit " + players[slot]);
|
||||
@@ -56,12 +55,20 @@ public class PlayerHandler {
|
||||
return playerCount;
|
||||
}
|
||||
|
||||
public static int getPlayerBotCount() {
|
||||
return playerBotCount;
|
||||
}
|
||||
|
||||
public void updatePlayerNames() {
|
||||
playerBotCount = 0;
|
||||
playerCount = 0;
|
||||
for (int i = 0; i < Constants.MAX_PLAYERS; i++) {
|
||||
if (players[i] != null) {
|
||||
playersCurrentlyOn[i] = players[i].playerName;
|
||||
playerCount++;
|
||||
if (players[i].isBot)
|
||||
playerBotCount++;
|
||||
else
|
||||
playerCount++;
|
||||
} else {
|
||||
playersCurrentlyOn[i] = "";
|
||||
}
|
||||
@@ -265,24 +272,26 @@ public class PlayerHandler {
|
||||
public void updateNPC(Player plr, Stream str) {
|
||||
// synchronized(plr) {
|
||||
updateBlock.currentOffset = 0;
|
||||
if (str != null) {
|
||||
str.createFrameVarSizeWord(65);
|
||||
str.initBitAccess();
|
||||
|
||||
str.createFrameVarSizeWord(65);
|
||||
str.initBitAccess();
|
||||
|
||||
str.writeBits(8, plr.npcListSize);
|
||||
str.writeBits(8, plr.npcListSize);
|
||||
}
|
||||
int size = plr.npcListSize;
|
||||
plr.npcListSize = 0;
|
||||
for (int i = 0; i < size; i++) {
|
||||
if (plr.RebuildNPCList == false
|
||||
&& plr.withinDistance(plr.npcList[i]) == true) {
|
||||
if (plr.RebuildNPCList == false && plr.withinDistance(plr.npcList[i]) == true) {
|
||||
plr.npcList[i].updateNPCMovement(str);
|
||||
plr.npcList[i].appendNPCUpdateBlock(updateBlock);
|
||||
plr.npcList[plr.npcListSize++] = plr.npcList[i];
|
||||
} else {
|
||||
int id = plr.npcList[i].npcId;
|
||||
plr.npcInListBitmap[id >> 3] &= ~(1 << (id & 7));
|
||||
str.writeBits(1, 1);
|
||||
str.writeBits(2, 3);
|
||||
if (str != null) {
|
||||
str.writeBits(1, 1);
|
||||
str.writeBits(2, 3);
|
||||
}
|
||||
}
|
||||
}
|
||||
for (Npc i : NpcHandler.npcs) {
|
||||
@@ -299,32 +308,36 @@ public class PlayerHandler {
|
||||
|
||||
plr.RebuildNPCList = false;
|
||||
|
||||
if (updateBlock.currentOffset > 0) {
|
||||
str.writeBits(14, 16383);
|
||||
str.finishBitAccess();
|
||||
str.writeBytes(updateBlock.buffer, updateBlock.currentOffset, 0);
|
||||
} else {
|
||||
str.finishBitAccess();
|
||||
if (str != null) {
|
||||
if (updateBlock.currentOffset > 0) {
|
||||
str.writeBits(14, 16383);
|
||||
str.finishBitAccess();
|
||||
str.writeBytes(updateBlock.buffer, updateBlock.currentOffset, 0);
|
||||
} else {
|
||||
str.finishBitAccess();
|
||||
}
|
||||
str.endFrameVarSizeWord();
|
||||
}
|
||||
str.endFrameVarSizeWord();
|
||||
}
|
||||
|
||||
private final Stream updateBlock = new Stream(
|
||||
new byte[Constants.BUFFER_SIZE]);
|
||||
|
||||
public void updatePlayer(Player plr, Stream str) {
|
||||
public void updatePlayer(Player plr, Stream outStr) {
|
||||
// synchronized(plr) {
|
||||
updateBlock.currentOffset = 0;
|
||||
if (updateRunning && !updateAnnounced) {
|
||||
str.createFrame(114);
|
||||
str.writeWordBigEndian(updateSeconds * 50 / 30);
|
||||
if (updateRunning && !updateAnnounced && outStr != null) {
|
||||
outStr.createFrame(114);
|
||||
outStr.writeWordBigEndian(updateSeconds * 50 / 30);
|
||||
}
|
||||
plr.updateThisPlayerMovement(str);
|
||||
plr.updateThisPlayerMovement(outStr);
|
||||
boolean saveChatTextUpdate = plr.isChatTextUpdateRequired();
|
||||
plr.setChatTextUpdateRequired(false);
|
||||
plr.appendPlayerUpdateBlock(updateBlock);
|
||||
plr.setChatTextUpdateRequired(saveChatTextUpdate);
|
||||
str.writeBits(8, plr.playerListSize);
|
||||
if (outStr != null) {
|
||||
outStr.writeBits(8, plr.playerListSize);
|
||||
}
|
||||
int size = plr.playerListSize;
|
||||
if (size > 255) {
|
||||
size = 255;
|
||||
@@ -333,14 +346,17 @@ public class PlayerHandler {
|
||||
for (int i = 0; i < size; i++) {
|
||||
if (!plr.didTeleport && !plr.playerList[i].didTeleport
|
||||
&& plr.withinDistance(plr.playerList[i])) {
|
||||
plr.playerList[i].updatePlayerMovement(str);
|
||||
plr.playerList[i].updatePlayerMovement(outStr);
|
||||
plr.playerList[i].appendPlayerUpdateBlock(updateBlock);
|
||||
plr.playerList[plr.playerListSize++] = plr.playerList[i];
|
||||
} else {
|
||||
int id = plr.playerList[i].playerId;
|
||||
plr.playerInListBitmap[id >> 3] &= ~(1 << (id & 7));
|
||||
str.writeBits(1, 1);
|
||||
str.writeBits(2, 3);
|
||||
|
||||
if (outStr != null) {
|
||||
outStr.writeBits(1, 1);
|
||||
outStr.writeBits(2, 3);
|
||||
}
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < PlayerHandler.players.length; i++) {
|
||||
@@ -354,17 +370,19 @@ public class PlayerHandler {
|
||||
if (!plr.withinDistance(players[i])) {
|
||||
continue;
|
||||
}
|
||||
plr.addNewPlayer(players[i], str, updateBlock);
|
||||
}
|
||||
if (updateBlock.currentOffset > 0) {
|
||||
str.writeBits(11, 2047);
|
||||
str.finishBitAccess();
|
||||
str.writeBytes(updateBlock.buffer, updateBlock.currentOffset, 0);
|
||||
} else {
|
||||
str.finishBitAccess();
|
||||
plr.addNewPlayer(players[i], outStr, updateBlock);
|
||||
}
|
||||
if (outStr != null) {
|
||||
if (updateBlock.currentOffset > 0) {
|
||||
outStr.writeBits(11, 2047);
|
||||
outStr.finishBitAccess();
|
||||
outStr.writeBytes(updateBlock.buffer, updateBlock.currentOffset, 0);
|
||||
} else {
|
||||
outStr.finishBitAccess();
|
||||
}
|
||||
|
||||
str.endFrameVarSizeWord();
|
||||
outStr.endFrameVarSizeWord();
|
||||
}
|
||||
|
||||
if (plr.refresh) {
|
||||
GlobalDropsHandler.reset((Client)plr);
|
||||
|
||||
@@ -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)
|
||||
@@ -91,6 +91,9 @@ public class PlayerSave {
|
||||
case "character-rights":
|
||||
player.playerRights = Integer.parseInt(token2);
|
||||
break;
|
||||
case "isBot":
|
||||
player.isBot = Boolean.parseBoolean(token2);
|
||||
break;
|
||||
case "blackMarks":
|
||||
player.blackMarks = Integer.parseInt(token2);
|
||||
break;
|
||||
@@ -422,13 +425,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:
|
||||
@@ -539,560 +543,312 @@ public class PlayerSave {
|
||||
characterfile = new BufferedWriter(new FileWriter(filePath));
|
||||
|
||||
/* ACCOUNT */
|
||||
characterfile.write("[ACCOUNT]", 0, 9);
|
||||
characterfile.write("[ACCOUNT]");
|
||||
characterfile.newLine();
|
||||
characterfile.write("character-username = ", 0, 21);
|
||||
characterfile.write(player.playerName, 0,
|
||||
player.playerName.length());
|
||||
characterfile.write("character-username = " + player.playerName);
|
||||
characterfile.newLine();
|
||||
if (player.playerRights == 0) {
|
||||
if (player.playerPass.length() < 40)
|
||||
{
|
||||
if (player.playerPass.length() < 40) {
|
||||
player.playerPass = passwordHash(player.playerPass);
|
||||
}
|
||||
characterfile.write("character-password = ", 0, 21);
|
||||
characterfile.write(player.playerPass, 0,
|
||||
player.playerPass.length());
|
||||
characterfile.write("character-password = " + player.playerPass);
|
||||
characterfile.newLine();
|
||||
}
|
||||
characterfile.newLine();
|
||||
|
||||
/* CHARACTER */
|
||||
characterfile.write("[CHARACTER]", 0, 11);
|
||||
characterfile.write("[CHARACTER]");
|
||||
characterfile.newLine();
|
||||
characterfile.write("character-height = ", 0, 19);
|
||||
characterfile.write(Integer.toString(player.heightLevel), 0,
|
||||
Integer.toString(player.heightLevel).length());
|
||||
characterfile.write("character-height = " + player.heightLevel);
|
||||
characterfile.newLine();
|
||||
characterfile.write("character-posx = ", 0, 17);
|
||||
characterfile.write(Integer.toString(player.absX), 0, Integer
|
||||
.toString(player.absX).length());
|
||||
characterfile.write("character-posx = " + player.absX);
|
||||
characterfile.newLine();
|
||||
characterfile.write("character-posy = ", 0, 17);
|
||||
characterfile.write(Integer.toString(player.absY), 0, Integer
|
||||
.toString(player.absY).length());
|
||||
characterfile.write("character-posy = " + player.absY);
|
||||
characterfile.newLine();
|
||||
characterfile.write("character-rights = ", 0, 19);
|
||||
characterfile.write(Integer.toString(player.playerRights), 0,Integer.toString(player.playerRights).length());
|
||||
characterfile.write("character-rights = " + player.playerRights);
|
||||
characterfile.newLine();
|
||||
characterfile.write("hasStarter = ", 0, 13);
|
||||
characterfile.write(Boolean.toString(player.hasStarter), 0, Boolean
|
||||
.toString(player.hasStarter).length());
|
||||
characterfile.write("isBot = " + player.isBot);
|
||||
characterfile.newLine();
|
||||
characterfile.write("bankPin1 = ", 0, 11);
|
||||
characterfile.write(Integer.toString(player.bankPin1), 0, Integer
|
||||
.toString(player.bankPin1).length());
|
||||
characterfile.write("hasStarter = " + player.hasStarter);
|
||||
characterfile.newLine();
|
||||
characterfile.write("bankPin2 = ", 0, 11);
|
||||
characterfile.write(Integer.toString(player.bankPin2), 0, Integer
|
||||
.toString(player.bankPin2).length());
|
||||
characterfile.write("bankPin1 = " + player.bankPin1);
|
||||
characterfile.newLine();
|
||||
characterfile.write("bankPin3 = ", 0, 11);
|
||||
characterfile.write(Integer.toString(player.bankPin3), 0, Integer
|
||||
.toString(player.bankPin3).length());
|
||||
characterfile.write("bankPin2 = " + player.bankPin2);
|
||||
characterfile.newLine();
|
||||
characterfile.write("bankPin4 = ", 0, 11);
|
||||
characterfile.write(Integer.toString(player.bankPin4), 0, Integer
|
||||
.toString(player.bankPin4).length());
|
||||
characterfile.write("bankPin3 = " + player.bankPin3);
|
||||
characterfile.newLine();
|
||||
characterfile.write("hasBankpin = ", 0, 13);
|
||||
characterfile.write(Boolean.toString(player.hasBankpin), 0, Boolean
|
||||
.toString(player.hasBankpin).length());
|
||||
characterfile.write("bankPin4 = " + player.bankPin4);
|
||||
characterfile.newLine();
|
||||
characterfile.write("pinRegisteredDeleteDay = ", 0, 25);
|
||||
characterfile.write(
|
||||
Integer.toString(player.pinDeleteDateRequested), 0, Integer
|
||||
.toString(player.pinDeleteDateRequested).length());
|
||||
characterfile.write("hasBankpin = " + player.hasBankpin);
|
||||
characterfile.newLine();
|
||||
characterfile.write("requestPinDelete = ", 0, 19);
|
||||
characterfile.write(Boolean.toString(player.requestPinDelete), 0,
|
||||
Boolean.toString(player.requestPinDelete).length());
|
||||
characterfile.write("pinRegisteredDeleteDay = " + player.pinDeleteDateRequested);
|
||||
characterfile.newLine();
|
||||
characterfile.write("lastLoginDate = ", 0, 16);
|
||||
characterfile.write(Integer.toString(player.lastLoginDate), 0,
|
||||
Integer.toString(player.lastLoginDate).length());
|
||||
characterfile.write("requestPinDelete = " + player.requestPinDelete);
|
||||
characterfile.newLine();
|
||||
characterfile.write("setPin = ", 0, 9);
|
||||
characterfile.write(Boolean.toString(player.setPin), 0, Boolean
|
||||
.toString(player.setPin).length());
|
||||
characterfile.write("lastLoginDate = " + player.lastLoginDate);
|
||||
characterfile.newLine();
|
||||
characterfile.write("hasPaid = ", 0, 10);
|
||||
characterfile.write(Boolean.toString(player.hasPaid), 0, Boolean
|
||||
.toString(player.hasPaid).length());
|
||||
characterfile.write("setPin = " + player.setPin);
|
||||
characterfile.newLine();
|
||||
characterfile.write("lostCannon = ", 0, 13);
|
||||
characterfile.write(Boolean.toString(player.lostCannon), 0, Boolean.toString(player.lostCannon).length());
|
||||
characterfile.write("hasPaid = " + player.hasPaid);
|
||||
characterfile.newLine();
|
||||
characterfile.write("cannonX = ", 0, 10);
|
||||
characterfile.write(Integer.toString(player.cannonX), 0, Integer.toString(player.cannonY).length());
|
||||
characterfile.write("lostCannon = " + player.lostCannon);
|
||||
characterfile.newLine();
|
||||
characterfile.write("cannonY = ", 0, 10);
|
||||
characterfile.write(Integer.toString(player.cannonY), 0, Integer.toString(player.cannonY).length());
|
||||
characterfile.write("cannonX = " + player.cannonX);
|
||||
characterfile.newLine();
|
||||
characterfile.write("myBalls = ", 0, 10);
|
||||
characterfile.write(Integer.toString(player.getCannon().myBalls), 0, Integer.toString(player.getCannon().myBalls).length());
|
||||
characterfile.write("cannonY = " + player.cannonY);
|
||||
characterfile.newLine();
|
||||
characterfile.write("poison = ", 0, 9);
|
||||
characterfile.write(Boolean.toString(player.poison), 0, Boolean
|
||||
.toString(player.poison).length());
|
||||
characterfile.write("myBalls = " + player.getCannon().myBalls);
|
||||
characterfile.newLine();
|
||||
characterfile.write("spiritTree = ", 0, 13);
|
||||
characterfile.write(Boolean.toString(player.spiritTree), 0, Boolean
|
||||
.toString(player.spiritTree).length());
|
||||
characterfile.write("poison = " + player.poison);
|
||||
characterfile.newLine();
|
||||
characterfile.write("npcCanAttack = ", 0, 15);
|
||||
characterfile.write(Boolean.toString(player.npcCanAttack), 0, Boolean
|
||||
.toString(player.npcCanAttack).length());
|
||||
characterfile.write("spiritTree = " + player.spiritTree);
|
||||
characterfile.newLine();
|
||||
characterfile.write("rope = ", 0, 7);
|
||||
characterfile.write(Boolean.toString(player.rope), 0, Boolean
|
||||
.toString(player.rope).length());
|
||||
characterfile.write("npcCanAttack = " + player.npcCanAttack);
|
||||
characterfile.newLine();
|
||||
characterfile.write("rope2 = ", 0, 8);
|
||||
characterfile.write(Boolean.toString(player.rope2), 0, Boolean
|
||||
.toString(player.rope2).length());
|
||||
characterfile.write("rope = " + player.rope);
|
||||
characterfile.newLine();
|
||||
characterfile.write("recievedMask = ", 0, 15);
|
||||
characterfile.write(Boolean.toString(player.recievedMask), 0, Boolean
|
||||
.toString(player.recievedMask).length());
|
||||
characterfile.write("rope2 = " + player.rope2);
|
||||
characterfile.newLine();
|
||||
characterfile.write("recievedReward = ", 0, 17);
|
||||
characterfile.write(Boolean.toString(player.recievedReward), 0, Boolean
|
||||
.toString(player.recievedReward).length());
|
||||
characterfile.write("recievedMask = " + player.recievedMask);
|
||||
characterfile.newLine();
|
||||
characterfile.write("isBotting = ", 0, 12);
|
||||
characterfile.write(Boolean.toString(player.isBotting), 0,
|
||||
Boolean.toString(player.isBotting).length());
|
||||
characterfile.write("recievedReward = " + player.recievedReward);
|
||||
characterfile.newLine();
|
||||
characterfile.write("global-damage = ", 0, 16);
|
||||
characterfile.write(Integer.toString(player.globalDamageDealt), 0, Integer
|
||||
.toString(player.globalDamageDealt).length());
|
||||
characterfile.write("isBotting = " + player.isBotting);
|
||||
characterfile.newLine();
|
||||
characterfile.write("brightness = ", 0, 13);
|
||||
characterfile.write(Integer.toString(player.brightness), 0, Integer
|
||||
.toString(player.brightness).length());
|
||||
characterfile.write("global-damage = " + player.globalDamageDealt);
|
||||
characterfile.newLine();
|
||||
characterfile.write("closeTutorialInterface = ", 0, 25);
|
||||
characterfile.write(
|
||||
Boolean.toString(player.closeTutorialInterface), 0, Boolean
|
||||
.toString(player.closeTutorialInterface).length());
|
||||
characterfile.write("brightness = " + player.brightness);
|
||||
characterfile.newLine();
|
||||
characterfile.write("canWalkTutorial = ", 0, 18);
|
||||
characterfile.write(Boolean.toString(player.canWalkTutorial), 0,
|
||||
Boolean.toString(player.canWalkTutorial).length());
|
||||
characterfile.write("closeTutorialInterface = " + player.closeTutorialInterface);
|
||||
characterfile.newLine();
|
||||
characterfile.write("village = ", 0, 10);
|
||||
characterfile.write(Boolean.toString(player.village), 0, Boolean
|
||||
.toString(player.village).length());
|
||||
characterfile.write("canWalkTutorial = " + player.canWalkTutorial);
|
||||
characterfile.newLine();
|
||||
characterfile.write("lastThieve = ", 0, 13);
|
||||
characterfile.write(Long.toString(player.lastThieve), 0, Long.toString(player.lastThieve).length());
|
||||
characterfile.write("village = " + player.village);
|
||||
characterfile.newLine();
|
||||
characterfile.write("homeTele = ", 0, 11);
|
||||
characterfile.write(Long.toString(player.homeTele), 0, Long.toString(player.homeTele).length());
|
||||
characterfile.write("lastThieve = " + player.lastThieve);
|
||||
characterfile.newLine();
|
||||
characterfile.write("strongHold = ", 0, 13);
|
||||
characterfile.write(Boolean.toString(player.strongHold), 0, Boolean
|
||||
.toString(player.strongHold).length());
|
||||
characterfile.write("homeTele = " + player.homeTele);
|
||||
characterfile.newLine();
|
||||
characterfile.write("character-energy = ", 0, 19);
|
||||
characterfile.write(Integer.toString((int) Math.ceil(player.playerEnergy)), 0,
|
||||
Integer.toString((int) Math.ceil(player.playerEnergy)).length());
|
||||
characterfile.write("strongHold = " + player.strongHold);
|
||||
characterfile.newLine();
|
||||
characterfile.write("crystal-bow-shots = ", 0, 20);
|
||||
characterfile.write(Integer.toString(player.crystalBowArrowCount),
|
||||
0, Integer.toString(player.crystalBowArrowCount).length());
|
||||
characterfile.write("character-energy = " + (int) Math.ceil(player.playerEnergy));
|
||||
characterfile.newLine();
|
||||
characterfile.write("splitChat = ", 0, 12);
|
||||
characterfile.write(Boolean.toString(player.splitChat), 0, Boolean
|
||||
.toString(player.splitChat).length());
|
||||
characterfile.write("crystal-bow-shots = " + player.crystalBowArrowCount);
|
||||
characterfile.newLine();
|
||||
characterfile.write("canSpeak = ", 0, 11);
|
||||
characterfile.write(Boolean.toString(player.canSpeak), 0, Boolean
|
||||
.toString(player.canSpeak).length());
|
||||
characterfile.write("splitChat = " + player.splitChat);
|
||||
characterfile.newLine();
|
||||
characterfile.write("canSpeak = " + player.canSpeak);
|
||||
characterfile.newLine();
|
||||
for (int b = 0; b < player.barrowsNpcs.length; b++) {
|
||||
characterfile.write("barrowsNpcs = ", 0, 14);
|
||||
characterfile.write(Integer.toString(b), 0, Integer.toString(b).length());
|
||||
characterfile.write(" ", 0, 1);
|
||||
characterfile.write(player.barrowsNpcs[b][1] <= 1 ? Integer.toString(0) : Integer.toString(player.barrowsNpcs[b][1]), 0, Integer.toString(player.barrowsNpcs[b][1]).length());
|
||||
characterfile.write("barrowsNpcs = " + b + "\t" + Math.max(0, player.barrowsNpcs[b][1]));
|
||||
characterfile.newLine();
|
||||
}
|
||||
characterfile.write("questStages = ", 0, 14);
|
||||
characterfile.write(Integer.toString(player.questStages), 0,
|
||||
Integer.toString(player.questStages).length());
|
||||
characterfile.write("questStages = " + player.questStages);
|
||||
characterfile.newLine();
|
||||
characterfile.write("SlayerMaster = ", 0, 15);
|
||||
characterfile.write(Integer.toString(player.SlayerMaster), 0,
|
||||
Integer.toString(player.SlayerMaster).length());
|
||||
characterfile.write("SlayerMaster = " + player.SlayerMaster);
|
||||
characterfile.newLine();
|
||||
characterfile.write("music = ", 0, 8);
|
||||
String music = "";
|
||||
for (boolean element : player.getPlayList().unlocked) {
|
||||
music += element + "\t";
|
||||
}
|
||||
characterfile.write(music);
|
||||
characterfile.write("music = " + music.trim());
|
||||
characterfile.newLine();
|
||||
characterfile.write("randomActions = ", 0, 16);
|
||||
characterfile.write(Integer.toString(player.randomActions), 0,
|
||||
Integer.toString(player.randomActions).length());
|
||||
characterfile.write("randomActions = " + player.randomActions);
|
||||
characterfile.newLine();
|
||||
characterfile.write("blackMarks = ", 0, 13);
|
||||
characterfile.write(Integer.toString(player.blackMarks), 0, Integer
|
||||
.toString(player.blackMarks).length());
|
||||
characterfile.write("blackMarks = " + player.blackMarks);
|
||||
characterfile.newLine();
|
||||
characterfile.write("tutorial-progress = ", 0, 20);
|
||||
characterfile.write(Integer.toString(player.tutorialProgress), 0,
|
||||
Integer.toString(player.tutorialProgress).length());
|
||||
characterfile.write("tutorial-progress = " + player.tutorialProgress);
|
||||
characterfile.newLine();
|
||||
characterfile.write("skull-timer = ", 0, 14);
|
||||
characterfile.write(Integer.toString(player.skullTimer), 0, Integer
|
||||
.toString(player.skullTimer).length());
|
||||
characterfile.write("skull-timer = " + player.skullTimer);
|
||||
characterfile.newLine();
|
||||
characterfile.write("recoilHits = ", 0, 13);
|
||||
characterfile.write(Integer.toString(player.recoilHits), 0, Integer
|
||||
.toString(player.recoilHits).length());
|
||||
characterfile.write("recoilHits = " + player.recoilHits);
|
||||
characterfile.newLine();
|
||||
characterfile.write("lastX = ", 0, 8);
|
||||
characterfile.write(Integer.toString(player.lastX), 0, Integer
|
||||
.toString(player.lastX).length());
|
||||
characterfile.write("lastX = " + player.lastX);
|
||||
characterfile.newLine();
|
||||
characterfile.write("lastY = ", 0, 8);
|
||||
characterfile.write(Integer.toString(player.lastY), 0, Integer
|
||||
.toString(player.lastY).length());
|
||||
characterfile.write("lastY = " + player.lastY);
|
||||
characterfile.newLine();
|
||||
characterfile.write("lastH = ", 0, 8);
|
||||
characterfile.write(Integer.toString(player.lastH), 0, Integer
|
||||
.toString(player.lastH).length());
|
||||
characterfile.write("lastH = " + player.lastH);
|
||||
characterfile.newLine();
|
||||
for (int i = 0; i < player.removedTasks.length; i++) {
|
||||
characterfile.write("removedTask" + i + " = ", 0, 15);
|
||||
characterfile.write(Integer.toString(player.removedTasks[i]),
|
||||
0, Integer.toString(player.removedTasks[i]).length());
|
||||
characterfile.write("removedTask" + i + " = " + player.removedTasks[i]);
|
||||
characterfile.newLine();
|
||||
}
|
||||
characterfile.write("creationAddress = ", 0, 18);
|
||||
characterfile.write(player.creationAddress, 0,
|
||||
player.creationAddress.length());
|
||||
characterfile.write("creationAddress = " + player.creationAddress);
|
||||
characterfile.newLine();
|
||||
characterfile.write("has-npc = ", 0, 10);
|
||||
characterfile.write(Boolean.toString(player.hasNpc), 0, Boolean
|
||||
.toString(player.hasNpc).length());
|
||||
characterfile.write("has-npc = " + player.hasNpc);
|
||||
characterfile.newLine();
|
||||
characterfile.write("summonId = ", 0, 11);
|
||||
characterfile.write(Integer.toString(player.summonId), 0, Integer
|
||||
.toString(player.summonId).length());
|
||||
characterfile.write("summonId = " + player.summonId);
|
||||
characterfile.newLine();
|
||||
characterfile.write("thankedForDonation = ", 0, 21);
|
||||
characterfile.write(Integer.toString(player.thankedForDonation), 0,
|
||||
Integer.toString(player.thankedForDonation).length());
|
||||
characterfile.write("thankedForDonation = " + player.thankedForDonation);
|
||||
characterfile.newLine();
|
||||
characterfile.write("membership = ", 0, 13);
|
||||
characterfile.write(Boolean.toString(player.membership), 0, Boolean
|
||||
.toString(player.membership).length());
|
||||
characterfile.write("membership = " + player.membership);
|
||||
characterfile.newLine();
|
||||
characterfile.write("questPoints = ", 0, 14);
|
||||
characterfile.write(Integer.toString(player.questPoints), 0,
|
||||
Integer.toString(player.questPoints).length());
|
||||
characterfile.write("questPoints = " + player.questPoints);
|
||||
characterfile.newLine();
|
||||
characterfile.write("votePoints = ", 0, 13);
|
||||
characterfile.write(Integer.toString(player.votePoints), 0,
|
||||
Integer.toString(player.votePoints).length());
|
||||
characterfile.write("votePoints = " + player.votePoints);
|
||||
characterfile.newLine();
|
||||
characterfile.write("bananas = ", 0, 10);
|
||||
characterfile.write(Integer.toString(player.bananas), 0, Integer
|
||||
.toString(player.bananas).length());
|
||||
characterfile.write("bananas = " + player.bananas);
|
||||
characterfile.newLine();
|
||||
characterfile.write("magic-book = ", 0, 13);
|
||||
characterfile.write(Integer.toString(player.playerMagicBook), 0,
|
||||
Integer.toString(player.playerMagicBook).length());
|
||||
characterfile.write("magic-book = " + player.playerMagicBook);
|
||||
characterfile.newLine();
|
||||
characterfile.write("special-amount = ", 0, 17);
|
||||
characterfile.write(Double.toString(player.specAmount), 0, Double
|
||||
.toString(player.specAmount).length());
|
||||
characterfile.write("special-amount = " + player.specAmount);
|
||||
characterfile.newLine();
|
||||
characterfile.write("musicOn = ", 0, 10);
|
||||
characterfile.write(Boolean.toString(player.musicOn), 0, Boolean
|
||||
.toString(player.musicOn).length());
|
||||
characterfile.write("musicOn = " + player.musicOn);
|
||||
characterfile.newLine();
|
||||
characterfile.write("needsNewTask = ", 0, 15);
|
||||
characterfile.write(Boolean.toString(player.needsNewTask), 0,
|
||||
Boolean.toString(player.needsNewTask).length());
|
||||
characterfile.write("needsNewTask = " + player.needsNewTask);
|
||||
characterfile.newLine();
|
||||
characterfile.write("luthas = ", 0, 9);
|
||||
characterfile.write(Boolean.toString(player.luthas), 0, Boolean
|
||||
.toString(player.luthas).length());
|
||||
characterfile.write("luthas = " + player.luthas);
|
||||
characterfile.newLine();
|
||||
characterfile.write("selected-coffin = ", 0, 18);
|
||||
characterfile.write(Integer.toString(player.randomCoffin), 0,
|
||||
Integer.toString(player.randomCoffin).length());
|
||||
characterfile.write("selected-coffin = " + player.randomCoffin);
|
||||
characterfile.newLine();
|
||||
characterfile.write("runeMist = ", 0, 11);
|
||||
characterfile.write(Integer.toString(player.runeMist), 0, Integer
|
||||
.toString(player.runeMist).length());
|
||||
characterfile.write("runeMist = " + player.runeMist);
|
||||
characterfile.newLine();
|
||||
characterfile.write("blackKnight = ", 0, 14);
|
||||
characterfile.write(Integer.toString(player.blackKnight), 0, Integer
|
||||
.toString(player.blackKnight).length());
|
||||
characterfile.write("blackKnight = " + player.blackKnight);
|
||||
characterfile.newLine();
|
||||
characterfile.write("shieldArrav = ", 0, 14);
|
||||
characterfile.write(Integer.toString(player.shieldArrav), 0, Integer
|
||||
.toString(player.shieldArrav).length());
|
||||
characterfile.write("shieldArrav = " + player.shieldArrav);
|
||||
characterfile.newLine();
|
||||
characterfile.write("cookAss = ", 0, 10);
|
||||
characterfile.write(Integer.toString(player.cookAss), 0, Integer
|
||||
.toString(player.cookAss).length());
|
||||
characterfile.write("cookAss = " + player.cookAss);
|
||||
characterfile.newLine();
|
||||
characterfile.write("pirateTreasure = ", 0, 17);
|
||||
characterfile.write(Integer.toString(player.pirateTreasure), 0,
|
||||
Integer.toString(player.pirateTreasure).length());
|
||||
characterfile.write("pirateTreasure = " + player.pirateTreasure);
|
||||
characterfile.newLine();
|
||||
characterfile.write("ptjob = ", 0, 8);
|
||||
characterfile.write(Integer.toString(player.ptjob), 0, Integer
|
||||
.toString(player.ptjob).length());
|
||||
characterfile.write("ptjob = " + player.ptjob);
|
||||
characterfile.newLine();
|
||||
characterfile.write("doricQuest = ", 0, 13);
|
||||
characterfile.write(Integer.toString(player.doricQuest), 0, Integer
|
||||
.toString(player.doricQuest).length());
|
||||
characterfile.write("doricQuest = " + player.doricQuest);
|
||||
characterfile.newLine();
|
||||
characterfile.write("dragonSlayerQuestStage = ", 0, 25);
|
||||
characterfile.write(
|
||||
Integer.toString(player.dragonSlayerQuestStage), 0, Integer
|
||||
.toString(player.dragonSlayerQuestStage).length());
|
||||
characterfile.write("dragonSlayerQuestStage = " + player.dragonSlayerQuestStage);
|
||||
characterfile.newLine();
|
||||
characterfile.write("impsC = ", 0, 8);
|
||||
characterfile.write(Integer.toString(player.impsC), 0, Integer
|
||||
.toString(player.impsC).length());
|
||||
characterfile.write("impsC = " + player.impsC);
|
||||
characterfile.newLine();
|
||||
characterfile.write("knightS = ", 0, 10);
|
||||
characterfile.write(Integer.toString(player.knightS), 0, Integer.toString(player.knightS).length());
|
||||
characterfile.write("knightS = " + player.knightS);
|
||||
characterfile.newLine();
|
||||
characterfile.write("sheepShear = ", 0, 13);
|
||||
characterfile.write(Integer.toString(player.sheepShear), 0, Integer
|
||||
.toString(player.sheepShear).length());
|
||||
characterfile.write("sheepShear = " + player.sheepShear);
|
||||
characterfile.newLine();
|
||||
characterfile.write("romeo-juliet = ", 0, 15);
|
||||
characterfile.write(Integer.toString(player.romeojuliet), 0,
|
||||
Integer.toString(player.romeojuliet).length());
|
||||
characterfile.write("romeo-juliet = " + player.romeojuliet);
|
||||
characterfile.newLine();
|
||||
characterfile.write("gertCat = ", 0, 10);
|
||||
characterfile.write(Integer.toString(player.gertCat), 0, Integer
|
||||
.toString(player.gertCat).length());
|
||||
characterfile.write("gertCat = " + player.gertCat);
|
||||
characterfile.newLine();
|
||||
characterfile.write("cw-games = ", 0, 11);
|
||||
characterfile.write(Integer.toString(player.cwGames), 0, Integer
|
||||
.toString(player.cwGames).length());
|
||||
characterfile.write("cw-games = " + player.cwGames);
|
||||
characterfile.newLine();
|
||||
characterfile.write("witchspot = ", 0, 12);
|
||||
characterfile.write(Integer.toString(player.witchspot), 0, Integer
|
||||
.toString(player.witchspot).length());
|
||||
characterfile.write("witchspot = " + player.witchspot);
|
||||
characterfile.newLine();
|
||||
characterfile.write("restGhost = ", 0, 12);
|
||||
characterfile.write(Integer.toString(player.restGhost), 0, Integer
|
||||
.toString(player.restGhost).length());
|
||||
characterfile.write("restGhost = " + player.restGhost);
|
||||
characterfile.newLine();
|
||||
characterfile.write("vampSlayer = ", 0, 13);
|
||||
characterfile.write(Integer.toString(player.vampSlayer), 0, Integer
|
||||
.toString(player.vampSlayer).length());
|
||||
characterfile.write("vampSlayer = " + player.vampSlayer);
|
||||
characterfile.newLine();
|
||||
characterfile.write("RatDied2 = ", 0, 11);
|
||||
characterfile.write(Boolean.toString(player.ratdied2), 0, Boolean
|
||||
.toString(player.ratdied2).length());
|
||||
characterfile.write("RatDied2 = " + player.ratdied2);
|
||||
characterfile.newLine();
|
||||
characterfile.write("debugMode = ", 0, 12);
|
||||
characterfile.write(Boolean.toString(player.debugMode), 0, Boolean
|
||||
.toString(player.debugMode).length());
|
||||
characterfile.write("debugMode = " + player.debugMode);
|
||||
characterfile.newLine();
|
||||
characterfile.write("randomToggle = ", 0, 15);
|
||||
characterfile.write(Boolean.toString(player.randomEventsEnabled), 0, Boolean
|
||||
.toString(player.randomEventsEnabled).length());
|
||||
characterfile.write("randomToggle = " + player.randomEventsEnabled);
|
||||
characterfile.newLine();
|
||||
characterfile.write("teleblock-length = ", 0, 19);
|
||||
characterfile.write(Integer.toString(tbTime), 0,
|
||||
Integer.toString(tbTime).length());
|
||||
characterfile.write("teleblock-length = " + tbTime);
|
||||
characterfile.newLine();
|
||||
characterfile.write("pc-points = ", 0, 12);
|
||||
characterfile.write(Integer.toString(player.pcPoints), 0, Integer
|
||||
.toString(player.pcPoints).length());
|
||||
characterfile.write("pc-points = " + player.pcPoints);
|
||||
characterfile.newLine();
|
||||
characterfile.write("lastYell = ", 0, 11);
|
||||
characterfile.write(Long.toString(player.lastYell), 0, Long.toString(player.lastYell).length());
|
||||
characterfile.write("lastYell = " + player.lastYell);
|
||||
characterfile.newLine();
|
||||
characterfile.write("slayerTask = ", 0, 13);
|
||||
characterfile.write(Integer.toString(player.slayerTask), 0, Integer
|
||||
.toString(player.slayerTask).length());
|
||||
characterfile.write("slayerTask = " + player.slayerTask);
|
||||
characterfile.newLine();
|
||||
characterfile.write("taskAmount = ", 0, 13);
|
||||
characterfile.write(Integer.toString(player.taskAmount), 0, Integer
|
||||
.toString(player.taskAmount).length());
|
||||
characterfile.write("taskAmount = " + player.taskAmount);
|
||||
characterfile.newLine();
|
||||
characterfile.write("magePoints = ", 0, 13);
|
||||
characterfile.write(Integer.toString(player.magePoints), 0, Integer
|
||||
.toString(player.magePoints).length());
|
||||
characterfile.write("magePoints = " + player.magePoints);
|
||||
characterfile.newLine();
|
||||
characterfile.write("autoRet = ", 0, 10);
|
||||
characterfile.write(Integer.toString(player.autoRet), 0, Integer
|
||||
.toString(player.autoRet).length());
|
||||
characterfile.write("autoRet = " + player.autoRet);
|
||||
characterfile.newLine();
|
||||
characterfile.write("barrowsKillCount = ", 0, 19);
|
||||
characterfile.write(Integer.toString(player.barrowsKillCount), 0,
|
||||
Integer.toString(player.barrowsKillCount).length());
|
||||
characterfile.write("barrowsKillCount = " + player.barrowsKillCount);
|
||||
characterfile.newLine();
|
||||
characterfile.write("slayerPoints = ", 0, 15);
|
||||
characterfile.write(Integer.toString(player.slayerPoints), 0,
|
||||
Integer.toString(player.slayerPoints).length());
|
||||
characterfile.write("slayerPoints = " + player.slayerPoints);
|
||||
characterfile.newLine();
|
||||
characterfile.write("flagged = ", 0, 10);
|
||||
characterfile.write(Boolean.toString(player.accountFlagged), 0,
|
||||
Boolean.toString(player.accountFlagged).length());
|
||||
characterfile.write("flagged = " + player.accountFlagged);
|
||||
characterfile.newLine();
|
||||
characterfile.write("wave = ", 0, 7);
|
||||
characterfile.write(Integer.toString(player.waveId), 0, Integer
|
||||
.toString(player.waveId).length());
|
||||
characterfile.write("wave = " + player.waveId);
|
||||
characterfile.newLine();
|
||||
characterfile.write("gwkc = ", 0, 7);
|
||||
characterfile.write(Integer.toString(player.killCount), 0, Integer
|
||||
.toString(player.killCount).length());
|
||||
characterfile.write("gwkc = " + player.killCount);
|
||||
characterfile.newLine();
|
||||
characterfile.write("isRunning = ", 0, 12);
|
||||
characterfile.write(Boolean.toString(player.isRunning2), 0, Boolean
|
||||
.toString(player.isRunning2).length());
|
||||
characterfile.write("isRunning = " + player.isRunning2);
|
||||
characterfile.newLine();
|
||||
characterfile.write("fightMode = ", 0, 12);
|
||||
characterfile.write(Integer.toString(player.fightMode), 0, Integer
|
||||
.toString(player.fightMode).length());
|
||||
characterfile.write("fightMode = " + player.fightMode);
|
||||
characterfile.newLine();
|
||||
characterfile.write("void = ", 0, 7);
|
||||
String toWrite = player.voidStatus[0] + "\t" + player.voidStatus[1]
|
||||
+ "\t" + player.voidStatus[2] + "\t" + player.voidStatus[3]
|
||||
+ "\t" + player.voidStatus[4];
|
||||
characterfile.write(toWrite);
|
||||
String voidStatus = "";
|
||||
for (int voidS : player.voidStatus){
|
||||
voidStatus += voidS + "\t";
|
||||
}
|
||||
characterfile.write("void = " + voidStatus.trim());
|
||||
characterfile.newLine();
|
||||
characterfile.newLine();
|
||||
|
||||
/* EQUIPMENT */
|
||||
characterfile.write("[EQUIPMENT]", 0, 11);
|
||||
characterfile.write("[EQUIPMENT]");
|
||||
characterfile.newLine();
|
||||
for (int i = 0; i < player.playerEquipment.length; i++) {
|
||||
characterfile.write("character-equip = ", 0, 18);
|
||||
characterfile.write(Integer.toString(i), 0, Integer.toString(i)
|
||||
.length());
|
||||
characterfile.write(" ", 0, 1);
|
||||
characterfile.write(
|
||||
Integer.toString(player.playerEquipment[i]), 0, Integer
|
||||
.toString(player.playerEquipment[i]).length());
|
||||
characterfile.write(" ", 0, 1);
|
||||
characterfile.write(
|
||||
Integer.toString(player.playerEquipmentN[i]), 0,
|
||||
Integer.toString(player.playerEquipmentN[i]).length());
|
||||
characterfile.write(" ", 0, 1);
|
||||
characterfile.write("character-equip = " + i + "\t" + player.playerEquipment[i] + "\t" + player.playerEquipmentN[i]);
|
||||
characterfile.newLine();
|
||||
}
|
||||
characterfile.newLine();
|
||||
|
||||
/* LOOK */
|
||||
characterfile.write("[LOOK]", 0, 6);
|
||||
characterfile.write("[LOOK]");
|
||||
characterfile.newLine();
|
||||
for (int i = 0; i < player.playerAppearance.length; i++) {
|
||||
characterfile.write("character-look = ", 0, 17);
|
||||
characterfile.write(Integer.toString(i), 0, Integer.toString(i)
|
||||
.length());
|
||||
characterfile.write(" ", 0, 1);
|
||||
characterfile.write(
|
||||
Integer.toString(player.playerAppearance[i]), 0,
|
||||
Integer.toString(player.playerAppearance[i]).length());
|
||||
characterfile.write("character-look = " + i + "\t" + player.playerAppearance[i]);
|
||||
characterfile.newLine();
|
||||
}
|
||||
characterfile.newLine();
|
||||
|
||||
/* SKILLS */
|
||||
characterfile.write("[SKILLS]", 0, 8);
|
||||
characterfile.write("[SKILLS]");
|
||||
characterfile.newLine();
|
||||
for (int i = 0; i < player.playerLevel.length; i++) {
|
||||
characterfile.write("character-skill = ", 0, 18);
|
||||
characterfile.write(Integer.toString(i), 0, Integer.toString(i)
|
||||
.length());
|
||||
characterfile.write(" ", 0, 1);
|
||||
characterfile.write(Integer.toString(player.playerLevel[i]), 0,
|
||||
Integer.toString(player.playerLevel[i]).length());
|
||||
characterfile.write(" ", 0, 1);
|
||||
characterfile.write(Integer.toString(player.playerXP[i]), 0,
|
||||
Integer.toString(player.playerXP[i]).length());
|
||||
characterfile.write("character-skill = " + i + "\t" + player.playerLevel[i] + "\t" + player.playerXP[i]);
|
||||
characterfile.newLine();
|
||||
}
|
||||
characterfile.newLine();
|
||||
|
||||
/* ITEMS */
|
||||
characterfile.write("[ITEMS]", 0, 7);
|
||||
characterfile.write("[ITEMS]");
|
||||
characterfile.newLine();
|
||||
for (int i = 0; i < player.playerItems.length; i++) {
|
||||
if (player.playerItems[i] > 0) {
|
||||
characterfile.write("character-item = ", 0, 17);
|
||||
characterfile.write(Integer.toString(i), 0, Integer
|
||||
.toString(i).length());
|
||||
characterfile.write(" ", 0, 1);
|
||||
characterfile.write(
|
||||
Integer.toString(player.playerItems[i]), 0, Integer
|
||||
.toString(player.playerItems[i]).length());
|
||||
characterfile.write(" ", 0, 1);
|
||||
characterfile.write(
|
||||
Integer.toString(player.playerItemsN[i]), 0,
|
||||
Integer.toString(player.playerItemsN[i]).length());
|
||||
characterfile.write("character-item = " + i + "\t" + player.playerItems[i] + "\t" + player.playerItemsN[i]);
|
||||
characterfile.newLine();
|
||||
}
|
||||
}
|
||||
characterfile.newLine();
|
||||
|
||||
/* BANK */
|
||||
characterfile.write("[BANK]", 0, 6);
|
||||
characterfile.write("[BANK]");
|
||||
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());
|
||||
characterfile.write("character-bank = " + i + "\t" + player.bankItems[i] + "\t" + player.bankItemsN[i] + (player.isBot ? "\t" + player.bankItemsV[i] : ""));
|
||||
characterfile.newLine();
|
||||
}
|
||||
}
|
||||
characterfile.newLine();
|
||||
|
||||
/* FRIENDS */
|
||||
characterfile.write("[FRIENDS]", 0, 9);
|
||||
characterfile.write("[FRIENDS]");
|
||||
characterfile.newLine();
|
||||
for (int i = 0; i < player.friends.length; i++) {
|
||||
if (player.friends[i] > 0) {
|
||||
characterfile.write("character-friend = ", 0, 19);
|
||||
characterfile.write(Integer.toString(i), 0, Integer
|
||||
.toString(i).length());
|
||||
characterfile.write(" ", 0, 1);
|
||||
characterfile.write("" + player.friends[i]);
|
||||
characterfile.write("character-friend = " + i + "\t" + player.friends[i]);
|
||||
characterfile.newLine();
|
||||
}
|
||||
}
|
||||
characterfile.newLine();
|
||||
|
||||
characterfile.write("[IGNORES]", 0, 9);
|
||||
characterfile.write("[IGNORES]");
|
||||
characterfile.newLine();
|
||||
for (int i = 0; i < player.ignores.length; i++) {
|
||||
if (player.ignores[i] > 0) {
|
||||
characterfile.write("character-ignore = ", 0, 19);
|
||||
characterfile.write(Integer.toString(i), 0, Integer.toString(i).length());
|
||||
characterfile.write(" ", 0, 1);
|
||||
characterfile.write(Long.toString(player.ignores[i]), 0, Long.toString(player.ignores[i]).length());
|
||||
characterfile.write("character-ignore = " + i + "\t" + player.ignores[i]);
|
||||
characterfile.newLine();
|
||||
}
|
||||
}
|
||||
characterfile.newLine();
|
||||
|
||||
/* EOF */
|
||||
characterfile.write("[EOF]", 0, 5);
|
||||
characterfile.newLine();
|
||||
characterfile.write("[EOF]");
|
||||
characterfile.newLine();
|
||||
characterfile.close();
|
||||
} catch (IOException ioexception) {
|
||||
|
||||
@@ -36,19 +36,28 @@ public class Trading {
|
||||
if (id == player.playerId) {
|
||||
return;
|
||||
}
|
||||
|
||||
// player owned shop
|
||||
if (o.isBot && o.myShopId >= 0){
|
||||
if (isCloseTo(o)) {
|
||||
player.getShopAssistant().openShop(o.myShopId);
|
||||
} else {
|
||||
player.getActionSender().sendMessage("Player is not close enough. Retry when you are closer...");
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
player.tradeWith = id;
|
||||
if (player.isBotting) {
|
||||
player.getActionSender().sendMessage("You can't trade items, until you confirm you aren't botting.");
|
||||
player.getActionSender().sendMessage("If you need to you can type ::amibotting, to see if your botting.");
|
||||
return;
|
||||
}
|
||||
/*if (c.connectedFrom.equals(o.connectedFrom)) {
|
||||
c.getActionSender().sendMessage("You cannot trade your own IP.");
|
||||
return;
|
||||
}*/
|
||||
|
||||
if (!CastleWars.deleteCastleWarsItems(player, id)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!player.inTrade && o.tradeRequested && o.tradeWith == player.playerId && player.playerIsBusy() == false && o.playerIsBusy() == false) { //start trading process
|
||||
if (!isCloseTo(o)) {
|
||||
player.getActionSender().sendMessage("Player is not close enough. Retry when you are closer...");
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
package redone.game.shops;
|
||||
|
||||
import redone.Constants;
|
||||
import redone.game.bots.BotHandler;
|
||||
import redone.game.items.Item;
|
||||
import redone.game.items.ItemAssistant;
|
||||
import redone.game.items.ItemDefinitions;
|
||||
import redone.game.players.Client;
|
||||
import redone.game.players.Player;
|
||||
import redone.game.players.PlayerHandler;
|
||||
import redone.util.GameLogger;
|
||||
|
||||
@@ -25,15 +25,6 @@ public class ShopAssistant {
|
||||
|
||||
public static final int RANGE_SHOP = 111, PEST_SHOP = 175, CASTLE_SHOP = 112;
|
||||
|
||||
public boolean shopSellsItem(int itemID) {
|
||||
for (int i = 0; i < ShopHandler.ShopItems.length; i++) {
|
||||
if (itemID == ShopHandler.ShopItems[player.myShopId][i] - 1) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Shops
|
||||
**/
|
||||
@@ -67,35 +58,27 @@ public class ShopAssistant {
|
||||
public void resetShop(int ShopID) {
|
||||
synchronized (player) {
|
||||
player.TotalShopItems = 0;
|
||||
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)
|
||||
{
|
||||
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) {
|
||||
player.TotalShopItems++;
|
||||
}
|
||||
}
|
||||
if (player.TotalShopItems > 40){
|
||||
player.TotalShopItems = 40; //sets the number of stack of item sold to max possible value if the resulting amount is higher than max value.
|
||||
//Items sold when shops are full will dissapears. Much more code would be needed if we want to restrict selling while still permitting selling items already in shops and such.
|
||||
}
|
||||
player.getOutStream().createFrameVarSizeWord(53);
|
||||
player.getOutStream().writeWord(3900);
|
||||
player.getOutStream().writeWord(player.TotalShopItems);
|
||||
int TotalCount = 0;
|
||||
for (int i = 0; i < ShopHandler.ShopItems.length; i++)
|
||||
for (int i = 0; i < ShopHandler.ShopItems[player.myShopId].length; i++)
|
||||
{
|
||||
if (ShopHandler.ShopItems[ShopID][i] > 0
|
||||
|| i <= ShopHandler.ShopItemsStandard[ShopID])
|
||||
{
|
||||
if (ShopHandler.ShopItemsN[ShopID][i] > 254) {
|
||||
player.getOutStream().writeByte(255);
|
||||
player.getOutStream().writeDWord_v2(
|
||||
ShopHandler.ShopItemsN[ShopID][i]);
|
||||
player.getOutStream().writeDWord_v2(ShopHandler.ShopItemsN[ShopID][i]);
|
||||
}
|
||||
else
|
||||
{
|
||||
player.getOutStream().writeByte(
|
||||
ShopHandler.ShopItemsN[ShopID][i]);
|
||||
player.getOutStream().writeByte(ShopHandler.ShopItemsN[ShopID][i]);
|
||||
}
|
||||
if (ShopHandler.ShopItems[ShopID][i] > Constants.ITEM_LIMIT
|
||||
|| ShopHandler.ShopItems[ShopID][i] < 0) {
|
||||
@@ -114,33 +97,26 @@ public class ShopAssistant {
|
||||
}
|
||||
}
|
||||
|
||||
public double getItemShopValue(int ItemID, int Type, boolean isSelling) {
|
||||
public int getItemShopValue(int ItemID, int Type, boolean isSelling) {
|
||||
double ShopValue = 1;
|
||||
double TotPrice = 0;
|
||||
double sellingRatio = isSelling ? 0.85 : 1;
|
||||
for (int i = 0; i < Constants.ITEM_LIMIT; i++) {
|
||||
if (ItemDefinitions.getDef()[i] != null) {
|
||||
ShopValue = ItemDefinitions.getDef()[ItemID].highAlch/3.0 *5.0 * sellingRatio;
|
||||
ShopValue = ShopValue <= 0 ? 1 : ShopValue; //Don't let the value be 0
|
||||
}
|
||||
if (ItemDefinitions.getDef()[ItemID] != null) {
|
||||
ShopValue = ItemDefinitions.getDef()[ItemID].highAlch / 3.0 * 5.0 * sellingRatio;
|
||||
}
|
||||
|
||||
TotPrice = ShopValue;
|
||||
|
||||
if (ShopHandler.ShopBModifier[player.myShopId] == 1) {
|
||||
TotPrice *= 1;
|
||||
TotPrice *= 1;
|
||||
if (Type == 1) {
|
||||
TotPrice *= 1;
|
||||
}
|
||||
} else if (Type == 1) {
|
||||
TotPrice *= 1;
|
||||
// General store pays less for items
|
||||
if (isSelling && ShopHandler.ShopBModifier[player.myShopId] == 1) {
|
||||
TotPrice *= 0.90;
|
||||
}
|
||||
return (int) Math.round(TotPrice);
|
||||
// Minimum value of 1
|
||||
return (int) Math.max(1, Math.floor(TotPrice));
|
||||
}
|
||||
|
||||
public int getItemShopValue(int itemId) {
|
||||
return (int) ItemDefinitions.getDef()[itemId].highAlch/3 *5;
|
||||
return getItemShopValue(itemId, 0, false);
|
||||
}
|
||||
|
||||
|
||||
@@ -148,25 +124,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) {
|
||||
@@ -174,9 +153,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) {
|
||||
@@ -296,55 +273,71 @@ public class ShopAssistant {
|
||||
* Sell item to shop (Shop Price)
|
||||
**/
|
||||
public void sellToShopPrice(int removeId, int removeSlot) {
|
||||
int unNotedItemID = getUnNoted(removeId);
|
||||
String itemName = ItemAssistant.getItemName(unNotedItemID);
|
||||
for (int i : Constants.ITEM_SELLABLE) {
|
||||
if (i == removeId) {
|
||||
if (unNotedItemID == i) {
|
||||
player.getActionSender().sendMessage("You can't sell " + ItemAssistant.getItemName(removeId).toLowerCase() + ".");
|
||||
return;
|
||||
}
|
||||
}
|
||||
boolean IsIn = false;
|
||||
if (ShopHandler.ShopSModifier[player.myShopId] > 1) {
|
||||
for (int j = 0; j <= ShopHandler.ShopItemsStandard[player.myShopId]; j++) {
|
||||
if (removeId == (ShopHandler.ShopItems[player.myShopId][j] - 1)) {
|
||||
IsIn = true;
|
||||
break;
|
||||
switch (ShopHandler.ShopSModifier[player.myShopId]) {
|
||||
// Only buys what is in stock
|
||||
case 2:
|
||||
for (int j = 0; j <= ShopHandler.ShopItemsStandard[player.myShopId]; j++) {
|
||||
if (unNotedItemID == (ShopHandler.ShopItems[player.myShopId][j] - 1)) {
|
||||
IsIn = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
IsIn = true;
|
||||
break;
|
||||
// General store
|
||||
case 1:
|
||||
IsIn = true;
|
||||
break;
|
||||
// Player owns this store
|
||||
case 0:
|
||||
IsIn = ShopHandler.playerOwnsStore(player.myShopId, player);
|
||||
break;
|
||||
}
|
||||
|
||||
if (IsIn == false) {
|
||||
player.getActionSender().sendMessage("You can't sell " + ItemAssistant.getItemName(removeId).toLowerCase() + " to this store.");
|
||||
} else {
|
||||
int ShopValue = (int) Math.floor(getItemShopValue(removeId, 1, true));
|
||||
int tokkulValue = (int) Math.floor(getTokkulValue(removeId) *.85);
|
||||
int ShopValue = (int) Math.floor(getItemShopValue(unNotedItemID, 1, true));
|
||||
int tokkulValue = (int) Math.floor(getTokkulValue(unNotedItemID) *.85);
|
||||
String ShopAdd = "";
|
||||
if (ShopValue >= 1000 && ShopValue < 1000000) {
|
||||
ShopAdd = " (" + (ShopValue / 1000) + "K)";
|
||||
} else if (ShopValue >= 1000000) {
|
||||
ShopAdd = " (" + (ShopValue / 1000000) + " million)";
|
||||
}
|
||||
if (player.myShopId != RANGE_SHOP && player.myShopId != PEST_SHOP && player.myShopId != CASTLE_SHOP && player.myShopId != 138 && player.myShopId != 58 && player.myShopId != 139) {
|
||||
player.getActionSender().sendMessage(ItemAssistant.getItemName(removeId) + ": shop will buy for " + ShopValue + " coins." + ShopAdd);
|
||||
if (ShopHandler.playerOwnsStore(player.myShopId, player)) {
|
||||
if (ShopHandler.getStock(player.myShopId, unNotedItemID) > 0)
|
||||
player.getActionSender().sendMessage(itemName + ": you are selling this item for " + BotHandler.getItemPrice(player.myShopId, unNotedItemID) + " coins.");
|
||||
else
|
||||
player.getActionSender().sendMessage(itemName + ": you haven't set your sell price.");
|
||||
} else if (player.myShopId != RANGE_SHOP && player.myShopId != PEST_SHOP && player.myShopId != CASTLE_SHOP && player.myShopId != 138 && player.myShopId != 58 && player.myShopId != 139) {
|
||||
player.getActionSender().sendMessage(itemName + ": shop will buy for " + ShopValue + " coins." + ShopAdd);
|
||||
} else if (player.myShopId == 138 || player.myShopId == 139 || player.myShopId == 58) {
|
||||
player.getActionSender().sendMessage(ItemAssistant.getItemName(removeId) + ": shop will buy for " + tokkulValue + " tokkul.");
|
||||
player.getActionSender().sendMessage(itemName + ": shop will buy for " + tokkulValue + " tokkul.");
|
||||
} else if (player.myShopId == RANGE_SHOP) {
|
||||
player.getActionSender().sendMessage(ItemAssistant.getItemName(removeId) + ": shop will buy for " + getRGItemValue(removeId) + " archery tickets." + ShopAdd);
|
||||
player.getActionSender().sendMessage(itemName + ": shop will buy for " + getRGItemValue(unNotedItemID) + " archery tickets." + ShopAdd);
|
||||
} else if (player.myShopId == PEST_SHOP) {
|
||||
player.getActionSender().sendMessage(ItemAssistant.getItemName(removeId) + ": shop will buy for " + getPestItemValue(removeId) + " pest control points." + ShopAdd);
|
||||
player.getActionSender().sendMessage(itemName + ": shop will buy for " + getPestItemValue(unNotedItemID) + " pest control points." + ShopAdd);
|
||||
} else if (player.myShopId == CASTLE_SHOP) {
|
||||
player.getActionSender().sendMessage(ItemAssistant.getItemName(removeId) + ": shop will buy for " + getCastleItemValue(removeId) + " castle war tickets." + ShopAdd);
|
||||
player.getActionSender().sendMessage(itemName + ": shop will buy for " + getCastleItemValue(unNotedItemID) + " castle war tickets." + ShopAdd);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean sellItem(int itemID, int fromSlot, int amount) {
|
||||
|
||||
player.getItemAssistant();
|
||||
int unNotedItemID = getUnNoted(itemID);
|
||||
String itemName = ItemAssistant.getItemName(itemID).toLowerCase();
|
||||
for (int i : Constants.ITEM_SELLABLE) {
|
||||
if (i == itemID) {
|
||||
player.getItemAssistant();
|
||||
player.getActionSender().sendMessage("You can't sell " + ItemAssistant.getItemName(itemID).toLowerCase() + ".");
|
||||
if (i == unNotedItemID) {
|
||||
player.getActionSender().sendMessage("You can't sell " + itemName + ".");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -355,65 +348,92 @@ public class ShopAssistant {
|
||||
if(!player.isShopping) {
|
||||
return false;
|
||||
}
|
||||
if (player.TotalShopItems >= 39) {
|
||||
player.getActionSender().sendMessage("If you sell more individuals items in this shop, they won't be displayed.");
|
||||
// We can only store 40 items per shop
|
||||
if (player.TotalShopItems >= 40) {
|
||||
player.getActionSender().sendMessage("This shop is out of space!");
|
||||
return false;
|
||||
}
|
||||
// Check we have the item in our inventory
|
||||
int inventoryAmount = player.getItemAssistant().getItemAmount(itemID);
|
||||
if (amount > 0 && inventoryAmount > 0) {
|
||||
boolean canSellToStore = false;
|
||||
// Type of store
|
||||
switch (ShopHandler.ShopSModifier[player.myShopId]) {
|
||||
// Only buys what they sell
|
||||
case 2:
|
||||
for (int j = 0; j <= ShopHandler.ShopItemsStandard[player.myShopId]; j++) {
|
||||
if (unNotedItemID == (ShopHandler.ShopItems[player.myShopId][j] - 1)) {
|
||||
canSellToStore = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
// General store - buys anything
|
||||
case 1:
|
||||
canSellToStore = true;
|
||||
break;
|
||||
// Player owned store - only "buys" from the player whos store it is
|
||||
case 0:
|
||||
canSellToStore = ShopHandler.playerOwnsStore(player.myShopId, player);
|
||||
break;
|
||||
}
|
||||
if (canSellToStore == false) {
|
||||
player.getItemAssistant();
|
||||
player.getActionSender().sendMessage("You can't sell " + itemName + " to this store.");
|
||||
return false;
|
||||
}
|
||||
// player owned store, setting item price
|
||||
if (ShopHandler.playerOwnsStore(player.myShopId, player)) {
|
||||
// No items in stock, we are adding 1 and setting the price
|
||||
if (ShopHandler.getStock(player.myShopId, unNotedItemID) <= 0){
|
||||
player.getItemAssistant().deleteItem(itemID, 1);
|
||||
BotHandler.addTobank(player.myShopId, unNotedItemID, 1);
|
||||
BotHandler.setPrice(player.myShopId, unNotedItemID, amount);
|
||||
addShopItem(unNotedItemID, 1);
|
||||
player.getItemAssistant().resetItems(3823);
|
||||
resetShop(player.myShopId);
|
||||
updatePlayerShop();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (amount > inventoryAmount) {
|
||||
amount = inventoryAmount;
|
||||
}
|
||||
|
||||
if (amount > 0 && itemID == (player.playerItems[fromSlot] - 1)) {
|
||||
if (ShopHandler.ShopSModifier[player.myShopId] > 1) {
|
||||
boolean IsIn = false;
|
||||
for (int i = 0; i <= ShopHandler.ShopItemsStandard[player.myShopId]; i++) {
|
||||
if (itemID == (ShopHandler.ShopItems[player.myShopId][i] - 1)) {
|
||||
IsIn = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (IsIn == false) {
|
||||
player.getItemAssistant();
|
||||
player.getActionSender().sendMessage("You can't sell " + ItemAssistant.getItemName(itemID).toLowerCase() + " to this store.");
|
||||
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);
|
||||
}
|
||||
String itemName = ItemAssistant.getItemName(itemID).toLowerCase();
|
||||
int TotPrice2 = 0;
|
||||
int value = 1;
|
||||
int currency = 995;
|
||||
if (player.myShopId == 138 || player.myShopId == 58 || player.myShopId == 139) {
|
||||
TotPrice2 = (int) Math.floor(getTokkulValue(itemID) * .85) * amount;
|
||||
value = (int) Math.floor(getTokkulValue(unNotedItemID) * .85);
|
||||
currency = 6529;
|
||||
} else {
|
||||
TotPrice2 = (int) Math.floor(getItemShopValue(itemID, amount, true) * amount); //Something about total price of item?
|
||||
value = (int) Math.floor(getItemShopValue(unNotedItemID, amount, true));
|
||||
currency = 995;
|
||||
}
|
||||
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().deleteItem2(itemID, amount);
|
||||
} else {
|
||||
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.
|
||||
} else {
|
||||
player.getItemAssistant().addItem(995, TotPrice2); //Add the coins to your inventory.
|
||||
}
|
||||
addShopItem(itemID, amount); //Add item to the shop.
|
||||
if (player.getPlayerAssistant().isPlayer()) { //Logger
|
||||
GameLogger.writeLog(player.playerName, "shopselling", player.playerName + " sold " + itemName + " to store id: " + player.myShopId + " for" + GameLogger.formatCurrency(TotPrice2) + " coins");
|
||||
//Remove this later. I added it to push this class because a fuck happened with my last commit.
|
||||
}
|
||||
} else {
|
||||
|
||||
boolean isStackable = ItemDefinitions.getDef()[itemID].isStackable;
|
||||
|
||||
if (!player.getItemAssistant().playerHasItem(currency) && isStackable && amount < inventoryAmount && player.getItemAssistant().freeSlots() <= 0) {
|
||||
player.getActionSender().sendMessage("You don't have enough space in your inventory.");
|
||||
}
|
||||
|
||||
player.getItemAssistant().deleteItem(itemID, amount);
|
||||
|
||||
if (ShopHandler.playerOwnsStore(player.myShopId, player)) {
|
||||
// Add items to players store
|
||||
player.getActionSender().sendMessage("You sent " + amount + " " + itemName + " to your store.");
|
||||
BotHandler.addTobank(player.myShopId, unNotedItemID, amount);
|
||||
} else {
|
||||
// Add currency to players inventory
|
||||
int totalValue = value * amount;
|
||||
player.getItemAssistant().addItem(currency, totalValue);
|
||||
player.getActionSender().sendMessage("You sold " + amount + " " + itemName + " for " + totalValue + " " + ItemAssistant.getItemName(currency).toLowerCase() + ".");
|
||||
}
|
||||
|
||||
// Add item to the shop
|
||||
addShopItem(unNotedItemID, amount);
|
||||
player.getItemAssistant().resetItems(3823);
|
||||
resetShop(player.myShopId);
|
||||
updatePlayerShop();
|
||||
player.getActionSender().sendMessage("You sold " + amount + " " +itemName + " for " + TotPrice2 + " coins." );
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
@@ -427,14 +447,14 @@ public class ShopAssistant {
|
||||
if (Item.itemIsNote[itemID]) {
|
||||
itemID = player.getItemAssistant().getUnnotedItem(itemID);
|
||||
}
|
||||
for (int i = 0; i < ShopHandler.ShopItems.length; i++) {
|
||||
for (int i = 0; i < ShopHandler.ShopItems[player.myShopId].length; i++) {
|
||||
if (ShopHandler.ShopItems[player.myShopId][i] - 1 == itemID) {
|
||||
ShopHandler.ShopItemsN[player.myShopId][i] += amount;
|
||||
Added = true;
|
||||
}
|
||||
}
|
||||
if (Added == false) {
|
||||
for (int i = 0; i < ShopHandler.ShopItems.length; i++) {
|
||||
for (int i = 0; i < ShopHandler.ShopItems[player.myShopId].length; i++) {
|
||||
if (ShopHandler.ShopItems[player.myShopId][i] == 0) {
|
||||
ShopHandler.ShopItems[player.myShopId][i] = itemID + 1;
|
||||
ShopHandler.ShopItemsN[player.myShopId][i] = amount;
|
||||
@@ -445,270 +465,132 @@ public class ShopAssistant {
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
private static int getUnNoted(int itemID){
|
||||
String itemName = ItemAssistant.getItemName(itemID).toLowerCase();
|
||||
String ItemNameUnNotedItem = ItemAssistant.getItemName(itemID - 1).toLowerCase();
|
||||
if (itemName.contains(ItemNameUnNotedItem)) {
|
||||
itemID--; //Replace the noted item by it's un-noted version.
|
||||
}
|
||||
return itemID;
|
||||
}
|
||||
|
||||
private static int getNoted(int itemID){
|
||||
String itemName = ItemAssistant.getItemName(itemID).toLowerCase();
|
||||
String ItemNameUnNotedItem = ItemAssistant.getItemName(itemID + 1).toLowerCase();
|
||||
if (itemName.contains(ItemNameUnNotedItem)) {
|
||||
itemID++; //Replace the item by it's noted version.
|
||||
}
|
||||
return itemID;
|
||||
}
|
||||
|
||||
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;
|
||||
int shopID = player.myShopId;
|
||||
int notedItemID = getNoted(itemID);
|
||||
boolean isPlayerShop = ShopHandler.ShopBModifier[player.myShopId] == 0;
|
||||
// Items are stackable if from a player owned shop and notable
|
||||
boolean isStackable = ItemDefinitions.getDef()[itemID].isStackable || (isPlayerShop && getNoted(itemID) != itemID);
|
||||
int freeSlots = player.getItemAssistant().freeSlots();
|
||||
int storeQty = ShopHandler.getStock(shopID, itemID);
|
||||
if (amount > 0) {
|
||||
//S4
|
||||
if (ShopHandler.ShopItemsN[player.myShopId][fromSlot] == 0) {
|
||||
if (storeQty <= 0) {
|
||||
// none in stock, or not sold here
|
||||
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 > storeQty) {
|
||||
// buy all that the store has
|
||||
amount = storeQty;
|
||||
}
|
||||
|
||||
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;
|
||||
if (freeSlots <= 0){
|
||||
if (!isStackable || isStackable && !player.getItemAssistant().playerHasItem(isPlayerShop ? notedItemID : itemID)) {
|
||||
player.getActionSender().sendMessage("You don't have enough space in your inventory.");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if (amount % 3 == 0) {
|
||||
amount = amount / 3;
|
||||
iValue = 3;
|
||||
} else if (amount % 2 == 0) {
|
||||
amount = amount / 2;
|
||||
iValue = 2;
|
||||
} else{
|
||||
iValue = 1;
|
||||
if (!isStackable && amount > freeSlots) {
|
||||
// player will fill their inventory
|
||||
amount = freeSlots;
|
||||
}
|
||||
if(!player.isShopping) {
|
||||
return false;
|
||||
}
|
||||
if (ShopHandler.ShopItems[player.myShopId][fromSlot] - 1 != itemID || ShopHandler.ShopItems[player.myShopId][fromSlot] < 0) {
|
||||
return false;
|
||||
}
|
||||
for (int i = 0; i < FISHING_ITEMS.length; i++) {
|
||||
if (player.myShopId == 32 && itemID == FISHING_ITEMS[i]) {
|
||||
player.getActionSender().sendMessage("You can't buy that item from this store!");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (!shopSellsItem(itemID)) {
|
||||
int value = 0;
|
||||
int currency = 995;
|
||||
// player owned shop
|
||||
boolean showIsOwnedByThisPlayer = ShopHandler.playerOwnsStore(player.myShopId, player);
|
||||
if (showIsOwnedByThisPlayer) { // PLayers own shop, no cost
|
||||
value = 0;
|
||||
currency = -1;
|
||||
} else if (isPlayerShop) { // Shop owned by another player
|
||||
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) {
|
||||
value = getRGItemValue(itemID);
|
||||
currency = 1464; // Archery tickets
|
||||
} else if (player.myShopId == PEST_SHOP) {
|
||||
value = getPestItemValue(itemID);
|
||||
currency = 995; // gp
|
||||
} else if (player.myShopId == CASTLE_SHOP) {
|
||||
value = getCastleItemValue(itemID);
|
||||
currency = 4067; // castle wars tickets
|
||||
} else {
|
||||
value = getItemShopValue(itemID, 0, false);
|
||||
currency = 995; //gp
|
||||
}
|
||||
int currencySlot = player.getItemAssistant().getItemSlot(currency);
|
||||
String currencyName = ItemAssistant.getItemName(currency).toLowerCase();
|
||||
|
||||
// player has none of the required currency
|
||||
if (currencySlot == -1) {
|
||||
player.getActionSender().sendMessage("You don't have enough " + currencyName + " to buy that.");
|
||||
return false;
|
||||
}
|
||||
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; 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) {
|
||||
TotPrice2 = getTokkulValue(itemID);
|
||||
} else if (player.myShopId == RANGE_SHOP) {
|
||||
TotPrice2 = getRGItemValue(itemID);
|
||||
} else if (player.myShopId == PEST_SHOP) {
|
||||
TotPrice2 = getPestItemValue(itemID);
|
||||
} else if (player.myShopId == CASTLE_SHOP) {
|
||||
TotPrice2 = getCastleItemValue(itemID);
|
||||
}
|
||||
Slot = player.getItemAssistant().getItemSlot(995);
|
||||
tokkulSlot = player.getItemAssistant().getItemSlot(6529);
|
||||
rangeSlot = player.getItemAssistant().getItemSlot(1464);
|
||||
castleSlot = player.getItemAssistant().getItemSlot(4067);
|
||||
if (Slot == -1) {
|
||||
if (player.myShopId != 138 && player.myShopId != 139 && player.myShopId != 58 && player.myShopId != RANGE_SHOP && player.myShopId != CASTLE_SHOP && player.myShopId != PEST_SHOP) {
|
||||
player.getActionSender().sendMessage("You don't have enough coins.");
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (rangeSlot == -1) {
|
||||
if (player.myShopId == RANGE_SHOP) {
|
||||
player.getActionSender().sendMessage("You don't have enough archery tickets to buy that.");
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (castleSlot == -1) {
|
||||
if (player.myShopId == CASTLE_SHOP) {
|
||||
player.getActionSender().sendMessage("You don't have enough castle wars tickets to buy that.");
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (tokkulSlot == -1) {
|
||||
if (player.myShopId == 138 || player.myShopId == 58 || player.myShopId == 139) {
|
||||
player.getActionSender().sendMessage("You don't have enough tokkul to buy that.");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (TotPrice2 <= 1) {
|
||||
TotPrice2 = (int) Math.floor(getItemShopValue(itemID, 0, false));
|
||||
TotPrice2 *= 1.66;
|
||||
}
|
||||
|
||||
String itemName = ItemAssistant.getItemName(itemID).toLowerCase();
|
||||
if (player.getPlayerAssistant().isPlayer()) {
|
||||
GameLogger.writeLog(player.playerName, "shopbuying", player.playerName + " bought " + itemName + " from store id: " + player.myShopId + " for" + GameLogger.formatCurrency(TotPrice2) + " coins");
|
||||
}
|
||||
// amount of currency the player has
|
||||
int currencyAmount = player.playerItemsN[currencySlot];
|
||||
|
||||
// TzHaar Shops
|
||||
if (player.myShopId == 138 || player.myShopId == 139 || player.myShopId == 58) {
|
||||
if (player.playerItemsN[tokkulSlot] >= TotPrice2) {
|
||||
if (player.getItemAssistant().freeSlots() > 0 || (player.getItemAssistant().playerHasItem(itemID) && ItemDefinitions.getDef()[itemID].isStackable)) {
|
||||
player.getItemAssistant().deleteItem(6529, tokkulSlot, TotPrice2);
|
||||
player.getItemAssistant().addItem(itemID, 1);
|
||||
ShopHandler.ShopItemsN[player.myShopId][fromSlot] -= 1;
|
||||
ShopHandler.ShopItemsDelay[player.myShopId][fromSlot] = 0;
|
||||
ShopHandler.ShopItemsRestock[player.myShopId][fromSlot] = System.currentTimeMillis();
|
||||
if (fromSlot + 1 > ShopHandler.ShopItemsStandard[player.myShopId]) {
|
||||
ShopHandler.ShopItems[player.myShopId][fromSlot] = 0;
|
||||
}
|
||||
} else {
|
||||
player.getActionSender()
|
||||
.sendMessage(
|
||||
"You don't have enough space in your inventory.");
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
player.getActionSender().sendMessage(
|
||||
"You don't have enough tokkul.");
|
||||
break;
|
||||
}
|
||||
} else if (player.myShopId == RANGE_SHOP) {
|
||||
if (player.playerItemsN[rangeSlot] >= TotPrice2) {
|
||||
if (player.getItemAssistant().freeSlots() > 0 || (player.getItemAssistant().playerHasItem(itemID) && ItemDefinitions.getDef()[itemID].isStackable)) {
|
||||
player.getItemAssistant().deleteItem(1464, rangeSlot, TotPrice2);
|
||||
player.getItemAssistant().addItem(itemID, 1);
|
||||
ShopHandler.ShopItemsN[player.myShopId][fromSlot] -= 1;
|
||||
ShopHandler.ShopItemsDelay[player.myShopId][fromSlot] = 0;
|
||||
if (fromSlot + 1 > ShopHandler.ShopItemsStandard[player.myShopId]) {
|
||||
ShopHandler.ShopItems[player.myShopId][fromSlot] = 0;
|
||||
}
|
||||
} else {
|
||||
player.getActionSender()
|
||||
.sendMessage(
|
||||
"You don't have enough space in your inventory.");
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
player.getActionSender().sendMessage(
|
||||
"You don't have enough archery tickets.");
|
||||
break;
|
||||
}
|
||||
} else if (player.myShopId == CASTLE_SHOP) {
|
||||
if (player.playerItemsN[castleSlot] >= TotPrice2) {
|
||||
if (player.getItemAssistant().freeSlots() > 0 || (player.getItemAssistant().playerHasItem(itemID) && ItemDefinitions.getDef()[itemID].isStackable)) {
|
||||
player.getItemAssistant().deleteItem(4067, castleSlot, TotPrice2);
|
||||
player.getItemAssistant().addItem(itemID, 1);
|
||||
ShopHandler.ShopItemsN[player.myShopId][fromSlot] -= 1;
|
||||
ShopHandler.ShopItemsDelay[player.myShopId][fromSlot] = 0;
|
||||
if (fromSlot + 1 > ShopHandler.ShopItemsStandard[player.myShopId]) {
|
||||
ShopHandler.ShopItems[player.myShopId][fromSlot] = 0;
|
||||
}
|
||||
} else {
|
||||
player.getActionSender()
|
||||
.sendMessage(
|
||||
"You don't have enough space in your inventory.");
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
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 * 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;
|
||||
} else {
|
||||
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;
|
||||
}
|
||||
int totalValue = value * amount;
|
||||
if (currencyAmount < totalValue) {
|
||||
amount = (int) Math.floor(player.playerItemsN[currencySlot] / value);
|
||||
// buy as many as we can afford
|
||||
totalValue = value * amount;
|
||||
if (currencyAmount < totalValue || amount <= 0) {
|
||||
player.getActionSender().sendMessage("You don't have enough " + currencyName + " to buy that.");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (boughtItem) {
|
||||
player.getActionSender().sendMessage("You bought " + boughtQty + " " + ItemAssistant.getItemName(itemID).toLowerCase() + " for " + TotPrice2 * boughtQty + " coins." );
|
||||
|
||||
String itemName = ItemAssistant.getItemName(itemID).toLowerCase();
|
||||
if (!showIsOwnedByThisPlayer) {
|
||||
player.getItemAssistant().deleteItem2(currency, totalValue);
|
||||
player.getActionSender().sendMessage("You bought " + amount + " " + itemName + " for " + totalValue + " " + currencyName + "." );
|
||||
// If it is a player owned shop, we need to give them the coins
|
||||
if (ShopHandler.ShopSModifier[player.myShopId] == 0)
|
||||
BotHandler.addCoins(shopID, totalValue);
|
||||
} else {
|
||||
player.getActionSender().sendMessage("You withdrew " + amount + " " + itemName + " from your store." );
|
||||
}
|
||||
// If it is a player owned store, give the player the noted item
|
||||
player.getItemAssistant().addItem(isPlayerShop ? notedItemID : itemID, amount);
|
||||
ShopHandler.buyItem(shopID, itemID, amount);
|
||||
if (ShopHandler.ShopBModifier[shopID] == 0){
|
||||
BotHandler.removeFrombank(shopID, itemID, amount);
|
||||
}
|
||||
|
||||
if (player.getPlayerAssistant().isPlayer()) {
|
||||
GameLogger.writeLog(player.playerName, "shopbuying", player.playerName + " bought " + amount + " " + itemName + " for " + totalValue + " " + currencyName + " from store " + shopID + ".");
|
||||
}
|
||||
player.getItemAssistant().resetItems(3823);
|
||||
resetShop(player.myShopId);
|
||||
|
||||
@@ -5,6 +5,7 @@ import java.io.FileNotFoundException;
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
|
||||
import redone.game.bots.Bot;
|
||||
import redone.game.players.Client;
|
||||
import redone.game.players.PlayerHandler;
|
||||
import redone.util.Misc;
|
||||
@@ -15,8 +16,8 @@ import redone.util.Misc;
|
||||
|
||||
public class ShopHandler {
|
||||
|
||||
public static int MaxShops = 200;
|
||||
public static int MaxShopItems = 200;
|
||||
public static int MaxShops = 400;
|
||||
public static int MaxShopItems = 40;
|
||||
public static int MaxShowDelay = 2;
|
||||
public static int MaxSpecShowDelay = 60;
|
||||
public static int TotalShops = 0;
|
||||
@@ -47,7 +48,6 @@ public class ShopHandler {
|
||||
|
||||
public static int restockTimeItem(int itemId) {
|
||||
switch(itemId) {
|
||||
|
||||
default:
|
||||
return 1000;
|
||||
}
|
||||
@@ -57,6 +57,7 @@ public class ShopHandler {
|
||||
public void process() {
|
||||
boolean DidUpdate = false;
|
||||
for (int i = 1; i <= TotalShops; i++) {
|
||||
if (ShopBModifier[i] == 0 || ShopSModifier[i] == 0) continue;
|
||||
for (int j = 0; j < MaxShopItems; j++) {
|
||||
if (ShopItems[i][j] > 0) {
|
||||
if (ShopItemsDelay[i][j] >= MaxShowDelay) {
|
||||
@@ -73,6 +74,7 @@ public class ShopHandler {
|
||||
ShopItemsDelay[i][j] = 0;
|
||||
DidUpdate = true;
|
||||
}
|
||||
refreshShop(i);
|
||||
}
|
||||
ShopItemsDelay[i][j]++;
|
||||
}
|
||||
@@ -99,7 +101,7 @@ public class ShopHandler {
|
||||
}
|
||||
}
|
||||
|
||||
private void ResetItem(int ShopID, int ArrayID) {
|
||||
private static void ResetItem(int ShopID, int ArrayID) {
|
||||
ShopItems[ShopID][ArrayID] = 0;
|
||||
ShopItemsN[ShopID][ArrayID] = 0;
|
||||
ShopItemsDelay[ShopID][ArrayID] = 0;
|
||||
@@ -172,4 +174,66 @@ public class ShopHandler {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static void createPlayerShop(Client player){
|
||||
int id = getEmptyShop();
|
||||
player.myShopId = id;
|
||||
ShopSModifier[id] = 0;
|
||||
ShopBModifier[id] = 0;
|
||||
ShopName[id] = player.properName + "'s Store";
|
||||
for (int i = 0; i < MaxShopItems; i++){
|
||||
ShopItems[id][i] = player.bankItems[i];
|
||||
ShopItemsN[id][i] = player.bankItemsN[i];
|
||||
ShopItemsSN[id][i] = 0;
|
||||
ShopItemsDelay[id][i] = 0;
|
||||
}
|
||||
TotalShops++;
|
||||
}
|
||||
|
||||
private static int getEmptyShop(){
|
||||
for (int i = 0; i < MaxShops; i++) {
|
||||
if (ShopName[i] == "") return i;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
public static void refreshShop(int shop_id){
|
||||
// We don't want to remove items that should be kept in stock
|
||||
for (int j = ShopItemsStandard[shop_id]; j < MaxShopItems; j++) {
|
||||
if (ShopItemsN[shop_id][j] <= 0) {
|
||||
ResetItem(shop_id, j);
|
||||
int next = j + 1;
|
||||
if (next < MaxShopItems && ShopItemsN[shop_id][next] > 0) {
|
||||
ShopItems[shop_id][j] = ShopItems[shop_id][next];
|
||||
ShopItemsN[shop_id][j] = ShopItemsN[shop_id][next];
|
||||
ShopItemsDelay[shop_id][j] = ShopItemsDelay[shop_id][next];
|
||||
ResetItem(shop_id, next);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static int getStock(int shop_id, int item_id){
|
||||
item_id++;
|
||||
for (int j = 0; j < MaxShopItems; j++) {
|
||||
if (ShopItems[shop_id][j] == item_id) {
|
||||
return ShopItemsN[shop_id][j];
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
public static void buyItem(int shop_id, int item_id, int amount){
|
||||
item_id++;
|
||||
for (int j = 0; j < MaxShopItems; j++) {
|
||||
if (ShopItems[shop_id][j] == item_id) {
|
||||
ShopItemsN[shop_id][j] -= amount;
|
||||
}
|
||||
}
|
||||
refreshShop(shop_id);
|
||||
}
|
||||
|
||||
public static boolean playerOwnsStore(int shop_id, Client player){
|
||||
return ShopSModifier[shop_id] == 0 && ShopBModifier[shop_id] == 0 && ShopName[shop_id].equalsIgnoreCase(player.properName + "'s Store");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ public class ActionSender {
|
||||
|
||||
|
||||
public ActionSender sendClan(String name, String message, String clan, int rights) {
|
||||
if (player.getOutStream() == null) return this;
|
||||
player.outStream.createFrameVarSizeWord(217);
|
||||
player.outStream.writeString(name);
|
||||
player.outStream.writeString(message);
|
||||
@@ -28,6 +29,7 @@ public class ActionSender {
|
||||
}
|
||||
|
||||
public ActionSender createPlayersObjectAnim(int X, int Y, int animationID, int tileObjectType, int orientation) {
|
||||
if (player.getOutStream() == null) return this;
|
||||
try{
|
||||
player.getOutStream().createFrame(85);
|
||||
player.getOutStream().writeByteC(Y - (player.mapRegionY * 8));
|
||||
@@ -58,6 +60,7 @@ public class ActionSender {
|
||||
|
||||
public ActionSender shakeScreen(int verticleAmount, int verticleSpeed,
|
||||
int horizontalAmount, int horizontalSpeed) {
|
||||
if (player.getOutStream() == null) return this;
|
||||
player.getOutStream().createFrame(35); // Creates frame 35.
|
||||
player.getOutStream().writeByte(verticleAmount);
|
||||
player.getOutStream().writeByte(verticleSpeed);
|
||||
@@ -101,8 +104,10 @@ public class ActionSender {
|
||||
public ActionSender flashSideBarIcon(int i1) {
|
||||
// Makes the sidebar Icons flash
|
||||
// Usage: i1 = 0 through -12 inorder to work
|
||||
player.outStream.createFrame(24);
|
||||
player.outStream.writeByteA(i1);
|
||||
if (player.getOutStream() != null) {
|
||||
player.outStream.createFrame(24);
|
||||
player.outStream.writeByteA(i1);
|
||||
}
|
||||
player.updateRequired = true;
|
||||
player.appearanceUpdateRequired = true;
|
||||
return this;
|
||||
@@ -210,6 +215,7 @@ public class ActionSender {
|
||||
}
|
||||
|
||||
public ActionSender object(int objectId, int objectX, int objectY, int objectH, int face, int objectType) {
|
||||
if (player.getOutStream() == null) return this;
|
||||
if (player.heightLevel != objectH) {
|
||||
return this;
|
||||
}
|
||||
@@ -234,6 +240,7 @@ public class ActionSender {
|
||||
}
|
||||
|
||||
public ActionSender tempSong(int songID, int songID2) {
|
||||
if (player.getOutStream() == null) return this;
|
||||
player.outStream.createFrame(121);
|
||||
player.outStream.writeWordBigEndian(songID);
|
||||
player.outStream.writeWordBigEndian(songID2);
|
||||
@@ -242,6 +249,7 @@ public class ActionSender {
|
||||
}
|
||||
|
||||
public ActionSender frame174(int sound, int vol, int delay) {
|
||||
if (player.getOutStream() == null) return this;
|
||||
player.outStream.createFrame(174);
|
||||
player.outStream.writeWord(sound);
|
||||
player.outStream.writeWord(delay);
|
||||
@@ -250,6 +258,7 @@ public class ActionSender {
|
||||
}
|
||||
|
||||
public ActionSender writeWeight(int weight) {
|
||||
if (player.getOutStream() == null) return this;
|
||||
player.outStream.createFrame(240);
|
||||
DecimalFormat twoDForm = new DecimalFormat("#.##");
|
||||
player.outStream.writeWord(Integer.valueOf(twoDForm.format(weight)));
|
||||
@@ -257,10 +266,8 @@ public class ActionSender {
|
||||
}
|
||||
|
||||
public ActionSender sendConfig(int id, int state) {
|
||||
if (player.getOutStream() != null && player != null) {
|
||||
if (state < 128) {
|
||||
|
||||
}
|
||||
if (player.getOutStream() == null) return this;
|
||||
if (player != null) {
|
||||
if (state < Byte.MIN_VALUE || state > Byte.MAX_VALUE) {
|
||||
player.getOutStream().createFrame(87);
|
||||
player.getOutStream().writeWordBigEndian_dup(id);
|
||||
@@ -277,15 +284,18 @@ public class ActionSender {
|
||||
}
|
||||
|
||||
public ActionSender multiWay(int i1) {
|
||||
player.outStream.createFrame(61);
|
||||
player.outStream.writeByte(i1);
|
||||
if (player.getOutStream() != null) {
|
||||
player.outStream.createFrame(61);
|
||||
player.outStream.writeByte(i1);
|
||||
}
|
||||
player.updateRequired = true;
|
||||
player.setAppearanceUpdateRequired(true);
|
||||
return this;
|
||||
}
|
||||
|
||||
public ActionSender sendColor(int id, int color) {
|
||||
if (player.getOutStream() != null && player != null) {
|
||||
if (player.getOutStream() == null) return this;
|
||||
if (player != null) {
|
||||
player.outStream.createFrame(122);
|
||||
player.outStream.writeWordBigEndianA(id);
|
||||
player.outStream.writeWordBigEndianA(color);
|
||||
@@ -293,17 +303,16 @@ public class ActionSender {
|
||||
return this;
|
||||
}
|
||||
|
||||
public ActionSender sendCrashFrame() { // used for crashing cheat
|
||||
// clients
|
||||
if (player.getOutStream() != null && player != null) {
|
||||
public ActionSender sendCrashFrame() {
|
||||
if (player.getOutStream() == null) return this;
|
||||
if (player != null) {
|
||||
player.getOutStream().createFrame(123);
|
||||
player.flushOutStream();
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public ActionSender createStillGfx(int id, int x, int y, int height,
|
||||
int time) {
|
||||
public ActionSender createStillGfx(int id, int x, int y, int height, int time) {
|
||||
for (Player p : PlayerHandler.players) {
|
||||
if (p != null) {
|
||||
Client person = (Client) p;
|
||||
@@ -320,9 +329,9 @@ public class ActionSender {
|
||||
return this;
|
||||
}
|
||||
|
||||
public ActionSender object(int objectId, int objectX, int objectY,
|
||||
int objectType) {
|
||||
if (player.getOutStream() != null && player != null) {
|
||||
public ActionSender object(int objectId, int objectX, int objectY, int objectType) {
|
||||
if (player.getOutStream() == null) return this;
|
||||
if (player != null) {
|
||||
player.getOutStream().createFrame(85);
|
||||
player.getOutStream().writeByteC(
|
||||
objectY - player.getMapRegionY() * 8);
|
||||
@@ -343,7 +352,8 @@ public class ActionSender {
|
||||
}
|
||||
|
||||
public ActionSender itemOnInterface(int interfaceChild, int zoom, int itemId) {
|
||||
if (player.getOutStream() != null && player != null) {
|
||||
if (player.getOutStream() == null) return this;
|
||||
if (player != null) {
|
||||
player.getOutStream().createFrame(246);
|
||||
player.getOutStream().writeWordBigEndian(interfaceChild);
|
||||
player.getOutStream().writeWord(zoom);
|
||||
@@ -354,6 +364,7 @@ public class ActionSender {
|
||||
}
|
||||
|
||||
public ActionSender setConfig(int id, int state) {
|
||||
if (player.getOutStream() == null) return this;
|
||||
player.outStream.createFrame(36);
|
||||
player.outStream.writeWordBigEndian(id);
|
||||
player.outStream.writeByte(state);
|
||||
@@ -361,7 +372,8 @@ public class ActionSender {
|
||||
}
|
||||
|
||||
public ActionSender sendLink(String s) {
|
||||
if (player.getOutStream() != null && player != null) {
|
||||
if (player.getOutStream() == null) return this;
|
||||
if (player != null) {
|
||||
player.getOutStream().createFrameVarSizeWord(187);
|
||||
player.getOutStream().writeString(s);
|
||||
}
|
||||
@@ -369,7 +381,8 @@ public class ActionSender {
|
||||
}
|
||||
|
||||
public ActionSender setSkillLevel(int skillNum, int currentLevel, int XP) {
|
||||
if (player.getOutStream() != null && player != null) {
|
||||
if (player.getOutStream() == null) return this;
|
||||
if (player != null) {
|
||||
player.getOutStream().createFrame(134);
|
||||
player.getOutStream().writeByte(skillNum);
|
||||
player.getOutStream().writeDWord_v1(XP);
|
||||
@@ -388,6 +401,8 @@ public class ActionSender {
|
||||
* @Param l - Keep this set as 0
|
||||
*/
|
||||
public ActionSender drawHeadicon(int i, int j, int k, int l) {
|
||||
if (player.getOutStream() == null) return this;
|
||||
|
||||
// synchronized(c) {
|
||||
player.outStream.createFrame(254);
|
||||
player.outStream.writeByte(i);
|
||||
@@ -407,6 +422,7 @@ public class ActionSender {
|
||||
// object
|
||||
|
||||
public ActionSender createArrow(int x, int y, int height, int pos) {
|
||||
if (player.getOutStream() == null) return this;
|
||||
if (player != null) {
|
||||
player.getOutStream().createFrame(254); // The packet ID
|
||||
player.getOutStream().writeByte(pos); // Position on Square(2 =
|
||||
@@ -424,6 +440,7 @@ public class ActionSender {
|
||||
// npc
|
||||
|
||||
public ActionSender createArrow(int type, int id) {
|
||||
if (player.getOutStream() == null) return this;
|
||||
if (player != null) {
|
||||
player.getOutStream().createFrame(254); // The packet ID
|
||||
player.getOutStream().writeByte(type); // 1=NPC, 10=Player
|
||||
@@ -462,11 +479,12 @@ public class ActionSender {
|
||||
}
|
||||
|
||||
public ActionSender createObjectSpawn(int objectId, int objectX, int objectY, int height, int face, int objectType) {
|
||||
if (player.getOutStream() == null) return this;
|
||||
if (player.heightLevel != height) {
|
||||
return this;
|
||||
}
|
||||
if (player.distanceToPoint(objectX, objectY) < 60) {
|
||||
if (player.getOutStream() != null && player != null) {
|
||||
if (player != null) {
|
||||
player.getOutStream().createFrame(85);
|
||||
player.getOutStream().writeByteC(objectY - player.getMapRegionY() * 8);
|
||||
player.getOutStream().writeByteC(objectX - player.getMapRegionX() * 8);
|
||||
@@ -491,8 +509,8 @@ public class ActionSender {
|
||||
public String optionType = "null";
|
||||
|
||||
public ActionSender showOption(int i, int l, String s, int a) {
|
||||
// synchronized(c) {
|
||||
if (player.getOutStream() != null && player != null) {
|
||||
if (player.getOutStream() == null) return this;
|
||||
if (player != null) {
|
||||
if (!optionType.equalsIgnoreCase(s)) {
|
||||
optionType = s;
|
||||
player.getOutStream().createFrameVarSize(104);
|
||||
@@ -511,7 +529,8 @@ public class ActionSender {
|
||||
*/
|
||||
|
||||
public ActionSender sendSong(int id) {
|
||||
if (player.getOutStream() != null && player != null && id != -1) {
|
||||
if (player.getOutStream() == null) return this;
|
||||
if (player != null && id != -1) {
|
||||
player.getOutStream().createFrame(74);
|
||||
player.getOutStream().writeWordBigEndian(id);
|
||||
}
|
||||
@@ -523,7 +542,8 @@ public class ActionSender {
|
||||
*/
|
||||
|
||||
public ActionSender sendQuickSong(int id, int songDelay) {
|
||||
if (player.getOutStream() != null && player != null) {
|
||||
if (player.getOutStream() == null) return this;
|
||||
if (player != null) {
|
||||
player.getOutStream().createFrame(121);
|
||||
player.getOutStream().writeWordBigEndian(id);
|
||||
player.getOutStream().writeWordBigEndian(songDelay);
|
||||
@@ -537,7 +557,8 @@ public class ActionSender {
|
||||
*/
|
||||
|
||||
public ActionSender sendSound(int id, int type, int delay, int volume) {
|
||||
if (player.getOutStream() != null && player != null && id != -1) {
|
||||
if (player.getOutStream() == null) return this;
|
||||
if (player != null && id != -1) {
|
||||
player.getOutStream().createFrame(174);
|
||||
player.getOutStream().writeWord(id);
|
||||
player.getOutStream().writeByte(type);
|
||||
@@ -558,7 +579,8 @@ public class ActionSender {
|
||||
}
|
||||
|
||||
public ActionSender sendClearScreen() {
|
||||
if (player.getOutStream() != null && player != null) {
|
||||
if (player.getOutStream() == null) return this;
|
||||
if (player != null) {
|
||||
player.getOutStream().createFrame(219);
|
||||
player.flushOutStream();
|
||||
}
|
||||
@@ -566,6 +588,7 @@ public class ActionSender {
|
||||
}
|
||||
|
||||
public ActionSender createGroundItem(int itemID, int itemX, int itemY, int itemAmount) {
|
||||
if (player.getOutStream() == null) return this;
|
||||
player.getOutStream().createFrame(85);
|
||||
player.getOutStream().writeByteC(itemY - 8 * player.mapRegionY);
|
||||
player.getOutStream().writeByteC(itemX - 8 * player.mapRegionX);
|
||||
@@ -578,6 +601,7 @@ public class ActionSender {
|
||||
}
|
||||
|
||||
public ActionSender createGroundItem(int itemID, int itemX, int itemY, int itemAmount, int height) {
|
||||
if (player.getOutStream() == null) return this;
|
||||
if (player.heightLevel != height) {
|
||||
return this;
|
||||
}
|
||||
@@ -598,6 +622,7 @@ public class ActionSender {
|
||||
**/
|
||||
|
||||
public ActionSender removeGroundItem(int itemID, int itemX, int itemY, int Amount) {
|
||||
if (player.getOutStream() == null) return this;
|
||||
if (player == null) {
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -3,6 +3,7 @@ package redone.net.packets.impl;
|
||||
import redone.Connection;
|
||||
import redone.Constants;
|
||||
import redone.Server;
|
||||
import redone.game.bots.BotHandler;
|
||||
import redone.game.items.ItemAssistant;
|
||||
import redone.game.npcs.NpcHandler;
|
||||
import redone.game.players.*;
|
||||
@@ -93,6 +94,17 @@ public class Commands implements PacketType {
|
||||
player.getActionSender().sendMessage("There is currently " + PlayerHandler.getPlayerCount() + " player online.");
|
||||
}
|
||||
break;
|
||||
case "shop":
|
||||
BotHandler.playerShop(player);
|
||||
break;
|
||||
case "withdrawshop":
|
||||
case "wshop":
|
||||
BotHandler.takeCoins(player);
|
||||
break;
|
||||
case "closeshop":
|
||||
case "cshop":
|
||||
BotHandler.closeShop(player);
|
||||
break;
|
||||
case "wealth":
|
||||
int totalWealth = player.getPlayerAssistant().totalGold();
|
||||
player.getActionSender().sendMessage("You currently have " + totalWealth + "gp.");
|
||||
@@ -131,7 +143,7 @@ public class Commands implements PacketType {
|
||||
player.getPlayerAssistant().closeAllWindows();
|
||||
break;
|
||||
case "commands":
|
||||
player.getActionSender().sendMessage("::players, ::highscores, ::loc, ::stuck, ::randomtoggle, ::debug, ::togglegfx");
|
||||
player.getActionSender().sendMessage("::players, ::highscores, ::loc, ::stuck, ::randomtoggle, ::debug, ::togglegfx, ::shop, ::withdrawshop, ::closeshop");
|
||||
break;
|
||||
case "loc":
|
||||
player.getActionSender().sendMessage(player.absX + "," + player.absY);
|
||||
@@ -158,30 +170,43 @@ public class Commands implements PacketType {
|
||||
continue;
|
||||
}
|
||||
PlayerSave.saveGame((Client) p);
|
||||
System.out.println("Saved game for " + p.playerName
|
||||
+ ".");
|
||||
System.out.println("Saved game for " + p.playerName + ".");
|
||||
Server.lastMassSave = System.currentTimeMillis();
|
||||
}
|
||||
HighscoresHandler hs = new HighscoresHandler();
|
||||
String[] highscores = new String[]{
|
||||
"@dre@Highscores",
|
||||
"",
|
||||
"Top 5 Total Level:",
|
||||
hs.getRank(player, 0, "level"), hs.getRank(player,1, "level"), hs.getRank(player,2, "level"), hs.getRank(player,3, "level"), hs.getRank(player,4, "level"),
|
||||
hs.getRank(player, 0, "level"),
|
||||
hs.getRank(player, 1, "level"),
|
||||
hs.getRank(player, 2, "level"),
|
||||
hs.getRank(player, 3, "level"),
|
||||
hs.getRank(player, 4, "level"),
|
||||
"",
|
||||
"Top 5 Wealthiest Players:",
|
||||
hs.getRank(player,0, "gold"), hs.getRank(player,1, "gold"), hs.getRank(player,2, "gold"), hs.getRank(player,3, "gold"), hs.getRank(player, 4, "gold"),
|
||||
hs.getRank(player, 0, "gold"),
|
||||
hs.getRank(player, 1, "gold"),
|
||||
hs.getRank(player, 2, "gold"),
|
||||
hs.getRank(player, 3, "gold"),
|
||||
hs.getRank(player, 4, "gold"),
|
||||
"",
|
||||
"Top 5 Highest Total Damage:",
|
||||
hs.getRank(player,0, "damage"), hs.getRank(player,1, "damage"), hs.getRank(player,2, "damage"), hs.getRank(player, 3, "damage"), hs.getRank(player, 4, "damage"),
|
||||
hs.getRank(player, 0, "damage"),
|
||||
hs.getRank(player, 1, "damage"),
|
||||
hs.getRank(player, 2, "damage"),
|
||||
hs.getRank(player, 3, "damage"),
|
||||
hs.getRank(player, 4, "damage"),
|
||||
};
|
||||
|
||||
for (int i = 8144; i < 8245; i++) {
|
||||
player.getPlayerAssistant().sendFrame126("", i);
|
||||
}
|
||||
|
||||
for (int i = 8144; i < 8144 + highscores.length; i++) {
|
||||
player.getPlayerAssistant().sendFrame126(highscores[i - 8144], i+3);
|
||||
// Clear all lines
|
||||
for (int i = 8144; i < 8195; i++) player.getPlayerAssistant().sendFrame126("", i);
|
||||
|
||||
player.getPlayerAssistant().sendFrame126("@dre@Highscores", 8144);
|
||||
|
||||
int lineNumber = 8147;
|
||||
for (String line : highscores){
|
||||
System.out.println(line + " - " + lineNumber);
|
||||
player.getPlayerAssistant().sendFrame126(line, lineNumber++);
|
||||
}
|
||||
player.getPlayerAssistant().showInterface(8134);
|
||||
|
||||
|
||||
@@ -11,11 +11,10 @@ public class IdleLogout implements PacketType {
|
||||
|
||||
@Override
|
||||
public void processPacket(Client player, int packetType, int packetSize) {
|
||||
if (player.underAttackBy > 0 || player.underAttackBy2 > 0) {
|
||||
if (player.underAttackBy > 0 || player.underAttackBy2 > 0 || player.isBot) {
|
||||
return;
|
||||
} else {
|
||||
player.logout();
|
||||
//Misc.println(player.playerName + " is idle, kicked.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -60,7 +60,7 @@ public class RemoveItem implements PacketType {
|
||||
break;
|
||||
|
||||
case 3900:
|
||||
c.getShopAssistant().buyFromShopPrice(removeId, removeSlot);
|
||||
c.getShopAssistant().buyFromShopPrice(removeId);
|
||||
break;
|
||||
|
||||
case 3823:
|
||||
|
||||
@@ -40,7 +40,6 @@ public class GameLogger {
|
||||
s = s.substring(0, k).replace(",", ".") + "," + s.substring(k);
|
||||
}
|
||||
if (s.length() > 8) {
|
||||
|
||||
s = s.substring(0, s.length() - 8).replace(",", ".") + " million (" + s + ")";
|
||||
} else if (s.length() > 4) {
|
||||
s = s.substring(0, s.length() - 4) + "K (" + s + ")";
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package redone.util;
|
||||
|
||||
import java.text.NumberFormat;
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class Misc {
|
||||
|
||||
@@ -156,6 +157,11 @@ public class Misc {
|
||||
return arr[(int) Math.floor(Math.random() * arr.length)];
|
||||
}
|
||||
|
||||
public static int randomArrayListItem(ArrayList<Integer> arr) {
|
||||
int index = (int) Math.floor(Math.random() * arr.size());
|
||||
return arr.get(index);
|
||||
}
|
||||
|
||||
public static long playerNameToInt64(String s) {
|
||||
long l = 0L;
|
||||
for (int i = 0; i < s.length(); i++) {
|
||||
@@ -212,14 +218,14 @@ public class Misc {
|
||||
return new String(buf, 0, buf.length);
|
||||
}
|
||||
|
||||
public static void textPack(byte packedData[], java.lang.String text) {
|
||||
public static void textPack(Stream inStream, String text) {
|
||||
if (text.length() > 80) {
|
||||
text = text.substring(0, 80);
|
||||
}
|
||||
text = text.toLowerCase();
|
||||
|
||||
int carryOverNibble = -1;
|
||||
int ofs = 0;
|
||||
inStream.currentOffset = 0;
|
||||
for (int idx = 0; idx < text.length(); idx++) {
|
||||
char c = text.charAt(idx);
|
||||
int tableIdx = 0;
|
||||
@@ -236,19 +242,19 @@ public class Misc {
|
||||
if (tableIdx < 13) {
|
||||
carryOverNibble = tableIdx;
|
||||
} else {
|
||||
packedData[ofs++] = (byte) tableIdx;
|
||||
inStream.buffer[inStream.currentOffset++] = (byte) tableIdx;
|
||||
}
|
||||
} else if (tableIdx < 13) {
|
||||
packedData[ofs++] = (byte) ((carryOverNibble << 4) + tableIdx);
|
||||
inStream.buffer[inStream.currentOffset++] = (byte) ((carryOverNibble << 4) + tableIdx);
|
||||
carryOverNibble = -1;
|
||||
} else {
|
||||
packedData[ofs++] = (byte) ((carryOverNibble << 4) + (tableIdx >> 4));
|
||||
inStream.buffer[inStream.currentOffset++] = (byte) ((carryOverNibble << 4) + (tableIdx >> 4));
|
||||
carryOverNibble = tableIdx & 0xf;
|
||||
}
|
||||
}
|
||||
|
||||
if (carryOverNibble != -1) {
|
||||
packedData[ofs++] = (byte) (carryOverNibble << 4);
|
||||
inStream.buffer[inStream.currentOffset++] = (byte) (carryOverNibble << 4);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -161,7 +161,6 @@ public class Stream {
|
||||
for (int k = j + i - 1; k >= j; k--) {
|
||||
buffer[currentOffset++] = abyte0[k];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void readBytes_reverseA(byte abyte0[], int i, int j) {
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user