mirror of
https://github.com/2006-Scape/2006Scape.git
synced 2026-07-06 00:32:01 +00:00
update bots handling, spawn bot on player
This commit is contained in:
@@ -6,6 +6,7 @@ import redone.game.players.Client;
|
||||
import redone.game.players.Player;
|
||||
import redone.game.players.PlayerHandler;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Random;
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
@@ -17,15 +18,15 @@ public class Bot {
|
||||
private Client botClient;
|
||||
static Timer timer = new Timer();
|
||||
|
||||
public Bot(String username) {
|
||||
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.saveCharacter = true;
|
||||
char first = username.charAt(0);
|
||||
botClient.properName = Character.toUpperCase(first) + username.substring(1, username.length());
|
||||
|
||||
@@ -33,8 +34,10 @@ public class Bot {
|
||||
botClient.saveCharacter = true;
|
||||
botClient.isActive = true;
|
||||
botClient.disconnected = false;
|
||||
System.out.println(botClient.getPlayerAssistant().getTotalLevel());
|
||||
Server.playerHandler.newPlayerClient(botClient);
|
||||
|
||||
botClient.getPlayerAssistant().movePlayer(x, y, z);
|
||||
|
||||
loadPlayerInfo(botClient, username, "bot_password", false);
|
||||
new TradeChat().run();
|
||||
}
|
||||
@@ -47,15 +50,24 @@ public class Bot {
|
||||
@Override
|
||||
public void run() {
|
||||
sendTradeChat();
|
||||
int delay = (15 + new Random().nextInt(25)) * 1000;
|
||||
int delay = (5 + new Random().nextInt(15)) * 1000;
|
||||
timer.schedule(new TradeChat(), delay);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void sendTradeChat() {
|
||||
botClient.forcedChat("Selling Rune Platebody 210k ea");
|
||||
/*
|
||||
Real chat - Disabled for now, can't get it to function correctly
|
||||
|
||||
botClient.setChatTextColor(9);
|
||||
botClient.setChatTextEffects(2);
|
||||
botClient.forcedChat("<col=#FF0033>Selling Rune Platebody 210k ea - " + botClient.playerName + "</col>");
|
||||
String message = "Selling Rune Platebody 210k ea - " + botClient.playerName;
|
||||
botClient.setChatTextSize((byte) 29);
|
||||
botClient.setChatText(message.getBytes(StandardCharsets.UTF_8));
|
||||
botClient.inStream.readBytes_reverseA(botClient.getChatText(), botClient.getChatTextSize(), 0);
|
||||
botClient.setChatTextUpdateRequired(true);
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user