private void parseTriggerLine(String line) { if (line.startsWith(TRIGTOT_KEYWORD)) { _log.debug("Found the " + TRIGTOT_KEYWORD + " section"); return; } String data = line.substring(TRIG_KEYWORD.length()); String[] trigDataSplit = getData(data); int roomVnum = Integer.valueOf(trigDataSplit[0]); TriggerType triggerType = TriggerType.getTriggerType(Integer.valueOf(trigDataSplit[1])); if (triggerType.equals(TriggerType.Invalid)) { _log.info("Invalid trigger found -- " + trigDataSplit[1]); } Room room = _area.getEntry(roomVnum); if (room == null) { _log.info("Room " + roomVnum + " does not exist! Skipping"); return; } Trigger trigger = new DefaultTrigger(); trigger.setTriggerType(triggerType); trigger.setV2(Integer.valueOf(trigDataSplit[2])); trigger.setV3(Integer.valueOf(trigDataSplit[3])); trigger.setV4(Integer.valueOf(trigDataSplit[4])); trigger.setV5(Integer.valueOf(trigDataSplit[5])); trigger.setV6(Integer.valueOf(trigDataSplit[6])); trigger.setV7(Integer.valueOf(trigDataSplit[7])); room.getTriggers().add(trigger); }
private void parseDarknessLine(String line) { if (line.startsWith(DD1TOT_KEYWORD)) { _log.debug("Found the " + DD1TOT_KEYWORD + " section"); return; } String data = line.substring(DARKNESS_KEYWORD.length()); String[] roomDataSplit = getData(data); int start = new Integer(roomDataSplit[0]).intValue(); int end = new Integer(roomDataSplit[1]).intValue(); int darknessFlag = new Integer(roomDataSplit[2]).intValue(); for (int roomVnum = start; roomVnum <= end; roomVnum++) { Room room = getOrCreateRoom(roomVnum); int flags = room.getRoomFlags(); if (darknessFlag == 1) { flags += RoomFlags.PERM_DARK.getBit(); } else { flags += RoomFlags.DARK.getBit(); } room.setRoomFlags(flags); } }
private void parseExitLine(String line) { if (line.startsWith(EXITTOT_KEYWORD)) { _log.debug("Found the " + EXITTOT_KEYWORD + " section"); return; } String data = line.substring(EXIT_KEYWORD.length()); String[] split = data.split(" "); int roomVnum = new Integer(split[0]); Room room = getOrCreateRoom(roomVnum); String[] exitSplit = getData(data); for (int count = 0; count < exitSplit.length - 1; count++) { int exitRoomVnum = Integer.valueOf(exitSplit[count]); if (exitRoomVnum != 0) { ExitDirectionEnum exitDir = getExitDirectionEnum(count); room.addExit(new DefaultExit(exitDir, exitRoomVnum)); // If the destination room is negative, it must go to a town. Create the other end. if (exitRoomVnum < 0) { ExitDirectionEnum oppositeExitDir = GameUtil.getOppositeExit(exitDir); _townArea.getEntry(exitRoomVnum).addExit(new DefaultExit(oppositeExitDir, roomVnum)); } } } room.setDefaultDescription(Integer.valueOf(exitSplit[10]).intValue()); room.setAltDescription(Integer.valueOf(exitSplit[10]).intValue()); _area.getRoomMap().put(room.getRoomNumber(), room); }
private void fixTriggerV7(int roomVnum, int v7) { try { Room room = _area.getRoomMap().get(roomVnum); room.getTriggers().get(0).setV7(v7); } catch (Exception e) { _log.error("Error attempting to trigger V7 for room " + roomVnum); } }
private void fixDoorV4(int fromRoom, ExitDirectionEnum exitDirection, int v4) { try { Room room = _area.getRoomMap().get(fromRoom); Exit exit = room.getExit(exitDirection); exit.getDoor().setV4(v4); } catch (Exception e) { _log.error("Error attempting to hack door consumes value for room " + fromRoom); } }
private void fixTriggerDescription(int roomVnum, int v4, int v5) { try { Room room = _area.getRoomMap().get(roomVnum); Trigger trigger = room.getTriggers().get(0); trigger.setV4(v4); trigger.setV5(v5); } catch (Exception e) { _log.error("Error attempting to hack triggers description value for room " + roomVnum); } }
private void parseDoorLine(String line) { if (line.startsWith(DOORTOT_KEYWORD)) { _log.debug("Found the " + DOORTOT_KEYWORD + " section"); return; } String data = line.substring(DOOR_KEYWORD.length()); String[] doorDataSplit = getData(data); int fromRoom = Integer.valueOf(doorDataSplit[1]); int toRoom = Integer.valueOf(doorDataSplit[2]); Room room = _area.getEntry(fromRoom); if (room == null) { room = _townArea.getEntry(fromRoom); } Exit exit = room.getExit(toRoom); if (exit == null) { _log.info( "Exit from room " + room.getRoomNumber() + " to room " + toRoom + " does not exist! Skipping"); return; } int doorTypeInt = Integer.valueOf(doorDataSplit[0]).intValue(); Door door = new NullDoor(); if (doorTypeInt >= 0) { door = new ItemKeyDoor(); } else { DoorType doorType = DoorType.getDoorType(doorTypeInt); if (doorType.equals(DoorType.HAS_RUNE)) { door = new HasRuneDoor(); } else if (doorType.equals(DoorType.MINIMUM_RUNE)) { door = new MinimumRuneDoor(); } else if (doorType.equals(DoorType.PRIVATE_ROOM)) { door = new PrivateRoomDoor(); } else if (doorType.equals(DoorType.PUZZLE)) { door = new PuzzleDoor(); } else if (doorType.equals(DoorType.PROMOTE_DOOR)) { door = new PromoteDoor(); } } door.setV0(Integer.valueOf(doorDataSplit[0]).intValue()); door.setV3(Integer.valueOf(doorDataSplit[3]).intValue()); door.setV4(Integer.valueOf(doorDataSplit[4]).intValue()); door.setV5(Integer.valueOf(doorDataSplit[5]).intValue()); door.setV6(Integer.valueOf(doorDataSplit[6]).intValue()); exit.setDoor(door); }
private Room getOrCreateRoom(int vnum) { Room room = _area.getEntry(vnum); if (room == null) { room = new DefaultRoom(); room.setRoomNumber(vnum); _area.getRoomMap().put(vnum, room); } return room; }
private void fixDoorPuzzle(int roomVnum1, int roomVnum2) { try { Room room1 = _area.getRoomMap().get(roomVnum1); Exit exit1 = room1.getExit(ExitDirectionEnum.NORTH); Room room2 = _area.getRoomMap().get(roomVnum2); Exit exit2 = room2.getExit(ExitDirectionEnum.SOUTH); exit1.setDoor(exit2.getDoor()); exit2.setDoor(null); } catch (Exception e) { _log.error("Error attempting to hack door puzzle for room " + roomVnum1); } }
private void parseTerrainLine(String line) { if (line.startsWith(DD2TOT_KEYWORD)) { _log.debug("Found the " + DD2TOT_KEYWORD + " section"); return; } String data = line.substring(TERRAIN_KEYWORD.length()); String[] roomDataSplit = getData(data); int start = new Integer(roomDataSplit[0]).intValue(); int end = new Integer(roomDataSplit[1]).intValue(); for (int roomVnum = start; roomVnum <= end; roomVnum++) { Room room = getOrCreateRoom(roomVnum); Terrain terrain = Terrain.getTerrain(new Integer(roomDataSplit[2]).intValue()); room.setTerrain(terrain); } }
private void fixExits() { int roomVnum = 1605; int oldValue = 1712; int newValue = 1680; Room room = _area.getRoomMap().get(roomVnum); Exit exit = room.getExit(ExitDirectionEnum.UP); if (exit.getToRoom() == oldValue) { exit.setToRoom(newValue); } else { _log.error( "Room " + roomVnum + ". Expected to see " + oldValue + " but got " + exit.getToRoom() + "."); } }
private void parseLairLine(String line) { if (line.startsWith(LAIRTOT_KEYWORD)) { _log.debug("Found the " + LAIRTOT_KEYWORD + " section"); return; } String data = line.substring(TERRAIN_KEYWORD.length()); String[] lairDataSplit = getData(data); int roomVnum = Integer.valueOf(lairDataSplit[0]); int mob = Integer.valueOf(lairDataSplit[1]); int number = Integer.valueOf(lairDataSplit[2]); int item = Integer.valueOf(lairDataSplit[3]); Lair lair = new DefaultLair(mob, number, item); Room room = getOrCreateRoom(roomVnum); room.getLairs().add(lair); }