Fix non-random speech.java

This commit is contained in:
Oliver 2024-05-12 20:33:32 +00:00
parent dfb97f37e9
commit 112e1ff377

View File

@ -43,11 +43,11 @@ public class Bot implements Runnable {
private short chatDelay; private short chatDelay;
private int chatTimeOut; private int chatTimeOut;
private int chatTimestamp; private int chatTimestamp;
private short lastChatIndex; private int lastChatIndex;
private int bubble; private int bubble;
private String type; private final String type;
private int effect; private int effect;
@ -187,9 +187,7 @@ public class Bot implements Runnable {
if (!this.chatLines.isEmpty() && this.chatTimeOut <= Emulator.getIntUnixTimestamp() && this.chatAuto) { if (!this.chatLines.isEmpty() && this.chatTimeOut <= Emulator.getIntUnixTimestamp() && this.chatAuto) {
if (this.room != null) { if (this.room != null) {
this.lastChatIndex = (this.chatRandom ? (short) Emulator.getRandom().nextInt(this.chatLines.size()) : (this.lastChatIndex == (this.chatLines.size() - 1) ? 0 : this.lastChatIndex++)); if (this.lastChatIndex < 0 || this.lastChatIndex >= this.chatLines.size()) {
if (this.lastChatIndex >= this.chatLines.size()) {
this.lastChatIndex = 0; this.lastChatIndex = 0;
} }
@ -204,9 +202,19 @@ public class Bot implements Runnable {
this.talk(message); this.talk(message);
} }
if (this.chatRandom) {
this.lastChatIndex = (short) Emulator.getRandom().nextInt(this.chatLines.size());
} else {
this.lastChatIndex++;
if (this.lastChatIndex >= this.chatLines.size()) {
this.lastChatIndex = 0; // start from scratch :-3
}
}
this.chatTimeOut = Emulator.getIntUnixTimestamp() + this.chatDelay; this.chatTimeOut = Emulator.getIntUnixTimestamp() + this.chatDelay;
} }
} }
} }
} }
@ -420,6 +428,11 @@ public class Bot implements Runnable {
return this.effect; return this.effect;
} }
public void setBubble(int bubble) {
this.bubble = bubble;
this.needsUpdate = true;
}
public void setEffect(int effect, int duration) { public void setEffect(int effect, int duration) {
this.effect = effect; this.effect = effect;
this.needsUpdate = true; this.needsUpdate = true;