Removed cycleRoomUnit for RoomAvatars

This commit is contained in:
Stankman 2023-07-25 11:57:29 -05:00
parent 4fee1bccf3
commit 9f40ce0a43
5 changed files with 72 additions and 7 deletions

View File

@ -57,8 +57,12 @@ public class Bot extends Unit implements Runnable {
private boolean chatRandom;
@Getter
private short chatDelay;
@Getter
@Setter
private int chatTimeOut;
private int chatTimestamp;
@Getter
@Setter
private short lastChatIndex;
private final int bubble;
@Getter
@ -445,4 +449,11 @@ public class Bot extends Unit implements Runnable {
}
}
public void incrementLastChatIndex() {
this.lastChatIndex++;
}
public void resetLastChatIndex() {
this.lastChatIndex = 0;
}
}

View File

@ -159,8 +159,6 @@ public class BotManager {
log.error("Caught exception", e);
}
}
bot.cycle(false);
} else {
habbo.getClient().sendResponse(new NotificationDialogMessageComposer(BubbleAlertKeys.FURNITURE_PLACEMENT_ERROR.getKey(), FurnitureMovementError.NO_RIGHTS.getErrorCode()));
}

View File

@ -816,10 +816,9 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
continue;
}
bot.cycle(this.allowBotsWalk);
bot.getRoomUnit().cycle(this);
if (this.cycleRoomUnit(bot.getRoomUnit())) {
if(bot.getRoomUnit().isStatusUpdateNeeded()) {
bot.getRoomUnit().setStatusUpdateNeeded(false);
updatedUnit.add(bot.getRoomUnit());
}

View File

@ -320,8 +320,6 @@ public class RoomAvatar extends RoomUnit {
public void giveEffect(int effectId, int duration, boolean forceEffect) {
if (!this.isInRoom()) {
return;
} else {
RoomAvatar roomAvatar = this;
}
if(this instanceof RoomHabbo) {

View File

@ -1,6 +1,11 @@
package com.eu.habbo.habbohotel.rooms.entities.units.types;
import com.eu.habbo.Emulator;
import com.eu.habbo.habbohotel.bots.Bot;
import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnitType;
import com.eu.habbo.habbohotel.wired.WiredHandler;
import com.eu.habbo.habbohotel.wired.WiredTriggerType;
import lombok.Getter;
@Getter
@ -9,6 +14,60 @@ public class RoomBot extends RoomAvatar {
super();
}
@Override
public boolean cycle(Room room) {
Bot bot = this.getRoom().getRoomUnitManager().getBotByRoomUnit(this);
if(bot == null) {
return false;
}
if (this.getRoom().isAllowBotsWalk()) {
if(bot.canWalk()) {
if (!this.isWalking()) {
if (this.getWalkTimeOut() < Emulator.getIntUnixTimestamp() && bot.getFollowingHabboId() == 0) {
this.setGoalLocation(Emulator.getConfig().getBoolean("hotel.bot.limit.walking.distance", true) ? this.getRoom().getLayout().getRandomWalkableTilesAround(this, this.getRoom().getLayout().getTile(this.getBotStartLocation().getX(), this.getBotStartLocation().getY()), this.getRoom(), Emulator.getConfig().getInt("hotel.bot.limit.walking.distance.radius", 5)) : this.getRoom().getRandomWalkableTile());
int timeOut = Emulator.getRandom().nextInt(20) * 2;
this.setWalkTimeOut((timeOut < 10 ? 5 : timeOut) + Emulator.getIntUnixTimestamp());
}
}
}
}
if (!bot.getChatLines().isEmpty() && bot.getChatTimeOut() <= Emulator.getIntUnixTimestamp() && bot.isChatAuto()) {
if (this.getRoom() != null) {
short test = 0;
if(bot.isChatRandom()) {
bot.setLastChatIndex((short) Emulator.getRandom().nextInt(bot.getChatLines().size()));
} else if(bot.getLastChatIndex() == bot.getChatLines().size() - 1) {
bot.resetLastChatIndex();
} else {
bot.incrementLastChatIndex();
}
if (bot.getLastChatIndex() >= bot.getChatLines().size()) {
bot.resetLastChatIndex();
}
String message = bot.getChatLines().get(bot.getLastChatIndex())
.replace(Emulator.getTexts().getValue("wired.variable.owner", "%owner%"), this.getRoom().getRoomInfo().getOwnerInfo().getUsername())
.replace(Emulator.getTexts().getValue("wired.variable.item_count", "%item_count%"), String.valueOf(this.getRoom().getRoomItemManager().getCurrentItems().size()))
.replace(Emulator.getTexts().getValue("wired.variable.name", "%name%"), bot.getName())
.replace(Emulator.getTexts().getValue("wired.variable.roomname", "%roomname%"), this.getRoom().getRoomInfo().getName())
.replace(Emulator.getTexts().getValue("wired.variable.user_count", "%user_count%"), String.valueOf(this.getRoom().getRoomUnitManager().getRoomHabbosCount()));
if(!WiredHandler.handle(WiredTriggerType.SAY_SOMETHING, this, room, new Object[]{ message })) {
bot.talk(message);
}
bot.setChatTimeOut(Emulator.getIntUnixTimestamp() + bot.getChatDelay());
}
}
return super.cycle(room);
}
public RoomUnitType getRoomUnitType() {
return RoomUnitType.BOT;
}