From b0a0da455c5644763234c7e3a2e8c7c70080fa5e Mon Sep 17 00:00:00 2001 From: duckietm Date: Fri, 6 Mar 2026 11:30:48 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=86=95=20wf=5Fslc=5Fusers=5Farea=20and=20?= =?UTF-8?q?some=20wired=20updates?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../habbo/habbohotel/items/ItemManager.java | 2 + .../wired/effects/WiredEffectAlert.java | 6 +- .../effects/WiredEffectBotTalkToHabbo.java | 23 +-- .../wired/effects/WiredEffectGiveEffect.java | 7 +- .../effects/WiredEffectGiveHandItem.java | 8 +- .../wired/effects/WiredEffectGiveRespect.java | 11 +- .../wired/effects/WiredEffectGiveReward.java | 11 +- .../wired/effects/WiredEffectGiveScore.java | 29 +-- .../wired/effects/WiredEffectJoinTeam.java | 6 +- .../wired/effects/WiredEffectKickHabbo.java | 10 +- .../wired/effects/WiredEffectLeaveTeam.java | 6 +- .../wired/effects/WiredEffectMuteHabbo.java | 13 +- .../wired/effects/WiredEffectTeleport.java | 15 +- .../wired/effects/WiredEffectWhisper.java | 18 +- .../wired/selector/WiredEffectUsersArea.java | 172 ++++++++++++++++++ .../eu/habbo/habbohotel/pets/PetCommand.java | 1 + .../habbohotel/wired/WiredEffectType.java | 3 +- .../habbohotel/wired/api/IWiredEffect.java | 6 +- .../habbohotel/wired/core/WiredEngine.java | 48 +++-- 19 files changed, 301 insertions(+), 94 deletions(-) create mode 100644 Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/selector/WiredEffectUsersArea.java diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/items/ItemManager.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/items/ItemManager.java index 40142e71..c21d3949 100644 --- a/Emulator/src/main/java/com/eu/habbo/habbohotel/items/ItemManager.java +++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/items/ItemManager.java @@ -48,6 +48,7 @@ import com.eu.habbo.habbohotel.items.interactions.totems.InteractionTotemPlanet; import com.eu.habbo.habbohotel.items.interactions.wired.conditions.*; import com.eu.habbo.habbohotel.items.interactions.wired.effects.*; import com.eu.habbo.habbohotel.items.interactions.wired.selector.WiredEffectFurniArea; +import com.eu.habbo.habbohotel.items.interactions.wired.selector.WiredEffectUsersArea; import com.eu.habbo.habbohotel.items.interactions.wired.selector.WiredEffectFurniNeighborhood; import com.eu.habbo.habbohotel.items.interactions.wired.selector.WiredEffectFurniByType; import com.eu.habbo.habbohotel.items.interactions.wired.extra.WiredBlob; @@ -254,6 +255,7 @@ public class ItemManager { this.interactionsList.add(new ItemInteraction("wf_slc_furni_area", WiredEffectFurniArea.class)); this.interactionsList.add(new ItemInteraction("wf_slc_furni_neighborhood", WiredEffectFurniNeighborhood.class)); this.interactionsList.add(new ItemInteraction("wf_slc_furni_bytype", WiredEffectFurniByType.class)); + this.interactionsList.add(new ItemInteraction("wf_slc_users_area", WiredEffectUsersArea.class)); this.interactionsList.add(new ItemInteraction("wf_cnd_has_furni_on", WiredConditionFurniHaveFurni.class)); this.interactionsList.add(new ItemInteraction("wf_cnd_furnis_hv_avtrs", WiredConditionFurniHaveHabbo.class)); diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectAlert.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectAlert.java index 72869321..40bd2d3d 100644 --- a/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectAlert.java +++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectAlert.java @@ -21,9 +21,11 @@ public class WiredEffectAlert extends WiredEffectWhisper { @Override public void execute(WiredContext ctx) { Room room = ctx.room(); - Habbo habbo = ctx.actor().map(room::getHabbo).orElse(null); - if (habbo != null) { + for (com.eu.habbo.habbohotel.rooms.RoomUnit unit : ctx.targets().users()) { + Habbo habbo = room.getHabbo(unit); + if (habbo == null) continue; + habbo.alert(this.message .replace("%online%", Emulator.getGameEnvironment().getHabboManager().getOnlineCount() + "") .replace("%username%", habbo.getHabboInfo().getUsername()) diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotTalkToHabbo.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotTalkToHabbo.java index ec2222d5..c765b2ba 100644 --- a/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotTalkToHabbo.java +++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotTalkToHabbo.java @@ -111,12 +111,15 @@ public class WiredEffectBotTalkToHabbo extends InteractionWiredEffect { @Override public void execute(WiredContext ctx) { Room room = ctx.room(); - RoomUnit roomUnit = ctx.actor().orElse(null); - if (roomUnit == null) return; - Habbo habbo = room.getHabbo(roomUnit); + List bots = room.getBots(this.botName); + if (bots.size() != 1) return; + Bot bot = bots.get(0); + + for (RoomUnit roomUnit : ctx.targets().users()) { + Habbo habbo = room.getHabbo(roomUnit); + if (habbo == null) continue; - if (habbo != null) { String m = this.message; m = m.replace(Emulator.getTexts().getValue("wired.variable.username", "%username%"), habbo.getHabboInfo().getUsername()) .replace(Emulator.getTexts().getValue("wired.variable.credits", "%credits%"), habbo.getHabboInfo().getCredits() + "") @@ -128,15 +131,7 @@ public class WiredEffectBotTalkToHabbo extends InteractionWiredEffect { .replace(Emulator.getTexts().getValue("wired.variable.roomname", "%roomname%"), room.getName()) .replace(Emulator.getTexts().getValue("wired.variable.user_count", "%user_count%"), room.getUserCount() + ""); - List bots = room.getBots(this.botName); - - if (bots.size() != 1) { - return; - } - - Bot bot = bots.get(0); - - if(!WiredManager.triggerUserSays(room, bot.getRoomUnit(), m)) { + if (!WiredManager.triggerUserSays(room, bot.getRoomUnit(), m)) { if (this.mode == 1) { bot.whisper(m, habbo); } else { @@ -192,7 +187,7 @@ public class WiredEffectBotTalkToHabbo extends InteractionWiredEffect { @Override public boolean requiresTriggeringUser() { - return true; + return false; } static class JsonData { diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectGiveEffect.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectGiveEffect.java index eece5048..1c7a976b 100644 --- a/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectGiveEffect.java +++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectGiveEffect.java @@ -28,10 +28,11 @@ public class WiredEffectGiveEffect extends WiredEffectWhisper { } Room room = ctx.room(); - RoomUnit roomUnit = ctx.actor().orElse(null); - if (effectId >= 0 && roomUnit != null) { - room.giveEffect(roomUnit, effectId, Integer.MAX_VALUE); + if (effectId >= 0) { + for (RoomUnit roomUnit : ctx.targets().users()) { + room.giveEffect(roomUnit, effectId, Integer.MAX_VALUE); + } } } } diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectGiveHandItem.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectGiveHandItem.java index da7261b1..637c02c4 100644 --- a/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectGiveHandItem.java +++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectGiveHandItem.java @@ -23,10 +23,12 @@ public class WiredEffectGiveHandItem extends WiredEffectWhisper { int itemId = Integer.parseInt(this.message); Room room = ctx.room(); - Habbo habbo = ctx.actor().map(room::getHabbo).orElse(null); - if (habbo != null) { - room.giveHandItem(habbo, itemId); + for (com.eu.habbo.habbohotel.rooms.RoomUnit unit : ctx.targets().users()) { + Habbo habbo = room.getHabbo(unit); + if (habbo != null) { + room.giveHandItem(habbo, itemId); + } } } catch (Exception e) { } diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectGiveRespect.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectGiveRespect.java index 94e40db0..a83e9a31 100644 --- a/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectGiveRespect.java +++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectGiveRespect.java @@ -88,13 +88,14 @@ public class WiredEffectGiveRespect extends InteractionWiredEffect { @Override public void execute(WiredContext ctx) { Room room = ctx.room(); - Habbo habbo = ctx.actor().map(room::getHabbo).orElse(null); - if (habbo == null) - return; + for (RoomUnit unit : ctx.targets().users()) { + Habbo habbo = room.getHabbo(unit); + if (habbo == null) continue; - habbo.getHabboStats().respectPointsReceived += this.respects; - AchievementManager.progressAchievement(habbo, Emulator.getGameEnvironment().getAchievementManager().getAchievement("RespectEarned"), this.respects); + habbo.getHabboStats().respectPointsReceived += this.respects; + AchievementManager.progressAchievement(habbo, Emulator.getGameEnvironment().getAchievementManager().getAchievement("RespectEarned"), this.respects); + } } @Override diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectGiveReward.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectGiveReward.java index 41453538..21d8e10e 100644 --- a/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectGiveReward.java +++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectGiveReward.java @@ -52,13 +52,12 @@ public class WiredEffectGiveReward extends InteractionWiredEffect { @Override public void execute(WiredContext ctx) { Room room = ctx.room(); - RoomUnit roomUnit = ctx.actor().orElse(null); - if (roomUnit == null) return; - Habbo habbo = room.getHabbo(roomUnit); - - if (habbo != null) { - WiredManager.getReward(habbo, this); + for (RoomUnit roomUnit : ctx.targets().users()) { + Habbo habbo = room.getHabbo(roomUnit); + if (habbo != null) { + WiredManager.getReward(habbo, this); + } } } diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectGiveScore.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectGiveScore.java index c5c86e74..416a5e18 100644 --- a/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectGiveScore.java +++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectGiveScore.java @@ -46,13 +46,15 @@ public class WiredEffectGiveScore extends InteractionWiredEffect { @Override public void execute(WiredContext ctx) { Room room = ctx.room(); - Habbo habbo = ctx.actor().map(room::getHabbo).orElse(null); - if (habbo != null && habbo.getHabboInfo().getCurrentGame() != null) { + for (RoomUnit unit : ctx.targets().users()) { + Habbo habbo = room.getHabbo(unit); + if (habbo == null || habbo.getHabboInfo().getCurrentGame() == null) continue; + Game game = room.getGame(habbo.getHabboInfo().getCurrentGame()); if (game == null) - return; + continue; int gameStartTime = game.getStartTime(); @@ -60,6 +62,7 @@ public class WiredEffectGiveScore extends InteractionWiredEffect { TObjectIntIterator> iterator = dataClone.iterator(); + boolean alreadyCounted = false; for (int i = dataClone.size(); i-- > 0; ) { iterator.advance(); @@ -72,7 +75,8 @@ public class WiredEffectGiveScore extends InteractionWiredEffect { habbo.getHabboInfo().getGamePlayer().addScore(this.score, true); - return; + alreadyCounted = true; + break; } } else { iterator.remove(); @@ -80,16 +84,17 @@ public class WiredEffectGiveScore extends InteractionWiredEffect { } } - try { - this.data.put(new AbstractMap.SimpleEntry<>(gameStartTime, habbo.getHabboInfo().getId()), 1); - } - catch(IllegalArgumentException e) { + if (!alreadyCounted) { + try { + this.data.put(new AbstractMap.SimpleEntry<>(gameStartTime, habbo.getHabboInfo().getId()), 1); + } + catch(IllegalArgumentException e) { - } + } - - if (habbo.getHabboInfo().getGamePlayer() != null) { - habbo.getHabboInfo().getGamePlayer().addScore(this.score, true); + if (habbo.getHabboInfo().getGamePlayer() != null) { + habbo.getHabboInfo().getGamePlayer().addScore(this.score, true); + } } } } diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectJoinTeam.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectJoinTeam.java index 5664771a..6a548fa1 100644 --- a/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectJoinTeam.java +++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectJoinTeam.java @@ -40,9 +40,11 @@ public class WiredEffectJoinTeam extends InteractionWiredEffect { @Override public void execute(WiredContext ctx) { Room room = ctx.room(); - Habbo habbo = ctx.actor().map(room::getHabbo).orElse(null); - if (habbo != null) { + for (RoomUnit unit : ctx.targets().users()) { + Habbo habbo = room.getHabbo(unit); + if (habbo == null) continue; + WiredGame game = (WiredGame) room.getGameOrCreate(WiredGame.class); if (habbo.getHabboInfo().getGamePlayer() != null && habbo.getHabboInfo().getCurrentGame() != null && (habbo.getHabboInfo().getCurrentGame() != WiredGame.class || (habbo.getHabboInfo().getCurrentGame() == WiredGame.class && habbo.getHabboInfo().getGamePlayer().getTeamColor() != this.teamColor))) { diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectKickHabbo.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectKickHabbo.java index c4f765df..c15f336c 100644 --- a/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectKickHabbo.java +++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectKickHabbo.java @@ -42,17 +42,19 @@ public class WiredEffectKickHabbo extends InteractionWiredEffect { @Override public void execute(WiredContext ctx) { Room room = ctx.room(); - Habbo habbo = ctx.actor().map(room::getHabbo).orElse(null); - if (habbo != null) { + for (RoomUnit unit : ctx.targets().users()) { + Habbo habbo = room.getHabbo(unit); + if (habbo == null) continue; + if (habbo.hasPermission(Permission.ACC_UNKICKABLE)) { habbo.whisper(Emulator.getTexts().getValue("hotel.wired.kickexception.unkickable")); - return; + continue; } if (habbo.getHabboInfo().getId() == room.getOwnerId()) { habbo.whisper(Emulator.getTexts().getValue("hotel.wired.kickexception.owner")); - return; + continue; } room.giveEffect(habbo, 4, 2); diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectLeaveTeam.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectLeaveTeam.java index 881c9efd..e294ac51 100644 --- a/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectLeaveTeam.java +++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectLeaveTeam.java @@ -37,9 +37,11 @@ public class WiredEffectLeaveTeam extends InteractionWiredEffect { @Override public void execute(WiredContext ctx) { Room room = ctx.room(); - Habbo habbo = ctx.actor().map(room::getHabbo).orElse(null); - if (habbo != null) { + for (RoomUnit unit : ctx.targets().users()) { + Habbo habbo = room.getHabbo(unit); + if (habbo == null) continue; + if (habbo.getHabboInfo().getCurrentGame() != null) { Game game = room.getGame(habbo.getHabboInfo().getCurrentGame()); diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMuteHabbo.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMuteHabbo.java index ce053643..a476d224 100644 --- a/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMuteHabbo.java +++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMuteHabbo.java @@ -64,16 +64,13 @@ public class WiredEffectMuteHabbo extends InteractionWiredEffect { @Override public void execute(WiredContext ctx) { - RoomUnit roomUnit = ctx.actor().orElse(null); - if (roomUnit == null) - return; - Room room = ctx.room(); - Habbo habbo = room.getHabbo(roomUnit); - if (habbo != null) { - if (room.hasRights(habbo)) - return; + for (RoomUnit roomUnit : ctx.targets().users()) { + Habbo habbo = room.getHabbo(roomUnit); + if (habbo == null) continue; + + if (room.hasRights(habbo)) continue; room.muteHabbo(habbo, 60); diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectTeleport.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectTeleport.java index eef82e51..d5bdd7cf 100644 --- a/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectTeleport.java +++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectTeleport.java @@ -191,20 +191,21 @@ public class WiredEffectTeleport extends InteractionWiredEffect { @Override public void execute(WiredContext ctx) { Room room = ctx.room(); - RoomUnit roomUnit = ctx.actor().orElse(null); - - if (roomUnit == null || room == null || room.getLayout() == null) { + + if (room == null || room.getLayout() == null) { return; } - + this.items.removeIf(item -> item == null || item.getRoomId() != this.getRoomId() || Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(item.getId()) == null); - if (!this.items.isEmpty()) { + if (this.items.isEmpty()) return; + + for (RoomUnit roomUnit : ctx.targets().users()) { int i = Emulator.getRandom().nextInt(this.items.size()); HabboItem item = this.items.get(i); - - if (item == null) return; + + if (item == null) continue; RoomTile tile = room.getLayout().getTile(item.getX(), item.getY()); if (tile != null) { diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectWhisper.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectWhisper.java index 45744c93..0a928d64 100644 --- a/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectWhisper.java +++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectWhisper.java @@ -91,21 +91,15 @@ public class WiredEffectWhisper extends InteractionWiredEffect { public void execute(WiredContext ctx) { Room room = ctx.room(); if (this.message.length() > 0) { - RoomUnit roomUnit = ctx.actor().orElse(null); - if (roomUnit != null) { + for (RoomUnit roomUnit : ctx.targets().users()) { Habbo habbo = room.getHabbo(roomUnit); + if (habbo == null) continue; - if (habbo != null) { - String msg = this.message.replace("%user%", habbo.getHabboInfo().getUsername()).replace("%online_count%", Emulator.getGameEnvironment().getHabboManager().getOnlineCount() + "").replace("%room_count%", Emulator.getGameEnvironment().getRoomManager().getActiveRooms().size() + ""); - habbo.getClient().sendResponse(new RoomUserWhisperComposer(new RoomChatMessage(msg, habbo, habbo, RoomChatMessageBubbles.WIRED))); + String msg = this.message.replace("%user%", habbo.getHabboInfo().getUsername()).replace("%online_count%", Emulator.getGameEnvironment().getHabboManager().getOnlineCount() + "").replace("%room_count%", Emulator.getGameEnvironment().getRoomManager().getActiveRooms().size() + ""); + habbo.getClient().sendResponse(new RoomUserWhisperComposer(new RoomChatMessage(msg, habbo, habbo, RoomChatMessageBubbles.WIRED))); - if (habbo.getRoomUnit().isIdle()) { - habbo.getRoomUnit().getRoom().unIdle(habbo); - } - } - } else { - for (Habbo h : room.getHabbos()) { - h.getClient().sendResponse(new RoomUserWhisperComposer(new RoomChatMessage(this.message.replace("%user%", h.getHabboInfo().getUsername()).replace("%online_count%", Emulator.getGameEnvironment().getHabboManager().getOnlineCount() + "").replace("%room_count%", Emulator.getGameEnvironment().getRoomManager().getActiveRooms().size() + ""), h, h, RoomChatMessageBubbles.WIRED))); + if (habbo.getRoomUnit().isIdle()) { + habbo.getRoomUnit().getRoom().unIdle(habbo); } } } diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/selector/WiredEffectUsersArea.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/selector/WiredEffectUsersArea.java new file mode 100644 index 00000000..20918e2f --- /dev/null +++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/selector/WiredEffectUsersArea.java @@ -0,0 +1,172 @@ +package com.eu.habbo.habbohotel.items.interactions.wired.selector; + +import com.eu.habbo.habbohotel.gameclients.GameClient; +import com.eu.habbo.habbohotel.items.Item; +import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect; +import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings; +import com.eu.habbo.habbohotel.rooms.Room; +import com.eu.habbo.habbohotel.rooms.RoomUnit; +import com.eu.habbo.habbohotel.wired.WiredEffectType; +import com.eu.habbo.habbohotel.wired.core.WiredContext; +import com.eu.habbo.habbohotel.wired.core.WiredManager; +import com.eu.habbo.messages.ServerMessage; +import com.eu.habbo.messages.incoming.wired.WiredSaveException; + +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.List; + +public class WiredEffectUsersArea extends InteractionWiredEffect { + + public static final WiredEffectType type = WiredEffectType.USERS_AREA_SELECTOR; + + private int rootX = 0; + private int rootY = 0; + private int areaWidth = 0; + private int areaHeight = 0; + private boolean filterExisting = false; + private boolean invert = false; + + public WiredEffectUsersArea(ResultSet set, Item baseItem) throws SQLException { + super(set, baseItem); + } + + public WiredEffectUsersArea(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { + super(id, userId, item, extradata, limitedStack, limitedSells); + } + + @Override + public void execute(WiredContext ctx) { + Room room = ctx.room(); + if (room == null || areaWidth <= 0 || areaHeight <= 0) return; + + int maxX = rootX + areaWidth - 1; + int maxY = rootY + areaHeight - 1; + + List usersInArea = new ArrayList<>(); + for (RoomUnit unit : room.getRoomUnits()) { + int x = unit.getX(); + int y = unit.getY(); + boolean inArea = x >= rootX && x <= maxX && y >= rootY && y <= maxY; + if (invert ? !inArea : inArea) { + usersInArea.add(unit); + } + } + + if (filterExisting) { + usersInArea.retainAll(ctx.targets().users()); + } + + ctx.targets().setUsers(usersInArea); + } + + @Override + public boolean saveData(WiredSettings settings, GameClient gameClient) throws WiredSaveException { + int[] params = settings.getIntParams(); + if (params == null || params.length < 4) { + throw new WiredSaveException("wf_slc_users_area requires at least 4 int params: rootX, rootY, width, height"); + } + + this.rootX = params[0]; + this.rootY = params[1]; + this.areaWidth = params[2]; + this.areaHeight = params[3]; + this.filterExisting = params.length >= 5 && params[4] == 1; + this.invert = params.length >= 6 && params[5] == 1; + this.setDelay(settings.getDelay()); + + return true; + } + + @Override + public WiredEffectType getType() { + return type; + } + + @Override + public boolean isSelector() { + return true; + } + + @Override + public String getWiredData() { + return WiredManager.getGson().toJson(new JsonData(rootX, rootY, areaWidth, areaHeight, filterExisting, invert, getDelay())); + } + + @Override + public void loadWiredData(ResultSet set, Room room) throws SQLException { + String wiredData = set.getString("wired_data"); + + if (wiredData != null && wiredData.startsWith("{")) { + JsonData data = WiredManager.getGson().fromJson(wiredData, JsonData.class); + this.rootX = data.rootX; + this.rootY = data.rootY; + this.areaWidth = data.width; + this.areaHeight = data.height; + this.filterExisting = data.filterExisting; + this.invert = data.invert; + this.setDelay(data.delay); + } + } + + @Override + public void onPickUp() { + this.rootX = 0; + this.rootY = 0; + this.areaWidth = 0; + this.areaHeight = 0; + this.filterExisting = false; + this.invert = false; + this.setDelay(0); + } + + @Override + public void serializeWiredData(ServerMessage message, Room room) { + message.appendBoolean(false); + message.appendInt(0); + message.appendInt(0); + + message.appendInt(this.getBaseItem().getSpriteId()); + message.appendInt(this.getId()); + message.appendString(""); + + message.appendInt(6); + message.appendInt(this.rootX); + message.appendInt(this.rootY); + message.appendInt(this.areaWidth); + message.appendInt(this.areaHeight); + message.appendInt(this.filterExisting ? 1 : 0); + message.appendInt(this.invert ? 1 : 0); + + message.appendInt(0); + message.appendInt(this.getType().code); + message.appendInt(this.getDelay()); + message.appendInt(0); + } + + @Override + public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) { + return false; + } + + static class JsonData { + int rootX; + int rootY; + int width; + int height; + boolean filterExisting; + boolean invert; + int delay; + + JsonData(int rootX, int rootY, int width, int height, boolean filterExisting, boolean invert, int delay) { + this.rootX = rootX; + this.rootY = rootY; + this.width = width; + this.height = height; + this.filterExisting = filterExisting; + this.invert = invert; + this.delay = delay; + } + } +} diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/pets/PetCommand.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/pets/PetCommand.java index b05182f3..8fd91778 100644 --- a/Emulator/src/main/java/com/eu/habbo/habbohotel/pets/PetCommand.java +++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/pets/PetCommand.java @@ -80,6 +80,7 @@ public class PetCommand implements Comparable { if (Emulator.getRandom().nextInt(100) >= obeyChance) { pet.say(pet.getPetData().randomVocal(PetVocalsType.DISOBEY)); + // Don't record execution on random disobey — player can retry immediately return; } diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/wired/WiredEffectType.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/wired/WiredEffectType.java index c8da8f54..d2f9959b 100644 --- a/Emulator/src/main/java/com/eu/habbo/habbohotel/wired/WiredEffectType.java +++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/wired/WiredEffectType.java @@ -29,7 +29,8 @@ public enum WiredEffectType { BOT_TALK_TO_AVATAR(27), FURNI_AREA_SELECTOR(28), FURNI_NEIGHBORHOOD_SELECTOR(29), - FURNI_BYTYPE_SELECTOR(30); + FURNI_BYTYPE_SELECTOR(30), + USERS_AREA_SELECTOR(31); public final int code; diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/wired/api/IWiredEffect.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/wired/api/IWiredEffect.java index 68cd68e4..ed972341 100644 --- a/Emulator/src/main/java/com/eu/habbo/habbohotel/wired/api/IWiredEffect.java +++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/wired/api/IWiredEffect.java @@ -72,7 +72,11 @@ public interface IWiredEffect { default long getCooldown() { return 0L; } - + + default boolean isSelector() { + return false; + } + /** * Simulate this effect's execution and record intended state changes. *

diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/wired/core/WiredEngine.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/wired/core/WiredEngine.java index 350fae31..e47698c2 100644 --- a/Emulator/src/main/java/com/eu/habbo/habbohotel/wired/core/WiredEngine.java +++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/wired/core/WiredEngine.java @@ -348,25 +348,49 @@ public final class WiredEngine { return; } - // Determine which effects to execute + // Separate selectors from regular effects. + // Selectors must always run first so ctx.targets() is populated before + // regular effects consume it. + List selectors = new ArrayList<>(); + List regulars = new ArrayList<>(); + for (IWiredEffect e : effects) { + if (e.isSelector()) selectors.add(e); + else regulars.add(e); + } + + // Determine which (regular) effects to execute List toExecute; - + if (stack.useRandom()) { - // Random mode: pick one random effect - int randomIndex = new Random().nextInt(effects.size()); - toExecute = Collections.singletonList(effects.get(randomIndex)); - debug(ctx.room(), "Random mode: selected effect {}/{}", randomIndex + 1, effects.size()); + // Random mode: pick one random regular effect + if (regulars.isEmpty()) { + toExecute = new ArrayList<>(); + } else { + int randomIndex = new Random().nextInt(regulars.size()); + toExecute = Collections.singletonList(regulars.get(randomIndex)); + debug(ctx.room(), "Random mode: selected effect {}/{}", randomIndex + 1, regulars.size()); + } } else if (stack.useUnseen()) { - // Unseen mode: round-robin selection - int index = getNextUnseenIndex(stack, effects.size()); - toExecute = Collections.singletonList(effects.get(index)); - debug(ctx.room(), "Unseen mode: selected effect {}/{}", index + 1, effects.size()); + // Unseen mode: round-robin among regular effects + if (regulars.isEmpty()) { + toExecute = new ArrayList<>(); + } else { + int index = getNextUnseenIndex(stack, regulars.size()); + toExecute = Collections.singletonList(regulars.get(index)); + debug(ctx.room(), "Unseen mode: selected effect {}/{}", index + 1, regulars.size()); + } } else { - // Normal mode: execute all in random order - toExecute = new ArrayList<>(effects); + // Normal mode: regular effects in random order + toExecute = new ArrayList<>(regulars); Collections.shuffle(toExecute); } + // Selectors always run first (in their natural tile order), then regular effects + List ordered = new ArrayList<>(selectors.size() + toExecute.size()); + ordered.addAll(selectors); + ordered.addAll(toExecute); + toExecute = ordered; + // Execute selected effects for (IWiredEffect effect : toExecute) { // Check if effect requires actor