mirror of
https://github.com/2006-Scape/2006Scape.git
synced 2026-10-01 02:17:17 +00:00
Non-spammy player shops (#407)
* Add check that players are over total level 50, but shop items check is broken * Bots now only appear when they meet reqs! Woot!
This commit is contained in:
@@ -10,7 +10,7 @@ public class GameConstants {
|
|||||||
|
|
||||||
public final static int ITEM_LIMIT = 15000, MAXITEM_AMOUNT = Integer.MAX_VALUE, CLIENT_VERSION = 999999,
|
public final static int ITEM_LIMIT = 15000, MAXITEM_AMOUNT = Integer.MAX_VALUE, CLIENT_VERSION = 999999,
|
||||||
WORLD = 1, IPS_ALLOWED = 250, CONNECTION_DELAY = 100,
|
WORLD = 1, IPS_ALLOWED = 250, CONNECTION_DELAY = 100,
|
||||||
MESSAGE_DELAY = 6000, MAX_PLAYERS = 100, REQ_AMOUNT = 150;
|
MESSAGE_DELAY = 6000, MAX_PLAYERS = 200, REQ_AMOUNT = 150;
|
||||||
|
|
||||||
public final static boolean SOUND = true,
|
public final static boolean SOUND = true,
|
||||||
GUILDS = true, WORLD_LIST_FIX = false,
|
GUILDS = true, WORLD_LIST_FIX = false,
|
||||||
|
|||||||
@@ -35,7 +35,12 @@ public class Bot {
|
|||||||
|
|
||||||
loadPlayerInfo(botClient, username, "bot_password", false);
|
loadPlayerInfo(botClient, username, "bot_password", false);
|
||||||
|
|
||||||
|
System.out.println("x is " + x);
|
||||||
|
if (x == null) {
|
||||||
|
System.out.println("Bot should be at " + botClient.getX() + ", " + botClient.getY());
|
||||||
|
}
|
||||||
if (x != null) {
|
if (x != null) {
|
||||||
|
System.out.println("Moving player to " + x + "," + y + "," + z);
|
||||||
botClient.getPlayerAssistant().movePlayer(x, y, z);
|
botClient.getPlayerAssistant().movePlayer(x, y, z);
|
||||||
}
|
}
|
||||||
new TradeChat().run();
|
new TradeChat().run();
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package com.rebotted.game.bots;
|
|||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.security.SecureRandom;
|
import java.security.SecureRandom;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
@@ -13,6 +14,8 @@ import com.rebotted.game.players.PlayerHandler;
|
|||||||
import com.rebotted.game.shops.ShopHandler;
|
import com.rebotted.game.shops.ShopHandler;
|
||||||
import com.rebotted.util.Misc;
|
import com.rebotted.util.Misc;
|
||||||
|
|
||||||
|
import static com.rebotted.game.players.PlayerSave.loadPlayerInfo;
|
||||||
|
|
||||||
public class BotHandler {
|
public class BotHandler {
|
||||||
|
|
||||||
static final List<Bot> botList = new ArrayList<>(BotConstants.MAX_BOTS);
|
static final List<Bot> botList = new ArrayList<>(BotConstants.MAX_BOTS);
|
||||||
@@ -39,7 +42,18 @@ public class BotHandler {
|
|||||||
if (child.getName().startsWith("♥")) {
|
if (child.getName().startsWith("♥")) {
|
||||||
String playerName = child.getName().split("♥")[1];
|
String playerName = child.getName().split("♥")[1];
|
||||||
playerName = playerName.substring(0, playerName.length() - 4);
|
playerName = playerName.substring(0, playerName.length() - 4);
|
||||||
System.out.println("Loading " + playerName + " shop");
|
|
||||||
|
Client determineIfLoad = new Client(null);
|
||||||
|
determineIfLoad.playerName = getShopName(playerName);
|
||||||
|
|
||||||
|
loadPlayerInfo(determineIfLoad, getShopName(playerName), "bot_password", false);
|
||||||
|
System.out.println(Arrays.toString(determineIfLoad.bankItemsN));
|
||||||
|
System.out.println("Bot [" + playerName + "] has totalLevel, bankItems[0]" + determineIfLoad.getPlayerAssistant().getTotalLevel() + ", " + determineIfLoad.bankItemsN[0]);
|
||||||
|
if (determineIfLoad.getPlayerAssistant().getTotalLevel() < 50 || determineIfLoad.bankItemsN[0] == 0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
System.out.println("Loading bot " + playerName);
|
||||||
|
|
||||||
String shopName = getShopName(playerName);
|
String shopName = getShopName(playerName);
|
||||||
Bot bot = connectBot(shopName, null, null, null);
|
Bot bot = connectBot(shopName, null, null, null);
|
||||||
Client playerShop = bot.getBotClient();
|
Client playerShop = bot.getBotClient();
|
||||||
@@ -56,6 +70,7 @@ public class BotHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
player.getPacketSender().sendMessage("Shop commands- ::shop, ::withdrawshop, ::closeshop");
|
player.getPacketSender().sendMessage("Shop commands- ::shop, ::withdrawshop, ::closeshop");
|
||||||
|
player.getPacketSender().sendMessage("Your shop will permanently stay if you're total level > 50!");
|
||||||
|
|
||||||
Client playerShop = getPlayerShop(player.playerName);
|
Client playerShop = getPlayerShop(player.playerName);
|
||||||
|
|
||||||
@@ -81,9 +96,11 @@ public class BotHandler {
|
|||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
// Set bot to same level as player
|
// Set bot to same level as player
|
||||||
|
playerShop.combatLevel = player.combatLevel;
|
||||||
i = 0;
|
i = 0;
|
||||||
for (int level : player.playerLevel) {
|
for (int level : player.playerLevel) {
|
||||||
playerShop.playerLevel[i] = level;
|
playerShop.playerLevel[i] = level;
|
||||||
|
playerShop.playerXP[i] = playerShop.getPlayerAssistant().getXPForLevel(level);
|
||||||
playerShop.getPlayerAssistant().refreshSkill(i);
|
playerShop.getPlayerAssistant().refreshSkill(i);
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,6 +27,9 @@ public class PlayerSave {
|
|||||||
BufferedReader characterfile = null;
|
BufferedReader characterfile = null;
|
||||||
boolean File1 = false;
|
boolean File1 = false;
|
||||||
|
|
||||||
|
if (player.playerName == null) {
|
||||||
|
System.out.println("WARNING: called loadPlayerInfo with a Client who does not have a .playerName");
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
characterfile = new BufferedReader(new FileReader(System.getProperty("user.dir") + "/data/characters/" + player.playerName + ".txt"));
|
characterfile = new BufferedReader(new FileReader(System.getProperty("user.dir") + "/data/characters/" + player.playerName + ".txt"));
|
||||||
File1 = true;
|
File1 = true;
|
||||||
|
|||||||
@@ -202,7 +202,7 @@ public class ShopHandler {
|
|||||||
|
|
||||||
private static int getEmptyshop(){
|
private static int getEmptyshop(){
|
||||||
for (int i = 0; i < MAX_SHOPS; i++) {
|
for (int i = 0; i < MAX_SHOPS; i++) {
|
||||||
if (shopName[i] == "") return i;
|
if (shopName[i].equals("")) return i;
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user