🆙 Small fix for bouncing on user

This commit is contained in:
duckietm
2026-03-16 17:49:18 +01:00
parent a50ff9b9f8
commit 68180bcb04
2 changed files with 23 additions and 0 deletions
@@ -4,11 +4,16 @@ import com.eu.habbo.Emulator;
import com.eu.habbo.habbohotel.rooms.Room;
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 com.eu.habbo.messages.outgoing.rooms.items.FloorItemOnRollerComposer;
import com.eu.habbo.util.pathfinding.Direction8;
import gnu.trove.set.hash.THashSet;
/**
* Alternative football physics based on the Rebug plugin.
* Uses momentum decay (ball slows down over time) and simple 180-degree bounce.
*/
public class RebugKickBallAction implements Runnable {
private final HabboItem ball;
@@ -18,6 +23,9 @@ public class RebugKickBallAction implements Runnable {
private boolean isDribble;
public boolean dead = false;
// Track tiles traveled since last wall bounce for user-bounce logic
private int tilesSinceBounce = -1; // -1 = no bounce has happened yet
public RebugKickBallAction(HabboItem ball, Room room, Direction8 direction, int momentum) {
this.ball = ball;
this.room = room;
@@ -42,6 +50,7 @@ public class RebugKickBallAction implements Runnable {
if (isTileBlocked(nextX, nextY)) {
this.direction = this.direction.rotateDirection180Degrees();
this.tilesSinceBounce = 0;
nextX = this.ball.getX() + this.direction.getDiffX();
nextY = this.ball.getY() + this.direction.getDiffY();
}
@@ -58,6 +67,20 @@ public class RebugKickBallAction implements Runnable {
this.ball.setZ(nextTile.getStackHeight());
this.ball.needsUpdate(true);
// Count tiles since bounce
if (this.tilesSinceBounce >= 0) {
this.tilesSinceBounce++;
}
// After bouncing, if ball has traveled more than 1 tile from the wall, bounce off users
if (this.tilesSinceBounce > 1 && !this.isDribble) {
THashSet<Habbo> habbos = this.room.getHabbosAt(nextTile.x, nextTile.y);
if (!habbos.isEmpty()) {
this.direction = this.direction.rotateDirection180Degrees();
this.tilesSinceBounce = 0;
}
}
// Schedule next movement
if (!this.isDribble) {
long delay = getDelayForMomentum(this.momentum);