You've already forked Arcturus-Morningstar-Extended
mirror of
https://github.com/duckietm/Arcturus-Morningstar-Extended.git
synced 2026-06-19 15:06:19 +00:00
🆕 Added the option turn in menu for BOT
This commit is contained in:
@@ -189,11 +189,7 @@ public class Bot implements Runnable {
|
|||||||
int timeOut = Emulator.getRandom().nextInt(20) * 2;
|
int timeOut = Emulator.getRandom().nextInt(20) * 2;
|
||||||
this.roomUnit.setWalkTimeOut((timeOut < 10 ? 5 : timeOut) + Emulator.getIntUnixTimestamp());
|
this.roomUnit.setWalkTimeOut((timeOut < 10 ? 5 : timeOut) + Emulator.getIntUnixTimestamp());
|
||||||
}
|
}
|
||||||
}/* else {
|
}
|
||||||
for (RoomTile t : this.room.getLayout().getTilesAround(this.room.getLayout().getTile(this.getRoomUnit().getX(), this.getRoomUnit().getY()))) {
|
|
||||||
WiredManager.handle(WiredTriggerType.BOT_REACHED_STF, this.roomUnit, this.room, this.room.getItemsAt(t).toArray());
|
|
||||||
}
|
|
||||||
}*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!this.chatLines.isEmpty() && this.chatTimeOut <= Emulator.getIntUnixTimestamp() && this.chatAuto) {
|
if (!this.chatLines.isEmpty() && this.chatTimeOut <= Emulator.getIntUnixTimestamp() && this.chatAuto) {
|
||||||
@@ -218,7 +214,7 @@ public class Bot implements Runnable {
|
|||||||
} else {
|
} else {
|
||||||
this.lastChatIndex++;
|
this.lastChatIndex++;
|
||||||
if (this.lastChatIndex >= this.chatLines.size()) {
|
if (this.lastChatIndex >= this.chatLines.size()) {
|
||||||
this.lastChatIndex = 0; // start from scratch :-3
|
this.lastChatIndex = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -310,9 +306,6 @@ public class Bot implements Runnable {
|
|||||||
public void setName(String name) {
|
public void setName(String name) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.needsUpdate = true;
|
this.needsUpdate = true;
|
||||||
|
|
||||||
//if(this.room != null)
|
|
||||||
//this.room.sendComposer(new ChangeNameUpdatedComposer(this.getRoomUnit(), this.getName()).compose());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getMotto() {
|
public String getMotto() {
|
||||||
@@ -539,9 +532,28 @@ public class Bot implements Runnable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final short[] DEFAULT_OWNER_ACTION_IDS = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
|
private static final short[] DEFAULT_OWNER_ACTION_IDS = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 11};
|
||||||
|
|
||||||
|
public static final int ACTION_ROTATE = 11;
|
||||||
|
|
||||||
|
private static final long MIN_OWNER_ACTION_INTERVAL_MS = 200L;
|
||||||
|
|
||||||
|
private volatile long lastOwnerActionAt;
|
||||||
|
|
||||||
public short[] getOwnerActionIds() {
|
public short[] getOwnerActionIds() {
|
||||||
return DEFAULT_OWNER_ACTION_IDS;
|
return DEFAULT_OWNER_ACTION_IDS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public synchronized boolean tryAcquireOwnerActionSlot() {
|
||||||
|
long now = System.currentTimeMillis();
|
||||||
|
if (now - this.lastOwnerActionAt < MIN_OWNER_ACTION_INTERVAL_MS) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
this.lastOwnerActionAt = now;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onPostOwnerAction(int actionId) {
|
||||||
|
// no-op default
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,7 +23,6 @@ import java.util.regex.Pattern;
|
|||||||
|
|
||||||
public class FrankBot extends ButlerBot {
|
public class FrankBot extends ButlerBot {
|
||||||
private static final Logger LOGGER = LoggerFactory.getLogger(FrankBot.class);
|
private static final Logger LOGGER = LoggerFactory.getLogger(FrankBot.class);
|
||||||
|
|
||||||
public static final String BOT_TYPE = "frank";
|
public static final String BOT_TYPE = "frank";
|
||||||
public static final String PERMISSION_USE = "acc_bot_frank";
|
public static final String PERMISSION_USE = "acc_bot_frank";
|
||||||
private static final String KEY_DOOR_LINES = "__door_lines";
|
private static final String KEY_DOOR_LINES = "__door_lines";
|
||||||
@@ -75,13 +74,20 @@ public class FrankBot extends ButlerBot {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final short[] FRANK_OWNER_ACTIONS = new short[0];
|
private static final short[] FRANK_OWNER_ACTIONS = { (short) Bot.ACTION_ROTATE };
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public short[] getOwnerActionIds() {
|
public short[] getOwnerActionIds() {
|
||||||
return FRANK_OWNER_ACTIONS;
|
return FRANK_OWNER_ACTIONS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onPostOwnerAction(int actionId) {
|
||||||
|
if (actionId == ACTION_ROTATE && this.getRoomUnit() != null) {
|
||||||
|
this.homeRotation = this.getRoomUnit().getBodyRotation();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static void initialise() {
|
public static void initialise() {
|
||||||
chatResponses.clear();
|
chatResponses.clear();
|
||||||
doorLines = DEFAULT_DOOR_LINES;
|
doorLines = DEFAULT_DOOR_LINES;
|
||||||
|
|||||||
+22
-6
@@ -5,11 +5,13 @@ import com.eu.habbo.habbohotel.bots.Bot;
|
|||||||
import com.eu.habbo.habbohotel.bots.BotManager;
|
import com.eu.habbo.habbohotel.bots.BotManager;
|
||||||
import com.eu.habbo.habbohotel.permissions.Permission;
|
import com.eu.habbo.habbohotel.permissions.Permission;
|
||||||
import com.eu.habbo.habbohotel.rooms.Room;
|
import com.eu.habbo.habbohotel.rooms.Room;
|
||||||
|
import com.eu.habbo.habbohotel.rooms.RoomUserRotation;
|
||||||
import com.eu.habbo.habbohotel.users.DanceType;
|
import com.eu.habbo.habbohotel.users.DanceType;
|
||||||
import com.eu.habbo.messages.incoming.MessageHandler;
|
import com.eu.habbo.messages.incoming.MessageHandler;
|
||||||
import com.eu.habbo.messages.outgoing.generic.alerts.BotErrorComposer;
|
import com.eu.habbo.messages.outgoing.generic.alerts.BotErrorComposer;
|
||||||
import com.eu.habbo.messages.outgoing.rooms.users.RoomUserDanceComposer;
|
import com.eu.habbo.messages.outgoing.rooms.users.RoomUserDanceComposer;
|
||||||
import com.eu.habbo.messages.outgoing.rooms.users.RoomUserNameChangedComposer;
|
import com.eu.habbo.messages.outgoing.rooms.users.RoomUserNameChangedComposer;
|
||||||
|
import com.eu.habbo.messages.outgoing.rooms.users.RoomUserStatusComposer;
|
||||||
import com.eu.habbo.messages.outgoing.rooms.users.RoomUsersComposer;
|
import com.eu.habbo.messages.outgoing.rooms.users.RoomUsersComposer;
|
||||||
import com.eu.habbo.plugin.events.bots.BotSavedChatEvent;
|
import com.eu.habbo.plugin.events.bots.BotSavedChatEvent;
|
||||||
import com.eu.habbo.plugin.events.bots.BotSavedLookEvent;
|
import com.eu.habbo.plugin.events.bots.BotSavedLookEvent;
|
||||||
@@ -28,16 +30,20 @@ public class BotSaveSettingsEvent extends MessageHandler {
|
|||||||
|
|
||||||
if (room.getOwnerId() == this.client.getHabbo().getHabboInfo().getId() || this.client.getHabbo().hasPermission(Permission.ACC_ANYROOMOWNER)) {
|
if (room.getOwnerId() == this.client.getHabbo().getHabboInfo().getId() || this.client.getHabbo().hasPermission(Permission.ACC_ANYROOMOWNER)) {
|
||||||
int botId = this.packet.readInt();
|
int botId = this.packet.readInt();
|
||||||
|
|
||||||
Bot bot = room.getBot(Math.abs(botId));
|
Bot bot = room.getBot(Math.abs(botId));
|
||||||
|
|
||||||
if (bot == null)
|
if (bot == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (bot.getOwnerActionIds().length == 0)
|
|
||||||
return;
|
|
||||||
|
|
||||||
int settingId = this.packet.readInt();
|
int settingId = this.packet.readInt();
|
||||||
|
boolean allowed = false;
|
||||||
|
for (short a : bot.getOwnerActionIds()) {
|
||||||
|
if (a == settingId) {
|
||||||
|
allowed = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!allowed) return;
|
||||||
|
|
||||||
|
if (!bot.tryAcquireOwnerActionSlot()) return;
|
||||||
|
|
||||||
switch (settingId) {
|
switch (settingId) {
|
||||||
case 1:
|
case 1:
|
||||||
@@ -163,8 +169,18 @@ public class BotSaveSettingsEvent extends MessageHandler {
|
|||||||
bot.needsUpdate(true);
|
bot.needsUpdate(true);
|
||||||
room.sendComposer(new RoomUsersComposer(bot).compose());
|
room.sendComposer(new RoomUsersComposer(bot).compose());
|
||||||
break;
|
break;
|
||||||
|
case Bot.ACTION_ROTATE:
|
||||||
|
if (bot.getRoomUnit() == null) break;
|
||||||
|
int next = (bot.getRoomUnit().getBodyRotation().getValue() + 2) % 8;
|
||||||
|
RoomUserRotation rotation = RoomUserRotation.fromValue(next);
|
||||||
|
bot.getRoomUnit().setRotation(rotation);
|
||||||
|
bot.needsUpdate(true);
|
||||||
|
room.sendComposer(new RoomUserStatusComposer(bot.getRoomUnit()).compose());
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bot.onPostOwnerAction(settingId);
|
||||||
|
|
||||||
if (bot.needsUpdate()) {
|
if (bot.needsUpdate()) {
|
||||||
Emulator.getThreading().run(bot);
|
Emulator.getThreading().run(bot);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user