public boolean execute(MOB mob, Vector commands, int metaFlags) throws java.io.IOException { Environmental openThis = null; String dir = ""; int dirCode = -1; Environmental E = null; if (commands.size() > 1) { dirCode = Directions.getGoodDirectionCode((String) commands.lastElement()); if (dirCode >= 0) { if ((mob.location().getRoomInDir(dirCode) == null) || (mob.location().getExitInDir(dirCode) == null) || (!mob.location().getExitInDir(dirCode).isOpen())) { mob.tell("You can't pull anything that way."); return false; } E = mob.location().getRoomInDir(dirCode); dir = " " + (((mob.location() instanceof SpaceShip) || (mob.location().getArea() instanceof SpaceShip)) ? Directions.getShipDirectionName(dirCode) : Directions.getDirectionName(dirCode)); commands.removeElementAt(commands.size() - 1); } } if (dir.length() == 0) { dirCode = Directions.getGoodDirectionCode((String) commands.lastElement()); if (dirCode >= 0) openThis = mob.location().getExitInDir(dirCode); } String itemName = CMParms.combine(commands, 1); if (openThis == null) openThis = mob.location().fetchFromRoomFavorItems(null, itemName); if (openThis == null) openThis = mob.location().fetchFromMOBRoomFavorsItems(mob, null, itemName, Wearable.FILTER_ANY); if ((openThis == null) || (!CMLib.flags().canBeSeenBy(openThis, mob))) { mob.tell("You don't see '" + itemName + "' here."); return false; } CMMsg msg = CMClass.getMsg(mob, openThis, E, CMMsg.MSG_PULL, "<S-NAME> pull(s) <T-NAME>" + dir + "."); if (mob.location().okMessage(mob, msg)) { mob.location().send(mob, msg); if ((dir.length() > 0) && (msg.tool() instanceof Room)) { Room R = (Room) msg.tool(); dirCode = CMLib.tracking().findRoomDir(mob, R); if ((dirCode >= 0) && (CMLib.tracking().walk(mob, dirCode, false, false, false, false))) { if (openThis instanceof Item) R.moveItemTo( (Item) openThis, ItemPossessor.Expire.Player_Drop, ItemPossessor.Move.Followers); else if (openThis instanceof MOB) CMLib.tracking() .walk((MOB) openThis, dirCode, ((MOB) openThis).isInCombat(), false, true, true); } } } return false; }
public boolean open( MOB mob, Environmental openThis, String openableWord, int dirCode, boolean quietly) { final String openWord = (!(openThis instanceof Exit)) ? "open" : ((Exit) openThis).openWord(); final String openMsg = quietly ? null : ("<S-NAME> " + openWord + "(s) <T-NAMESELF>.") + CMLib.protocol().msp("dooropen.wav", 10); final CMMsg msg = CMClass.getMsg(mob, openThis, null, CMMsg.MSG_OPEN, openMsg, openableWord, openMsg); if (openThis instanceof Exit) { final boolean open = ((Exit) openThis).isOpen(); if ((mob.location().okMessage(msg.source(), msg)) && (!open)) { mob.location().send(msg.source(), msg); if (dirCode < 0) for (int d = Directions.NUM_DIRECTIONS() - 1; d >= 0; d--) if (mob.location().getExitInDir(d) == openThis) { dirCode = d; break; } if ((dirCode >= 0) && (mob.location().getRoomInDir(dirCode) != null)) { final Room opR = mob.location().getRoomInDir(dirCode); final Exit opE = mob.location().getPairedExit(dirCode); if (opE != null) { final CMMsg altMsg = CMClass.getMsg( msg.source(), opE, msg.tool(), msg.sourceCode(), null, msg.targetCode(), null, msg.othersCode(), null); opE.executeMsg(msg.source(), altMsg); } final int opCode = Directions.getOpDirectionCode(dirCode); if ((opE != null) && (opE.isOpen()) && (((Exit) openThis).isOpen())) { final boolean useShipDirs = (opR instanceof BoardableShip) || (opR.getArea() instanceof BoardableShip); final String inDirName = useShipDirs ? Directions.getShipInDirectionName(opCode) : Directions.getInDirectionName(opCode); opR.showHappens(CMMsg.MSG_OK_ACTION, L("@x1 @x2 opens.", opE.name(), inDirName)); } return true; } } } else if (mob.location().okMessage(mob, msg)) { mob.location().send(mob, msg); return true; } return false; }
public boolean okMessage(Environmental myHost, CMMsg msg) { if (!super.okMessage(myHost, msg)) return false; if (affected == null) return true; MOB mob = (MOB) affected; if ((msg.amISource(mob)) && (mob.location() != null) && (msg.target() != null) && (msg.target() instanceof Room)) { if ((msg.sourceMinor() == CMMsg.TYP_ENTER) && ((mob.location().domainType() == Room.DOMAIN_OUTDOORS_WATERSURFACE) || (mob.location().domainType() == Room.DOMAIN_INDOORS_WATERSURFACE)) && (msg.target() == mob.location().getRoomInDir(Directions.UP))) { msg.source() .tell("Your water walking magic prevents you from ascending from the water surface."); return false; } else if ((msg.sourceMinor() == CMMsg.TYP_LEAVE) && (mob.location().domainType() != Room.DOMAIN_OUTDOORS_WATERSURFACE) && (mob.location().domainType() != Room.DOMAIN_INDOORS_WATERSURFACE) && (msg.tool() != null) && (msg.tool() instanceof Exit)) { for (int d = Directions.NUM_DIRECTIONS() - 1; d >= 0; d--) { Room R = mob.location().getRoomInDir(d); if ((R != null) && (mob.location().getReverseExit(d) == msg.tool()) && ((R.domainType() == Room.DOMAIN_OUTDOORS_WATERSURFACE) || (R.domainType() == Room.DOMAIN_INDOORS_WATERSURFACE))) { triggerNow = true; msg.source().recoverEnvStats(); return true; } } } } return true; }
public boolean okMessage(Environmental myHost, CMMsg msg) { if (!super.okMessage(myHost, msg)) return false; if (msg.targetMinor() == CMMsg.TYP_ENTER) { if (msg.target() == this) { MOB mob = msg.source(); if ((mob.location() != null) && (mob.location().roomID().length() > 0)) { int direction = -1; for (int d = Directions.NUM_DIRECTIONS() - 1; d >= 0; d--) { if (mob.location().getRoomInDir(d) == this) direction = d; } if (direction < 0) { mob.tell("Some great evil is preventing your movement that way."); return false; } msg.modify( msg.source(), getAltRoomFrom(mob.location(), direction), msg.tool(), msg.sourceCode(), msg.sourceMessage(), msg.targetCode(), msg.targetMessage(), msg.othersCode(), msg.othersMessage()); } } } return true; }
public Room getRoom(String roomID) { if (!CMath.bset(flags(), Area.FLAG_INSTANCE_CHILD)) return super.getRoom(roomID); if (!isRoom(roomID)) return null; Room R = super.getRoom(roomID); if (((R == null) || (R.amDestroyed())) && (roomID != null)) { Area parentA = getParentArea(); if (parentA == null) return null; if (roomID.toUpperCase().startsWith(Name().toUpperCase() + "#")) roomID = Name() + roomID.substring(Name().length()); // for case sensitive situations R = parentA.getRoom(parentA.Name() + getStrippedRoomID(roomID)); if (R == null) return null; Room origRoom = R; R = (Room) R.copyOf(); R.clearSky(); if (R instanceof GridLocale) ((GridLocale) R).clearGrid(null); for (int d = Directions.NUM_DIRECTIONS() - 1; d >= 0; d--) R.rawDoors()[d] = null; R.setRoomID(roomID); R.setArea(this); addProperRoom(R); synchronized (("SYNC" + roomID).intern()) { for (int d = Directions.NUM_DIRECTIONS() - 1; d >= 0; d--) { Room dirR = origRoom.rawDoors()[d]; if (dirR != null) { String myRID = dirR.roomID(); if (dirR.getArea() == parentA) { String localDirRID = convertToMyArea(myRID); Room localDirR = getProperRoom(localDirRID); if (localDirR != null) R.rawDoors()[d] = localDirR; else { R.rawDoors()[d] = CMClass.getLocale("ThinRoom"); R.rawDoors()[d].setRoomID(localDirRID); R.rawDoors()[d].setArea(this); } } else R.rawDoors()[d] = dirR; } } } fillInAreaRoom(R); R.setExpirationDate(System.currentTimeMillis() + WorldMap.ROOM_EXPIRATION_MILLIS); } return R; }
public boolean isGoodSafehouse(Room target) { if (target == null) return false; if ((target.domainType() == Room.DOMAIN_INDOORS_WOOD) || (target.domainType() == Room.DOMAIN_INDOORS_STONE)) for (int d = Directions.NUM_DIRECTIONS() - 1; d >= 0; d--) { Room R = target.getRoomInDir(d); if ((R != null) && (R.domainType() == Room.DOMAIN_OUTDOORS_CITY)) return true; } return false; }
protected boolean canFallFrom(Room fromHere, int direction) { if ((fromHere == null) || (direction < 0) || (direction >= Directions.NUM_DIRECTIONS())) return false; final Room toHere = fromHere.getRoomInDir(direction); if ((toHere == null) || (fromHere.getExitInDir(direction) == null) || (!fromHere.getExitInDir(direction).isOpen())) return false; if (CMLib.flags().isWaterySurfaceRoom(fromHere) && CMLib.flags().isUnderWateryRoom(toHere)) return false; return true; }
public void fillInFlags() { for (Enumeration<LayoutNode> e = set().elements(); e.hasMoreElements(); ) { LayoutNode n = e.nextElement(); int[] dirs = new int[n.links().size()]; int x = 0; for (Integer dirLink : n.links().keySet()) dirs[x++] = dirLink.intValue(); n.setExits(dirs); if ((dirs.length == 1) && (!n.isFlagged(LayoutFlags.gate))) n.reType(LayoutTypes.leaf); } for (Enumeration<LayoutNode> e = set().elements(); e.hasMoreElements(); ) { LayoutNode n = e.nextElement(); if (n.links().size() == 2) { LayoutFlags flag = null; if (n.type() == LayoutTypes.interior) for (Integer dirLink : n.links().keySet()) { LayoutNode n2 = n.links().get(dirLink); if ((n2 != null) && (n2.type() == LayoutTypes.leaf)) flag = LayoutFlags.offleaf; } if (flag != null) n.flag(flag); else { Enumeration<Integer> dirs = n.links().keys(); Integer lN1 = dirs.nextElement(); Integer lN2 = dirs.nextElement(); if (lN1.intValue() != Directions.getOpDirectionCode(lN2.intValue())) n.flag(LayoutFlags.corner); } } else if ((n.links().size() == 3) && (((n.type() == LayoutTypes.street) || (n.type() != LayoutTypes.surround)))) { boolean allStreet = true; for (Integer dirLink : n.links().keySet()) { LayoutNode n2 = n.links().get(dirLink); if ((n2 == null) || ((n2.type() != LayoutTypes.street) && (n2.type() != LayoutTypes.surround))) allStreet = false; } if (allStreet) n.flag(LayoutFlags.tee); } else if ((n.links().size() == 4) && (((n.type() == LayoutTypes.street) || (n.type() != LayoutTypes.surround)))) { boolean allStreet = true; for (Integer dirLink : n.links().keySet()) { LayoutNode n2 = n.links().get(dirLink); if ((n2 == null) || ((n2.type() != LayoutTypes.street) && (n2.type() != LayoutTypes.surround))) allStreet = false; } if (allStreet) n.flag(LayoutFlags.intersection); } } }
public boolean isHere(Tickable E2, Room here) { if (E2 == null) return false; else if (E2 == here) return true; else if ((E2 instanceof MOB) && (((MOB) E2).location() == here)) return true; else if ((E2 instanceof Item) && (((Item) E2).owner() == here)) return true; else if ((E2 instanceof Item) && (((Item) E2).owner() != null) && (((Item) E2).owner() instanceof MOB) && (((MOB) ((Item) E2).owner()).location() == here)) return true; else if (E2 instanceof Exit) { for (int d = Directions.NUM_DIRECTIONS() - 1; d >= 0; d--) if (here.getRawExit(d) == E2) return true; } return false; }
protected boolean findVictim(MOB mob, Room room, Vector rooms, int depth) { if (depth > 5) return false; if (victimHere(room, mob) != null) { rooms.addElement(room); return true; } for (int d = Directions.NUM_DIRECTIONS() - 1; d >= 0; d--) { final Room R = room.getRoomInDir(d); final Exit E = room.getExitInDir(d); if ((R != null) && (E != null) && (E.isOpen())) { if (findVictim(mob, R, rooms, depth + 1)) { rooms.addElement(R); return true; } } } return false; }
@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); } } }
public void roomAffectFully(CMMsg msg, Room room, int dirCode) { room.send(msg.source(), msg); if ((msg.target() == null) || (!(msg.target() instanceof Exit))) return; if (dirCode < 0) { for (int d = Directions.NUM_DIRECTIONS() - 1; d >= 0; d--) if (room.getExitInDir(d) == msg.target()) { dirCode = d; break; } } if (dirCode < 0) return; Exit pair = room.getPairedExit(dirCode); if (pair != null) { CMMsg altMsg = null; if ((msg.targetCode() == CMMsg.MSG_OPEN) && (pair.isLocked())) { altMsg = CMClass.getMsg( msg.source(), pair, msg.tool(), CMMsg.MSG_UNLOCK, null, CMMsg.MSG_UNLOCK, null, CMMsg.MSG_UNLOCK, null); pair.executeMsg(msg.source(), altMsg); } altMsg = CMClass.getMsg( msg.source(), pair, msg.tool(), msg.sourceCode(), null, msg.targetCode(), null, msg.othersCode(), null); pair.executeMsg(msg.source(), altMsg); } }
@Override public boolean execute(MOB mob, Vector commands, int metaFlags) throws java.io.IOException { final String whatToOpen = CMParms.combine(commands, 1); if (whatToOpen.length() == 0) { mob.tell(L("Open what?")); return false; } Environmental openThis = null; final int dirCode = Directions.getGoodDirectionCode(whatToOpen); if (dirCode >= 0) openThis = mob.location().getExitInDir(dirCode); if (openThis == null) openThis = mob.location().fetchFromMOBRoomItemExit(mob, null, whatToOpen, Wearable.FILTER_ANY); if ((openThis == null) || (!CMLib.flags().canBeSeenBy(openThis, mob))) { mob.tell(L("You don't see '@x1' here.", whatToOpen)); return false; } open(mob, openThis, whatToOpen, dirCode, false); return false; }
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); }
public void executeMsg(Environmental myHost, CMMsg msg) { if ((msg.targetMinor() == CMMsg.TYP_EXPIRE) && (msg.target() instanceof Room)) { Room R = (Room) msg.target(); if (R.getGridParent() == this) { if ((roomID().length() > 0) && (getArea() != null)) getArea().delProperRoomnumber(getGridChildCode(R)); DVector thisGridRooms = rooms; thisGridRooms.removeElement(R); Room R2 = null; for (int r = thisGridRooms.size() - 1; r >= 0; r--) { R2 = (Room) thisGridRooms.elementAt(r, 1); for (int d = Directions.NUM_DIRECTIONS() - 1; d >= 0; d--) if (R2.rawDoors()[d] == R) { R2.rawDoors()[d] = null; R2.setRawExit(d, null); } } } } super.executeMsg(myHost, msg); }
public static void main(String[] args) { Directions.instance(); int d = Directions.NORTH; { draw(new BoxCityLayout(), 25, d); draw(new BoxCityLayout(), 50, d); draw(new BoxCityLayout(), 100, d); draw(new BoxCitySquareLayout(), 25, d); draw(new BoxCitySquareLayout(), 50, d); draw(new BoxCitySquareLayout(), 100, d); draw(new CrossLayout(), 25, d); draw(new CrossLayout(), 50, d); draw(new CrossLayout(), 100, d); draw(new GridCityLayout(), 25, d); draw(new GridCityLayout(), 50, d); draw(new GridCityLayout(), 100, d); draw(new MazeLayout(), 25, d); draw(new MazeLayout(), 50, d); draw(new MazeLayout(), 100, d); draw(new TreeLayout(), 25, d); draw(new TreeLayout(), 50, d); draw(new TreeLayout(), 100, d); } }
public void clipLongStreets() { @SuppressWarnings("unchecked") Vector<LayoutNode> set2 = (Vector<LayoutNode>) set().clone(); for (Enumeration<LayoutNode> e = set2.elements(); e.hasMoreElements(); ) { LayoutNode p = e.nextElement(); if (isUsed(p) && p.isStreetLike()) for (int d = 0; d < 4; d++) if (p.getLink(d) == null) { LayoutNode p2 = getNextNode(p, d); if ((p2 != null) && (!p.links().containsValue(p2))) { Enumeration<LayoutNode> nodes = p.links().elements(); LayoutNode p_1 = nodes.nextElement(); LayoutNode p_2 = nodes.nextElement(); p.deLink(); p_1.crossLink(p_2); unUse(p); LayoutNode p3 = makeNextNode(p2, Directions.getOpDirectionCode(d)); p2.crossLink(p3); use(p3, LayoutTypes.leaf); break; } } } }
public boolean invoke( MOB mob, Vector commands, Environmental givenTarget, boolean auto, int asLevel) { if ((commands.size() < 1) && (givenTarget == null)) { mob.tell("Wizard Lock what?."); return false; } String targetName = CMParms.combine(commands, 0); Environmental target = null; int dirCode = Directions.getGoodDirectionCode(targetName); if (dirCode >= 0) target = mob.location().getExitInDir(dirCode); if (target == null) target = getTarget(mob, mob.location(), givenTarget, commands, Wearable.FILTER_ANY); if (target == null) return false; if ((!(target instanceof Container)) && (!(target instanceof Exit))) { mob.tell("You can't lock that."); return false; } if (target instanceof Container) { Container container = (Container) target; if ((!container.hasALid()) || (!container.hasALock())) { mob.tell("You can't lock that!"); return false; } } else if (target instanceof Exit) { Exit exit = (Exit) target; if (!exit.hasADoor()) { mob.tell("You can't lock that!"); return false; } } if (target.fetchEffect(this.ID()) != null) { mob.tell(target.name() + " is already magically locked!"); return false; } if (!super.invoke(mob, commands, givenTarget, auto, asLevel)) return false; boolean success = proficiencyCheck(mob, 0, auto); if (success) { CMMsg msg = CMClass.getMsg( mob, target, this, verbalCastCode(mob, target, auto), auto ? "" : "^S<S-NAME> point(s) <S-HIS-HER> finger at <T-NAMESELF>, incanting.^?"); if (mob.location().okMessage(mob, msg)) { mob.location().send(mob, msg); if (target instanceof Exit) { Exit exit = (Exit) target; exit.setDoorsNLocks( exit.hasADoor(), false, exit.defaultsClosed(), exit.hasALock(), true, exit.defaultsLocked()); Room R = mob.location(); Room R2 = null; for (int d = Directions.NUM_DIRECTIONS() - 1; d >= 0; d--) if (R.getExitInDir(d) == target) { R2 = R.getRoomInDir(d); break; } if ((CMLib.law().doesOwnThisProperty(mob, R)) || ((R2 != null) && (CMLib.law().doesOwnThisProperty(mob, R2)))) { target.addNonUninvokableEffect((Ability) copyOf()); CMLib.database().DBUpdateExits(R); } else beneficialAffect(mob, target, asLevel, Integer.MAX_VALUE / 2); mob.location().show(mob, target, CMMsg.MSG_OK_VISUAL, "<T-NAME> look(s) shut tight!"); } else if (target instanceof Container) { beneficialAffect(mob, target, asLevel, Integer.MAX_VALUE / 2); Container container = (Container) target; container.setLidsNLocks(container.hasALid(), false, container.hasALock(), true); mob.location().show(mob, target, CMMsg.MSG_OK_VISUAL, "<T-NAME> look(s) shut tight!"); } Ability lock = target.fetchEffect(ID()); if (lock != null) { lock.setMiscText(Integer.toString(mob.envStats().level())); if (target instanceof Exit) { Room R = mob.location(); if (!CMLib.law().doesHavePriviledgesHere(mob, R)) for (int a = 0; a < R.numEffects(); a++) if ((R.fetchEffect(a) instanceof LandTitle) && (((LandTitle) R.fetchEffect(a)).landOwner().length() > 0)) lock.setMiscText(lock.text() + " MALICIOUS"); } } } } else beneficialWordsFizzle( mob, target, "<S-NAME> point(s) at <T-NAMESELF>, incanting, but nothing happens."); // return whether it worked return success; }
@Override public boolean execute(MOB mob, Vector commands, int metaFlags) throws java.io.IOException { final Room R = mob.location(); boolean quiet = false; if ((commands != null) && (commands.size() > 1) && (((String) commands.lastElement()).equalsIgnoreCase("UNOBTRUSIVELY"))) { commands.remove(commands.size() - 1); quiet = true; } final String textMsg = "<S-NAME> look(s) "; if (R == null) return false; if ((commands != null) && (commands.size() > 1)) { Environmental thisThang = null; if ((commands.size() > 2) && (((String) commands.get(1)).equalsIgnoreCase("at"))) commands.remove(1); else if ((commands.size() > 2) && (((String) commands.get(1)).equalsIgnoreCase("to"))) commands.remove(1); final String ID = CMParms.combine(commands, 1); if ((ID.toUpperCase().startsWith("EXIT") && (commands.size() == 2)) && (CMProps.getIntVar(CMProps.Int.EXVIEW) != 1)) { final CMMsg exitMsg = CMClass.getMsg(mob, R, null, CMMsg.MSG_LOOK_EXITS, null); if ((CMProps.getIntVar(CMProps.Int.EXVIEW) >= 2) != mob.isAttribute(MOB.Attrib.BRIEF)) exitMsg.setValue(CMMsg.MASK_OPTIMIZE); if (R.okMessage(mob, exitMsg)) R.send(mob, exitMsg); return false; } if (ID.equalsIgnoreCase("SELF") || ID.equalsIgnoreCase("ME")) thisThang = mob; if (thisThang == null) thisThang = R.fetchFromMOBRoomFavorsItems(mob, null, ID, noCoinFilter); if (thisThang == null) thisThang = R.fetchFromMOBRoomFavorsItems(mob, null, ID, Wearable.FILTER_ANY); if ((thisThang == null) && (commands.size() > 2) && (((String) commands.get(1)).equalsIgnoreCase("in"))) { commands.remove(1); final String ID2 = CMParms.combine(commands, 1); thisThang = R.fetchFromMOBRoomFavorsItems(mob, null, ID2, Wearable.FILTER_ANY); if ((thisThang != null) && ((!(thisThang instanceof Container)) || (((Container) thisThang).capacity() == 0))) { mob.tell(L("That's not a container.")); return false; } } int dirCode = -1; Environmental lookingTool = null; if (thisThang == null) { dirCode = Directions.getGoodDirectionCode(ID); if (dirCode >= 0) { final Room room = R.getRoomInDir(dirCode); final Exit exit = R.getExitInDir(dirCode); if ((room != null) && (exit != null)) { thisThang = exit; lookingTool = room; } else { mob.tell(L("You don't see anything that way.")); return false; } } } if (thisThang != null) { String name = "at <T-NAMESELF>"; if ((thisThang instanceof Room) || (thisThang instanceof Exit)) { if (thisThang == R) name = "around"; else if (dirCode >= 0) name = ((R instanceof BoardableShip) || (R.getArea() instanceof BoardableShip)) ? Directions.getShipDirectionName(dirCode) : Directions.getDirectionName(dirCode); } final CMMsg msg = CMClass.getMsg(mob, thisThang, lookingTool, CMMsg.MSG_LOOK, textMsg + name + "."); if ((thisThang instanceof Room) && (mob.isAttribute(MOB.Attrib.AUTOEXITS)) && (CMProps.getIntVar(CMProps.Int.EXVIEW) != 1)) { final CMMsg exitMsg = CMClass.getMsg(mob, thisThang, lookingTool, CMMsg.MSG_LOOK_EXITS, null); if ((CMProps.getIntVar(CMProps.Int.EXVIEW) >= 2) != mob.isAttribute(MOB.Attrib.BRIEF)) exitMsg.setValue(CMMsg.MASK_OPTIMIZE); msg.addTrailerMsg(exitMsg); } if (R.okMessage(mob, msg)) R.send(mob, msg); } else mob.tell(L("You don't see that here!")); } else { if ((commands != null) && (commands.size() > 0)) if (((String) commands.get(0)).toUpperCase().startsWith("E")) { mob.tell(L("Examine what?")); return false; } final CMMsg msg = CMClass.getMsg( mob, R, null, CMMsg.MSG_LOOK, (quiet ? null : textMsg + "around."), CMMsg.MSG_LOOK, (quiet ? null : textMsg + "at you."), CMMsg.MSG_LOOK, (quiet ? null : textMsg + "around.")); if ((mob.isAttribute(MOB.Attrib.AUTOEXITS)) && (CMProps.getIntVar(CMProps.Int.EXVIEW) != 1) && (CMLib.flags().canBeSeenBy(R, mob))) { final CMMsg exitMsg = CMClass.getMsg(mob, R, null, CMMsg.MSG_LOOK_EXITS, null); if ((CMProps.getIntVar(CMProps.Int.EXVIEW) >= 2) != mob.isAttribute(MOB.Attrib.BRIEF)) exitMsg.setValue(CMMsg.MASK_OPTIMIZE); msg.addTrailerMsg(exitMsg); } if (R.okMessage(mob, msg)) R.send(mob, msg); } return false; }
public Room getAltRoomFrom(Room loc, int direction) { if ((loc == null) || (direction < 0)) return null; int opDirection = Directions.getOpDirectionCode(direction); String roomID = CMLib.map().getExtendedRoomID(loc); for (int d = 0; d < gridexits.size(); d++) { WorldMap.CrossExit EX = (WorldMap.CrossExit) gridexits.elementAt(d); if ((!EX.out) && (EX.destRoomID.equalsIgnoreCase(roomID)) && (EX.dir == direction) && (EX.x >= 0) && (EX.y >= 0) && (EX.x < xGridSize()) && (EX.y < yGridSize())) return getMakeGridRoom(EX.x, EX.y); } Room oldLoc = loc; if (loc.getGridParent() != null) loc = loc.getGridParent(); if ((oldLoc != loc) && (loc instanceof GridLocale)) { int y = ((GridLocale) loc).getGridChildY(oldLoc); int x = ((GridLocale) loc).getGridChildX(oldLoc); if ((x >= 0) && (y >= 0)) switch (opDirection) { case Directions.EAST: if ((((GridLocale) loc).yGridSize() == yGridSize())) return getMakeGridRoom(xGridSize() - 1, y); break; case Directions.WEST: if ((((GridLocale) loc).yGridSize() == yGridSize())) return getMakeGridRoom(0, y); break; case Directions.NORTH: if ((((GridLocale) loc).xGridSize() == xGridSize())) return getMakeGridRoom(x, 0); break; case Directions.NORTHWEST: return getMakeGridRoom(0, 0); case Directions.SOUTHEAST: return getMakeGridRoom(xGridSize() - 1, yGridSize() - 1); case Directions.NORTHEAST: return getMakeGridRoom(xGridSize() - 1, 0); case Directions.SOUTHWEST: return getMakeGridRoom(0, yGridSize() - 1); case Directions.SOUTH: if ((((GridLocale) loc).xGridSize() == xGridSize())) return getMakeGridRoom(x, yGridSize() - 1); break; } } int x = 0; int y = 0; switch (opDirection) { case Directions.NORTH: x = xGridSize() / 2; break; case Directions.SOUTH: x = xGridSize() / 2; y = yGridSize() - 1; break; case Directions.EAST: x = xGridSize() - 1; y = yGridSize() / 2; break; case Directions.WEST: y = yGridSize() / 2; break; case Directions.NORTHWEST: x = 0; y = 0; break; case Directions.NORTHEAST: x = xGridSize() - 1; y = 0; break; case Directions.SOUTHWEST: x = 0; y = yGridSize() - 1; break; case Directions.SOUTHEAST: x = xGridSize() - 1; y = yGridSize() - 1; break; case Directions.UP: case Directions.DOWN: x = xGridSize() / 2; y = yGridSize() / 2; break; } return getMakeGridRoom(x, y); }
@Override public boolean tick(Tickable ticking, int tickID) { tickStatus = Tickable.STATUS_MISC + 0; super.tick(ticking, tickID); tickStatus = Tickable.STATUS_MISC + 1; if (tickID != Tickable.TICKID_MOB) { tickStatus = Tickable.STATUS_NOT; return true; } if (!canFreelyBehaveNormal(ticking)) { tickStatus = Tickable.STATUS_NOT; return true; } final MOB mob = (MOB) ticking; // ridden things dont wander! if (ticking instanceof Rideable) if (((Rideable) ticking).numRiders() > 0) { tickStatus = Tickable.STATUS_NOT; return true; } tickStatus = Tickable.STATUS_MISC + 2; if (((mob.amFollowing() != null) && (mob.location() == mob.amFollowing().location())) || (!CMLib.flags().canTaste(mob))) { tickStatus = Tickable.STATUS_NOT; return true; } tickStatus = Tickable.STATUS_MISC + 3; final Room thisRoom = mob.location(); MOB victim = GoodGuardian.anyPeaceToMake(mob.location(), mob); GoodGuardian.keepPeace(mob, victim); victim = null; int dirCode = -1; tickStatus = Tickable.STATUS_MISC + 4; for (int d = Directions.NUM_DIRECTIONS() - 1; d >= 0; d--) { tickStatus = Tickable.STATUS_MISC + 5 + d; final Room room = thisRoom.getRoomInDir(d); final Exit exit = thisRoom.getExitInDir(d); if ((room != null) && (exit != null) && (okRoomForMe(mob, thisRoom, room, false))) { tickStatus = Tickable.STATUS_MISC + 20 + d; if (exit.isOpen()) { tickStatus = Tickable.STATUS_MISC + 40 + d; victim = GoodGuardian.anyPeaceToMake(room, mob); if (victim != null) { dirCode = d; break; } tickStatus = Tickable.STATUS_MISC + 60 + d; } tickStatus = Tickable.STATUS_MISC + 80 + d; } if (dirCode >= 0) break; tickStatus = Tickable.STATUS_MISC + 100 + d; } tickStatus = Tickable.STATUS_MISC + 120; if ((dirCode >= 0) && (!CMSecurity.isDisabled(CMSecurity.DisFlag.MOBILITY))) { tickStatus = Tickable.STATUS_MISC + 121; CMLib.tracking().walk(mob, dirCode, false, false); tickStatus = Tickable.STATUS_MISC + 122; GoodGuardian.keepPeace(mob, victim); tickStatus = Tickable.STATUS_MISC + 123; } tickStatus = Tickable.STATUS_NOT; return true; }
public boolean invoke(MOB mob, Vector commands, Physical givenTarget, boolean auto, int asLevel) { String whatToRevoke = CMParms.combine(commands, 0); Physical target = null; if ((whatToRevoke.length() == 0) && (mob.location().numEffects() > 0)) target = mob.location(); else if (whatToRevoke.equalsIgnoreCase("room")) target = mob.location(); else if (whatToRevoke.equalsIgnoreCase("self")) target = mob; else { int dir = Directions.getGoodDirectionCode(whatToRevoke); if (dir >= 0) target = mob.location().getExitInDir(dir); else { target = mob.location().fetchFromRoomFavorMOBs(null, whatToRevoke); if (target == null) target = mob.findItem(null, whatToRevoke); } } if ((target == null) || (!CMLib.flags().canBeSeenBy(target, mob))) { mob.tell("Revoke from what? You don't see '" + whatToRevoke + "' here."); return false; } Ability revokeThis = null; for (int a = 0; a < target.numEffects(); a++) { Ability A = target.fetchEffect(a); if ((A != null) && (A.invoker() == mob) && (((A.classificationCode() & Ability.ALL_ACODES) == Ability.ACODE_SPELL) || ((A.classificationCode() & Ability.ALL_ACODES) == Ability.ACODE_SONG) || ((A.classificationCode() & Ability.ALL_ACODES) == Ability.ACODE_PRAYER) || ((A.classificationCode() & Ability.ALL_ACODES) == Ability.ACODE_CHANT)) && (A.canBeUninvoked())) revokeThis = A; } if (revokeThis == null) { if (target instanceof Room) mob.tell("Revoke your magic from what?"); else mob.tell( mob, target, null, "<T-NAME> do(es) not appear to be affected by anything you can revoke."); return false; } if (!super.invoke(mob, commands, givenTarget, auto, asLevel)) return false; boolean success = proficiencyCheck(mob, 0, auto); if (success) { CMMsg msg = CMClass.getMsg( mob, null, this, CMMsg.MSG_HANDS, "<S-NAME> revoke(s) " + revokeThis.name() + " from " + target.name()); if (mob.location().okMessage(mob, msg)) { mob.location().send(mob, msg); revokeThis.unInvoke(); } } else beneficialVisualFizzle( mob, target, "<S-NAME> attempt(s) to revoke " + revokeThis.name() + " from " + target.name() + ", but flub(s) it."); return success; }
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 static int updateLotWithThisData( Room R, LandTitle T, boolean resetRoomName, boolean clearAllItems, List optPlayerList, int lastNumItems) { boolean updateItems = false; boolean updateExits = false; boolean updateRoom = false; synchronized (("SYNC" + R.roomID()).intern()) { R = CMLib.map().getRoom(R); if (T.getOwnerName().length() == 0) { Item I = null; for (int i = R.numItems() - 1; i >= 0; i--) { I = R.getItem(i); if ((I == null) || (I.Name().equalsIgnoreCase("id"))) continue; CMLib.catalog().updateCatalogIntegrity(I); if (clearAllItems) { I.destroy(); updateItems = true; } else { if (I.expirationDate() == 0) { long now = System.currentTimeMillis(); now += (TimeManager.MILI_MINUTE * CMProps.getIntVar(CMProps.Int.EXPIRE_PLAYER_DROP)); I.setExpirationDate(now); } if ((I.phyStats().rejuv() != PhyStats.NO_REJUV) && (I.phyStats().rejuv() != 0)) { I.basePhyStats().setRejuv(PhyStats.NO_REJUV); I.recoverPhyStats(); } } } Ability A = null; if (clearAllItems) for (final Enumeration<Ability> a = R.effects(); a.hasMoreElements(); ) { A = a.nextElement(); if (((A != null) && ((A.classificationCode() & Ability.ALL_ACODES) != Ability.ACODE_PROPERTY))) { A.unInvoke(); R.delEffect(A); updateRoom = true; } } for (int d = Directions.NUM_DIRECTIONS() - 1; d >= 0; d--) { final Room R2 = R.rawDoors()[d]; Exit E = R.getRawExit(d); if ((E != null) && (E.hasALock()) && (E.isGeneric())) { E.setKeyName(""); E.setDoorsNLocks(E.hasADoor(), E.isOpen(), E.defaultsClosed(), false, false, false); updateExits = true; if (R2 != null) { E = R2.getRawExit(Directions.getOpDirectionCode(d)); if ((E != null) && (E.hasALock()) && (E.isGeneric())) { E.setKeyName(""); E.setDoorsNLocks(E.hasADoor(), E.isOpen(), E.defaultsClosed(), false, false, false); CMLib.database().DBUpdateExits(R2); R2.getArea().fillInAreaRoom(R2); } } } } if (updateExits) { CMLib.database().DBUpdateExits(R); R.getArea().fillInAreaRoom(R); } if (updateItems) CMLib.database().DBUpdateItems(R); if (updateRoom) CMLib.database().DBUpdateRoom(R); colorForSale(R, T.rentalProperty(), resetRoomName); return -1; } if ((lastNumItems < 0) && (!CMSecurity.isDisabled(CMSecurity.DisFlag.PROPERTYOWNERCHECKS)) && (optPlayerList != null)) { boolean playerExists = (CMLib.players().getPlayer(T.getOwnerName()) != null); if (!playerExists) playerExists = (CMLib.clans().getClan(T.getOwnerName()) != null); if (!playerExists) playerExists = optPlayerList.contains(T.getOwnerName()); if (!playerExists) for (int i = 0; i < optPlayerList.size(); i++) if (((String) optPlayerList.get(i)).equalsIgnoreCase(T.getOwnerName())) { playerExists = true; break; } if (!playerExists) { T.setOwnerName(""); T.updateLot(null); return -1; } } int x = R.description().indexOf(SALESTR); if (x >= 0) { R.setDescription(R.description().substring(0, x)); CMLib.database().DBUpdateRoom(R); } x = R.description().indexOf(RENTSTR); if (x >= 0) { R.setDescription(R.description().substring(0, x)); CMLib.database().DBUpdateRoom(R); } // this works on the priciple that // 1. if an item has ONLY been removed, the lastNumItems will be != current # items // 2. if an item has ONLY been added, the dispossessiontime will be != null // 3. if an item has been added AND removed, the dispossession time will be != null on the // added if ((lastNumItems >= 0) && (R.numItems() != lastNumItems)) updateItems = true; for (int i = 0; i < R.numItems(); i++) { final Item I = R.getItem(i); if ((I.expirationDate() != 0) && ((I.isSavable()) || (I.Name().equalsIgnoreCase("id"))) && ((!(I instanceof DeadBody)) || (((DeadBody) I).isPlayerCorpse()))) { I.setExpirationDate(0); updateItems = true; } if ((I.phyStats().rejuv() != Integer.MAX_VALUE) && (I.phyStats().rejuv() != 0)) { I.basePhyStats().setRejuv(PhyStats.NO_REJUV); I.recoverPhyStats(); updateItems = true; } } lastNumItems = R.numItems(); if ((!CMSecurity.isSaveFlag(CMSecurity.SaveFlag.NOPROPERTYITEMS)) && (updateItems)) CMLib.database().DBUpdateItems(R); } return lastNumItems; }
public boolean execute(MOB mob, Vector commands, int metaFlags) throws java.io.IOException { String whatToOpen = CMParms.combine(commands, 1); if (whatToOpen.length() == 0) { mob.tell("Open what?"); return false; } Environmental openThis = null; int dirCode = Directions.getGoodDirectionCode(whatToOpen); if (dirCode >= 0) openThis = mob.location().getExitInDir(dirCode); if (openThis == null) openThis = mob.location().fetchFromMOBRoomItemExit(mob, null, whatToOpen, Item.WORNREQ_ANY); if ((openThis == null) || (!CMLib.flags().canBeSeenBy(openThis, mob))) { mob.tell("You don't see '" + whatToOpen + "' here."); return false; } String openWord = (!(openThis instanceof Exit)) ? "open" : ((Exit) openThis).openWord(); CMMsg msg = CMClass.getMsg( mob, openThis, null, CMMsg.MSG_OPEN, ("<S-NAME> " + openWord + "(s) <T-NAMESELF>.") + CMProps.msp("dooropen.wav", 10)); if (openThis instanceof Exit) { boolean open = ((Exit) openThis).isOpen(); if ((mob.location().okMessage(msg.source(), msg)) && (!open)) { mob.location().send(msg.source(), msg); if (dirCode < 0) for (int d = Directions.NUM_DIRECTIONS() - 1; d >= 0; d--) if (mob.location().getExitInDir(d) == openThis) { dirCode = d; break; } if ((dirCode >= 0) && (mob.location().getRoomInDir(dirCode) != null)) { Room opR = mob.location().getRoomInDir(dirCode); Exit opE = mob.location().getPairedExit(dirCode); if (opE != null) { CMMsg altMsg = CMClass.getMsg( msg.source(), opE, msg.tool(), msg.sourceCode(), null, msg.targetCode(), null, msg.othersCode(), null); opE.executeMsg(msg.source(), altMsg); } int opCode = Directions.getOpDirectionCode(dirCode); if ((opE != null) && (opE.isOpen()) && (((Exit) openThis).isOpen())) opR.showHappens( CMMsg.MSG_OK_ACTION, opE.name() + " " + Directions.getInDirectionName(opCode) + " opens."); } } } else if (mob.location().okMessage(mob, msg)) mob.location().send(mob, msg); return false; }
public String[] getMiniMap(Room room, final int diameter, boolean openOnly) { char[][] map = new char[diameter][diameter]; for (int i = 0; i < diameter; i++) for (int i2 = 0; i2 < diameter; i2++) map[i][i2] = ' '; boolean amIndoors = ((room.domainType() & Room.INDOORS) == Room.INDOORS); Room[][] rmap = new Room[diameter][diameter]; Vector rooms = new Vector(); HashSet closedPaths = new HashSet(); TrackingLibrary.TrackingFlags flags; flags = new TrackingLibrary.TrackingFlags() .plus(TrackingLibrary.TrackingFlag.NOEMPTYGRIDS) .plus(TrackingLibrary.TrackingFlag.NOAIR); if (openOnly) flags = flags.plus(TrackingLibrary.TrackingFlag.OPENONLY); CMLib.tracking().getRadiantRooms(room, rooms, flags, null, diameter, null); rmap[diameter / 2][diameter / 2] = room; map[diameter / 2][diameter / 2] = '*'; for (int i = 0; i < rooms.size(); i++) { Room R = (Room) rooms.elementAt(i); if ((closedPaths.contains(R)) || (R == room)) continue; Room parentR = null; int parentDir = -1; int[] xy = null; for (int i2 = 0; (i2 < diameter) && (parentR == null); i2++) for (int i3 = 0; (i3 < diameter) && (parentR == null); i3++) { Room R2 = rmap[i2][i3]; if (R2 != null) for (int d = Directions.NUM_DIRECTIONS() - 1; d >= 0; d--) if ((R2.getRoomInDir(d) == R) && (!closedPaths.contains(R2)) && (R2.getExitInDir(d) != null)) { parentR = R2; parentDir = d; xy = Directions.adjustXYByDirections(i3, i2, d); break; } } if (xy != null) { if ((parentDir < 0) || (xy[0] < 0) || (xy[0] >= diameter) || (xy[1] < 0) || (xy[1] >= diameter) || (map[xy[1]][xy[0]] != ' ')) closedPaths.add(R); else { map[xy[1]][xy[0]] = roomChar(R, !amIndoors); rmap[xy[1]][xy[0]] = R; if ((R.domainType() & Room.INDOORS) == Room.INDOORS) closedPaths.add(R); } } } final String[] miniMap = new String[diameter]; final StringBuffer str = new StringBuffer(""); char r = ' '; char c = ' '; for (int i2 = 0; i2 < diameter; i2++) { str.setLength(0); for (int i3 = 0; i3 < diameter; i3++) { r = map[i2][i3]; c = roomColor(rmap[i2][i3]); if (c != ' ') str.append("^" + c + "" + r); else str.append(r); } miniMap[i2] = str.toString(); } return miniMap; }
public boolean invoke( MOB mob, Vector commands, Environmental givenTarget, boolean auto, int asLevel) { if (!super.invoke(mob, commands, givenTarget, auto, asLevel)) return false; Room target = mob.location(); if ((auto) && (givenTarget != null) && (givenTarget instanceof Room)) target = (Room) givenTarget; Ability A = target.fetchEffect(ID()); if (A != null) { mob.tell("This place is already a safehouse."); return false; } if ((!auto) && (CMLib.law().getLegalBehavior(target) == null)) { mob.tell("There is no law here!"); return false; } if (!isGoodSafehouse(target)) { TrackingLibrary.TrackingFlags flags; flags = new TrackingLibrary.TrackingFlags() .add(TrackingLibrary.TrackingFlag.OPENONLY) .add(TrackingLibrary.TrackingFlag.AREAONLY) .add(TrackingLibrary.TrackingFlag.NOEMPTYGRIDS) .add(TrackingLibrary.TrackingFlag.NOAIR) .add(TrackingLibrary.TrackingFlag.NOWATER); Vector V = CMLib.tracking().getRadiantRooms(target, flags, 50 + (2 * getXLEVELLevel(mob))); Room R = null; int v = 0; for (; v < V.size(); v++) { R = (Room) V.elementAt(v); if ((isGoodSafehouse(R)) && (!isLawHere(R))) break; } mob.tell("A place like this can't be a safehouse."); if ((isGoodSafehouse(R)) && (!isLawHere(R))) { V = CMLib.tracking() .findBastardTheBestWay( target, CMParms.makeVector(R), flags, 50 + (2 * getXLEVELLevel(mob))); StringBuffer trail = new StringBuffer(""); int dir = CMLib.tracking().trackNextDirectionFromHere(V, target, true); while (target != R) { if ((dir < 0) || (dir >= Directions.NUM_DIRECTIONS()) || (target == null)) break; trail.append(Directions.getDirectionName(dir)); if (target.getRoomInDir(dir) != R) trail.append(", "); target = target.getRoomInDir(dir); dir = CMLib.tracking().trackNextDirectionFromHere(V, target, true); } if (target == R) mob.tell("You happen to know of one nearby though. Go: " + trail.toString()); } return false; } boolean success = proficiencyCheck(mob, 0, auto); CMMsg msg = CMClass.getMsg( mob, null, this, auto ? CMMsg.MASK_ALWAYS : CMMsg.MSG_DELICATE_HANDS_ACT, CMMsg.MSG_OK_VISUAL, CMMsg.MSG_OK_VISUAL, auto ? "" : "<S-NAME> hide(s) out from the law here."); if (!success) return beneficialVisualFizzle( mob, null, auto ? "" : "<S-NAME> attempt(s) hide out from the law here, but things are just too hot."); else if (mob.location().okMessage(mob, msg)) { mob.location().send(mob, msg); beneficialAffect(mob, target, asLevel, (CMProps.getIntVar(CMProps.SYSTEMI_TICKSPERMUDMONTH))); } return success; }