mirror of
https://git.krews.org/morningstar/Arcturus-Community.git
synced 2025-01-18 23:46:28 +01:00
RoomUnit walking behaviour refactor
This commit is contained in:
parent
81f45ba4b7
commit
13a05d1c07
@ -121,6 +121,7 @@ public class Bot extends Unit implements Runnable {
|
|||||||
this.bubbleId = set.getInt("bubble_id");
|
this.bubbleId = set.getInt("bubble_id");
|
||||||
|
|
||||||
this.roomUnit = new RoomBot();
|
this.roomUnit = new RoomBot();
|
||||||
|
this.roomUnit.setUnit(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Bot(Bot bot) {
|
public Bot(Bot bot) {
|
||||||
@ -189,48 +190,6 @@ public class Bot extends Unit implements Runnable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void cycle(boolean allowBotsWalk) {
|
|
||||||
if (this.getRoomUnit() != null) {
|
|
||||||
if (allowBotsWalk && this.canWalk) {
|
|
||||||
if (!this.getRoomUnit().isWalking()) {
|
|
||||||
if (this.getRoomUnit().getWalkTimeOut() < Emulator.getIntUnixTimestamp() && this.followingHabboId == 0) {
|
|
||||||
this.getRoomUnit().setGoalLocation(Emulator.getConfig().getBoolean("hotel.bot.limit.walking.distance", true) ? this.room.getLayout().getRandomWalkableTilesAround(this.getRoomUnit(), this.room.getLayout().getTile(this.getRoomUnit().getBotStartLocation().getX(), this.getRoomUnit().getBotStartLocation().getY()), this.room, Emulator.getConfig().getInt("hotel.bot.limit.walking.distance.radius", 5)) : this.room.getRandomWalkableTile());
|
|
||||||
|
|
||||||
int timeOut = Emulator.getRandom().nextInt(20) * 2;
|
|
||||||
this.getRoomUnit().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()))) {
|
|
||||||
WiredHandler.handle(WiredTriggerType.BOT_REACHED_STF, this.getRoomUnit(), this.room, this.room.getItemsAt(t).toArray());
|
|
||||||
}
|
|
||||||
}*/
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!this.chatLines.isEmpty() && this.chatTimeOut <= Emulator.getIntUnixTimestamp() && this.chatAuto) {
|
|
||||||
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 >= this.chatLines.size()) {
|
|
||||||
this.lastChatIndex = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
String message = this.chatLines.get(this.lastChatIndex)
|
|
||||||
.replace(Emulator.getTexts().getValue("wired.variable.owner", "%owner%"), this.room.getRoomInfo().getOwnerInfo().getUsername())
|
|
||||||
.replace(Emulator.getTexts().getValue("wired.variable.item_count", "%item_count%"), this.room.getRoomItemManager().getCurrentItems().size() + "")
|
|
||||||
.replace(Emulator.getTexts().getValue("wired.variable.name", "%name%"), this.name)
|
|
||||||
.replace(Emulator.getTexts().getValue("wired.variable.roomname", "%roomname%"), this.room.getRoomInfo().getName())
|
|
||||||
.replace(Emulator.getTexts().getValue("wired.variable.user_count", "%user_count%"), this.room.getRoomUnitManager().getRoomHabbosCount() + "");
|
|
||||||
|
|
||||||
if(!WiredHandler.handle(WiredTriggerType.SAY_SOMETHING, this.getRoomUnit(), room, new Object[]{ message })) {
|
|
||||||
this.talk(message);
|
|
||||||
}
|
|
||||||
|
|
||||||
this.chatTimeOut = Emulator.getIntUnixTimestamp() + this.chatDelay;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void talk(String message) {
|
public void talk(String message) {
|
||||||
if (this.room != null) {
|
if (this.room != null) {
|
||||||
BotChatEvent event = new BotTalkEvent(this, message);
|
BotChatEvent event = new BotTalkEvent(this, message);
|
||||||
|
@ -126,13 +126,10 @@ public class BotManager {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
bot.setRoomUnit(new RoomBot());
|
|
||||||
|
|
||||||
RoomBot roomBot = bot.getRoomUnit();
|
RoomBot roomBot = bot.getRoomUnit();
|
||||||
roomBot.setRotation(RoomRotation.SOUTH);
|
roomBot.setRotation(RoomRotation.SOUTH);
|
||||||
roomBot.setLocation(location);
|
roomBot.setLocation(location);
|
||||||
double stackHeight = room.getRoomItemManager().getTopHeightAt(location.getX(), location.getY());
|
double stackHeight = room.getRoomItemManager().getTopHeightAt(location.getX(), location.getY());
|
||||||
roomBot.setPreviousLocationZ(stackHeight);
|
|
||||||
roomBot.setCurrentZ(stackHeight);
|
roomBot.setCurrentZ(stackHeight);
|
||||||
roomBot.setRoom(room);
|
roomBot.setRoom(room);
|
||||||
roomBot.setRoomUnitType(RoomUnitType.BOT);
|
roomBot.setRoomUnitType(RoomUnitType.BOT);
|
||||||
|
@ -33,7 +33,7 @@ public class EnableCommand extends Command {
|
|||||||
}
|
}
|
||||||
if (target == gameClient.getHabbo() || gameClient.getHabbo().hasPermissionRight(Permission.ACC_ENABLE_OTHERS)) {
|
if (target == gameClient.getHabbo() || gameClient.getHabbo().hasPermissionRight(Permission.ACC_ENABLE_OTHERS)) {
|
||||||
try {
|
try {
|
||||||
if (target.getRoomUnit().getRoom() != null && target.getHabboInfo().getRiding() == null) {
|
if (target.getRoomUnit().getRoom() != null && !target.getRoomUnit().isRiding()) {
|
||||||
if (Emulator.getGameEnvironment().getPermissionsManager().isEffectBlocked(effectId, target.getHabboInfo().getPermissionGroup().getId())) {
|
if (Emulator.getGameEnvironment().getPermissionsManager().isEffectBlocked(effectId, target.getHabboInfo().getPermissionGroup().getId())) {
|
||||||
gameClient.getHabbo().whisper(getTextsValue("commands.error.cmd_enable.not_allowed"), RoomChatMessageBubbles.ALERT);
|
gameClient.getHabbo().whisper(getTextsValue("commands.error.cmd_enable.not_allowed"), RoomChatMessageBubbles.ALERT);
|
||||||
return true;
|
return true;
|
||||||
|
@ -12,9 +12,11 @@ public class FastwalkCommand extends Command {
|
|||||||
@Override
|
@Override
|
||||||
public boolean handle(GameClient gameClient, String[] params) {
|
public boolean handle(GameClient gameClient, String[] params) {
|
||||||
if (gameClient.getHabbo().getRoomUnit().getRoom() != null) {
|
if (gameClient.getHabbo().getRoomUnit().getRoom() != null) {
|
||||||
|
|
||||||
//TODO Make this an event plugin which fires that can be cancelled
|
//TODO Make this an event plugin which fires that can be cancelled
|
||||||
if (gameClient.getHabbo().getRoomUnit().getRoom() != null && gameClient.getHabbo().getHabboInfo().getRiding() != null)
|
if (gameClient.getHabbo().getRoomUnit().isRiding()) {
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
Habbo habbo = gameClient.getHabbo();
|
Habbo habbo = gameClient.getHabbo();
|
||||||
|
|
||||||
@ -26,7 +28,8 @@ public class FastwalkCommand extends Command {
|
|||||||
if (habbo == null)
|
if (habbo == null)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
habbo.getRoomUnit().setFastWalkEnabled(!habbo.getRoomUnit().isFastWalkEnabled());
|
|
||||||
|
habbo.getRoomUnit().setCmdFastWalkEnabled(!habbo.getRoomUnit().isCmdFastWalkEnabled());
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -41,7 +41,7 @@ public class PullCommand extends Command {
|
|||||||
gameClient.getHabbo().whisper(replaceUsername(getTextsValue("commands.error.cmd_pull.invalid"), params[1]));
|
gameClient.getHabbo().whisper(replaceUsername(getTextsValue("commands.error.cmd_pull.invalid"), params[1]));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
habbo.getRoomUnit().setGoalLocation(tile);
|
habbo.getRoomUnit().walkTo(tile);
|
||||||
gameClient.getHabbo().getRoomUnit().getRoom().sendComposer(new ChatMessageComposer(new RoomChatMessage(replaceUser(getTextsValue("commands.succes.cmd_pull.pull"), params[1]).replace("%gender_name%", (gameClient.getHabbo().getHabboInfo().getGender().equals(HabboGender.M) ? getTextsValue("gender.him") : getTextsValue("gender.her"))), gameClient.getHabbo(), gameClient.getHabbo(), RoomChatMessageBubbles.NORMAL)).compose());
|
gameClient.getHabbo().getRoomUnit().getRoom().sendComposer(new ChatMessageComposer(new RoomChatMessage(replaceUser(getTextsValue("commands.succes.cmd_pull.pull"), params[1]).replace("%gender_name%", (gameClient.getHabbo().getHabboInfo().getGender().equals(HabboGender.M) ? getTextsValue("gender.him") : getTextsValue("gender.her"))), gameClient.getHabbo(), gameClient.getHabbo(), RoomChatMessageBubbles.NORMAL)).compose());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -40,7 +40,7 @@ public class PushCommand extends Command {
|
|||||||
gameClient.getHabbo().whisper(replaceUsername(getTextsValue("commands.error.cmd_push.invalid"), params[1]));
|
gameClient.getHabbo().whisper(replaceUsername(getTextsValue("commands.error.cmd_push.invalid"), params[1]));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
habbo.getRoomUnit().setGoalLocation(tFrontTarget);
|
habbo.getRoomUnit().walkTo(tFrontTarget);
|
||||||
gameClient.getHabbo().getRoomUnit().getRoom().sendComposer(
|
gameClient.getHabbo().getRoomUnit().getRoom().sendComposer(
|
||||||
new ChatMessageComposer(
|
new ChatMessageComposer(
|
||||||
new RoomChatMessage(
|
new RoomChatMessage(
|
||||||
|
@ -10,7 +10,7 @@ public class SitCommand extends Command {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean handle(GameClient gameClient, String[] params) {
|
public boolean handle(GameClient gameClient, String[] params) {
|
||||||
if (gameClient.getHabbo().getHabboInfo().getRiding() == null) //TODO Make this an event plugin which fires that can be cancelled
|
if (!gameClient.getHabbo().getRoomUnit().isRiding()) //TODO Make this an event plugin which fires that can be cancelled
|
||||||
gameClient.getHabbo().getRoomUnit().makeSit();
|
gameClient.getHabbo().getRoomUnit().makeSit();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -10,7 +10,7 @@ public class StandCommand extends Command {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean handle(GameClient gameClient, String[] params) {
|
public boolean handle(GameClient gameClient, String[] params) {
|
||||||
if (gameClient.getHabbo().getHabboInfo().getRiding() == null) {
|
if (!gameClient.getHabbo().getRoomUnit().isRiding()) {
|
||||||
gameClient.getHabbo().getRoomUnit().makeStand();
|
gameClient.getHabbo().getRoomUnit().makeStand();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -41,6 +41,8 @@ public class SummonCommand extends Command {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Room room = habbo.getRoomUnit().getRoom();
|
Room room = habbo.getRoomUnit().getRoom();
|
||||||
|
|
||||||
|
//WHY? Why not just roomManager -> leaveRoom()
|
||||||
if (room != null) {
|
if (room != null) {
|
||||||
Emulator.getGameEnvironment().getRoomManager().logExit(habbo);
|
Emulator.getGameEnvironment().getRoomManager().logExit(habbo);
|
||||||
|
|
||||||
|
@ -36,7 +36,7 @@ public class SuperPullCommand extends Command {
|
|||||||
gameClient.getHabbo().whisper(replaceUsername(getTextsValue("commands.error.cmd_pull.invalid"), params[1]), RoomChatMessageBubbles.ALERT);
|
gameClient.getHabbo().whisper(replaceUsername(getTextsValue("commands.error.cmd_pull.invalid"), params[1]), RoomChatMessageBubbles.ALERT);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
habbo.getRoomUnit().setGoalLocation(tile);
|
habbo.getRoomUnit().walkTo(tile);
|
||||||
gameClient.getHabbo().getRoomUnit().getRoom().sendComposer(new ChatMessageComposer(new RoomChatMessage(replaceUser(getTextsValue("commands.succes.cmd_pull.pull"), params[1]).replace("%gender_name%", (gameClient.getHabbo().getHabboInfo().getGender().equals(HabboGender.M) ? getTextsValue("gender.him") : getTextsValue("gender.her"))), gameClient.getHabbo(), gameClient.getHabbo(), RoomChatMessageBubbles.NORMAL)).compose());
|
gameClient.getHabbo().getRoomUnit().getRoom().sendComposer(new ChatMessageComposer(new RoomChatMessage(replaceUser(getTextsValue("commands.succes.cmd_pull.pull"), params[1]).replace("%gender_name%", (gameClient.getHabbo().getHabboInfo().getGender().equals(HabboGender.M) ? getTextsValue("gender.him") : getTextsValue("gender.her"))), gameClient.getHabbo(), gameClient.getHabbo(), RoomChatMessageBubbles.NORMAL)).compose());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -12,7 +12,7 @@ public class TeleportCommand extends Command {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean handle(GameClient gameClient, String[] params) {
|
public boolean handle(GameClient gameClient, String[] params) {
|
||||||
if (gameClient.getHabbo().getHabboInfo().getRiding() != null){ //TODO Make this an event plugin which fires that can be cancelled
|
if (gameClient.getHabbo().getRoomUnit().isRiding()){ //TODO Make this an event plugin which fires that can be cancelled
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -687,7 +687,7 @@ public class ItemManager {
|
|||||||
Constructor<? extends RoomItem> c = itemClass.getConstructor(ResultSet.class, Item.class);
|
Constructor<? extends RoomItem> c = itemClass.getConstructor(ResultSet.class, Item.class);
|
||||||
c.setAccessible(true);
|
c.setAccessible(true);
|
||||||
|
|
||||||
RoomItem item = (RoomItem) c.newInstance(set, baseItem);
|
RoomItem item = c.newInstance(set, baseItem);
|
||||||
|
|
||||||
if (item instanceof InteractionWired interactionWired) {
|
if (item instanceof InteractionWired interactionWired) {
|
||||||
interactionWired.loadWiredSettings(set);
|
interactionWired.loadWiredSettings(set);
|
||||||
|
@ -139,7 +139,7 @@ public class InteractionBuildArea extends InteractionCustomValues {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean inSquare(RoomTile location) {
|
public boolean inSquare(RoomTile location) {
|
||||||
Room room = Emulator.getGameEnvironment().getRoomManager().getActiveRoomById(this.getRoomId());
|
Room room = this.getRoom();
|
||||||
|
|
||||||
if (room != null && this.tiles.size() == 0) {
|
if (room != null && this.tiles.size() == 0) {
|
||||||
regenAffectedTiles(room);
|
regenAffectedTiles(room);
|
||||||
|
@ -65,7 +65,7 @@ public class InteractionCannon extends RoomItem {
|
|||||||
if ((client == null || (tiles.contains(client.getHabbo().getRoomUnit().getCurrentPosition())) && client.getHabbo().getRoomUnit().isCanWalk()) && !this.cooldown) {
|
if ((client == null || (tiles.contains(client.getHabbo().getRoomUnit().getCurrentPosition())) && client.getHabbo().getRoomUnit().isCanWalk()) && !this.cooldown) {
|
||||||
if (client != null) {
|
if (client != null) {
|
||||||
client.getHabbo().getRoomUnit().setCanWalk(false);
|
client.getHabbo().getRoomUnit().setCanWalk(false);
|
||||||
client.getHabbo().getRoomUnit().setGoalLocation(client.getHabbo().getRoomUnit().getCurrentPosition());
|
client.getHabbo().getRoomUnit().walkTo(client.getHabbo().getRoomUnit().getCurrentPosition());
|
||||||
client.getHabbo().getRoomUnit().lookAtPoint(fuseTile);
|
client.getHabbo().getRoomUnit().lookAtPoint(fuseTile);
|
||||||
client.getHabbo().getRoomUnit().setStatusUpdateNeeded(true);
|
client.getHabbo().getRoomUnit().setStatusUpdateNeeded(true);
|
||||||
}
|
}
|
||||||
|
@ -64,14 +64,14 @@ public class InteractionCrackable extends RoomItem {
|
|||||||
|
|
||||||
super.onClick(client, room, objects);
|
super.onClick(client, room, objects);
|
||||||
synchronized (this.lock) {
|
synchronized (this.lock) {
|
||||||
if (this.getRoomId() == 0)
|
if (this.getRoom() == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (this.cracked)
|
if (this.cracked)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (this.userRequiredToBeAdjacent() && client.getHabbo().getRoomUnit().getCurrentPosition().distance(room.getLayout().getTile(this.getCurrentPosition().getX(), this.getCurrentPosition().getY())) > 1.5) {
|
if (this.userRequiredToBeAdjacent() && client.getHabbo().getRoomUnit().getCurrentPosition().distance(room.getLayout().getTile(this.getCurrentPosition().getX(), this.getCurrentPosition().getY())) > 1.5) {
|
||||||
client.getHabbo().getRoomUnit().setGoalLocation(room.getLayout().getTileInFront(room.getLayout().getTile(this.getCurrentPosition().getX(), this.getCurrentPosition().getY()), Rotation.Calculate(client.getHabbo().getRoomUnit().getCurrentPosition().getX(), client.getHabbo().getRoomUnit().getCurrentPosition().getY(), this.getCurrentPosition().getX(), this.getCurrentPosition().getY())));
|
client.getHabbo().getRoomUnit().walkTo(room.getLayout().getTileInFront(room.getLayout().getTile(this.getCurrentPosition().getX(), this.getCurrentPosition().getY()), Rotation.Calculate(client.getHabbo().getRoomUnit().getCurrentPosition().getX(), client.getHabbo().getRoomUnit().getCurrentPosition().getY(), this.getCurrentPosition().getX(), this.getCurrentPosition().getY())));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -87,7 +87,7 @@ public class InteractionFireworks extends InteractionDefault {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
client.getHabbo().getRoomUnit().setGoalLocation(closestTile);
|
client.getHabbo().getRoomUnit().walkTo(closestTile);
|
||||||
Emulator.getThreading().run(new RoomUnitWalkToLocation(client.getHabbo().getRoomUnit(), closestTile, room, onSuccess, new ArrayList<>()));
|
Emulator.getThreading().run(new RoomUnitWalkToLocation(client.getHabbo().getRoomUnit(), closestTile, room, onSuccess, new ArrayList<>()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -131,7 +131,7 @@ public class InteractionGymEquipment extends InteractionEffectTile implements IC
|
|||||||
super.setRotation(rotation);
|
super.setRotation(rotation);
|
||||||
|
|
||||||
if (this.forceRotation() && this.roomUnitId != -1) {
|
if (this.forceRotation() && this.roomUnitId != -1) {
|
||||||
Room room = Emulator.getGameEnvironment().getRoomManager().getActiveRoomById(this.getRoomId());
|
Room room = this.getRoom();
|
||||||
if (room != null) {
|
if (room != null) {
|
||||||
RoomUnit roomUnit = this.getCurrentRoomUnit(room);
|
RoomUnit roomUnit = this.getCurrentRoomUnit(room);
|
||||||
|
|
||||||
|
@ -62,7 +62,7 @@ public class InteractionHopper extends RoomItem {
|
|||||||
|
|
||||||
Emulator.getThreading().run(new HopperActionOne(this, room, client), 500);
|
Emulator.getThreading().run(new HopperActionOne(this, room, client), 500);
|
||||||
} else {
|
} else {
|
||||||
client.getHabbo().getRoomUnit().setGoalLocation(loc);
|
client.getHabbo().getRoomUnit().walkTo(loc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -78,7 +78,7 @@ public class InteractionHopper extends RoomItem {
|
|||||||
if (!this.getExtraData().equals("0")) {
|
if (!this.getExtraData().equals("0")) {
|
||||||
this.setExtraData("0");
|
this.setExtraData("0");
|
||||||
|
|
||||||
Room room = Emulator.getGameEnvironment().getRoomManager().getActiveRoomById(this.getRoomId());
|
Room room = this.getRoom();
|
||||||
if (room != null) {
|
if (room != null) {
|
||||||
room.updateItemState(this);
|
room.updateItemState(this);
|
||||||
}
|
}
|
||||||
|
@ -91,7 +91,6 @@ public class InteractionMultiHeight extends RoomItem {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (this.getBaseItem().allowSit() || unit.hasStatus(RoomUnitStatus.SIT)) {
|
if (this.getBaseItem().allowSit() || unit.hasStatus(RoomUnitStatus.SIT)) {
|
||||||
unit.setSitUpdate(true);
|
|
||||||
unit.setStatusUpdateNeeded(true);
|
unit.setStatusUpdateNeeded(true);
|
||||||
} else {
|
} else {
|
||||||
unit.setCurrentZ(unit.getCurrentPosition().getStackHeight());
|
unit.setCurrentZ(unit.getCurrentPosition().getStackHeight());
|
||||||
|
@ -74,7 +74,7 @@ public class InteractionMuteArea extends InteractionCustomValues {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean inSquare(RoomTile location) {
|
public boolean inSquare(RoomTile location) {
|
||||||
Room room = Emulator.getGameEnvironment().getRoomManager().getActiveRoomById(this.getRoomId());
|
Room room = this.getRoom();
|
||||||
|
|
||||||
if(!this.values.get("state").equals("1"))
|
if(!this.values.get("state").equals("1"))
|
||||||
return false;
|
return false;
|
||||||
|
@ -103,15 +103,15 @@ public class InteractionObstacle extends RoomItem implements ICycleable {
|
|||||||
if (roomUnit.getBodyRotation().getValue() % 2 == 0) {
|
if (roomUnit.getBodyRotation().getValue() % 2 == 0) {
|
||||||
if (this.getRotation() == 2) {
|
if (this.getRotation() == 2) {
|
||||||
if (roomUnit.getBodyRotation().equals(RoomRotation.WEST)) {
|
if (roomUnit.getBodyRotation().equals(RoomRotation.WEST)) {
|
||||||
((HorsePet) pet).getRider().getRoomUnit().setGoalLocation(room.getLayout().getTile((short) (roomUnit.getCurrentPosition().getX() - 3), roomUnit.getCurrentPosition().getY()));
|
((HorsePet) pet).getRider().getRoomUnit().walkTo(room.getLayout().getTile((short) (roomUnit.getCurrentPosition().getX() - 3), roomUnit.getCurrentPosition().getY()));
|
||||||
} else if (roomUnit.getBodyRotation().equals(RoomRotation.EAST)) {
|
} else if (roomUnit.getBodyRotation().equals(RoomRotation.EAST)) {
|
||||||
((HorsePet) pet).getRider().getRoomUnit().setGoalLocation(room.getLayout().getTile((short) (roomUnit.getCurrentPosition().getX() + 3), roomUnit.getCurrentPosition().getY()));
|
((HorsePet) pet).getRider().getRoomUnit().walkTo(room.getLayout().getTile((short) (roomUnit.getCurrentPosition().getX() + 3), roomUnit.getCurrentPosition().getY()));
|
||||||
}
|
}
|
||||||
} else if (this.getRotation() == 4) {
|
} else if (this.getRotation() == 4) {
|
||||||
if (roomUnit.getBodyRotation().equals(RoomRotation.NORTH)) {
|
if (roomUnit.getBodyRotation().equals(RoomRotation.NORTH)) {
|
||||||
((HorsePet) pet).getRider().getRoomUnit().setGoalLocation(room.getLayout().getTile(roomUnit.getCurrentPosition().getX(), (short) (roomUnit.getCurrentPosition().getY() - 3)));
|
((HorsePet) pet).getRider().getRoomUnit().walkTo(room.getLayout().getTile(roomUnit.getCurrentPosition().getX(), (short) (roomUnit.getCurrentPosition().getY() - 3)));
|
||||||
} else if (roomUnit.getBodyRotation().equals(RoomRotation.SOUTH)) {
|
} else if (roomUnit.getBodyRotation().equals(RoomRotation.SOUTH)) {
|
||||||
((HorsePet) pet).getRider().getRoomUnit().setGoalLocation(room.getLayout().getTile(roomUnit.getCurrentPosition().getX(), (short) (roomUnit.getCurrentPosition().getY() + 3)));
|
((HorsePet) pet).getRider().getRoomUnit().walkTo(room.getLayout().getTile(roomUnit.getCurrentPosition().getX(), (short) (roomUnit.getCurrentPosition().getY() + 3)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -191,12 +191,12 @@ public class InteractionObstacle extends RoomItem implements ICycleable {
|
|||||||
|
|
||||||
RoomTile tileInfront = room.getLayout().getTileInFront(roomUnit.getCurrentPosition(), roomUnit.getBodyRotation().getValue());
|
RoomTile tileInfront = room.getLayout().getTileInFront(roomUnit.getCurrentPosition(), roomUnit.getBodyRotation().getValue());
|
||||||
if(tileInfront.getState() != RoomTileState.INVALID && tileInfront.getState() != RoomTileState.BLOCKED && room.getRoomUnitManager().getRoomUnitsAt(tileInfront).size() == 0) {
|
if(tileInfront.getState() != RoomTileState.INVALID && tileInfront.getState() != RoomTileState.BLOCKED && room.getRoomUnitManager().getRoomUnitsAt(tileInfront).size() == 0) {
|
||||||
roomUnit.setGoalLocation(tileInfront);
|
roomUnit.walkTo(tileInfront);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
RoomTile tileBehind = room.getLayout().getTileInFront(roomUnit.getCurrentPosition(), Objects.requireNonNull(roomUnit.getBodyRotation().getOpposite()).getValue());
|
RoomTile tileBehind = room.getLayout().getTileInFront(roomUnit.getCurrentPosition(), Objects.requireNonNull(roomUnit.getBodyRotation().getOpposite()).getValue());
|
||||||
if(tileBehind.getState() != RoomTileState.INVALID && tileBehind.getState() != RoomTileState.BLOCKED && room.getRoomUnitManager().getRoomUnitsAt(tileBehind).size() == 0) {
|
if(tileBehind.getState() != RoomTileState.INVALID && tileBehind.getState() != RoomTileState.BLOCKED && room.getRoomUnitManager().getRoomUnitsAt(tileBehind).size() == 0) {
|
||||||
roomUnit.setGoalLocation(tileBehind);
|
roomUnit.walkTo(tileBehind);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -85,7 +85,7 @@ public class InteractionOneWayGate extends RoomItem {
|
|||||||
unit.setCanLeaveRoomByDoor(false);
|
unit.setCanLeaveRoomByDoor(false);
|
||||||
walkable = this.getBaseItem().allowWalk();
|
walkable = this.getBaseItem().allowWalk();
|
||||||
RoomTile tile = room.getLayout().getTileInFront(room.getLayout().getTile(this.getCurrentPosition().getX(), this.getCurrentPosition().getY()), this.getRotation() + 4);
|
RoomTile tile = room.getLayout().getTileInFront(room.getLayout().getTile(this.getCurrentPosition().getX(), this.getCurrentPosition().getY()), this.getRotation() + 4);
|
||||||
unit.setGoalLocation(tile);
|
unit.walkTo(tile);
|
||||||
Emulator.getThreading().run(new RoomUnitWalkToLocation(unit, tile, room, onFail, onFail));
|
Emulator.getThreading().run(new RoomUnitWalkToLocation(unit, tile, room, onFail, onFail));
|
||||||
|
|
||||||
Emulator.getThreading().run(() -> WiredHandler.handle(WiredTriggerType.WALKS_ON_FURNI, unit, room, new Object[]{this}), 500);
|
Emulator.getThreading().run(() -> WiredHandler.handle(WiredTriggerType.WALKS_ON_FURNI, unit, room, new Object[]{this}), 500);
|
||||||
@ -102,7 +102,7 @@ public class InteractionOneWayGate extends RoomItem {
|
|||||||
walkable = true;
|
walkable = true;
|
||||||
room.updateTile(currentLocation);
|
room.updateTile(currentLocation);
|
||||||
unit.addOverrideTile(currentLocation);
|
unit.addOverrideTile(currentLocation);
|
||||||
unit.setGoalLocation(currentLocation);
|
unit.walkTo(currentLocation);
|
||||||
Emulator.getThreading().run(new RoomUnitWalkToLocation(unit, currentLocation, room, onSuccess, onFail));
|
Emulator.getThreading().run(new RoomUnitWalkToLocation(unit, currentLocation, room, onSuccess, onFail));
|
||||||
room.sendComposer(new DiceValueMessageComposer(this.getId(), 1).compose());
|
room.sendComposer(new DiceValueMessageComposer(this.getId(), 1).compose());
|
||||||
|
|
||||||
|
@ -50,7 +50,7 @@ public class InteractionPuzzleBox extends RoomItem {
|
|||||||
if (rotation == null) {
|
if (rotation == null) {
|
||||||
RoomTile nearestTile = client.getHabbo().getRoomUnit().getClosestAdjacentTile(this.getCurrentPosition().getX(), this.getCurrentPosition().getY(), false);
|
RoomTile nearestTile = client.getHabbo().getRoomUnit().getClosestAdjacentTile(this.getCurrentPosition().getX(), this.getCurrentPosition().getY(), false);
|
||||||
|
|
||||||
if (nearestTile != null) client.getHabbo().getRoomUnit().setGoalLocation(nearestTile);
|
if (nearestTile != null) client.getHabbo().getRoomUnit().walkTo(nearestTile);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -77,9 +77,9 @@ public class InteractionPuzzleBox extends RoomItem {
|
|||||||
|
|
||||||
room.scheduledComposers.add(new FloorItemOnRollerComposer(this, null, tile, 0, room).compose());
|
room.scheduledComposers.add(new FloorItemOnRollerComposer(this, null, tile, 0, room).compose());
|
||||||
room.scheduledTasks.add(() -> {
|
room.scheduledTasks.add(() -> {
|
||||||
client.getHabbo().getRoomUnit().setGoalLocation(boxLocation);
|
client.getHabbo().getRoomUnit().walkTo(boxLocation);
|
||||||
|
|
||||||
room.scheduledTasks.add(() -> client.getHabbo().getRoomUnit().setGoalLocation(boxLocation));
|
room.scheduledTasks.add(() -> client.getHabbo().getRoomUnit().walkTo(boxLocation));
|
||||||
});
|
});
|
||||||
this.needsUpdate(true);
|
this.needsUpdate(true);
|
||||||
}
|
}
|
||||||
|
@ -58,7 +58,7 @@ public class InteractionRentableSpace extends RoomItem {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (this.getRoomId() > 0) {
|
if (this.getRoom() != null) {
|
||||||
Emulator.getThreading().run(new ClearRentedSpace(this, Emulator.getGameEnvironment().getRoomManager().getActiveRoomById(this.getRoomId())));
|
Emulator.getThreading().run(new ClearRentedSpace(this, Emulator.getGameEnvironment().getRoomManager().getActiveRoomById(this.getRoomId())));
|
||||||
this.renterId = 0;
|
this.renterId = 0;
|
||||||
}
|
}
|
||||||
@ -152,7 +152,7 @@ public class InteractionRentableSpace extends RoomItem {
|
|||||||
public void endRent() {
|
public void endRent() {
|
||||||
this.setEndTimestamp(0);
|
this.setEndTimestamp(0);
|
||||||
|
|
||||||
Room room = Emulator.getGameEnvironment().getRoomManager().getActiveRoomById(this.getRoomId());
|
Room room = this.getRoom();
|
||||||
|
|
||||||
if (room == null)
|
if (room == null)
|
||||||
return;
|
return;
|
||||||
|
@ -62,7 +62,7 @@ public class InteractionSwitch extends InteractionDefault {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
client.getHabbo().getRoomUnit().setGoalLocation(closestTile);
|
client.getHabbo().getRoomUnit().walkTo(closestTile);
|
||||||
Emulator.getThreading().run(new RoomUnitWalkToLocation(client.getHabbo().getRoomUnit(), closestTile, room, onSuccess, new ArrayList<>()));
|
Emulator.getThreading().run(new RoomUnitWalkToLocation(client.getHabbo().getRoomUnit(), closestTile, room, onSuccess, new ArrayList<>()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -100,7 +100,7 @@ public class InteractionTeleport extends RoomItem {
|
|||||||
this.roomUnitID = roomHabbo.getVirtualId();
|
this.roomUnitID = roomHabbo.getVirtualId();
|
||||||
this.setExtraData("1");
|
this.setExtraData("1");
|
||||||
room.updateItemState(this);
|
room.updateItemState(this);
|
||||||
roomHabbo.setGoalLocation(inFrontTile);
|
roomHabbo.walkTo(inFrontTile);
|
||||||
|
|
||||||
List<Runnable> onSuccess = new ArrayList<>();
|
List<Runnable> onSuccess = new ArrayList<>();
|
||||||
List<Runnable> onFail = new ArrayList<>();
|
List<Runnable> onFail = new ArrayList<>();
|
||||||
@ -127,7 +127,7 @@ public class InteractionTeleport extends RoomItem {
|
|||||||
|
|
||||||
room.updateTile(currentItemLocation);
|
room.updateTile(currentItemLocation);
|
||||||
roomHabbo.addOverrideTile(currentItemLocation);
|
roomHabbo.addOverrideTile(currentItemLocation);
|
||||||
roomHabbo.setGoalLocation(currentItemLocation);
|
roomHabbo.walkTo(currentItemLocation);
|
||||||
roomHabbo.setCanLeaveRoomByDoor(false);
|
roomHabbo.setCanLeaveRoomByDoor(false);
|
||||||
|
|
||||||
Emulator.getThreading().run(new RoomUnitWalkToLocation(roomHabbo, currentItemLocation, room, onSuccess, onFail));
|
Emulator.getThreading().run(new RoomUnitWalkToLocation(roomHabbo, currentItemLocation, room, onSuccess, onFail));
|
||||||
@ -138,7 +138,7 @@ public class InteractionTeleport extends RoomItem {
|
|||||||
|
|
||||||
onSuccess.add(() -> tryTeleport(client, room));
|
onSuccess.add(() -> tryTeleport(client, room));
|
||||||
|
|
||||||
roomHabbo.setGoalLocation(inFrontTile);
|
roomHabbo.walkTo(inFrontTile);
|
||||||
Emulator.getThreading().run(new RoomUnitWalkToLocation(roomHabbo, inFrontTile, room, onSuccess, onFail));
|
Emulator.getThreading().run(new RoomUnitWalkToLocation(roomHabbo, inFrontTile, room, onSuccess, onFail));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -204,13 +204,13 @@ public class InteractionTeleport extends RoomItem {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
RoomUnit unit = habbo.getRoomUnit();
|
RoomHabbo roomHabbo = habbo.getRoomUnit();
|
||||||
|
|
||||||
if (unit == null) {
|
if (roomHabbo == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return habbo.getHabboInfo().getRiding() == null;
|
return !roomHabbo.isRiding();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void startTeleport(Room room, Habbo habbo) {
|
public void startTeleport(Room room, Habbo habbo) {
|
||||||
|
@ -38,7 +38,7 @@ public class InteractionTeleportTile extends InteractionTeleport {
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
if (!habbo.getRoomUnit().isTeleporting()) {
|
if (!habbo.getRoomUnit().isTeleporting()) {
|
||||||
habbo.getRoomUnit().setGoalLocation(habbo.getRoomUnit().getCurrentPosition());
|
habbo.getRoomUnit().walkTo(habbo.getRoomUnit().getCurrentPosition());
|
||||||
this.startTeleport(room, habbo, 1000);
|
this.startTeleport(room, habbo, 1000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -143,7 +143,7 @@ public class InteractionVendingMachine extends RoomItem {
|
|||||||
|
|
||||||
onSuccess.add(() -> tryInteract(client, room, unit));
|
onSuccess.add(() -> tryInteract(client, room, unit));
|
||||||
|
|
||||||
unit.setGoalLocation(tileToWalkTo);
|
unit.walkTo(tileToWalkTo);
|
||||||
Emulator.getThreading().run(new RoomUnitWalkToLocation(unit, tileToWalkTo, room, onSuccess, onFail));
|
Emulator.getThreading().run(new RoomUnitWalkToLocation(unit, tileToWalkTo, room, onSuccess, onFail));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -321,11 +321,6 @@ public class InteractionGameTimer extends RoomItem implements Runnable {
|
|||||||
this.needsUpdate(true);
|
this.needsUpdate(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getDatabaseExtraData() {
|
|
||||||
return this.getExtraData();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean allowWiredResetState() {
|
public boolean allowWiredResetState() {
|
||||||
return true;
|
return true;
|
||||||
|
@ -64,7 +64,7 @@ public class InteractionBattleBanzaiTeleporter extends RoomItem {
|
|||||||
this.setExtraData("1");
|
this.setExtraData("1");
|
||||||
room.updateItemState(this);
|
room.updateItemState(this);
|
||||||
roomUnit.removeStatus(RoomUnitStatus.MOVE);
|
roomUnit.removeStatus(RoomUnitStatus.MOVE);
|
||||||
roomUnit.setGoalLocation(roomUnit.getCurrentPosition());
|
roomUnit.walkTo(roomUnit.getCurrentPosition());
|
||||||
roomUnit.setCanWalk(false);
|
roomUnit.setCanWalk(false);
|
||||||
Emulator.getThreading().run(new BanzaiRandomTeleport(this, target, roomUnit, room), 500);
|
Emulator.getThreading().run(new BanzaiRandomTeleport(this, target, roomUnit, room), 500);
|
||||||
}
|
}
|
||||||
|
@ -72,7 +72,7 @@ public class InteractionNest extends RoomItem {
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
pet.setTask(PetTasks.NEST);
|
pet.setTask(PetTasks.NEST);
|
||||||
pet.getRoomUnit().setGoalLocation(room.getLayout().getTile(this.getCurrentPosition().getX(), this.getCurrentPosition().getY()));
|
pet.getRoomUnit().walkTo(room.getLayout().getTile(this.getCurrentPosition().getX(), this.getCurrentPosition().getY()));
|
||||||
pet.getRoomUnit().clearStatuses();
|
pet.getRoomUnit().clearStatuses();
|
||||||
pet.getRoomUnit().removeStatus(RoomUnitStatus.MOVE);
|
pet.getRoomUnit().removeStatus(RoomUnitStatus.MOVE);
|
||||||
pet.getRoomUnit().addStatus(RoomUnitStatus.LAY, room.getStackHeight(this.getCurrentPosition().getX(), this.getCurrentPosition().getY(), false) + "");
|
pet.getRoomUnit().addStatus(RoomUnitStatus.LAY, room.getStackHeight(this.getCurrentPosition().getX(), this.getCurrentPosition().getY(), false) + "");
|
||||||
|
@ -58,7 +58,7 @@ public class InteractionPetDrink extends InteractionDefault {
|
|||||||
List<Runnable> onSuccess = new ArrayList<>();
|
List<Runnable> onSuccess = new ArrayList<>();
|
||||||
onSuccess.add(() -> this.change(room, this.getBaseItem().getStateCount() - 1));
|
onSuccess.add(() -> this.change(room, this.getBaseItem().getStateCount() - 1));
|
||||||
|
|
||||||
client.getHabbo().getRoomUnit().setGoalLocation(closestTile);
|
client.getHabbo().getRoomUnit().walkTo(closestTile);
|
||||||
Emulator.getThreading().run(new RoomUnitWalkToLocation(client.getHabbo().getRoomUnit(), closestTile, room, onSuccess, new ArrayList<>()));
|
Emulator.getThreading().run(new RoomUnitWalkToLocation(client.getHabbo().getRoomUnit(), closestTile, room, onSuccess, new ArrayList<>()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -76,7 +76,7 @@ public class InteractionPetDrink extends InteractionDefault {
|
|||||||
|
|
||||||
if (pet != null && pet.getPetData().haveDrinkItem(this) && pet.levelThirst >= 35) {
|
if (pet != null && pet.getPetData().haveDrinkItem(this) && pet.levelThirst >= 35) {
|
||||||
pet.clearPosture();
|
pet.clearPosture();
|
||||||
pet.getRoomUnit().setGoalLocation(room.getLayout().getTile(this.getCurrentPosition().getX(), this.getCurrentPosition().getY()));
|
pet.getRoomUnit().walkTo(room.getLayout().getTile(this.getCurrentPosition().getX(), this.getCurrentPosition().getY()));
|
||||||
pet.getRoomUnit().setRotation(RoomRotation.values()[this.getRotation()]);
|
pet.getRoomUnit().setRotation(RoomRotation.values()[this.getRotation()]);
|
||||||
pet.getRoomUnit().clearStatuses();
|
pet.getRoomUnit().clearStatuses();
|
||||||
pet.getRoomUnit().addStatus(RoomUnitStatus.EAT, pet.getRoomUnit().getCurrentPosition().getStackHeight() + "");
|
pet.getRoomUnit().addStatus(RoomUnitStatus.EAT, pet.getRoomUnit().getCurrentPosition().getStackHeight() + "");
|
||||||
|
@ -38,7 +38,7 @@ public class InteractionPetFood extends InteractionDefault {
|
|||||||
if (pet.getPetData().haveFoodItem(this)) {
|
if (pet.getPetData().haveFoodItem(this)) {
|
||||||
if (pet.levelHunger >= 35) {
|
if (pet.levelHunger >= 35) {
|
||||||
pet.setTask(PetTasks.EAT);
|
pet.setTask(PetTasks.EAT);
|
||||||
pet.getRoomUnit().setGoalLocation(room.getLayout().getTile(this.getCurrentPosition().getX(), this.getCurrentPosition().getY()));
|
pet.getRoomUnit().walkTo(room.getLayout().getTile(this.getCurrentPosition().getX(), this.getCurrentPosition().getY()));
|
||||||
pet.getRoomUnit().setRotation(RoomRotation.values()[this.getRotation()]);
|
pet.getRoomUnit().setRotation(RoomRotation.values()[this.getRotation()]);
|
||||||
pet.getRoomUnit().clearStatuses();
|
pet.getRoomUnit().clearStatuses();
|
||||||
pet.getRoomUnit().removeStatus(RoomUnitStatus.MOVE);
|
pet.getRoomUnit().removeStatus(RoomUnitStatus.MOVE);
|
||||||
|
@ -65,7 +65,7 @@ public class InteractionPetToy extends InteractionDefault {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pet.setTask(PetTasks.PLAY);
|
pet.setTask(PetTasks.PLAY);
|
||||||
pet.getRoomUnit().setGoalLocation(room.getLayout().getTile(this.getCurrentPosition().getX(), this.getCurrentPosition().getY()));
|
pet.getRoomUnit().walkTo(room.getLayout().getTile(this.getCurrentPosition().getX(), this.getCurrentPosition().getY()));
|
||||||
pet.getRoomUnit().setRotation(RoomRotation.values()[this.getRotation()]);
|
pet.getRoomUnit().setRotation(RoomRotation.values()[this.getRotation()]);
|
||||||
pet.getRoomUnit().clearStatuses();
|
pet.getRoomUnit().clearStatuses();
|
||||||
pet.getRoomUnit().addStatus(RoomUnitStatus.PLAY, pet.getRoomUnit().getCurrentPosition().getStackHeight() + "");
|
pet.getRoomUnit().addStatus(RoomUnitStatus.PLAY, pet.getRoomUnit().getCurrentPosition().getStackHeight() + "");
|
||||||
|
@ -69,7 +69,7 @@ public class InteractionPetTrampoline extends InteractionDefault {
|
|||||||
pet.getRoomUnit().addStatus(RoomUnitStatus.JUMP, "");
|
pet.getRoomUnit().addStatus(RoomUnitStatus.JUMP, "");
|
||||||
Emulator.getThreading().run(() -> {
|
Emulator.getThreading().run(() -> {
|
||||||
new PetClearPosture(pet, RoomUnitStatus.JUMP, null, false);
|
new PetClearPosture(pet, RoomUnitStatus.JUMP, null, false);
|
||||||
pet.getRoomUnit().setGoalLocation(room.getRandomWalkableTile());
|
pet.getRoomUnit().walkTo(room.getRandomWalkableTile());
|
||||||
this.setExtraData("0");
|
this.setExtraData("0");
|
||||||
room.updateItemState(this);
|
room.updateItemState(this);
|
||||||
}, 4000);
|
}, 4000);
|
||||||
|
@ -58,7 +58,7 @@ public class WiredEffectBotGiveHandItem extends InteractionWiredEffect {
|
|||||||
RoomTile tile = bot.getRoomUnit().getClosestAdjacentTile(roomAvatar.getCurrentPosition().getX(), roomAvatar.getCurrentPosition().getY(), true);
|
RoomTile tile = bot.getRoomUnit().getClosestAdjacentTile(roomAvatar.getCurrentPosition().getX(), roomAvatar.getCurrentPosition().getY(), true);
|
||||||
|
|
||||||
if(tile != null) {
|
if(tile != null) {
|
||||||
bot.getRoomUnit().setGoalLocation(tile);
|
bot.getRoomUnit().walkTo(tile);
|
||||||
}
|
}
|
||||||
|
|
||||||
Emulator.getThreading().run(new RoomUnitGiveHanditem(bot.getRoomUnit(), room, itemId));
|
Emulator.getThreading().run(new RoomUnitGiveHanditem(bot.getRoomUnit(), room, itemId));
|
||||||
|
@ -56,7 +56,7 @@ public class WiredEffectBotWalkToFurni extends InteractionWiredEffect {
|
|||||||
if (item.getRoomId() != 0) {
|
if (item.getRoomId() != 0) {
|
||||||
Room room1 = bot.getRoom();
|
Room room1 = bot.getRoom();
|
||||||
if (item.getRoomId() == room1.getRoomInfo().getId()) {
|
if (item.getRoomId() == room1.getRoomInfo().getId()) {
|
||||||
bot.getRoomUnit().setGoalLocation(room.getLayout().getTile(item.getCurrentPosition().getX(), item.getCurrentPosition().getY()));
|
bot.getRoomUnit().walkTo(room.getLayout().getTile(item.getCurrentPosition().getX(), item.getCurrentPosition().getY()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,7 @@ import com.eu.habbo.database.DatabaseConstants;
|
|||||||
import com.eu.habbo.habbohotel.achievements.AchievementManager;
|
import com.eu.habbo.habbohotel.achievements.AchievementManager;
|
||||||
import com.eu.habbo.habbohotel.rooms.*;
|
import com.eu.habbo.habbohotel.rooms.*;
|
||||||
import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem;
|
import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem;
|
||||||
|
import com.eu.habbo.habbohotel.rooms.entities.units.types.RoomPet;
|
||||||
import com.eu.habbo.habbohotel.units.Unit;
|
import com.eu.habbo.habbohotel.units.Unit;
|
||||||
import com.eu.habbo.habbohotel.users.Habbo;
|
import com.eu.habbo.habbohotel.users.Habbo;
|
||||||
import com.eu.habbo.messages.ISerialize;
|
import com.eu.habbo.messages.ISerialize;
|
||||||
@ -127,6 +128,10 @@ public class Pet extends Unit implements ISerialize, Runnable {
|
|||||||
@Getter
|
@Getter
|
||||||
private boolean muted = false;
|
private boolean muted = false;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
private RoomPet roomUnit;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new pet using the given result set, which should contain data retrieved from a
|
* Creates a new pet using the given result set, which should contain data retrieved from a
|
||||||
* database.
|
* database.
|
||||||
@ -359,7 +364,7 @@ public class Pet extends Unit implements ISerialize, Runnable {
|
|||||||
RoomTile tile = this.room.getRandomWalkableTile();
|
RoomTile tile = this.room.getRandomWalkableTile();
|
||||||
|
|
||||||
if (tile != null) {
|
if (tile != null) {
|
||||||
this.getRoomUnit().setGoalLocation(tile);
|
this.getRoomUnit().walkTo(tile);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -376,7 +381,7 @@ public class Pet extends Unit implements ISerialize, Runnable {
|
|||||||
if (this.energy == PetManager.maxEnergy(this.level)) {
|
if (this.energy == PetManager.maxEnergy(this.level)) {
|
||||||
this.getRoomUnit().removeStatus(RoomUnitStatus.LAY);
|
this.getRoomUnit().removeStatus(RoomUnitStatus.LAY);
|
||||||
this.getRoomUnit().setCanWalk(true);
|
this.getRoomUnit().setCanWalk(true);
|
||||||
this.getRoomUnit().setGoalLocation(this.room.getRandomWalkableTile());
|
this.getRoomUnit().walkTo(this.room.getRandomWalkableTile());
|
||||||
this.task = null;
|
this.task = null;
|
||||||
this.getRoomUnit().addStatus(RoomUnitStatus.GESTURE, PetGestures.ENERGY.getKey());
|
this.getRoomUnit().addStatus(RoomUnitStatus.GESTURE, PetGestures.ENERGY.getKey());
|
||||||
this.gestureTickTimeout = currentTime;
|
this.gestureTickTimeout = currentTime;
|
||||||
@ -578,7 +583,7 @@ public class Pet extends Unit implements ISerialize, Runnable {
|
|||||||
RoomItem item = this.petData.randomNest(this.room.getRoomSpecialTypes().getNests());
|
RoomItem item = this.petData.randomNest(this.room.getRoomSpecialTypes().getNests());
|
||||||
this.getRoomUnit().setCanWalk(true);
|
this.getRoomUnit().setCanWalk(true);
|
||||||
if (item != null) {
|
if (item != null) {
|
||||||
this.getRoomUnit().setGoalLocation(this.room.getLayout().getTile(item.getCurrentPosition().getX(), item.getCurrentPosition().getY()));
|
this.getRoomUnit().walkTo(this.room.getLayout().getTile(item.getCurrentPosition().getX(), item.getCurrentPosition().getY()));
|
||||||
} else {
|
} else {
|
||||||
if(this instanceof HorsePet horsePet && horsePet.hasSaddle()) {
|
if(this instanceof HorsePet horsePet && horsePet.hasSaddle()) {
|
||||||
return;
|
return;
|
||||||
@ -603,7 +608,7 @@ public class Pet extends Unit implements ISerialize, Runnable {
|
|||||||
} catch (Exception ignored) {
|
} catch (Exception ignored) {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
this.getRoomUnit().setGoalLocation(this.room.getLayout().getTile(item.getCurrentPosition().getX(), item.getCurrentPosition().getY()));
|
this.getRoomUnit().walkTo(this.room.getLayout().getTile(item.getCurrentPosition().getX(), item.getCurrentPosition().getY()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return item != null;
|
return item != null;
|
||||||
@ -616,7 +621,7 @@ public class Pet extends Unit implements ISerialize, Runnable {
|
|||||||
RoomItem item = this.petData.randomFoodItem(this.room.getRoomSpecialTypes().getPetFoods());
|
RoomItem item = this.petData.randomFoodItem(this.room.getRoomSpecialTypes().getPetFoods());
|
||||||
if (item != null) {
|
if (item != null) {
|
||||||
this.getRoomUnit().setCanWalk(true);
|
this.getRoomUnit().setCanWalk(true);
|
||||||
this.getRoomUnit().setGoalLocation(this.room.getLayout().getTile(item.getCurrentPosition().getX(), item.getCurrentPosition().getY()));
|
this.getRoomUnit().walkTo(this.room.getLayout().getTile(item.getCurrentPosition().getX(), item.getCurrentPosition().getY()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -636,7 +641,7 @@ public class Pet extends Unit implements ISerialize, Runnable {
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
this.getRoomUnit().setGoalLocation(this.room.getLayout().getTile(item.getCurrentPosition().getX(), item.getCurrentPosition().getY()));
|
this.getRoomUnit().walkTo(this.room.getLayout().getTile(item.getCurrentPosition().getX(), item.getCurrentPosition().getY()));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -663,7 +668,7 @@ public class Pet extends Unit implements ISerialize, Runnable {
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
this.getRoomUnit().setGoalLocation(this.room.getLayout().getTile(item.getCurrentPosition().getX(), item.getCurrentPosition().getY()));
|
this.getRoomUnit().walkTo(this.room.getLayout().getTile(item.getCurrentPosition().getX(), item.getCurrentPosition().getY()));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@ -768,7 +773,7 @@ public class Pet extends Unit implements ISerialize, Runnable {
|
|||||||
*/
|
*/
|
||||||
public void freeCommand() {
|
public void freeCommand() {
|
||||||
this.task = null;
|
this.task = null;
|
||||||
this.getRoomUnit().setGoalLocation(this.getRoomUnit().getCurrentPosition());
|
this.getRoomUnit().walkTo(this.getRoomUnit().getCurrentPosition());
|
||||||
this.getRoomUnit().clearStatuses();
|
this.getRoomUnit().clearStatuses();
|
||||||
this.getRoomUnit().setCanWalk(true);
|
this.getRoomUnit().setCanWalk(true);
|
||||||
this.say(this.petData.randomVocal(PetVocalsType.GENERIC_NEUTRAL));
|
this.say(this.petData.randomVocal(PetVocalsType.GENERIC_NEUTRAL));
|
||||||
|
@ -59,7 +59,7 @@ public class PetCommand implements Comparable<PetCommand> {
|
|||||||
if (this.action != null && pet.energy > this.energyCost && pet.happiness > this.happinessCost && Emulator.getRandom().nextInt((pet.level - this.level <= 0 ? 2 : pet.level - this.level) + 2) == 0) {
|
if (this.action != null && pet.energy > this.energyCost && pet.happiness > this.happinessCost && Emulator.getRandom().nextInt((pet.level - this.level <= 0 ? 2 : pet.level - this.level) + 2) == 0) {
|
||||||
if (this.action.petTask != pet.getTask()) {
|
if (this.action.petTask != pet.getTask()) {
|
||||||
if (this.action.stopsPetWalking) {
|
if (this.action.stopsPetWalking) {
|
||||||
pet.getRoomUnit().setGoalLocation(pet.getRoomUnit().getCurrentPosition());
|
pet.getRoomUnit().walkTo(pet.getRoomUnit().getCurrentPosition());
|
||||||
}
|
}
|
||||||
if (this.action.apply(pet, habbo, data)) {
|
if (this.action.apply(pet, habbo, data)) {
|
||||||
for (RoomUnitStatus status : this.action.statusToRemove) {
|
for (RoomUnitStatus status : this.action.statusToRemove) {
|
||||||
|
@ -444,6 +444,7 @@ public class PetManager {
|
|||||||
pet.setUserId(habbo.getHabboInfo().getId());
|
pet.setUserId(habbo.getHabboInfo().getId());
|
||||||
pet.setRoom(room);
|
pet.setRoom(room);
|
||||||
pet.setRoomUnit(new RoomPet());
|
pet.setRoomUnit(new RoomPet());
|
||||||
|
pet.getRoomUnit().setUnit(pet);
|
||||||
pet.getRoomUnit().setRoom(room);
|
pet.getRoomUnit().setRoom(room);
|
||||||
pet.setNeedsUpdate(true);
|
pet.setNeedsUpdate(true);
|
||||||
pet.run();
|
pet.run();
|
||||||
@ -463,6 +464,7 @@ public class PetManager {
|
|||||||
pet.setUserId(habbo.getHabboInfo().getId());
|
pet.setUserId(habbo.getHabboInfo().getId());
|
||||||
pet.setRoom(room);
|
pet.setRoom(room);
|
||||||
pet.setRoomUnit(new RoomPet());
|
pet.setRoomUnit(new RoomPet());
|
||||||
|
pet.getRoomUnit().setUnit(pet);
|
||||||
pet.getRoomUnit().setRoom(room);
|
pet.getRoomUnit().setRoom(room);
|
||||||
pet.setNeedsUpdate(true);
|
pet.setNeedsUpdate(true);
|
||||||
pet.run();
|
pet.run();
|
||||||
@ -483,6 +485,7 @@ public class PetManager {
|
|||||||
pet.setUserId(habbo.getHabboInfo().getId());
|
pet.setUserId(habbo.getHabboInfo().getId());
|
||||||
pet.setRoom(room);
|
pet.setRoom(room);
|
||||||
pet.setRoomUnit(new RoomPet());
|
pet.setRoomUnit(new RoomPet());
|
||||||
|
pet.getRoomUnit().setUnit(pet);
|
||||||
pet.getRoomUnit().setRoom(room);
|
pet.getRoomUnit().setRoom(room);
|
||||||
pet.setNeedsUpdate(true);
|
pet.setNeedsUpdate(true);
|
||||||
pet.run();
|
pet.run();
|
||||||
|
@ -25,7 +25,7 @@ public class ActionBreed extends PetAction {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (nest != null) {
|
if (nest != null) {
|
||||||
pet.getRoomUnit().setGoalLocation(pet.getRoom().getLayout().getTile(nest.getCurrentPosition().getX(), nest.getCurrentPosition().getY()));
|
pet.getRoomUnit().walkTo(pet.getRoom().getLayout().getTile(nest.getCurrentPosition().getX(), nest.getCurrentPosition().getY()));
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
|
@ -24,7 +24,7 @@ public class ActionDip extends PetAction {
|
|||||||
|
|
||||||
RoomItem waterPatch = (RoomItem) waterItems.toArray()[Emulator.getRandom().nextInt(waterItems.size())];
|
RoomItem waterPatch = (RoomItem) waterItems.toArray()[Emulator.getRandom().nextInt(waterItems.size())];
|
||||||
|
|
||||||
pet.getRoomUnit().setGoalLocation(pet.getRoom().getLayout().getTile(waterPatch.getCurrentPosition().getX(), waterPatch.getCurrentPosition().getY()));
|
pet.getRoomUnit().walkTo(pet.getRoom().getLayout().getTile(waterPatch.getCurrentPosition().getX(), waterPatch.getCurrentPosition().getY()));
|
||||||
|
|
||||||
if (pet.getHappiness() > 70) {
|
if (pet.getHappiness() > 70) {
|
||||||
pet.say(pet.getPetData().randomVocal(PetVocalsType.PLAYFUL));
|
pet.say(pet.getPetData().randomVocal(PetVocalsType.PLAYFUL));
|
||||||
|
@ -16,7 +16,7 @@ public class ActionHere extends PetAction {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(Pet pet, Habbo habbo, String[] data) {
|
public boolean apply(Pet pet, Habbo habbo, String[] data) {
|
||||||
pet.getRoomUnit().setGoalLocation(pet.getRoom().getLayout().getTileInFront(habbo.getRoomUnit().getCurrentPosition(), habbo.getRoomUnit().getBodyRotation().getValue()));
|
pet.getRoomUnit().walkTo(pet.getRoom().getLayout().getTileInFront(habbo.getRoomUnit().getCurrentPosition(), habbo.getRoomUnit().getBodyRotation().getValue()));
|
||||||
pet.getRoomUnit().setCanWalk(true);
|
pet.getRoomUnit().setCanWalk(true);
|
||||||
|
|
||||||
if (pet.getHappiness() > 50) {
|
if (pet.getHappiness() > 50) {
|
||||||
|
@ -13,7 +13,7 @@ public class ActionMoveForward extends PetAction {
|
|||||||
@Override
|
@Override
|
||||||
public boolean apply(Pet pet, Habbo habbo, String[] data) {
|
public boolean apply(Pet pet, Habbo habbo, String[] data) {
|
||||||
|
|
||||||
pet.getRoomUnit().setGoalLocation(pet.getRoom().getLayout().getTileInFront(pet.getRoomUnit().getCurrentPosition(), pet.getRoomUnit().getBodyRotation().getValue()));
|
pet.getRoomUnit().walkTo(pet.getRoom().getLayout().getTileInFront(pet.getRoomUnit().getCurrentPosition(), pet.getRoomUnit().getBodyRotation().getValue()));
|
||||||
pet.getRoomUnit().setCanWalk(true);
|
pet.getRoomUnit().setCanWalk(true);
|
||||||
|
|
||||||
pet.say(pet.getPetData().randomVocal(PetVocalsType.GENERIC_NEUTRAL));
|
pet.say(pet.getPetData().randomVocal(PetVocalsType.GENERIC_NEUTRAL));
|
||||||
|
@ -32,7 +32,7 @@ public class ActionPlayFootball extends PetAction {
|
|||||||
if(foundBall == null)
|
if(foundBall == null)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
pet.getRoomUnit().setGoalLocation(room.getLayout().getTile(foundBall.getCurrentPosition().getX(), foundBall.getCurrentPosition().getY()));
|
pet.getRoomUnit().walkTo(room.getLayout().getTile(foundBall.getCurrentPosition().getX(), foundBall.getCurrentPosition().getY()));
|
||||||
|
|
||||||
if (pet.getHappiness() > 75)
|
if (pet.getHappiness() > 75)
|
||||||
pet.say(pet.getPetData().randomVocal(PetVocalsType.PLAYFUL));
|
pet.say(pet.getPetData().randomVocal(PetVocalsType.PLAYFUL));
|
||||||
|
@ -401,6 +401,7 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Improve this
|
||||||
for (Habbo habbo : habbos) {
|
for (Habbo habbo : habbos) {
|
||||||
double z = habbo.getRoomUnit().getCurrentPosition().getStackHeight();
|
double z = habbo.getRoomUnit().getCurrentPosition().getStackHeight();
|
||||||
|
|
||||||
@ -413,12 +414,16 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (item != null && (item.getBaseItem().allowSit() || item.getBaseItem().allowLay())) {
|
if (item != null && (item.getBaseItem().allowSit() || item.getBaseItem().allowLay())) {
|
||||||
|
if(item.getBaseItem().allowSit()) {
|
||||||
|
habbo.getRoomUnit().addStatus(RoomUnitStatus.SIT, String.valueOf(Item.getCurrentHeight(item)));
|
||||||
|
} else if(item.getBaseItem().allowLay()) {
|
||||||
|
habbo.getRoomUnit().addStatus(RoomUnitStatus.LAY, String.valueOf(Item.getCurrentHeight(item)));
|
||||||
|
}
|
||||||
|
|
||||||
habbo.getRoomUnit().setCurrentZ(item.getCurrentZ());
|
habbo.getRoomUnit().setCurrentZ(item.getCurrentZ());
|
||||||
habbo.getRoomUnit().setPreviousLocationZ(item.getCurrentZ());
|
|
||||||
habbo.getRoomUnit().setRotation(RoomRotation.fromValue(item.getRotation()));
|
habbo.getRoomUnit().setRotation(RoomRotation.fromValue(item.getRotation()));
|
||||||
} else {
|
} else {
|
||||||
habbo.getRoomUnit().setCurrentZ(z);
|
habbo.getRoomUnit().setCurrentZ(z);
|
||||||
habbo.getRoomUnit().setPreviousLocationZ(z);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -437,7 +442,6 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
|
|||||||
if (topItem != null) {
|
if (topItem != null) {
|
||||||
if (topItem.getBaseItem().allowSit()) {
|
if (topItem.getBaseItem().allowSit()) {
|
||||||
bot.getRoomUnit().setCurrentZ(topItem.getCurrentZ());
|
bot.getRoomUnit().setCurrentZ(topItem.getCurrentZ());
|
||||||
bot.getRoomUnit().setPreviousLocationZ(topItem.getCurrentZ());
|
|
||||||
bot.getRoomUnit().setRotation(RoomRotation.fromValue(topItem.getRotation()));
|
bot.getRoomUnit().setRotation(RoomRotation.fromValue(topItem.getRotation()));
|
||||||
} else {
|
} else {
|
||||||
bot.getRoomUnit().setCurrentZ(topItem.getCurrentZ() + Item.getCurrentHeight(topItem));
|
bot.getRoomUnit().setCurrentZ(topItem.getCurrentZ() + Item.getCurrentHeight(topItem));
|
||||||
@ -448,7 +452,6 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
bot.getRoomUnit().setCurrentZ(bot.getRoomUnit().getCurrentPosition().getStackHeight());
|
bot.getRoomUnit().setCurrentZ(bot.getRoomUnit().getCurrentPosition().getStackHeight());
|
||||||
bot.getRoomUnit().setPreviousLocationZ(bot.getRoomUnit().getCurrentPosition().getStackHeight());
|
|
||||||
}
|
}
|
||||||
roomUnits.add(bot.getRoomUnit());
|
roomUnits.add(bot.getRoomUnit());
|
||||||
});
|
});
|
||||||
@ -590,7 +593,7 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
|
|||||||
habbo.getHabboStats().getChatCounter().decrementAndGet();
|
habbo.getHabboStats().getChatCounter().decrementAndGet();
|
||||||
}
|
}
|
||||||
|
|
||||||
habbo.getRoomUnit().cycle(this);
|
habbo.getRoomUnit().cycle();
|
||||||
|
|
||||||
if(habbo.getRoomUnit().isStatusUpdateNeeded()) {
|
if(habbo.getRoomUnit().isStatusUpdateNeeded()) {
|
||||||
habbo.getRoomUnit().setStatusUpdateNeeded(false);
|
habbo.getRoomUnit().setStatusUpdateNeeded(false);
|
||||||
@ -622,7 +625,7 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
bot.getRoomUnit().cycle(this);
|
bot.getRoomUnit().cycle();
|
||||||
|
|
||||||
if(bot.getRoomUnit().isStatusUpdateNeeded()) {
|
if(bot.getRoomUnit().isStatusUpdateNeeded()) {
|
||||||
bot.getRoomUnit().setStatusUpdateNeeded(false);
|
bot.getRoomUnit().setStatusUpdateNeeded(false);
|
||||||
@ -647,7 +650,7 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
pet.getRoomUnit().cycle(this);
|
pet.getRoomUnit().cycle();
|
||||||
pet.cycle();
|
pet.cycle();
|
||||||
|
|
||||||
if(pet.getRoomUnit().isStatusUpdateNeeded()) {
|
if(pet.getRoomUnit().isStatusUpdateNeeded()) {
|
||||||
@ -804,9 +807,9 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
|
|||||||
if (roomUnit.getRoomUnitType() == RoomUnitType.HABBO) {
|
if (roomUnit.getRoomUnitType() == RoomUnitType.HABBO) {
|
||||||
Habbo rollingHabbo = this.getRoomUnitManager().getHabboByRoomUnit(roomUnit);
|
Habbo rollingHabbo = this.getRoomUnitManager().getHabboByRoomUnit(roomUnit);
|
||||||
if (rollingHabbo != null && rollingHabbo.getHabboInfo() != null) {
|
if (rollingHabbo != null && rollingHabbo.getHabboInfo() != null) {
|
||||||
RideablePet riding = rollingHabbo.getHabboInfo().getRiding();
|
RideablePet ridingPet = rollingHabbo.getRoomUnit().getRidingPet();
|
||||||
if (riding != null) {
|
if (ridingPet != null) {
|
||||||
RoomUnit ridingUnit = riding.getRoomUnit();
|
RoomUnit ridingUnit = ridingPet.getRoomUnit();
|
||||||
newZ = ridingUnit.getCurrentZ() + zOffset;
|
newZ = ridingUnit.getCurrentZ() + zOffset;
|
||||||
rolledUnitIds.add(ridingUnit.getVirtualId());
|
rolledUnitIds.add(ridingUnit.getVirtualId());
|
||||||
updatedUnit.remove(ridingUnit);
|
updatedUnit.remove(ridingUnit);
|
||||||
@ -836,10 +839,6 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
|
|||||||
}, this.roomInfo.getRollerSpeed() == 0 ? 250 : InteractionRoller.DELAY);
|
}, this.roomInfo.getRollerSpeed() == 0 ? 250 : InteractionRoller.DELAY);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (roomUnit.hasStatus(RoomUnitStatus.SIT)) {
|
|
||||||
roomUnit.setSitUpdate(true);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1261,7 +1260,7 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
habbo.getRoomUnit().setKicked(true);
|
habbo.getRoomUnit().setKicked(true);
|
||||||
habbo.getRoomUnit().setGoalLocation(this.layout.getDoorTile());
|
habbo.getRoomUnit().walkTo(this.layout.getDoorTile());
|
||||||
|
|
||||||
if (habbo.getRoomUnit().getPath() == null || habbo.getRoomUnit().getPath().size() <= 1 || this.roomInfo.isPublicRoom()) {
|
if (habbo.getRoomUnit().getPath() == null || habbo.getRoomUnit().getPath().size() <= 1 || this.roomInfo.isPublicRoom()) {
|
||||||
habbo.getRoomUnit().setCanWalk(true);
|
habbo.getRoomUnit().setCanWalk(true);
|
||||||
@ -1318,9 +1317,8 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
roomUnit.setLocation(tile);
|
roomUnit.setLocation(tile);
|
||||||
roomUnit.setGoalLocation(tile);
|
roomUnit.walkTo(tile);
|
||||||
roomUnit.setCurrentZ(z);
|
roomUnit.setCurrentZ(z);
|
||||||
roomUnit.setPreviousLocationZ(z);
|
|
||||||
this.updateRoomUnit(roomUnit);
|
this.updateRoomUnit(roomUnit);
|
||||||
|
|
||||||
|
|
||||||
@ -1351,8 +1349,6 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void habboEntered(Habbo habbo) {
|
public void habboEntered(Habbo habbo) {
|
||||||
habbo.getRoomUnit().setAnimateWalk(false);
|
|
||||||
|
|
||||||
synchronized (this.roomUnitManager.getCurrentBots()) {
|
synchronized (this.roomUnitManager.getCurrentBots()) {
|
||||||
if (habbo.getHabboInfo().getId() != this.roomInfo.getOwnerInfo().getId())
|
if (habbo.getHabboInfo().getId() != this.roomInfo.getOwnerInfo().getId())
|
||||||
return;
|
return;
|
||||||
@ -1744,6 +1740,10 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
|
|||||||
return this.getStackHeight(x, y, calculateHeightmap, null);
|
return this.getStackHeight(x, y, calculateHeightmap, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean canSitOrLayAt(RoomTile tile) {
|
||||||
|
return this.canSitOrLayAt(tile.getX(), tile.getY());
|
||||||
|
}
|
||||||
|
|
||||||
public boolean canSitOrLayAt(int x, int y) {
|
public boolean canSitOrLayAt(int x, int y) {
|
||||||
RoomTile tile = this.layout.getTile((short) x, (short) y);
|
RoomTile tile = this.layout.getTile((short) x, (short) y);
|
||||||
|
|
||||||
|
@ -128,7 +128,9 @@ public class RoomItemManager {
|
|||||||
try {
|
try {
|
||||||
this.currentItems.put(item.getId(), item);
|
this.currentItems.put(item.getId(), item);
|
||||||
this.sortItem(item);
|
this.sortItem(item);
|
||||||
|
//Deprecated
|
||||||
item.setRoomId(this.room.getRoomInfo().getId());
|
item.setRoomId(this.room.getRoomInfo().getId());
|
||||||
|
item.setRoom(room);
|
||||||
} catch (Exception ignored) {
|
} catch (Exception ignored) {
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -344,7 +346,9 @@ public class RoomItemManager {
|
|||||||
this.room.sendComposer(new ItemAddMessageComposer(item, this.room.getFurniOwnerName(item.getOwnerInfo().getId())).compose());
|
this.room.sendComposer(new ItemAddMessageComposer(item, this.room.getFurniOwnerName(item.getOwnerInfo().getId())).compose());
|
||||||
item.needsUpdate(true);
|
item.needsUpdate(true);
|
||||||
this.addRoomItem(item);
|
this.addRoomItem(item);
|
||||||
|
//Deprecated
|
||||||
item.setRoomId(this.room.getRoomInfo().getId());
|
item.setRoomId(this.room.getRoomInfo().getId());
|
||||||
|
item.setRoom(this.room);
|
||||||
item.onPlace(this.room);
|
item.onPlace(this.room);
|
||||||
Emulator.getThreading().run(item);
|
Emulator.getThreading().run(item);
|
||||||
return FurnitureMovementError.NONE;
|
return FurnitureMovementError.NONE;
|
||||||
@ -543,7 +547,9 @@ public class RoomItemManager {
|
|||||||
|
|
||||||
this.removeRoomItem(item);
|
this.removeRoomItem(item);
|
||||||
item.onPickUp(this.room);
|
item.onPickUp(this.room);
|
||||||
|
//Deprecated
|
||||||
item.setRoomId(0);
|
item.setRoomId(0);
|
||||||
|
item.setRoom(null);
|
||||||
item.needsUpdate(true);
|
item.needsUpdate(true);
|
||||||
|
|
||||||
if (item.getBaseItem().getType() == FurnitureType.FLOOR) {
|
if (item.getBaseItem().getType() == FurnitureType.FLOOR) {
|
||||||
|
@ -210,7 +210,7 @@ public class RoomLayout {
|
|||||||
|
|
||||||
if(this.tileExists(x, y)) {
|
if(this.tileExists(x, y)) {
|
||||||
RoomTile tile = this.getTile(x, y);
|
RoomTile tile = this.getTile(x, y);
|
||||||
walkable = tile.getState().equals(RoomTileState.OPEN) && tile.isWalkable() && (this.room.getRoomUnitManager().areRoomUnitsAt(tile) && !this.room.getRoomInfo().isAllowWalkthrough());
|
walkable = tile.isWalkable() && (this.room.getRoomUnitManager().areRoomUnitsAt(tile) && !this.room.getRoomInfo().isAllowWalkthrough());
|
||||||
}
|
}
|
||||||
|
|
||||||
return walkable;
|
return walkable;
|
||||||
|
@ -574,7 +574,6 @@ public class RoomManager {
|
|||||||
RoomHabbo roomHabbo = habbo.getRoomUnit();
|
RoomHabbo roomHabbo = habbo.getRoomUnit();
|
||||||
|
|
||||||
roomHabbo.clear();
|
roomHabbo.clear();
|
||||||
roomHabbo.clearWalking();
|
|
||||||
|
|
||||||
if (roomHabbo.getCurrentPosition() == null) {
|
if (roomHabbo.getCurrentPosition() == null) {
|
||||||
RoomTile spawnTile = spawnLocation == null ? room.getLayout().getDoorTile() : spawnLocation;
|
RoomTile spawnTile = spawnLocation == null ? room.getLayout().getDoorTile() : spawnLocation;
|
||||||
@ -622,7 +621,7 @@ public class RoomManager {
|
|||||||
|
|
||||||
habbo.getClient().sendResponse(new RoomRatingComposer(room.getRoomInfo().getScore(), !this.hasVotedForRoom(habbo, room)));
|
habbo.getClient().sendResponse(new RoomRatingComposer(room.getRoomInfo().getScore(), !this.hasVotedForRoom(habbo, room)));
|
||||||
|
|
||||||
roomHabbo.setFastWalkEnabled(roomHabbo.isFastWalkEnabled() && habbo.canExecuteCommand("cmd_fastwalk", room.getRoomRightsManager().hasRights(habbo)));
|
roomHabbo.setCmdFastWalkEnabled(roomHabbo.isCmdFastWalkEnabled() && habbo.canExecuteCommand("cmd_fastwalk", room.getRoomRightsManager().hasRights(habbo)));
|
||||||
|
|
||||||
if (room.isPromoted()) {
|
if (room.isPromoted()) {
|
||||||
habbo.getClient().sendResponse(new RoomEventComposer(room, room.getPromotion()));
|
habbo.getClient().sendResponse(new RoomEventComposer(room, room.getPromotion()));
|
||||||
@ -875,9 +874,8 @@ public class RoomManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void leaveRoom(Habbo habbo, Room room, boolean redirectToHotelView) {
|
public void leaveRoom(Habbo habbo, Room room, boolean redirectToHotelView) {
|
||||||
if (habbo.getRoomUnit().getRoom() != null && habbo.getRoomUnit().getRoom() == room) {
|
if (habbo.getRoomUnit().getRoom() != null && habbo.getRoomUnit().getRoom().equals(room)) {
|
||||||
this.logExit(habbo);
|
this.logExit(habbo);
|
||||||
|
|
||||||
room.getRoomUnitManager().removeHabbo(habbo, true);
|
room.getRoomUnitManager().removeHabbo(habbo, true);
|
||||||
|
|
||||||
if (redirectToHotelView) {
|
if (redirectToHotelView) {
|
||||||
@ -885,9 +883,8 @@ public class RoomManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
habbo.getRoomUnit().setPreviousRoom(room);
|
habbo.getRoomUnit().setPreviousRoom(room);
|
||||||
habbo.getRoomUnit().setRoom(null);
|
|
||||||
|
|
||||||
if (room.getRoomInfo().getOwnerInfo().getId() != habbo.getHabboInfo().getId()) {
|
if (!room.getRoomInfo().isRoomOwner(habbo)) {
|
||||||
AchievementManager.progressAchievement(room.getRoomInfo().getOwnerInfo().getId(), Emulator.getGameEnvironment().getAchievementManager().getAchievement("RoomDecoHosting"), (int) Math.floor((Emulator.getIntUnixTimestamp() - habbo.getHabboStats().roomEnterTimestamp) / 60000.0));
|
AchievementManager.progressAchievement(room.getRoomInfo().getOwnerInfo().getId(), Emulator.getGameEnvironment().getAchievementManager().getAchievement("RoomDecoHosting"), (int) Math.floor((Emulator.getIntUnixTimestamp() - habbo.getHabboStats().roomEnterTimestamp) / 60000.0));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -902,13 +899,13 @@ public class RoomManager {
|
|||||||
control.getRoomUnit().getCacheable().remove("controller");
|
control.getRoomUnit().getCacheable().remove("controller");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (habbo.getHabboInfo().getRiding() != null) {
|
if (habbo.getRoomUnit().isRiding()) {
|
||||||
if (habbo.getHabboInfo().getRiding().getRoomUnit() != null) {
|
if (habbo.getRoomUnit().getRidingPet().getRoomUnit() != null) {
|
||||||
habbo.getHabboInfo().getRiding().getRoomUnit().setGoalLocation(habbo.getHabboInfo().getRiding().getRoomUnit().getCurrentPosition());
|
habbo.getRoomUnit().getRidingPet().getRoomUnit().walkTo(habbo.getRoomUnit().getRidingPet().getRoomUnit().getCurrentPosition());
|
||||||
}
|
}
|
||||||
habbo.getHabboInfo().getRiding().setTask(PetTasks.FREE);
|
habbo.getRoomUnit().getRidingPet().setTask(PetTasks.FREE);
|
||||||
habbo.getHabboInfo().getRiding().setRider(null);
|
habbo.getRoomUnit().getRidingPet().setRider(null);
|
||||||
habbo.getHabboInfo().setRiding(null);
|
habbo.getRoomUnit().setRidingPet(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
Room room = habbo.getRoomUnit().getRoom();
|
Room room = habbo.getRoomUnit().getRoom();
|
||||||
|
@ -57,6 +57,7 @@ public class RoomTile {
|
|||||||
if (this.state == RoomTileState.INVALID) {
|
if (this.state == RoomTileState.INVALID) {
|
||||||
this.allowStack = false;
|
this.allowStack = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.roomUnits = tile.roomUnits;
|
this.roomUnits = tile.roomUnits;
|
||||||
this.roomItems = tile.roomItems;
|
this.roomItems = tile.roomItems;
|
||||||
}
|
}
|
||||||
@ -106,6 +107,10 @@ public class RoomTile {
|
|||||||
((RoomTile) o).y == this.y;
|
((RoomTile) o).y == this.y;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean equals(int x, int y) {
|
||||||
|
return this.x == x && this.y == y;
|
||||||
|
}
|
||||||
|
|
||||||
public RoomTile copy() {
|
public RoomTile copy() {
|
||||||
return new RoomTile(this);
|
return new RoomTile(this);
|
||||||
}
|
}
|
||||||
@ -162,11 +167,9 @@ public class RoomTile {
|
|||||||
|
|
||||||
public void addRoomUnit(RoomUnit roomUnit) {
|
public void addRoomUnit(RoomUnit roomUnit) {
|
||||||
synchronized (this.roomUnits) {
|
synchronized (this.roomUnits) {
|
||||||
if (!this.roomUnits.contains(roomUnit)) {
|
|
||||||
this.roomUnits.add(roomUnit);
|
this.roomUnits.add(roomUnit);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public void removeUnit(RoomUnit roomUnit) {
|
public void removeUnit(RoomUnit roomUnit) {
|
||||||
synchronized (this.roomUnits) {
|
synchronized (this.roomUnits) {
|
||||||
|
@ -266,7 +266,9 @@ public class RoomTraxManager implements Disposable {
|
|||||||
|
|
||||||
this.room.sendComposer(new JukeboxSongDisksMessageComposer(this.songs, this.totalLength).compose());
|
this.room.sendComposer(new JukeboxSongDisksMessageComposer(this.songs, this.totalLength).compose());
|
||||||
|
|
||||||
|
//Deprecated
|
||||||
musicDisc.setRoomId(-1);
|
musicDisc.setRoomId(-1);
|
||||||
|
musicDisc.setRoom(null);
|
||||||
musicDisc.needsUpdate(true);
|
musicDisc.needsUpdate(true);
|
||||||
Emulator.getThreading().run(musicDisc);
|
Emulator.getThreading().run(musicDisc);
|
||||||
|
|
||||||
@ -293,8 +295,9 @@ public class RoomTraxManager implements Disposable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.room.sendComposer(new JukeboxSongDisksMessageComposer(this.songs, this.totalLength).compose());
|
this.room.sendComposer(new JukeboxSongDisksMessageComposer(this.songs, this.totalLength).compose());
|
||||||
|
//Deprecated
|
||||||
musicDisc.setRoomId(0);
|
musicDisc.setRoomId(0);
|
||||||
|
musicDisc.setRoom(null);
|
||||||
musicDisc.needsUpdate(true);
|
musicDisc.needsUpdate(true);
|
||||||
Emulator.getThreading().run(musicDisc);
|
Emulator.getThreading().run(musicDisc);
|
||||||
|
|
||||||
@ -324,7 +327,9 @@ public class RoomTraxManager implements Disposable {
|
|||||||
|
|
||||||
if (musicDisc != null) {
|
if (musicDisc != null) {
|
||||||
if (musicDisc instanceof InteractionMusicDisc && musicDisc.getRoomId() == -1) {
|
if (musicDisc instanceof InteractionMusicDisc && musicDisc.getRoomId() == -1) {
|
||||||
|
//Deprecated
|
||||||
musicDisc.setRoomId(0);
|
musicDisc.setRoomId(0);
|
||||||
|
musicDisc.setRoom(null);
|
||||||
musicDisc.needsUpdate(true);
|
musicDisc.needsUpdate(true);
|
||||||
Emulator.getThreading().run(musicDisc);
|
Emulator.getThreading().run(musicDisc);
|
||||||
|
|
||||||
|
@ -14,7 +14,6 @@ import com.eu.habbo.habbohotel.rooms.entities.units.types.RoomPet;
|
|||||||
import com.eu.habbo.habbohotel.units.Unit;
|
import com.eu.habbo.habbohotel.units.Unit;
|
||||||
import com.eu.habbo.habbohotel.users.DanceType;
|
import com.eu.habbo.habbohotel.users.DanceType;
|
||||||
import com.eu.habbo.habbohotel.users.Habbo;
|
import com.eu.habbo.habbohotel.users.Habbo;
|
||||||
import com.eu.habbo.messages.outgoing.hotelview.CloseConnectionMessageComposer;
|
|
||||||
import com.eu.habbo.messages.outgoing.inventory.PetAddedToInventoryComposer;
|
import com.eu.habbo.messages.outgoing.inventory.PetAddedToInventoryComposer;
|
||||||
import com.eu.habbo.messages.outgoing.rooms.pets.RoomPetComposer;
|
import com.eu.habbo.messages.outgoing.rooms.pets.RoomPetComposer;
|
||||||
import com.eu.habbo.messages.outgoing.rooms.users.UserRemoveMessageComposer;
|
import com.eu.habbo.messages.outgoing.rooms.users.UserRemoveMessageComposer;
|
||||||
@ -67,10 +66,11 @@ public class RoomUnitManager {
|
|||||||
try (ResultSet set = statement.executeQuery()) {
|
try (ResultSet set = statement.executeQuery()) {
|
||||||
while (set.next()) {
|
while (set.next()) {
|
||||||
Bot bot = Emulator.getGameEnvironment().getBotManager().loadBot(set);
|
Bot bot = Emulator.getGameEnvironment().getBotManager().loadBot(set);
|
||||||
|
//TODO IMPROVE THIS
|
||||||
if (bot != null) {
|
if (bot != null) {
|
||||||
bot.setRoom(this.room);
|
bot.setRoom(this.room);
|
||||||
bot.setRoomUnit(new RoomBot());
|
bot.setRoomUnit(new RoomBot());
|
||||||
|
bot.getRoomUnit().setUnit(bot);
|
||||||
bot.getRoomUnit().setRoom(this.room);
|
bot.getRoomUnit().setRoom(this.room);
|
||||||
bot.getRoomUnit().setLocation(this.room.getLayout().getTile((short) set.getInt("x"), (short) set.getInt("y")));
|
bot.getRoomUnit().setLocation(this.room.getLayout().getTile((short) set.getInt("x"), (short) set.getInt("y")));
|
||||||
if (bot.getRoomUnit().getCurrentPosition() == null || bot.getRoomUnit().getCurrentPosition().getState() == RoomTileState.INVALID) {
|
if (bot.getRoomUnit().getCurrentPosition() == null || bot.getRoomUnit().getCurrentPosition().getState() == RoomTileState.INVALID) {
|
||||||
@ -79,7 +79,6 @@ public class RoomUnitManager {
|
|||||||
bot.getRoomUnit().setRotation(RoomRotation.fromValue(this.room.getLayout().getDoorDirection()));
|
bot.getRoomUnit().setRotation(RoomRotation.fromValue(this.room.getLayout().getDoorDirection()));
|
||||||
} else {
|
} else {
|
||||||
bot.getRoomUnit().setCurrentZ(set.getDouble("z"));
|
bot.getRoomUnit().setCurrentZ(set.getDouble("z"));
|
||||||
bot.getRoomUnit().setPreviousLocationZ(set.getDouble("z"));
|
|
||||||
bot.getRoomUnit().setRotation(RoomRotation.values()[set.getInt("rot")]);
|
bot.getRoomUnit().setRotation(RoomRotation.values()[set.getInt("rot")]);
|
||||||
}
|
}
|
||||||
bot.getRoomUnit().setRoomUnitType(RoomUnitType.BOT);
|
bot.getRoomUnit().setRoomUnitType(RoomUnitType.BOT);
|
||||||
@ -110,6 +109,7 @@ public class RoomUnitManager {
|
|||||||
|
|
||||||
pet.setRoom(this.room);
|
pet.setRoom(this.room);
|
||||||
pet.setRoomUnit(new RoomPet());
|
pet.setRoomUnit(new RoomPet());
|
||||||
|
pet.getRoomUnit().setUnit(pet);
|
||||||
pet.getRoomUnit().setRoom(this.room);
|
pet.getRoomUnit().setRoom(this.room);
|
||||||
pet.getRoomUnit().setLocation(this.room.getLayout().getTile((short) set.getInt("x"), (short) set.getInt("y")));
|
pet.getRoomUnit().setLocation(this.room.getLayout().getTile((short) set.getInt("x"), (short) set.getInt("y")));
|
||||||
if (pet.getRoomUnit().getCurrentPosition() == null || pet.getRoomUnit().getCurrentPosition().getState() == RoomTileState.INVALID) {
|
if (pet.getRoomUnit().getCurrentPosition() == null || pet.getRoomUnit().getCurrentPosition().getState() == RoomTileState.INVALID) {
|
||||||
@ -227,15 +227,13 @@ public class RoomUnitManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pet.setRoomUnit(new RoomPet());
|
pet.setRoomUnit(new RoomPet());
|
||||||
|
pet.getRoomUnit().setUnit(pet);
|
||||||
pet.setRoom(room);
|
pet.setRoom(room);
|
||||||
pet.getRoomUnit()
|
pet.getRoomUnit().walkTo(tile);
|
||||||
.setGoalLocation(tile)
|
pet.getRoomUnit().setLocation(tile)
|
||||||
.setLocation(tile)
|
|
||||||
.setRoomUnitType(RoomUnitType.PET)
|
.setRoomUnitType(RoomUnitType.PET)
|
||||||
.setCanWalk(true)
|
.setCanWalk(true)
|
||||||
.setPreviousLocationZ(z)
|
.setCurrentZ(z);
|
||||||
.setCurrentZ(z)
|
|
||||||
.setRoom(room);
|
|
||||||
|
|
||||||
if (pet.getRoomUnit().getCurrentPosition() == null) {
|
if (pet.getRoomUnit().getCurrentPosition() == null) {
|
||||||
pet.getRoomUnit()
|
pet.getRoomUnit()
|
||||||
@ -291,11 +289,7 @@ public class RoomUnitManager {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
RoomUnit roomUnit = habbo.getRoomUnit();
|
RoomHabbo roomHabbo = habbo.getRoomUnit();
|
||||||
|
|
||||||
if(roomUnit == null || !(roomUnit instanceof RoomHabbo roomHabbo)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(roomHabbo.getCurrentPosition() != null) {
|
if(roomHabbo.getCurrentPosition() != null) {
|
||||||
roomHabbo.getCurrentPosition().removeUnit(habbo.getRoomUnit());
|
roomHabbo.getCurrentPosition().removeUnit(habbo.getRoomUnit());
|
||||||
@ -308,6 +302,7 @@ public class RoomUnitManager {
|
|||||||
|
|
||||||
roomHabbo.getRoom().sendComposer(new UserRemoveMessageComposer(roomHabbo).compose());
|
roomHabbo.getRoom().sendComposer(new UserRemoveMessageComposer(roomHabbo).compose());
|
||||||
|
|
||||||
|
//MOVE THIS TO RoomTile.java -> removeUnit()
|
||||||
RoomItem item = roomHabbo.getRoom().getRoomItemManager().getTopItemAt(roomHabbo.getCurrentPosition());
|
RoomItem item = roomHabbo.getRoom().getRoomItemManager().getTopItemAt(roomHabbo.getCurrentPosition());
|
||||||
|
|
||||||
if (item != null) {
|
if (item != null) {
|
||||||
@ -333,7 +328,6 @@ public class RoomUnitManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
roomHabbo.getRoom().updateDatabaseUserCount();
|
roomHabbo.getRoom().updateDatabaseUserCount();
|
||||||
|
|
||||||
roomHabbo.clear();
|
roomHabbo.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -414,11 +408,9 @@ public class RoomUnitManager {
|
|||||||
|
|
||||||
public void dispose() {
|
public void dispose() {
|
||||||
for(Habbo habbo : this.currentHabbos.values()) {
|
for(Habbo habbo : this.currentHabbos.values()) {
|
||||||
Emulator.getGameEnvironment().getRoomManager().leaveRoom(habbo, this.room);
|
Emulator.getGameEnvironment().getRoomManager().leaveRoom(habbo, this.room, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.room.sendComposer(new CloseConnectionMessageComposer().compose());
|
|
||||||
|
|
||||||
this.currentHabbos.clear();
|
this.currentHabbos.clear();
|
||||||
|
|
||||||
Iterator<Bot> botIterator = this.currentBots.values().iterator();
|
Iterator<Bot> botIterator = this.currentBots.values().iterator();
|
||||||
@ -450,7 +442,6 @@ public class RoomUnitManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.currentPets.clear();
|
this.currentPets.clear();
|
||||||
|
|
||||||
this.currentRoomUnits.clear();
|
this.currentRoomUnits.clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,6 +19,12 @@ public interface IRoomEntity {
|
|||||||
double getCurrentZ();
|
double getCurrentZ();
|
||||||
RoomEntity setCurrentZ(double currentZ);
|
RoomEntity setCurrentZ(double currentZ);
|
||||||
|
|
||||||
|
RoomTile getNextPosition();
|
||||||
|
RoomEntity setNextPosition(RoomTile nextPosition);
|
||||||
|
|
||||||
|
double getNextZ();
|
||||||
|
RoomEntity setNextZ(double nextZ);
|
||||||
|
|
||||||
RoomTile getTargetPosition();
|
RoomTile getTargetPosition();
|
||||||
RoomEntity setTargetPosition(RoomTile targetPosition);
|
RoomEntity setTargetPosition(RoomTile targetPosition);
|
||||||
|
|
||||||
|
@ -7,33 +7,35 @@ import lombok.Setter;
|
|||||||
import lombok.experimental.Accessors;
|
import lombok.experimental.Accessors;
|
||||||
|
|
||||||
import java.util.Deque;
|
import java.util.Deque;
|
||||||
import java.util.LinkedList;
|
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
@Setter
|
@Setter
|
||||||
@Accessors(chain = true)
|
@Accessors(chain = true)
|
||||||
public abstract class RoomEntity implements IRoomEntity {
|
public abstract class RoomEntity implements IRoomEntity {
|
||||||
private Room room;
|
protected Room room;
|
||||||
private RoomTile previousPosition;
|
protected RoomTile previousPosition;
|
||||||
private double previousZ;
|
protected double previousZ;
|
||||||
private RoomTile currentPosition;
|
protected RoomTile currentPosition;
|
||||||
private double currentZ;
|
protected double currentZ;
|
||||||
private RoomTile targetPosition;
|
protected RoomTile nextPosition;
|
||||||
private double targetZ;
|
protected double nextZ;
|
||||||
private Deque<RoomTile> path = new LinkedList<>();
|
protected RoomTile targetPosition;
|
||||||
private int tilesMoved;
|
protected double targetZ;
|
||||||
|
protected Deque<RoomTile> path;
|
||||||
|
protected int tilesMoved;
|
||||||
|
|
||||||
public boolean isAtGoal() {
|
public boolean isAtGoal() {
|
||||||
if(this.currentPosition == null) {
|
if(this.targetPosition == null) {
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.currentPosition.equals(this.targetPosition);
|
return this.currentPosition.equals(this.targetPosition);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPreviousLocation(RoomTile previousLocation) {
|
public RoomEntity setCurrentPosition(RoomTile tile) {
|
||||||
this.previousPosition = previousLocation;
|
this.previousPosition = this.currentPosition;
|
||||||
this.previousZ = this.getCurrentZ();
|
this.currentPosition = tile;
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public RoomEntity setCurrentZ(double currentZ) {
|
public RoomEntity setCurrentZ(double currentZ) {
|
||||||
@ -42,6 +44,11 @@ public abstract class RoomEntity implements IRoomEntity {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void clearNextLocation() {
|
||||||
|
this.nextPosition = null;
|
||||||
|
this.nextZ = 0;
|
||||||
|
}
|
||||||
|
|
||||||
public synchronized void incrementTilesMoved() {
|
public synchronized void incrementTilesMoved() {
|
||||||
this.tilesMoved++;
|
this.tilesMoved++;
|
||||||
}
|
}
|
||||||
@ -49,4 +56,22 @@ public abstract class RoomEntity implements IRoomEntity {
|
|||||||
public synchronized void decrementTilesMoved() {
|
public synchronized void decrementTilesMoved() {
|
||||||
this.tilesMoved--;
|
this.tilesMoved--;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void clear() {
|
||||||
|
this.room = null;
|
||||||
|
|
||||||
|
this.previousPosition = null;
|
||||||
|
this.previousZ = 0;
|
||||||
|
|
||||||
|
this.currentPosition = null;
|
||||||
|
this.currentZ = 0;
|
||||||
|
|
||||||
|
this.nextPosition = null;
|
||||||
|
this.nextZ = 0;
|
||||||
|
|
||||||
|
this.targetPosition = null;
|
||||||
|
this.targetZ = 0;
|
||||||
|
|
||||||
|
this.path = null;
|
||||||
|
}
|
||||||
}
|
}
|
@ -53,15 +53,20 @@ import java.util.List;
|
|||||||
public abstract class RoomItem extends RoomEntity implements Runnable, IEventTriggers {
|
public abstract class RoomItem extends RoomEntity implements Runnable, IEventTriggers {
|
||||||
private final int id;
|
private final int id;
|
||||||
private HabboInfo ownerInfo;
|
private HabboInfo ownerInfo;
|
||||||
|
/**
|
||||||
|
* TODO FINISH GET RID OF THIS
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
private int roomId;
|
private int roomId;
|
||||||
|
|
||||||
private final Item baseItem;
|
private final Item baseItem;
|
||||||
private String wallPosition;
|
private String wallPosition;
|
||||||
private int rotation;
|
private int rotation;
|
||||||
private String extraData;
|
private String extraData;
|
||||||
private int limitedStack;
|
private int limitedStack;
|
||||||
private int limitedSells;
|
private int limitedSells;
|
||||||
private boolean needsUpdate = false;
|
private boolean sqlUpdateNeeded = false;
|
||||||
private boolean needsDelete = false;
|
private boolean sqlDeleteNeeded = false;
|
||||||
private boolean isFromGift = false;
|
private boolean isFromGift = false;
|
||||||
|
|
||||||
@SuppressWarnings("rawtypes")
|
@SuppressWarnings("rawtypes")
|
||||||
@ -75,6 +80,7 @@ public abstract class RoomItem extends RoomEntity implements Runnable, IEventTri
|
|||||||
public RoomItem(ResultSet set, Item baseItem) throws SQLException {
|
public RoomItem(ResultSet set, Item baseItem) throws SQLException {
|
||||||
this.id = set.getInt("id");
|
this.id = set.getInt("id");
|
||||||
this.ownerInfo = Emulator.getGameEnvironment().getHabboManager().getOfflineHabboInfo(set.getInt(DatabaseConstants.USER_ID));
|
this.ownerInfo = Emulator.getGameEnvironment().getHabboManager().getOfflineHabboInfo(set.getInt(DatabaseConstants.USER_ID));
|
||||||
|
|
||||||
this.roomId = set.getInt("room_id");
|
this.roomId = set.getInt("room_id");
|
||||||
|
|
||||||
Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(set.getInt("room_id"));
|
Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(set.getInt("room_id"));
|
||||||
@ -84,9 +90,15 @@ public abstract class RoomItem extends RoomEntity implements Runnable, IEventTri
|
|||||||
this.wallPosition = set.getString("wall_pos");
|
this.wallPosition = set.getString("wall_pos");
|
||||||
|
|
||||||
if(room != null) {
|
if(room != null) {
|
||||||
this.setCurrentPosition(room.getLayout().getTile(set.getShort("x"), set.getShort("y")));
|
RoomTile itemTile = room.getLayout().getTile(set.getShort("x"), set.getShort("y"));
|
||||||
|
|
||||||
|
if(itemTile == null) {
|
||||||
|
this.setRoom(null);
|
||||||
|
} else {
|
||||||
|
this.setCurrentPosition(itemTile);
|
||||||
this.setCurrentZ(set.getDouble("z"));
|
this.setCurrentZ(set.getDouble("z"));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
this.rotation = set.getInt("rot");
|
this.rotation = set.getInt("rot");
|
||||||
this.extraData = set.getString("extra_data").isEmpty() ? "0" : set.getString("extra_data");
|
this.extraData = set.getString("extra_data").isEmpty() ? "0" : set.getString("extra_data");
|
||||||
@ -96,8 +108,6 @@ public abstract class RoomItem extends RoomEntity implements Runnable, IEventTri
|
|||||||
this.limitedStack = Integer.parseInt(set.getString("limited_data").split(":")[0]);
|
this.limitedStack = Integer.parseInt(set.getString("limited_data").split(":")[0]);
|
||||||
this.limitedSells = Integer.parseInt(set.getString("limited_data").split(":")[1]);
|
this.limitedSells = Integer.parseInt(set.getString("limited_data").split(":")[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.setRoom(Emulator.getGameEnvironment().getRoomManager().getRoom(set.getInt("room_id")));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public RoomItem(int id, HabboInfo ownerInfo, Item item, String extraData, int limitedStack, int limitedSells) {
|
public RoomItem(int id, HabboInfo ownerInfo, Item item, String extraData, int limitedStack, int limitedSells) {
|
||||||
@ -171,19 +181,19 @@ public abstract class RoomItem extends RoomEntity implements Runnable, IEventTri
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean needsUpdate() {
|
public boolean needsUpdate() {
|
||||||
return this.needsUpdate;
|
return this.sqlUpdateNeeded;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean needsDelete() {
|
public boolean needsDelete() {
|
||||||
return needsDelete;
|
return sqlDeleteNeeded;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void needsUpdate(boolean value) {
|
public void needsUpdate(boolean value) {
|
||||||
this.needsUpdate = value;
|
this.sqlUpdateNeeded = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void needsDelete(boolean value) {
|
public void needsDelete(boolean value) {
|
||||||
this.needsDelete = value;
|
this.sqlDeleteNeeded = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isLimited() {
|
public boolean isLimited() {
|
||||||
@ -195,24 +205,24 @@ public abstract class RoomItem extends RoomEntity implements Runnable, IEventTri
|
|||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection()) {
|
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection()) {
|
||||||
if (this.needsDelete) {
|
if (this.sqlDeleteNeeded) {
|
||||||
this.needsUpdate = false;
|
this.sqlUpdateNeeded = false;
|
||||||
this.needsDelete = false;
|
this.sqlDeleteNeeded = false;
|
||||||
|
|
||||||
try (PreparedStatement statement = connection.prepareStatement("DELETE FROM items WHERE id = ?")) {
|
try (PreparedStatement statement = connection.prepareStatement("DELETE FROM items WHERE id = ?")) {
|
||||||
statement.setInt(1, this.getId());
|
statement.setInt(1, this.getId());
|
||||||
statement.execute();
|
statement.execute();
|
||||||
}
|
}
|
||||||
} else if (this.needsUpdate) {
|
} else if (this.sqlUpdateNeeded) {
|
||||||
try (PreparedStatement statement = connection.prepareStatement("UPDATE items SET user_id = ?, room_id = ?, wall_pos = ?, x = ?, y = ?, z = ?, rot = ?, extra_data = ?, limited_data = ? WHERE id = ?")) {
|
try (PreparedStatement statement = connection.prepareStatement("UPDATE items SET user_id = ?, room_id = ?, wall_pos = ?, x = ?, y = ?, z = ?, rot = ?, extra_data = ?, limited_data = ? WHERE id = ?")) {
|
||||||
statement.setInt(1, this.ownerInfo.getId());
|
statement.setInt(1, this.ownerInfo.getId());
|
||||||
statement.setInt(2, this.roomId);
|
statement.setInt(2, (this.getRoom() == null) ? 0 : this.getRoom().getRoomInfo().getId());
|
||||||
statement.setString(3, this.wallPosition);
|
statement.setString(3, this.wallPosition);
|
||||||
statement.setInt(4, this.getCurrentPosition().getX());
|
statement.setInt(4, this.getCurrentPosition().getX());
|
||||||
statement.setInt(5, this.getCurrentPosition().getY());
|
statement.setInt(5, this.getCurrentPosition().getY());
|
||||||
statement.setDouble(6, Math.max(-9999, Math.min(9999, Math.round(this.getCurrentZ() * Math.pow(10, 6)) / Math.pow(10, 6))));
|
statement.setDouble(6, Math.max(-9999, Math.min(9999, Math.round(this.getCurrentZ() * Math.pow(10, 6)) / Math.pow(10, 6))));
|
||||||
statement.setInt(7, this.rotation);
|
statement.setInt(7, this.rotation);
|
||||||
statement.setString(8, this instanceof InteractionGuildGate ? "" : this.getDatabaseExtraData());
|
statement.setString(8, this instanceof InteractionGuildGate ? "" : this.extraData);
|
||||||
statement.setString(9, this.limitedStack + ":" + this.limitedSells);
|
statement.setString(9, this.limitedStack + ":" + this.limitedSells);
|
||||||
statement.setInt(10, this.id);
|
statement.setInt(10, this.id);
|
||||||
statement.execute();
|
statement.execute();
|
||||||
@ -221,7 +231,7 @@ public abstract class RoomItem extends RoomEntity implements Runnable, IEventTri
|
|||||||
log.error("SQLException trying to save HabboItem: " + this);
|
log.error("SQLException trying to save HabboItem: " + this);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.needsUpdate = false;
|
this.sqlUpdateNeeded = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
@ -259,7 +269,7 @@ public abstract class RoomItem extends RoomEntity implements Runnable, IEventTri
|
|||||||
if (this.getBaseItem().getEffectF() > 0 || this.getBaseItem().getEffectM() > 0) {
|
if (this.getBaseItem().getEffectF() > 0 || this.getBaseItem().getEffectM() > 0) {
|
||||||
Habbo habbo = room.getRoomUnitManager().getHabboByRoomUnit(roomAvatar);
|
Habbo habbo = room.getRoomUnitManager().getHabboByRoomUnit(roomAvatar);
|
||||||
|
|
||||||
if (habbo != null && habbo.getHabboInfo().getRiding() == null) {
|
if (habbo != null && !habbo.getRoomUnit().isRiding()) {
|
||||||
if (habbo.getHabboInfo().getGender().equals(HabboGender.M) && this.getBaseItem().getEffectM() > 0) {
|
if (habbo.getHabboInfo().getGender().equals(HabboGender.M) && this.getBaseItem().getEffectM() > 0) {
|
||||||
roomAvatar.giveEffect(this.getBaseItem().getEffectM(), -1);
|
roomAvatar.giveEffect(this.getBaseItem().getEffectM(), -1);
|
||||||
return;
|
return;
|
||||||
@ -299,7 +309,7 @@ public abstract class RoomItem extends RoomEntity implements Runnable, IEventTri
|
|||||||
|
|
||||||
Habbo habbo = room.getRoomUnitManager().getHabboByRoomUnit(roomAvatar);
|
Habbo habbo = room.getRoomUnitManager().getHabboByRoomUnit(roomAvatar);
|
||||||
|
|
||||||
if (habbo != null && habbo.getHabboInfo().getRiding() == null) {
|
if (habbo != null && !habbo.getRoomUnit().isRiding()) {
|
||||||
if (habbo.getHabboInfo().getGender().equals(HabboGender.M) && this.getBaseItem().getEffectM() > 0) {
|
if (habbo.getHabboInfo().getGender().equals(HabboGender.M) && this.getBaseItem().getEffectM() > 0) {
|
||||||
roomAvatar.giveEffect(0, -1);
|
roomAvatar.giveEffect(0, -1);
|
||||||
}
|
}
|
||||||
@ -459,10 +469,6 @@ public abstract class RoomItem extends RoomEntity implements Runnable, IEventTri
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getDatabaseExtraData() {
|
|
||||||
return this.getExtraData();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "ID: " + this.id + ", BaseID: " + this.getBaseItem().getId() + ", X: " + this.getCurrentPosition().getX() + ", Y: " + this.getCurrentPosition().getY() + ", Z: " + this.getCurrentZ() + ", Extradata: " + this.extraData;
|
return "ID: " + this.id + ", BaseID: " + this.getBaseItem().getId() + ", X: " + this.getCurrentPosition().getX() + ", Y: " + this.getCurrentPosition().getY() + ", Z: " + this.getCurrentZ() + ", Extradata: " + this.extraData;
|
||||||
|
@ -10,13 +10,13 @@ import com.eu.habbo.habbohotel.rooms.entities.RoomEntity;
|
|||||||
import com.eu.habbo.habbohotel.rooms.entities.RoomRotation;
|
import com.eu.habbo.habbohotel.rooms.entities.RoomRotation;
|
||||||
import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem;
|
import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem;
|
||||||
import com.eu.habbo.habbohotel.rooms.entities.units.types.RoomAvatar;
|
import com.eu.habbo.habbohotel.rooms.entities.units.types.RoomAvatar;
|
||||||
|
import com.eu.habbo.habbohotel.units.Unit;
|
||||||
import com.eu.habbo.habbohotel.users.DanceType;
|
import com.eu.habbo.habbohotel.users.DanceType;
|
||||||
import com.eu.habbo.messages.outgoing.rooms.users.UserUpdateComposer;
|
import com.eu.habbo.messages.outgoing.rooms.users.UserUpdateComposer;
|
||||||
import com.eu.habbo.plugin.Event;
|
import com.eu.habbo.plugin.Event;
|
||||||
import com.eu.habbo.plugin.events.roomunit.RoomUnitLookAtPointEvent;
|
import com.eu.habbo.plugin.events.roomunit.RoomUnitLookAtPointEvent;
|
||||||
import com.eu.habbo.plugin.events.roomunit.RoomUnitSetGoalEvent;
|
import com.eu.habbo.plugin.events.roomunit.RoomUnitSetGoalEvent;
|
||||||
import com.eu.habbo.util.pathfinding.Rotation;
|
import com.eu.habbo.util.pathfinding.Rotation;
|
||||||
import gnu.trove.map.TMap;
|
|
||||||
import gnu.trove.map.hash.THashMap;
|
import gnu.trove.map.hash.THashMap;
|
||||||
import gnu.trove.set.hash.THashSet;
|
import gnu.trove.set.hash.THashSet;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
@ -24,10 +24,7 @@ import lombok.Setter;
|
|||||||
import lombok.experimental.Accessors;
|
import lombok.experimental.Accessors;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.Comparator;
|
|
||||||
import java.util.Deque;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@ -37,6 +34,8 @@ public abstract class RoomUnit extends RoomEntity {
|
|||||||
@Setter
|
@Setter
|
||||||
private int virtualId;
|
private int virtualId;
|
||||||
@Setter
|
@Setter
|
||||||
|
private Unit unit;
|
||||||
|
@Setter
|
||||||
private RoomUnitType roomUnitType;
|
private RoomUnitType roomUnitType;
|
||||||
@Setter
|
@Setter
|
||||||
private RoomRotation bodyRotation;
|
private RoomRotation bodyRotation;
|
||||||
@ -49,8 +48,6 @@ public abstract class RoomUnit extends RoomEntity {
|
|||||||
@Setter
|
@Setter
|
||||||
private boolean isTeleporting;
|
private boolean isTeleporting;
|
||||||
@Setter
|
@Setter
|
||||||
private boolean cmdTeleportEnabled = false;
|
|
||||||
@Setter
|
|
||||||
private boolean cmdSitEnabled = false;
|
private boolean cmdSitEnabled = false;
|
||||||
@Setter
|
@Setter
|
||||||
private boolean cmdStandEnabled = false;
|
private boolean cmdStandEnabled = false;
|
||||||
@ -59,50 +56,31 @@ public abstract class RoomUnit extends RoomEntity {
|
|||||||
@Setter
|
@Setter
|
||||||
private boolean isSwimming = false;
|
private boolean isSwimming = false;
|
||||||
@Setter
|
@Setter
|
||||||
private boolean fastWalkEnabled;
|
private boolean cmdFastWalkEnabled;
|
||||||
private final ConcurrentHashMap<RoomUnitStatus, String> statuses;
|
private final ConcurrentHashMap<RoomUnitStatus, String> statuses;
|
||||||
@Setter
|
@Setter
|
||||||
private boolean statusUpdateNeeded;
|
private boolean statusUpdateNeeded;
|
||||||
@Getter
|
|
||||||
@Setter
|
@Setter
|
||||||
private boolean isWiredTeleporting = false;
|
private boolean isWiredTeleporting = false;
|
||||||
@Getter
|
|
||||||
@Setter
|
@Setter
|
||||||
private boolean isLeavingTeleporter = false;
|
private boolean isLeavingTeleporter = false;
|
||||||
private final THashMap<String, Object> cacheable;
|
private final THashMap<String, Object> cacheable;
|
||||||
@Getter
|
|
||||||
@Setter
|
|
||||||
private boolean animateWalk = false;
|
|
||||||
@Setter
|
|
||||||
@Getter
|
|
||||||
private boolean sitUpdate = false;
|
|
||||||
@Setter
|
@Setter
|
||||||
private boolean isKicked;
|
private boolean isKicked;
|
||||||
@Setter
|
@Setter
|
||||||
private int kickCount = 0;
|
private int kickCount = 0;
|
||||||
@Getter
|
|
||||||
private RoomTile startLocation;
|
|
||||||
@Getter
|
|
||||||
@Setter
|
|
||||||
private RoomTile botStartLocation;
|
|
||||||
@Getter
|
|
||||||
@Setter
|
|
||||||
@Accessors(chain = true)
|
|
||||||
private double previousLocationZ;
|
|
||||||
@Getter
|
|
||||||
@Setter
|
@Setter
|
||||||
private boolean inRoom;
|
private boolean inRoom;
|
||||||
@Getter
|
|
||||||
@Setter
|
@Setter
|
||||||
@Accessors(chain = true)
|
@Accessors(chain = true)
|
||||||
private boolean invisible = false;
|
private boolean invisible = false;
|
||||||
@Setter
|
@Setter
|
||||||
private boolean canLeaveRoomByDoor = true;
|
private boolean canLeaveRoomByDoor = true;
|
||||||
|
@Setter
|
||||||
private int walkTimeOut;
|
private int walkTimeOut;
|
||||||
private int previousEffectId;
|
private int previousEffectId;
|
||||||
private int previousEffectEndTimestamp;
|
private int previousEffectEndTimestamp;
|
||||||
private int timeInRoom;
|
private int timeInRoom;
|
||||||
@Getter
|
|
||||||
private RoomRightLevels rightsLevel = RoomRightLevels.NONE;
|
private RoomRightLevels rightsLevel = RoomRightLevels.NONE;
|
||||||
private final THashSet<Integer> overridableTiles;
|
private final THashSet<Integer> overridableTiles;
|
||||||
|
|
||||||
@ -113,7 +91,7 @@ public abstract class RoomUnit extends RoomEntity {
|
|||||||
this.canWalk = true;
|
this.canWalk = true;
|
||||||
this.canRotate = true;
|
this.canRotate = true;
|
||||||
this.isTeleporting = false;
|
this.isTeleporting = false;
|
||||||
this.fastWalkEnabled = false;
|
this.cmdFastWalkEnabled = false;
|
||||||
this.statuses = new ConcurrentHashMap<>();
|
this.statuses = new ConcurrentHashMap<>();
|
||||||
this.statusUpdateNeeded = false;
|
this.statusUpdateNeeded = false;
|
||||||
|
|
||||||
@ -132,17 +110,21 @@ public abstract class RoomUnit extends RoomEntity {
|
|||||||
this.overridableTiles = new THashSet<>();
|
this.overridableTiles = new THashSet<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract boolean cycle(Room room);
|
public RoomItem getCurrentItem() {
|
||||||
|
return this.room.getRoomItemManager().getTopItemAt(this.currentPosition);
|
||||||
|
}
|
||||||
|
|
||||||
|
public abstract void cycle();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public RoomUnit setCurrentPosition(RoomTile tile) {
|
public RoomUnit setCurrentPosition(RoomTile tile) {
|
||||||
if (this.getCurrentPosition() != null) {
|
|
||||||
this.getCurrentPosition().removeUnit(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
super.setCurrentPosition(tile);
|
super.setCurrentPosition(tile);
|
||||||
|
|
||||||
if(this.getCurrentPosition() != null) {
|
if (this.previousPosition != null) {
|
||||||
|
this.previousPosition.removeUnit(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(this.currentPosition != null) {
|
||||||
tile.addRoomUnit(this);
|
tile.addRoomUnit(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -155,18 +137,14 @@ public abstract class RoomUnit extends RoomEntity {
|
|||||||
this.statusUpdateNeeded = true;
|
this.statusUpdateNeeded = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void clearWalking() {
|
|
||||||
this.setTargetPosition(null);
|
|
||||||
this.startLocation = this.getCurrentPosition();
|
|
||||||
this.statuses.clear();
|
|
||||||
this.cacheable.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void stopWalking() {
|
public void stopWalking() {
|
||||||
synchronized (this.statuses) {
|
synchronized (this.statuses) {
|
||||||
this.statuses.remove(RoomUnitStatus.MOVE);
|
this.path.clear();
|
||||||
this.statusUpdateNeeded = true;
|
this.nextPosition = null;
|
||||||
this.setGoalLocation(this.getCurrentPosition());
|
this.targetPosition = null;
|
||||||
|
this.removeStatus(RoomUnitStatus.MOVE);
|
||||||
|
this.handleSitStatus();
|
||||||
|
this.handleLayStatus();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -174,8 +152,8 @@ public abstract class RoomUnit extends RoomEntity {
|
|||||||
public RoomUnit setCurrentZ(double currentZ) {
|
public RoomUnit setCurrentZ(double currentZ) {
|
||||||
super.setCurrentZ(currentZ);
|
super.setCurrentZ(currentZ);
|
||||||
|
|
||||||
if (this.getRoom() != null) {
|
if (this.room != null) {
|
||||||
Bot bot = this.getRoom().getRoomUnitManager().getRoomBotById(getVirtualId());
|
Bot bot = this.room.getRoomUnitManager().getRoomBotById(getVirtualId());
|
||||||
if (bot != null) {
|
if (bot != null) {
|
||||||
bot.needsUpdate(true);
|
bot.needsUpdate(true);
|
||||||
}
|
}
|
||||||
@ -185,54 +163,79 @@ public abstract class RoomUnit extends RoomEntity {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public RoomUnit setGoalLocation(RoomTile goalLocation) {
|
/**
|
||||||
if (goalLocation != null) {
|
* Sets the target position for the character's movement and calculates the path to reach the destination.
|
||||||
this.setGoalLocation(goalLocation, false);
|
*
|
||||||
}
|
* @param goalLocation The target location (represented by a {@link RoomTile}) to which the character should move.
|
||||||
return this;
|
* @return {@code true} if the path calculation to the goal location is successful, {@code false} otherwise.
|
||||||
|
* Returns {@code false} if the goal location is not walkable or the character's current room does not allow sitting or laying at that location.
|
||||||
|
* Additionally, the path calculation may be canceled by registered plugins listening to {@link RoomUnitSetGoalEvent}.
|
||||||
|
* In such cases, the method also returns {@code false}.
|
||||||
|
*/
|
||||||
|
public boolean walkTo(RoomTile goalLocation) {
|
||||||
|
if(!goalLocation.isWalkable() && !this.room.canSitOrLayAt(goalLocation)) {
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setGoalLocation(RoomTile goalLocation, boolean noReset) {
|
|
||||||
if (Emulator.getPluginManager().isRegistered(RoomUnitSetGoalEvent.class, false)) {
|
if (Emulator.getPluginManager().isRegistered(RoomUnitSetGoalEvent.class, false)) {
|
||||||
Event event = new RoomUnitSetGoalEvent(this.getRoom(), this, goalLocation);
|
Event event = new RoomUnitSetGoalEvent(this.room, this, goalLocation);
|
||||||
Emulator.getPluginManager().fireEvent(event);
|
Emulator.getPluginManager().fireEvent(event);
|
||||||
|
|
||||||
if (event.isCancelled())
|
if (event.isCancelled())
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Set start location
|
if(this.nextPosition != null) {
|
||||||
this.startLocation = this.getCurrentPosition();
|
this.currentPosition = this.nextPosition;
|
||||||
|
this.currentZ = this.nextZ;
|
||||||
if (goalLocation != null && !noReset) {
|
|
||||||
boolean isWalking = this.hasStatus(RoomUnitStatus.MOVE);
|
|
||||||
this.setTargetPosition(goalLocation);
|
|
||||||
|
|
||||||
this.findPath(); ///< Quadral: this is where we start formulating a path
|
|
||||||
if (!this.getPath().isEmpty()) {
|
|
||||||
this.setTilesMoved(isWalking ? this.getTilesMoved() : 0);
|
|
||||||
this.setCmdSitEnabled(false);
|
|
||||||
} else {
|
|
||||||
this.setTargetPosition(this.getCurrentPosition());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.targetPosition = goalLocation;
|
||||||
|
this.findPath();
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public RoomUnit setLocation(RoomTile location) {
|
public RoomUnit setLocation(RoomTile location) {
|
||||||
if (location != null) {
|
if (location != null) {
|
||||||
this.startLocation = location;
|
this.currentPosition = location;
|
||||||
this.setPreviousLocation(location);
|
this.targetPosition = location;
|
||||||
this.setCurrentPosition(location);
|
|
||||||
this.setTargetPosition(location);
|
|
||||||
this.botStartLocation = location;
|
|
||||||
}
|
}
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Finds a path from the current position to the target position within a room's layout, if valid.
|
||||||
|
* The method checks if the room, layout, and target position are valid, and if the target position is walkable
|
||||||
|
* or can be occupied by sitting or laying, or if it can be overridden.
|
||||||
|
* If all conditions are met, the method attempts to find a path from the current position to the target position
|
||||||
|
* using the room's layout and sets the path accordingly.
|
||||||
|
*
|
||||||
|
* Pre-conditions:
|
||||||
|
* - The current object must have a valid room set (using the `setRoom(Room room)` method).
|
||||||
|
* - The target position must be set (using the `setTargetPosition(RoomTile targetPosition)` method).
|
||||||
|
*
|
||||||
|
* Post-conditions:
|
||||||
|
* - If a valid path is found from the current position to the target position, the path is set using the `setPath(Deque<RoomTile> path)` method.
|
||||||
|
*
|
||||||
|
* Note:
|
||||||
|
* - The method relies on the validity of the room and layout, and whether the target position is walkable, or can be occupied by sitting or laying,
|
||||||
|
* or can be overridden. If any of these conditions are not met, the method will not attempt to find a path.
|
||||||
|
* - The `findPath()` method assumes that the room and layout are well-defined and consistent, and that the target position is within the boundaries of the room's layout.
|
||||||
|
* - The method may return `null` if no valid path is found from the current position to the target position.
|
||||||
|
*/
|
||||||
public void findPath() {
|
public void findPath() {
|
||||||
if (this.getRoom() != null && this.getRoom().getLayout() != null && this.getTargetPosition() != null && (this.getTargetPosition().isWalkable() || this.getRoom().canSitOrLayAt(this.getTargetPosition().getX(), this.getTargetPosition().getY()) || this.canOverrideTile(this.getTargetPosition()))) {
|
boolean hasValidRoom = this.room != null;
|
||||||
Deque<RoomTile> newPath = this.getRoom().getLayout().findPath(this.getCurrentPosition(), this.getTargetPosition(), this.getTargetPosition(), this);
|
boolean hasValidLayout = hasValidRoom && this.room.getLayout() != null;
|
||||||
if (newPath != null) this.setPath(newPath);
|
boolean hasValidTargetPosition = this.targetPosition != null;
|
||||||
|
boolean isTargetPositionWalkable = hasValidTargetPosition && this.targetPosition.isWalkable();
|
||||||
|
boolean canSitOrLayAtTarget = hasValidTargetPosition && hasValidRoom && this.room.canSitOrLayAt(this.targetPosition.getX(), this.targetPosition.getY());
|
||||||
|
boolean canOverrideTile = hasValidTargetPosition && this.canOverrideTile(this.targetPosition);
|
||||||
|
|
||||||
|
if (hasValidLayout && (isTargetPositionWalkable || canSitOrLayAtTarget || canOverrideTile)) {
|
||||||
|
Deque<RoomTile> newPath = this.room.getLayout().findPath(this.currentPosition, this.targetPosition, this.targetPosition, this);
|
||||||
|
if (newPath != null) {
|
||||||
|
this.setPath(newPath);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -248,6 +251,16 @@ public abstract class RoomUnit extends RoomEntity {
|
|||||||
return this.statuses.get(key);
|
return this.statuses.get(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getCurrentStatuses() {
|
||||||
|
StringBuilder status = new StringBuilder("/");
|
||||||
|
|
||||||
|
for (Map.Entry<RoomUnitStatus, String> entry : this.statuses.entrySet()) {
|
||||||
|
status.append(entry.getKey()).append(" ").append(entry.getValue()).append("/");
|
||||||
|
}
|
||||||
|
|
||||||
|
return status.toString();
|
||||||
|
}
|
||||||
|
|
||||||
public void addStatus(RoomUnitStatus key, String value) {
|
public void addStatus(RoomUnitStatus key, String value) {
|
||||||
if (key != null && value != null) {
|
if (key != null && value != null) {
|
||||||
this.statuses.put(key, value);
|
this.statuses.put(key, value);
|
||||||
@ -275,9 +288,9 @@ public abstract class RoomUnit extends RoomEntity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void makeStand() {
|
public void makeStand() {
|
||||||
RoomItem item = this.getRoom().getRoomItemManager().getTopItemAt(this.getCurrentPosition().getX(), this.getCurrentPosition().getY());
|
RoomItem item = this.room.getRoomItemManager().getTopItemAt(this.currentPosition.getX(), this.currentPosition.getY());
|
||||||
if (item == null || !item.getBaseItem().allowSit() || !item.getBaseItem().allowLay()) {
|
if (item == null || !item.getBaseItem().allowSit() || !item.getBaseItem().allowLay()) {
|
||||||
this.setCmdStandEnabled(true);
|
this.cmdStandEnabled = true;
|
||||||
this.setBodyRotation(RoomRotation.values()[this.getBodyRotation().getValue() - this.getBodyRotation().getValue() % 2]);
|
this.setBodyRotation(RoomRotation.values()[this.getBodyRotation().getValue() - this.getBodyRotation().getValue() % 2]);
|
||||||
this.removeStatus(RoomUnitStatus.SIT);
|
this.removeStatus(RoomUnitStatus.SIT);
|
||||||
this.instantUpdate();
|
this.instantUpdate();
|
||||||
@ -289,9 +302,9 @@ public abstract class RoomUnit extends RoomEntity {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.setCmdSitEnabled(true);
|
this.cmdSitEnabled = true;
|
||||||
this.setBodyRotation(RoomRotation.values()[this.getBodyRotation().getValue() - this.getBodyRotation().getValue() % 2]);
|
this.setBodyRotation(RoomRotation.values()[this.getBodyRotation().getValue() - this.getBodyRotation().getValue() % 2]);
|
||||||
this.addStatus(RoomUnitStatus.SIT, 0.5 + "");
|
this.addStatus(RoomUnitStatus.SIT, "0.5");
|
||||||
|
|
||||||
if(this instanceof RoomAvatar roomAvatar) {
|
if(this instanceof RoomAvatar roomAvatar) {
|
||||||
roomAvatar.setDance(DanceType.NONE);
|
roomAvatar.setDance(DanceType.NONE);
|
||||||
@ -300,26 +313,10 @@ public abstract class RoomUnit extends RoomEntity {
|
|||||||
this.instantUpdate();
|
this.instantUpdate();
|
||||||
}
|
}
|
||||||
|
|
||||||
public TMap<String, Object> getCacheable() {
|
|
||||||
return this.cacheable;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getWalkTimeOut() {
|
|
||||||
return this.walkTimeOut;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setWalkTimeOut(int walkTimeOut) {
|
|
||||||
this.walkTimeOut = walkTimeOut;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void increaseTimeInRoom() {
|
public void increaseTimeInRoom() {
|
||||||
this.timeInRoom++;
|
this.timeInRoom++;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getTimeInRoom() {
|
|
||||||
return this.timeInRoom;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void resetTimeInRoom() {
|
public void resetTimeInRoom() {
|
||||||
this.timeInRoom = 0;
|
this.timeInRoom = 0;
|
||||||
}
|
}
|
||||||
@ -330,7 +327,7 @@ public abstract class RoomUnit extends RoomEntity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (Emulator.getPluginManager().isRegistered(RoomUnitLookAtPointEvent.class, false)) {
|
if (Emulator.getPluginManager().isRegistered(RoomUnitLookAtPointEvent.class, false)) {
|
||||||
Event lookAtPointEvent = new RoomUnitLookAtPointEvent(this.getRoom(), this, location);
|
Event lookAtPointEvent = new RoomUnitLookAtPointEvent(this.room, this, location);
|
||||||
Emulator.getPluginManager().fireEvent(lookAtPointEvent);
|
Emulator.getPluginManager().fireEvent(lookAtPointEvent);
|
||||||
|
|
||||||
if (lookAtPointEvent.isCancelled())
|
if (lookAtPointEvent.isCancelled())
|
||||||
@ -341,7 +338,7 @@ public abstract class RoomUnit extends RoomEntity {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
RoomRotation rotation = (RoomRotation.values()[Rotation.Calculate(this.getCurrentPosition().getX(), this.getCurrentPosition().getY(), location.getX(), location.getY())]);
|
RoomRotation rotation = (RoomRotation.values()[Rotation.Calculate(this.currentPosition.getX(), this.currentPosition.getY(), location.getX(), location.getY())]);
|
||||||
|
|
||||||
if (!this.statuses.containsKey(RoomUnitStatus.SIT)) {
|
if (!this.statuses.containsKey(RoomUnitStatus.SIT)) {
|
||||||
this.bodyRotation = rotation;
|
this.bodyRotation = rotation;
|
||||||
@ -355,9 +352,9 @@ public abstract class RoomUnit extends RoomEntity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean canOverrideTile(RoomTile tile) {
|
public boolean canOverrideTile(RoomTile tile) {
|
||||||
if (tile == null || this.getRoom() == null || this.getRoom().getLayout() == null) return false;
|
if (tile == null || this.room == null || this.room.getLayout() == null) return false;
|
||||||
|
|
||||||
if (this.getRoom().getRoomItemManager().getItemsAt(tile).stream().anyMatch(i -> i.canOverrideTile(this, this.getRoom(), tile)))
|
if (this.room.getRoomItemManager().getItemsAt(tile).stream().anyMatch(i -> i.canOverrideTile(this, this.room, tile)))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
int tileIndex = (tile.getX() & 0xFF) | (tile.getY() << 12);
|
int tileIndex = (tile.getX() & 0xFF) | (tile.getY() << 12);
|
||||||
@ -372,28 +369,28 @@ public abstract class RoomUnit extends RoomEntity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void removeOverrideTile(RoomTile tile) {
|
public void removeOverrideTile(RoomTile tile) {
|
||||||
if (this.getRoom() == null || this.getRoom().getLayout() == null) return;
|
if (this.room == null || this.room.getLayout() == null) return;
|
||||||
|
|
||||||
int tileIndex = (tile.getX() & 0xFF) | (tile.getY() << 12);
|
int tileIndex = (tile.getX() & 0xFF) | (tile.getY() << 12);
|
||||||
this.overridableTiles.remove(tileIndex);
|
this.overridableTiles.remove(tileIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean canForcePosture() {
|
public boolean canForcePosture() {
|
||||||
if (this.getRoom() == null) return false;
|
if (this.room == null) return false;
|
||||||
|
|
||||||
RoomItem topItem = this.getRoom().getRoomItemManager().getTopItemAt(this.getCurrentPosition().getX(), this.getCurrentPosition().getY());
|
RoomItem topItem = this.room.getRoomItemManager().getTopItemAt(this.currentPosition.getX(), this.currentPosition.getY());
|
||||||
|
|
||||||
return (!(topItem instanceof InteractionWater) && !(topItem instanceof InteractionWaterItem));
|
return (!(topItem instanceof InteractionWater) && !(topItem instanceof InteractionWaterItem));
|
||||||
}
|
}
|
||||||
|
|
||||||
public RoomTile getClosestTile(List<RoomTile> tiles) {
|
public RoomTile getClosestTile(List<RoomTile> tiles) {
|
||||||
return tiles.stream().min(Comparator.comparingDouble(a -> a.distance(this.getCurrentPosition()))).orElse(null);
|
return tiles.stream().min(Comparator.comparingDouble(a -> a.distance(this.currentPosition))).orElse(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public RoomTile getClosestAdjacentTile(short x, short y, boolean diagonal) {
|
public RoomTile getClosestAdjacentTile(short x, short y, boolean diagonal) {
|
||||||
if (this.getRoom() == null) return null;
|
if (this.room == null) return null;
|
||||||
|
|
||||||
RoomTile baseTile = this.getRoom().getLayout().getTile(x, y);
|
RoomTile baseTile = this.room.getLayout().getTile(x, y);
|
||||||
|
|
||||||
if (baseTile == null) return null;
|
if (baseTile == null) return null;
|
||||||
|
|
||||||
@ -412,75 +409,191 @@ public abstract class RoomUnit extends RoomEntity {
|
|||||||
|
|
||||||
return this.getClosestTile(
|
return this.getClosestTile(
|
||||||
rotations.stream()
|
rotations.stream()
|
||||||
.map(rotation -> this.getRoom().getLayout().getTileInFront(baseTile, rotation))
|
.map(rotation -> this.room.getLayout().getTileInFront(baseTile, rotation))
|
||||||
.filter(t -> t != null && t.isWalkable() && (this.getCurrentPosition().equals(t) || !this.getRoom().getRoomUnitManager().hasHabbosAt(t)))
|
.filter(t -> t != null && t.isWalkable() && (this.currentPosition.equals(t) || !this.room.getRoomUnitManager().hasHabbosAt(t)))
|
||||||
.toList()
|
.toList()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean handleSitStatus(RoomItem topItem) {
|
public void handleSitStatus() {
|
||||||
if(topItem == null || !topItem.getBaseItem().allowSit()) {
|
if(this.getCurrentItem() == null || !this.getCurrentItem().getBaseItem().allowSit()) {
|
||||||
return false;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!this.isCmdSitEnabled()) {
|
if(!this.isCmdSitEnabled()) {
|
||||||
if(this.getCurrentPosition().getState().equals(RoomTileState.SIT) && !this.hasStatus(RoomUnitStatus.SIT)) {
|
if(this.currentPosition.getState().equals(RoomTileState.SIT) && !this.hasStatus(RoomUnitStatus.SIT)) {
|
||||||
this.addStatus(RoomUnitStatus.SIT, String.valueOf(Item.getCurrentHeight(topItem)));
|
this.addStatus(RoomUnitStatus.SIT, String.valueOf(Item.getCurrentHeight(this.getCurrentItem())));
|
||||||
this.setCurrentZ(topItem.getCurrentZ());
|
this.setCurrentZ(this.getCurrentItem().getCurrentZ());
|
||||||
this.setRotation(RoomRotation.values()[topItem.getRotation()]);
|
this.setRotation(RoomRotation.values()[this.getCurrentItem().getRotation()]);
|
||||||
return true;
|
} else if(!this.getCurrentItem().getBaseItem().allowSit() && this.hasStatus(RoomUnitStatus.SIT)) {
|
||||||
} else if(!topItem.getBaseItem().allowSit() && this.hasStatus(RoomUnitStatus.SIT)) {
|
|
||||||
this.removeStatus(RoomUnitStatus.SIT);
|
this.removeStatus(RoomUnitStatus.SIT);
|
||||||
this.instantUpdate();
|
this.instantUpdate();
|
||||||
return true;
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
public void handleLayStatus() {
|
||||||
}
|
if(this.getCurrentItem() == null || !this.getCurrentItem().getBaseItem().allowLay()) {
|
||||||
|
return;
|
||||||
public boolean handleLayStatus(RoomItem topItem) {
|
|
||||||
if(topItem == null || !topItem.getBaseItem().allowLay()) {
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!this.isCmdLayEnabled()) {
|
if(!this.isCmdLayEnabled()) {
|
||||||
if(this.getCurrentPosition().getState().equals(RoomTileState.LAY) && !this.hasStatus(RoomUnitStatus.LAY)) {
|
if(this.currentPosition.getState().equals(RoomTileState.LAY) && !this.hasStatus(RoomUnitStatus.LAY)) {
|
||||||
this.addStatus(RoomUnitStatus.LAY, String.valueOf(Item.getCurrentHeight(topItem)));
|
this.addStatus(RoomUnitStatus.LAY, String.valueOf(Item.getCurrentHeight(this.getCurrentItem())));
|
||||||
this.setRotation(RoomRotation.values()[topItem.getRotation() % 4]);
|
this.setRotation(RoomRotation.values()[this.getCurrentItem().getRotation() % 4]);
|
||||||
|
} else if (!this.getCurrentItem().getBaseItem().allowLay() && this.hasStatus(RoomUnitStatus.LAY)) {
|
||||||
if (topItem.getRotation() == 0 || topItem.getRotation() == 4) {
|
|
||||||
this.setLocation(this.getRoom().getLayout().getTile(this.getCurrentPosition().getX(), topItem.getCurrentPosition().getY()));
|
|
||||||
} else {
|
|
||||||
this.setLocation(this.getRoom().getLayout().getTile(topItem.getCurrentPosition().getX(), this.getCurrentPosition().getY()));
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
} else if (!topItem.getBaseItem().allowLay() && this.hasStatus(RoomUnitStatus.LAY)) {
|
|
||||||
this.removeStatus(RoomUnitStatus.LAY);
|
this.removeStatus(RoomUnitStatus.LAY);
|
||||||
this.instantUpdate();
|
this.instantUpdate();
|
||||||
return true;
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
/**
|
||||||
}
|
* Performs an instant update of the character's status to the connected room, if needed.
|
||||||
|
* The method checks if a status update is required based on the internal flag `statusUpdateNeeded`.
|
||||||
|
* If an update is needed, the method sends the character's updated status information to the room
|
||||||
|
* using the {@link UserUpdateComposer}, effectively synchronizing the character's status with other room participants.
|
||||||
|
* After the update is sent, the `statusUpdateNeeded` flag is reset to false until the next change in the character's status.
|
||||||
|
* Note: This method is typically called when an immediate status update is necessary, such as when a status change occurs
|
||||||
|
* and should be communicated to other room users without delay.
|
||||||
|
*/
|
||||||
public void instantUpdate() {
|
public void instantUpdate() {
|
||||||
if(this.statusUpdateNeeded) {
|
if(this.statusUpdateNeeded) {
|
||||||
this.statusUpdateNeeded = false;
|
this.statusUpdateNeeded = false;
|
||||||
this.getRoom().sendComposer(new UserUpdateComposer(this).compose());
|
this.room.sendComposer(new UserUpdateComposer(this).compose());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Processes the character's walking behavior based on its current walking state.
|
||||||
|
* If the character is currently walking, the method executes the necessary steps to continue the movement.
|
||||||
|
* The process involves updating the character's status, position, rotation, and height while moving along the computed path.
|
||||||
|
* If the character reaches the destination tile, walking is stopped.
|
||||||
|
* If the character encounters an invalid tile during its path, it recalculates the path to find an alternative route.
|
||||||
|
* The method also handles fast walking when enabled, allowing the character to move more quickly through the path.
|
||||||
|
* Note: This method is typically called in a loop to facilitate continuous character movement.
|
||||||
|
*/
|
||||||
|
public void processWalking() {
|
||||||
|
if(this.isWalking()) {
|
||||||
|
this.statuses.entrySet().removeIf(entry -> entry.getKey().isRemoveWhenWalking());
|
||||||
|
|
||||||
|
if(this.getNextPosition() != null) {
|
||||||
|
this.currentPosition = this.getNextPosition();
|
||||||
|
this.currentZ = this.getNextZ();
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!this.path.isEmpty()) {
|
||||||
|
RoomTile next = this.path.poll();
|
||||||
|
|
||||||
|
if(this.path.size() > 1 && this.cmdFastWalkEnabled) {
|
||||||
|
next = this.path.poll();
|
||||||
|
}
|
||||||
|
|
||||||
|
if(next == null || !this.isValidTile(next)) {
|
||||||
|
this.path.clear();
|
||||||
|
this.findPath();
|
||||||
|
|
||||||
|
if(this.path.isEmpty()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
next = this.path.poll();
|
||||||
|
}
|
||||||
|
|
||||||
|
RoomRotation nextRotation = this.handleNextRotation(next);
|
||||||
|
double nextHeight = this.handleNextHeight(next);
|
||||||
|
|
||||||
|
this.setRotation(nextRotation);
|
||||||
|
this.addStatus(RoomUnitStatus.MOVE, next.getX() + "," + next.getY() + "," + nextHeight);
|
||||||
|
this.nextPosition = next;
|
||||||
|
this.nextZ = nextHeight;
|
||||||
|
} else {
|
||||||
|
this.stopWalking();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private RoomRotation handleNextRotation(RoomTile next) {
|
||||||
|
return RoomRotation.values()[Rotation.Calculate(this.currentPosition.getX(), this.currentPosition.getY(), next.getX(), next.getY())];
|
||||||
|
}
|
||||||
|
|
||||||
|
private double handleNextHeight(RoomTile next) {
|
||||||
|
double height = 0.0D;
|
||||||
|
|
||||||
|
RoomItem nextTileItem = this.room.getRoomItemManager().getTopItemAt(next);
|
||||||
|
|
||||||
|
if(nextTileItem != null) {
|
||||||
|
height += nextTileItem.getNextZ();
|
||||||
|
|
||||||
|
if (!nextTileItem.getBaseItem().allowSit() && !nextTileItem.getBaseItem().allowLay()) {
|
||||||
|
height += Item.getCurrentHeight(nextTileItem);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
height += this.room.getLayout().getHeightAtSquare(next.getX(), next.getY());
|
||||||
|
}
|
||||||
|
|
||||||
|
return height;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks whether the provided {@link RoomTile} is a valid tile for the character to walk on.
|
||||||
|
*
|
||||||
|
* @param tile The {@link RoomTile} to be validated.
|
||||||
|
* @return {@code true} if the tile is valid for walking, {@code false} otherwise.
|
||||||
|
* Returns {@code true} if the character can override the tile (e.g., walk on furniture).
|
||||||
|
* Otherwise, the method checks various conditions to determine the tile's validity:
|
||||||
|
* - The tile's height difference from the character's current height should be within the allowable step height range.
|
||||||
|
* - The tile should not be blocked, invalid, or have an open state with a height difference above the maximum step height.
|
||||||
|
* - If the room allows walkthrough, the tile should not be occupied by other room units (excluding the character's target position).
|
||||||
|
* - If the room disallows walkthrough, the tile should not be occupied by any room units.
|
||||||
|
* - If there's a room item on the tile, it is considered a valid tile.
|
||||||
|
*/
|
||||||
|
private boolean isValidTile(RoomTile tile) {
|
||||||
|
boolean canOverrideTile = this.canOverrideTile(tile);
|
||||||
|
if (canOverrideTile) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
double heightDifference = tile.getStackHeight() - this.currentZ;
|
||||||
|
|
||||||
|
boolean areRoomUnitsAtTile = this.room.getRoomUnitManager().areRoomUnitsAt(tile);
|
||||||
|
boolean isAboveMaximumStepHeight = (!RoomLayout.ALLOW_FALLING && heightDifference < -RoomLayout.MAXIMUM_STEP_HEIGHT);
|
||||||
|
boolean isOpenTileAboveMaxHeight = (tile.getState() == RoomTileState.OPEN && heightDifference > RoomLayout.MAXIMUM_STEP_HEIGHT);
|
||||||
|
boolean isTileBlocked = tile.getState().equals(RoomTileState.BLOCKED) || tile.getState().equals(RoomTileState.INVALID);
|
||||||
|
|
||||||
|
if(isTileBlocked || isAboveMaximumStepHeight || isOpenTileAboveMaxHeight) {
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
if(this.room.getRoomInfo().isAllowWalkthrough()) {
|
||||||
|
if(areRoomUnitsAtTile && !this.targetPosition.equals(tile)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if(areRoomUnitsAtTile) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
RoomItem item = this.room.getRoomItemManager().getTopItemAt(tile);
|
||||||
|
|
||||||
|
if(item != null) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
public void clear() {
|
public void clear() {
|
||||||
this.setRoom(null);
|
super.clear();
|
||||||
|
|
||||||
this.canWalk = true;
|
this.canWalk = true;
|
||||||
this.canRotate = true;
|
this.canRotate = true;
|
||||||
this.fastWalkEnabled = false;
|
this.cmdFastWalkEnabled = false;
|
||||||
this.cmdTeleportEnabled = false;
|
|
||||||
this.clearStatuses();
|
this.clearStatuses();
|
||||||
this.previousEffectId = 0;
|
this.previousEffectId = 0;
|
||||||
this.previousEffectEndTimestamp = -1;
|
this.previousEffectEndTimestamp = -1;
|
||||||
this.isKicked = false;
|
this.isKicked = false;
|
||||||
|
this.cacheable.clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,12 +1,10 @@
|
|||||||
package com.eu.habbo.habbohotel.rooms.entities.units.types;
|
package com.eu.habbo.habbohotel.rooms.entities.units.types;
|
||||||
|
|
||||||
import com.eu.habbo.Emulator;
|
import com.eu.habbo.Emulator;
|
||||||
import com.eu.habbo.habbohotel.items.Item;
|
|
||||||
import com.eu.habbo.habbohotel.items.interactions.interfaces.ConditionalGate;
|
|
||||||
import com.eu.habbo.habbohotel.pets.PetTasks;
|
import com.eu.habbo.habbohotel.pets.PetTasks;
|
||||||
import com.eu.habbo.habbohotel.pets.RideablePet;
|
import com.eu.habbo.habbohotel.pets.RideablePet;
|
||||||
import com.eu.habbo.habbohotel.rooms.*;
|
import com.eu.habbo.habbohotel.rooms.RoomTile;
|
||||||
import com.eu.habbo.habbohotel.rooms.entities.RoomRotation;
|
import com.eu.habbo.habbohotel.rooms.RoomUnitStatus;
|
||||||
import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem;
|
import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem;
|
||||||
import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit;
|
import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit;
|
||||||
import com.eu.habbo.habbohotel.users.DanceType;
|
import com.eu.habbo.habbohotel.users.DanceType;
|
||||||
@ -16,37 +14,33 @@ import com.eu.habbo.habbohotel.wired.WiredTriggerType;
|
|||||||
import com.eu.habbo.messages.outgoing.rooms.users.AvatarEffectMessageComposer;
|
import com.eu.habbo.messages.outgoing.rooms.users.AvatarEffectMessageComposer;
|
||||||
import com.eu.habbo.messages.outgoing.rooms.users.DanceMessageComposer;
|
import com.eu.habbo.messages.outgoing.rooms.users.DanceMessageComposer;
|
||||||
import com.eu.habbo.messages.outgoing.rooms.users.UserUpdateComposer;
|
import com.eu.habbo.messages.outgoing.rooms.users.UserUpdateComposer;
|
||||||
import com.eu.habbo.plugin.Event;
|
|
||||||
import com.eu.habbo.plugin.events.users.UserIdleEvent;
|
|
||||||
import com.eu.habbo.plugin.events.users.UserTakeStepEvent;
|
|
||||||
import com.eu.habbo.threading.runnables.RoomUnitKick;
|
|
||||||
import com.eu.habbo.util.pathfinding.Rotation;
|
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
import lombok.experimental.Accessors;
|
import lombok.experimental.Accessors;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@Getter
|
@Getter
|
||||||
@Setter
|
@Setter
|
||||||
@Accessors(chain = true)
|
@Accessors(chain = true)
|
||||||
public class RoomAvatar extends RoomUnit {
|
public class RoomAvatar extends RoomUnit {
|
||||||
private RideablePet rideablePet;
|
protected RideablePet ridingPet;
|
||||||
private boolean rideLock;
|
protected boolean rideLocked;
|
||||||
private DanceType danceType;
|
protected DanceType danceType;
|
||||||
private int handItem;
|
protected int handItem;
|
||||||
private long handItemTimestamp;
|
protected long handItemTimestamp;
|
||||||
private int effectId;
|
protected int effectId;
|
||||||
private int effectEndTimestamp;
|
protected int effectEndTimestamp;
|
||||||
private int previousEffectId;
|
protected int previousEffectId;
|
||||||
private int previousEffectEndTimestamp;
|
protected int previousEffectEndTimestamp;
|
||||||
|
|
||||||
public RoomAvatar() {
|
public RoomAvatar() {
|
||||||
super();
|
super();
|
||||||
|
|
||||||
this.rideablePet = null;
|
this.ridingPet = null;
|
||||||
this.danceType = DanceType.NONE;
|
this.danceType = DanceType.NONE;
|
||||||
this.handItem = 0;
|
this.handItem = 0;
|
||||||
this.handItemTimestamp = 0;
|
this.handItemTimestamp = 0;
|
||||||
@ -57,267 +51,61 @@ public class RoomAvatar extends RoomUnit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean cycle(Room room) {
|
public void cycle() {
|
||||||
try {
|
this.handleSignStatus();
|
||||||
if (this.hasStatus(RoomUnitStatus.SIGN)) {
|
this.processWalking();
|
||||||
this.getRoom().sendComposer(new UserUpdateComposer(this).compose());
|
|
||||||
this.removeStatus(RoomUnitStatus.SIGN);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!this.isWalking() || this.getPath() == null || this.getPath().isEmpty()) {
|
@Override
|
||||||
if (this.hasStatus(RoomUnitStatus.MOVE) && !this.isAnimateWalk()) {
|
public boolean walkTo(RoomTile goalLocation) {
|
||||||
this.removeStatus(RoomUnitStatus.MOVE);
|
if (this.hasStatus(RoomUnitStatus.LAY)) {
|
||||||
}
|
if (this.room.getLayout().getTilesInFront(this.getCurrentPosition(), this.getBodyRotation().getValue(), 2).contains(goalLocation))
|
||||||
|
|
||||||
if(!this.isWalking()) {
|
|
||||||
RoomItem topItem = this.getRoom().getRoomItemManager().getTopItemAt(this.getCurrentPosition());
|
|
||||||
return this.handleSitStatus(topItem) || this.handleLayStatus(topItem);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Habbo habbo = null;
|
|
||||||
boolean canFastWalk = false;
|
|
||||||
|
|
||||||
if(this instanceof RoomHabbo roomHabbo) {
|
|
||||||
habbo = room.getRoomUnitManager().getHabboByRoomUnit(roomHabbo);
|
|
||||||
canFastWalk = habbo == null || habbo.getHabboInfo().getRiding() == null;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (Map.Entry<RoomUnitStatus, String> set : this.getStatuses().entrySet()) {
|
|
||||||
if (set.getKey().isRemoveWhenWalking()) {
|
|
||||||
this.removeStatus(set.getKey());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.getPath() == null || this.getPath().isEmpty()) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
RoomTile next = this.getPath().poll();
|
|
||||||
boolean overrideTile = next != null && this.canOverrideTile(next);
|
|
||||||
|
|
||||||
if (this.getPath().isEmpty()) {
|
|
||||||
this.setSitUpdate(true);
|
|
||||||
|
|
||||||
if (next != null && room.getRoomUnitManager().areRoomUnitsAt(next) && !overrideTile) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Deque<RoomTile> peekPath = room.getLayout().findPath(this.getCurrentPosition(), this.getPath().peek(), this.getTargetPosition(), this);
|
|
||||||
|
|
||||||
if (peekPath == null) {
|
|
||||||
peekPath = new LinkedList<>();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (peekPath.size() >= 3) {
|
|
||||||
if (this.getPath().isEmpty()) {
|
|
||||||
this.setStatusUpdateNeeded(true);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.getPath().pop();
|
|
||||||
//peekPath.pop(); //Start
|
|
||||||
peekPath.removeLast(); //End
|
|
||||||
|
|
||||||
if (peekPath.peek() != next) {
|
|
||||||
next = peekPath.poll();
|
|
||||||
for (int i = 0; i < peekPath.size(); i++) {
|
|
||||||
this.getPath().addFirst(peekPath.removeLast());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (canFastWalk && this.isFastWalkEnabled() && this.getPath().size() > 1) {
|
|
||||||
next = this.getPath().poll();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (next == null) {
|
|
||||||
this.setStatusUpdateNeeded(true);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.removeStatus(RoomUnitStatus.DEAD);
|
|
||||||
|
|
||||||
if (habbo != null) {
|
|
||||||
RoomHabbo roomHabbo = (RoomHabbo) this;
|
|
||||||
if (roomHabbo.isIdle()) {
|
|
||||||
UserIdleEvent event = new UserIdleEvent(habbo, UserIdleEvent.IdleReason.WALKED, false);
|
|
||||||
Emulator.getPluginManager().fireEvent(event);
|
|
||||||
|
|
||||||
if (!event.isCancelled() && !event.isIdle()) {
|
|
||||||
roomHabbo.unIdle();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Emulator.getPluginManager().isRegistered(UserTakeStepEvent.class, false)) {
|
|
||||||
Event e = new UserTakeStepEvent(habbo, room.getLayout().getTile(this.getCurrentPosition().getX(), this.getCurrentPosition().getY()), next);
|
|
||||||
Emulator.getPluginManager().fireEvent(e);
|
|
||||||
|
|
||||||
if (e.isCancelled()) {
|
|
||||||
this.setStatusUpdateNeeded(true);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
RoomItem item = room.getRoomItemManager().getTopItemAt(next.getX(), next.getY());
|
|
||||||
|
|
||||||
double height = next.getStackHeight() - this.getCurrentPosition().getStackHeight();
|
|
||||||
|
|
||||||
if (!room.getLayout().tileWalkable(next) || (!RoomLayout.ALLOW_FALLING && height < -RoomLayout.MAXIMUM_STEP_HEIGHT) || (next.getState() == RoomTileState.OPEN && height > RoomLayout.MAXIMUM_STEP_HEIGHT)) {
|
|
||||||
this.getPath().clear();
|
|
||||||
this.findPath();
|
|
||||||
|
|
||||||
if (this.getPath().isEmpty()) {
|
|
||||||
this.removeStatus(RoomUnitStatus.MOVE);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
next = this.getPath().pop();
|
|
||||||
}
|
|
||||||
|
|
||||||
boolean canSitNextTile = room.canSitAt(next.getX(), next.getY());
|
|
||||||
|
|
||||||
if (canSitNextTile) {
|
|
||||||
RoomItem tallestChair = room.getRoomItemManager().getTallestChair(next);
|
|
||||||
|
|
||||||
if (tallestChair != null)
|
|
||||||
item = tallestChair;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (next.equals(this.getTargetPosition()) && next.getState() == RoomTileState.SIT && !overrideTile && (item == null || item.getCurrentZ() - this.getCurrentZ() > RoomLayout.MAXIMUM_STEP_HEIGHT)) {
|
|
||||||
this.removeStatus(RoomUnitStatus.MOVE);
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
double zHeight = 0.0D;
|
if (this.room.canLayAt(goalLocation)) {
|
||||||
|
RoomItem bed = this.room.getRoomItemManager().getTopItemAt(goalLocation.getX(), goalLocation.getY());
|
||||||
|
|
||||||
if(habbo != null && habbo.getHabboInfo().getRiding() != null) {
|
if (bed != null && bed.getBaseItem().allowLay()) {
|
||||||
zHeight += 1.0D;
|
this.room.getLayout().getTile(bed.getCurrentPosition().getX(), bed.getCurrentPosition().getY());
|
||||||
}
|
RoomTile pillow = switch (bed.getRotation()) {
|
||||||
|
case 0, 4 -> this.room.getLayout().getTile(goalLocation.getX(), bed.getCurrentPosition().getY());
|
||||||
|
case 2, 8 -> this.room.getLayout().getTile(bed.getCurrentPosition().getX(), goalLocation.getY());
|
||||||
|
default -> this.room.getLayout().getTile(bed.getCurrentPosition().getX(), bed.getCurrentPosition().getY());
|
||||||
|
};
|
||||||
|
|
||||||
RoomItem roomItem = room.getRoomItemManager().getTopItemAt(this.getCurrentPosition().getX(), this.getCurrentPosition().getY());
|
if (pillow != null && this.room.canLayAt(pillow)) {
|
||||||
if (roomItem != null && (roomItem != item || !RoomLayout.pointInSquare(roomItem.getCurrentPosition().getX(), roomItem.getCurrentPosition().getY(), roomItem.getCurrentPosition().getX() + roomItem.getBaseItem().getWidth() - 1, roomItem.getCurrentPosition().getY() + roomItem.getBaseItem().getLength() - 1, next.getX(), next.getY())))
|
goalLocation = pillow;
|
||||||
roomItem.onWalkOff(this, room, new Object[]{this.getCurrentPosition(), next});
|
|
||||||
|
|
||||||
|
|
||||||
this.incrementTilesMoved();
|
|
||||||
|
|
||||||
RoomRotation oldRotation = this.getBodyRotation();
|
|
||||||
|
|
||||||
this.setRotation(RoomRotation.values()[Rotation.Calculate(this.getCurrentPosition().getX(), this.getCurrentPosition().getY(), next.getX(), next.getY())]);
|
|
||||||
if (item != null) {
|
|
||||||
if (item != roomItem || !RoomLayout.pointInSquare(item.getCurrentPosition().getX(), item.getCurrentPosition().getY(), item.getCurrentPosition().getX() + item.getBaseItem().getWidth() - 1, item.getCurrentPosition().getY() + item.getBaseItem().getLength() - 1, this.getCurrentPosition().getX(), this.getCurrentPosition().getY())) {
|
|
||||||
if (item.canWalkOn(this, room, null)) {
|
|
||||||
item.onWalkOn(this, room, new Object[]{this.getCurrentPosition(), next});
|
|
||||||
} else if (item instanceof ConditionalGate conditionalGate) {
|
|
||||||
this.setRotation(oldRotation);
|
|
||||||
this.decrementTilesMoved();
|
|
||||||
this.setGoalLocation(this.getCurrentPosition());
|
|
||||||
this.removeStatus(RoomUnitStatus.MOVE);
|
|
||||||
this.instantUpdate();
|
|
||||||
|
|
||||||
if(this instanceof RoomHabbo) {
|
|
||||||
conditionalGate.onRejected(this, this.getRoom(), new Object[]{});
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
item.onWalk(this, room, new Object[]{this.getCurrentPosition(), next});
|
|
||||||
}
|
|
||||||
|
|
||||||
zHeight += item.getCurrentZ();
|
|
||||||
|
|
||||||
if (!item.getBaseItem().allowSit() && !item.getBaseItem().allowLay()) {
|
|
||||||
zHeight += Item.getCurrentHeight(item);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
zHeight += room.getLayout().getHeightAtSquare(next.getX(), next.getY());
|
|
||||||
}
|
|
||||||
|
|
||||||
this.setPreviousLocation(this.getCurrentPosition());
|
|
||||||
|
|
||||||
this.addStatus(RoomUnitStatus.MOVE, next.getX() + "," + next.getY() + "," + zHeight);
|
|
||||||
|
|
||||||
if(habbo != null) {
|
|
||||||
RideablePet rideablePet = habbo.getHabboInfo().getRiding();
|
|
||||||
|
|
||||||
if(rideablePet != null) {
|
|
||||||
RoomUnit ridingUnit = rideablePet.getRoomUnit();
|
|
||||||
|
|
||||||
if (ridingUnit != null) {
|
|
||||||
ridingUnit.setPreviousLocationZ(this.getCurrentZ());
|
|
||||||
this.setCurrentZ(zHeight - 1.0);
|
|
||||||
ridingUnit.setRotation(RoomRotation.values()[Rotation.Calculate(this.getCurrentPosition().getX(), this.getCurrentPosition().getY(), next.getX(), next.getY())]);
|
|
||||||
ridingUnit.setPreviousLocation(this.getCurrentPosition());
|
|
||||||
ridingUnit.setGoalLocation(this.getTargetPosition());
|
|
||||||
ridingUnit.addStatus(RoomUnitStatus.MOVE, next.getX() + "," + next.getY() + "," + (zHeight - 1.0));
|
|
||||||
room.sendComposer(new UserUpdateComposer(ridingUnit).compose());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.setCurrentZ(zHeight);
|
return super.walkTo(goalLocation);
|
||||||
this.setCurrentPosition(room.getLayout().getTile(next.getX(), next.getY()));
|
|
||||||
|
|
||||||
if(this instanceof RoomHabbo roomHabbo) {
|
|
||||||
roomHabbo.resetIdleTicks();
|
|
||||||
}
|
|
||||||
|
|
||||||
if(habbo != null) {
|
|
||||||
RoomItem topItem = room.getRoomItemManager().getTopItemAt(next);
|
|
||||||
|
|
||||||
boolean isAtDoor = next.getX() == room.getLayout().getDoorX() && next.getY() == room.getLayout().getDoorY();
|
|
||||||
boolean publicRoomKicks = !room.getRoomInfo().isPublicRoom() || Emulator.getConfig().getBoolean("hotel.room.public.doortile.kick");
|
|
||||||
boolean invalidated = topItem != null && topItem.invalidatesToRoomKick();
|
|
||||||
|
|
||||||
if (this.isCanLeaveRoomByDoor() && isAtDoor && publicRoomKicks && !invalidated) {
|
|
||||||
Emulator.getThreading().run(new RoomUnitKick(habbo, room, false), 500);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
|
|
||||||
} catch (Exception e) {
|
|
||||||
log.error("Caught exception", e);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void dismountPet(boolean isRemoving) {
|
public void dismountPet(boolean isRemoving) {
|
||||||
Habbo habbo = null;
|
if(!this.isRiding()) {
|
||||||
|
|
||||||
if(this instanceof RoomHabbo roomHabbo) {
|
|
||||||
habbo = this.getRoom().getRoomUnitManager().getHabboByRoomUnit(roomHabbo);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(habbo == null || habbo.getHabboInfo().getRiding() == null) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
RideablePet ridingPet = habbo.getHabboInfo().getRiding();
|
this.ridingPet.setRider(null);
|
||||||
|
this.ridingPet.setTask(PetTasks.FREE);
|
||||||
|
|
||||||
ridingPet.setRider(null);
|
this.ridingPet = null;
|
||||||
ridingPet.setTask(PetTasks.FREE);
|
|
||||||
|
|
||||||
habbo.getHabboInfo().setRiding(null);
|
|
||||||
|
|
||||||
this.giveEffect(0, -1);
|
this.giveEffect(0, -1);
|
||||||
this.setCurrentZ(ridingPet.getRoomUnit().getCurrentZ());
|
this.setCurrentZ(this.ridingPet.getRoomUnit().getCurrentZ());
|
||||||
this.setPreviousLocationZ(ridingPet.getRoomUnit().getCurrentZ());
|
|
||||||
this.stopWalking();
|
this.stopWalking();
|
||||||
|
|
||||||
ridingPet.getRoomUnit().stopWalking();
|
this.ridingPet.getRoomUnit().stopWalking();
|
||||||
|
|
||||||
this.instantUpdate();
|
this.instantUpdate();
|
||||||
ridingPet.getRoomUnit().instantUpdate();
|
this.ridingPet.getRoomUnit().instantUpdate();
|
||||||
|
|
||||||
List<RoomTile> availableTiles = isRemoving ? new ArrayList<>() : this.getRoom().getLayout().getWalkableTilesAround(this.getCurrentPosition());
|
List<RoomTile> availableTiles = isRemoving ? new ArrayList<>() : this.room.getLayout().getWalkableTilesAround(this.getCurrentPosition());
|
||||||
|
|
||||||
RoomTile tile = availableTiles.isEmpty() ? this.getCurrentPosition() : availableTiles.get(0);
|
RoomTile tile = availableTiles.isEmpty() ? this.getCurrentPosition() : availableTiles.get(0);
|
||||||
this.setGoalLocation(tile);
|
this.walkTo(tile);
|
||||||
this.setStatusUpdateNeeded(true);
|
this.setStatusUpdateNeeded(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -325,12 +113,12 @@ public class RoomAvatar extends RoomUnit {
|
|||||||
if (this.danceType != danceType) {
|
if (this.danceType != danceType) {
|
||||||
boolean isDancing = !this.danceType.equals(DanceType.NONE);
|
boolean isDancing = !this.danceType.equals(DanceType.NONE);
|
||||||
this.danceType = danceType;
|
this.danceType = danceType;
|
||||||
this.getRoom().sendComposer(new DanceMessageComposer(this).compose());
|
this.room.sendComposer(new DanceMessageComposer(this).compose());
|
||||||
|
|
||||||
if (danceType.equals(DanceType.NONE) && isDancing) {
|
if (danceType.equals(DanceType.NONE) && isDancing) {
|
||||||
WiredHandler.handle(WiredTriggerType.STOPS_DANCING, this, this.getRoom(), new Object[]{this});
|
WiredHandler.handle(WiredTriggerType.STOPS_DANCING, this, this.room, new Object[]{this});
|
||||||
} else if (!danceType.equals(DanceType.NONE) && !isDancing) {
|
} else if (!danceType.equals(DanceType.NONE) && !isDancing) {
|
||||||
WiredHandler.handle(WiredTriggerType.STARTS_DANCING, this, this.getRoom(), new Object[]{this});
|
WiredHandler.handle(WiredTriggerType.STARTS_DANCING, this, this.room, new Object[]{this});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -355,7 +143,7 @@ public class RoomAvatar extends RoomUnit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(this instanceof RoomHabbo) {
|
if(this instanceof RoomHabbo) {
|
||||||
Habbo habbo = this.getRoom().getRoomUnitManager().getHabboByRoomUnit(this);
|
Habbo habbo = this.room.getRoomUnitManager().getHabboByRoomUnit(this);
|
||||||
if(habbo == null || (habbo.getHabboInfo().isInGame() && !forceEffect)) {
|
if(habbo == null || (habbo.getHabboInfo().isInGame() && !forceEffect)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -367,11 +155,11 @@ public class RoomAvatar extends RoomUnit {
|
|||||||
duration += Emulator.getIntUnixTimestamp();
|
duration += Emulator.getIntUnixTimestamp();
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((this.getRoom().isAllowEffects() || forceEffect) && !this.isSwimming()) {
|
if ((this.room.isAllowEffects() || forceEffect) && !this.isSwimming()) {
|
||||||
this.effectId = effectId;
|
this.effectId = effectId;
|
||||||
this.effectEndTimestamp = duration;
|
this.effectEndTimestamp = duration;
|
||||||
|
|
||||||
this.getRoom().sendComposer(new AvatarEffectMessageComposer(this).compose());
|
this.room.sendComposer(new AvatarEffectMessageComposer(this).compose());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -380,11 +168,22 @@ public class RoomAvatar extends RoomUnit {
|
|||||||
this.previousEffectEndTimestamp = endTimestamp;
|
this.previousEffectEndTimestamp = endTimestamp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void handleSignStatus() {
|
||||||
|
if (this.hasStatus(RoomUnitStatus.SIGN)) {
|
||||||
|
this.room.sendComposer(new UserUpdateComposer(this).compose());
|
||||||
|
this.removeStatus(RoomUnitStatus.SIGN);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isRiding() {
|
||||||
|
return this.ridingPet != null;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void clear() {
|
public void clear() {
|
||||||
super.clear();
|
super.clear();
|
||||||
|
|
||||||
this.rideablePet = null;
|
this.ridingPet = null;
|
||||||
this.danceType = DanceType.NONE;
|
this.danceType = DanceType.NONE;
|
||||||
this.handItem = 0;
|
this.handItem = 0;
|
||||||
this.handItemTimestamp = 0;
|
this.handItemTimestamp = 0;
|
||||||
|
@ -1,71 +1,20 @@
|
|||||||
package com.eu.habbo.habbohotel.rooms.entities.units.types;
|
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.bots.Bot;
|
||||||
import com.eu.habbo.habbohotel.rooms.Room;
|
|
||||||
import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnitType;
|
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;
|
import lombok.Getter;
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
public class RoomBot extends RoomAvatar {
|
public class RoomBot extends RoomAvatar {
|
||||||
|
private Bot unit;
|
||||||
|
|
||||||
public RoomBot() {
|
public RoomBot() {
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean cycle(Room room) {
|
public void cycle() {
|
||||||
Bot bot = this.getRoom().getRoomUnitManager().getBotByRoomUnit(this);
|
super.cycle();
|
||||||
|
|
||||||
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() {
|
public RoomUnitType getRoomUnitType() {
|
||||||
|
@ -1,11 +1,17 @@
|
|||||||
package com.eu.habbo.habbohotel.rooms.entities.units.types;
|
package com.eu.habbo.habbohotel.rooms.entities.units.types;
|
||||||
|
|
||||||
|
import com.eu.habbo.Emulator;
|
||||||
|
import com.eu.habbo.habbohotel.pets.PetTasks;
|
||||||
import com.eu.habbo.habbohotel.rooms.Room;
|
import com.eu.habbo.habbohotel.rooms.Room;
|
||||||
|
import com.eu.habbo.habbohotel.rooms.RoomTile;
|
||||||
import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnitType;
|
import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnitType;
|
||||||
import com.eu.habbo.habbohotel.users.DanceType;
|
import com.eu.habbo.habbohotel.users.DanceType;
|
||||||
|
import com.eu.habbo.habbohotel.users.Habbo;
|
||||||
import com.eu.habbo.habbohotel.wired.WiredHandler;
|
import com.eu.habbo.habbohotel.wired.WiredHandler;
|
||||||
import com.eu.habbo.habbohotel.wired.WiredTriggerType;
|
import com.eu.habbo.habbohotel.wired.WiredTriggerType;
|
||||||
|
import com.eu.habbo.messages.outgoing.rooms.users.RoomUnitOnRollerComposer;
|
||||||
import com.eu.habbo.messages.outgoing.rooms.users.SleepMessageComposer;
|
import com.eu.habbo.messages.outgoing.rooms.users.SleepMessageComposer;
|
||||||
|
import com.eu.habbo.plugin.events.users.UserIdleEvent;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
import lombok.experimental.Accessors;
|
import lombok.experimental.Accessors;
|
||||||
@ -16,9 +22,12 @@ import lombok.extern.slf4j.Slf4j;
|
|||||||
@Setter
|
@Setter
|
||||||
@Accessors(chain = true)
|
@Accessors(chain = true)
|
||||||
public class RoomHabbo extends RoomAvatar {
|
public class RoomHabbo extends RoomAvatar {
|
||||||
|
private Habbo unit;
|
||||||
private Room loadingRoom;
|
private Room loadingRoom;
|
||||||
private Room previousRoom;
|
private Room previousRoom;
|
||||||
|
|
||||||
|
private boolean cmdTeleportEnabled;
|
||||||
|
|
||||||
// @Setter
|
// @Setter
|
||||||
// private boolean isKicked;
|
// private boolean isKicked;
|
||||||
private int kickCount;
|
private int kickCount;
|
||||||
@ -28,13 +37,50 @@ public class RoomHabbo extends RoomAvatar {
|
|||||||
|
|
||||||
public RoomHabbo() {
|
public RoomHabbo() {
|
||||||
super();
|
super();
|
||||||
|
this.cmdTeleportEnabled = false;
|
||||||
// this.isKicked = false;
|
// this.isKicked = false;
|
||||||
// this.overridableTiles = new HashSet<>();
|
// this.overridableTiles = new HashSet<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean cycle(Room room) {
|
@Override
|
||||||
return super.cycle(room);
|
public void cycle() {
|
||||||
|
super.cycle();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean walkTo(RoomTile goalLocation) {
|
||||||
|
if(this.rideLocked || this.isTeleporting() || this.isKicked()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(this.cmdTeleportEnabled) {
|
||||||
|
if (this.isRiding()) {
|
||||||
|
this.room.sendComposer(new RoomUnitOnRollerComposer(this, null, this.currentPosition, this.currentZ, goalLocation, goalLocation.getStackHeight() + 1.0D, this.room).compose());
|
||||||
|
this.room.sendComposer(new RoomUnitOnRollerComposer(this.ridingPet.getRoomUnit(), goalLocation, this.room).compose());
|
||||||
|
} else {
|
||||||
|
this.room.sendComposer(new RoomUnitOnRollerComposer(this, goalLocation, this.room).compose());
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.isRiding() && this.ridingPet.getTask() != null && this.ridingPet.getTask().equals(PetTasks.JUMP)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Reset idle status
|
||||||
|
if (this.isIdle()) {
|
||||||
|
UserIdleEvent event = new UserIdleEvent(this.unit, UserIdleEvent.IdleReason.WALKED, false);
|
||||||
|
Emulator.getPluginManager().fireEvent(event);
|
||||||
|
|
||||||
|
if (!event.isCancelled()) {
|
||||||
|
if (!event.isIdle()) {
|
||||||
|
this.unIdle();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return super.walkTo(goalLocation);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isLoadingRoom() {
|
public boolean isLoadingRoom() {
|
||||||
@ -56,17 +102,17 @@ public class RoomHabbo extends RoomAvatar {
|
|||||||
this.setDance(DanceType.NONE);
|
this.setDance(DanceType.NONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.getRoom().sendComposer(new SleepMessageComposer(this).compose());
|
this.room.sendComposer(new SleepMessageComposer(this).compose());
|
||||||
|
|
||||||
WiredHandler.handle(WiredTriggerType.IDLES, this, this.getRoom(), new Object[]{this});
|
WiredHandler.handle(WiredTriggerType.IDLES, this, this.room, new Object[]{this});
|
||||||
}
|
}
|
||||||
|
|
||||||
public void unIdle() {
|
public void unIdle() {
|
||||||
this.resetIdleTicks();
|
this.resetIdleTicks();
|
||||||
|
|
||||||
this.getRoom().sendComposer(new SleepMessageComposer(this).compose());
|
this.room.sendComposer(new SleepMessageComposer(this).compose());
|
||||||
|
|
||||||
WiredHandler.handle(WiredTriggerType.UNIDLES, this, this.getRoom(), new Object[]{this});
|
WiredHandler.handle(WiredTriggerType.UNIDLES, this, this.room, new Object[]{this});
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isIdle() {
|
public boolean isIdle() {
|
||||||
@ -92,5 +138,6 @@ public class RoomHabbo extends RoomAvatar {
|
|||||||
@Override
|
@Override
|
||||||
public void clear() {
|
public void clear() {
|
||||||
super.clear();
|
super.clear();
|
||||||
|
this.cmdTeleportEnabled = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,184 +1,24 @@
|
|||||||
package com.eu.habbo.habbohotel.rooms.entities.units.types;
|
package com.eu.habbo.habbohotel.rooms.entities.units.types;
|
||||||
|
|
||||||
import com.eu.habbo.habbohotel.items.Item;
|
|
||||||
import com.eu.habbo.habbohotel.items.interactions.interfaces.ConditionalGate;
|
|
||||||
import com.eu.habbo.habbohotel.pets.Pet;
|
import com.eu.habbo.habbohotel.pets.Pet;
|
||||||
import com.eu.habbo.habbohotel.pets.RideablePet;
|
import com.eu.habbo.habbohotel.pets.RideablePet;
|
||||||
import com.eu.habbo.habbohotel.rooms.*;
|
import com.eu.habbo.habbohotel.rooms.Room;
|
||||||
import com.eu.habbo.habbohotel.rooms.entities.RoomRotation;
|
import com.eu.habbo.habbohotel.rooms.RoomUnitStatus;
|
||||||
import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem;
|
|
||||||
import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit;
|
import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit;
|
||||||
import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnitType;
|
import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnitType;
|
||||||
import com.eu.habbo.habbohotel.users.Habbo;
|
import com.eu.habbo.habbohotel.users.Habbo;
|
||||||
import com.eu.habbo.util.pathfinding.Rotation;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
import java.util.Deque;
|
|
||||||
import java.util.LinkedList;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class RoomPet extends RoomUnit {
|
public class RoomPet extends RoomUnit {
|
||||||
|
private Pet unit;
|
||||||
|
|
||||||
public RoomPet() {
|
public RoomPet() {
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean cycle(Room room) {
|
public void cycle() {}
|
||||||
try {
|
|
||||||
Pet pet = this.getRoom().getRoomUnitManager().getPetByRoomUnit(this);
|
|
||||||
|
|
||||||
if(pet == null) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.handleRider(pet, room)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!this.isWalking() || this.getPath() == null || this.getPath().isEmpty()) {
|
|
||||||
if (this.hasStatus(RoomUnitStatus.MOVE) && !this.isAnimateWalk()) {
|
|
||||||
this.removeStatus(RoomUnitStatus.MOVE);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!this.isWalking()) {
|
|
||||||
RoomItem topItem = this.getRoom().getRoomItemManager().getTopItemAt(this.getCurrentPosition());
|
|
||||||
return this.handleSitStatus(topItem) || this.handleLayStatus(topItem);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (Map.Entry<RoomUnitStatus, String> set : this.getStatuses().entrySet()) {
|
|
||||||
if (set.getKey().isRemoveWhenWalking()) {
|
|
||||||
this.removeStatus(set.getKey());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.getPath() == null || this.getPath().isEmpty()) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
RoomTile next = this.getPath().poll();
|
|
||||||
boolean overrideChecks = next != null && this.canOverrideTile(next);
|
|
||||||
|
|
||||||
if (this.getPath().isEmpty()) {
|
|
||||||
this.setSitUpdate(true);
|
|
||||||
|
|
||||||
if (next != null && room.getRoomUnitManager().areRoomUnitsAt(next) && !overrideChecks) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Deque<RoomTile> peekPath = room.getLayout().findPath(this.getCurrentPosition(), this.getPath().peek(), this.getTargetPosition(), this);
|
|
||||||
|
|
||||||
if (peekPath == null) {
|
|
||||||
peekPath = new LinkedList<>();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (peekPath.size() >= 3) {
|
|
||||||
if (this.getPath().isEmpty()) {
|
|
||||||
this.setStatusUpdateNeeded(true);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.getPath().pop();
|
|
||||||
//peekPath.pop(); //Start
|
|
||||||
peekPath.removeLast(); //End
|
|
||||||
|
|
||||||
if (peekPath.peek() != next) {
|
|
||||||
next = peekPath.poll();
|
|
||||||
for (int i = 0; i < peekPath.size(); i++) {
|
|
||||||
this.getPath().addFirst(peekPath.removeLast());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (next == null) {
|
|
||||||
this.setStatusUpdateNeeded(true);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.removeStatus(RoomUnitStatus.DEAD);
|
|
||||||
|
|
||||||
RoomItem item = room.getRoomItemManager().getTopItemAt(next.getX(), next.getY());
|
|
||||||
|
|
||||||
double height = next.getStackHeight() - this.getCurrentPosition().getStackHeight();
|
|
||||||
if (!room.getLayout().tileWalkable(next) || (!RoomLayout.ALLOW_FALLING && height < -RoomLayout.MAXIMUM_STEP_HEIGHT) || (next.getState() == RoomTileState.OPEN && height > RoomLayout.MAXIMUM_STEP_HEIGHT)) {
|
|
||||||
this.getPath().clear();
|
|
||||||
this.findPath();
|
|
||||||
|
|
||||||
if (this.getPath().isEmpty()) {
|
|
||||||
this.removeStatus(RoomUnitStatus.MOVE);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
next = this.getPath().pop();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
boolean canSitNextTile = room.canSitAt(next.getX(), next.getY());
|
|
||||||
|
|
||||||
if (canSitNextTile) {
|
|
||||||
RoomItem tallestChair = room.getRoomItemManager().getTallestChair(next);
|
|
||||||
|
|
||||||
if (tallestChair != null)
|
|
||||||
item = tallestChair;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (next.equals(this.getTargetPosition()) && next.getState() == RoomTileState.SIT && !overrideChecks && (item == null || item.getCurrentZ() - this.getCurrentZ() > RoomLayout.MAXIMUM_STEP_HEIGHT)) {
|
|
||||||
this.removeStatus(RoomUnitStatus.MOVE);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
double zHeight = 0.0D;
|
|
||||||
|
|
||||||
RoomItem roomItem = room.getRoomItemManager().getTopItemAt(this.getCurrentPosition().getX(), this.getCurrentPosition().getY());
|
|
||||||
if (roomItem != null && (roomItem != item || !RoomLayout.pointInSquare(roomItem.getCurrentPosition().getX(), roomItem.getCurrentPosition().getY(), roomItem.getCurrentPosition().getX() + roomItem.getBaseItem().getWidth() - 1, roomItem.getCurrentPosition().getY() + roomItem.getBaseItem().getLength() - 1, next.getX(), next.getY())))
|
|
||||||
roomItem.onWalkOff(this, room, new Object[]{this.getCurrentPosition(), next});
|
|
||||||
|
|
||||||
|
|
||||||
this.incrementTilesMoved();
|
|
||||||
|
|
||||||
RoomRotation oldRotation = this.getBodyRotation();
|
|
||||||
this.setRotation(RoomRotation.values()[Rotation.Calculate(this.getCurrentPosition().getX(), this.getCurrentPosition().getY(), next.getX(), next.getY())]);
|
|
||||||
if (item != null) {
|
|
||||||
if (item != roomItem || !RoomLayout.pointInSquare(item.getCurrentPosition().getX(), item.getCurrentPosition().getY(), item.getCurrentPosition().getX() + item.getBaseItem().getWidth() - 1, item.getCurrentPosition().getY() + item.getBaseItem().getLength() - 1, this.getCurrentPosition().getX(), this.getCurrentPosition().getY())) {
|
|
||||||
if (item.canWalkOn(this, room, null)) {
|
|
||||||
item.onWalkOn(this, room, new Object[]{this.getCurrentPosition(), next});
|
|
||||||
} else if (item instanceof ConditionalGate conditionalGate) {
|
|
||||||
this.setRotation(oldRotation);
|
|
||||||
this.decrementTilesMoved();
|
|
||||||
this.setGoalLocation(this.getCurrentPosition());
|
|
||||||
this.removeStatus(RoomUnitStatus.MOVE);
|
|
||||||
this.instantUpdate();
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
item.onWalk(this, room, new Object[]{this.getCurrentPosition(), next});
|
|
||||||
}
|
|
||||||
|
|
||||||
zHeight += item.getCurrentZ();
|
|
||||||
|
|
||||||
if (!item.getBaseItem().allowSit() && !item.getBaseItem().allowLay()) {
|
|
||||||
zHeight += Item.getCurrentHeight(item);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
zHeight += room.getLayout().getHeightAtSquare(next.getX(), next.getY());
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
this.setPreviousLocation(this.getCurrentPosition());
|
|
||||||
|
|
||||||
this.addStatus(RoomUnitStatus.MOVE, next.getX() + "," + next.getY() + "," + zHeight);
|
|
||||||
|
|
||||||
this.setCurrentZ(zHeight);
|
|
||||||
this.setCurrentPosition(room.getLayout().getTile(next.getX(), next.getY()));
|
|
||||||
|
|
||||||
return false;
|
|
||||||
} catch (Exception e) {
|
|
||||||
log.error("Caught exception", e);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean handleRider(Pet pet, Room room) {
|
public boolean handleRider(Pet pet, Room room) {
|
||||||
Habbo rider = null;
|
Habbo rider = null;
|
||||||
@ -198,8 +38,6 @@ public class RoomPet extends RoomUnit {
|
|||||||
|
|
||||||
if (!this.getCurrentPosition().equals(rider.getRoomUnit().getCurrentPosition())) {
|
if (!this.getCurrentPosition().equals(rider.getRoomUnit().getCurrentPosition())) {
|
||||||
this.addStatus(RoomUnitStatus.MOVE, rider.getRoomUnit().getCurrentPosition().getX() + "," + rider.getRoomUnit().getCurrentPosition().getY() + "," + (rider.getRoomUnit().getCurrentPosition().getStackHeight()));
|
this.addStatus(RoomUnitStatus.MOVE, rider.getRoomUnit().getCurrentPosition().getX() + "," + rider.getRoomUnit().getCurrentPosition().getY() + "," + (rider.getRoomUnit().getCurrentPosition().getStackHeight()));
|
||||||
this.setPreviousLocation(rider.getRoomUnit().getPreviousPosition());
|
|
||||||
this.setPreviousLocationZ(rider.getRoomUnit().getPreviousPosition().getStackHeight());
|
|
||||||
this.setCurrentPosition(rider.getRoomUnit().getCurrentPosition());
|
this.setCurrentPosition(rider.getRoomUnit().getCurrentPosition());
|
||||||
this.setCurrentZ(rider.getRoomUnit().getCurrentPosition().getStackHeight());
|
this.setCurrentZ(rider.getRoomUnit().getCurrentPosition().getStackHeight());
|
||||||
}
|
}
|
||||||
|
@ -6,6 +6,6 @@ import lombok.Setter;
|
|||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
@Setter
|
@Setter
|
||||||
public class Unit {
|
public abstract class Unit {
|
||||||
private RoomUnit roomUnit;
|
private RoomUnit roomUnit;
|
||||||
}
|
}
|
@ -70,6 +70,8 @@ public class Habbo extends Unit implements Runnable {
|
|||||||
this.messenger.loadFriendRequests(this);
|
this.messenger.loadFriendRequests(this);
|
||||||
|
|
||||||
this.roomUnit = new RoomHabbo();
|
this.roomUnit = new RoomHabbo();
|
||||||
|
this.roomUnit.setUnit(this);
|
||||||
|
|
||||||
this.update = false;
|
this.update = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,7 +8,6 @@ import com.eu.habbo.habbohotel.games.GamePlayer;
|
|||||||
import com.eu.habbo.habbohotel.messenger.MessengerCategory;
|
import com.eu.habbo.habbohotel.messenger.MessengerCategory;
|
||||||
import com.eu.habbo.habbohotel.navigation.NavigatorSavedSearch;
|
import com.eu.habbo.habbohotel.navigation.NavigatorSavedSearch;
|
||||||
import com.eu.habbo.habbohotel.permissions.PermissionGroup;
|
import com.eu.habbo.habbohotel.permissions.PermissionGroup;
|
||||||
import com.eu.habbo.habbohotel.pets.RideablePet;
|
|
||||||
import gnu.trove.map.hash.TIntIntHashMap;
|
import gnu.trove.map.hash.TIntIntHashMap;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
@ -40,7 +39,6 @@ public class HabboInfo implements Runnable {
|
|||||||
private int homeRoom;
|
private int homeRoom;
|
||||||
private boolean online;
|
private boolean online;
|
||||||
private int roomQueueId;
|
private int roomQueueId;
|
||||||
private RideablePet riding;
|
|
||||||
private Class<? extends Game> currentGame;
|
private Class<? extends Game> currentGame;
|
||||||
private TIntIntHashMap currencies;
|
private TIntIntHashMap currencies;
|
||||||
private GamePlayer gamePlayer;
|
private GamePlayer gamePlayer;
|
||||||
|
@ -28,9 +28,7 @@ public class QuitEvent extends MessageHandler {
|
|||||||
this.client.sendResponse(new CloseConnectionMessageComposer());
|
this.client.sendResponse(new CloseConnectionMessageComposer());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (roomHabbo != null) {
|
roomHabbo.clear();
|
||||||
roomHabbo.clearWalking();
|
|
||||||
roomHabbo.setInRoom(false);
|
roomHabbo.setInRoom(false);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -35,7 +35,9 @@ public class CustomizeAvatarWithFurniEvent extends MessageHandler {
|
|||||||
|
|
||||||
if (clothing != null) {
|
if (clothing != null) {
|
||||||
if (!this.client.getHabbo().getInventory().getWardrobeComponent().getClothing().contains(clothing.getId())) {
|
if (!this.client.getHabbo().getInventory().getWardrobeComponent().getClothing().contains(clothing.getId())) {
|
||||||
|
//Deprecated
|
||||||
item.setRoomId(0);
|
item.setRoomId(0);
|
||||||
|
item.setRoom(null);
|
||||||
RoomTile tile = this.client.getHabbo().getRoomUnit().getRoom().getLayout().getTile(item.getCurrentPosition().getX(), item.getCurrentPosition().getY());
|
RoomTile tile = this.client.getHabbo().getRoomUnit().getRoom().getLayout().getTile(item.getCurrentPosition().getX(), item.getCurrentPosition().getY());
|
||||||
this.client.getHabbo().getRoomUnit().getRoom().getRoomItemManager().removeRoomItem(item);
|
this.client.getHabbo().getRoomUnit().getRoom().getRoomItemManager().removeRoomItem(item);
|
||||||
this.client.getHabbo().getRoomUnit().getRoom().updateTile(tile);
|
this.client.getHabbo().getRoomUnit().getRoom().updateTile(tile);
|
||||||
|
@ -29,7 +29,9 @@ public class PlacePostItEvent extends MessageHandler {
|
|||||||
if (room.getPostItNotes().size() < Room.MAXIMUM_POSTITNOTES) {
|
if (room.getPostItNotes().size() < Room.MAXIMUM_POSTITNOTES) {
|
||||||
room.getRoomItemManager().addRoomItem(item);
|
room.getRoomItemManager().addRoomItem(item);
|
||||||
item.setExtraData("FFFF33");
|
item.setExtraData("FFFF33");
|
||||||
|
//Deprecated
|
||||||
item.setRoomId(this.client.getHabbo().getRoomUnit().getRoom().getRoomInfo().getId());
|
item.setRoomId(this.client.getHabbo().getRoomUnit().getRoom().getRoomInfo().getId());
|
||||||
|
item.setRoom(this.client.getHabbo().getRoomUnit().getRoom());
|
||||||
item.setWallPosition(location);
|
item.setWallPosition(location);
|
||||||
item.setOwnerInfo(this.client.getHabbo().getHabboInfo());
|
item.setOwnerInfo(this.client.getHabbo().getHabboInfo());
|
||||||
item.needsUpdate(true);
|
item.needsUpdate(true);
|
||||||
|
@ -24,7 +24,9 @@ public class RemoveItemEvent extends MessageHandler {
|
|||||||
|
|
||||||
if (item instanceof InteractionPostIt || item instanceof InteractionExternalImage) {
|
if (item instanceof InteractionPostIt || item instanceof InteractionExternalImage) {
|
||||||
if (item.getOwnerInfo().getId() == this.client.getHabbo().getHabboInfo().getId() || this.client.getHabbo().hasPermissionRight(Permission.ACC_ANYROOMOWNER)) {
|
if (item.getOwnerInfo().getId() == this.client.getHabbo().getHabboInfo().getId() || this.client.getHabbo().hasPermissionRight(Permission.ACC_ANYROOMOWNER)) {
|
||||||
|
//Deprecated
|
||||||
item.setRoomId(0);
|
item.setRoomId(0);
|
||||||
|
item.setRoom(null);
|
||||||
room.getRoomItemManager().removeRoomItem(item);
|
room.getRoomItemManager().removeRoomItem(item);
|
||||||
room.sendComposer(new ItemRemoveMessageComposer(item).compose());
|
room.sendComposer(new ItemRemoveMessageComposer(item).compose());
|
||||||
Emulator.getThreading().run(new QueryDeleteHabboItem(item.getId()));
|
Emulator.getThreading().run(new QueryDeleteHabboItem(item.getId()));
|
||||||
|
@ -85,7 +85,9 @@ public class CustomizePetWithFurniEvent extends MessageHandler {
|
|||||||
|
|
||||||
room.getRoomItemManager().removeRoomItem(item);
|
room.getRoomItemManager().removeRoomItem(item);
|
||||||
room.sendComposer(new RemoveFloorItemComposer(item, true).compose());
|
room.sendComposer(new RemoveFloorItemComposer(item, true).compose());
|
||||||
|
//Deprecated
|
||||||
item.setRoomId(0);
|
item.setRoomId(0);
|
||||||
|
item.setRoom(null);
|
||||||
Emulator.getGameEnvironment().getItemManager().deleteItem(item);
|
Emulator.getGameEnvironment().getItemManager().deleteItem(item);
|
||||||
}
|
}
|
||||||
} else if (pet instanceof MonsterplantPet) {
|
} else if (pet instanceof MonsterplantPet) {
|
||||||
|
@ -29,8 +29,8 @@ public class MountPetEvent extends MessageHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//dismount
|
//dismount
|
||||||
if (habbo.getHabboInfo().getRiding() != null) {
|
if (habbo.getRoomUnit().isRiding()) {
|
||||||
boolean mountAnotherPet = petId != habbo.getHabboInfo().getRiding().getId();
|
boolean mountAnotherPet = petId != habbo.getRoomUnit().getRidingPet().getId();
|
||||||
|
|
||||||
habbo.getRoomUnit().dismountPet(false);
|
habbo.getRoomUnit().dismountPet(false);
|
||||||
|
|
||||||
@ -57,8 +57,8 @@ public class MountPetEvent extends MessageHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
RoomTile goalTile = availableTiles.get(0);
|
RoomTile goalTile = availableTiles.get(0);
|
||||||
habbo.getRoomUnit().setGoalLocation(goalTile);
|
habbo.getRoomUnit().walkTo(goalTile);
|
||||||
habbo.getRoomUnit().setRideLock(true);
|
habbo.getRoomUnit().setRideLocked(true);
|
||||||
Emulator.getThreading().run(new RoomUnitRidePet(rideablePet, habbo, goalTile));
|
Emulator.getThreading().run(new RoomUnitRidePet(rideablePet, habbo, goalTile));
|
||||||
rideablePet.getRoomUnit().setWalkTimeOut(3 + Emulator.getIntUnixTimestamp());
|
rideablePet.getRoomUnit().setWalkTimeOut(3 + Emulator.getIntUnixTimestamp());
|
||||||
rideablePet.getRoomUnit().stopWalking();
|
rideablePet.getRoomUnit().stopWalking();
|
||||||
|
@ -24,10 +24,8 @@ public class MovePetEvent extends MessageHandler {
|
|||||||
|
|
||||||
if (tile != null) {
|
if (tile != null) {
|
||||||
pet.getRoomUnit().setLocation(tile);
|
pet.getRoomUnit().setLocation(tile);
|
||||||
pet.getRoomUnit().setPreviousLocation(tile);
|
|
||||||
pet.getRoomUnit().setCurrentZ(tile.getZ());
|
pet.getRoomUnit().setCurrentZ(tile.getZ());
|
||||||
pet.getRoomUnit().setRotation(RoomRotation.fromValue(this.packet.readInt()));
|
pet.getRoomUnit().setRotation(RoomRotation.fromValue(this.packet.readInt()));
|
||||||
pet.getRoomUnit().setPreviousLocationZ(pet.getRoomUnit().getCurrentZ());
|
|
||||||
room.sendComposer(new UserUpdateComposer(pet.getRoomUnit()).compose());
|
room.sendComposer(new UserUpdateComposer(pet.getRoomUnit()).compose());
|
||||||
pet.setNeedsUpdate(true);
|
pet.setNeedsUpdate(true);
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,6 @@ import com.eu.habbo.habbohotel.pets.Pet;
|
|||||||
import com.eu.habbo.habbohotel.rooms.Room;
|
import com.eu.habbo.habbohotel.rooms.Room;
|
||||||
import com.eu.habbo.habbohotel.rooms.RoomTile;
|
import com.eu.habbo.habbohotel.rooms.RoomTile;
|
||||||
import com.eu.habbo.habbohotel.rooms.RoomUnitStatus;
|
import com.eu.habbo.habbohotel.rooms.RoomUnitStatus;
|
||||||
import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit;
|
|
||||||
import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnitType;
|
import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnitType;
|
||||||
import com.eu.habbo.habbohotel.rooms.entities.units.types.RoomPet;
|
import com.eu.habbo.habbohotel.rooms.entities.units.types.RoomPet;
|
||||||
import com.eu.habbo.messages.incoming.MessageHandler;
|
import com.eu.habbo.messages.incoming.MessageHandler;
|
||||||
@ -17,6 +16,7 @@ import com.eu.habbo.messages.outgoing.rooms.pets.RoomPetComposer;
|
|||||||
public class PlacePetEvent extends MessageHandler {
|
public class PlacePetEvent extends MessageHandler {
|
||||||
@Override
|
@Override
|
||||||
public void handle() {
|
public void handle() {
|
||||||
|
//TODO Improve This
|
||||||
Room room = this.client.getHabbo().getRoomUnit().getRoom();
|
Room room = this.client.getHabbo().getRoomUnit().getRoom();
|
||||||
|
|
||||||
if (room == null)
|
if (room == null)
|
||||||
@ -74,22 +74,23 @@ public class PlacePetEvent extends MessageHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pet.setRoom(room);
|
pet.setRoom(room);
|
||||||
RoomUnit roomUnit = pet.getRoomUnit();
|
RoomPet roomPet = pet.getRoomUnit();
|
||||||
|
|
||||||
if (roomUnit == null) {
|
if (roomPet == null) {
|
||||||
roomUnit = new RoomPet();
|
roomPet = new RoomPet();
|
||||||
|
roomPet.setUnit(pet);
|
||||||
}
|
}
|
||||||
|
|
||||||
roomUnit.setRoom(room);
|
roomPet.setRoom(room);
|
||||||
|
|
||||||
roomUnit.setLocation(tile);
|
roomPet.setLocation(tile);
|
||||||
roomUnit.setCurrentZ(tile.getStackHeight());
|
roomPet.setCurrentZ(tile.getStackHeight());
|
||||||
roomUnit.addStatus(RoomUnitStatus.SIT, "0");
|
roomPet.addStatus(RoomUnitStatus.SIT, "0");
|
||||||
roomUnit.setRoomUnitType(RoomUnitType.PET);
|
roomPet.setRoomUnitType(RoomUnitType.PET);
|
||||||
if (playerTile != null) {
|
if (playerTile != null) {
|
||||||
roomUnit.lookAtPoint(playerTile);
|
roomPet.lookAtPoint(playerTile);
|
||||||
}
|
}
|
||||||
pet.setRoomUnit(roomUnit);
|
pet.setRoomUnit(roomPet);
|
||||||
room.getRoomUnitManager().addRoomUnit(pet);
|
room.getRoomUnitManager().addRoomUnit(pet);
|
||||||
pet.setNeedsUpdate(true);
|
pet.setNeedsUpdate(true);
|
||||||
Emulator.getThreading().run(pet);
|
Emulator.getThreading().run(pet);
|
||||||
|
@ -37,7 +37,7 @@ public class RespectPetEvent extends MessageHandler {
|
|||||||
|
|
||||||
RoomTile tile = habbo.getRoomUnit().getClosestAdjacentTile(pet.getRoomUnit().getCurrentPosition().getX(), pet.getRoomUnit().getCurrentPosition().getY(), true);
|
RoomTile tile = habbo.getRoomUnit().getClosestAdjacentTile(pet.getRoomUnit().getCurrentPosition().getX(), pet.getRoomUnit().getCurrentPosition().getY(), true);
|
||||||
if(tile != null) {
|
if(tile != null) {
|
||||||
habbo.getRoomUnit().setGoalLocation(tile);
|
habbo.getRoomUnit().walkTo(tile);
|
||||||
}
|
}
|
||||||
|
|
||||||
Emulator.getThreading().run(new RoomUnitWalkToLocation(habbo.getRoomUnit(), tile, room, tasks, tasks));
|
Emulator.getThreading().run(new RoomUnitWalkToLocation(habbo.getRoomUnit(), tile, room, tasks, tasks));
|
||||||
|
@ -1,23 +1,14 @@
|
|||||||
package com.eu.habbo.messages.incoming.rooms.users;
|
package com.eu.habbo.messages.incoming.rooms.users;
|
||||||
|
|
||||||
import com.eu.habbo.Emulator;
|
|
||||||
import com.eu.habbo.habbohotel.pets.PetTasks;
|
|
||||||
import com.eu.habbo.habbohotel.rooms.Room;
|
import com.eu.habbo.habbohotel.rooms.Room;
|
||||||
import com.eu.habbo.habbohotel.rooms.RoomTile;
|
import com.eu.habbo.habbohotel.rooms.RoomTile;
|
||||||
import com.eu.habbo.habbohotel.rooms.RoomUnitStatus;
|
|
||||||
import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem;
|
|
||||||
import com.eu.habbo.habbohotel.rooms.entities.units.types.RoomHabbo;
|
import com.eu.habbo.habbohotel.rooms.entities.units.types.RoomHabbo;
|
||||||
import com.eu.habbo.habbohotel.users.Habbo;
|
import com.eu.habbo.habbohotel.users.Habbo;
|
||||||
import com.eu.habbo.messages.incoming.MessageHandler;
|
import com.eu.habbo.messages.incoming.MessageHandler;
|
||||||
import com.eu.habbo.messages.outgoing.rooms.users.RoomUnitOnRollerComposer;
|
|
||||||
import com.eu.habbo.plugin.events.users.UserIdleEvent;
|
|
||||||
import gnu.trove.set.hash.THashSet;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class MoveAvatarEvent extends MessageHandler {
|
public class MoveAvatarEvent extends MessageHandler {
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getRatelimit() {
|
public int getRatelimit() {
|
||||||
return 500;
|
return 500;
|
||||||
@ -25,52 +16,31 @@ public class MoveAvatarEvent extends MessageHandler {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handle() throws Exception {
|
public void handle() throws Exception {
|
||||||
if (this.client.getHabbo().getRoomUnit().getRoom() != null) {
|
int x = this.packet.readInt();
|
||||||
int x = this.packet.readInt(); // Position X
|
int y = this.packet.readInt();
|
||||||
int y = this.packet.readInt(); // Position Y
|
|
||||||
|
|
||||||
// Get Habbo object
|
|
||||||
Habbo habbo = this.client.getHabbo();
|
Habbo habbo = this.client.getHabbo();
|
||||||
|
|
||||||
if(habbo == null) {
|
if(habbo == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get Room Habbo object (Unique GUID?)
|
|
||||||
RoomHabbo roomHabbo = this.client.getHabbo().getRoomUnit();
|
RoomHabbo roomHabbo = this.client.getHabbo().getRoomUnit();
|
||||||
|
|
||||||
if(roomHabbo == null) {
|
if(roomHabbo == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If habbo is teleporting, don't calculate a new path
|
|
||||||
if (roomHabbo.isTeleporting()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// If habbo is being kicked don't calculate a new path
|
|
||||||
if (roomHabbo.isKicked()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
//Is going to ride a pet, can't cancel
|
|
||||||
if(roomHabbo.isRideLock()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get the room the habbo is in
|
|
||||||
Room room = habbo.getRoomUnit().getRoom();
|
Room room = habbo.getRoomUnit().getRoom();
|
||||||
|
|
||||||
if (room == null || room.getLayout() == null) {
|
if (room == null || room.getLayout() == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Don't calulcate a new path if are already at the end position
|
if (roomHabbo.getCurrentPosition().equals(x,y)) {
|
||||||
if (x == roomHabbo.getCurrentPosition().getX() && y == roomHabbo.getCurrentPosition().getY()) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If habbo has control (im assuming admin, do something else, but we dont care about this part here)
|
|
||||||
if (roomHabbo.getCacheable().get("control") != null) {
|
if (roomHabbo.getCacheable().get("control") != null) {
|
||||||
habbo = (Habbo) roomHabbo.getCacheable().get("control");
|
habbo = (Habbo) roomHabbo.getCacheable().get("control");
|
||||||
|
|
||||||
@ -81,100 +51,17 @@ public class MoveAvatarEvent extends MessageHandler {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Recover roomUnit if necessary
|
|
||||||
roomHabbo = habbo.getRoomUnit();
|
roomHabbo = habbo.getRoomUnit();
|
||||||
|
|
||||||
// If our room unit is not nullptr and we are in a room and we can walk, then calculate a new path
|
|
||||||
if (roomHabbo != null && roomHabbo.isInRoom() && roomHabbo.isCanWalk()) {
|
if (roomHabbo != null && roomHabbo.isInRoom() && roomHabbo.isCanWalk()) {
|
||||||
|
|
||||||
//If teleport command is enabled
|
|
||||||
if(roomHabbo.isCmdTeleportEnabled()) {
|
|
||||||
RoomTile t = room.getLayout().getTile((short) x, (short) y);
|
|
||||||
|
|
||||||
if (habbo.getHabboInfo().getRiding() != null) {
|
|
||||||
room.sendComposer(new RoomUnitOnRollerComposer(roomHabbo, null, roomHabbo.getCurrentPosition(), roomHabbo.getCurrentZ(), t, t.getStackHeight() + 1.0D, room).compose());
|
|
||||||
room.sendComposer(new RoomUnitOnRollerComposer(habbo.getHabboInfo().getRiding().getRoomUnit(), t, room).compose());
|
|
||||||
} else {
|
|
||||||
room.sendComposer(new RoomUnitOnRollerComposer(roomHabbo, t, room).compose());
|
|
||||||
}
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Don't calculate a new path if we are on a horse
|
|
||||||
if (habbo.getHabboInfo().getRiding() != null && habbo.getHabboInfo().getRiding().getTask() != null && habbo.getHabboInfo().getRiding().getTask().equals(PetTasks.JUMP)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Reset idle status
|
|
||||||
if (roomHabbo.isIdle()) {
|
|
||||||
UserIdleEvent event = new UserIdleEvent(habbo, UserIdleEvent.IdleReason.WALKED, false);
|
|
||||||
Emulator.getPluginManager().fireEvent(event);
|
|
||||||
|
|
||||||
if (!event.isCancelled()) {
|
|
||||||
if (!event.isIdle()) {
|
|
||||||
if (roomHabbo.getRoom() != null) {
|
|
||||||
roomHabbo.unIdle();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get room height map
|
|
||||||
RoomTile tile = room.getLayout().getTile((short) x, (short) y);
|
RoomTile tile = room.getLayout().getTile((short) x, (short) y);
|
||||||
|
|
||||||
// this should never happen, if it does it would be a design flaw
|
|
||||||
if (tile == null) {
|
if (tile == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Don't care
|
log.info("CLICKED ON TILE [x]: {} [y]: {}", tile.getX(), tile.getY());
|
||||||
if (habbo.getRoomUnit().hasStatus(RoomUnitStatus.LAY)) {
|
roomHabbo.walkTo(tile);
|
||||||
if (room.getLayout().getTilesInFront(habbo.getRoomUnit().getCurrentPosition(), habbo.getRoomUnit().getBodyRotation().getValue(), 2).contains(tile))
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (room.canLayAt(tile)) {
|
|
||||||
RoomItem bed = room.getRoomItemManager().getTopItemAt(tile.getX(), tile.getY());
|
|
||||||
|
|
||||||
if (bed != null && bed.getBaseItem().allowLay()) {
|
|
||||||
room.getLayout().getTile(bed.getCurrentPosition().getX(), bed.getCurrentPosition().getY());
|
|
||||||
RoomTile pillow = switch (bed.getRotation()) {
|
|
||||||
case 0, 4 -> room.getLayout().getTile((short) x, bed.getCurrentPosition().getY());
|
|
||||||
case 2, 8 -> room.getLayout().getTile(bed.getCurrentPosition().getX(), (short) y);
|
|
||||||
default ->
|
|
||||||
room.getLayout().getTile(bed.getCurrentPosition().getX(), bed.getCurrentPosition().getY());
|
|
||||||
};
|
|
||||||
|
|
||||||
if (pillow != null && room.canLayAt(pillow)) {
|
|
||||||
roomHabbo.setGoalLocation(pillow);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
THashSet<RoomItem> items = room.getRoomItemManager().getItemsAt(tile);
|
|
||||||
|
|
||||||
if (items.size() > 0) {
|
|
||||||
for (RoomItem item : items) {
|
|
||||||
RoomTile overriddenTile = item.getOverrideGoalTile(roomHabbo, room, tile);
|
|
||||||
|
|
||||||
if (overriddenTile == null) {
|
|
||||||
return; // null cancels the entire event
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!overriddenTile.equals(tile) && overriddenTile.isWalkable()) {
|
|
||||||
tile = overriddenTile;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// This is where we set the end location and begin finding a path
|
|
||||||
if (tile.isWalkable() || room.canSitOrLayAt(tile.getX(), tile.getY())) {
|
|
||||||
roomHabbo.setGoalLocation(tile);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -83,7 +83,6 @@ public class RoomUnitOnRollerComposer extends MessageComposer {
|
|||||||
|
|
||||||
this.roomUnit.setLocation(this.newLocation);
|
this.roomUnit.setLocation(this.newLocation);
|
||||||
this.roomUnit.setCurrentZ(this.newLocation.getStackHeight());
|
this.roomUnit.setCurrentZ(this.newLocation.getStackHeight());
|
||||||
this.roomUnit.setPreviousLocationZ(this.newLocation.getStackHeight());
|
|
||||||
|
|
||||||
if (topItemNewLocation != null && topItemNewLocation != roller && oldTopItem != topItemNewLocation) {
|
if (topItemNewLocation != null && topItemNewLocation != roller && oldTopItem != topItemNewLocation) {
|
||||||
try {
|
try {
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package com.eu.habbo.messages.outgoing.rooms.users;
|
package com.eu.habbo.messages.outgoing.rooms.users;
|
||||||
|
|
||||||
import com.eu.habbo.habbohotel.rooms.RoomUnitStatus;
|
|
||||||
import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit;
|
import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit;
|
||||||
import com.eu.habbo.habbohotel.users.Habbo;
|
import com.eu.habbo.habbohotel.users.Habbo;
|
||||||
import com.eu.habbo.messages.ServerMessage;
|
import com.eu.habbo.messages.ServerMessage;
|
||||||
@ -9,7 +8,6 @@ import com.eu.habbo.messages.outgoing.Outgoing;
|
|||||||
import gnu.trove.set.hash.THashSet;
|
import gnu.trove.set.hash.THashSet;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
public class UserUpdateComposer extends MessageComposer {
|
public class UserUpdateComposer extends MessageComposer {
|
||||||
private Collection<Habbo> habbos;
|
private Collection<Habbo> habbos;
|
||||||
@ -41,42 +39,29 @@ public class UserUpdateComposer extends MessageComposer {
|
|||||||
this.response.appendInt(this.roomUnits.size());
|
this.response.appendInt(this.roomUnits.size());
|
||||||
for (RoomUnit roomUnit : this.roomUnits) {
|
for (RoomUnit roomUnit : this.roomUnits) {
|
||||||
this.response.appendInt(roomUnit.getVirtualId());
|
this.response.appendInt(roomUnit.getVirtualId());
|
||||||
this.response.appendInt(roomUnit.getPreviousPosition().getX());
|
this.response.appendInt(roomUnit.getCurrentPosition().getX());
|
||||||
this.response.appendInt(roomUnit.getPreviousPosition().getY());
|
this.response.appendInt(roomUnit.getCurrentPosition().getY());
|
||||||
this.response.appendString((this.overrideZ != -1 ? this.overrideZ : roomUnit.getPreviousLocationZ()) + "");
|
this.response.appendString(String.valueOf(this.overrideZ != -1 ? this.overrideZ : roomUnit.getCurrentZ()));
|
||||||
|
|
||||||
|
|
||||||
this.response.appendInt(roomUnit.getHeadRotation().getValue());
|
this.response.appendInt(roomUnit.getHeadRotation().getValue());
|
||||||
this.response.appendInt(roomUnit.getBodyRotation().getValue());
|
this.response.appendInt(roomUnit.getBodyRotation().getValue());
|
||||||
|
|
||||||
StringBuilder status = new StringBuilder("/");
|
this.response.appendString(roomUnit.getCurrentStatuses());
|
||||||
for (Map.Entry<RoomUnitStatus, String> entry : roomUnit.getStatuses().entrySet()) {
|
|
||||||
status.append(entry.getKey()).append(" ").append(entry.getValue()).append("/");
|
|
||||||
}
|
|
||||||
|
|
||||||
this.response.appendString(status.toString());
|
|
||||||
roomUnit.setPreviousLocation(roomUnit.getCurrentPosition());
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
synchronized (this.habbos) {
|
synchronized (this.habbos) {
|
||||||
this.response.appendInt(this.habbos.size());
|
this.response.appendInt(this.habbos.size());
|
||||||
for (Habbo habbo : this.habbos) {
|
for (Habbo habbo : this.habbos) {
|
||||||
this.response.appendInt(habbo.getRoomUnit().getVirtualId());
|
this.response.appendInt(habbo.getRoomUnit().getVirtualId());
|
||||||
this.response.appendInt(habbo.getRoomUnit().getPreviousPosition().getX());
|
this.response.appendInt(habbo.getRoomUnit().getCurrentPosition().getX());
|
||||||
this.response.appendInt(habbo.getRoomUnit().getPreviousPosition().getY());
|
this.response.appendInt(habbo.getRoomUnit().getCurrentPosition().getY());
|
||||||
this.response.appendString(habbo.getRoomUnit().getPreviousLocationZ() + "");
|
this.response.appendString(String.valueOf(habbo.getRoomUnit().getCurrentZ()));
|
||||||
|
|
||||||
|
|
||||||
this.response.appendInt(habbo.getRoomUnit().getHeadRotation().getValue());
|
this.response.appendInt(habbo.getRoomUnit().getHeadRotation().getValue());
|
||||||
this.response.appendInt(habbo.getRoomUnit().getBodyRotation().getValue());
|
this.response.appendInt(habbo.getRoomUnit().getBodyRotation().getValue());
|
||||||
|
|
||||||
StringBuilder status = new StringBuilder("/");
|
this.response.appendString(habbo.getRoomUnit().getCurrentStatuses());
|
||||||
|
|
||||||
for (Map.Entry<RoomUnitStatus, String> entry : habbo.getRoomUnit().getStatuses().entrySet()) {
|
|
||||||
status.append(entry.getKey()).append(" ").append(entry.getValue()).append("/");
|
|
||||||
}
|
|
||||||
this.response.appendString(status.toString());
|
|
||||||
habbo.getRoomUnit().setPreviousLocation(habbo.getRoomUnit().getCurrentPosition());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -16,6 +16,6 @@ public class RoomUnitSetGoalEvent extends RoomUnitEvent {
|
|||||||
|
|
||||||
|
|
||||||
public void setGoal(RoomTile t) {
|
public void setGoal(RoomTile t) {
|
||||||
super.roomUnit.setGoalLocation(t);
|
super.roomUnit.walkTo(t);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -40,7 +40,7 @@ public class BotFollowHabbo implements Runnable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (target.getX() >= 0 && target.getY() >= 0) {
|
if (target.getX() >= 0 && target.getY() >= 0) {
|
||||||
this.bot.getRoomUnit().setGoalLocation(target);
|
this.bot.getRoomUnit().walkTo(target);
|
||||||
this.bot.getRoomUnit().setCanWalk(true);
|
this.bot.getRoomUnit().setCanWalk(true);
|
||||||
Emulator.getThreading().run(this, 500);
|
Emulator.getThreading().run(this, 500);
|
||||||
}
|
}
|
||||||
|
@ -24,7 +24,9 @@ public class ClearRentedSpace implements Runnable {
|
|||||||
for (RoomItem i : this.room.getRoomItemManager().getItemsAt(t)) {
|
for (RoomItem i : this.room.getRoomItemManager().getItemsAt(t)) {
|
||||||
if (i.getOwnerInfo().getId() == this.item.getRenterId()) {
|
if (i.getOwnerInfo().getId() == this.item.getRenterId()) {
|
||||||
items.add(i);
|
items.add(i);
|
||||||
|
//Deprecated
|
||||||
i.setRoomId(0);
|
i.setRoomId(0);
|
||||||
|
i.setRoom(null);
|
||||||
i.needsUpdate(true);
|
i.needsUpdate(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -31,7 +31,9 @@ public class CrackableExplode implements Runnable {
|
|||||||
if (!this.habboItem.resetable()) {
|
if (!this.habboItem.resetable()) {
|
||||||
this.room.getRoomItemManager().removeRoomItem(this.habboItem);
|
this.room.getRoomItemManager().removeRoomItem(this.habboItem);
|
||||||
this.room.sendComposer(new RemoveFloorItemComposer(this.habboItem, true).compose());
|
this.room.sendComposer(new RemoveFloorItemComposer(this.habboItem, true).compose());
|
||||||
|
//Deprecated
|
||||||
this.habboItem.setRoomId(0);
|
this.habboItem.setRoomId(0);
|
||||||
|
this.habboItem.setRoom(null);
|
||||||
Emulator.getGameEnvironment().getItemManager().deleteItem(this.habboItem);
|
Emulator.getGameEnvironment().getItemManager().deleteItem(this.habboItem);
|
||||||
} else {
|
} else {
|
||||||
this.habboItem.reset(this.room);
|
this.habboItem.reset(this.room);
|
||||||
@ -51,8 +53,9 @@ public class CrackableExplode implements Runnable {
|
|||||||
} else {
|
} else {
|
||||||
newItem.setCurrentPosition(this.tile);
|
newItem.setCurrentPosition(this.tile);
|
||||||
newItem.setCurrentZ(this.room.getStackHeight(this.tile.getX(), this.tile.getY(), false));
|
newItem.setCurrentZ(this.room.getStackHeight(this.tile.getX(), this.tile.getY(), false));
|
||||||
|
//Deprecated
|
||||||
newItem.setRoomId(this.room.getRoomInfo().getId());
|
newItem.setRoomId(this.room.getRoomInfo().getId());
|
||||||
|
newItem.setRoom(this.room);
|
||||||
newItem.needsUpdate(true);
|
newItem.needsUpdate(true);
|
||||||
this.room.getRoomItemManager().addRoomItem(newItem);
|
this.room.getRoomItemManager().addRoomItem(newItem);
|
||||||
this.room.updateItem(newItem);
|
this.room.updateItem(newItem);
|
||||||
|
@ -21,13 +21,9 @@ public class OneWayGateActionOne implements Runnable {
|
|||||||
|
|
||||||
RoomTile t = this.room.getLayout().getTileInFront(this.room.getLayout().getTile(this.oneWayGate.getCurrentPosition().getX(), this.oneWayGate.getCurrentPosition().getY()), (this.oneWayGate.getRotation() + 4) % 8);
|
RoomTile t = this.room.getLayout().getTileInFront(this.room.getLayout().getTile(this.oneWayGate.getCurrentPosition().getX(), this.oneWayGate.getCurrentPosition().getY()), (this.oneWayGate.getRotation() + 4) % 8);
|
||||||
|
|
||||||
if (this.client.getHabbo().getRoomUnit().isAnimateWalk()) {
|
|
||||||
this.client.getHabbo().getRoomUnit().setAnimateWalk(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (t.isWalkable()) {
|
if (t.isWalkable()) {
|
||||||
if (this.room.getLayout().tileWalkable(t) && this.client.getHabbo().getRoomUnit().getCurrentPosition().getX() == this.oneWayGate.getCurrentPosition().getX() && this.client.getHabbo().getRoomUnit().getCurrentPosition().getY() == this.oneWayGate.getCurrentPosition().getY()) {
|
if (this.room.getLayout().tileWalkable(t) && this.client.getHabbo().getRoomUnit().getCurrentPosition().getX() == this.oneWayGate.getCurrentPosition().getX() && this.client.getHabbo().getRoomUnit().getCurrentPosition().getY() == this.oneWayGate.getCurrentPosition().getY()) {
|
||||||
this.client.getHabbo().getRoomUnit().setGoalLocation(t);
|
this.client.getHabbo().getRoomUnit().walkTo(t);
|
||||||
|
|
||||||
if (!this.oneWayGate.getExtraData().equals("0")) {
|
if (!this.oneWayGate.getExtraData().equals("0")) {
|
||||||
Emulator.getThreading().run(new HabboItemNewState(this.oneWayGate, this.room, "0"), 1000);
|
Emulator.getThreading().run(new HabboItemNewState(this.oneWayGate, this.room, "0"), 1000);
|
||||||
|
@ -30,7 +30,7 @@ public class PetFollowHabbo implements Runnable {
|
|||||||
|
|
||||||
if (target.getX() >= 0 && target.getY() >= 0) {
|
if (target.getX() >= 0 && target.getY() >= 0) {
|
||||||
if (this.pet.getRoom().getLayout().tileWalkable(target)) {
|
if (this.pet.getRoom().getLayout().tileWalkable(target)) {
|
||||||
this.pet.getRoomUnit().setGoalLocation(target);
|
this.pet.getRoomUnit().walkTo(target);
|
||||||
this.pet.getRoomUnit().setCanWalk(true);
|
this.pet.getRoomUnit().setCanWalk(true);
|
||||||
this.pet.setTask(PetTasks.FOLLOW);
|
this.pet.setTask(PetTasks.FOLLOW);
|
||||||
}
|
}
|
||||||
|
@ -24,13 +24,11 @@ public class RoomUnitRidePet implements Runnable {
|
|||||||
if (habbo.getRoomUnit().getCurrentPosition().distance(pet.getRoomUnit().getCurrentPosition()) <= 1) {
|
if (habbo.getRoomUnit().getCurrentPosition().distance(pet.getRoomUnit().getCurrentPosition()) <= 1) {
|
||||||
habbo.getRoomUnit().stopWalking();
|
habbo.getRoomUnit().stopWalking();
|
||||||
habbo.getRoomUnit().giveEffect(77, -1);
|
habbo.getRoomUnit().giveEffect(77, -1);
|
||||||
habbo.getHabboInfo().setRiding(pet);
|
habbo.getRoomUnit().setRidingPet(pet);
|
||||||
habbo.getRoomUnit().setCurrentPosition(this.pet.getRoomUnit().getCurrentPosition());
|
habbo.getRoomUnit().setCurrentPosition(this.pet.getRoomUnit().getCurrentPosition());
|
||||||
habbo.getRoomUnit().setPreviousLocation(this.pet.getRoomUnit().getCurrentPosition());
|
|
||||||
habbo.getRoomUnit().setCurrentZ(this.pet.getRoomUnit().getCurrentZ() + 1);
|
habbo.getRoomUnit().setCurrentZ(this.pet.getRoomUnit().getCurrentZ() + 1);
|
||||||
habbo.getRoomUnit().setPreviousLocationZ(this.pet.getRoomUnit().getCurrentZ() + 1);
|
|
||||||
habbo.getRoomUnit().setRotation(this.pet.getRoomUnit().getBodyRotation());
|
habbo.getRoomUnit().setRotation(this.pet.getRoomUnit().getBodyRotation());
|
||||||
habbo.getRoomUnit().setRideLock(false);
|
habbo.getRoomUnit().setRideLocked(false);
|
||||||
pet.setRider(habbo);
|
pet.setRider(habbo);
|
||||||
habbo.getRoomUnit().getRoom().sendComposer(new UserUpdateComposer(habbo.getRoomUnit()).compose());
|
habbo.getRoomUnit().getRoom().sendComposer(new UserUpdateComposer(habbo.getRoomUnit()).compose());
|
||||||
habbo.getRoomUnit().getRoom().sendComposer(new AvatarEffectMessageComposer(habbo.getRoomUnit()).compose());
|
habbo.getRoomUnit().getRoom().sendComposer(new AvatarEffectMessageComposer(habbo.getRoomUnit()).compose());
|
||||||
@ -38,7 +36,7 @@ public class RoomUnitRidePet implements Runnable {
|
|||||||
} else {
|
} else {
|
||||||
pet.getRoomUnit().setWalkTimeOut(3 + Emulator.getIntUnixTimestamp());
|
pet.getRoomUnit().setWalkTimeOut(3 + Emulator.getIntUnixTimestamp());
|
||||||
pet.getRoomUnit().stopWalking();
|
pet.getRoomUnit().stopWalking();
|
||||||
habbo.getRoomUnit().setGoalLocation(goalTile);
|
habbo.getRoomUnit().walkTo(goalTile);
|
||||||
Emulator.getThreading().run(this, 500);
|
Emulator.getThreading().run(this, 500);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -46,9 +46,7 @@ public class RoomUnitTeleport implements Runnable {
|
|||||||
}
|
}
|
||||||
this.roomUnit.setPath(new LinkedList<>());
|
this.roomUnit.setPath(new LinkedList<>());
|
||||||
this.roomUnit.setCurrentPosition(newLocation);
|
this.roomUnit.setCurrentPosition(newLocation);
|
||||||
this.roomUnit.setPreviousLocation(newLocation);
|
|
||||||
this.roomUnit.setCurrentZ(this.z);
|
this.roomUnit.setCurrentZ(this.z);
|
||||||
this.roomUnit.setPreviousLocationZ(this.z);
|
|
||||||
this.roomUnit.removeStatus(RoomUnitStatus.MOVE);
|
this.roomUnit.removeStatus(RoomUnitStatus.MOVE);
|
||||||
//ServerMessage teleportMessage = new RoomUnitOnRollerComposer(this.roomUnit, newLocation, this.room).compose();
|
//ServerMessage teleportMessage = new RoomUnitOnRollerComposer(this.roomUnit, newLocation, this.room).compose();
|
||||||
this.roomUnit.setLocation(newLocation);
|
this.roomUnit.setLocation(newLocation);
|
||||||
|
@ -35,7 +35,7 @@ public class RoomUnitTeleportWalkToAction implements Runnable {
|
|||||||
log.error("Caught exception", e);
|
log.error("Caught exception", e);
|
||||||
}
|
}
|
||||||
} else if (tile.isWalkable()) {
|
} else if (tile.isWalkable()) {
|
||||||
this.habbo.getRoomUnit().setGoalLocation(tile);
|
this.habbo.getRoomUnit().walkTo(tile);
|
||||||
Emulator.getThreading().run(this, (long) this.habbo.getRoomUnit().getPath().size() + 2 * 510);
|
Emulator.getThreading().run(this, (long) this.habbo.getRoomUnit().getPath().size() + 2 * 510);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -36,7 +36,7 @@ public class RoomUnitVendingMachineAction implements Runnable {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (this.room.getLayout().getTile(tile.getX(), tile.getY()).isWalkable()) {
|
if (this.room.getLayout().getTile(tile.getX(), tile.getY()).isWalkable()) {
|
||||||
this.habbo.getRoomUnit().setGoalLocation(tile);
|
this.habbo.getRoomUnit().walkTo(tile);
|
||||||
Emulator.getThreading().run(this, (long) this.habbo.getRoomUnit().getPath().size() + 2 * 510);
|
Emulator.getThreading().run(this, (long) this.habbo.getRoomUnit().getPath().size() + 2 * 510);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -64,7 +64,7 @@ public class RoomUnitWalkToRoomUnit implements Runnable {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.walker.setGoalLocation(this.goalTile);
|
this.walker.walkTo(this.goalTile);
|
||||||
|
|
||||||
if (this.walker.getPath().isEmpty() && this.failedReached != null) {
|
if (this.walker.getPath().isEmpty() && this.failedReached != null) {
|
||||||
for (Runnable r : this.failedReached) {
|
for (Runnable r : this.failedReached) {
|
||||||
|
@ -42,7 +42,7 @@ class TeleportInteraction extends Thread {
|
|||||||
this.room.updateItem(this.teleportOne);
|
this.room.updateItem(this.teleportOne);
|
||||||
RoomTile tile = RoomItem.getSquareInFront(this.room.getLayout(), this.teleportTwo);
|
RoomTile tile = RoomItem.getSquareInFront(this.room.getLayout(), this.teleportTwo);
|
||||||
if (tile != null) {
|
if (tile != null) {
|
||||||
this.client.getHabbo().getRoomUnit().setGoalLocation(tile);
|
this.client.getHabbo().getRoomUnit().walkTo(tile);
|
||||||
}
|
}
|
||||||
Emulator.getThreading().run(this.teleportTwo, 500);
|
Emulator.getThreading().run(this.teleportTwo, 500);
|
||||||
Emulator.getThreading().run(this.teleportOne, 500);
|
Emulator.getThreading().run(this.teleportOne, 500);
|
||||||
@ -95,7 +95,7 @@ class TeleportInteraction extends Thread {
|
|||||||
this.state = 4;
|
this.state = 4;
|
||||||
Emulator.getThreading().run(this, 500);
|
Emulator.getThreading().run(this, 500);
|
||||||
} else if (this.state == 2) {
|
} else if (this.state == 2) {
|
||||||
this.client.getHabbo().getRoomUnit().setGoalLocation(this.room.getLayout().getTile(this.teleportOne.getCurrentPosition().getX(), this.teleportOne.getCurrentPosition().getY()));
|
this.client.getHabbo().getRoomUnit().walkTo(this.room.getLayout().getTile(this.teleportOne.getCurrentPosition().getX(), this.teleportOne.getCurrentPosition().getY()));
|
||||||
this.client.getHabbo().getRoomUnit().setRotation(RoomRotation.values()[this.newRotation(this.teleportOne.getRotation())]);
|
this.client.getHabbo().getRoomUnit().setRotation(RoomRotation.values()[this.newRotation(this.teleportOne.getRotation())]);
|
||||||
this.client.getHabbo().getRoomUnit().addStatus(RoomUnitStatus.MOVE, this.teleportOne.getCurrentPosition().getX() + "," + this.teleportOne.getCurrentPosition().getY() + "," + this.teleportOne.getCurrentZ());
|
this.client.getHabbo().getRoomUnit().addStatus(RoomUnitStatus.MOVE, this.teleportOne.getCurrentPosition().getX() + "," + this.teleportOne.getCurrentPosition().getY() + "," + this.teleportOne.getCurrentZ());
|
||||||
//room.sendComposer(new RoomUserStatusComposer(this.client.getHabbo().getRoomUnit()));
|
//room.sendComposer(new RoomUserStatusComposer(this.client.getHabbo().getRoomUnit()));
|
||||||
|
@ -19,7 +19,7 @@ class HopperActionFive implements Runnable {
|
|||||||
this.client.getHabbo().getRoomUnit().setTeleporting(false);
|
this.client.getHabbo().getRoomUnit().setTeleporting(false);
|
||||||
RoomTile tile = this.room.getLayout().getTileInFront(this.room.getLayout().getTile(this.currentTeleport.getCurrentPosition().getX(), this.currentTeleport.getCurrentPosition().getY()), this.currentTeleport.getRotation());
|
RoomTile tile = this.room.getLayout().getTileInFront(this.room.getLayout().getTile(this.currentTeleport.getCurrentPosition().getX(), this.currentTeleport.getCurrentPosition().getY()), this.currentTeleport.getRotation());
|
||||||
if (tile != null) {
|
if (tile != null) {
|
||||||
this.client.getHabbo().getRoomUnit().setGoalLocation(tile);
|
this.client.getHabbo().getRoomUnit().walkTo(tile);
|
||||||
}
|
}
|
||||||
|
|
||||||
Emulator.getThreading().run(new HabboItemNewState(this.currentTeleport, this.room, "0"), 1000);
|
Emulator.getThreading().run(new HabboItemNewState(this.currentTeleport, this.room, "0"), 1000);
|
||||||
|
@ -23,7 +23,6 @@ public class HopperActionOne implements Runnable {
|
|||||||
this.room.scheduledComposers.add(new UserUpdateComposer(this.client.getHabbo().getRoomUnit()).compose());
|
this.room.scheduledComposers.add(new UserUpdateComposer(this.client.getHabbo().getRoomUnit()).compose());
|
||||||
this.client.getHabbo().getRoomUnit().setLocation(this.room.getLayout().getTile(this.teleportOne.getCurrentPosition().getX(), this.teleportOne.getCurrentPosition().getY()));
|
this.client.getHabbo().getRoomUnit().setLocation(this.room.getLayout().getTile(this.teleportOne.getCurrentPosition().getX(), this.teleportOne.getCurrentPosition().getY()));
|
||||||
this.client.getHabbo().getRoomUnit().setCurrentZ(this.teleportOne.getCurrentZ());
|
this.client.getHabbo().getRoomUnit().setCurrentZ(this.teleportOne.getCurrentZ());
|
||||||
this.client.getHabbo().getRoomUnit().setPreviousLocationZ(this.teleportOne.getCurrentZ());
|
|
||||||
|
|
||||||
Emulator.getThreading().run(() -> {
|
Emulator.getThreading().run(() -> {
|
||||||
HopperActionOne.this.client.getHabbo().getRoomUnit().removeStatus(RoomUnitStatus.MOVE);
|
HopperActionOne.this.client.getHabbo().getRoomUnit().removeStatus(RoomUnitStatus.MOVE);
|
||||||
|
@ -43,7 +43,6 @@ class HopperActionThree implements Runnable {
|
|||||||
targetTeleport.setExtraData("2");
|
targetTeleport.setExtraData("2");
|
||||||
targetRoom.updateItem(targetTeleport);
|
targetRoom.updateItem(targetTeleport);
|
||||||
this.client.getHabbo().getRoomUnit().setLocation(this.room.getLayout().getTile(targetTeleport.getCurrentPosition().getX(), targetTeleport.getCurrentPosition().getY()));
|
this.client.getHabbo().getRoomUnit().setLocation(this.room.getLayout().getTile(targetTeleport.getCurrentPosition().getX(), targetTeleport.getCurrentPosition().getY()));
|
||||||
this.client.getHabbo().getRoomUnit().setPreviousLocationZ(targetTeleport.getCurrentZ());
|
|
||||||
this.client.getHabbo().getRoomUnit().setCurrentZ(targetTeleport.getCurrentZ());
|
this.client.getHabbo().getRoomUnit().setCurrentZ(targetTeleport.getCurrentZ());
|
||||||
this.client.getHabbo().getRoomUnit().setRotation(RoomRotation.values()[targetTeleport.getRotation() % 8]);
|
this.client.getHabbo().getRoomUnit().setRotation(RoomRotation.values()[targetTeleport.getRotation() % 8]);
|
||||||
this.client.getHabbo().getRoomUnit().removeStatus(RoomUnitStatus.MOVE);
|
this.client.getHabbo().getRoomUnit().removeStatus(RoomUnitStatus.MOVE);
|
||||||
|
@ -49,7 +49,7 @@ class TeleportActionFive implements Runnable {
|
|||||||
});
|
});
|
||||||
|
|
||||||
unit.setCanLeaveRoomByDoor(false);
|
unit.setCanLeaveRoomByDoor(false);
|
||||||
unit.setGoalLocation(tile);
|
unit.walkTo(tile);
|
||||||
unit.setStatusUpdateNeeded(true);
|
unit.setStatusUpdateNeeded(true);
|
||||||
unit.setLeavingTeleporter(true);
|
unit.setLeavingTeleporter(true);
|
||||||
Emulator.getThreading().run(new RoomUnitWalkToLocation(unit, tile, room, onSuccess, onSuccess));
|
Emulator.getThreading().run(new RoomUnitWalkToLocation(unit, tile, room, onSuccess, onSuccess));
|
||||||
|
@ -56,7 +56,6 @@ class TeleportActionThree implements Runnable {
|
|||||||
this.client.getHabbo().getRoomUnit().getPath().clear();
|
this.client.getHabbo().getRoomUnit().getPath().clear();
|
||||||
this.client.getHabbo().getRoomUnit().removeStatus(RoomUnitStatus.MOVE);
|
this.client.getHabbo().getRoomUnit().removeStatus(RoomUnitStatus.MOVE);
|
||||||
this.client.getHabbo().getRoomUnit().setCurrentZ(teleportLocation.getStackHeight());
|
this.client.getHabbo().getRoomUnit().setCurrentZ(teleportLocation.getStackHeight());
|
||||||
this.client.getHabbo().getRoomUnit().setPreviousLocationZ(teleportLocation.getStackHeight());
|
|
||||||
|
|
||||||
if (targetRoom != this.room) {
|
if (targetRoom != this.room) {
|
||||||
this.room.getRoomUnitManager().removeHabbo(this.client.getHabbo(), false);
|
this.room.getRoomUnitManager().removeHabbo(this.client.getHabbo(), false);
|
||||||
@ -67,10 +66,7 @@ class TeleportActionThree implements Runnable {
|
|||||||
|
|
||||||
targetTeleport.setExtraData("2");
|
targetTeleport.setExtraData("2");
|
||||||
targetRoom.updateItem(targetTeleport);
|
targetRoom.updateItem(targetTeleport);
|
||||||
//targetRoom.updateHabbo(this.client.getHabbo());
|
|
||||||
//LOGGER.info((targetTeleport.getX() + " | " + targetTeleport.getY());
|
|
||||||
this.client.getHabbo().getRoomUnit().setRoom(targetRoom);
|
this.client.getHabbo().getRoomUnit().setRoom(targetRoom);
|
||||||
//Emulator.getThreading().run(new HabboItemNewState(this.currentTeleport, this.room, "0"), 500);
|
|
||||||
Emulator.getThreading().run(new TeleportActionFour(targetTeleport, targetRoom, this.client), this.currentTeleport instanceof InteractionTeleportTile ? 0 : 500);
|
Emulator.getThreading().run(new TeleportActionFour(targetTeleport, targetRoom, this.client), this.currentTeleport instanceof InteractionTeleportTile ? 0 : 500);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user