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/InteractionPetDrink.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionPetDrink.java index a18ada6b..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 @@ -2,21 +2,27 @@ 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.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); + + public InteractionPetDrink(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); } @@ -25,28 +31,64 @@ 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 { + 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 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 +96,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/items/interactions/pets/InteractionPetToy.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionPetToy.java index caeaf54f..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 @@ -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,35 @@ 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) { + this.setExtradata("0"); + room.updateItem(this); + + for (Pet pet : room.getPetsAt(oldLocation)) { + pet.getRoomUnit().clearStatus(); + pet.packetUpdate = true; + } + } + @Override + public void onPickUp(Room room) { + this.setExtradata("0"); + + 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 +61,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); @@ -64,10 +85,18 @@ public class InteractionPetToy extends InteractionDefault { if (pet != null) { this.setExtradata("0"); - room.updateItemState(this); + room.updateItem(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/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/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..2ddfac92 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); @@ -390,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(); @@ -461,12 +458,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; } @@ -481,16 +485,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 findPetItem(PetTasks task, Class type) { + HabboItem item = this.petData.randomToyHabboItem(this.room.getRoomSpecialTypes().getItemsOfType(type)); + + 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..dabbf764 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 randomToyHabboItem(THashSet items) { + List itemList = new ArrayList<>(); + + for (HabboItem item : items) { + if (this.haveToyItem(item)) { + itemList.add(item); + } + } + + if (!itemList.isEmpty()) { + Collections.shuffle(itemList); + return itemList.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/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/ActionCroak.java b/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionCroak.java index bd165833..80953c52 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() > 70) pet.say(pet.getPetData().randomVocal(PetVocalsType.GENERIC_HAPPY)); 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/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; } } 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..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 @@ -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.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() + ""); + + 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..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,26 +1,30 @@ 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; - Emulator.getThreading().run(new PetClearPosture(pet, RoomUnitStatus.JUMP, null, false), 2000); + pet.clearPosture(); + pet.setTask(PetTasks.JUMP); + 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..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 @@ -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.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() + ""); + + 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..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 @@ -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.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() + ""); + + 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..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 @@ -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.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() + ""); - 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; } } 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..b49765c1 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java @@ -2390,8 +2390,12 @@ 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 InteractionPetTrampoline) { + this.roomSpecialTypes.addUndefined(item); } else if (item instanceof InteractionMoodLight) { this.roomSpecialTypes.addUndefined(item); } else if (item instanceof InteractionPyramid) { @@ -2542,8 +2546,12 @@ 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 InteractionPetTrampoline) { + this.roomSpecialTypes.removeUndefined(item); } else if (item instanceof InteractionMoodLight) { this.roomSpecialTypes.removeUndefined(item); } else if (item instanceof InteractionPyramid) {