public void tryFillInExtraneousExternal(WorldMap.CrossExit EX, Exit ox, Room linkFrom) { if (EX == null) return; Room linkTo = CMLib.map().getRoom(EX.destRoomID); if ((linkTo != null) && (linkTo.getGridParent() != null)) linkTo = linkTo.getGridParent(); if ((linkTo != null) && (linkFrom.rawDoors()[EX.dir] != linkTo)) { if (ox == null) ox = CMClass.getExit("Open"); linkFrom.rawDoors()[EX.dir] = linkTo; linkFrom.setRawExit(EX.dir, ox); } }
protected void linkRoom(Room room, Room loc, int dirCode, Exit o, Exit ao) { if (loc == null) return; if (room == null) return; int opCode = Directions.getOpDirectionCode(dirCode); if (room.rawDoors()[dirCode] != null) { if (room.rawDoors()[dirCode].getGridParent() == null) return; if (room.rawDoors()[dirCode].getGridParent().isMyGridChild(room.rawDoors()[dirCode])) return; room.rawDoors()[dirCode] = null; } if (o == null) o = CMClass.getExit("Open"); room.rawDoors()[dirCode] = alternativeLink(room, loc, dirCode); room.setRawExit(dirCode, o); if (loc.rawDoors()[opCode] != null) { if (loc.rawDoors()[opCode].getGridParent() == null) return; if (loc.rawDoors()[opCode].getGridParent().isMyGridChild(loc.rawDoors()[opCode])) return; loc.rawDoors()[opCode] = null; } if (ao == null) ao = CMClass.getExit("Open"); loc.rawDoors()[opCode] = alternativeLink(loc, room, opCode); loc.setRawExit(opCode, ao); }
protected void halfLink(Room room, Room loc, int dirCode, Exit o) { if (room == null) return; if (loc == null) return; if (room.rawDoors()[dirCode] != null) { if (room.rawDoors()[dirCode].getGridParent() == null) return; if (room.rawDoors()[dirCode].getGridParent().isMyGridChild(room.rawDoors()[dirCode])) return; room.rawDoors()[dirCode] = null; } if (o == null) o = CMClass.getExit("Open"); room.rawDoors()[dirCode] = alternativeLink(room, loc, dirCode); room.setRawExit(dirCode, o); }
@Override protected void fillExitsOfGridRoom(Room R, int x, int y) { super.fillExitsOfGridRoom(R, x, y); if ((x < 0) || (y < 0) || (y >= yGridSize()) || (x >= xGridSize())) return; // the adjacent rooms created by this method should also take // into account the possibility that they are on the edge. // it does NOT if (ox == null) ox = CMClass.getExit("Open"); Room R2 = null; if ((y == 0) && (R.rawDoors()[Directions.NORTH] == null)) { R2 = getMakeSingleGridRoom(x, yGridSize() / 2); if (R2 != null) linkRoom(R, R2, Directions.NORTH, ox, ox); } else if ((y == yGridSize() - 1) && (R.rawDoors()[Directions.SOUTH] == null)) { R2 = getMakeSingleGridRoom(x, yGridSize() / 2); if (R2 != null) linkRoom(R, R2, Directions.SOUTH, ox, ox); } if ((x == 0) && (R.rawDoors()[Directions.WEST] == null)) { R2 = getMakeSingleGridRoom(xGridSize() / 2, y); if (R2 != null) linkRoom(R, R2, Directions.WEST, ox, ox); } else if ((x == xGridSize() - 1) && (R.rawDoors()[Directions.EAST] == null)) { R2 = getMakeSingleGridRoom(xGridSize() / 2, y); if (R2 != null) linkRoom(R, R2, Directions.EAST, ox, ox); } if (Directions.NORTHEAST < Directions.NUM_DIRECTIONS()) { if (((x == 0) || (y == 0)) && (R.rawDoors()[Directions.NORTHWEST] == null)) { R2 = getMakeSingleGridRoom(xGridSize() / 2, yGridSize() / 2); if (R2 != null) linkRoom(R, R2, Directions.NORTHWEST, ox, ox); } else if (((x == xGridSize() - 1) || (y == yGridSize() - 1)) && (R.rawDoors()[Directions.SOUTHEAST] == null)) { R2 = getMakeSingleGridRoom(xGridSize() / 2, yGridSize() / 2); if (R2 != null) linkRoom(R, R2, Directions.SOUTHEAST, ox, ox); } if (((x == xGridSize() - 1) || (y == 0)) && (R.rawDoors()[Directions.NORTHEAST] == null)) { R2 = getMakeSingleGridRoom(xGridSize() / 2, yGridSize() / 2); if (R2 != null) linkRoom(R, R2, Directions.NORTHEAST, ox, ox); } else if (((x == 0) || (y == yGridSize() - 1)) && (R.rawDoors()[Directions.SOUTHWEST] == null)) { R2 = getMakeSingleGridRoom(xGridSize() / 2, yGridSize() / 2); if (R2 != null) linkRoom(R, R2, Directions.SOUTHWEST, ox, ox); } } }
protected void fillExitsOfGridRoom(Room R, int x, int y) { if ((x < 0) || (y < 0) || (y >= yGridSize()) || (x >= xGridSize())) return; synchronized (R.baseEnvStats()) { int mask = R.baseEnvStats().sensesMask(); if (CMath.bset(mask, EnvStats.SENSE_ROOMGRIDSYNC)) return; R.baseEnvStats().setSensesMask(mask | EnvStats.SENSE_ROOMGRIDSYNC); } // the adjacent rooms created by this method should also take // into account the possibility that they are on the edge. // it does NOT if (ox == null) ox = CMClass.getExit("Open"); Room R2 = null; if (y > 0) { R2 = getMakeSingleGridRoom(x, y - 1); if (R2 != null) linkRoom(R, R2, Directions.NORTH, ox, ox); } else if ((rawDoors()[Directions.NORTH] != null) && (exits[Directions.NORTH] != null)) linkRoom( R, rawDoors()[Directions.NORTH], Directions.NORTH, exits[Directions.NORTH], exits[Directions.NORTH]); if (x > 0) { R2 = getMakeSingleGridRoom(x - 1, y); if (R2 != null) linkRoom(R, R2, Directions.WEST, ox, ox); } else if ((rawDoors()[Directions.WEST] != null) && (exits[Directions.WEST] != null)) linkRoom( R, rawDoors()[Directions.WEST], Directions.WEST, exits[Directions.WEST], exits[Directions.WEST]); if (y < (yGridSize() - 1)) { R2 = getMakeSingleGridRoom(x, y + 1); if (R2 != null) linkRoom(R, R2, Directions.SOUTH, ox, ox); } else if ((rawDoors()[Directions.SOUTH] != null) && (exits[Directions.SOUTH] != null)) linkRoom( R, rawDoors()[Directions.SOUTH], Directions.SOUTH, exits[Directions.SOUTH], exits[Directions.SOUTH]); if (x < (xGridSize() - 1)) { R2 = getMakeSingleGridRoom(x + 1, y); if (R2 != null) linkRoom(R, R2, Directions.EAST, ox, ox); } else if ((rawDoors()[Directions.EAST] != null) && (exits[Directions.EAST] != null)) linkRoom( R, rawDoors()[Directions.EAST], Directions.EAST, exits[Directions.EAST], exits[Directions.EAST]); if (Directions.NORTHEAST < Directions.NUM_DIRECTIONS()) { if ((y > 0) && (x > 0)) { R2 = getMakeSingleGridRoom(x - 1, y - 1); if (R2 != null) linkRoom(R, R2, Directions.NORTHWEST, ox, ox); } else if ((rawDoors()[Directions.NORTHWEST] != null) && (exits[Directions.NORTHWEST] != null)) linkRoom( R, rawDoors()[Directions.NORTHWEST], Directions.NORTHWEST, exits[Directions.NORTHWEST], exits[Directions.NORTHWEST]); if ((x > 0) && (y < (yGridSize() - 1))) { R2 = getMakeSingleGridRoom(x - 1, y + 1); if (R2 != null) linkRoom(R, R2, Directions.SOUTHWEST, ox, ox); } else if ((rawDoors()[Directions.SOUTHWEST] != null) && (exits[Directions.SOUTHWEST] != null)) linkRoom( R, rawDoors()[Directions.SOUTHWEST], Directions.SOUTHWEST, exits[Directions.SOUTHWEST], exits[Directions.SOUTHWEST]); if ((x < (xGridSize() - 1)) && (y > 0)) { R2 = getMakeSingleGridRoom(x + 1, y - 1); if (R2 != null) linkRoom(R, R2, Directions.NORTHEAST, ox, ox); } else if ((rawDoors()[Directions.NORTHEAST] != null) && (exits[Directions.NORTHEAST] != null)) linkRoom( R, rawDoors()[Directions.NORTHEAST], Directions.NORTHEAST, exits[Directions.NORTHEAST], exits[Directions.NORTHEAST]); if ((x < (xGridSize() - 1)) && (y < (yGridSize() - 1))) { R2 = getMakeSingleGridRoom(x + 1, y + 1); if (R2 != null) linkRoom(R, R2, Directions.SOUTHEAST, ox, ox); } else if ((rawDoors()[Directions.SOUTHEAST] != null) && (exits[Directions.SOUTHEAST] != null)) linkRoom( R, rawDoors()[Directions.SOUTHEAST], Directions.SOUTHEAST, exits[Directions.SOUTHEAST], exits[Directions.SOUTHEAST]); } for (int d = 0; d < gridexits.size(); d++) { WorldMap.CrossExit EX = (WorldMap.CrossExit) gridexits.elementAt(d); try { if ((EX.out) && (EX.x == x) && (EX.y == y)) switch (EX.dir) { case Directions.NORTH: if (EX.y == 0) tryFillInExtraneousExternal(EX, ox, R); break; case Directions.SOUTH: if (EX.y == yGridSize() - 1) tryFillInExtraneousExternal(EX, ox, R); break; case Directions.EAST: if (EX.x == xGridSize() - 1) tryFillInExtraneousExternal(EX, ox, R); break; case Directions.WEST: if (EX.x == 0) tryFillInExtraneousExternal(EX, ox, R); break; case Directions.NORTHEAST: if ((EX.y == 0) && (EX.x == xGridSize() - 1)) tryFillInExtraneousExternal(EX, ox, R); break; case Directions.SOUTHWEST: if ((EX.y == yGridSize() - 1) && (EX.x == 0)) tryFillInExtraneousExternal(EX, ox, R); break; case Directions.NORTHWEST: if ((EX.y == 0) && (EX.x == 0)) tryFillInExtraneousExternal(EX, ox, R); break; case Directions.SOUTHEAST: if ((EX.y == yGridSize() - 1) && (EX.x == xGridSize() - 1)) tryFillInExtraneousExternal(EX, ox, R); break; } } catch (Exception e) { } } R.baseEnvStats() .setSensesMask(CMath.unsetb(R.baseEnvStats().sensesMask(), EnvStats.SENSE_ROOMGRIDSYNC)); }
public boolean invoke( MOB mob, Vector commands, Environmental givenTarget, boolean auto, int asLevel) { if ((auto || mob.isMonster()) && (commands.size() == 0)) commands.addElement(CMLib.map().getRandomRoom().displayText()); if (commands.size() < 1) { mob.tell("Pray for a gateway to where?"); return false; } if ((mob.location().getRoomInDir(Directions.GATE) != null) || (mob.location().getExitInDir(Directions.GATE) != null)) { mob.tell("A gateway cannot be created here."); return false; } String areaName = CMParms.combine(commands, 0).trim().toUpperCase(); oldRoom = null; newRoom = null; try { Vector rooms = CMLib.map().findRooms(CMLib.map().rooms(), mob, areaName, true, 10); if (rooms.size() > 0) newRoom = (Room) rooms.elementAt(CMLib.dice().roll(1, rooms.size(), -1)); } catch (NoSuchElementException e) { } if (newRoom == null) { mob.tell("You don't know of an place called '" + CMParms.combine(commands, 0) + "'."); return false; } int profNeg = 0; for (int i = 0; i < newRoom.numInhabitants(); i++) { MOB t = newRoom.fetchInhabitant(i); if (t != null) { int adjustment = t.envStats().level() - (mob.envStats().level() + (2 * super.getXLEVELLevel(mob))); if (t.isMonster()) adjustment = adjustment * 3; profNeg += adjustment; } } profNeg += newRoom.numItems() * 20; if (!super.invoke(mob, commands, givenTarget, auto, asLevel)) return false; boolean success = proficiencyCheck(mob, -profNeg, auto); if ((success) && ((newRoom.getRoomInDir(Directions.GATE) == null) && (newRoom.getExitInDir(Directions.GATE) == null))) { CMMsg msg = CMClass.getMsg( mob, mob.location(), this, verbalCastCode(mob, mob.location(), auto), "^S<S-NAME> " + prayWord(mob) + " for a blinding, divine gateway here.^?"); CMMsg msg2 = CMClass.getMsg( mob, newRoom, this, verbalCastCode(mob, newRoom, auto), "A blinding, divine gateway appears here."); if ((mob.location().okMessage(mob, msg)) && (newRoom.okMessage(mob, msg2))) { mob.location().send(mob, msg); newRoom.send(mob, msg2); Exit e = CMClass.getExit("GenExit"); e.setDescription("A divine gateway to somewhere"); e.setDisplayText("A divine gateway to somewhere"); e.setDoorsNLocks(false, true, false, false, false, false); e.setExitParams("gateway", "close", "open", "closed."); e.setName("a divine gateway"); mob.location().rawDoors()[Directions.GATE] = newRoom; newRoom.rawDoors()[Directions.GATE] = mob.location(); mob.location().setRawExit(Directions.GATE, e); newRoom.setRawExit(Directions.GATE, e); oldRoom = mob.location(); beneficialAffect(mob, e, asLevel, 5); } } else beneficialWordsFizzle( mob, null, "<S-NAME> " + prayWord(mob) + " for a gateway, but nothing happens."); // return whether it worked return success; }