mirror of
https://git.krews.org/morningstar/Arcturus-Community.git
synced 2025-01-19 07:56:26 +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
|
@Override
|
||||||
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);
|
||||||
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");
|
this.setExtradata("1");
|
||||||
roomUnit.removeStatus(RoomUnitStatus.MOVE);
|
room.updateItemState(this);
|
||||||
target.setExtradata("1");
|
roomUnit.removeStatus(RoomUnitStatus.MOVE);
|
||||||
room.updateItem(this);
|
roomUnit.setGoalLocation(roomUnit.getCurrentLocation());
|
||||||
room.updateItem(target);
|
roomUnit.setCanWalk(false);
|
||||||
roomUnit.setGoalLocation(room.getLayout().getTile(roomUnit.getX(), roomUnit.getY()));
|
Emulator.getThreading().run(new BanzaiRandomTeleport(this, target, roomUnit, room), 500);
|
||||||
roomUnit.setCanWalk(false);
|
}
|
||||||
Emulator.getThreading().run(new BanzaiRandomTeleport(this, target, roomUnit, room), 1000);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -2971,7 +2971,7 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
|
|||||||
this.teleportRoomUnitToLocation(roomUnit, x, y, 0.0);
|
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) {
|
if (this.loaded) {
|
||||||
RoomTile tile = this.layout.getTile(x, y);
|
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.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.RoomUnit;
|
import com.eu.habbo.habbohotel.rooms.RoomUnit;
|
||||||
import com.eu.habbo.habbohotel.rooms.RoomUserRotation;
|
import com.eu.habbo.habbohotel.rooms.RoomUserRotation;
|
||||||
import com.eu.habbo.habbohotel.users.HabboItem;
|
import com.eu.habbo.habbohotel.users.HabboItem;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
public class BanzaiRandomTeleport implements Runnable {
|
public class BanzaiRandomTeleport implements Runnable {
|
||||||
private final HabboItem item;
|
private final HabboItem item;
|
||||||
@ -21,12 +23,52 @@ public class BanzaiRandomTeleport implements Runnable {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
this.habbo.setCanWalk(true);
|
HabboItem topItemNow = this.room.getTopItemAt(this.habbo.getX(), this.habbo.getY());
|
||||||
this.item.setExtradata("0");
|
RoomTile lastLocation = this.habbo.getCurrentLocation();
|
||||||
this.toItem.setExtradata("0");
|
RoomTile newLocation = this.room.getLayout().getTile(toItem.getX(), toItem.getY());
|
||||||
this.room.updateItem(this.item);
|
|
||||||
this.room.updateItem(this.toItem);
|
if(topItemNow != null) {
|
||||||
this.habbo.setRotation(RoomUserRotation.fromValue(Emulator.getRandom().nextInt(8)));
|
try {
|
||||||
this.room.teleportRoomUnitToItem(this.habbo, this.toItem);
|
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);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -37,7 +37,8 @@ public class RoomUnitTeleport implements Runnable {
|
|||||||
if (roomUnit == null || roomUnit.getRoom() == null || room.getLayout() == null || roomUnit.isLeavingTeleporter)
|
if (roomUnit == null || roomUnit.getRoom() == null || room.getLayout() == null || roomUnit.isLeavingTeleporter)
|
||||||
return;
|
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);
|
HabboItem topItem = this.room.getTopItemAt(this.roomUnit.getCurrentLocation().x, this.roomUnit.getCurrentLocation().y);
|
||||||
if (topItem != null) {
|
if (topItem != null) {
|
||||||
@ -48,23 +49,23 @@ public class RoomUnitTeleport implements Runnable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.roomUnit.setPath(new LinkedList<>());
|
this.roomUnit.setPath(new LinkedList<>());
|
||||||
this.roomUnit.setCurrentLocation(t);
|
this.roomUnit.setCurrentLocation(newLocation);
|
||||||
this.roomUnit.setPreviousLocation(t);
|
this.roomUnit.setPreviousLocation(newLocation);
|
||||||
this.roomUnit.setZ(this.z);
|
this.roomUnit.setZ(this.z);
|
||||||
this.roomUnit.setPreviousLocationZ(this.z);
|
this.roomUnit.setPreviousLocationZ(this.z);
|
||||||
this.roomUnit.removeStatus(RoomUnitStatus.MOVE);
|
this.roomUnit.removeStatus(RoomUnitStatus.MOVE);
|
||||||
ServerMessage teleportMessage = new RoomUnitOnRollerComposer(this.roomUnit, t, this.room).compose();
|
ServerMessage teleportMessage = new RoomUnitOnRollerComposer(this.roomUnit, newLocation, this.room).compose();
|
||||||
this.roomUnit.setLocation(t);
|
this.roomUnit.setLocation(newLocation);
|
||||||
this.room.sendComposer(teleportMessage);
|
this.room.sendComposer(teleportMessage);
|
||||||
roomUnit.isWiredTeleporting = false;
|
roomUnit.isWiredTeleporting = false;
|
||||||
|
|
||||||
this.room.updateHabbosAt(t.x, t.y);
|
this.room.updateHabbosAt(newLocation.x, newLocation.y);
|
||||||
this.room.updateBotsAt(t.x, t.y);
|
this.room.updateBotsAt(newLocation.x, newLocation.y);
|
||||||
|
|
||||||
topItem = room.getTopItemAt(x, y);
|
topItem = room.getTopItemAt(x, y);
|
||||||
if (topItem != null && roomUnit.getCurrentLocation().equals(room.getLayout().getTile((short) x, (short) y))) {
|
if (topItem != null && roomUnit.getCurrentLocation().equals(room.getLayout().getTile((short) x, (short) y))) {
|
||||||
try {
|
try {
|
||||||
topItem.onWalkOn(roomUnit, room, new Object[]{});
|
topItem.onWalkOn(roomUnit, room, new Object[]{ lastLocation, newLocation, this });
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user