mirror of
https://git.krews.org/morningstar/Arcturus-Community.git
synced 2024-11-27 08:50:51 +01:00
Merge branch 'fix-pets-finally' into 'fix-pets-finally'
5 PetActions + InteractionPetTree + Pet animation on water See merge request morningstar/Arcturus-Community!527
This commit is contained in:
commit
0c61803992
@ -133,6 +133,7 @@ public class ItemManager {
|
|||||||
this.interactionsList.add(new ItemInteraction("pet_drink", InteractionPetDrink.class));
|
this.interactionsList.add(new ItemInteraction("pet_drink", InteractionPetDrink.class));
|
||||||
this.interactionsList.add(new ItemInteraction("pet_food", InteractionPetFood.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_toy", InteractionPetToy.class));
|
||||||
|
this.interactionsList.add(new ItemInteraction("pet_tree", InteractionPetTree.class));
|
||||||
this.interactionsList.add(new ItemInteraction("breeding_nest", InteractionPetBreedingNest.class));
|
this.interactionsList.add(new ItemInteraction("breeding_nest", InteractionPetBreedingNest.class));
|
||||||
this.interactionsList.add(new ItemInteraction("obstacle", InteractionObstacle.class));
|
this.interactionsList.add(new ItemInteraction("obstacle", InteractionObstacle.class));
|
||||||
this.interactionsList.add(new ItemInteraction("monsterplant_seed", InteractionMonsterPlantSeed.class));
|
this.interactionsList.add(new ItemInteraction("monsterplant_seed", InteractionMonsterPlantSeed.class));
|
||||||
|
@ -48,16 +48,19 @@ public class InteractionWater extends InteractionDefault {
|
|||||||
for (Habbo habbo : room.getHabbosOnItem(this)) {
|
for (Habbo habbo : room.getHabbosOnItem(this)) {
|
||||||
try {
|
try {
|
||||||
this.onWalkOff(habbo.getRoomUnit(), room, empty);
|
this.onWalkOff(habbo.getRoomUnit(), room, empty);
|
||||||
} catch (Exception e) {
|
} catch (Exception ignored) {}
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Bot bot : room.getBotsOnItem(this)) {
|
for (Bot bot : room.getBotsOnItem(this)) {
|
||||||
try {
|
try {
|
||||||
this.onWalkOff(bot.getRoomUnit(), room, empty);
|
this.onWalkOff(bot.getRoomUnit(), room, empty);
|
||||||
} catch (Exception e) {
|
} catch (Exception ignored) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (Pet pet : room.getPetsOnItem(this)) {
|
||||||
|
try {
|
||||||
|
this.onWalkOff(pet.getRoomUnit(), room, empty);
|
||||||
|
} catch (Exception ignored) {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -78,7 +81,9 @@ public class InteractionWater extends InteractionDefault {
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
if (!pet.getRoomUnit().hasStatus(RoomUnitStatus.SWIM) && pet.getPetData().canSwim) {
|
if (!pet.getRoomUnit().hasStatus(RoomUnitStatus.SWIM) && pet.getPetData().canSwim) {
|
||||||
pet.getRoomUnit().setStatus(RoomUnitStatus.SWIM, "");
|
pet.getRoomUnit().clearStatus();
|
||||||
|
pet.getRoomUnit().setStatus(RoomUnitStatus.SWIM, pet.getRoomUnit().getCurrentLocation().getStackHeight() + "");
|
||||||
|
pet.packetUpdate = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -91,7 +96,9 @@ public class InteractionWater extends InteractionDefault {
|
|||||||
if(pet == null)
|
if(pet == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
pet.getRoomUnit().clearStatus();
|
||||||
pet.getRoomUnit().removeStatus(RoomUnitStatus.SWIM);
|
pet.getRoomUnit().removeStatus(RoomUnitStatus.SWIM);
|
||||||
|
pet.packetUpdate = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -0,0 +1,109 @@
|
|||||||
|
package com.eu.habbo.habbohotel.items.interactions.pets;
|
||||||
|
|
||||||
|
import com.eu.habbo.Emulator;
|
||||||
|
import com.eu.habbo.habbohotel.bots.Bot;
|
||||||
|
import com.eu.habbo.habbohotel.items.Item;
|
||||||
|
import com.eu.habbo.habbohotel.items.interactions.InteractionDefault;
|
||||||
|
import com.eu.habbo.habbohotel.pets.Pet;
|
||||||
|
import com.eu.habbo.habbohotel.pets.PetTasks;
|
||||||
|
import com.eu.habbo.habbohotel.rooms.*;
|
||||||
|
import com.eu.habbo.habbohotel.users.Habbo;
|
||||||
|
import com.eu.habbo.habbohotel.users.HabboItem;
|
||||||
|
import com.eu.habbo.messages.outgoing.rooms.users.RoomUserStatusComposer;
|
||||||
|
import com.eu.habbo.threading.runnables.PetClearPosture;
|
||||||
|
|
||||||
|
import java.sql.ResultSet;
|
||||||
|
import java.sql.SQLException;
|
||||||
|
|
||||||
|
public class InteractionPetTree extends InteractionDefault {
|
||||||
|
public InteractionPetTree(ResultSet set, Item baseItem) throws SQLException {
|
||||||
|
super(set, baseItem);
|
||||||
|
}
|
||||||
|
|
||||||
|
public InteractionPetTree(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
|
||||||
|
super(id, userId, item, extradata, limitedStack, limitedSells);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onMove(Room room, RoomTile oldLocation, RoomTile newLocation) {
|
||||||
|
for (Pet pet : room.getPetsAt(oldLocation)) {
|
||||||
|
pet.getRoomUnit().clearStatus();
|
||||||
|
pet.getRoomUnit().setStatus(RoomUnitStatus.RELAX, pet.getRoomUnit().getCurrentLocation().getStackHeight() + "");
|
||||||
|
pet.packetUpdate = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public void onPickUp(Room room) {
|
||||||
|
for (Pet pet : room.getPetsOnItem(this)) {
|
||||||
|
pet.getRoomUnit().clearStatus();
|
||||||
|
pet.getRoomUnit().setStatus(RoomUnitStatus.RELAX, pet.getRoomUnit().getCurrentLocation().getStackHeight() + "");
|
||||||
|
pet.packetUpdate = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public 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().getType() == 12 && this.getOccupyingTiles(room.getLayout()).contains(pet.getRoomUnit().getGoal())) {
|
||||||
|
RoomUnitStatus task = RoomUnitStatus.HANG;
|
||||||
|
switch(pet.getTask()){
|
||||||
|
case RING_OF_FIRE: task = RoomUnitStatus.RINGOFFIRE; break;
|
||||||
|
case SWING: task = RoomUnitStatus.SWING; break;
|
||||||
|
case ROLL: task = RoomUnitStatus.ROLL; break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pet.getEnergy() >= 35 && task != RoomUnitStatus.HANG) {
|
||||||
|
|
||||||
|
pet.getRoomUnit().setCanWalk(false);
|
||||||
|
pet.getRoomUnit().setRotation(RoomUserRotation.values()[this.getRotation()]);
|
||||||
|
pet.getRoomUnit().clearStatus();
|
||||||
|
pet.getRoomUnit().setStatus(task, pet.getRoomUnit().getCurrentLocation().getStackHeight() + "");
|
||||||
|
pet.packetUpdate = true;
|
||||||
|
RoomUnitStatus finalTask = task;
|
||||||
|
Emulator.getThreading().run(() -> {
|
||||||
|
pet.addHappyness(25);
|
||||||
|
pet.getRoomUnit().clearStatus();
|
||||||
|
new PetClearPosture(pet, finalTask, null, true);
|
||||||
|
if (this.getRoomId() == room.getId() && this.getOccupyingTiles(room.getLayout()).contains(pet.getRoomUnit().getCurrentLocation())) {
|
||||||
|
pet.getRoomUnit().setStatus(RoomUnitStatus.HANG, pet.getRoomUnit().getCurrentLocation().getStackHeight() + "");
|
||||||
|
} else {
|
||||||
|
pet.getRoomUnit().setStatus(RoomUnitStatus.RELAX, pet.getRoomUnit().getCurrentLocation().getStackHeight() + "");
|
||||||
|
}
|
||||||
|
pet.getRoomUnit().setCanWalk(true);
|
||||||
|
pet.packetUpdate = true;
|
||||||
|
}, 2500 + (Emulator.getRandom().nextInt(20) * 500));
|
||||||
|
} else {
|
||||||
|
pet.getRoomUnit().setRotation(RoomUserRotation.values()[this.getRotation()]);
|
||||||
|
pet.getRoomUnit().clearStatus();
|
||||||
|
pet.getRoomUnit().setStatus(RoomUnitStatus.HANG, pet.getRoomUnit().getCurrentLocation().getStackHeight() + "");
|
||||||
|
pet.packetUpdate = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onWalkOff(RoomUnit roomUnit, Room room, Object[] objects) throws Exception {
|
||||||
|
super.onWalkOff(roomUnit, room, objects);
|
||||||
|
|
||||||
|
Pet pet = room.getPet(roomUnit);
|
||||||
|
|
||||||
|
if (pet != null) {
|
||||||
|
pet.getRoomUnit().clearStatus();
|
||||||
|
pet.getRoomUnit().setStatus(RoomUnitStatus.RELAX, pet.getRoomUnit().getCurrentLocation().getStackHeight() + "");
|
||||||
|
pet.packetUpdate = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canWalkOn(RoomUnit roomUnit, Room room, Object[] objects) {
|
||||||
|
Pet pet = room.getPet(roomUnit);
|
||||||
|
return roomUnit.getRoomUnitType() == RoomUnitType.PET && pet != null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean allowWiredResetState() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
@ -63,7 +63,10 @@ public class PetManager {
|
|||||||
this.put(31, new ActionDance());
|
this.put(31, new ActionDance());
|
||||||
this.put(35, new ActionWings());
|
this.put(35, new ActionWings());
|
||||||
this.put(36, new ActionBreatheFire());
|
this.put(36, new ActionBreatheFire());
|
||||||
|
this.put(37, new ActionHang());
|
||||||
this.put(38, new ActionTorch());
|
this.put(38, new ActionTorch());
|
||||||
|
this.put(40, new ActionSwing());
|
||||||
|
this.put(41, new ActionRoll());
|
||||||
this.put(42, new ActionRingOfFire());
|
this.put(42, new ActionRingOfFire());
|
||||||
this.put(43, new ActionEat());
|
this.put(43, new ActionEat());
|
||||||
this.put(46, new ActionBreed());
|
this.put(46, new ActionBreed());
|
||||||
|
@ -0,0 +1,70 @@
|
|||||||
|
package com.eu.habbo.habbohotel.pets.actions;
|
||||||
|
|
||||||
|
import com.eu.habbo.habbohotel.items.interactions.pets.InteractionPetTree;
|
||||||
|
import com.eu.habbo.habbohotel.pets.Pet;
|
||||||
|
import com.eu.habbo.habbohotel.pets.PetAction;
|
||||||
|
import com.eu.habbo.habbohotel.pets.PetTasks;
|
||||||
|
import com.eu.habbo.habbohotel.pets.PetVocalsType;
|
||||||
|
import com.eu.habbo.habbohotel.rooms.RoomTile;
|
||||||
|
import com.eu.habbo.habbohotel.rooms.RoomTileState;
|
||||||
|
import com.eu.habbo.habbohotel.users.Habbo;
|
||||||
|
import com.eu.habbo.habbohotel.users.HabboItem;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
public class ActionHang extends PetAction {
|
||||||
|
public ActionHang() {
|
||||||
|
super(null, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean apply(Pet pet, Habbo habbo, String[] data) {
|
||||||
|
if (pet.getHappyness() < 50) {
|
||||||
|
pet.say(pet.getPetData().randomVocal(PetVocalsType.DISOBEY));
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
|
||||||
|
Set<HabboItem> petTrees = pet.getRoom().getRoomSpecialTypes().getItemsOfType(InteractionPetTree.class);
|
||||||
|
|
||||||
|
if (petTrees == null || petTrees.isEmpty()) {
|
||||||
|
pet.say(pet.getPetData().randomVocal(PetVocalsType.DISOBEY));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
ArrayList<RoomTile> 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,32 +1,70 @@
|
|||||||
package com.eu.habbo.habbohotel.pets.actions;
|
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.Pet;
|
||||||
import com.eu.habbo.habbohotel.pets.PetAction;
|
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.pets.PetVocalsType;
|
||||||
import com.eu.habbo.habbohotel.rooms.RoomUnitStatus;
|
import com.eu.habbo.habbohotel.rooms.RoomTile;
|
||||||
|
import com.eu.habbo.habbohotel.rooms.RoomTileState;
|
||||||
import com.eu.habbo.habbohotel.users.Habbo;
|
import com.eu.habbo.habbohotel.users.Habbo;
|
||||||
import com.eu.habbo.threading.runnables.PetClearPosture;
|
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 class ActionRingOfFire extends PetAction {
|
||||||
public ActionRingOfFire() {
|
public ActionRingOfFire() {
|
||||||
super(null, true);
|
super(null, true);
|
||||||
|
|
||||||
this.minimumActionDuration = 2000;
|
|
||||||
this.statusToSet.add(RoomUnitStatus.RINGOFFIRE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// TO-DO: Make it specifically for the toy tree. I dont have the skills for that
|
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(Pet pet, Habbo habbo, String[] data) {
|
public boolean apply(Pet pet, Habbo habbo, String[] data) {
|
||||||
if (pet.getHappyness() < 50) {
|
if (pet.getHappyness() < 50) {
|
||||||
pet.say(pet.getPetData().randomVocal(PetVocalsType.DISOBEY));
|
pet.say(pet.getPetData().randomVocal(PetVocalsType.DISOBEY));
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
pet.say(pet.getPetData().randomVocal(PetVocalsType.GENERIC_NEUTRAL));
|
|
||||||
|
Set<HabboItem> petTrees = pet.getRoom().getRoomSpecialTypes().getItemsOfType(InteractionPetTree.class);
|
||||||
|
|
||||||
|
if (petTrees == null || petTrees.isEmpty()) {
|
||||||
|
pet.say(pet.getPetData().randomVocal(PetVocalsType.DISOBEY));
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Emulator.getThreading().run(new PetClearPosture(pet, RoomUnitStatus.RINGOFFIRE, null, false), this.minimumActionDuration);
|
ArrayList<RoomTile> 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;
|
return true;
|
||||||
|
} else {
|
||||||
|
pet.say(pet.getPetData().randomVocal(PetVocalsType.DISOBEY));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -0,0 +1,70 @@
|
|||||||
|
package com.eu.habbo.habbohotel.pets.actions;
|
||||||
|
|
||||||
|
import com.eu.habbo.habbohotel.items.interactions.pets.InteractionPetTree;
|
||||||
|
import com.eu.habbo.habbohotel.pets.Pet;
|
||||||
|
import com.eu.habbo.habbohotel.pets.PetAction;
|
||||||
|
import com.eu.habbo.habbohotel.pets.PetTasks;
|
||||||
|
import com.eu.habbo.habbohotel.pets.PetVocalsType;
|
||||||
|
import com.eu.habbo.habbohotel.rooms.RoomTile;
|
||||||
|
import com.eu.habbo.habbohotel.rooms.RoomTileState;
|
||||||
|
import com.eu.habbo.habbohotel.users.Habbo;
|
||||||
|
import com.eu.habbo.habbohotel.users.HabboItem;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
public class ActionRoll extends PetAction {
|
||||||
|
public ActionRoll() {
|
||||||
|
super(null, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean apply(Pet pet, Habbo habbo, String[] data) {
|
||||||
|
if (pet.getHappyness() < 50) {
|
||||||
|
pet.say(pet.getPetData().randomVocal(PetVocalsType.DISOBEY));
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
|
||||||
|
Set<HabboItem> petTrees = pet.getRoom().getRoomSpecialTypes().getItemsOfType(InteractionPetTree.class);
|
||||||
|
|
||||||
|
if (petTrees == null || petTrees.isEmpty()) {
|
||||||
|
pet.say(pet.getPetData().randomVocal(PetVocalsType.DISOBEY));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
ArrayList<RoomTile> tileList = new ArrayList<>();
|
||||||
|
|
||||||
|
for (HabboItem petTree : petTrees) {
|
||||||
|
if (petTree == null || petTree.getRoomId() != pet.getRoom().getId()) continue;
|
||||||
|
tileList.addAll(petTree.getOccupyingTiles(pet.getRoom().getLayout()));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!tileList.isEmpty()) {
|
||||||
|
Collections.shuffle(tileList);
|
||||||
|
RoomTile goal = tileList.get(0);
|
||||||
|
pet.say(pet.getPetData().randomVocal(PetVocalsType.GENERIC_NEUTRAL));
|
||||||
|
|
||||||
|
if (goal == null || goal.state == RoomTileState.BLOCKED) {
|
||||||
|
goal = pet.getRoomUnit().getClosestTile(tileList);
|
||||||
|
}
|
||||||
|
pet.setTask(PetTasks.ROLL);
|
||||||
|
if (goal.distance(pet.getRoomUnit().getCurrentLocation()) == 0) {
|
||||||
|
HabboItem tree = pet.getRoom().getItemsAt(goal).stream().filter(habboItem -> habboItem instanceof InteractionPetTree).findAny().orElse(null);
|
||||||
|
if (tree != null) {
|
||||||
|
try {
|
||||||
|
tree.onWalkOn(pet.getRoomUnit(), pet.getRoom(), null);
|
||||||
|
} catch (Exception ignored) {}
|
||||||
|
} else {
|
||||||
|
pet.say(pet.getPetData().randomVocal(PetVocalsType.DISOBEY));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} else pet.getRoomUnit().setGoalLocation(goal);
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
pet.say(pet.getPetData().randomVocal(PetVocalsType.DISOBEY));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,70 @@
|
|||||||
|
package com.eu.habbo.habbohotel.pets.actions;
|
||||||
|
|
||||||
|
import com.eu.habbo.habbohotel.items.interactions.pets.InteractionPetTree;
|
||||||
|
import com.eu.habbo.habbohotel.pets.Pet;
|
||||||
|
import com.eu.habbo.habbohotel.pets.PetAction;
|
||||||
|
import com.eu.habbo.habbohotel.pets.PetTasks;
|
||||||
|
import com.eu.habbo.habbohotel.pets.PetVocalsType;
|
||||||
|
import com.eu.habbo.habbohotel.rooms.RoomTile;
|
||||||
|
import com.eu.habbo.habbohotel.rooms.RoomTileState;
|
||||||
|
import com.eu.habbo.habbohotel.users.Habbo;
|
||||||
|
import com.eu.habbo.habbohotel.users.HabboItem;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
public class ActionSwing extends PetAction {
|
||||||
|
public ActionSwing() {
|
||||||
|
super(null, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean apply(Pet pet, Habbo habbo, String[] data) {
|
||||||
|
if (pet.getHappyness() < 50) {
|
||||||
|
pet.say(pet.getPetData().randomVocal(PetVocalsType.DISOBEY));
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
|
||||||
|
Set<HabboItem> petTrees = pet.getRoom().getRoomSpecialTypes().getItemsOfType(InteractionPetTree.class);
|
||||||
|
|
||||||
|
if (petTrees == null || petTrees.isEmpty()) {
|
||||||
|
pet.say(pet.getPetData().randomVocal(PetVocalsType.DISOBEY));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
ArrayList<RoomTile> 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -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.freeze.InteractionFreezeExitTile;
|
||||||
import com.eu.habbo.habbohotel.items.interactions.games.tag.InteractionTagField;
|
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.games.tag.InteractionTagPole;
|
||||||
import com.eu.habbo.habbohotel.items.interactions.pets.InteractionNest;
|
import com.eu.habbo.habbohotel.items.interactions.pets.*;
|
||||||
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.wired.extra.WiredBlob;
|
import com.eu.habbo.habbohotel.items.interactions.wired.extra.WiredBlob;
|
||||||
import com.eu.habbo.habbohotel.messenger.MessengerBuddy;
|
import com.eu.habbo.habbohotel.messenger.MessengerBuddy;
|
||||||
import com.eu.habbo.habbohotel.permissions.Permission;
|
import com.eu.habbo.habbohotel.permissions.Permission;
|
||||||
@ -2393,6 +2390,8 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
|
|||||||
this.roomSpecialTypes.addPetDrink((InteractionPetDrink) item);
|
this.roomSpecialTypes.addPetDrink((InteractionPetDrink) item);
|
||||||
} else if (item instanceof InteractionPetFood) {
|
} else if (item instanceof InteractionPetFood) {
|
||||||
this.roomSpecialTypes.addPetFood((InteractionPetFood) item);
|
this.roomSpecialTypes.addPetFood((InteractionPetFood) item);
|
||||||
|
} else if (item instanceof InteractionPetTree) {
|
||||||
|
this.roomSpecialTypes.addUndefined(item);
|
||||||
} else if (item instanceof InteractionMoodLight) {
|
} else if (item instanceof InteractionMoodLight) {
|
||||||
this.roomSpecialTypes.addUndefined(item);
|
this.roomSpecialTypes.addUndefined(item);
|
||||||
} else if (item instanceof InteractionPyramid) {
|
} else if (item instanceof InteractionPyramid) {
|
||||||
@ -2923,6 +2922,27 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
|
|||||||
return false;
|
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) {
|
public THashSet<Bot> getBotsAt(RoomTile tile) {
|
||||||
THashSet<Bot> bots = new THashSet<>();
|
THashSet<Bot> bots = new THashSet<>();
|
||||||
synchronized (this.currentBots) {
|
synchronized (this.currentBots) {
|
||||||
@ -3000,6 +3020,17 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
|
|||||||
return bots;
|
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) {
|
public void teleportHabboToItem(Habbo habbo, HabboItem item) {
|
||||||
this.teleportRoomUnitToLocation(habbo.getRoomUnit(), item.getX(), item.getY(), item.getZ() + Item.getCurrentHeight(item));
|
this.teleportRoomUnitToLocation(habbo.getRoomUnit(), item.getX(), item.getY(), item.getZ() + Item.getCurrentHeight(item));
|
||||||
}
|
}
|
||||||
|
@ -69,7 +69,12 @@ public enum RoomUnitStatus {
|
|||||||
|
|
||||||
SLEEP_IN("slp-in"),
|
SLEEP_IN("slp-in"),
|
||||||
SLEEP("slp", true),
|
SLEEP("slp", true),
|
||||||
SLEEP_OUT("slp-out");
|
SLEEP_OUT("slp-out"),
|
||||||
|
|
||||||
|
RINGOFFIRE("rng"),
|
||||||
|
SWING("swg"),
|
||||||
|
HANG("hg"),
|
||||||
|
ROLL("rll");
|
||||||
|
|
||||||
public final String key;
|
public final String key;
|
||||||
public final boolean removeWhenWalking;
|
public final boolean removeWhenWalking;
|
||||||
|
Loading…
Reference in New Issue
Block a user