mirror of
https://git.krews.org/morningstar/Arcturus-Community.git
synced 2025-01-18 23:46:28 +01:00
Random Banzai teleporter fixed #853
This commit is contained in:
parent
3a595ee4bc
commit
9b25c37525
@ -55,18 +55,18 @@ public class InteractionBattleBanzaiTeleporter extends HabboItem {
|
||||
@Override
|
||||
public void onWalkOn(RoomUnit roomUnit, Room room, Object[] objects) throws Exception {
|
||||
super.onWalkOn(roomUnit, room, objects);
|
||||
HabboItem target = room.getRoomSpecialTypes().getRandomTeleporter(this.getBaseItem(), this);
|
||||
|
||||
if (target == null) return;
|
||||
if(objects.length < 3) {
|
||||
HabboItem target = room.getRoomSpecialTypes().getRandomTeleporter(this.getBaseItem(), this);
|
||||
if (target == null) return;
|
||||
|
||||
this.setExtradata("1");
|
||||
roomUnit.removeStatus(RoomUnitStatus.MOVE);
|
||||
target.setExtradata("1");
|
||||
room.updateItem(this);
|
||||
room.updateItem(target);
|
||||
roomUnit.setGoalLocation(room.getLayout().getTile(roomUnit.getX(), roomUnit.getY()));
|
||||
roomUnit.setCanWalk(false);
|
||||
Emulator.getThreading().run(new BanzaiRandomTeleport(this, target, roomUnit, room), 1000);
|
||||
this.setExtradata("1");
|
||||
room.updateItemState(this);
|
||||
roomUnit.removeStatus(RoomUnitStatus.MOVE);
|
||||
roomUnit.setGoalLocation(roomUnit.getCurrentLocation());
|
||||
roomUnit.setCanWalk(false);
|
||||
Emulator.getThreading().run(new BanzaiRandomTeleport(this, target, roomUnit, room), 500);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -2971,7 +2971,7 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
|
||||
this.teleportRoomUnitToLocation(roomUnit, x, y, 0.0);
|
||||
}
|
||||
|
||||
void teleportRoomUnitToLocation(RoomUnit roomUnit, short x, short y, double z) {
|
||||
public void teleportRoomUnitToLocation(RoomUnit roomUnit, short x, short y, double z) {
|
||||
if (this.loaded) {
|
||||
RoomTile tile = this.layout.getTile(x, y);
|
||||
|
||||
|
@ -2,9 +2,11 @@ package com.eu.habbo.threading.runnables;
|
||||
|
||||
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.RoomUnit;
|
||||
import com.eu.habbo.habbohotel.rooms.RoomUserRotation;
|
||||
import com.eu.habbo.habbohotel.users.HabboItem;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class BanzaiRandomTeleport implements Runnable {
|
||||
private final HabboItem item;
|
||||
@ -21,12 +23,52 @@ public class BanzaiRandomTeleport implements Runnable {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
this.habbo.setCanWalk(true);
|
||||
this.item.setExtradata("0");
|
||||
this.toItem.setExtradata("0");
|
||||
this.room.updateItem(this.item);
|
||||
this.room.updateItem(this.toItem);
|
||||
this.habbo.setRotation(RoomUserRotation.fromValue(Emulator.getRandom().nextInt(8)));
|
||||
this.room.teleportRoomUnitToItem(this.habbo, this.toItem);
|
||||
HabboItem topItemNow = this.room.getTopItemAt(this.habbo.getX(), this.habbo.getY());
|
||||
RoomTile lastLocation = this.habbo.getCurrentLocation();
|
||||
RoomTile newLocation = this.room.getLayout().getTile(toItem.getX(), toItem.getY());
|
||||
|
||||
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(() -> {
|
||||
if (this.item.getExtradata().equals("1")) {
|
||||
this.item.setExtradata("0");
|
||||
this.room.updateItemState(this.item);
|
||||
}
|
||||
}, 500);
|
||||
|
||||
if(!this.toItem.getExtradata().equals("1")) {
|
||||
this.toItem.setExtradata("1");
|
||||
this.room.updateItemState(this.toItem);
|
||||
}
|
||||
|
||||
Emulator.getThreading().run(() -> {
|
||||
this.habbo.setCanWalk(true);
|
||||
HabboItem topItemNext = this.room.getTopItemAt(this.habbo.getX(), this.habbo.getY());
|
||||
|
||||
if(topItemNext != null) {
|
||||
try {
|
||||
topItemNext.onWalkOn(this.habbo, this.room, new Object[] { lastLocation, newLocation, this });
|
||||
} catch (Exception e) {
|
||||
LoggerFactory.getLogger(BanzaiRandomTeleport.class).error("BanzaiRandomTeleport exception", e);
|
||||
}
|
||||
}
|
||||
|
||||
if (this.toItem.getExtradata().equals("1")) {
|
||||
this.toItem.setExtradata("0");
|
||||
this.room.updateItemState(this.toItem);
|
||||
}
|
||||
}, 750);
|
||||
|
||||
Emulator.getThreading().run(() -> {
|
||||
this.habbo.setRotation(RoomUserRotation.fromValue(Emulator.getRandom().nextInt(8)));
|
||||
this.room.teleportRoomUnitToLocation(this.habbo, newLocation.x, newLocation.y, newLocation.getStackHeight());
|
||||
}, 250);
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -36,8 +36,9 @@ public class RoomUnitTeleport implements Runnable {
|
||||
public void run() {
|
||||
if (roomUnit == null || roomUnit.getRoom() == null || room.getLayout() == null || roomUnit.isLeavingTeleporter)
|
||||
return;
|
||||
|
||||
RoomTile t = this.room.getLayout().getTile((short) this.x, (short) this.y);
|
||||
|
||||
RoomTile lastLocation = this.roomUnit.getCurrentLocation();
|
||||
RoomTile newLocation = this.room.getLayout().getTile((short) this.x, (short) this.y);
|
||||
|
||||
HabboItem topItem = this.room.getTopItemAt(this.roomUnit.getCurrentLocation().x, this.roomUnit.getCurrentLocation().y);
|
||||
if (topItem != null) {
|
||||
@ -48,23 +49,23 @@ public class RoomUnitTeleport implements Runnable {
|
||||
}
|
||||
}
|
||||
this.roomUnit.setPath(new LinkedList<>());
|
||||
this.roomUnit.setCurrentLocation(t);
|
||||
this.roomUnit.setPreviousLocation(t);
|
||||
this.roomUnit.setCurrentLocation(newLocation);
|
||||
this.roomUnit.setPreviousLocation(newLocation);
|
||||
this.roomUnit.setZ(this.z);
|
||||
this.roomUnit.setPreviousLocationZ(this.z);
|
||||
this.roomUnit.removeStatus(RoomUnitStatus.MOVE);
|
||||
ServerMessage teleportMessage = new RoomUnitOnRollerComposer(this.roomUnit, t, this.room).compose();
|
||||
this.roomUnit.setLocation(t);
|
||||
ServerMessage teleportMessage = new RoomUnitOnRollerComposer(this.roomUnit, newLocation, this.room).compose();
|
||||
this.roomUnit.setLocation(newLocation);
|
||||
this.room.sendComposer(teleportMessage);
|
||||
roomUnit.isWiredTeleporting = false;
|
||||
|
||||
this.room.updateHabbosAt(t.x, t.y);
|
||||
this.room.updateBotsAt(t.x, t.y);
|
||||
this.room.updateHabbosAt(newLocation.x, newLocation.y);
|
||||
this.room.updateBotsAt(newLocation.x, newLocation.y);
|
||||
|
||||
topItem = room.getTopItemAt(x, y);
|
||||
if (topItem != null && roomUnit.getCurrentLocation().equals(room.getLayout().getTile((short) x, (short) y))) {
|
||||
try {
|
||||
topItem.onWalkOn(roomUnit, room, new Object[]{});
|
||||
topItem.onWalkOn(roomUnit, room, new Object[]{ lastLocation, newLocation, this });
|
||||
} catch (Exception e) {
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user