🆙 Not 100% yet but it is working : Banzai teleporters while riding horse and better timing/animations to match official habbo
This commit is contained in:
parent
808d9b45ea
commit
1d6ef05206
1
.gitignore
vendored
1
.gitignore
vendored
@ -13,3 +13,4 @@ config.ini
|
|||||||
*.zip
|
*.zip
|
||||||
.DS_Store
|
.DS_Store
|
||||||
|
|
||||||
|
/Emulator/plugins
|
||||||
|
@ -116,32 +116,29 @@ public class RoomUnit {
|
|||||||
|
|
||||||
public boolean cycle(Room room) {
|
public boolean cycle(Room room) {
|
||||||
try {
|
try {
|
||||||
Habbo rider = null;
|
Habbo rider;
|
||||||
if (this.getRoomUnitType() == RoomUnitType.PET) {
|
if (this.getRoomUnitType() == RoomUnitType.PET) {
|
||||||
Pet pet = room.getPet(this);
|
Pet pet = room.getPet(this);
|
||||||
if (pet instanceof RideablePet) {
|
if (pet instanceof RideablePet) {
|
||||||
rider = ((RideablePet) pet).getRider();
|
rider = ((RideablePet) pet).getRider();
|
||||||
|
|
||||||
|
if (rider != null) {
|
||||||
|
if (this.status.containsKey(RoomUnitStatus.MOVE) && !rider.getRoomUnit().getStatusMap().containsKey(RoomUnitStatus.MOVE))
|
||||||
|
this.status.remove(RoomUnitStatus.MOVE);
|
||||||
|
|
||||||
|
if (rider.getRoomUnit().getCurrentLocation().x != this.getX() || rider.getRoomUnit().getCurrentLocation().y != this.getY()) {
|
||||||
|
this.status.put(RoomUnitStatus.MOVE, rider.getRoomUnit().getCurrentLocation().x + "," + rider.getRoomUnit().getCurrentLocation().y + "," + (rider.getRoomUnit().getCurrentLocation().getStackHeight()));
|
||||||
|
this.setPreviousLocation(rider.getRoomUnit().getPreviousLocation());
|
||||||
|
this.setPreviousLocationZ(rider.getRoomUnit().getPreviousLocation().getStackHeight());
|
||||||
|
this.setCurrentLocation(rider.getRoomUnit().getCurrentLocation());
|
||||||
|
this.setZ(rider.getRoomUnit().getCurrentLocation().getStackHeight());
|
||||||
|
}
|
||||||
|
|
||||||
|
return this.statusUpdate;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rider != null) {
|
|
||||||
// copy things from rider
|
|
||||||
if (this.status.containsKey(RoomUnitStatus.MOVE) && !rider.getRoomUnit().getStatusMap().containsKey(RoomUnitStatus.MOVE)) {
|
|
||||||
this.status.remove(RoomUnitStatus.MOVE);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (rider.getRoomUnit().getCurrentLocation().x != this.getX() || rider.getRoomUnit().getCurrentLocation().y != this.getY()) {
|
|
||||||
this.status.put(RoomUnitStatus.MOVE, rider.getRoomUnit().getCurrentLocation().x + "," + rider.getRoomUnit().getCurrentLocation().y + "," + (rider.getRoomUnit().getCurrentLocation().getStackHeight()));
|
|
||||||
this.setPreviousLocation(rider.getRoomUnit().getPreviousLocation());
|
|
||||||
this.setPreviousLocationZ(rider.getRoomUnit().getPreviousLocation().getStackHeight());
|
|
||||||
this.setCurrentLocation(rider.getRoomUnit().getCurrentLocation());
|
|
||||||
this.setZ(rider.getRoomUnit().getCurrentLocation().getStackHeight());
|
|
||||||
}
|
|
||||||
|
|
||||||
return this.statusUpdate;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if (!this.isWalking() && !this.isKicked) {
|
if (!this.isWalking() && !this.isKicked) {
|
||||||
if (this.status.remove(RoomUnitStatus.MOVE) == null) {
|
if (this.status.remove(RoomUnitStatus.MOVE) == null) {
|
||||||
Habbo habboT = room.getHabbo(this);
|
Habbo habboT = room.getHabbo(this);
|
||||||
@ -248,7 +245,8 @@ public class RoomUnit {
|
|||||||
//if(!(this.path.size() == 0 && canSitNextTile))
|
//if(!(this.path.size() == 0 && canSitNextTile))
|
||||||
{
|
{
|
||||||
double height = next.getStackHeight() - this.currentLocation.getStackHeight();
|
double height = next.getStackHeight() - this.currentLocation.getStackHeight();
|
||||||
if (!room.tileWalkable(next) || (!RoomLayout.ALLOW_FALLING && height < -RoomLayout.MAXIMUM_STEP_HEIGHT) || (next.state == RoomTileState.OPEN && height > RoomLayout.MAXIMUM_STEP_HEIGHT)) {
|
if (!room.tileWalkable(next) || (!RoomLayout.ALLOW_FALLING && height < -RoomLayout.MAXIMUM_STEP_HEIGHT) ||
|
||||||
|
(next.state == RoomTileState.OPEN && height > RoomLayout.MAXIMUM_STEP_HEIGHT)) {
|
||||||
this.room = room;
|
this.room = room;
|
||||||
this.path.clear();
|
this.path.clear();
|
||||||
this.findPath();
|
this.findPath();
|
||||||
@ -257,8 +255,7 @@ public class RoomUnit {
|
|||||||
this.status.remove(RoomUnitStatus.MOVE);
|
this.status.remove(RoomUnitStatus.MOVE);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
next = (RoomTile)this.path.pop();
|
next = this.path.pop();
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -330,7 +327,7 @@ public class RoomUnit {
|
|||||||
zHeight += room.getLayout().getHeightAtSquare(next.x, next.y);
|
zHeight += room.getLayout().getHeightAtSquare(next.x, next.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
Optional<HabboItem> stackHelper = room.getItemsAt(next).stream().filter(i -> i instanceof InteractionTileWalkMagic).findAny();
|
Optional<HabboItem> stackHelper = this.room.getItemsAt(next).stream().filter(i -> i instanceof InteractionTileWalkMagic).findAny();
|
||||||
if (stackHelper.isPresent()) {
|
if (stackHelper.isPresent()) {
|
||||||
zHeight = stackHelper.get().getZ();
|
zHeight = stackHelper.get().getZ();
|
||||||
}
|
}
|
||||||
@ -511,10 +508,10 @@ public class RoomUnit {
|
|||||||
|
|
||||||
public void setGoalLocation(RoomTile goalLocation) {
|
public void setGoalLocation(RoomTile goalLocation) {
|
||||||
if (goalLocation != null) {
|
if (goalLocation != null) {
|
||||||
// if (goalLocation.state != RoomTileState.INVALID) {
|
// if (goalLocation.state != RoomTileState.INVALID) {
|
||||||
this.setGoalLocation(goalLocation, false);
|
this.setGoalLocation(goalLocation, false);
|
||||||
}
|
}
|
||||||
//}
|
//}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setGoalLocation(RoomTile goalLocation, boolean noReset) {
|
public void setGoalLocation(RoomTile goalLocation, boolean noReset) {
|
||||||
@ -817,9 +814,9 @@ public class RoomUnit {
|
|||||||
|
|
||||||
return this.getClosestTile(
|
return this.getClosestTile(
|
||||||
rotations.stream()
|
rotations.stream()
|
||||||
.map(rotation -> room.getLayout().getTileInFront(baseTile, rotation))
|
.map(rotation -> room.getLayout().getTileInFront(baseTile, rotation))
|
||||||
.filter(t -> t != null && t.isWalkable() && (this.getCurrentLocation().equals(t) || !room.hasHabbosAt(t.x, t.y)))
|
.filter(t -> t != null && t.isWalkable() && (this.getCurrentLocation().equals(t) || !room.hasHabbosAt(t.x, t.y)))
|
||||||
.collect(Collectors.toList())
|
.collect(Collectors.toList())
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,74 +1,145 @@
|
|||||||
package com.eu.habbo.threading.runnables;
|
package com.eu.habbo.threading.runnables;
|
||||||
|
|
||||||
import com.eu.habbo.Emulator;
|
import com.eu.habbo.Emulator;
|
||||||
import com.eu.habbo.habbohotel.rooms.Room;
|
import com.eu.habbo.habbohotel.rooms.*;
|
||||||
import com.eu.habbo.habbohotel.rooms.RoomTile;
|
import com.eu.habbo.habbohotel.users.Habbo;
|
||||||
import com.eu.habbo.habbohotel.rooms.RoomUnit;
|
|
||||||
import com.eu.habbo.habbohotel.rooms.RoomUserRotation;
|
|
||||||
import com.eu.habbo.habbohotel.users.HabboItem;
|
import com.eu.habbo.habbohotel.users.HabboItem;
|
||||||
|
import com.eu.habbo.habbohotel.pets.Pet;
|
||||||
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
public class BanzaiRandomTeleport implements Runnable {
|
public class BanzaiRandomTeleport implements Runnable {
|
||||||
private final HabboItem item;
|
private static final Logger LOGGER = LoggerFactory.getLogger(BanzaiRandomTeleport.class);
|
||||||
private final HabboItem toItem;
|
|
||||||
private final RoomUnit habbo;
|
|
||||||
private final Room room;
|
|
||||||
|
|
||||||
public BanzaiRandomTeleport(HabboItem item, HabboItem toItem, RoomUnit habbo, Room room) {
|
private final HabboItem initialTeleporter;
|
||||||
this.item = item;
|
private final HabboItem targetTeleporter;
|
||||||
this.toItem = toItem;
|
private final RoomUnit roomUnit;
|
||||||
this.habbo = habbo;
|
private final Room room;
|
||||||
|
private RoomUserRotation newRotation;
|
||||||
|
|
||||||
|
public BanzaiRandomTeleport(HabboItem initialTeleporter, HabboItem targetTeleporter, RoomUnit roomUnit, Room room) {
|
||||||
|
this(initialTeleporter, targetTeleporter, roomUnit, room, getRandomRotation());
|
||||||
|
}
|
||||||
|
|
||||||
|
public BanzaiRandomTeleport(HabboItem initialTeleporter, HabboItem targetTeleporter, RoomUnit roomUnit, Room room, RoomUserRotation newRotation) {
|
||||||
|
this.initialTeleporter = initialTeleporter;
|
||||||
|
this.targetTeleporter = targetTeleporter;
|
||||||
|
this.roomUnit = roomUnit;
|
||||||
this.room = room;
|
this.room = room;
|
||||||
|
this.newRotation = newRotation;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static RoomUserRotation getRandomRotation() {
|
||||||
|
RoomUserRotation[] rotations = RoomUserRotation.values();
|
||||||
|
return rotations[Emulator.getRandom().nextInt(rotations.length)];
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
HabboItem topItemNow = this.room.getTopItemAt(this.habbo.getX(), this.habbo.getY());
|
if (roomUnit == null || room == null || roomUnit.getCurrentLocation() == null) {
|
||||||
RoomTile lastLocation = this.habbo.getCurrentLocation();
|
LOGGER.warn("RoomUnit or Room reference is null, teleport aborted.");
|
||||||
RoomTile newLocation = this.room.getLayout().getTile(toItem.getX(), toItem.getY());
|
return;
|
||||||
|
|
||||||
if(topItemNow != null) {
|
|
||||||
try {
|
|
||||||
topItemNow.onWalkOff(this.habbo, this.room, new Object[] { lastLocation, newLocation, this });
|
|
||||||
} catch (Exception e) {
|
|
||||||
LoggerFactory.getLogger(BanzaiRandomTeleport.class).error("BanzaiRandomTeleport exception", e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Emulator.getThreading().run(() -> {
|
final RoomTile teleporterTile = room.getLayout().getTile(initialTeleporter.getX(), initialTeleporter.getY());
|
||||||
if (this.item.getExtradata().equals("1")) {
|
final RoomTile newLocation = room.getLayout().getTile(targetTeleporter.getX(), targetTeleporter.getY());
|
||||||
this.item.setExtradata("0");
|
|
||||||
this.room.updateItemState(this.item);
|
|
||||||
}
|
|
||||||
}, 500);
|
|
||||||
|
|
||||||
if(!this.toItem.getExtradata().equals("1")) {
|
// Determine if the user is riding a pet
|
||||||
this.toItem.setExtradata("1");
|
final boolean isRiding = isUserRiding();
|
||||||
this.room.updateItemState(this.toItem);
|
final Habbo rider = isRiding ? room.getHabbo(roomUnit) : null;
|
||||||
|
final RoomUnit petUnit;
|
||||||
|
|
||||||
|
if (rider != null && rider.getHabboInfo().getRiding() != null) {
|
||||||
|
petUnit = rider.getHabboInfo().getRiding().getRoomUnit();
|
||||||
|
} else {
|
||||||
|
petUnit = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
Emulator.getThreading().run(() -> {
|
// Move the pet onto the teleport tile before teleporting
|
||||||
this.habbo.setCanWalk(true);
|
if (petUnit != null) {
|
||||||
HabboItem topItemNext = this.room.getTopItemAt(this.habbo.getX(), this.habbo.getY());
|
// Temporarily override the pet's movement logic to force it onto the teleport tile
|
||||||
|
petUnit.setCanWalk(true); // Ensure the pet can walk
|
||||||
|
petUnit.setGoalLocation(teleporterTile); // Set the goal location
|
||||||
|
petUnit.setCurrentLocation(teleporterTile); // Force the pet to the teleport tile
|
||||||
|
petUnit.setZ(teleporterTile.getStackHeight()); // Set the correct Z-height
|
||||||
|
LOGGER.info("Pet {} moved onto teleporter tile at ({}, {})", petUnit.getId(), teleporterTile.x, teleporterTile.y);
|
||||||
|
|
||||||
if(topItemNext != null) {
|
// Ensure both pet and rider face the same direction
|
||||||
try {
|
roomUnit.setRotation(this.newRotation);
|
||||||
topItemNext.onWalkOn(this.habbo, this.room, new Object[] { lastLocation, newLocation, this });
|
petUnit.setRotation(this.newRotation);
|
||||||
} catch (Exception e) {
|
|
||||||
LoggerFactory.getLogger(BanzaiRandomTeleport.class).error("BanzaiRandomTeleport exception", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.toItem.getExtradata().equals("1")) {
|
// Get correct Z-height
|
||||||
this.toItem.setExtradata("0");
|
final double baseZ = targetTeleporter.getZ();
|
||||||
this.room.updateItemState(this.toItem);
|
final double finalPetZ = baseZ;
|
||||||
}
|
final double finalRiderZ = baseZ + (isRiding ? 1 : 0); // Rider stays above pet if riding
|
||||||
}, 750);
|
|
||||||
|
|
||||||
Emulator.getThreading().run(() -> {
|
// Delay to ensure the pet has reached the teleport tile
|
||||||
this.habbo.setRotation(RoomUserRotation.fromValue(Emulator.getRandom().nextInt(8)));
|
Emulator.getThreading().run(() -> {
|
||||||
this.room.teleportRoomUnitToLocation(this.habbo, newLocation.x, newLocation.y, newLocation.getStackHeight());
|
room.teleportRoomUnitToLocation(petUnit, newLocation.x, newLocation.y, finalPetZ);
|
||||||
}, 250);
|
petUnit.setZ(finalPetZ);
|
||||||
|
LOGGER.info("Pet {} teleported to ({}, {}), Z = {}", petUnit.getId(), newLocation.x, newLocation.y, finalPetZ);
|
||||||
|
|
||||||
|
room.teleportRoomUnitToLocation(roomUnit, newLocation.x, newLocation.y, finalRiderZ);
|
||||||
|
roomUnit.setZ(finalRiderZ);
|
||||||
|
LOGGER.info("Rider {} teleported to ({}, {}), Z = {}", roomUnit.getId(), newLocation.x, newLocation.y, finalRiderZ);
|
||||||
|
|
||||||
|
// Synchronize rotations after teleportation
|
||||||
|
petUnit.setRotation(roomUnit.getBodyRotation());
|
||||||
|
petUnit.setBodyRotation(roomUnit.getBodyRotation());
|
||||||
|
petUnit.setHeadRotation(roomUnit.getHeadRotation());
|
||||||
|
|
||||||
|
// Re-enable walking after teleportation
|
||||||
|
Emulator.getThreading().run(() -> {
|
||||||
|
roomUnit.setCanWalk(true);
|
||||||
|
petUnit.setCanWalk(true);
|
||||||
|
|
||||||
|
// Update teleporter states
|
||||||
|
if ("1".equals(initialTeleporter.getExtradata())) {
|
||||||
|
initialTeleporter.setExtradata("0");
|
||||||
|
room.updateItemState(initialTeleporter);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ("1".equals(targetTeleporter.getExtradata())) {
|
||||||
|
targetTeleporter.setExtradata("0");
|
||||||
|
room.updateItemState(targetTeleporter);
|
||||||
|
}
|
||||||
|
}, 650); // Delay to ensure smooth transition
|
||||||
|
}, 1000); // Increased delay to ensure pet reaches the teleport tile
|
||||||
|
} else {
|
||||||
|
// If not riding, proceed with teleportation for the rider only
|
||||||
|
roomUnit.setRotation(this.newRotation);
|
||||||
|
|
||||||
|
final double baseZ = targetTeleporter.getZ();
|
||||||
|
final double finalRiderZ = baseZ;
|
||||||
|
|
||||||
|
Emulator.getThreading().run(() -> {
|
||||||
|
room.teleportRoomUnitToLocation(roomUnit, newLocation.x, newLocation.y, finalRiderZ);
|
||||||
|
roomUnit.setZ(finalRiderZ);
|
||||||
|
LOGGER.info("Rider {} teleported to ({}, {}), Z = {}", roomUnit.getId(), newLocation.x, newLocation.y, finalRiderZ);
|
||||||
|
|
||||||
|
Emulator.getThreading().run(() -> {
|
||||||
|
roomUnit.setCanWalk(true);
|
||||||
|
|
||||||
|
// Update teleporter states
|
||||||
|
if ("1".equals(initialTeleporter.getExtradata())) {
|
||||||
|
initialTeleporter.setExtradata("0");
|
||||||
|
room.updateItemState(initialTeleporter);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ("1".equals(targetTeleporter.getExtradata())) {
|
||||||
|
targetTeleporter.setExtradata("0");
|
||||||
|
room.updateItemState(targetTeleporter);
|
||||||
|
}
|
||||||
|
}, 650); // Delay to ensure smooth transition
|
||||||
|
}, 700); // Standard delay for non-ridden teleportation
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
private boolean isUserRiding() {
|
||||||
|
if (roomUnit.getRoomUnitType() != RoomUnitType.USER) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
Habbo habbo = room.getHabbo(roomUnit);
|
||||||
|
return habbo != null && habbo.getHabboInfo().getRiding() != null;
|
||||||
|
}
|
||||||
|
}
|
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user