From 8509692f4bd1f0882c3c81b73db901867a71d562 Mon Sep 17 00:00:00 2001 From: brenoepic <59066707+brenoepics@users.noreply.github.com> Date: Sat, 9 Apr 2022 00:17:00 -0300 Subject: [PATCH 01/10] Tree RoomUnitStatus --- .../java/com/eu/habbo/habbohotel/rooms/RoomUnitStatus.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomUnitStatus.java b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomUnitStatus.java index 73191762..005114c5 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomUnitStatus.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomUnitStatus.java @@ -64,7 +64,12 @@ public enum RoomUnitStatus { SLEEP_IN("slp-in"), SLEEP("slp", true), - SLEEP_OUT("slp-out"); + SLEEP_OUT("slp-out"), + + RINGOFFIRE("rng"), // ring of fire for dragon, toy undone + SWING("swg"), // same as roll but less energic, related to Dragon tree toy. + HANG("hg"), // hang, related to Dragon tree toy. just hangs under the branch + ROLL("rll"); // roll, related to Dragon tree toy. rolls around the branch public final String key; public final boolean removeWhenWalking; From 582da9dad0333ee48d6022fd9bd9addd0a67b0b6 Mon Sep 17 00:00:00 2001 From: brenoepic <59066707+brenoepics@users.noreply.github.com> Date: Sat, 9 Apr 2022 00:18:53 -0300 Subject: [PATCH 02/10] Feature InteractionPetTree --- .../habbo/habbohotel/items/ItemManager.java | 1 + .../interactions/pets/InteractionPetTree.java | 108 ++++++++++++++++++ .../com/eu/habbo/habbohotel/rooms/Room.java | 39 ++++++- 3 files changed, 144 insertions(+), 4 deletions(-) create mode 100644 src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionPetTree.java diff --git a/src/main/java/com/eu/habbo/habbohotel/items/ItemManager.java b/src/main/java/com/eu/habbo/habbohotel/items/ItemManager.java index e62b1f0a..17b3c05c 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/ItemManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/ItemManager.java @@ -133,6 +133,7 @@ public class ItemManager { this.interactionsList.add(new ItemInteraction("pet_drink", InteractionPetDrink.class)); this.interactionsList.add(new ItemInteraction("pet_food", InteractionPetFood.class)); this.interactionsList.add(new ItemInteraction("pet_toy", InteractionPetToy.class)); + this.interactionsList.add(new ItemInteraction("pet_tree", InteractionPetTree.class)); this.interactionsList.add(new ItemInteraction("breeding_nest", InteractionPetBreedingNest.class)); this.interactionsList.add(new ItemInteraction("obstacle", InteractionObstacle.class)); this.interactionsList.add(new ItemInteraction("monsterplant_seed", InteractionMonsterPlantSeed.class)); diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionPetTree.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionPetTree.java new file mode 100644 index 00000000..9e273ebd --- /dev/null +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionPetTree.java @@ -0,0 +1,108 @@ +package com.eu.habbo.habbohotel.items.interactions.pets; + +import com.eu.habbo.Emulator; +import com.eu.habbo.habbohotel.bots.Bot; +import com.eu.habbo.habbohotel.items.Item; +import com.eu.habbo.habbohotel.items.interactions.InteractionDefault; +import com.eu.habbo.habbohotel.pets.Pet; +import com.eu.habbo.habbohotel.pets.PetTasks; +import com.eu.habbo.habbohotel.rooms.*; +import com.eu.habbo.habbohotel.users.Habbo; +import com.eu.habbo.habbohotel.users.HabboItem; +import com.eu.habbo.messages.outgoing.rooms.users.RoomUserStatusComposer; +import com.eu.habbo.threading.runnables.PetClearPosture; + +import java.sql.ResultSet; +import java.sql.SQLException; + +public class InteractionPetTree extends InteractionDefault { + public InteractionPetTree(ResultSet set, Item baseItem) throws SQLException { + super(set, baseItem); + } + + public InteractionPetTree(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { + super(id, userId, item, extradata, limitedStack, limitedSells); + } + + @Override + public void onMove(Room room, RoomTile oldLocation, RoomTile newLocation) { + for (Pet pet : room.getPetsAt(oldLocation)) { + pet.getRoomUnit().clearStatus(); + pet.getRoomUnit().setStatus(RoomUnitStatus.RELAX, pet.getRoomUnit().getCurrentLocation().getStackHeight() + ""); + pet.packetUpdate = true; + } + } + @Override + public void onPickUp(Room room) { + for (Pet pet : room.getPetsOnItem(this)) { + pet.getRoomUnit().clearStatus(); + pet.getRoomUnit().setStatus(RoomUnitStatus.RELAX, pet.getRoomUnit().getCurrentLocation().getStackHeight() + ""); + pet.packetUpdate = true; + } + } + + @Override + public boolean canWalkOn(RoomUnit roomUnit, Room room, Object[] objects) { + Pet pet = room.getPet(roomUnit); + return (roomUnit.getRoomUnitType() == RoomUnitType.PET && pet != null && pet.getPetData().getType() == 12); + } + + @Override + public void onWalkOn(RoomUnit roomUnit, Room room, Object[] objects) throws Exception { + super.onWalkOn(roomUnit, room, objects); + + Pet pet = room.getPet(roomUnit); + if (pet != null && this.getOccupyingTiles(room.getLayout()).contains(pet.getRoomUnit().getGoal())) { + RoomUnitStatus task = RoomUnitStatus.HANG; + switch(pet.getTask()){ + case RING_OF_FIRE: task = RoomUnitStatus.RINGOFFIRE; break; + case SWING: task = RoomUnitStatus.SWING; break; + case ROLL: task = RoomUnitStatus.ROLL; break; + } + + if (pet.getEnergy() >= 35 && task != RoomUnitStatus.HANG) { + + pet.getRoomUnit().setCanWalk(false); + pet.getRoomUnit().setRotation(RoomUserRotation.values()[this.getRotation()]); + pet.getRoomUnit().clearStatus(); + pet.getRoomUnit().setStatus(task, pet.getRoomUnit().getCurrentLocation().getStackHeight() + ""); + pet.packetUpdate = true; + RoomUnitStatus finalTask = task; + Emulator.getThreading().run(() -> { + pet.addHappyness(25); + pet.getRoomUnit().clearStatus(); + new PetClearPosture(pet, finalTask, null, true); + if (this.getRoomId() == room.getId() && this.getOccupyingTiles(room.getLayout()).contains(pet.getRoomUnit().getCurrentLocation())) { + pet.getRoomUnit().setStatus(RoomUnitStatus.HANG, pet.getRoomUnit().getCurrentLocation().getStackHeight() + ""); + } else { + pet.getRoomUnit().setStatus(RoomUnitStatus.RELAX, pet.getRoomUnit().getCurrentLocation().getStackHeight() + ""); + } + pet.getRoomUnit().setCanWalk(true); + pet.packetUpdate = true; + }, 2500 + (Emulator.getRandom().nextInt(20) * 500)); + } else { + pet.getRoomUnit().setRotation(RoomUserRotation.values()[this.getRotation()]); + pet.getRoomUnit().clearStatus(); + pet.getRoomUnit().setStatus(RoomUnitStatus.HANG, pet.getRoomUnit().getCurrentLocation().getStackHeight() + ""); + pet.packetUpdate = true; + } + } + } + + @Override + public void onWalkOff(RoomUnit roomUnit, Room room, Object[] objects) throws Exception { + super.onWalkOff(roomUnit, room, objects); + + Pet pet = room.getPet(roomUnit); + + if (pet != null) { + pet.getRoomUnit().clearStatus(); + pet.getRoomUnit().setStatus(RoomUnitStatus.RELAX, pet.getRoomUnit().getCurrentLocation().getStackHeight() + ""); + pet.packetUpdate = true; + } + } + @Override + public boolean allowWiredResetState() { + return false; + } +} \ No newline at end of file diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java b/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java index 09c54558..4958cefa 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java @@ -20,10 +20,7 @@ import com.eu.habbo.habbohotel.items.interactions.games.battlebanzai.Interaction import com.eu.habbo.habbohotel.items.interactions.games.freeze.InteractionFreezeExitTile; import com.eu.habbo.habbohotel.items.interactions.games.tag.InteractionTagField; import com.eu.habbo.habbohotel.items.interactions.games.tag.InteractionTagPole; -import com.eu.habbo.habbohotel.items.interactions.pets.InteractionNest; -import com.eu.habbo.habbohotel.items.interactions.pets.InteractionPetBreedingNest; -import com.eu.habbo.habbohotel.items.interactions.pets.InteractionPetDrink; -import com.eu.habbo.habbohotel.items.interactions.pets.InteractionPetFood; +import com.eu.habbo.habbohotel.items.interactions.pets.*; import com.eu.habbo.habbohotel.items.interactions.wired.extra.WiredBlob; import com.eu.habbo.habbohotel.messenger.MessengerBuddy; import com.eu.habbo.habbohotel.permissions.Permission; @@ -2391,6 +2388,8 @@ public class Room implements Comparable, ISerialize, Runnable { this.roomSpecialTypes.addPetDrink((InteractionPetDrink) item); } else if (item instanceof InteractionPetFood) { this.roomSpecialTypes.addPetFood((InteractionPetFood) item); + } else if (item instanceof InteractionPetTree) { + this.roomSpecialTypes.addUndefined(item); } else if (item instanceof InteractionMoodLight) { this.roomSpecialTypes.addUndefined(item); } else if (item instanceof InteractionPyramid) { @@ -2921,6 +2920,27 @@ public class Room implements Comparable, ISerialize, Runnable { return false; } + public THashSet getPetsAt(RoomTile tile) { + THashSet pets = new THashSet<>(); + synchronized (this.currentPets) { + TIntObjectIterator petIterator = this.currentPets.iterator(); + + for (int i = this.currentPets.size(); i-- > 0; ) { + try { + petIterator.advance(); + + if (petIterator.value().getRoomUnit().getCurrentLocation().equals(tile)) { + pets.add(petIterator.value()); + } + } catch (Exception e) { + break; + } + } + } + + return pets; + } + public THashSet getBotsAt(RoomTile tile) { THashSet bots = new THashSet<>(); synchronized (this.currentBots) { @@ -2998,6 +3018,17 @@ public class Room implements Comparable, ISerialize, Runnable { return bots; } + public THashSet getPetsOnItem(HabboItem item) { + THashSet pets = new THashSet<>(); + for (short x = item.getX(); x < item.getX() + item.getBaseItem().getLength(); x++) { + for (short y = item.getY(); y < item.getY() + item.getBaseItem().getWidth(); y++) { + pets.addAll(this.getPetsAt(this.getLayout().getTile(x, y))); + } + } + + return pets; + } + public void teleportHabboToItem(Habbo habbo, HabboItem item) { this.teleportRoomUnitToLocation(habbo.getRoomUnit(), item.getX(), item.getY(), item.getZ() + Item.getCurrentHeight(item)); } From 4a84432630ec4c362c1fcff1e439d04446ef7e05 Mon Sep 17 00:00:00 2001 From: brenoepic <59066707+brenoepics@users.noreply.github.com> Date: Sat, 9 Apr 2022 00:19:00 -0300 Subject: [PATCH 03/10] Create ActionHang.java --- .../habbohotel/pets/actions/ActionHang.java | 70 +++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionHang.java diff --git a/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionHang.java b/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionHang.java new file mode 100644 index 00000000..2675f81d --- /dev/null +++ b/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionHang.java @@ -0,0 +1,70 @@ +package com.eu.habbo.habbohotel.pets.actions; + +import com.eu.habbo.habbohotel.items.interactions.pets.InteractionPetTree; +import com.eu.habbo.habbohotel.pets.Pet; +import com.eu.habbo.habbohotel.pets.PetAction; +import com.eu.habbo.habbohotel.pets.PetTasks; +import com.eu.habbo.habbohotel.pets.PetVocalsType; +import com.eu.habbo.habbohotel.rooms.RoomTile; +import com.eu.habbo.habbohotel.rooms.RoomTileState; +import com.eu.habbo.habbohotel.users.Habbo; +import com.eu.habbo.habbohotel.users.HabboItem; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.Set; + +public class ActionHang extends PetAction { + public ActionHang() { + super(null, true); + } + + @Override + public boolean apply(Pet pet, Habbo habbo, String[] data) { + if (pet.getHappyness() < 50) { + pet.say(pet.getPetData().randomVocal(PetVocalsType.DISOBEY)); + return false; + } else { + + Set petTrees = pet.getRoom().getRoomSpecialTypes().getItemsOfType(InteractionPetTree.class); + + if (petTrees == null || petTrees.isEmpty()) { + pet.say(pet.getPetData().randomVocal(PetVocalsType.DISOBEY)); + return false; + } + + ArrayList tileList = new ArrayList<>(); + + for (HabboItem petTree : petTrees) { + if (petTree == null || petTree.getRoomId() != pet.getRoom().getId()) continue; + tileList.addAll(petTree.getOccupyingTiles(pet.getRoom().getLayout())); + } + + if (!tileList.isEmpty()) { + Collections.shuffle(tileList); + RoomTile goal = tileList.get(0); + pet.say(pet.getPetData().randomVocal(PetVocalsType.GENERIC_NEUTRAL)); + + if (goal == null || goal.state == RoomTileState.BLOCKED) { + goal = pet.getRoomUnit().getClosestTile(tileList); + } + pet.setTask(PetTasks.HANG); + if (goal.distance(pet.getRoomUnit().getCurrentLocation()) == 0) { + HabboItem tree = pet.getRoom().getItemsAt(goal).stream().filter(habboItem -> habboItem instanceof InteractionPetTree).findAny().orElse(null); + if (tree != null) { + try { + tree.onWalkOn(pet.getRoomUnit(), pet.getRoom(), null); + } catch (Exception ignored) {} + } else { + pet.say(pet.getPetData().randomVocal(PetVocalsType.DISOBEY)); + return false; + } + } else pet.getRoomUnit().setGoalLocation(goal); + return true; + } else { + pet.say(pet.getPetData().randomVocal(PetVocalsType.DISOBEY)); + return false; + } + } + } +} \ No newline at end of file From 8e4446e46e01430ee8724b04de18b1187d9dc4b9 Mon Sep 17 00:00:00 2001 From: brenoepic <59066707+brenoepics@users.noreply.github.com> Date: Sat, 9 Apr 2022 00:19:08 -0300 Subject: [PATCH 04/10] Create ActionRingOfFire.java --- .../pets/actions/ActionRingOfFire.java | 70 +++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionRingOfFire.java diff --git a/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionRingOfFire.java b/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionRingOfFire.java new file mode 100644 index 00000000..23a404f5 --- /dev/null +++ b/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionRingOfFire.java @@ -0,0 +1,70 @@ +package com.eu.habbo.habbohotel.pets.actions; + +import com.eu.habbo.habbohotel.items.interactions.pets.InteractionPetTree; +import com.eu.habbo.habbohotel.pets.Pet; +import com.eu.habbo.habbohotel.pets.PetAction; +import com.eu.habbo.habbohotel.pets.PetTasks; +import com.eu.habbo.habbohotel.pets.PetVocalsType; +import com.eu.habbo.habbohotel.rooms.RoomTile; +import com.eu.habbo.habbohotel.rooms.RoomTileState; +import com.eu.habbo.habbohotel.users.Habbo; +import com.eu.habbo.habbohotel.users.HabboItem; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.Set; + +public class ActionRingOfFire extends PetAction { + public ActionRingOfFire() { + super(null, true); + } + + @Override + public boolean apply(Pet pet, Habbo habbo, String[] data) { + if (pet.getHappyness() < 50) { + pet.say(pet.getPetData().randomVocal(PetVocalsType.DISOBEY)); + return false; + } else { + + Set petTrees = pet.getRoom().getRoomSpecialTypes().getItemsOfType(InteractionPetTree.class); + + if (petTrees == null || petTrees.isEmpty()) { + pet.say(pet.getPetData().randomVocal(PetVocalsType.DISOBEY)); + return false; + } + + ArrayList tileList = new ArrayList<>(); + + for (HabboItem petTree : petTrees) { + if (petTree == null || petTree.getRoomId() != pet.getRoom().getId()) continue; + tileList.addAll(petTree.getOccupyingTiles(pet.getRoom().getLayout())); + } + + if (!tileList.isEmpty()) { + Collections.shuffle(tileList); + RoomTile goal = tileList.get(0); + pet.say(pet.getPetData().randomVocal(PetVocalsType.GENERIC_NEUTRAL)); + + if (goal == null || goal.state == RoomTileState.BLOCKED) { + goal = pet.getRoomUnit().getClosestTile(tileList); + } + pet.setTask(PetTasks.RING_OF_FIRE); + if (goal.distance(pet.getRoomUnit().getCurrentLocation()) == 0) { + HabboItem tree = pet.getRoom().getItemsAt(goal).stream().filter(habboItem -> habboItem instanceof InteractionPetTree).findAny().orElse(null); + if (tree != null) { + try { + tree.onWalkOn(pet.getRoomUnit(), pet.getRoom(), null); + } catch (Exception ignored) {} + } else { + pet.say(pet.getPetData().randomVocal(PetVocalsType.DISOBEY)); + return false; + } + } else pet.getRoomUnit().setGoalLocation(goal); + return true; + } else { + pet.say(pet.getPetData().randomVocal(PetVocalsType.DISOBEY)); + return false; + } + } + } +} \ No newline at end of file From 510cfef21c3882827f6cd48a32301ecdd2a943cf Mon Sep 17 00:00:00 2001 From: brenoepic <59066707+brenoepics@users.noreply.github.com> Date: Sat, 9 Apr 2022 00:19:13 -0300 Subject: [PATCH 05/10] Create ActionRoll.java --- .../habbohotel/pets/actions/ActionRoll.java | 70 +++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionRoll.java diff --git a/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionRoll.java b/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionRoll.java new file mode 100644 index 00000000..3a58caed --- /dev/null +++ b/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionRoll.java @@ -0,0 +1,70 @@ +package com.eu.habbo.habbohotel.pets.actions; + +import com.eu.habbo.habbohotel.items.interactions.pets.InteractionPetTree; +import com.eu.habbo.habbohotel.pets.Pet; +import com.eu.habbo.habbohotel.pets.PetAction; +import com.eu.habbo.habbohotel.pets.PetTasks; +import com.eu.habbo.habbohotel.pets.PetVocalsType; +import com.eu.habbo.habbohotel.rooms.RoomTile; +import com.eu.habbo.habbohotel.rooms.RoomTileState; +import com.eu.habbo.habbohotel.users.Habbo; +import com.eu.habbo.habbohotel.users.HabboItem; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.Set; + +public class ActionRoll extends PetAction { + public ActionRoll() { + super(null, true); + } + + @Override + public boolean apply(Pet pet, Habbo habbo, String[] data) { + if (pet.getHappyness() < 50) { + pet.say(pet.getPetData().randomVocal(PetVocalsType.DISOBEY)); + return false; + } else { + + Set petTrees = pet.getRoom().getRoomSpecialTypes().getItemsOfType(InteractionPetTree.class); + + if (petTrees == null || petTrees.isEmpty()) { + pet.say(pet.getPetData().randomVocal(PetVocalsType.DISOBEY)); + return false; + } + + ArrayList tileList = new ArrayList<>(); + + for (HabboItem petTree : petTrees) { + if (petTree == null || petTree.getRoomId() != pet.getRoom().getId()) continue; + tileList.addAll(petTree.getOccupyingTiles(pet.getRoom().getLayout())); + } + + if (!tileList.isEmpty()) { + Collections.shuffle(tileList); + RoomTile goal = tileList.get(0); + pet.say(pet.getPetData().randomVocal(PetVocalsType.GENERIC_NEUTRAL)); + + if (goal == null || goal.state == RoomTileState.BLOCKED) { + goal = pet.getRoomUnit().getClosestTile(tileList); + } + pet.setTask(PetTasks.ROLL); + if (goal.distance(pet.getRoomUnit().getCurrentLocation()) == 0) { + HabboItem tree = pet.getRoom().getItemsAt(goal).stream().filter(habboItem -> habboItem instanceof InteractionPetTree).findAny().orElse(null); + if (tree != null) { + try { + tree.onWalkOn(pet.getRoomUnit(), pet.getRoom(), null); + } catch (Exception ignored) {} + } else { + pet.say(pet.getPetData().randomVocal(PetVocalsType.DISOBEY)); + return false; + } + } else pet.getRoomUnit().setGoalLocation(goal); + return true; + } else { + pet.say(pet.getPetData().randomVocal(PetVocalsType.DISOBEY)); + return false; + } + } + } +} \ No newline at end of file From ac60af6cc10656b85d803d41c2173cc4d87c5928 Mon Sep 17 00:00:00 2001 From: brenoepic <59066707+brenoepics@users.noreply.github.com> Date: Sat, 9 Apr 2022 00:19:20 -0300 Subject: [PATCH 06/10] Create ActionSwing.java --- .../habbohotel/pets/actions/ActionSwing.java | 70 +++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionSwing.java diff --git a/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionSwing.java b/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionSwing.java new file mode 100644 index 00000000..0f7b89f4 --- /dev/null +++ b/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionSwing.java @@ -0,0 +1,70 @@ +package com.eu.habbo.habbohotel.pets.actions; + +import com.eu.habbo.habbohotel.items.interactions.pets.InteractionPetTree; +import com.eu.habbo.habbohotel.pets.Pet; +import com.eu.habbo.habbohotel.pets.PetAction; +import com.eu.habbo.habbohotel.pets.PetTasks; +import com.eu.habbo.habbohotel.pets.PetVocalsType; +import com.eu.habbo.habbohotel.rooms.RoomTile; +import com.eu.habbo.habbohotel.rooms.RoomTileState; +import com.eu.habbo.habbohotel.users.Habbo; +import com.eu.habbo.habbohotel.users.HabboItem; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.Set; + +public class ActionSwing extends PetAction { + public ActionSwing() { + super(null, true); + } + + @Override + public boolean apply(Pet pet, Habbo habbo, String[] data) { + if (pet.getHappyness() < 50) { + pet.say(pet.getPetData().randomVocal(PetVocalsType.DISOBEY)); + return false; + } else { + + Set petTrees = pet.getRoom().getRoomSpecialTypes().getItemsOfType(InteractionPetTree.class); + + if (petTrees == null || petTrees.isEmpty()) { + pet.say(pet.getPetData().randomVocal(PetVocalsType.DISOBEY)); + return false; + } + + ArrayList tileList = new ArrayList<>(); + + for (HabboItem petTree : petTrees) { + if (petTree == null || petTree.getRoomId() != pet.getRoom().getId()) continue; + tileList.addAll(petTree.getOccupyingTiles(pet.getRoom().getLayout())); + } + + if (!tileList.isEmpty()) { + Collections.shuffle(tileList); + RoomTile goal = tileList.get(0); + pet.say(pet.getPetData().randomVocal(PetVocalsType.GENERIC_NEUTRAL)); + + if (goal == null || goal.state == RoomTileState.BLOCKED) { + goal = pet.getRoomUnit().getClosestTile(tileList); + } + pet.setTask(PetTasks.SWING); + if (goal.distance(pet.getRoomUnit().getCurrentLocation()) == 0) { + HabboItem tree = pet.getRoom().getItemsAt(goal).stream().filter(habboItem -> habboItem instanceof InteractionPetTree).findAny().orElse(null); + if (tree != null) { + try { + tree.onWalkOn(pet.getRoomUnit(), pet.getRoom(), null); + } catch (Exception ignored) {} + } else { + pet.say(pet.getPetData().randomVocal(PetVocalsType.DISOBEY)); + return false; + } + } else pet.getRoomUnit().setGoalLocation(goal); + return true; + } else { + pet.say(pet.getPetData().randomVocal(PetVocalsType.DISOBEY)); + return false; + } + } + } +} \ No newline at end of file From e16b0527b8ac7507ac8ff9237da7e595f72c883c Mon Sep 17 00:00:00 2001 From: brenoepic <59066707+brenoepics@users.noreply.github.com> Date: Sat, 9 Apr 2022 00:19:27 -0300 Subject: [PATCH 07/10] Update PetManager.java --- src/main/java/com/eu/habbo/habbohotel/pets/PetManager.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main/java/com/eu/habbo/habbohotel/pets/PetManager.java b/src/main/java/com/eu/habbo/habbohotel/pets/PetManager.java index 8294707d..294c8beb 100644 --- a/src/main/java/com/eu/habbo/habbohotel/pets/PetManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/pets/PetManager.java @@ -61,7 +61,11 @@ public class PetManager { this.put(30, new ActionWave()); this.put(35, new ActionWings()); this.put(36, new ActionBreatheFire()); + this.put(37, new ActionHang()); this.put(38, new ActionTorch()); + this.put(40, new ActionSwing()); + this.put(41, new ActionRoll()); + this.put(42, new ActionRingOfFire()); this.put(43, new ActionEat()); this.put(46, new ActionBreed()); From 45766ef104829f9a46306faee2cf512687bffa1b Mon Sep 17 00:00:00 2001 From: brenoepics Date: Sat, 9 Apr 2022 03:22:11 +0000 Subject: [PATCH 08/10] Update RoomUnitStatus.java --- .../com/eu/habbo/habbohotel/rooms/RoomUnitStatus.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomUnitStatus.java b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomUnitStatus.java index 005114c5..5a857f75 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomUnitStatus.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomUnitStatus.java @@ -66,10 +66,10 @@ public enum RoomUnitStatus { SLEEP("slp", true), SLEEP_OUT("slp-out"), - RINGOFFIRE("rng"), // ring of fire for dragon, toy undone - SWING("swg"), // same as roll but less energic, related to Dragon tree toy. - HANG("hg"), // hang, related to Dragon tree toy. just hangs under the branch - ROLL("rll"); // roll, related to Dragon tree toy. rolls around the branch + RINGOFFIRE("rng"), + SWING("swg"), + HANG("hg"), + ROLL("rll"); public final String key; public final boolean removeWhenWalking; From 0363baf52340818ee4bf52a97159a7334ca1cb23 Mon Sep 17 00:00:00 2001 From: brenoepic <59066707+brenoepics@users.noreply.github.com> Date: Sat, 9 Apr 2022 15:29:32 -0300 Subject: [PATCH 09/10] Add is dragon check --- .../interactions/pets/InteractionPetTree.java | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionPetTree.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionPetTree.java index 9e273ebd..3369312c 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionPetTree.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionPetTree.java @@ -41,18 +41,12 @@ public class InteractionPetTree extends InteractionDefault { } } - @Override - public boolean canWalkOn(RoomUnit roomUnit, Room room, Object[] objects) { - Pet pet = room.getPet(roomUnit); - return (roomUnit.getRoomUnitType() == RoomUnitType.PET && pet != null && pet.getPetData().getType() == 12); - } - @Override public void onWalkOn(RoomUnit roomUnit, Room room, Object[] objects) throws Exception { super.onWalkOn(roomUnit, room, objects); Pet pet = room.getPet(roomUnit); - if (pet != null && this.getOccupyingTiles(room.getLayout()).contains(pet.getRoomUnit().getGoal())) { + if (pet != null && pet.getPetData().getType() == 12 && this.getOccupyingTiles(room.getLayout()).contains(pet.getRoomUnit().getGoal())) { RoomUnitStatus task = RoomUnitStatus.HANG; switch(pet.getTask()){ case RING_OF_FIRE: task = RoomUnitStatus.RINGOFFIRE; break; @@ -101,6 +95,13 @@ public class InteractionPetTree extends InteractionDefault { pet.packetUpdate = true; } } + + @Override + public boolean canWalkOn(RoomUnit roomUnit, Room room, Object[] objects) { + Pet pet = room.getPet(roomUnit); + return roomUnit.getRoomUnitType() == RoomUnitType.PET && pet != null; + } + @Override public boolean allowWiredResetState() { return false; From 90dfc4579699ca0b77a7b8a5bce3eddd0c4d8d2e Mon Sep 17 00:00:00 2001 From: brenoepic <59066707+brenoepics@users.noreply.github.com> Date: Sat, 9 Apr 2022 15:30:01 -0300 Subject: [PATCH 10/10] Added pet swim on water --- .../items/interactions/InteractionWater.java | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWater.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWater.java index d697ee4a..8b844c5b 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWater.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWater.java @@ -48,16 +48,19 @@ public class InteractionWater extends InteractionDefault { for (Habbo habbo : room.getHabbosOnItem(this)) { try { this.onWalkOff(habbo.getRoomUnit(), room, empty); - } catch (Exception e) { - - } + } catch (Exception ignored) {} } for (Bot bot : room.getBotsOnItem(this)) { try { this.onWalkOff(bot.getRoomUnit(), room, empty); - } catch (Exception e) { - } + } catch (Exception ignored) {} + } + + for (Pet pet : room.getPetsOnItem(this)) { + try { + this.onWalkOff(pet.getRoomUnit(), room, empty); + } catch (Exception ignored) {} } } @@ -78,7 +81,9 @@ public class InteractionWater extends InteractionDefault { return; if (!pet.getRoomUnit().hasStatus(RoomUnitStatus.SWIM) && pet.getPetData().canSwim) { - pet.getRoomUnit().setStatus(RoomUnitStatus.SWIM, ""); + pet.getRoomUnit().clearStatus(); + pet.getRoomUnit().setStatus(RoomUnitStatus.SWIM, pet.getRoomUnit().getCurrentLocation().getStackHeight() + ""); + pet.packetUpdate = true; } } @@ -91,7 +96,9 @@ public class InteractionWater extends InteractionDefault { if(pet == null) return; + pet.getRoomUnit().clearStatus(); pet.getRoomUnit().removeStatus(RoomUnitStatus.SWIM); + pet.packetUpdate = true; } @Override