From 42198c46bdf3c20baf0c5bce9a663a2a7aea2053 Mon Sep 17 00:00:00 2001 From: Harmonic Date: Thu, 7 Apr 2022 14:37:34 -0700 Subject: [PATCH 01/40] Fixed pet commands not pushing the RoomUserStatusComposer after setting the gesture. --- src/main/java/com/eu/habbo/habbohotel/pets/PetCommand.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/eu/habbo/habbohotel/pets/PetCommand.java b/src/main/java/com/eu/habbo/habbohotel/pets/PetCommand.java index e2ca68ad..fc549cb9 100644 --- a/src/main/java/com/eu/habbo/habbohotel/pets/PetCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/pets/PetCommand.java @@ -3,6 +3,7 @@ package com.eu.habbo.habbohotel.pets; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.rooms.RoomUnitStatus; import com.eu.habbo.habbohotel.users.Habbo; +import com.eu.habbo.messages.outgoing.rooms.users.RoomUserStatusComposer; import java.sql.ResultSet; import java.sql.SQLException; @@ -65,7 +66,7 @@ public class PetCommand implements Comparable { } pet.getRoomUnit().setStatus(RoomUnitStatus.GESTURE, this.action.gestureToSet); - + pet.getRoom().sendComposer(new RoomUserStatusComposer(pet.getRoomUnit()).compose()); pet.addEnergy(-this.energyCost); pet.addHappyness(-this.happynessCost); pet.addExperience(this.xp); From 2e2d7ae96cf81bb237678d78acd046fe4176b23d Mon Sep 17 00:00:00 2001 From: Breno Andrade <59066707+brenoepics@users.noreply.github.com> Date: Thu, 7 Apr 2022 21:42:59 -0300 Subject: [PATCH 02/40] Fix pets and bots invalid tiles --- src/main/java/com/eu/habbo/habbohotel/rooms/Room.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) 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..c8d41847 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java @@ -475,7 +475,8 @@ public class Room implements Comparable, ISerialize, Runnable { b.setRoomUnit(new RoomUnit()); b.getRoomUnit().setPathFinderRoom(this); b.getRoomUnit().setLocation(this.layout.getTile((short) set.getInt("x"), (short) set.getInt("y"))); - if (b.getRoomUnit().getCurrentLocation() == null) { + if (b.getRoomUnit().getCurrentLocation() == null || b.getRoomUnit().getCurrentLocation().state == RoomTileState.INVALID) { + b.getRoomUnit().setZ(this.getLayout().getDoorTile().getStackHeight()); b.getRoomUnit().setLocation(this.getLayout().getDoorTile()); b.getRoomUnit().setRotation(RoomUserRotation.fromValue(this.getLayout().getDoorDirection())); } else { @@ -510,7 +511,8 @@ public class Room implements Comparable, ISerialize, Runnable { pet.setRoomUnit(new RoomUnit()); pet.getRoomUnit().setPathFinderRoom(this); pet.getRoomUnit().setLocation(this.layout.getTile((short) set.getInt("x"), (short) set.getInt("y"))); - if (pet.getRoomUnit().getCurrentLocation() == null) { + if (pet.getRoomUnit().getCurrentLocation() == null || pet.getRoomUnit().getCurrentLocation().state == RoomTileState.INVALID) { + pet.getRoomUnit().setZ(this.getLayout().getDoorTile().getStackHeight()); pet.getRoomUnit().setLocation(this.getLayout().getDoorTile()); pet.getRoomUnit().setRotation(RoomUserRotation.fromValue(this.getLayout().getDoorDirection())); } else { From 4a68e6a4a26c8b3e1ac2a89f58e2f6dd690840ee Mon Sep 17 00:00:00 2001 From: Harmonic Date: Thu, 7 Apr 2022 17:49:47 -0700 Subject: [PATCH 03/40] Fixed Action Turn Right and Turn Left not moving the pets head. --- .../com/eu/habbo/habbohotel/pets/actions/ActionTurnLeft.java | 1 + .../com/eu/habbo/habbohotel/pets/actions/ActionTurnRight.java | 1 + 2 files changed, 2 insertions(+) diff --git a/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionTurnLeft.java b/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionTurnLeft.java index de7a4d8d..a04efc81 100644 --- a/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionTurnLeft.java +++ b/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionTurnLeft.java @@ -14,6 +14,7 @@ public class ActionTurnLeft extends PetAction { @Override public boolean apply(Pet pet, Habbo habbo, String[] data) { pet.getRoomUnit().setBodyRotation(RoomUserRotation.values()[(pet.getRoomUnit().getBodyRotation().getValue() - 1 < 0 ? 7 : pet.getRoomUnit().getBodyRotation().getValue() - 1)]); + pet.getRoomUnit().setHeadRotation(RoomUserRotation.values()[(pet.getRoomUnit().getHeadRotation().getValue() - 1 < 0 ? 7 : pet.getRoomUnit().getHeadRotation().getValue() - 1)]); pet.say(pet.getPetData().randomVocal(PetVocalsType.GENERIC_NEUTRAL)); return true; } diff --git a/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionTurnRight.java b/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionTurnRight.java index 37041721..6bb19b73 100644 --- a/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionTurnRight.java +++ b/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionTurnRight.java @@ -14,6 +14,7 @@ public class ActionTurnRight extends PetAction { @Override public boolean apply(Pet pet, Habbo habbo, String[] data) { pet.getRoomUnit().setBodyRotation(RoomUserRotation.values()[(pet.getRoomUnit().getBodyRotation().getValue() + 1 > 7 ? 0 : pet.getRoomUnit().getBodyRotation().getValue() + 1)]); + pet.getRoomUnit().setHeadRotation(RoomUserRotation.values()[(pet.getRoomUnit().getHeadRotation().getValue() + 1 > 7 ? 0 : pet.getRoomUnit().getHeadRotation().getValue() + 1)]); pet.say(pet.getPetData().randomVocal(PetVocalsType.GENERIC_NEUTRAL)); return true; } From 516560f6032240999c9dbac5bb1c6615ae6422c2 Mon Sep 17 00:00:00 2001 From: brenoepic <59066707+brenoepics@users.noreply.github.com> Date: Fri, 8 Apr 2022 00:02:30 -0300 Subject: [PATCH 04/40] Fix ActionSit --- .../habbo/habbohotel/pets/actions/ActionSit.java | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionSit.java b/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionSit.java index 52ef037f..918530a0 100644 --- a/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionSit.java +++ b/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionSit.java @@ -1,5 +1,6 @@ package com.eu.habbo.habbohotel.pets.actions; +import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.pets.Pet; import com.eu.habbo.habbohotel.pets.PetAction; import com.eu.habbo.habbohotel.pets.PetTasks; @@ -10,12 +11,23 @@ import com.eu.habbo.habbohotel.users.Habbo; public class ActionSit extends PetAction { public ActionSit() { super(PetTasks.SIT, true); + this.statusToRemove.add(RoomUnitStatus.BEG); + this.statusToRemove.add(RoomUnitStatus.MOVE); + this.statusToRemove.add(RoomUnitStatus.LAY); + this.statusToRemove.add(RoomUnitStatus.DEAD); + this.statusToRemove.add(RoomUnitStatus.LAY); } @Override public boolean apply(Pet pet, Habbo habbo, String[] data) { if (pet.getTask() != PetTasks.SIT && !pet.getRoomUnit().hasStatus(RoomUnitStatus.SIT)) { - pet.getRoomUnit().setStatus(RoomUnitStatus.SIT, pet.getRoom().getStackHeight(pet.getRoomUnit().getX(), pet.getRoomUnit().getY(), false) - 0.50 + ""); + pet.getRoomUnit().cmdSit = true; + pet.getRoomUnit().setStatus(RoomUnitStatus.SIT, pet.getRoomUnit().getCurrentLocation().getStackHeight() + ""); + + Emulator.getThreading().run(() -> { + pet.getRoomUnit().cmdSit = false; + pet.clearPosture(); + }, 4000); if (pet.getHappyness() > 75) pet.say(pet.getPetData().randomVocal(PetVocalsType.PLAYFUL)); From 6625e4edc4c9dd50c2caf59eaaa34fcfbc7e76ae Mon Sep 17 00:00:00 2001 From: brenoepic <59066707+brenoepics@users.noreply.github.com> Date: Fri, 8 Apr 2022 00:17:14 -0300 Subject: [PATCH 05/40] Fix ActionDown --- .../habbohotel/pets/actions/ActionDown.java | 24 ++++++++++++++----- 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionDown.java b/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionDown.java index 2f601fb5..910d4563 100644 --- a/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionDown.java +++ b/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionDown.java @@ -1,5 +1,6 @@ package com.eu.habbo.habbohotel.pets.actions; +import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.pets.Pet; import com.eu.habbo.habbohotel.pets.PetAction; import com.eu.habbo.habbohotel.pets.PetTasks; @@ -10,18 +11,29 @@ import com.eu.habbo.habbohotel.users.Habbo; public class ActionDown extends PetAction { public ActionDown() { super(PetTasks.DOWN, true); + this.statusToRemove.add(RoomUnitStatus.BEG); this.statusToRemove.add(RoomUnitStatus.MOVE); - this.statusToRemove.add(RoomUnitStatus.SIT); + this.statusToRemove.add(RoomUnitStatus.DEAD); } @Override public boolean apply(Pet pet, Habbo habbo, String[] data) { - pet.getRoomUnit().setStatus(RoomUnitStatus.LAY, pet.getRoom().getStackHeight(pet.getRoomUnit().getX(), pet.getRoomUnit().getY(), false) + ""); + if (pet.getTask() != PetTasks.DOWN && !pet.getRoomUnit().hasStatus(RoomUnitStatus.LAY)) { + pet.getRoomUnit().cmdLay = true; + pet.getRoomUnit().setStatus(RoomUnitStatus.LAY, pet.getRoomUnit().getCurrentLocation().getStackHeight() + ""); - if (pet.getHappyness() > 50) - pet.say(pet.getPetData().randomVocal(PetVocalsType.PLAYFUL)); - else - pet.say(pet.getPetData().randomVocal(PetVocalsType.GENERIC_NEUTRAL)); + Emulator.getThreading().run(() -> { + pet.getRoomUnit().cmdLay = false; + pet.clearPosture(); + }, 4000); + + if (pet.getHappyness() > 50) + pet.say(pet.getPetData().randomVocal(PetVocalsType.PLAYFUL)); + else + pet.say(pet.getPetData().randomVocal(PetVocalsType.GENERIC_NEUTRAL)); + + return true; + } return true; } From 01c01dcf7055988243a035928e059051282b9a4f Mon Sep 17 00:00:00 2001 From: brenoepic <59066707+brenoepics@users.noreply.github.com> Date: Fri, 8 Apr 2022 00:17:30 -0300 Subject: [PATCH 06/40] Update ActionSit.java --- .../java/com/eu/habbo/habbohotel/pets/actions/ActionSit.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionSit.java b/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionSit.java index 918530a0..b9a1b762 100644 --- a/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionSit.java +++ b/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionSit.java @@ -15,7 +15,6 @@ public class ActionSit extends PetAction { this.statusToRemove.add(RoomUnitStatus.MOVE); this.statusToRemove.add(RoomUnitStatus.LAY); this.statusToRemove.add(RoomUnitStatus.DEAD); - this.statusToRemove.add(RoomUnitStatus.LAY); } @Override From 55015afd46af0ce7e566ceb4ff5637ef4c9d645c Mon Sep 17 00:00:00 2001 From: brenoepic <59066707+brenoepics@users.noreply.github.com> Date: Fri, 8 Apr 2022 00:37:40 -0300 Subject: [PATCH 07/40] Fix ActionPlayDead --- .../com/eu/habbo/habbohotel/pets/actions/ActionPlayDead.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionPlayDead.java b/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionPlayDead.java index 53aae87f..94b7a1ee 100644 --- a/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionPlayDead.java +++ b/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionPlayDead.java @@ -12,7 +12,6 @@ public class ActionPlayDead extends PetAction { super(PetTasks.PLAY_DEAD, true); this.statusToRemove.add(RoomUnitStatus.MOVE); this.statusToRemove.add(RoomUnitStatus.LAY); - this.statusToRemove.add(RoomUnitStatus.DEAD); } @Override From df0b34a7bd5a91ea725c3194cab4bd7b14cc4f64 Mon Sep 17 00:00:00 2001 From: brenoepic <59066707+brenoepics@users.noreply.github.com> Date: Fri, 8 Apr 2022 01:41:07 -0300 Subject: [PATCH 08/40] Fix ActionFollow --- .../eu/habbo/habbohotel/pets/actions/ActionFollow.java | 8 +++----- .../com/eu/habbo/threading/runnables/PetFollowHabbo.java | 6 +++++- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionFollow.java b/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionFollow.java index 767faa3f..39dff84d 100644 --- a/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionFollow.java +++ b/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionFollow.java @@ -11,16 +11,14 @@ import com.eu.habbo.threading.runnables.PetFollowHabbo; public class ActionFollow extends PetAction { public ActionFollow() { - super(PetTasks.FOLLOW, true); - this.statusToRemove.add(RoomUnitStatus.MOVE); - this.statusToRemove.add(RoomUnitStatus.LAY); - this.statusToRemove.add(RoomUnitStatus.DEAD); + super(PetTasks.FOLLOW, false); } @Override public boolean apply(Pet pet, Habbo habbo, String[] data) { - pet.clearPosture(); + pet.clearPosture(); + pet.setTask(PetTasks.FOLLOW); Emulator.getThreading().run(new PetFollowHabbo(pet, habbo, 0)); if (pet.getHappyness() > 75) diff --git a/src/main/java/com/eu/habbo/threading/runnables/PetFollowHabbo.java b/src/main/java/com/eu/habbo/threading/runnables/PetFollowHabbo.java index b790916f..d5a0ebe2 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/PetFollowHabbo.java +++ b/src/main/java/com/eu/habbo/threading/runnables/PetFollowHabbo.java @@ -39,7 +39,11 @@ public class PetFollowHabbo implements Runnable { this.pet.setTask(PetTasks.FOLLOW); } } - Emulator.getThreading().run(this, 500); + if(target.distance(this.pet.getRoomUnit().getCurrentLocation()) > 1) { + Emulator.getThreading().run(this, 500); + } else { + this.pet.setTask(PetTasks.FREE); + } } } } From 8e449e79a14f3d7f4e89856e4f2ca0beda94c601 Mon Sep 17 00:00:00 2001 From: brenoepic <59066707+brenoepics@users.noreply.github.com> Date: Fri, 8 Apr 2022 01:44:21 -0300 Subject: [PATCH 09/40] Fix Follow Left/Right --- .../eu/habbo/habbohotel/pets/actions/ActionFollowLeft.java | 5 ++--- .../eu/habbo/habbohotel/pets/actions/ActionFollowRight.java | 5 ++--- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionFollowLeft.java b/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionFollowLeft.java index 84b16e6a..31beb14a 100644 --- a/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionFollowLeft.java +++ b/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionFollowLeft.java @@ -10,14 +10,13 @@ import com.eu.habbo.threading.runnables.PetFollowHabbo; public class ActionFollowLeft extends PetAction { public ActionFollowLeft() { - super(PetTasks.FOLLOW, true); + super(PetTasks.FOLLOW, false); } @Override public boolean apply(Pet pet, Habbo habbo, String[] data) { - //Follow left. pet.clearPosture(); - + pet.setTask(PetTasks.FOLLOW); Emulator.getThreading().run(new PetFollowHabbo(pet, habbo, -2)); if (pet.getHappyness() > 75) diff --git a/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionFollowRight.java b/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionFollowRight.java index e00de028..3e51d877 100644 --- a/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionFollowRight.java +++ b/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionFollowRight.java @@ -10,14 +10,13 @@ import com.eu.habbo.threading.runnables.PetFollowHabbo; public class ActionFollowRight extends PetAction { public ActionFollowRight() { - super(PetTasks.FOLLOW, true); + super(PetTasks.FOLLOW, false); } @Override public boolean apply(Pet pet, Habbo habbo, String[] data) { - //Follow right. pet.clearPosture(); - + pet.setTask(PetTasks.FOLLOW); Emulator.getThreading().run(new PetFollowHabbo(pet, habbo, +2)); if (pet.getHappyness() > 75) From 6484d7f563959d406eeaed8df2cd2f0e2efb038e Mon Sep 17 00:00:00 2001 From: Oliver Date: Fri, 8 Apr 2022 15:30:26 +0000 Subject: [PATCH 10/40] Add Ring of Fire to PetManager.java --- src/main/java/com/eu/habbo/habbohotel/pets/PetManager.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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..d2a4013a 100644 --- a/src/main/java/com/eu/habbo/habbohotel/pets/PetManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/pets/PetManager.java @@ -62,6 +62,7 @@ public class PetManager { this.put(35, new ActionWings()); this.put(36, new ActionBreatheFire()); this.put(38, new ActionTorch()); + this.put(42, new ActionRingOfFire()); this.put(43, new ActionEat()); this.put(46, new ActionBreed()); @@ -519,4 +520,4 @@ public class PetManager { return false; } -} \ No newline at end of file +} From 66d8db7fb422a510bae203365acd5079d136de45 Mon Sep 17 00:00:00 2001 From: Oliver Date: Fri, 8 Apr 2022 15:33:11 +0000 Subject: [PATCH 11/40] Add some dragon stuff to RoomUnitStatus.java --- .../java/com/eu/habbo/habbohotel/rooms/RoomUnitStatus.java | 5 +++++ 1 file changed, 5 insertions(+) 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..b0108be0 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomUnitStatus.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomUnitStatus.java @@ -42,6 +42,11 @@ public enum RoomUnitStatus { RELAX("rlx"), WINGS("wng", true), FLAME("flm"), + 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 + RIP("rip"), GROW("grw"), GROW_1("grw1"), From 5e44354ce383439fc606e38720287bbb3ca16e20 Mon Sep 17 00:00:00 2001 From: Oliver Date: Fri, 8 Apr 2022 15:34:49 +0000 Subject: [PATCH 12/40] Upload ActionRingOfFire --- .../pets/actions/ActionRingOfFire.java | 32 +++++++++++++++++++ 1 file changed, 32 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..c3f3c611 --- /dev/null +++ b/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionRingOfFire.java @@ -0,0 +1,32 @@ +package com.eu.habbo.habbohotel.pets.actions; + +import com.eu.habbo.Emulator; +import com.eu.habbo.habbohotel.pets.Pet; +import com.eu.habbo.habbohotel.pets.PetAction; +import com.eu.habbo.habbohotel.pets.PetVocalsType; +import com.eu.habbo.habbohotel.rooms.RoomUnitStatus; +import com.eu.habbo.habbohotel.users.Habbo; +import com.eu.habbo.threading.runnables.PetClearPosture; + +public class ActionRingOfFire extends PetAction { + public ActionRingOfFire() { + super(null, true); + + this.minimumActionDuration = 2000; + this.statusToSet.add(RoomUnitStatus.RINGOFFIRE); + } + + // TO-DO: Make it specifically for the toy tree. I dont have the skills for that + @Override + public boolean apply(Pet pet, Habbo habbo, String[] data) { + if (pet.getHappyness() < 50) { + pet.say(pet.getPetData().randomVocal(PetVocalsType.DISOBEY)); + return false; + } else { + pet.say(pet.getPetData().randomVocal(PetVocalsType.GENERIC_NEUTRAL)); + } + + Emulator.getThreading().run(new PetClearPosture(pet, RoomUnitStatus.RINGOFFIRE, null, false), this.minimumActionDuration); + return true; + } +} \ No newline at end of file From 12ad3adfcc1b05c522403c0c733ff0354c3cd1e3 Mon Sep 17 00:00:00 2001 From: Oliver Date: Fri, 8 Apr 2022 16:19:14 +0000 Subject: [PATCH 13/40] Add Dance & Mambo --- .../habbohotel/pets/actions/ActionDance.java | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionDance.java diff --git a/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionDance.java b/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionDance.java new file mode 100644 index 00000000..d3bcbc5a --- /dev/null +++ b/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionDance.java @@ -0,0 +1,32 @@ +package com.eu.habbo.habbohotel.pets.actions; + +import com.eu.habbo.Emulator; +import com.eu.habbo.habbohotel.pets.Pet; +import com.eu.habbo.habbohotel.pets.PetAction; +import com.eu.habbo.habbohotel.pets.PetVocalsType; +import com.eu.habbo.habbohotel.rooms.RoomUnitStatus; +import com.eu.habbo.habbohotel.users.Habbo; +import com.eu.habbo.threading.runnables.PetClearPosture; + +public class ActionDance extends PetAction { + public ActionDance() { + super(null, true); + + this.minimumActionDuration = 3000; + this.statusToSet.add(RoomUnitStatus.DANCE); +} + + // mambojambo works better than ur dancing skills + @Override + public boolean apply(Pet pet, Habbo habbo, String[] data) { + if (pet.getHappyness() < 50) { + pet.say(pet.getPetData().randomVocal(PetVocalsType.DISOBEY)); + return false; + } else { + pet.say(pet.getPetData().randomVocal(PetVocalsType.GENERIC_NEUTRAL)); + } + + Emulator.getThreading().run(new PetClearPosture(pet, RoomUnitStatus.DANCE, null, false), this.minimumActionDuration); + return true; + } +} From fd23c73b24649fe32a25b4e330457481f1fe6f2a Mon Sep 17 00:00:00 2001 From: Oliver Date: Fri, 8 Apr 2022 16:20:14 +0000 Subject: [PATCH 14/40] Add dance and Mambo to PetManager.java --- src/main/java/com/eu/habbo/habbohotel/pets/PetManager.java | 2 ++ 1 file changed, 2 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 d2a4013a..f7ebf614 100644 --- a/src/main/java/com/eu/habbo/habbohotel/pets/PetManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/pets/PetManager.java @@ -52,6 +52,7 @@ public class PetManager { this.put(15, new ActionFollowLeft()); this.put(16, new ActionFollowRight()); this.put(17, new ActionPlayFootball()); + this.put(21, new ActionDance()); this.put(24, new ActionMoveForward()); this.put(25, new ActionTurnLeft()); this.put(26, new ActionTurnRight()); @@ -59,6 +60,7 @@ public class PetManager { this.put(28, new ActionCroak()); this.put(29, new ActionDip()); this.put(30, new ActionWave()); + this.put(31, new ActionDance()); this.put(35, new ActionWings()); this.put(36, new ActionBreatheFire()); this.put(38, new ActionTorch()); From 397edaeba8b3a8d6e9a31c59886bf7cc35a49fe7 Mon Sep 17 00:00:00 2001 From: brenoepic <59066707+brenoepics@users.noreply.github.com> Date: Fri, 8 Apr 2022 13:28:20 -0300 Subject: [PATCH 15/40] Fix PetPickupEvent --- .../eu/habbo/messages/incoming/rooms/pets/PetPickupEvent.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/PetPickupEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/PetPickupEvent.java index 211375c3..8f6d489f 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/PetPickupEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/PetPickupEvent.java @@ -23,7 +23,7 @@ public class PetPickupEvent extends MessageHandler { Pet pet = room.getPet(petId); if (pet != null) { - if (this.client.getHabbo().getHabboInfo().getId() == pet.getId() || room.getOwnerId() == this.client.getHabbo().getHabboInfo().getId() || this.client.getHabbo().hasPermission(Permission.ACC_ANYROOMOWNER)) { + if (this.client.getHabbo().getHabboInfo().getId() == pet.getUserId() || room.getOwnerId() == this.client.getHabbo().getHabboInfo().getId() || this.client.getHabbo().hasPermission(Permission.ACC_ANYROOMOWNER)) { if (!this.client.getHabbo().hasPermission(Permission.ACC_UNLIMITED_PETS) && this.client.getHabbo().getInventory().getPetsComponent().getPets().size() >= PetManager.MAXIMUM_PET_INVENTORY_SIZE) { this.client.getHabbo().alert(Emulator.getTexts().getValue("error.pets.max.inventory").replace("%amount%", PetManager.MAXIMUM_PET_INVENTORY_SIZE + "")); return; From 01e082136fba9eaa01ce9b2dedc5826ba515fce5 Mon Sep 17 00:00:00 2001 From: Oliver Date: Fri, 8 Apr 2022 22:43:10 +0000 Subject: [PATCH 16/40] Cleaned up RoomUnitStatus and added some stuff --- .../habbohotel/rooms/RoomUnitStatus.java | 74 +++++++++++-------- 1 file changed, 42 insertions(+), 32 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 b0108be0..8ff934a6 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomUnitStatus.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomUnitStatus.java @@ -3,50 +3,74 @@ package com.eu.habbo.habbohotel.rooms; public enum RoomUnitStatus { MOVE("mv", true), + // SIT SIT_IN("sit-in"), SIT("sit", true), SIT_OUT("sit-out"), + // lay or down LAY_IN("lay-in"), LAY("lay", true), LAY_OUT("lay-out"), - FLAT_CONTROL("flatctrl"), - SIGN("sign"), - GESTURE("gst"), - WAVE("wav"), - TRADING("trd"), - - DIP("dip"), - + // eat EAT_IN("eat-in"), EAT("eat"), EAT_OUT("eat-out"), - BEG("beg", true), + // basic controls and gestures + FLAT_CONTROL("flatctrl"), + SIGN("sign"), + GESTURE("gst"), + WAVE("wav"), // this doesnt exist? + TRADING("trd"), // this doesnt exist? + KICK("kck"), // kicks leg, horse atleast + SPEAK("spk"), // speak animation + SRP("srp"), // SURPRISED very funny with monkey + SRP_IN("srp-in"), + SWIM("swm"), // supposedly should happen when monkey reaches water | essentially dip is useless + // sleep + SLEEP_IN("slp-in"), + SLEEP("slp", true), // sleep + SLEEP_OUT("slp-out"), + + // play dead DEAD_IN("ded-in"), - DEAD("ded", true), + DEAD("ded", true), // play dead DEAD_OUT("ded-out"), + // jump JUMP_IN("jmp-in"), - JUMP("jmp", true), + JUMP("jmp", true), // jump JUMP_OUT("jmp-out"), + // play with toy PLAY_IN("pla-in"), - PLAY("pla", true), + PLAY("pla", true), // play PLAY_OUT("pla-out"), - SPEAK("spk"), - CROAK("crk"), + // specific commands + DIP("dip"), // walks towards random water + BEG("beg", true), // begs for food + WAG_TAIL("wag"), // self-explanatory + DANCE("dan"), // dances, for example spider and monkey + AMS("ams"), // SOME WEIRD PUPPET SHIT PROBABLY SPEAK FOR MONKEY + TURN("trn"), // turns + SPIN("spn"), // spinny spin + CROAK("crk"), // speak but for frog + FLAT("flt"), // flat, falls on stomach (spider n shit) + FLAT_IN("flt-in"), // flat-in? dunno dc + BOUNCE("bnc"), // bounces once RELAX("rlx"), - WINGS("wng", true), - FLAME("flm"), - RINGOFFIRE("rng"), // ring of fire for dragon, toy undone + WINGS("wng", true), // spreads wings dragon + FLAME("flm"), // breathe fire + RINGOFFIRE("rng"), // ring of fire for dragon related to toy 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 + // monsterplant shit i aint touching that RIP("rip"), GROW("grw"), GROW_1("grw1"), @@ -55,21 +79,7 @@ public enum RoomUnitStatus { GROW_4("grw4"), GROW_5("grw5"), GROW_6("grw6"), - GROW_7("grw7"), - - KICK("kck"), - WAG_TAIL("wag"), - DANCE("dan"), - AMS("ams"), - SWIM("swm"), - TURN("trn"), - - SRP("srp"), - SRP_IN("srp-in"), - - SLEEP_IN("slp-in"), - SLEEP("slp", true), - SLEEP_OUT("slp-out"); + GROW_7("grw7"); public final String key; public final boolean removeWhenWalking; From 02ba30072a1c07da3f3836d30ab96aba819e617d Mon Sep 17 00:00:00 2001 From: Oliver Date: Fri, 8 Apr 2022 22:44:10 +0000 Subject: [PATCH 17/40] Add Flat command --- .../habbohotel/pets/actions/ActionFlat.java | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionFlat.java diff --git a/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionFlat.java b/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionFlat.java new file mode 100644 index 00000000..90977f1e --- /dev/null +++ b/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionFlat.java @@ -0,0 +1,33 @@ +package com.eu.habbo.habbohotel.pets.actions; + +import com.eu.habbo.Emulator; +import com.eu.habbo.habbohotel.pets.Pet; +import com.eu.habbo.habbohotel.pets.PetAction; +import com.eu.habbo.habbohotel.pets.PetVocalsType; +import com.eu.habbo.habbohotel.rooms.RoomUnitStatus; +import com.eu.habbo.habbohotel.users.Habbo; +import com.eu.habbo.threading.runnables.PetClearPosture; + +public class ActionFlat extends PetAction { + public ActionFlat() { + super(null, true); + + this.minimumActionDuration = 4000; + this.statusToSet.add(RoomUnitStatus.FLAT); + } + + // flat attack + @Override + public boolean apply(Pet pet, Habbo habbo, String[] data) { + + if (pet.getHappyness() > 30) { + Emulator.getThreading().run(new PetClearPosture(pet, RoomUnitStatus.FLAT, null, false), this.minimumActionDuration); + pet.say(pet.getPetData().randomVocal(PetVocalsType.GENERIC_NEUTRAL)); + return true; + } else { + pet.say(pet.getPetData().randomVocal(PetVocalsType.DISOBEY)); + return false; + } + } +} + From 8940b2d727c47a5321b78c99822794068d3a754c Mon Sep 17 00:00:00 2001 From: Oliver Date: Fri, 8 Apr 2022 22:44:47 +0000 Subject: [PATCH 18/40] Add Bounce command --- .../habbohotel/pets/actions/ActionBounce.java | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionBounce.java diff --git a/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionBounce.java b/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionBounce.java new file mode 100644 index 00000000..6b042a8f --- /dev/null +++ b/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionBounce.java @@ -0,0 +1,32 @@ +package com.eu.habbo.habbohotel.pets.actions; + +import com.eu.habbo.Emulator; +import com.eu.habbo.habbohotel.pets.Pet; +import com.eu.habbo.habbohotel.pets.PetAction; +import com.eu.habbo.habbohotel.pets.PetVocalsType; +import com.eu.habbo.habbohotel.rooms.RoomUnitStatus; +import com.eu.habbo.habbohotel.users.Habbo; +import com.eu.habbo.threading.runnables.PetClearPosture; + +public class ActionBounce extends PetAction { + public ActionBounce() { + super(null, true); + + this.minimumActionDuration = 1000; + this.statusToSet.add(RoomUnitStatus.BOUNCE); + } + + // bouncy bounce + @Override + public boolean apply(Pet pet, Habbo habbo, String[] data) { + + if (pet.getHappyness() > 50) { + Emulator.getThreading().run(new PetClearPosture(pet, RoomUnitStatus.BOUNCE, null, false), this.minimumActionDuration); + pet.say(pet.getPetData().randomVocal(PetVocalsType.GENERIC_NEUTRAL)); + return true; + } else { + pet.say(pet.getPetData().randomVocal(PetVocalsType.DISOBEY)); + return false; + } + } +} From 49f62727f9678051b690d3ceaaa49d74a763e103 Mon Sep 17 00:00:00 2001 From: Oliver Date: Fri, 8 Apr 2022 22:45:05 +0000 Subject: [PATCH 19/40] Upload New File --- .../pets/actions/ActionWagTail.java | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionWagTail.java diff --git a/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionWagTail.java b/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionWagTail.java new file mode 100644 index 00000000..04e3d594 --- /dev/null +++ b/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionWagTail.java @@ -0,0 +1,34 @@ +package com.eu.habbo.habbohotel.pets.actions; + +import com.eu.habbo.Emulator; +import com.eu.habbo.habbohotel.pets.Pet; +import com.eu.habbo.habbohotel.pets.PetAction; +import com.eu.habbo.habbohotel.pets.PetVocalsType; +import com.eu.habbo.habbohotel.rooms.RoomUnitStatus; +import com.eu.habbo.habbohotel.users.Habbo; +import com.eu.habbo.threading.runnables.PetClearPosture; + +public class ActionWagTail extends PetAction { + public ActionWagTail() { + super(null, false); + + this.minimumActionDuration = 2000; + this.statusToRemove.add(RoomUnitStatus.MOVE); + this.statusToSet.add(RoomUnitStatus.WAG_TAIL); + } + + // waggy waggy + @Override + public boolean apply(Pet pet, Habbo habbo, String[] data) { + pet.clearPosture(); + + if (pet.getHappyness() > 40) { + Emulator.getThreading().run(new PetClearPosture(pet, RoomUnitStatus.WAG_TAIL, null, false), this.minimumActionDuration); + pet.say(pet.getPetData().randomVocal(PetVocalsType.GENERIC_NEUTRAL)); + return true; + } else { + pet.say(pet.getPetData().randomVocal(PetVocalsType.DISOBEY)); + return false; + } + } +} From 85f71ca745f4144a11189adc48bf6c6b0fd4be94 Mon Sep 17 00:00:00 2001 From: Oliver Date: Fri, 8 Apr 2022 22:45:33 +0000 Subject: [PATCH 20/40] Upload New File --- .../habbohotel/pets/actions/ActionSpin.java | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionSpin.java diff --git a/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionSpin.java b/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionSpin.java new file mode 100644 index 00000000..46dc42e2 --- /dev/null +++ b/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionSpin.java @@ -0,0 +1,32 @@ +package com.eu.habbo.habbohotel.pets.actions; + +import com.eu.habbo.Emulator; +import com.eu.habbo.habbohotel.pets.Pet; +import com.eu.habbo.habbohotel.pets.PetAction; +import com.eu.habbo.habbohotel.pets.PetVocalsType; +import com.eu.habbo.habbohotel.rooms.RoomUnitStatus; +import com.eu.habbo.habbohotel.users.Habbo; +import com.eu.habbo.threading.runnables.PetClearPosture; + +public class ActionSpin extends PetAction { + public ActionSpin() { + super(null, true); + + this.minimumActionDuration = 1500; + this.statusToSet.add(RoomUnitStatus.SPIN); + } + + // spinny spin + @Override + public boolean apply(Pet pet, Habbo habbo, String[] data) { + + if (pet.getHappyness() > 50) { + Emulator.getThreading().run(new PetClearPosture(pet, RoomUnitStatus.SPIN, null, false), this.minimumActionDuration); + pet.say(pet.getPetData().randomVocal(PetVocalsType.GENERIC_NEUTRAL)); + return true; + } else { + pet.say(pet.getPetData().randomVocal(PetVocalsType.DISOBEY)); + return false; + } + } +} \ No newline at end of file From 3427700897321c91399490ba3b1b320da6742bd5 Mon Sep 17 00:00:00 2001 From: Oliver Date: Fri, 8 Apr 2022 22:49:15 +0000 Subject: [PATCH 21/40] Update PetManager for new commands --- 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 f7ebf614..e8fd5886 100644 --- a/src/main/java/com/eu/habbo/habbohotel/pets/PetManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/pets/PetManager.java @@ -52,7 +52,10 @@ public class PetManager { this.put(15, new ActionFollowLeft()); this.put(16, new ActionFollowRight()); this.put(17, new ActionPlayFootball()); + this.put(19, new ActionBounce()); + this.put(20, new ActionFlat()); this.put(21, new ActionDance()); + this.put(22, new ActionSpin()); this.put(24, new ActionMoveForward()); this.put(25, new ActionTurnLeft()); this.put(26, new ActionTurnRight()); @@ -66,6 +69,7 @@ public class PetManager { this.put(38, new ActionTorch()); this.put(42, new ActionRingOfFire()); this.put(43, new ActionEat()); + this.put(44, new ActionWagTail()); this.put(46, new ActionBreed()); } 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 22/40] 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 23/40] 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 24/40] 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 25/40] 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 26/40] 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 27/40] 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 28/40] 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 29/40] 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 30/40] 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 31/40] 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 From a0193c48b38c6708ab8b3146761fc0155bd3be3c Mon Sep 17 00:00:00 2001 From: brenoepic <59066707+brenoepics@users.noreply.github.com> Date: Sun, 10 Apr 2022 00:11:14 -0300 Subject: [PATCH 32/40] Pet Fixes + fix conflicts --- .../interactions/pets/InteractionPetTree.java | 5 ++--- .../com/eu/habbo/habbohotel/pets/PetManager.java | 9 +++------ .../java/com/eu/habbo/habbohotel/rooms/Room.java | 4 ++++ .../eu/habbo/habbohotel/rooms/RoomUnitStatus.java | 15 +++++---------- 4 files changed, 14 insertions(+), 19 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 3369312c..26eaed36 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 @@ -46,14 +46,13 @@ public class InteractionPetTree extends InteractionDefault { super.onWalkOn(roomUnit, room, objects); Pet pet = room.getPet(roomUnit); - if (pet != null && pet.getPetData().getType() == 12 && this.getOccupyingTiles(room.getLayout()).contains(pet.getRoomUnit().getGoal())) { + if (pet != null && pet.getPetData().haveToyItem(this.getBaseItem()) && 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); @@ -99,7 +98,7 @@ 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; + return roomUnit.getRoomUnitType() == RoomUnitType.PET && pet != null && pet.getPetData().haveToyItem(this.getBaseItem()); } @Override 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 9cc4f85f..3e38702e 100644 --- a/src/main/java/com/eu/habbo/habbohotel/pets/PetManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/pets/PetManager.java @@ -3,10 +3,7 @@ package com.eu.habbo.habbohotel.pets; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.items.Item; -import com.eu.habbo.habbohotel.items.interactions.pets.InteractionNest; -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.InteractionPetToy; +import com.eu.habbo.habbohotel.items.interactions.pets.*; import com.eu.habbo.habbohotel.pets.actions.*; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomTile; @@ -207,7 +204,7 @@ public class PetManager { PetData.generalFoodItems.add(baseItem); else if (baseItem.getInteractionType().getType() == InteractionPetDrink.class) PetData.generalDrinkItems.add(baseItem); - else if (baseItem.getInteractionType().getType() == InteractionPetToy.class) + else if (baseItem.getInteractionType().getType() == InteractionPetToy.class || baseItem.getInteractionType().getType() == InteractionPetTree.class) PetData.generalToyItems.add(baseItem); } else { PetData data = this.getPetData(set.getInt("pet_id")); @@ -219,7 +216,7 @@ public class PetManager { data.addFoodItem(baseItem); else if (baseItem.getInteractionType().getType() == InteractionPetDrink.class) data.addDrinkItem(baseItem); - else if (baseItem.getInteractionType().getType() == InteractionPetToy.class) + else if (baseItem.getInteractionType().getType() == InteractionPetToy.class || baseItem.getInteractionType().getType() == InteractionPetTree.class) data.addToyItem(baseItem); } } 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 3e49173a..42d3b428 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java @@ -2542,6 +2542,8 @@ public class Room implements Comparable, ISerialize, Runnable { this.roomSpecialTypes.removePetDrink((InteractionPetDrink) item); } else if (item instanceof InteractionPetFood) { this.roomSpecialTypes.removePetFood((InteractionPetFood) item); + } else if (item instanceof InteractionPetTree) { + this.roomSpecialTypes.removeUndefined(item); } else if (item instanceof InteractionMoodLight) { this.roomSpecialTypes.removeUndefined(item); } else if (item instanceof InteractionPyramid) { @@ -2578,6 +2580,8 @@ public class Room implements Comparable, ISerialize, Runnable { this.roomSpecialTypes.removeUndefined(item); } else if (item instanceof InteractionSnowboardSlope) { this.roomSpecialTypes.removeUndefined(item); + } else if (item instanceof InteractionBuildArea) { + this.roomSpecialTypes.removeUndefined(item); } } } 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 10e07c18..44fa79b1 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomUnitStatus.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomUnitStatus.java @@ -42,10 +42,10 @@ public enum RoomUnitStatus { RELAX("rlx"), WINGS("wng", true), FLAME("flm"), - 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", true), + SWING("swg", true), + HANG("hg", true), + ROLL("rll", true), RIP("rip"), GROW("grw"), @@ -69,12 +69,7 @@ public enum RoomUnitStatus { SLEEP_IN("slp-in"), SLEEP("slp", true), - SLEEP_OUT("slp-out"), - - RINGOFFIRE("rng"), - SWING("swg"), - HANG("hg"), - ROLL("rll"); + SLEEP_OUT("slp-out"); public final String key; public final boolean removeWhenWalking; From 90fec0f18a822ed814633181810d7ba479337245 Mon Sep 17 00:00:00 2001 From: brenoepic <59066707+brenoepics@users.noreply.github.com> Date: Sun, 10 Apr 2022 19:35:51 -0300 Subject: [PATCH 33/40] Fix turtles roll --- .../habbo/habbohotel/pets/actions/ActionRoll.java | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) 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 index 3a58caed..7047344b 100644 --- a/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionRoll.java +++ b/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionRoll.java @@ -1,5 +1,6 @@ package com.eu.habbo.habbohotel.pets.actions; +import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.items.interactions.pets.InteractionPetTree; import com.eu.habbo.habbohotel.pets.Pet; import com.eu.habbo.habbohotel.pets.PetAction; @@ -7,6 +8,7 @@ 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.rooms.RoomUnitStatus; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.users.HabboItem; @@ -36,7 +38,7 @@ public class ActionRoll extends PetAction { ArrayList tileList = new ArrayList<>(); for (HabboItem petTree : petTrees) { - if (petTree == null || petTree.getRoomId() != pet.getRoom().getId()) continue; + if (petTree == null || !pet.getPetData().haveToyItem(petTree.getBaseItem())) continue; tileList.addAll(petTree.getOccupyingTiles(pet.getRoom().getLayout())); } @@ -62,6 +64,17 @@ public class ActionRoll extends PetAction { } else pet.getRoomUnit().setGoalLocation(goal); return true; } else { + if (pet.getPetData().getToyItems().stream().noneMatch(item -> item.getInteractionType().getType() == InteractionPetTree.class)) { + pet.getRoomUnit().setCanWalk(false); + pet.getRoomUnit().setStatus(RoomUnitStatus.ROLL, pet.getRoomUnit().getCurrentLocation().getStackHeight() + ""); + + Emulator.getThreading().run(() -> { + pet.getRoomUnit().setCanWalk(true); + pet.clearPosture(); + }, 4000); + return true; + } + pet.say(pet.getPetData().randomVocal(PetVocalsType.DISOBEY)); return false; } From e3f4d2898c4663a821759842a2eacd94626a4164 Mon Sep 17 00:00:00 2001 From: Oliver Date: Mon, 11 Apr 2022 13:00:26 +0000 Subject: [PATCH 34/40] Fix ActionCroak --- .../habbo/habbohotel/pets/actions/ActionCroak.java | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionCroak.java b/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionCroak.java index 6ad3b69f..bd165833 100644 --- a/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionCroak.java +++ b/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionCroak.java @@ -21,8 +21,18 @@ public class ActionCroak extends PetAction { Emulator.getThreading().run(new PetClearPosture(pet, RoomUnitStatus.CROAK, null, false), 2000); - if (pet.getHappyness() > 80) - pet.say(pet.getPetData().randomVocal(PetVocalsType.PLAYFUL)); + if (pet.getHappyness() > 70) + pet.say(pet.getPetData().randomVocal(PetVocalsType.GENERIC_HAPPY)); + else if (pet.getHappyness() < 30) + pet.say(pet.getPetData().randomVocal(PetVocalsType.GENERIC_SAD)); + else if (pet.getLevelHunger() > 65) + pet.say(pet.getPetData().randomVocal(PetVocalsType.HUNGRY)); + else if (pet.getLevelThirst() > 65) + pet.say(pet.getPetData().randomVocal(PetVocalsType.THIRSTY)); + else if (pet.getEnergy() < 25) + pet.say(pet.getPetData().randomVocal(PetVocalsType.TIRED)); + else if (pet.getTask() == PetTasks.NEST || pet.getTask() == PetTasks.DOWN) + pet.say(pet.getPetData().randomVocal(PetVocalsType.SLEEPING)); return true; } From 0cc5b5cb73249881f04f277fab415470e964f5aa Mon Sep 17 00:00:00 2001 From: brenoepic <59066707+brenoepics@users.noreply.github.com> Date: Mon, 11 Apr 2022 14:44:36 -0300 Subject: [PATCH 35/40] code cleanup --- .../interactions/pets/InteractionPetTree.java | 7 +- .../com/eu/habbo/habbohotel/pets/Pet.java | 32 +++++++- .../com/eu/habbo/habbohotel/pets/PetData.java | 21 +++++- .../habbohotel/pets/actions/ActionCroak.java | 4 +- .../habbohotel/pets/actions/ActionDown.java | 3 +- .../habbohotel/pets/actions/ActionEat.java | 2 +- .../habbohotel/pets/actions/ActionFollow.java | 1 - .../habbohotel/pets/actions/ActionHang.java | 66 +++++----------- .../habbohotel/pets/actions/ActionJump.java | 2 +- .../habbohotel/pets/actions/ActionNest.java | 1 - .../habbohotel/pets/actions/ActionPlay.java | 14 ++-- .../pets/actions/ActionPlayDead.java | 2 +- .../habbohotel/pets/actions/ActionRelax.java | 2 +- .../pets/actions/ActionRingOfFire.java | 66 +++++----------- .../habbohotel/pets/actions/ActionRoll.java | 75 ++++--------------- .../habbohotel/pets/actions/ActionSilent.java | 2 +- .../habbohotel/pets/actions/ActionSit.java | 3 +- .../habbohotel/pets/actions/ActionSwing.java | 60 ++++----------- .../habbohotel/pets/actions/ActionTorch.java | 4 - .../pets/actions/ActionWagTail.java | 11 +-- .../habbohotel/pets/actions/ActionWave.java | 10 +-- 21 files changed, 134 insertions(+), 254 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 26eaed36..3faa3313 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 @@ -28,7 +28,6 @@ public class InteractionPetTree extends InteractionDefault { 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; } } @@ -36,7 +35,6 @@ public class InteractionPetTree extends InteractionDefault { 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; } } @@ -65,10 +63,10 @@ public class InteractionPetTree extends InteractionDefault { 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())) { + if (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.clearPosture(); } pet.getRoomUnit().setCanWalk(true); pet.packetUpdate = true; @@ -90,7 +88,6 @@ public class InteractionPetTree extends InteractionDefault { if (pet != null) { pet.getRoomUnit().clearStatus(); - pet.getRoomUnit().setStatus(RoomUnitStatus.RELAX, pet.getRoomUnit().getCurrentLocation().getStackHeight() + ""); pet.packetUpdate = true; } } diff --git a/src/main/java/com/eu/habbo/habbohotel/pets/Pet.java b/src/main/java/com/eu/habbo/habbohotel/pets/Pet.java index afd7e035..883deb5d 100644 --- a/src/main/java/com/eu/habbo/habbohotel/pets/Pet.java +++ b/src/main/java/com/eu/habbo/habbohotel/pets/Pet.java @@ -2,6 +2,7 @@ package com.eu.habbo.habbohotel.pets; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.achievements.AchievementManager; +import com.eu.habbo.habbohotel.items.interactions.pets.InteractionPetTree; import com.eu.habbo.habbohotel.rooms.*; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.users.HabboItem; @@ -18,9 +19,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.sql.*; -import java.util.Calendar; -import java.util.Map; -import java.util.TimeZone; +import java.util.*; public class Pet implements ISerialize, Runnable { private static final Logger LOGGER = LoggerFactory.getLogger(Pet.class); @@ -481,16 +480,41 @@ public class Pet implements ISerialize, Runnable { } - public void findToy() { + public boolean findToy() { HabboItem item = this.petData.randomToyItem(this.room.getRoomSpecialTypes().getPetToys()); { if (item != null) { this.roomUnit.setCanWalk(true); + if (this.getRoomUnit().getCurrentLocation().distance(this.room.getLayout().getTile(item.getX(), item.getY())) == 0) { + try { + item.onWalkOn(this.getRoomUnit(), this.getRoom(), null); + } catch (Exception ignored) {} + return true; + } this.roomUnit.setGoalLocation(this.room.getLayout().getTile(item.getX(), item.getY())); + return true; } } + return false; } + public boolean findTree(PetTasks task) { + HabboItem item = this.petData.randomTreeItem(this.room.getRoomSpecialTypes().getItemsOfType(InteractionPetTree.class)); + + if (item != null) { + this.roomUnit.setCanWalk(true); + this.setTask(task); + if (this.getRoomUnit().getCurrentLocation().distance(this.room.getLayout().getTile(item.getX(), item.getY())) == 0) { + try { + item.onWalkOn(this.getRoomUnit(), this.getRoom(), null); + } catch (Exception ignored) {} + return true; + } + this.roomUnit.setGoalLocation(this.room.getLayout().getTile(item.getX(), item.getY())); + return true; + } + return false; + } public void randomHappyAction() { if (this.petData.actionsHappy.length > 0) { diff --git a/src/main/java/com/eu/habbo/habbohotel/pets/PetData.java b/src/main/java/com/eu/habbo/habbohotel/pets/PetData.java index 1eae8a4b..592358f0 100644 --- a/src/main/java/com/eu/habbo/habbohotel/pets/PetData.java +++ b/src/main/java/com/eu/habbo/habbohotel/pets/PetData.java @@ -2,10 +2,7 @@ package com.eu.habbo.habbohotel.pets; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.items.Item; -import com.eu.habbo.habbohotel.items.interactions.pets.InteractionNest; -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.InteractionPetToy; +import com.eu.habbo.habbohotel.items.interactions.pets.*; import com.eu.habbo.habbohotel.users.HabboItem; import gnu.trove.map.hash.THashMap; import gnu.trove.set.hash.THashSet; @@ -233,6 +230,22 @@ public class PetData implements Comparable { return null; } + public HabboItem randomTreeItem(THashSet trees) { + List treeList = new ArrayList<>(); + + for (HabboItem tree : trees) { + if (this.haveToyItem(tree)) { + treeList.add(tree); + } + } + + if (!treeList.isEmpty()) { + Collections.shuffle(treeList); + return treeList.get(0); + } + + return null; + } public PetVocal randomVocal(PetVocalsType type) { //TODO: Remove this useless copying. diff --git a/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionCroak.java b/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionCroak.java index 6ad3b69f..0ce96306 100644 --- a/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionCroak.java +++ b/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionCroak.java @@ -17,9 +17,9 @@ public class ActionCroak extends PetAction { @Override public boolean apply(Pet pet, Habbo habbo, String[] data) { - pet.getRoomUnit().setStatus(RoomUnitStatus.CROAK, "0"); + pet.getRoomUnit().setStatus(RoomUnitStatus.CROAK, pet.getRoomUnit().getCurrentLocation().getStackHeight() + ""); - Emulator.getThreading().run(new PetClearPosture(pet, RoomUnitStatus.CROAK, null, false), 2000); + Emulator.getThreading().run(new PetClearPosture(pet, RoomUnitStatus.CROAK, null, false), this.minimumActionDuration); if (pet.getHappyness() > 80) pet.say(pet.getPetData().randomVocal(PetVocalsType.PLAYFUL)); diff --git a/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionDown.java b/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionDown.java index 910d4563..8e46dc5a 100644 --- a/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionDown.java +++ b/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionDown.java @@ -14,6 +14,7 @@ public class ActionDown extends PetAction { this.statusToRemove.add(RoomUnitStatus.BEG); this.statusToRemove.add(RoomUnitStatus.MOVE); this.statusToRemove.add(RoomUnitStatus.DEAD); + this.minimumActionDuration = 4000; } @Override @@ -25,7 +26,7 @@ public class ActionDown extends PetAction { Emulator.getThreading().run(() -> { pet.getRoomUnit().cmdLay = false; pet.clearPosture(); - }, 4000); + }, this.minimumActionDuration); if (pet.getHappyness() > 50) pet.say(pet.getPetData().randomVocal(PetVocalsType.PLAYFUL)); diff --git a/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionEat.java b/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionEat.java index 0b701c6d..b844a9b2 100644 --- a/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionEat.java +++ b/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionEat.java @@ -20,7 +20,7 @@ public class ActionEat extends PetAction { //Eat if (pet.getLevelHunger() > 40) { pet.say(pet.getPetData().randomVocal(PetVocalsType.HUNGRY)); - Emulator.getThreading().run(new PetClearPosture(pet, RoomUnitStatus.EAT, null, false), 500); + Emulator.getThreading().run(new PetClearPosture(pet, RoomUnitStatus.EAT, null, false), this.minimumActionDuration); pet.eat(); return true; diff --git a/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionFollow.java b/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionFollow.java index 39dff84d..f1611e13 100644 --- a/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionFollow.java +++ b/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionFollow.java @@ -5,7 +5,6 @@ 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.RoomUnitStatus; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.threading.runnables.PetFollowHabbo; 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 index 2675f81d..f78b4642 100644 --- a/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionHang.java +++ b/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionHang.java @@ -1,70 +1,38 @@ package com.eu.habbo.habbohotel.pets.actions; +import com.eu.habbo.Emulator; 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.rooms.RoomUnitStatus; 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); + this.minimumActionDuration = 4000; } @Override public boolean apply(Pet pet, Habbo habbo, String[] data) { - if (pet.getHappyness() < 50) { + + boolean findTree = pet.findTree(PetTasks.HANG); + if (!findTree && pet.getPetData().getToyItems().stream().noneMatch(item -> item.getInteractionType().getType() == InteractionPetTree.class)) { + pet.getRoomUnit().setCanWalk(false); + pet.getRoomUnit().setStatus(RoomUnitStatus.HANG, pet.getRoomUnit().getCurrentLocation().getStackHeight() + ""); + + Emulator.getThreading().run(() -> { + pet.getRoomUnit().setCanWalk(true); + pet.clearPosture(); + }, minimumActionDuration); + } else if (!findTree) { 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; - } } + + pet.say(pet.getPetData().randomVocal(PetVocalsType.GENERIC_NEUTRAL)); + return true; } } \ No newline at end of file diff --git a/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionJump.java b/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionJump.java index 8e232d47..151ef22a 100644 --- a/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionJump.java +++ b/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionJump.java @@ -20,7 +20,7 @@ public class ActionJump extends PetAction { public boolean apply(Pet pet, Habbo habbo, String[] data) { pet.clearPosture(); - Emulator.getThreading().run(new PetClearPosture(pet, RoomUnitStatus.JUMP, null, false), 2000); + Emulator.getThreading().run(new PetClearPosture(pet, RoomUnitStatus.JUMP, null, false), this.minimumActionDuration); if (pet.getHappyness() > 60) pet.say(pet.getPetData().randomVocal(PetVocalsType.PLAYFUL)); diff --git a/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionNest.java b/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionNest.java index f7d994d6..166a35d3 100644 --- a/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionNest.java +++ b/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionNest.java @@ -14,7 +14,6 @@ public class ActionNest extends PetAction { public boolean apply(Pet pet, Habbo habbo, String[] data) { if (pet.getEnergy() < 65) { pet.findNest(); - if (pet.getEnergy() < 30) pet.say(pet.getPetData().randomVocal(PetVocalsType.TIRED)); diff --git a/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionPlay.java b/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionPlay.java index 71a7a291..9de22904 100644 --- a/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionPlay.java +++ b/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionPlay.java @@ -7,19 +7,19 @@ import com.eu.habbo.habbohotel.users.Habbo; public class ActionPlay extends PetAction { public ActionPlay() { - super(null, false); + super(null, true); } @Override public boolean apply(Pet pet, Habbo habbo, String[] data) { - //Play - //TODO Implement playing for pets. For example; go to ball, toy etc. - if (pet.getHappyness() > 75) - pet.say(pet.getPetData().randomVocal(PetVocalsType.PLAYFUL)); - else { + + boolean findToy = pet.findToy(); + if (!findToy) { pet.say(pet.getPetData().randomVocal(PetVocalsType.DISOBEY)); + return false; } + pet.say(pet.getPetData().randomVocal(PetVocalsType.GENERIC_NEUTRAL)); return true; } -} +} \ No newline at end of file diff --git a/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionPlayDead.java b/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionPlayDead.java index 94b7a1ee..56bce13e 100644 --- a/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionPlayDead.java +++ b/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionPlayDead.java @@ -18,7 +18,7 @@ public class ActionPlayDead extends PetAction { public boolean apply(Pet pet, Habbo habbo, String[] data) { pet.clearPosture(); - pet.getRoomUnit().setStatus(RoomUnitStatus.DEAD, pet.getRoom().getStackHeight(pet.getRoomUnit().getX(), pet.getRoomUnit().getY(), false) + ""); + pet.getRoomUnit().setStatus(RoomUnitStatus.DEAD, pet.getRoomUnit().getCurrentLocation().getStackHeight() + ""); if (pet.getHappyness() > 50) pet.say(pet.getPetData().randomVocal(PetVocalsType.PLAYFUL)); diff --git a/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionRelax.java b/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionRelax.java index 00f893e5..7b2e5560 100644 --- a/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionRelax.java +++ b/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionRelax.java @@ -21,7 +21,7 @@ public class ActionRelax extends PetAction { else pet.say(pet.getPetData().randomVocal(PetVocalsType.GENERIC_NEUTRAL)); - pet.getRoomUnit().setStatus(RoomUnitStatus.RELAX, "0"); + pet.getRoomUnit().setStatus(RoomUnitStatus.RELAX, pet.getRoomUnit().getCurrentLocation().getStackHeight() + ""); return true; } 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 index 23a404f5..c22531de 100644 --- a/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionRingOfFire.java +++ b/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionRingOfFire.java @@ -1,70 +1,38 @@ package com.eu.habbo.habbohotel.pets.actions; +import com.eu.habbo.Emulator; 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.rooms.RoomUnitStatus; 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); + this.minimumActionDuration = 4000; } @Override public boolean apply(Pet pet, Habbo habbo, String[] data) { - if (pet.getHappyness() < 50) { + + boolean findTree = pet.findTree(PetTasks.RING_OF_FIRE); + if (!findTree && pet.getPetData().getToyItems().stream().noneMatch(item -> item.getInteractionType().getType() == InteractionPetTree.class)) { + pet.getRoomUnit().setCanWalk(false); + pet.getRoomUnit().setStatus(RoomUnitStatus.RINGOFFIRE, pet.getRoomUnit().getCurrentLocation().getStackHeight() + ""); + + Emulator.getThreading().run(() -> { + pet.getRoomUnit().setCanWalk(true); + pet.clearPosture(); + }, minimumActionDuration); + } else if (!findTree) { 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; - } } + + pet.say(pet.getPetData().randomVocal(PetVocalsType.GENERIC_NEUTRAL)); + return true; } } \ No newline at end of file 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 index 7047344b..3f8dc9af 100644 --- a/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionRoll.java +++ b/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionRoll.java @@ -6,78 +6,33 @@ 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.rooms.RoomUnitStatus; 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); + this.minimumActionDuration = 4000; } @Override public boolean apply(Pet pet, Habbo habbo, String[] data) { - if (pet.getHappyness() < 50) { + + boolean findTree = pet.findTree(PetTasks.ROLL); + if (!findTree && pet.getPetData().getToyItems().stream().noneMatch(item -> item.getInteractionType().getType() == InteractionPetTree.class)) { + pet.getRoomUnit().setCanWalk(false); + pet.getRoomUnit().setStatus(RoomUnitStatus.ROLL, pet.getRoomUnit().getCurrentLocation().getStackHeight() + ""); + + Emulator.getThreading().run(() -> { + pet.getRoomUnit().setCanWalk(true); + pet.clearPosture(); + }, minimumActionDuration); + } else if (!findTree) { 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 || !pet.getPetData().haveToyItem(petTree.getBaseItem())) 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 { - if (pet.getPetData().getToyItems().stream().noneMatch(item -> item.getInteractionType().getType() == InteractionPetTree.class)) { - pet.getRoomUnit().setCanWalk(false); - pet.getRoomUnit().setStatus(RoomUnitStatus.ROLL, pet.getRoomUnit().getCurrentLocation().getStackHeight() + ""); - - Emulator.getThreading().run(() -> { - pet.getRoomUnit().setCanWalk(true); - pet.clearPosture(); - }, 4000); - return true; - } - - pet.say(pet.getPetData().randomVocal(PetVocalsType.DISOBEY)); - return false; - } } + + pet.say(pet.getPetData().randomVocal(PetVocalsType.GENERIC_NEUTRAL)); + return true; } } \ No newline at end of file diff --git a/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionSilent.java b/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionSilent.java index 2625825c..142d31c0 100644 --- a/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionSilent.java +++ b/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionSilent.java @@ -15,8 +15,8 @@ public class ActionSilent extends PetAction { @Override public boolean apply(Pet pet, Habbo habbo, String[] data) { - pet.setMuted(true); pet.say(pet.getPetData().randomVocal(PetVocalsType.MUTED)); + pet.setMuted(true); return false; } diff --git a/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionSit.java b/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionSit.java index b9a1b762..6a67bf68 100644 --- a/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionSit.java +++ b/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionSit.java @@ -15,6 +15,7 @@ public class ActionSit extends PetAction { this.statusToRemove.add(RoomUnitStatus.MOVE); this.statusToRemove.add(RoomUnitStatus.LAY); this.statusToRemove.add(RoomUnitStatus.DEAD); + this.minimumActionDuration = 4000; } @Override @@ -26,7 +27,7 @@ public class ActionSit extends PetAction { Emulator.getThreading().run(() -> { pet.getRoomUnit().cmdSit = false; pet.clearPosture(); - }, 4000); + }, this.minimumActionDuration); if (pet.getHappyness() > 75) pet.say(pet.getPetData().randomVocal(PetVocalsType.PLAYFUL)); 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 index 0f7b89f4..487156ec 100644 --- a/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionSwing.java +++ b/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionSwing.java @@ -1,70 +1,38 @@ package com.eu.habbo.habbohotel.pets.actions; +import com.eu.habbo.Emulator; 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.rooms.RoomUnitStatus; 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); + this.minimumActionDuration = 4000; } @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); + boolean findTree = pet.findTree(PetTasks.SWING); + if (!findTree && pet.getPetData().getToyItems().stream().noneMatch(item -> item.getInteractionType().getType() == InteractionPetTree.class)) { + pet.getRoomUnit().setCanWalk(false); + pet.getRoomUnit().setStatus(RoomUnitStatus.SWING, pet.getRoomUnit().getCurrentLocation().getStackHeight() + ""); - if (petTrees == null || petTrees.isEmpty()) { + Emulator.getThreading().run(() -> { + pet.getRoomUnit().setCanWalk(true); + pet.clearPosture(); + }, minimumActionDuration); + } else if (!findTree) { 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; - } - } + pet.say(pet.getPetData().randomVocal(PetVocalsType.GENERIC_NEUTRAL)); + return true; } } \ No newline at end of file diff --git a/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionTorch.java b/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionTorch.java index e6a7748e..8918e649 100644 --- a/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionTorch.java +++ b/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionTorch.java @@ -18,10 +18,6 @@ public class ActionTorch extends PetAction { @Override public boolean apply(Pet pet, Habbo habbo, String[] data) { - if (pet.getHappyness() < 30) { - pet.say(pet.getPetData().randomVocal(PetVocalsType.DISOBEY)); - return false; - } Emulator.getThreading().run(new PetClearPosture(pet, RoomUnitStatus.EAT, null, false), this.minimumActionDuration); return true; diff --git a/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionWagTail.java b/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionWagTail.java index 04e3d594..9109e328 100644 --- a/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionWagTail.java +++ b/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionWagTail.java @@ -21,14 +21,9 @@ public class ActionWagTail extends PetAction { @Override public boolean apply(Pet pet, Habbo habbo, String[] data) { pet.clearPosture(); + Emulator.getThreading().run(new PetClearPosture(pet, RoomUnitStatus.WAG_TAIL, null, false), this.minimumActionDuration); + pet.say(pet.getPetData().randomVocal(PetVocalsType.GENERIC_NEUTRAL)); + return true; - if (pet.getHappyness() > 40) { - Emulator.getThreading().run(new PetClearPosture(pet, RoomUnitStatus.WAG_TAIL, null, false), this.minimumActionDuration); - pet.say(pet.getPetData().randomVocal(PetVocalsType.GENERIC_NEUTRAL)); - return true; - } else { - pet.say(pet.getPetData().randomVocal(PetVocalsType.DISOBEY)); - return false; - } } } diff --git a/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionWave.java b/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionWave.java index 23b8ebfa..670d7b44 100644 --- a/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionWave.java +++ b/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionWave.java @@ -13,18 +13,14 @@ public class ActionWave extends PetAction { super(PetTasks.WAVE, false); this.statusToSet.add(RoomUnitStatus.WAVE); + this.minimumActionDuration = 2000; } @Override public boolean apply(Pet pet, Habbo habbo, String[] data) { - //WAV - if (pet.getHappyness() > 65) { - pet.getRoomUnit().setStatus(RoomUnitStatus.WAVE, "0"); + pet.getRoomUnit().setStatus(RoomUnitStatus.WAVE, pet.getRoomUnit().getCurrentLocation().getStackHeight() + ""); - Emulator.getThreading().run(new PetClearPosture(pet, RoomUnitStatus.WAVE, null, false), 2000); + Emulator.getThreading().run(new PetClearPosture(pet, RoomUnitStatus.WAVE, null, false), this.minimumActionDuration); return true; - } - - return false; } } From f54d1857720df9beb32ac60e200ee7c516e18851 Mon Sep 17 00:00:00 2001 From: brenoepic <59066707+brenoepics@users.noreply.github.com> Date: Mon, 11 Apr 2022 14:45:14 -0300 Subject: [PATCH 36/40] Feature: InteractionPetToy --- .../interactions/pets/InteractionPetToy.java | 40 ++++++++++++++----- .../com/eu/habbo/habbohotel/rooms/Room.java | 4 ++ 2 files changed, 35 insertions(+), 9 deletions(-) diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionPetToy.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionPetToy.java index caeaf54f..d33e5cc7 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionPetToy.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionPetToy.java @@ -1,14 +1,12 @@ package com.eu.habbo.habbohotel.items.interactions.pets; import com.eu.habbo.Emulator; +import com.eu.habbo.habbohotel.gameclients.GameClient; 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.Room; -import com.eu.habbo.habbohotel.rooms.RoomUnit; -import com.eu.habbo.habbohotel.rooms.RoomUnitStatus; -import com.eu.habbo.habbohotel.rooms.RoomUserRotation; +import com.eu.habbo.habbohotel.rooms.*; import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.threading.runnables.PetClearPosture; @@ -26,13 +24,30 @@ public class InteractionPetToy extends InteractionDefault { this.setExtradata("0"); } + @Override + public void onClick(GameClient client, Room room, Object[] objects) {} + @Override + public void onMove(Room room, RoomTile oldLocation, RoomTile newLocation) { + for (Pet pet : room.getPetsAt(oldLocation)) { + pet.getRoomUnit().clearStatus(); + pet.packetUpdate = true; + } + } + @Override + public void onPickUp(Room room) { + for (Pet pet : room.getPetsOnItem(this)) { + pet.getRoomUnit().clearStatus(); + pet.packetUpdate = true; + } + } + @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) { + if (pet != null && pet.getPetData().haveToyItem(this.getBaseItem()) && this.getOccupyingTiles(room.getLayout()).contains(pet.getRoomUnit().getGoal())) { if (pet.getEnergy() <= 35) { return; } @@ -41,15 +56,16 @@ public class InteractionPetToy extends InteractionDefault { pet.getRoomUnit().setGoalLocation(room.getLayout().getTile(this.getX(), this.getY())); pet.getRoomUnit().setRotation(RoomUserRotation.values()[this.getRotation()]); pet.getRoomUnit().clearStatus(); - pet.getRoomUnit().removeStatus(RoomUnitStatus.MOVE); - pet.getRoomUnit().setStatus(RoomUnitStatus.PLAY, "0"); + pet.getRoomUnit().setStatus(RoomUnitStatus.PLAY, pet.getRoomUnit().getCurrentLocation().getStackHeight() + ""); pet.packetUpdate = true; HabboItem item = this; Emulator.getThreading().run(() -> { pet.addHappyness(25); item.setExtradata("0"); room.updateItem(item); + pet.getRoomUnit().clearStatus(); new PetClearPosture(pet, RoomUnitStatus.PLAY, null, true).run(); + pet.packetUpdate = true; }, 2500 + (Emulator.getRandom().nextInt(20) * 500)); this.setExtradata("1"); room.updateItemState(this); @@ -63,11 +79,17 @@ public class InteractionPetToy extends InteractionDefault { Pet pet = room.getPet(roomUnit); if (pet != null) { - this.setExtradata("0"); - room.updateItemState(this); + pet.getRoomUnit().clearStatus(); + 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().haveToyItem(this.getBaseItem()); + } + @Override public boolean allowWiredResetState() { return false; 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 42d3b428..8036e661 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java @@ -2390,6 +2390,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 InteractionPetToy) { + this.roomSpecialTypes.addPetToy((InteractionPetToy) item); } else if (item instanceof InteractionPetTree) { this.roomSpecialTypes.addUndefined(item); } else if (item instanceof InteractionMoodLight) { @@ -2542,6 +2544,8 @@ public class Room implements Comparable, ISerialize, Runnable { this.roomSpecialTypes.removePetDrink((InteractionPetDrink) item); } else if (item instanceof InteractionPetFood) { this.roomSpecialTypes.removePetFood((InteractionPetFood) item); + } else if (item instanceof InteractionPetToy) { + this.roomSpecialTypes.removePetToy((InteractionPetToy) item); } else if (item instanceof InteractionPetTree) { this.roomSpecialTypes.removeUndefined(item); } else if (item instanceof InteractionMoodLight) { From a11544ffdcdecd86218d0f3a80a60902947f4262 Mon Sep 17 00:00:00 2001 From: brenoepic <59066707+brenoepics@users.noreply.github.com> Date: Mon, 11 Apr 2022 16:13:29 -0300 Subject: [PATCH 37/40] Update InteractionPetToy.java --- .../items/interactions/pets/InteractionPetToy.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionPetToy.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionPetToy.java index d33e5cc7..4925e4fe 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionPetToy.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionPetToy.java @@ -28,6 +28,9 @@ public class InteractionPetToy extends InteractionDefault { public void onClick(GameClient client, Room room, Object[] objects) {} @Override public void onMove(Room room, RoomTile oldLocation, RoomTile newLocation) { + this.setExtradata("0"); + room.updateItem(this); + for (Pet pet : room.getPetsAt(oldLocation)) { pet.getRoomUnit().clearStatus(); pet.packetUpdate = true; @@ -35,6 +38,8 @@ public class InteractionPetToy extends InteractionDefault { } @Override public void onPickUp(Room room) { + this.setExtradata("0"); + for (Pet pet : room.getPetsOnItem(this)) { pet.getRoomUnit().clearStatus(); pet.packetUpdate = true; @@ -79,6 +84,8 @@ public class InteractionPetToy extends InteractionDefault { Pet pet = room.getPet(roomUnit); if (pet != null) { + this.setExtradata("0"); + room.updateItem(this); pet.getRoomUnit().clearStatus(); pet.packetUpdate = true; } From 278da94db658316ea31c31c66846776b2fda0b34 Mon Sep 17 00:00:00 2001 From: brenoepic <59066707+brenoepics@users.noreply.github.com> Date: Mon, 11 Apr 2022 16:14:07 -0300 Subject: [PATCH 38/40] Fix pet drinks --- .../pets/InteractionPetDrink.java | 80 ++++++++++++++----- .../com/eu/habbo/habbohotel/pets/Pet.java | 11 ++- .../habbohotel/pets/actions/ActionDrink.java | 14 ++-- 3 files changed, 76 insertions(+), 29 deletions(-) diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionPetDrink.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionPetDrink.java index a18ada6b..2e3de3bb 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionPetDrink.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionPetDrink.java @@ -2,21 +2,23 @@ package com.eu.habbo.habbohotel.items.interactions.pets; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.achievements.AchievementManager; +import com.eu.habbo.habbohotel.gameclients.GameClient; 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.Room; -import com.eu.habbo.habbohotel.rooms.RoomUnit; -import com.eu.habbo.habbohotel.rooms.RoomUnitStatus; -import com.eu.habbo.habbohotel.rooms.RoomUserRotation; -import com.eu.habbo.messages.outgoing.rooms.users.RoomUserStatusComposer; +import com.eu.habbo.habbohotel.rooms.*; import com.eu.habbo.threading.runnables.PetClearPosture; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.sql.ResultSet; import java.sql.SQLException; public class InteractionPetDrink extends InteractionDefault { + private static final Logger LOGGER = LoggerFactory.getLogger(InteractionPetDrink.class); + + public InteractionPetDrink(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); } @@ -25,28 +27,38 @@ public class InteractionPetDrink extends InteractionDefault { super(id, userId, item, extradata, limitedStack, limitedSells); } + @Override + public void onClick(GameClient client, Room room, Object[] objects) throws Exception { + this.change(room, 1); + } + @Override public void onWalkOn(RoomUnit roomUnit, Room room, Object[] objects) throws Exception { super.onWalkOn(roomUnit, room, objects); + if (this.getExtradata() == null || this.getExtradata().isEmpty()) + this.setExtradata("0"); + Pet pet = room.getPet(roomUnit); - if (pet != null) { - if (pet.getPetData().haveDrinkItem(this)) { - if (pet.levelThirst >= 35) { - pet.setTask(PetTasks.EAT); - pet.getRoomUnit().setGoalLocation(room.getLayout().getTile(this.getX(), this.getY())); - pet.getRoomUnit().setRotation(RoomUserRotation.values()[this.getRotation()]); - pet.getRoomUnit().clearStatus(); - pet.getRoomUnit().removeStatus(RoomUnitStatus.MOVE); - pet.getRoomUnit().setStatus(RoomUnitStatus.EAT, "0"); - pet.addThirst(-75); - room.sendComposer(new RoomUserStatusComposer(roomUnit).compose()); - Emulator.getThreading().run(new PetClearPosture(pet, RoomUnitStatus.EAT, null, true), 500); + if (pet != null && pet.getPetData().haveDrinkItem(this) && pet.levelThirst >= 35) { + pet.clearPosture(); + pet.getRoomUnit().setGoalLocation(room.getLayout().getTile(this.getX(), this.getY())); + pet.getRoomUnit().setRotation(RoomUserRotation.values()[this.getRotation()]); + pet.getRoomUnit().clearStatus(); + pet.getRoomUnit().setStatus(RoomUnitStatus.EAT, pet.getRoomUnit().getCurrentLocation().getStackHeight() + ""); + pet.packetUpdate = true; + + Emulator.getThreading().run(() -> { + pet.addThirst(-75); + this.change(room, -1); + pet.getRoomUnit().clearStatus(); + new PetClearPosture(pet, RoomUnitStatus.EAT, null, true); + pet.packetUpdate = true; + }, 1000); + + AchievementManager.progressAchievement(Emulator.getGameEnvironment().getHabboManager().getHabbo(pet.getUserId()), Emulator.getGameEnvironment().getAchievementManager().getAchievement("PetFeeding"), 75); - AchievementManager.progressAchievement(Emulator.getGameEnvironment().getHabboManager().getHabbo(pet.getUserId()), Emulator.getGameEnvironment().getAchievementManager().getAchievement("PetFeeding"), 75); - } - } } } @@ -54,4 +66,32 @@ public class InteractionPetDrink extends InteractionDefault { public boolean allowWiredResetState() { return false; } + + private void change(Room room, int amount) { + int state = 0; + + if (this.getExtradata() == null || this.getExtradata().isEmpty()) { + this.setExtradata("0"); + } + + try { + state = Integer.parseInt(this.getExtradata()); + } catch (Exception e) { + LOGGER.error("Caught exception", e); + } + + state += amount; + if (state > this.getBaseItem().getStateCount() - 1) { + state = this.getBaseItem().getStateCount() - 1; + } + + if (state < 0) { + state = 0; + } + + this.setExtradata(state + ""); + this.needsUpdate(true); + room.updateItemState(this); + } + } diff --git a/src/main/java/com/eu/habbo/habbohotel/pets/Pet.java b/src/main/java/com/eu/habbo/habbohotel/pets/Pet.java index 883deb5d..70147f37 100644 --- a/src/main/java/com/eu/habbo/habbohotel/pets/Pet.java +++ b/src/main/java/com/eu/habbo/habbohotel/pets/Pet.java @@ -460,12 +460,19 @@ public class Pet implements ISerialize, Runnable { } - public void drink() { + public boolean drink() { HabboItem item = this.petData.randomDrinkItem(this.room.getRoomSpecialTypes().getPetDrinks()); if (item != null) { this.roomUnit.setCanWalk(true); - this.roomUnit.setGoalLocation(this.room.getLayout().getTile(item.getX(), item.getY())); + if (this.getRoomUnit().getCurrentLocation().distance(this.room.getLayout().getTile(item.getX(), item.getY())) == 0) { + try { + item.onWalkOn(this.getRoomUnit(), this.getRoom(), null); + } catch (Exception ignored) {} + } else { + this.roomUnit.setGoalLocation(this.room.getLayout().getTile(item.getX(), item.getY())); + } } + return item != null; } diff --git a/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionDrink.java b/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionDrink.java index 7d56c1c2..274b4f9c 100644 --- a/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionDrink.java +++ b/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionDrink.java @@ -12,17 +12,17 @@ public class ActionDrink extends PetAction { @Override public boolean apply(Pet pet, Habbo habbo, String[] data) { - if (pet.getLevelThirst() > 40) { - pet.drink(); + + if (pet.levelThirst < 35 || !pet.drink()) { + pet.say(pet.getPetData().randomVocal(PetVocalsType.DISOBEY)); + return false; + } if (pet.getLevelThirst() > 65) - pet.say(pet.getPetData().randomVocal(PetVocalsType.THIRSTY)); + pet.say(pet.getPetData().randomVocal(PetVocalsType.THIRSTY)); + else pet.say(pet.getPetData().randomVocal(PetVocalsType.DRINKING)); return true; - } else { - pet.say(pet.getPetData().randomVocal(PetVocalsType.DISOBEY)); - } - return false; } } From c8d33085230839c4c2bc8a70c972eacf163c2ac0 Mon Sep 17 00:00:00 2001 From: brenoepic <59066707+brenoepics@users.noreply.github.com> Date: Mon, 11 Apr 2022 17:51:37 -0300 Subject: [PATCH 39/40] Update InteractionPetDrink.java --- .../pets/InteractionPetDrink.java | 32 ++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionPetDrink.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionPetDrink.java index 2e3de3bb..0a140f9e 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionPetDrink.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionPetDrink.java @@ -8,12 +8,16 @@ 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.threading.runnables.PetClearPosture; +import com.eu.habbo.threading.runnables.RoomUnitWalkToLocation; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.sql.ResultSet; import java.sql.SQLException; +import java.util.ArrayList; +import java.util.List; public class InteractionPetDrink extends InteractionDefault { private static final Logger LOGGER = LoggerFactory.getLogger(InteractionPetDrink.class); @@ -27,9 +31,35 @@ public class InteractionPetDrink extends InteractionDefault { super(id, userId, item, extradata, limitedStack, limitedSells); } + @Override + public boolean canToggle(Habbo habbo, Room room) { + return RoomLayout.tilesAdjecent(room.getLayout().getTile(this.getX(), this.getY()), habbo.getRoomUnit().getCurrentLocation()); + } + @Override public void onClick(GameClient client, Room room, Object[] objects) throws Exception { - this.change(room, 1); + if (client == null) + return; + + if (!this.canToggle(client.getHabbo(), room)) { + RoomTile closestTile = null; + for (RoomTile tile : room.getLayout().getTilesAround(room.getLayout().getTile(this.getX(), this.getY()))) { + if (tile.isWalkable() && (closestTile == null || closestTile.distance(client.getHabbo().getRoomUnit().getCurrentLocation()) > tile.distance(client.getHabbo().getRoomUnit().getCurrentLocation()))) { + closestTile = tile; + } + } + + if (closestTile != null && !closestTile.equals(client.getHabbo().getRoomUnit().getCurrentLocation())) { + List onSuccess = new ArrayList<>(); + onSuccess.add(() -> { + this.change(room, this.getBaseItem().getStateCount() - 1); + }); + + client.getHabbo().getRoomUnit().setGoalLocation(closestTile); + Emulator.getThreading().run(new RoomUnitWalkToLocation(client.getHabbo().getRoomUnit(), closestTile, room, onSuccess, new ArrayList<>())); + } + } + } @Override From 7fef24fa85d7494fe938148c9dc2b0a2522b95a7 Mon Sep 17 00:00:00 2001 From: brenoepic <59066707+brenoepics@users.noreply.github.com> Date: Mon, 11 Apr 2022 20:21:11 -0300 Subject: [PATCH 40/40] Trampoline interaction --- .../habbo/habbohotel/items/ItemManager.java | 1 + .../pets/InteractionPetTrampoline.java | 102 ++++++++++++++++++ .../com/eu/habbo/habbohotel/pets/Pet.java | 8 +- .../com/eu/habbo/habbohotel/pets/PetData.java | 16 +-- .../eu/habbo/habbohotel/pets/PetManager.java | 4 +- .../habbohotel/pets/actions/ActionHang.java | 2 +- .../habbohotel/pets/actions/ActionJump.java | 10 +- .../pets/actions/ActionRingOfFire.java | 2 +- .../habbohotel/pets/actions/ActionRoll.java | 2 +- .../habbohotel/pets/actions/ActionSwing.java | 2 +- .../com/eu/habbo/habbohotel/rooms/Room.java | 4 + 11 files changed, 131 insertions(+), 22 deletions(-) create mode 100644 src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionPetTrampoline.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 17b3c05c..0e492e59 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/ItemManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/ItemManager.java @@ -134,6 +134,7 @@ public class ItemManager { 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("pet_trampoline", InteractionPetTrampoline.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/InteractionPetTrampoline.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionPetTrampoline.java new file mode 100644 index 00000000..9b21744d --- /dev/null +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionPetTrampoline.java @@ -0,0 +1,102 @@ +package com.eu.habbo.habbohotel.items.interactions.pets; + +import com.eu.habbo.Emulator; +import com.eu.habbo.habbohotel.gameclients.GameClient; +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.HabboItem; +import com.eu.habbo.threading.runnables.PetClearPosture; + +import java.sql.ResultSet; +import java.sql.SQLException; + +public class InteractionPetTrampoline extends InteractionDefault { + public InteractionPetTrampoline(ResultSet set, Item baseItem) throws SQLException { + super(set, baseItem); + this.setExtradata("0"); + } + + public InteractionPetTrampoline(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { + super(id, userId, item, extradata, limitedStack, limitedSells); + this.setExtradata("0"); + } + + @Override + public void onClick(GameClient client, Room room, Object[] objects) {} + + @Override + public void onMove(Room room, RoomTile oldLocation, RoomTile newLocation) { + this.setExtradata("0"); + room.updateItem(this); + + for (Pet pet : room.getPetsAt(oldLocation)) { + pet.getRoomUnit().removeStatus(RoomUnitStatus.JUMP); + pet.packetUpdate = true; + } + } + + @Override + public void onPickUp(Room room) { + this.setExtradata("0"); + + for (Pet pet : room.getPetsOnItem(this)) { + pet.getRoomUnit().removeStatus(RoomUnitStatus.JUMP); + pet.packetUpdate = true; + } + } + + @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 && pet.getPetData().haveToyItem(this.getBaseItem()) && this.getOccupyingTiles(room.getLayout()).contains(pet.getRoomUnit().getGoal())) { + if (pet.getEnergy() <= 35) { + return; + } + + pet.clearPosture(); + pet.setTask(PetTasks.JUMP); + pet.getRoomUnit().setStatus(RoomUnitStatus.JUMP, ""); + Emulator.getThreading().run(() -> { + new PetClearPosture(pet, RoomUnitStatus.JUMP, null, false); + pet.getRoomUnit().setGoalLocation(room.getRandomWalkableTile()); + this.setExtradata("0"); + room.updateItemState(this); + }, 4000); + pet.addHappyness(25); + + this.setExtradata("1"); + room.updateItemState(this); + } + } + + @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) { + this.setExtradata("0"); + room.updateItem(this); + pet.getRoomUnit().removeStatus(RoomUnitStatus.JUMP); + 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().haveToyItem(this.getBaseItem()); + } + + @Override + public boolean allowWiredResetState() { + return false; + } +} \ No newline at end of file diff --git a/src/main/java/com/eu/habbo/habbohotel/pets/Pet.java b/src/main/java/com/eu/habbo/habbohotel/pets/Pet.java index 70147f37..2ddfac92 100644 --- a/src/main/java/com/eu/habbo/habbohotel/pets/Pet.java +++ b/src/main/java/com/eu/habbo/habbohotel/pets/Pet.java @@ -389,9 +389,7 @@ public class Pet implements ISerialize, Runnable { keys.put(RoomUnitStatus.GESTURE, this.roomUnit.getStatus(RoomUnitStatus.GESTURE)); if (this.task == null) { - boolean isDead = false; - if (this.roomUnit.hasStatus(RoomUnitStatus.RIP)) - isDead = true; + boolean isDead = this.roomUnit.hasStatus(RoomUnitStatus.RIP); this.roomUnit.clearStatus(); @@ -505,8 +503,8 @@ public class Pet implements ISerialize, Runnable { return false; } - public boolean findTree(PetTasks task) { - HabboItem item = this.petData.randomTreeItem(this.room.getRoomSpecialTypes().getItemsOfType(InteractionPetTree.class)); + public boolean findPetItem(PetTasks task, Class type) { + HabboItem item = this.petData.randomToyHabboItem(this.room.getRoomSpecialTypes().getItemsOfType(type)); if (item != null) { this.roomUnit.setCanWalk(true); diff --git a/src/main/java/com/eu/habbo/habbohotel/pets/PetData.java b/src/main/java/com/eu/habbo/habbohotel/pets/PetData.java index 592358f0..dabbf764 100644 --- a/src/main/java/com/eu/habbo/habbohotel/pets/PetData.java +++ b/src/main/java/com/eu/habbo/habbohotel/pets/PetData.java @@ -230,18 +230,18 @@ public class PetData implements Comparable { return null; } - public HabboItem randomTreeItem(THashSet trees) { - List treeList = new ArrayList<>(); + public HabboItem randomToyHabboItem(THashSet items) { + List itemList = new ArrayList<>(); - for (HabboItem tree : trees) { - if (this.haveToyItem(tree)) { - treeList.add(tree); + for (HabboItem item : items) { + if (this.haveToyItem(item)) { + itemList.add(item); } } - if (!treeList.isEmpty()) { - Collections.shuffle(treeList); - return treeList.get(0); + if (!itemList.isEmpty()) { + Collections.shuffle(itemList); + return itemList.get(0); } return null; 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 a9764e0d..f1da909d 100644 --- a/src/main/java/com/eu/habbo/habbohotel/pets/PetManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/pets/PetManager.java @@ -208,7 +208,7 @@ public class PetManager { PetData.generalFoodItems.add(baseItem); else if (baseItem.getInteractionType().getType() == InteractionPetDrink.class) PetData.generalDrinkItems.add(baseItem); - else if (baseItem.getInteractionType().getType() == InteractionPetToy.class || baseItem.getInteractionType().getType() == InteractionPetTree.class) + else if (baseItem.getInteractionType().getType() == InteractionPetToy.class || baseItem.getInteractionType().getType() == InteractionPetTree.class || baseItem.getInteractionType().getType() == InteractionPetTrampoline.class) PetData.generalToyItems.add(baseItem); } else { PetData data = this.getPetData(set.getInt("pet_id")); @@ -220,7 +220,7 @@ public class PetManager { data.addFoodItem(baseItem); else if (baseItem.getInteractionType().getType() == InteractionPetDrink.class) data.addDrinkItem(baseItem); - else if (baseItem.getInteractionType().getType() == InteractionPetToy.class || baseItem.getInteractionType().getType() == InteractionPetTree.class) + else if (baseItem.getInteractionType().getType() == InteractionPetToy.class || baseItem.getInteractionType().getType() == InteractionPetTree.class || baseItem.getInteractionType().getType() == InteractionPetTrampoline.class) data.addToyItem(baseItem); } } 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 index f78b4642..0d610ee5 100644 --- a/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionHang.java +++ b/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionHang.java @@ -18,7 +18,7 @@ public class ActionHang extends PetAction { @Override public boolean apply(Pet pet, Habbo habbo, String[] data) { - boolean findTree = pet.findTree(PetTasks.HANG); + boolean findTree = pet.findPetItem(PetTasks.HANG, InteractionPetTree.class); if (!findTree && pet.getPetData().getToyItems().stream().noneMatch(item -> item.getInteractionType().getType() == InteractionPetTree.class)) { pet.getRoomUnit().setCanWalk(false); pet.getRoomUnit().setStatus(RoomUnitStatus.HANG, pet.getRoomUnit().getCurrentLocation().getStackHeight() + ""); diff --git a/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionJump.java b/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionJump.java index 151ef22a..05042f21 100644 --- a/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionJump.java +++ b/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionJump.java @@ -1,25 +1,29 @@ package com.eu.habbo.habbohotel.pets.actions; import com.eu.habbo.Emulator; +import com.eu.habbo.habbohotel.items.interactions.pets.InteractionPetTrampoline; +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.RoomUnitStatus; import com.eu.habbo.habbohotel.users.Habbo; +import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.threading.runnables.PetClearPosture; public class ActionJump extends PetAction { public ActionJump() { - super(PetTasks.JUMP, true); + super(null, false); this.minimumActionDuration = 2000; - this.statusToSet.add(RoomUnitStatus.JUMP); } @Override public boolean apply(Pet pet, Habbo habbo, String[] data) { - pet.clearPosture(); + if(pet.findPetItem(PetTasks.JUMP, InteractionPetTrampoline.class)) return true; + pet.clearPosture(); + pet.setTask(PetTasks.JUMP); Emulator.getThreading().run(new PetClearPosture(pet, RoomUnitStatus.JUMP, null, false), this.minimumActionDuration); if (pet.getHappyness() > 60) 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 index c22531de..fcaaee3f 100644 --- a/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionRingOfFire.java +++ b/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionRingOfFire.java @@ -18,7 +18,7 @@ public class ActionRingOfFire extends PetAction { @Override public boolean apply(Pet pet, Habbo habbo, String[] data) { - boolean findTree = pet.findTree(PetTasks.RING_OF_FIRE); + boolean findTree = pet.findPetItem(PetTasks.RING_OF_FIRE, InteractionPetTree.class); if (!findTree && pet.getPetData().getToyItems().stream().noneMatch(item -> item.getInteractionType().getType() == InteractionPetTree.class)) { pet.getRoomUnit().setCanWalk(false); pet.getRoomUnit().setStatus(RoomUnitStatus.RINGOFFIRE, pet.getRoomUnit().getCurrentLocation().getStackHeight() + ""); 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 index 3f8dc9af..8a757d5f 100644 --- a/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionRoll.java +++ b/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionRoll.java @@ -18,7 +18,7 @@ public class ActionRoll extends PetAction { @Override public boolean apply(Pet pet, Habbo habbo, String[] data) { - boolean findTree = pet.findTree(PetTasks.ROLL); + boolean findTree = pet.findPetItem(PetTasks.ROLL, InteractionPetTree.class); if (!findTree && pet.getPetData().getToyItems().stream().noneMatch(item -> item.getInteractionType().getType() == InteractionPetTree.class)) { pet.getRoomUnit().setCanWalk(false); pet.getRoomUnit().setStatus(RoomUnitStatus.ROLL, pet.getRoomUnit().getCurrentLocation().getStackHeight() + ""); 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 index 487156ec..3ca54d83 100644 --- a/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionSwing.java +++ b/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionSwing.java @@ -18,7 +18,7 @@ public class ActionSwing extends PetAction { @Override public boolean apply(Pet pet, Habbo habbo, String[] data) { - boolean findTree = pet.findTree(PetTasks.SWING); + boolean findTree = pet.findPetItem(PetTasks.SWING, InteractionPetTree.class); if (!findTree && pet.getPetData().getToyItems().stream().noneMatch(item -> item.getInteractionType().getType() == InteractionPetTree.class)) { pet.getRoomUnit().setCanWalk(false); pet.getRoomUnit().setStatus(RoomUnitStatus.SWING, pet.getRoomUnit().getCurrentLocation().getStackHeight() + ""); 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 8036e661..b49765c1 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java @@ -2394,6 +2394,8 @@ public class Room implements Comparable, ISerialize, Runnable { this.roomSpecialTypes.addPetToy((InteractionPetToy) item); } else if (item instanceof InteractionPetTree) { this.roomSpecialTypes.addUndefined(item); + } else if (item instanceof InteractionPetTrampoline) { + this.roomSpecialTypes.addUndefined(item); } else if (item instanceof InteractionMoodLight) { this.roomSpecialTypes.addUndefined(item); } else if (item instanceof InteractionPyramid) { @@ -2548,6 +2550,8 @@ public class Room implements Comparable, ISerialize, Runnable { this.roomSpecialTypes.removePetToy((InteractionPetToy) item); } else if (item instanceof InteractionPetTree) { this.roomSpecialTypes.removeUndefined(item); + } else if (item instanceof InteractionPetTrampoline) { + this.roomSpecialTypes.removeUndefined(item); } else if (item instanceof InteractionMoodLight) { this.roomSpecialTypes.removeUndefined(item); } else if (item instanceof InteractionPyramid) {