You've already forked Arcturus-Morningstar-Extended
mirror of
https://github.com/duckietm/Arcturus-Morningstar-Extended.git
synced 2026-06-20 15:36:17 +00:00
🆙 Start making ReBug Football great - all movements are 100% effects will follow later
This commit is contained in:
+59
-7
@@ -1,23 +1,23 @@
|
|||||||
package com.eu.habbo.habbohotel.items.interactions.games.football;
|
package com.eu.habbo.habbohotel.items.interactions.games.football;
|
||||||
|
|
||||||
import com.eu.habbo.Emulator;
|
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.Item;
|
||||||
import com.eu.habbo.habbohotel.items.interactions.InteractionDefault;
|
import com.eu.habbo.habbohotel.items.interactions.InteractionDefault;
|
||||||
import com.eu.habbo.habbohotel.rooms.Room;
|
import com.eu.habbo.habbohotel.rooms.Room;
|
||||||
|
import com.eu.habbo.habbohotel.rooms.RoomLayout;
|
||||||
|
import com.eu.habbo.habbohotel.rooms.RoomTile;
|
||||||
import com.eu.habbo.habbohotel.rooms.RoomUnit;
|
import com.eu.habbo.habbohotel.rooms.RoomUnit;
|
||||||
import com.eu.habbo.threading.runnables.RebugKickBallAction;
|
import com.eu.habbo.threading.runnables.RebugKickBallAction;
|
||||||
|
import com.eu.habbo.util.pathfinding.Direction8;
|
||||||
|
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
|
|
||||||
/**
|
|
||||||
* Rebug-style football interaction.
|
|
||||||
* Uses simplified momentum-decay physics with 180-degree bounce.
|
|
||||||
* Set interaction_type to "rebug_football" on a ball item to use this instead of the default football physics.
|
|
||||||
*/
|
|
||||||
public class InteractionRebugFootball extends InteractionDefault {
|
public class InteractionRebugFootball extends InteractionDefault {
|
||||||
|
|
||||||
private RebugKickBallAction currentThread;
|
private RebugKickBallAction currentThread;
|
||||||
|
private Direction8 lastDribbleDirection;
|
||||||
|
|
||||||
public InteractionRebugFootball(ResultSet set, Item baseItem) throws SQLException {
|
public InteractionRebugFootball(ResultSet set, Item baseItem) throws SQLException {
|
||||||
super(set, baseItem);
|
super(set, baseItem);
|
||||||
@@ -43,12 +43,64 @@ public class InteractionRebugFootball extends InteractionDefault {
|
|||||||
public void onWalkOn(RoomUnit roomUnit, Room room, Object[] objects) throws Exception {
|
public void onWalkOn(RoomUnit roomUnit, Room room, Object[] objects) throws Exception {
|
||||||
super.onWalkOn(roomUnit, room, objects);
|
super.onWalkOn(roomUnit, room, objects);
|
||||||
|
|
||||||
|
Direction8 userDir = Direction8.getDirection(roomUnit.getBodyRotation().getValue());
|
||||||
|
this.lastDribbleDirection = userDir;
|
||||||
|
|
||||||
|
// If this tile is the user's final destination, they'll stop here → long shot
|
||||||
|
RoomTile goal = roomUnit.getGoal();
|
||||||
|
if (goal != null && goal.x == this.getX() && goal.y == this.getY()) {
|
||||||
|
this.kick(room, roomUnit, 55);
|
||||||
|
} else {
|
||||||
|
// Dribble: ball moves 1 tile ahead of the user
|
||||||
|
this.kick(room, roomUnit, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onWalkOff(RoomUnit roomUnit, Room room, Object[] objects) throws Exception {
|
||||||
|
super.onWalkOff(roomUnit, room, objects);
|
||||||
|
|
||||||
|
if (objects != null && objects.length >= 2 && objects[1] instanceof RoomTile && objects[0] instanceof RoomTile) {
|
||||||
|
RoomTile fromTile = (RoomTile) objects[0];
|
||||||
|
RoomTile nextTile = (RoomTile) objects[1];
|
||||||
|
|
||||||
|
int dx = nextTile.x - fromTile.x;
|
||||||
|
int dy = nextTile.y - fromTile.y;
|
||||||
|
Direction8 walkDir = Direction8.fromDelta(dx, dy);
|
||||||
|
|
||||||
|
// User is walking in the same direction as the ball was dribbled → long shot
|
||||||
|
if (this.lastDribbleDirection != null && walkDir.getRot() == this.lastDribbleDirection.getRot()) {
|
||||||
|
this.kick(room, roomUnit, 55);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Walking sideways or away → just stop the ball
|
||||||
|
if (this.currentThread != null) {
|
||||||
|
this.currentThread.dead = true;
|
||||||
|
this.currentThread = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onClick(GameClient client, Room room, Object[] objects) throws Exception {
|
||||||
|
super.onClick(client, room, objects);
|
||||||
|
|
||||||
|
if (client == null) return;
|
||||||
|
RoomUnit unit = client.getHabbo().getRoomUnit();
|
||||||
|
if (RoomLayout.tilesAdjecent(unit.getCurrentLocation(), room.getLayout().getTile(this.getX(), this.getY()))) {
|
||||||
|
// Long shot when clicking the ball
|
||||||
|
this.kick(room, unit, 55);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void kick(Room room, RoomUnit kicker, int momentum) {
|
||||||
if (this.currentThread != null) {
|
if (this.currentThread != null) {
|
||||||
this.currentThread.dead = true;
|
this.currentThread.dead = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean hasPath = !roomUnit.getPath().isEmpty();
|
Direction8 direction = Direction8.getDirection(kicker.getBodyRotation().getValue());
|
||||||
this.currentThread = new RebugKickBallAction(this, room, roomUnit, hasPath);
|
this.currentThread = new RebugKickBallAction(this, room, direction, momentum);
|
||||||
Emulator.getThreading().run(this.currentThread, 50);
|
Emulator.getThreading().run(this.currentThread, 50);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,38 +4,31 @@ import com.eu.habbo.Emulator;
|
|||||||
import com.eu.habbo.habbohotel.rooms.Room;
|
import com.eu.habbo.habbohotel.rooms.Room;
|
||||||
import com.eu.habbo.habbohotel.rooms.RoomTile;
|
import com.eu.habbo.habbohotel.rooms.RoomTile;
|
||||||
import com.eu.habbo.habbohotel.rooms.RoomTileState;
|
import com.eu.habbo.habbohotel.rooms.RoomTileState;
|
||||||
import com.eu.habbo.habbohotel.rooms.RoomUnit;
|
|
||||||
import com.eu.habbo.habbohotel.users.HabboItem;
|
import com.eu.habbo.habbohotel.users.HabboItem;
|
||||||
import com.eu.habbo.messages.outgoing.rooms.items.FloorItemOnRollerComposer;
|
import com.eu.habbo.messages.outgoing.rooms.items.FloorItemOnRollerComposer;
|
||||||
import com.eu.habbo.util.pathfinding.Direction8;
|
import com.eu.habbo.util.pathfinding.Direction8;
|
||||||
import gnu.trove.set.hash.THashSet;
|
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 {
|
public class RebugKickBallAction implements Runnable {
|
||||||
|
|
||||||
private final HabboItem ball;
|
private final HabboItem ball;
|
||||||
private final Room room;
|
private final Room room;
|
||||||
private Direction8 direction;
|
private Direction8 direction;
|
||||||
private int momentum;
|
private int momentum;
|
||||||
|
private boolean isDribble;
|
||||||
public boolean dead = false;
|
public boolean dead = false;
|
||||||
|
|
||||||
public RebugKickBallAction(HabboItem ball, Room room, RoomUnit kicker, boolean hasPath) {
|
public RebugKickBallAction(HabboItem ball, Room room, Direction8 direction, int momentum) {
|
||||||
this.ball = ball;
|
this.ball = ball;
|
||||||
this.room = room;
|
this.room = room;
|
||||||
this.direction = Direction8.fromDelta(
|
this.direction = direction;
|
||||||
ball.getX() - kicker.getX(),
|
this.momentum = momentum;
|
||||||
ball.getY() - kicker.getY()
|
this.isDribble = (momentum == 0);
|
||||||
);
|
|
||||||
this.momentum = hasPath ? 55 : 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isTileBlocked(int x, int y) {
|
private boolean isTileBlocked(int x, int y) {
|
||||||
RoomTile tile = this.room.getLayout().getTile((short) x, (short) y);
|
RoomTile tile = this.room.getLayout().getTile((short) x, (short) y);
|
||||||
if (tile == null) return true;
|
if (tile == null) return true;
|
||||||
if (tile.hasUnits()) return true;
|
|
||||||
return tile.getState() != RoomTileState.OPEN;
|
return tile.getState() != RoomTileState.OPEN;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -65,10 +58,16 @@ public class RebugKickBallAction implements Runnable {
|
|||||||
this.ball.setZ(nextTile.getStackHeight());
|
this.ball.setZ(nextTile.getStackHeight());
|
||||||
this.ball.needsUpdate(true);
|
this.ball.needsUpdate(true);
|
||||||
|
|
||||||
// Schedule next movement based on momentum
|
// Schedule next movement
|
||||||
|
if (!this.isDribble) {
|
||||||
long delay = getDelayForMomentum(this.momentum);
|
long delay = getDelayForMomentum(this.momentum);
|
||||||
if (delay > 0) {
|
if (delay > 0) {
|
||||||
Emulator.getThreading().run(this, delay);
|
Emulator.getThreading().run(this, delay);
|
||||||
|
} else {
|
||||||
|
this.dead = true;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
this.dead = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update tiles
|
// Update tiles
|
||||||
|
|||||||
Reference in New Issue
Block a user