Fixed removal of POH 1st floor and dungeon rooms

This commit is contained in:
oftheshire
2026-04-19 10:11:48 +00:00
committed by Ryan
parent d67fb26749
commit 5a76a71d21
2 changed files with 67 additions and 15 deletions
@@ -53,10 +53,23 @@ public final class RemovalDialogue extends DialoguePlugin {
@Override @Override
public boolean open(Object... args) { public boolean open(Object... args) {
pos = (int[]) args[1]; pos = (int[]) args[1];
if (args.length > 2 && args[2] instanceof Integer) {
plane = (Integer) args[2];
} else {
plane = player.getLocation().getZ(); plane = player.getLocation().getZ();
if (HouseManager.isInDungeon(player)) { if (HouseManager.isInDungeon(player)) {
plane = 3; plane = 3;
} }
}
// check if room exists
room = player.getHouseManager().getRooms()[plane][pos[0]][pos[1]];
if (room == null || room.getProperties().isRoof()) {
interpreter.sendPlainMessage(false, "There is no room there to remove.");
return false;
}
room = player.getHouseManager().getRooms()[plane][pos[0]][pos[1]]; room = player.getHouseManager().getRooms()[plane][pos[0]][pos[1]];
player.getDialogueInterpreter().sendOptions("Remove the " + (room != null ? room.getProperties().getName() : "room") + "?", "Yes", "No"); player.getDialogueInterpreter().sendOptions("Remove the " + (room != null ? room.getProperties().getName() : "room") + "?", "Yes", "No");
stage = 0; stage = 0;
@@ -29,15 +29,19 @@ public final class StaircasePlugin extends OptionHandler {
public Plugin<Object> newInstance(Object arg) throws Throwable { public Plugin<Object> newInstance(Object arg) throws Throwable {
ClassScanner.definePlugin(new BuildDialogue()); ClassScanner.definePlugin(new BuildDialogue());
ClassScanner.definePlugin(new ClimbPohLadder()); ClassScanner.definePlugin(new ClimbPohLadder());
for (int i = 13497; i < 13507; i++) { // 13497 - 13502 are normal stairs
// 13503 - 13506 are spiral stairs
for (int i = 13497; i <= 13506; i++) {
SceneryDefinition.forId(i).getHandlers().put("option:climb", this); SceneryDefinition.forId(i).getHandlers().put("option:climb", this);
SceneryDefinition.forId(i).getHandlers().put("option:climb-up", this); SceneryDefinition.forId(i).getHandlers().put("option:climb-up", this);
SceneryDefinition.forId(i).getHandlers().put("option:climb-down", this); SceneryDefinition.forId(i).getHandlers().put("option:climb-down", this);
SceneryDefinition.forId(i).getHandlers().put("option:remove-room", this); SceneryDefinition.forId(i).getHandlers().put("option:remove-room", this);
} }
// 13409 is dungeon entrance
SceneryDefinition.forId(13409).getHandlers().put("option:enter", this); SceneryDefinition.forId(13409).getHandlers().put("option:enter", this);
SceneryDefinition.forId(13409).getHandlers().put("option:remove-room", this); SceneryDefinition.forId(13409).getHandlers().put("option:remove-room", this);
for (int id = 13328; id < 13331; id++) { // 13328 - 13330 are dungeon ladders
for (int id = 13328; id <= 13330; id++) {
SceneryDefinition.forId(id).getHandlers().put("option:climb", this); SceneryDefinition.forId(id).getHandlers().put("option:climb", this);
SceneryDefinition.forId(id).getHandlers().put("option:remove-room", this); SceneryDefinition.forId(id).getHandlers().put("option:remove-room", this);
} }
@@ -69,13 +73,47 @@ public final class StaircasePlugin extends OptionHandler {
SceneryBuilder.replace(object, object.transform(object.getId() - 3)); SceneryBuilder.replace(object, object.transform(object.getId() - 3));
return true; return true;
case "remove-room": case "remove-room":
if (player.getLocation().getZ() != 0) {
player.getPacketDispatch().sendMessage("The room below is supporting this room!"); int currentZ = player.getLocation().getZ();
int chunkX = player.getLocation().getChunkX();
int chunkY = player.getLocation().getChunkY();
// must be in building mode
if(!player.getHouseManager().isBuildingMode()) {
player.getPacketDispatch().sendMessage("You can only do this in building mode.");
return true; return true;
} }
return false;
// if you're in the dungeon, try and remove the room at Z = 0 from the house region.
if (HouseManager.isInDungeon(player)) {
player.getDialogueInterpreter().open("con:remove", null, new int[]{chunkX, chunkY}, 0);
// From ground floor (z=0), stairs could lead to 1st floor (z=1) or the dungeon (z=3)
} else {
// garden dungeon entrance and oubliette ladders don't need a height selection
if(node.getId() == 13409 || node.getId() == 13675 || node.getId() == 13676 || node.getId() == 13677 || node.getId() == 13678 || node.getId() == 13679 || node.getId() == 13680) {
player.getDialogueInterpreter().open("con:remove", null, new int[]{chunkX, chunkY}, 3);
} else {
player.getDialogueInterpreter().sendOptions("Remove which room?", "Room Above", "Room Below", "Cancel");
player.getDialogueInterpreter().addAction((interId, btn) -> {
if (btn == 2) { // Above
player.getDialogueInterpreter().open("con:remove", null, new int[]{chunkX, chunkY}, currentZ + 1);
} else if (btn == 3) { // Below
if (currentZ - 1 == -1) {
player.getDialogueInterpreter().open("con:remove", null, new int[]{chunkX, chunkY}, 3);
} else {
player.getDialogueInterpreter().open("con:remove", null, new int[]{chunkX, chunkY}, currentZ - 1);
}
}
});
}
}
return true;
case "climb": case "climb":
if (house.getDungeonRegion() == player.getViewport().getRegion()) { if (HouseManager.isInDungeon(player)) {
climb(player, 1, house, object); climb(player, 1, house, object);
return true; return true;
} }
@@ -379,10 +417,11 @@ public final class StaircasePlugin extends OptionHandler {
for (Direction d : dirs) { for (Direction d : dirs) {
if (d == room.getRotation()) { if (d == room.getRotation()) {
r.setRotation(d); r.setRotation(d);
Hotspot stairs = room.getStairs(); // todo this just puts a default set of stairs in the dungeon. The below code works for skill/quest hall, but not a dungeon entrance.
int index = stairs != null ? stairs.getDecorationIndex() : -1; //Hotspot stairs = room.getStairs();
//int index = stairs != null ? stairs.getDecorationIndex() : -1;
BuildingUtils.buildRoom(player, r, plane, roomX, roomY, r.getExits(), true); BuildingUtils.buildRoom(player, r, plane, roomX, roomY, r.getExits(), true);
r.getStairs().setDecorationIndex(index); r.getStairs().setDecorationIndex(/*index*/1);
end(); end();
return true; return true;
} }