コード例 #1
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;
  }
コード例 #2
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;
  }
コード例 #3
0
ファイル: Thief_Listen.java プロジェクト: Cocanuta/Marble
  public void executeMsg(final Environmental myHost, final CMMsg msg) {
    super.executeMsg(myHost, msg);
    if ((affected != null)
        && (affected instanceof Room)
        && (invoker() != null)
        && (invoker().location() != null)
        && (sourceRoom != null)
        && (!invoker().isInCombat())
        && (invoker().location() == sourceRoom)) {
      if (invoker().location() == room) {
        if ((msg.sourceMinor() == CMMsg.TYP_SPEAK)
            && (msg.othersCode() == CMMsg.NO_EFFECT)
            && (msg.othersMessage() == null)
            && (msg.sourceMessage() != null)
            && (!msg.amISource(invoker()))
            && (!msg.amITarget(invoker()))
            && (!lastSaid.equals(msg.sourceMessage()))) {
          lastSaid = msg.sourceMessage();
          if ((invoker().phyStats().level() + (getXLEVELLevel(invoker()) * 10))
              > msg.source().phyStats().level())
            invoker().tell(msg.source(), msg.target(), msg.tool(), msg.sourceMessage());
          else
            invoker()
                .tell(
                    msg.source(),
                    null,
                    null,
                    "<S-NAME> said something, but you couldn't quite make it out.");
        }
      } else if ((msg.sourceMinor() == CMMsg.TYP_SPEAK)
          && (msg.othersMinor() == CMMsg.TYP_SPEAK)
          && (msg.othersMessage() != null)
          && (msg.sourceMessage() != null)
          && (!lastSaid.equals(msg.sourceMessage()))) {
        lastSaid = msg.sourceMessage();
        if ((invoker().phyStats().level() + (getXLEVELLevel(invoker()) * 10))
            > msg.source().phyStats().level())
          invoker().tell(msg.source(), msg.target(), msg.tool(), msg.sourceMessage());
        else
          invoker()
              .tell(
                  msg.source(),
                  null,
                  null,
                  "<S-NAME> said something, but you couldn't quite make it out.");
      }

    } else unInvoke();
  }
コード例 #4
0
ファイル: Chant_AnimalSpy.java プロジェクト: Cocanuta/Marble
  public void executeMsg(final Environmental myHost, final CMMsg msg) {
    try {
      super.executeMsg(myHost, msg);
      if (spy == null) return;
      if (invoker == null) return;

      if ((msg.amISource(spy))
          && ((msg.sourceMinor() == CMMsg.TYP_LOOK) || (msg.sourceMinor() == CMMsg.TYP_EXAMINE))
          && (msg.target() != null)
          && ((invoker.location() != spy.location()) || (!(msg.target() instanceof Room)))) {
        disable = true;
        CMMsg newAffect = CMClass.getMsg(invoker, msg.target(), msg.sourceMinor(), null);
        msg.target().executeMsg(invoker, newAffect);
      } else if ((!msg.amISource(invoker))
          && (invoker.location() != spy.location())
          && (msg.source().location() == spy.location())
          && (msg.othersCode() != CMMsg.NO_EFFECT)
          && (msg.othersMessage() != null)
          && (!disable)) {
        disable = true;
        invoker.executeMsg(invoker, msg);
      } else if (msg.amISource(invoker)
          && (!disable)
          && (msg.sourceMinor() == CMMsg.TYP_SPEAK)
          && (msg.sourceMessage() != null)
          && ((msg.sourceMajor() & CMMsg.MASK_MAGIC) == 0)) {
        int start = msg.sourceMessage().indexOf("\'");
        int end = msg.sourceMessage().lastIndexOf("\'");
        if ((start > 0) && (end > start)) {
          String msg2 = msg.sourceMessage().substring(start + 1, end).trim();
          if (msg2.length() > 0)
            spy.enqueCommand(CMParms.parse(msg2.trim()), Command.METAFLAG_FORCED, 0);
        }
      }
    } finally {
      disable = false;
      if ((spy != null)
          && ((spy.amFollowing() != invoker)
              || (spy.amDead())
              || (!CMLib.flags().isInTheGame(spy, false))
              || (!CMLib.flags().isInTheGame(invoker, true)))) unInvoke();
    }
  }
コード例 #5
0
ファイル: CoffeeUtensils.java プロジェクト: bbailey/ewok
 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);
   }
 }
コード例 #6
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;
  }