예제 #1
0
 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;
 }
예제 #2
0
  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;
  }
예제 #3
0
  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;
  }
예제 #4
0
파일: Open.java 프로젝트: kingdavid127/MUD
  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;
  }
예제 #5
0
 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;
 }
예제 #6
0
  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;
  }
예제 #7
0
 public void fixExits(Room R) {
   for (int d = Directions.NUM_DIRECTIONS() - 1; d >= 0; d--) {
     GrinderDir D = new GrinderDir();
     Room R2 = R.rawDoors()[d];
     if (R2 != null) {
       D.room = R2.roomID();
       Exit E2 = R.getRawExit(d);
       if (E2 != null) D.exit = E2;
     }
     doors[d] = D;
   }
 }
예제 #8
0
 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;
 }
예제 #9
0
/*


   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

	   http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.
*/
public class GrinderRoom {
  public int z = 0;
  public int[] xy = null;
  public String roomID = "";
  private Room roomCache = null;

  public Room room() {
    if ((roomID.length() > 0) && ((roomCache == null) || (roomCache.amDestroyed()))) {
      roomCache = CMLib.map().getRoom(roomID);
      if (roomCache != null) fixExits(roomCache);
    }
    return roomCache;
  }

  public boolean isRoomGood() {
    return ((roomCache != null) && (!roomCache.amDestroyed()));
  }

  public GrinderDir[] doors = new GrinderDir[Directions.NUM_DIRECTIONS()];

  public GrinderRoom(String newRoomID) {
    roomCache = null;
    roomID = newRoomID;
  }

  public void fixExits(Room R) {
    for (int d = Directions.NUM_DIRECTIONS() - 1; d >= 0; d--) {
      GrinderDir D = new GrinderDir();
      Room R2 = R.rawDoors()[d];
      if (R2 != null) {
        D.room = R2.roomID();
        Exit E2 = R.getRawExit(d);
        if (E2 != null) D.exit = E2;
      }
      doors[d] = D;
    }
  }

  public GrinderRoom(Room R) {
    roomCache = null;
    if (!R.amDestroyed()) {
      roomCache = R;
      fixExits(R);
    }
    roomID = R.roomID();
  }
}
예제 #10
0
 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;
 }
예제 #11
0
  @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);
      }
    }
  }
예제 #12
0
 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);
   }
 }
예제 #13
0
 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);
 }
