mirror of
https://git.krews.org/morningstar/Arcturus-Community.git
synced 2025-01-18 23:46:28 +01:00
Merge branch 'fix-pets-finally' into ms4-unstable
This commit is contained in:
commit
4f0143e982
@ -133,6 +133,8 @@ 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("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));
|
||||
|
@ -48,16 +48,18 @@ 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) {}
|
||||
}
|
||||
|
||||
}
|
||||
@ -82,7 +84,6 @@ public class InteractionWater extends InteractionDefault {
|
||||
|
||||
if (!pet.getRoomUnit().hasStatus(RoomUnitStatus.SWIM) && pet.getPetData().canSwim) {
|
||||
pet.getRoomUnit().setStatus(RoomUnitStatus.SWIM, "");
|
||||
pet.packetUpdate = true;
|
||||
}
|
||||
}
|
||||
|
||||
@ -97,8 +98,7 @@ public class InteractionWater extends InteractionDefault {
|
||||
|
||||
if (pet == null) return;
|
||||
|
||||
roomUnit.removeStatus(RoomUnitStatus.SWIM);
|
||||
pet.packetUpdate = true;
|
||||
pet.getRoomUnit().removeStatus(RoomUnitStatus.SWIM);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -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.UserUpdateComposer;
|
||||
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<Runnable> 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 UserUpdateComposer(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);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
@ -0,0 +1,105 @@
|
||||
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.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 && 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);
|
||||
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.getOccupyingTiles(room.getLayout()).contains(pet.getRoomUnit().getCurrentLocation())) {
|
||||
pet.getRoomUnit().setStatus(RoomUnitStatus.HANG, pet.getRoomUnit().getCurrentLocation().getStackHeight() + "");
|
||||
} else {
|
||||
pet.clearPosture();
|
||||
}
|
||||
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.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;
|
||||
}
|
||||
}
|
@ -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<? extends HabboItem> 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) {
|
||||
|
@ -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<PetCommand> {
|
||||
}
|
||||
|
||||
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);
|
||||
|
@ -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<PetData> {
|
||||
return null;
|
||||
}
|
||||
|
||||
public HabboItem randomToyHabboItem(THashSet<HabboItem> items) {
|
||||
List<HabboItem> 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.
|
||||
|
@ -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;
|
||||
@ -52,6 +49,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());
|
||||
@ -59,10 +60,16 @@ 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(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(44, new ActionWagTail());
|
||||
this.put(46, new ActionBreed());
|
||||
|
||||
}
|
||||
@ -201,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)
|
||||
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"));
|
||||
@ -213,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)
|
||||
else if (baseItem.getInteractionType().getType() == InteractionPetToy.class || baseItem.getInteractionType().getType() == InteractionPetTree.class || baseItem.getInteractionType().getType() == InteractionPetTrampoline.class)
|
||||
data.addToyItem(baseItem);
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
@ -17,12 +17,22 @@ 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));
|
||||
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;
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
@ -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,30 @@ 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);
|
||||
this.minimumActionDuration = 4000;
|
||||
}
|
||||
|
||||
@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();
|
||||
}, this.minimumActionDuration);
|
||||
|
||||
if (pet.getHappyness() > 50)
|
||||
pet.say(pet.getPetData().randomVocal(PetVocalsType.PLAYFUL));
|
||||
else
|
||||
pet.say(pet.getPetData().randomVocal(PetVocalsType.GENERIC_NEUTRAL));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -5,22 +5,19 @@ 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;
|
||||
|
||||
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)
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
|
@ -0,0 +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.RoomUnitStatus;
|
||||
import com.eu.habbo.habbohotel.users.Habbo;
|
||||
|
||||
public class ActionHang extends PetAction {
|
||||
public ActionHang() {
|
||||
super(null, true);
|
||||
this.minimumActionDuration = 4000;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Pet pet, Habbo habbo, String[] data) {
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
pet.say(pet.getPetData().randomVocal(PetVocalsType.GENERIC_NEUTRAL));
|
||||
return true;
|
||||
}
|
||||
}
|
@ -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));
|
||||
|
@ -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));
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
@ -12,14 +12,13 @@ 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
|
||||
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));
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -0,0 +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.RoomUnitStatus;
|
||||
import com.eu.habbo.habbohotel.users.Habbo;
|
||||
|
||||
public class ActionRingOfFire extends PetAction {
|
||||
public ActionRingOfFire() {
|
||||
super(null, true);
|
||||
this.minimumActionDuration = 4000;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Pet pet, Habbo habbo, String[] data) {
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
pet.say(pet.getPetData().randomVocal(PetVocalsType.GENERIC_NEUTRAL));
|
||||
return true;
|
||||
}
|
||||
}
|
@ -0,0 +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.RoomUnitStatus;
|
||||
import com.eu.habbo.habbohotel.users.Habbo;
|
||||
|
||||
public class ActionRoll extends PetAction {
|
||||
public ActionRoll() {
|
||||
super(null, true);
|
||||
this.minimumActionDuration = 4000;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Pet pet, Habbo habbo, String[] data) {
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
pet.say(pet.getPetData().randomVocal(PetVocalsType.GENERIC_NEUTRAL));
|
||||
return true;
|
||||
}
|
||||
}
|
@ -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;
|
||||
}
|
||||
|
@ -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.minimumActionDuration = 4000;
|
||||
}
|
||||
|
||||
@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();
|
||||
}, this.minimumActionDuration);
|
||||
|
||||
if (pet.getHappyness() > 75)
|
||||
pet.say(pet.getPetData().randomVocal(PetVocalsType.PLAYFUL));
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +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.RoomUnitStatus;
|
||||
import com.eu.habbo.habbohotel.users.Habbo;
|
||||
|
||||
public class ActionSwing extends PetAction {
|
||||
public ActionSwing() {
|
||||
super(null, true);
|
||||
this.minimumActionDuration = 4000;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Pet pet, Habbo habbo, String[] data) {
|
||||
|
||||
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() + "");
|
||||
|
||||
Emulator.getThreading().run(() -> {
|
||||
pet.getRoomUnit().setCanWalk(true);
|
||||
pet.clearPosture();
|
||||
}, minimumActionDuration);
|
||||
} else if (!findTree) {
|
||||
pet.say(pet.getPetData().randomVocal(PetVocalsType.DISOBEY));
|
||||
return false;
|
||||
}
|
||||
|
||||
pet.say(pet.getPetData().randomVocal(PetVocalsType.GENERIC_NEUTRAL));
|
||||
return true;
|
||||
}
|
||||
}
|
@ -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;
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -0,0 +1,29 @@
|
||||
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();
|
||||
Emulator.getThreading().run(new PetClearPosture(pet, RoomUnitStatus.WAG_TAIL, null, false), this.minimumActionDuration);
|
||||
pet.say(pet.getPetData().randomVocal(PetVocalsType.GENERIC_NEUTRAL));
|
||||
return true;
|
||||
|
||||
}
|
||||
}
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
@ -475,7 +472,8 @@ public class Room implements Comparable<Room>, 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 +508,8 @@ public class Room implements Comparable<Room>, 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 {
|
||||
@ -2391,6 +2390,12 @@ public class Room implements Comparable<Room>, 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) {
|
||||
@ -2541,6 +2546,12 @@ public class Room implements Comparable<Room>, 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) {
|
||||
@ -2577,6 +2588,8 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
|
||||
this.roomSpecialTypes.removeUndefined(item);
|
||||
} else if (item instanceof InteractionSnowboardSlope) {
|
||||
this.roomSpecialTypes.removeUndefined(item);
|
||||
} else if (item instanceof InteractionBuildArea) {
|
||||
this.roomSpecialTypes.removeUndefined(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -2921,6 +2934,27 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
|
||||
return false;
|
||||
}
|
||||
|
||||
public THashSet<Pet> getPetsAt(RoomTile tile) {
|
||||
THashSet<Pet> pets = new THashSet<>();
|
||||
synchronized (this.currentPets) {
|
||||
TIntObjectIterator<Pet> 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<Bot> getBotsAt(RoomTile tile) {
|
||||
THashSet<Bot> bots = new THashSet<>();
|
||||
synchronized (this.currentBots) {
|
||||
@ -2997,6 +3031,17 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
|
||||
return bots;
|
||||
}
|
||||
|
||||
public THashSet<Pet> getPetsOnItem(HabboItem item) {
|
||||
THashSet<Pet> 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));
|
||||
}
|
||||
|
@ -3,45 +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"),
|
||||
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"),
|
||||
@ -50,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;
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user