mirror of
https://git.krews.org/morningstar/Arcturus-Community.git
synced 2024-11-27 08:50:51 +01:00
Feature InteractionPetTree
This commit is contained in:
parent
8509692f4b
commit
582da9dad0
@ -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));
|
||||||
|
@ -0,0 +1,108 @@
|
|||||||
|
package com.eu.habbo.habbohotel.items.interactions.pets;
|
||||||
|
|
||||||
|
import com.eu.habbo.Emulator;
|
||||||
|
import com.eu.habbo.habbohotel.bots.Bot;
|
||||||
|
import com.eu.habbo.habbohotel.items.Item;
|
||||||
|
import com.eu.habbo.habbohotel.items.interactions.InteractionDefault;
|
||||||
|
import com.eu.habbo.habbohotel.pets.Pet;
|
||||||
|
import com.eu.habbo.habbohotel.pets.PetTasks;
|
||||||
|
import com.eu.habbo.habbohotel.rooms.*;
|
||||||
|
import com.eu.habbo.habbohotel.users.Habbo;
|
||||||
|
import com.eu.habbo.habbohotel.users.HabboItem;
|
||||||
|
import com.eu.habbo.messages.outgoing.rooms.users.RoomUserStatusComposer;
|
||||||
|
import com.eu.habbo.threading.runnables.PetClearPosture;
|
||||||
|
|
||||||
|
import java.sql.ResultSet;
|
||||||
|
import java.sql.SQLException;
|
||||||
|
|
||||||
|
public class InteractionPetTree extends InteractionDefault {
|
||||||
|
public InteractionPetTree(ResultSet set, Item baseItem) throws SQLException {
|
||||||
|
super(set, baseItem);
|
||||||
|
}
|
||||||
|
|
||||||
|
public InteractionPetTree(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
|
||||||
|
super(id, userId, item, extradata, limitedStack, limitedSells);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onMove(Room room, RoomTile oldLocation, RoomTile newLocation) {
|
||||||
|
for (Pet pet : room.getPetsAt(oldLocation)) {
|
||||||
|
pet.getRoomUnit().clearStatus();
|
||||||
|
pet.getRoomUnit().setStatus(RoomUnitStatus.RELAX, pet.getRoomUnit().getCurrentLocation().getStackHeight() + "");
|
||||||
|
pet.packetUpdate = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public void onPickUp(Room room) {
|
||||||
|
for (Pet pet : room.getPetsOnItem(this)) {
|
||||||
|
pet.getRoomUnit().clearStatus();
|
||||||
|
pet.getRoomUnit().setStatus(RoomUnitStatus.RELAX, pet.getRoomUnit().getCurrentLocation().getStackHeight() + "");
|
||||||
|
pet.packetUpdate = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canWalkOn(RoomUnit roomUnit, Room room, Object[] objects) {
|
||||||
|
Pet pet = room.getPet(roomUnit);
|
||||||
|
return (roomUnit.getRoomUnitType() == RoomUnitType.PET && pet != null && pet.getPetData().getType() == 12);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onWalkOn(RoomUnit roomUnit, Room room, Object[] objects) throws Exception {
|
||||||
|
super.onWalkOn(roomUnit, room, objects);
|
||||||
|
|
||||||
|
Pet pet = room.getPet(roomUnit);
|
||||||
|
if (pet != null && this.getOccupyingTiles(room.getLayout()).contains(pet.getRoomUnit().getGoal())) {
|
||||||
|
RoomUnitStatus task = RoomUnitStatus.HANG;
|
||||||
|
switch(pet.getTask()){
|
||||||
|
case RING_OF_FIRE: task = RoomUnitStatus.RINGOFFIRE; break;
|
||||||
|
case SWING: task = RoomUnitStatus.SWING; break;
|
||||||
|
case ROLL: task = RoomUnitStatus.ROLL; break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pet.getEnergy() >= 35 && task != RoomUnitStatus.HANG) {
|
||||||
|
|
||||||
|
pet.getRoomUnit().setCanWalk(false);
|
||||||
|
pet.getRoomUnit().setRotation(RoomUserRotation.values()[this.getRotation()]);
|
||||||
|
pet.getRoomUnit().clearStatus();
|
||||||
|
pet.getRoomUnit().setStatus(task, pet.getRoomUnit().getCurrentLocation().getStackHeight() + "");
|
||||||
|
pet.packetUpdate = true;
|
||||||
|
RoomUnitStatus finalTask = task;
|
||||||
|
Emulator.getThreading().run(() -> {
|
||||||
|
pet.addHappyness(25);
|
||||||
|
pet.getRoomUnit().clearStatus();
|
||||||
|
new PetClearPosture(pet, finalTask, null, true);
|
||||||
|
if (this.getRoomId() == room.getId() && this.getOccupyingTiles(room.getLayout()).contains(pet.getRoomUnit().getCurrentLocation())) {
|
||||||
|
pet.getRoomUnit().setStatus(RoomUnitStatus.HANG, pet.getRoomUnit().getCurrentLocation().getStackHeight() + "");
|
||||||
|
} else {
|
||||||
|
pet.getRoomUnit().setStatus(RoomUnitStatus.RELAX, pet.getRoomUnit().getCurrentLocation().getStackHeight() + "");
|
||||||
|
}
|
||||||
|
pet.getRoomUnit().setCanWalk(true);
|
||||||
|
pet.packetUpdate = true;
|
||||||
|
}, 2500 + (Emulator.getRandom().nextInt(20) * 500));
|
||||||
|
} else {
|
||||||
|
pet.getRoomUnit().setRotation(RoomUserRotation.values()[this.getRotation()]);
|
||||||
|
pet.getRoomUnit().clearStatus();
|
||||||
|
pet.getRoomUnit().setStatus(RoomUnitStatus.HANG, pet.getRoomUnit().getCurrentLocation().getStackHeight() + "");
|
||||||
|
pet.packetUpdate = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onWalkOff(RoomUnit roomUnit, Room room, Object[] objects) throws Exception {
|
||||||
|
super.onWalkOff(roomUnit, room, objects);
|
||||||
|
|
||||||
|
Pet pet = room.getPet(roomUnit);
|
||||||
|
|
||||||
|
if (pet != null) {
|
||||||
|
pet.getRoomUnit().clearStatus();
|
||||||
|
pet.getRoomUnit().setStatus(RoomUnitStatus.RELAX, pet.getRoomUnit().getCurrentLocation().getStackHeight() + "");
|
||||||
|
pet.packetUpdate = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public boolean allowWiredResetState() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
@ -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;
|
||||||
@ -2391,6 +2388,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) {
|
||||||
@ -2921,6 +2920,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) {
|
||||||
@ -2998,6 +3018,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));
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user