예제 #14
0
  public boolean invoke(MOB mob, Vector commands, Physical givenTarget, boolean auto, int asLevel) {
    boolean saveTheTrap = false;
    if ((commands.size() > 0) && (commands.lastElement() instanceof Boolean)) {
      saveTheTrap = ((Boolean) commands.lastElement()).booleanValue();
      commands.removeElementAt(commands.size() - 1);
    }
    String whatTounlock = CMParms.combine(commands, 0);
    Physical unlockThis = null;
    int dirCode = Directions.getGoodDirectionCode(whatTounlock);
    Room R = mob.location();
    Room nextRoom = null;
    if (dirCode >= 0) {
      nextRoom = R.getRoomInDir(dirCode);
      unlockThis = R.getExitInDir(dirCode);
    }
    if ((unlockThis == null)
        && (whatTounlock.equalsIgnoreCase("room") || whatTounlock.equalsIgnoreCase("here")))
      unlockThis = R;
    if (unlockThis == null)
      unlockThis = getAnyTarget(mob, commands, givenTarget, Wearable.FILTER_UNWORNONLY);
    if (unlockThis == null) return false;
    int oldProficiency = proficiency();

    if (!super.invoke(mob, commands, givenTarget, auto, asLevel)) return false;

    boolean success =
        proficiencyCheck(
            mob,
            +(((mob.phyStats().level() + (getXLEVELLevel(mob) * 2)) - unlockThis.phyStats().level())
                * 3),
            auto);
    Vector<Physical> permSetV = new Vector<Physical>();
    Trap theTrap = CMLib.utensils().fetchMyTrap(unlockThis);
    if (theTrap != null) permSetV.addElement(unlockThis);
    Trap opTrap = null;
    boolean permanent = false;
    if ((unlockThis instanceof Room) && (CMLib.law().doesOwnThisProperty(mob, ((Room) unlockThis))))
      permanent = true;
    else if (unlockThis instanceof Exit) {
      Room R2 = null;
      if (dirCode < 0)
        for (int d = Directions.NUM_DIRECTIONS() - 1; d >= 0; d--)
          if (R.getExitInDir(d) == unlockThis) {
            dirCode = d;
            R2 = R.getRoomInDir(d);
            break;
          }
      if ((CMLib.law().doesOwnThisProperty(mob, R))
          || ((R2 != null) && (CMLib.law().doesOwnThisProperty(mob, R2)))) permanent = true;
      if (dirCode >= 0) {
        Exit exit = R.getReverseExit(dirCode);
        if (exit != null) opTrap = CMLib.utensils().fetchMyTrap(exit);
        if (opTrap != null) permSetV.addElement(exit);
        Trap roomTrap = null;
        if (nextRoom != null) roomTrap = CMLib.utensils().fetchMyTrap(nextRoom);
        if (roomTrap != null) permSetV.addElement(nextRoom);
        if ((theTrap != null) && (theTrap.disabled()) && (roomTrap != null)) {
          opTrap = null;
          unlockThis = nextRoom;
          theTrap = roomTrap;
        }
      }
    }
    if (unlockThis == null) {
      mob.tell("You can't seem to remember how this works.");
      return false;
    }
    CMMsg msg =
        CMClass.getMsg(
            mob,
            unlockThis,
            this,
            auto ? CMMsg.MSG_OK_ACTION : CMMsg.MSG_DELICATE_HANDS_ACT,
            CMMsg.MSG_DELICATE_HANDS_ACT,
            CMMsg.MSG_OK_ACTION,
            auto
                ? unlockThis.name() + " begins to glow."
                : "<S-NAME> attempt(s) to safely deactivate a trap on " + unlockThis.name() + ".");
    if ((success) && (!lastDone.contains("" + unlockThis))) {
      while (lastDone.size() > 40) lastDone.removeElementAt(0);
      lastDone.addElement("" + unlockThis);
      msg.setValue(1);
    } else msg.setValue(0);
    if (R.okMessage(mob, msg)) {
      R.send(mob, msg);
      if ((unlockThis == lastChecked) && ((theTrap == null) || (theTrap.disabled())))
        setProficiency(oldProficiency);
      if (success) {
        if (theTrap != null) {
          theTrap.disable();
          if (saveTheTrap) commands.addElement(theTrap);
        }
        if (opTrap != null) {
          opTrap.disable();
          if (saveTheTrap) commands.addElement(opTrap);
        }
        if (permanent) {
          for (int i = 0; i < permSetV.size(); i++) {
            if (theTrap != null) {
              theTrap.unInvoke();
              ((Physical) permSetV.elementAt(i)).delEffect(theTrap);
            }
            if (opTrap != null) {
              opTrap.unInvoke();
              ((Physical) permSetV.elementAt(i)).delEffect(opTrap);
            }
          }
          CMLib.database().DBUpdateRoom(R);
          CMLib.database().DBUpdateExits(R);
        }
      }
      if ((!auto) && (!saveTheTrap)) mob.tell("You have completed your attempt.");
      lastChecked = unlockThis;
    }

    return success;
  }
예제 #15
0
  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;
  }
예제 #16
0
  public boolean invoke(MOB mob, Vector commands, Physical 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()
              .plus(TrackingLibrary.TrackingFlag.OPENONLY)
              .plus(TrackingLibrary.TrackingFlag.AREAONLY)
              .plus(TrackingLibrary.TrackingFlag.NOEMPTYGRIDS)
              .plus(TrackingLibrary.TrackingFlag.NOAIR)
              .plus(TrackingLibrary.TrackingFlag.NOWATER);
      List<Room> V =
          CMLib.tracking().getRadiantRooms(target, flags, 50 + (2 * getXLEVELLevel(mob)));
      Room R = null;
      int v = 0;
      for (; v < V.size(); v++) {
        R = (Room) V.get(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, new XVector(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;
  }
예제 #17
0
  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));
  }
예제 #18
0
  @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;
  }
예제 #19
0
  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;
  }
예제 #20
0
  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;
  }