Bots use normal chat, with effects

This commit is contained in:
RedSparr0w
2019-11-23 20:40:56 +13:00
parent 576bee32c3
commit 2104fd9918
7 changed files with 17 additions and 25 deletions
+11 -18
View File
@@ -3,12 +3,8 @@ package redone.game.bots;
import redone.Server;
import redone.game.items.ItemAssistant;
import redone.game.players.Client;
import redone.game.players.Player;
import redone.game.players.PlayerHandler;
import redone.util.GameLogger;
import redone.util.Misc;
import java.nio.charset.StandardCharsets;
import java.text.DecimalFormat;
import java.util.*;
@@ -68,23 +64,20 @@ public class Bot {
String item_name = ItemAssistant.getItemName(item_id).toLowerCase();
int value = BotHandler.getItemPrice(botClient.myShopId, item_id);
if (value <= 0) return;
botClient.forcedChat("Selling " + item_name + " " + formatSellPrice(value) + " ea");
/*
Real chat - Disabled for now, can't get it to function correctly
// Add some color and effects
botClient.setChatTextColor(9);
botClient.setChatTextEffects(2);
String _message = "Selling " + item_name + " " + formatSellPrice(value) + " ea - " + botClient.playerName;
String message = "Selling " + item_name + " " + formatSellPrice(value) + " ea - " + botClient.playerName;
// Need to figure out how to calculate this
botClient.setChatTextSize((byte) 29);
// This is wrong too
botClient.setChatText(message.getBytes(StandardCharsets.UTF_8));
// Not a clue what this does
botClient.inStream.readBytes_reverseA(botClient.getChatText(), botClient.getChatTextSize(), 0);
// 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) {
+6 -6
View File
@@ -218,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;
@@ -242,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) {