Example #1
0
 @Override
 public void executeMsg(final Environmental myHost, final CMMsg msg) {
   super.executeMsg(myHost, msg);
   if (affected == null) {
     this.unInvoke();
     return;
   }
   if (affected instanceof Item) {
     final Item body = (Item) affected;
     if (msg.amITarget(body)) {
       if ((msg.targetMinor() == CMMsg.TYP_OPEN)
           || (msg.targetMinor() == CMMsg.TYP_GIVE)
           || (msg.targetMinor() == CMMsg.TYP_GET)
           || (msg.targetMinor() == CMMsg.TYP_JUSTICE)
           || (msg.targetMinor() == CMMsg.TYP_GENERAL)
           || (msg.targetMinor() == CMMsg.TYP_LOCK)
           || (msg.targetMinor() == CMMsg.TYP_PULL)
           || (msg.targetMinor() == CMMsg.TYP_PUSH)
           || (msg.targetMinor() == CMMsg.TYP_UNLOCK)) {
         this.spring(msg.source());
         return;
       }
     }
   }
 }
Example #2
0
 @Override
 public void executeMsg(Environmental host, CMMsg msg) {
   super.executeMsg(host, msg);
   if ((affected instanceof Item) && (text().length() > 0)) {
     final Item I = (Item) affected;
     if ((msg.sourceMinor() == CMMsg.TYP_SPEAK)
         && (msg.target() == I)
         && ((msg.source() == I.owner()) || (I.owner() instanceof Room))
         && (msg.sourceMessage() != null)
         && (CMLib.english()
             .containsString(
                 CMStrings.getSayFromMessage(msg.sourceMessage()).toUpperCase(), "REFUGE"))) {
       final Room newRoom = this.getRefuge(I);
       if ((newRoom != null) && (newRoom != msg.source().location())) {
         final Set<MOB> h = properTargets(msg.source(), null, false);
         if (h == null) return;
         final Room thisRoom = msg.source().location();
         final Ability thisA = this;
         msg.addTrailerRunnable(
             new Runnable() {
               @Override
               public void run() {
                 for (final Object element : h) {
                   final MOB follower = (MOB) element;
                   final CMMsg enterMsg =
                       CMClass.getMsg(
                           follower,
                           newRoom,
                           thisA,
                           CMMsg.MSG_ENTER,
                           null,
                           CMMsg.MSG_ENTER,
                           null,
                           CMMsg.MSG_ENTER,
                           L(
                               "<S-NAME> appears in a puff of smoke.@x1",
                               CMLib.protocol().msp("appear.wav", 10)));
                   final CMMsg leaveMsg =
                       CMClass.getMsg(
                           follower,
                           thisRoom,
                           thisA,
                           CMMsg.MSG_LEAVE | CMMsg.MASK_MAGIC,
                           L("<S-NAME> disappear(s) in a puff of smoke."));
                   if (thisRoom.okMessage(follower, leaveMsg)
                       && newRoom.okMessage(follower, enterMsg)) {
                     if (follower.isInCombat()) {
                       CMLib.commands().postFlee(follower, ("NOWHERE"));
                       follower.makePeace();
                     }
                     thisRoom.send(follower, leaveMsg);
                     newRoom.bringMobHere(follower, false);
                     newRoom.send(follower, enterMsg);
                     follower.tell(L("\n\r\n\r"));
                     CMLib.commands().postLook(follower, true);
                   }
                 }
               }
             });
         unInvoke();
       }
     }
   }
 }