Exemplo n.º 1
0
  @Override
  public void executeMsg(Environmental affecting, CMMsg msg) {
    super.executeMsg(affecting, msg);
    final MOB source = msg.source();
    if (!canFreelyBehaveNormal(affecting)) return;
    final MOB observer = (MOB) affecting;

    if ((source != observer)
        && (msg.amITarget(observer))
        && (msg.targetMinor() == CMMsg.TYP_GIVE)
        && (msg.tool() instanceof Coins)) {
      if ((CMLib.flags().canBeSeenBy(source, observer))
          && (CMLib.flags().canBeSeenBy(observer, source))) {
        double value = ((Coins) msg.tool()).getTotalValue();
        final String currency = ((Coins) msg.tool()).getCurrency().toUpperCase();
        double takeCut = getMyCut(affecting, currency);
        double amountToTake = CMLib.beanCounter().abbreviatedRePrice(observer, value * takeCut);
        if ((amountToTake > 0.0)
            && (amountToTake
                < CMLib.beanCounter()
                    .getLowestDenomination(CMLib.beanCounter().getCurrency(observer))))
          amountToTake =
              CMLib.beanCounter().getLowestDenomination(CMLib.beanCounter().getCurrency(observer));
        value -= amountToTake;
        observer.recoverPhyStats();
        final Coins C = CMLib.beanCounter().makeBestCurrency(observer, value);
        if ((value > 0.0) && (C != null)) {
          // this message will actually end up triggering the hand-over.
          final CMMsg newMsg =
              CMClass.getMsg(
                  observer,
                  source,
                  C,
                  CMMsg.MSG_SPEAK,
                  L("^T<S-NAME> say(s) 'Thank you for your business' to <T-NAMESELF>.^?"));
          C.setOwner(observer);
          final long num = C.getNumberOfCoins();
          final String curr = C.getCurrency();
          final double denom = C.getDenomination();
          C.destroy();
          C.setNumberOfCoins(num);
          C.setCurrency(curr);
          C.setDenomination(denom);
          msg.addTrailerMsg(newMsg);
        } else CMLib.commands().postSay(observer, source, L("Gee, thanks. :)"), true, false);
        ((Coins) msg.tool()).destroy();
      } else if (!CMLib.flags().canBeSeenBy(source, observer))
        CMLib.commands()
            .postSay(observer, null, L("Wha?  Where did this come from?  Cool!"), true, false);
    } else if ((msg.source() == observer)
        && (msg.target() instanceof MOB)
        && (msg.targetMinor() == CMMsg.TYP_SPEAK)
        && (msg.tool() instanceof Coins)
        && (((Coins) msg.tool()).amDestroyed())
        && (!msg.source().isMine(msg.tool()))
        && (!((MOB) msg.target()).isMine(msg.tool())))
      CMLib.beanCounter()
          .giveSomeoneMoney(msg.source(), (MOB) msg.target(), ((Coins) msg.tool()).getTotalValue());
  }
Exemplo n.º 2
0
 @Override
 public boolean okMessage(Environmental affecting, CMMsg msg) {
   if (!super.okMessage(affecting, msg)) return false;
   final MOB source = msg.source();
   if (!canFreelyBehaveNormal(affecting)) return true;
   final MOB observer = (MOB) affecting;
   if ((source != observer)
       && (msg.amITarget(observer))
       && (msg.targetMinor() == CMMsg.TYP_GIVE)
       && (!CMSecurity.isAllowed(source, source.location(), CMSecurity.SecFlag.CMDROOMS))
       && (msg.tool() != null)) {
     if (!(msg.tool() instanceof Coins)) {
       CMLib.commands()
           .postSay(observer, source, L("I'm sorry, I can only accept money."), true, false);
       return false;
     } else if (!doIExchangeThisCurrency(affecting, ((Coins) msg.tool()).getCurrency())) {
       CMLib.commands()
           .postSay(
               observer,
               source,
               L("I'm sorry, I don't accept that kind of currency."),
               true,
               false);
       return false;
     }
     double value = ((Coins) msg.tool()).getTotalValue();
     final String currency = ((Coins) msg.tool()).getCurrency().toUpperCase();
     double takeCut = getMyCut(affecting, currency);
     double amountToTake = CMLib.beanCounter().abbreviatedRePrice(observer, value * takeCut);
     if ((amountToTake > 0.0)
         && (amountToTake
             < CMLib.beanCounter()
                 .getLowestDenomination(CMLib.beanCounter().getCurrency(observer))))
       amountToTake =
           CMLib.beanCounter().getLowestDenomination(CMLib.beanCounter().getCurrency(observer));
     value -= amountToTake;
     observer.recoverPhyStats();
     final Coins C = CMLib.beanCounter().makeBestCurrency(observer, value);
     if ((value <= 0) || (C == null)) {
       CMLib.commands()
           .postSay(
               observer,
               source,
               L("I'm sorry, I can not change such a small amount."),
               true,
               false);
       return false;
     }
   }
   return true;
 }
Exemplo n.º 3
0
  @Override
  public boolean okMessage(final Environmental myHost, final CMMsg msg) {
    if (!super.okMessage(myHost, msg)) return false;

    final MOB mob = msg.source();
    if (mob.location() == null) return true;

    if (msg.amITarget(this))
      switch (msg.targetMinor()) {
        case CMMsg.TYP_HOLD:
        case CMMsg.TYP_WEAR:
        case CMMsg.TYP_WIELD:
        case CMMsg.TYP_GET:
          if ((!msg.source().charStats().getCurrentClass().ID().equals("Paladin"))
              || (!CMLib.flags().isGood(msg.source()))) {
            unWear();
            mob.location()
                .show(
                    mob,
                    null,
                    CMMsg.MSG_OK_ACTION,
                    L("@x1 flashes and flies out of <S-HIS-HER> hands!", name()));
            if (msg.source().isMine(this))
              CMLib.commands().postDrop(msg.source(), this, true, false, false);
            return false;
          }
          break;
        default:
          break;
      }
    return true;
  }
Exemplo n.º 4
0
  public boolean tick(Tickable ticking, int tickID) {
    if (!(affected instanceof MOB)) return false;

    if (invoker == null) return false;

    MOB mob = (MOB) affected;
    if (clan2Set == null) {
      if (clan2 == null) return super.tick(ticking, tickID);
      Vector<Pair<Clan, Integer>> V = new Vector<Pair<Clan, Integer>>();
      V.add(new Pair<Clan, Integer>(clan2, Integer.valueOf(clan2.getGovernment().getAcceptPos())));
      clan2Set = V;
    }
    List<String> channels =
        CMLib.channels().getFlaggedChannelNames(ChannelsLibrary.ChannelFlag.CLANINFO);
    for (int i = 0; i < channels.size(); i++)
      CMLib.commands()
          .postChannel(
              channels.get(i),
              clan2Set,
              mob.name()
                  + " located in '"
                  + mob.location().displayText(mob)
                  + "' is performing a peace ritual on behalf of "
                  + clan1.name()
                  + ".",
              false);
    return super.tick(ticking, tickID);
  }
Exemplo n.º 5
0
  public void unInvoke() {
    // undo the affects of this spell
    if (!(affected instanceof MOB)) return;
    super.unInvoke();

    if ((canBeUninvoked()) && (clan1 != null) && (clan2 != null)) {
      final Clan C1 = clan1;
      final Clan C2 = clan2;
      if ((C1 != null) && (C2 != null)) {
        if (C1.getClanRelations(C2.clanID()) == Clan.REL_WAR) {
          C1.setClanRelations(C2.clanID(), Clan.REL_HOSTILE, System.currentTimeMillis());
          C1.update();
        }
        if (C2.getClanRelations(C1.clanID()) == Clan.REL_WAR) {
          C2.setClanRelations(C1.clanID(), Clan.REL_HOSTILE, System.currentTimeMillis());
          C2.update();
        }
        List<String> channels =
            CMLib.channels().getFlaggedChannelNames(ChannelsLibrary.ChannelFlag.CLANINFO);
        for (int i = 0; i < channels.size(); i++)
          CMLib.commands()
              .postChannel(
                  channels.get(i),
                  CMLib.clans().clanRoles(),
                  "There is now peace between " + C1.name() + " and " + C2.name() + ".",
                  false);
      }
    }
  }
Exemplo n.º 6
0
 @Override
 public boolean tick(Tickable ticking, int tickID) {
   if ((affecting() == null) || (!(affecting() instanceof MOB))) return false;
   final MOB mob = (MOB) affecting();
   if ((affected == mob)
       && (mob != getCharmer())
       && ((mob.amFollowing() == null) || (mob.amFollowing() != getCharmer()))
       && (mob.location() != null)
       && (mob.location().isInhabitant(getCharmer())))
     CMLib.commands().postFollow(mob, getCharmer(), true);
   return super.tick(ticking, tickID);
 }
Exemplo n.º 7
0
  public boolean invoke(MOB mob, Vector commands, Physical givenTarget, boolean auto, int asLevel) {
    MOB target = this.getTarget(mob, commands, givenTarget);
    if (target == null) return false;
    Room R = CMLib.map().roomLocation(target);
    if (R == null) R = mob.location();

    if (!CMLib.flags().isAnimalIntelligence(target)) {
      mob.tell(target.name(mob) + " is not an animal!");
      return false;
    }

    // the invoke method for spells receives as
    // parameters the invoker, and the REMAINING
    // command line parameters, divided into words,
    // and added as String objects to a vector.
    if (!super.invoke(mob, commands, givenTarget, auto, asLevel)) return false;

    // now see if it worked
    boolean success = proficiencyCheck(mob, 0, auto);
    if (success) {
      // it worked, so build a copy of this ability,
      // and add it to the affects list of the
      // affected MOB. Then tell everyone else
      // what happened.
      String str = auto ? "" : "^S<S-NAME> chant(s) at <T-NAMESELF>.^?";
      CMMsg msg = CMClass.getMsg(mob, target, this, verbalCastCode(mob, target, auto), str);
      if (R.okMessage(mob, msg)) {
        R.send(mob, msg);
        if (msg.value() <= 0) {
          success =
              maliciousAffect(
                  mob,
                  target,
                  asLevel,
                  0,
                  CMMsg.MSK_CAST_VERBAL | CMMsg.TYP_MIND | (auto ? CMMsg.MASK_ALWAYS : 0));
          if (success) {
            if (target.isInCombat()) target.makePeace();
            CMLib.commands().postFollow(target, mob, false);
            CMLib.combat().makePeaceInGroup(mob);
            if (target.amFollowing() != mob)
              mob.tell(target.name(mob) + " seems unwilling to follow you.");
          }
        }
      }
    }
    if (!success)
      return maliciousFizzle(
          mob, target, "<S-NAME> chant(s) at <T-NAMESELF>, but nothing happens.");

    // return whether it worked
    return success;
  }
Exemplo n.º 8
0
 @Override
 public boolean tick(Tickable ticking, int tickID) {
   Item I = null;
   if (affected instanceof Item) I = (Item) affected;
   if ((canBeUninvoked())
       && (I != null)
       && (I.owner() instanceof MOB)
       && (I.amWearingAt(Wearable.WORN_NECK))) {
     final MOB mob = (MOB) I.owner();
     if ((!mob.amDead()) && (mob.isMonster()) && (CMLib.flags().isInTheGame(mob, false)))
       CMLib.commands().postRemove(mob, I, false);
   }
   return super.tick(ticking, tickID);
 }
Exemplo n.º 9
0
  public void unInvoke() {
    // undo the affects of this spell
    if (!(affected instanceof MOB)) return;
    MOB mob = (MOB) affected;

    super.unInvoke();

    if ((canBeUninvoked() && (!mob.amDead()))) {
      mob.location().show(mob, null, CMMsg.MSG_OK_VISUAL, "<S-YOUPOSS> natural-will returns.");
      if (mob.amFollowing() != null) CMLib.commands().postFollow(mob, null, false);
      CMLib.commands().postStand(mob, true);
      if (mob.isMonster()) {
        if ((CMLib.dice().rollPercentage() > 50)
            || ((mob.getStartRoom() != null)
                && (mob.getStartRoom().getArea() != mob.location().getArea())
                && (CMLib.flags().isAggressiveTo(mob, null)
                    || (invoker == null)
                    || (!mob.location().isInhabitant(invoker)))))
          CMLib.tracking().wanderAway(mob, true, true);
        else if ((invoker != null) && (invoker != mob)) mob.setVictim(invoker);
      }
    }
  }
Exemplo n.º 10
0
  @Override
  public boolean invoke(MOB mob, Vector commands, Physical givenTarget, boolean auto, int asLevel) {
    final MOB target = this.getTarget(mob, commands, givenTarget);
    if (target == null) return false;

    if ((!target.charStats().getMyRace().racialCategory().equals("Earth Elemental"))
        && (!target.charStats().getMyRace().racialCategory().equals("Stone Golem"))
        && (!target.charStats().getMyRace().racialCategory().equals("Metal Golem"))) {
      mob.tell(L("@x1 is not an stone/metal golem or earth elemental!", target.name(mob)));
      return false;
    }

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

    // now see if it worked
    boolean success = proficiencyCheck(mob, 0, auto);
    if (success) {
      final String str = auto ? "" : L("^S<S-NAME> chant(s) at <T-NAMESELF>.^?");
      final CMMsg msg = CMClass.getMsg(mob, target, this, verbalCastCode(mob, target, auto), str);
      if (mob.location().okMessage(mob, msg)) {
        mob.location().send(mob, msg);
        if (msg.value() <= 0) {
          success = maliciousAffect(mob, target, asLevel, 0, -1) != null;
          if (success) {
            if (target.isInCombat()) target.makePeace();
            CMLib.commands().postFollow(target, mob, false);
            CMLib.combat().makePeaceInGroup(mob);
            if (target.amFollowing() != mob)
              mob.tell(L("@x1 seems unwilling to follow you.", target.name(mob)));
          }
        }
      }
    }
    if (!success)
      return maliciousFizzle(
          mob, target, L("<S-NAME> chant(s) at <T-NAMESELF>, but nothing happens."));

    // return whether it worked
    return success;
  }
Exemplo n.º 11
0
 public void finishSpringing(MOB target) {
   if ((!invoker().mayIFight(target)) || (target.phyStats().weight() < 5))
     target
         .location()
         .show(target, null, CMMsg.MSG_OK_ACTION, "<S-NAME> float(s) gently into the pit!");
   else {
     target.location().show(target, null, CMMsg.MSG_OK_ACTION, "<S-NAME> hit(s) the pit floor!");
     int damage = CMLib.dice().roll(trapLevel() + abilityCode(), 6, 1);
     if ((daggerDamages != null) && (daggerDamages.size() > 0)) {
       for (int i = 0; i < daggerDamages.size(); i++)
         damage += CMLib.dice().roll(1, ((Integer) daggerDamages.elementAt(i)).intValue(), 0);
     } else damage += CMLib.dice().roll(5, 4, 0);
     CMLib.combat()
         .postDamage(
             invoker(),
             target,
             this,
             damage,
             CMMsg.MASK_MALICIOUS | CMMsg.MASK_ALWAYS | CMMsg.TYP_JUSTICE,
             Weapon.TYPE_PIERCING,
             "Spikes on the pit floor <DAMAGE> <T-NAME>!");
   }
   CMLib.commands().postLook(target, true);
 }
Exemplo n.º 12
0
  @Override
  public boolean invoke(
      MOB mob, List<String> commands, Physical givenTarget, boolean auto, int asLevel) {
    final MOB target = this.getTarget(mob, commands, givenTarget);
    if (target == null) return false;

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

    int levelDiff =
        target.phyStats().level() - (mob.phyStats().level() + (2 * getXLEVELLevel(mob)));
    if (levelDiff < 0) levelDiff = 0;
    final boolean success = proficiencyCheck(mob, -(levelDiff * 25), auto);
    Item Bread = null;
    Item BreadContainer = null;
    for (int i = 0; i < target.numItems(); i++) {
      final Item I = target.getItem(i);
      if ((I != null) && (I instanceof Food)) {
        if (I.container() != null) {
          Bread = I;
          BreadContainer = I.container();
        } else {
          Bread = I;
          BreadContainer = null;
          break;
        }
      }
    }
    if ((Bread != null) && (BreadContainer != null))
      CMLib.commands().postGet(target, BreadContainer, Bread, false);
    if (Bread == null) {
      final ShopKeeper SK = CMLib.coffeeShops().getShopKeeper(target);
      if (SK != null) {
        for (final Iterator<Environmental> i = SK.getShop().getStoreInventory(); i.hasNext(); ) {
          final Environmental E2 = i.next();
          if ((E2 != null) && (E2 instanceof Food)) {
            Bread = (Item) E2.copyOf();
            target.addItem(Bread);
            break;
          }
        }
      }
    }
    if ((success) && (Bread != null)) {
      CMMsg msg =
          CMClass.getMsg(
              mob,
              target,
              this,
              verbalCastCode(mob, target, auto),
              L(
                  "^S<S-NAME> @x1 for <T-NAMESELF> to provide <S-HIS-HER> daily bread!^?",
                  prayWord(mob)));
      final CMMsg msg2 =
          CMClass.getMsg(
              mob,
              target,
              this,
              CMMsg.MSK_CAST_MALICIOUS_VERBAL | CMMsg.TYP_MIND | (auto ? CMMsg.MASK_ALWAYS : 0),
              null);
      if ((mob.location().okMessage(mob, msg)) && (mob.location().okMessage(mob, msg2))) {
        mob.location().send(mob, msg);
        mob.location().send(mob, msg2);
        if ((msg.value() <= 0) && (msg2.value() <= 0)) {
          msg =
              CMClass.getMsg(
                  target,
                  mob,
                  Bread,
                  CMMsg.MSG_GIVE,
                  L("<S-NAME> gladly donate(s) <O-NAME> to <T-NAMESELF>."));
          if (mob.location().okMessage(mob, msg)) mob.location().send(mob, msg);
        }
      }
    } else
      maliciousFizzle(
          mob,
          target,
          auto
              ? ""
              : L(
                  "<S-NAME> @x1 for <T-NAMESELF> to provide <S-HIS-HER> daily bread, but nothing happens.",
                  prayWord(mob)));

    // return whether it worked
    return success;
  }
Exemplo n.º 13
0
  @Override
  public boolean invoke(
      MOB mob, List<String> commands, Physical givenTarget, boolean auto, int asLevel) {
    if (!mob.clans().iterator().hasNext()) {
      mob.tell(L("You aren't even a member of a clan."));
      return false;
    }
    final Pair<Clan, Integer> clanPair =
        CMLib.clans().findPrivilegedClan(mob, Clan.Function.CLAN_BENEFITS);
    if (clanPair == null) {
      mob.tell(L("You are not authorized to draw from the power of your clan."));
      return false;
    }
    final Clan C = clanPair.first;
    Room clanHomeRoom = null;
    clanHomeRoom = CMLib.map().getRoom(C.getRecall());
    if (clanHomeRoom == null) {
      mob.tell(L("Your clan does not have a clan home."));
      return false;
    }
    if (!CMLib.flags().canAccess(mob, clanHomeRoom)) {
      mob.tell(L("You can't use this magic to get there from here."));
      return false;
    }
    if (!CMLib.law().doesOwnThisProperty(C.clanID(), clanHomeRoom)) {
      mob.tell(L("Your clan no longer owns that room."));
      return false;
    }

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

    final boolean success = proficiencyCheck(mob, 0, auto);

    if (success) {
      final CMMsg msg =
          CMClass.getMsg(
              mob,
              null,
              this,
              CMMsg.MASK_MOVE | verbalCastCode(mob, mob, auto),
              L("^S<S-NAME> invoke(s) a teleportation spell.^?"));
      if (mob.location().okMessage(mob, msg)) {
        mob.location().send(mob, msg);
        final Set<MOB> h = properTargets(mob, givenTarget, false);
        if (h == null) return false;

        final Room thisRoom = mob.location();
        for (final Object element : h) {
          final MOB follower = (MOB) element;
          final CMMsg enterMsg =
              CMClass.getMsg(
                  follower,
                  clanHomeRoom,
                  this,
                  CMMsg.MSG_ENTER,
                  null,
                  CMMsg.MSG_ENTER,
                  null,
                  CMMsg.MSG_ENTER,
                  L("<S-NAME> appears in a puff of red smoke."));
          final CMMsg leaveMsg =
              CMClass.getMsg(
                  follower,
                  thisRoom,
                  this,
                  CMMsg.MSG_LEAVE | CMMsg.MASK_MAGIC,
                  L("<S-NAME> disappear(s) in a puff of red smoke."));
          if (thisRoom.okMessage(follower, leaveMsg)
              && clanHomeRoom.okMessage(follower, enterMsg)) {
            if (follower.isInCombat()) {
              CMLib.commands().postFlee(follower, ("NOWHERE"));
              follower.makePeace(false);
            }
            thisRoom.send(follower, leaveMsg);
            clanHomeRoom.bringMobHere(follower, false);
            clanHomeRoom.send(follower, enterMsg);
            follower.tell(L("\n\r\n\r"));
            CMLib.commands().postLook(follower, true);
          }
        }
      }

    } else
      beneficialWordsFizzle(
          mob, null, L("<S-NAME> attempt(s) to invoke transportation, but fizzle(s) the spell."));

    // return whether it worked
    return success;
  }
Exemplo n.º 14
0
  public boolean invoke(MOB mob, Vector commands, Physical givenTarget, boolean auto, int asLevel) {
    MOB target = this.getTarget(mob, commands, givenTarget);
    if (target == null) return false;

    if ((target.baseCharStats().getMyRace() == null)
        || (!target.baseCharStats().getMyRace().racialCategory().equals("Undead"))) {
      mob.tell(auto ? "Only the undead can be turned." : "You can only turn the undead.");
      return false;
    }

    if (CMLib.flags().isEvil(mob)) {
      mob.tell("Only the riteous may turn the undead.");
      return false;
    }

    // the invoke method for spells receives as
    // parameters the invoker, and the REMAINING
    // command line parameters, divided into words,
    // and added as String objects to a vector.
    if (!super.invoke(mob, commands, givenTarget, auto, asLevel)) return false;

    boolean success =
        proficiencyCheck(
            mob,
            ((mob.phyStats().level() + (4 * getXLEVELLevel(mob))) - target.phyStats().level()) * 30,
            auto);

    if (success) {
      // it worked, so build a copy of this ability,
      // and add it to the affects list of the
      // affected MOB. Then tell everyone else
      // what happened.
      CMMsg msg =
          CMClass.getMsg(
              mob,
              target,
              this,
              CMMsg.MSG_CAST_ATTACK_SOMANTIC_SPELL | (auto ? CMMsg.MASK_ALWAYS : 0),
              auto ? "<T-NAME> turn(s) away." : "^S<S-NAME> turn(s) <T-NAMESELF>.^?");
      if (mob.location().okMessage(mob, msg)) {
        mob.location().send(mob, msg);
        if (msg.value() <= 0) {
          if ((mob.phyStats().level() - target.phyStats().level()) > 6) {
            mob.location()
                .show(
                    mob,
                    target,
                    CMMsg.MSG_OK_ACTION,
                    "<T-NAME> wither(s)" + (auto ? "." : " under <S-HIS-HER> holy power!"));
            CMLib.combat()
                .postDamage(
                    mob,
                    target,
                    this,
                    target.curState().getHitPoints(),
                    CMMsg.MASK_ALWAYS | CMMsg.TYP_CAST_SPELL,
                    -1,
                    null);
          } else {
            mob.location().show(target, null, CMMsg.MSG_OK_VISUAL, "<S-NAME> shake(s) in fear!");
            CMLib.commands().postFlee(target, "");
          }
          invoker = mob;
        }
      }
    } else
      return maliciousFizzle(mob, target, "<S-NAME> attempt(s) to turn <T-NAMESELF>, but fail(s).");

    // return whether it worked
    return success;
  }
Exemplo n.º 15
0
  @Override
  public boolean invoke(MOB mob, Vector commands, Physical givenTarget, boolean auto, int asLevel) {

    if ((auto || mob.isMonster())
        && ((commands.size() < 1) || (((String) commands.firstElement()).equals(mob.name())))) {
      commands.clear();
      if (mob.numItems() > 0) commands.addElement(mob.getRandomItem());
      commands.addElement(CMLib.map().getRandomArea().Name());
    }
    final Room oldRoom = mob.location();
    if (commands.size() < 2) {
      mob.tell(L("Teleport what object to what place or person?"));
      return false;
    }
    final String objectName = (String) commands.firstElement();
    final Item target = mob.findItem(null, objectName);
    if (target == null) {
      mob.tell(L("You don't seem to have an item '@x1'.", objectName));
      return false;
    }
    if (target.amWearingAt(Wearable.IN_INVENTORY)) {
      mob.tell(L("You seem to be wearing or holding the item '@x1'.", objectName));
      return false;
    }
    String searchWhat = null;
    if (commands.size() > 2) {
      final String s = (String) commands.elementAt(1);
      if (s.equalsIgnoreCase("room")) searchWhat = "R";
      if (s.equalsIgnoreCase("area")) searchWhat = "E";
      if (s.equalsIgnoreCase("mob")) searchWhat = "M";
      if (s.equalsIgnoreCase("monster")) searchWhat = "M";
      if (s.equalsIgnoreCase("player")) searchWhat = "P";
      if (s.equalsIgnoreCase("user")) searchWhat = "P";
      if (s.equalsIgnoreCase("item")) searchWhat = "I";
      if (s.equalsIgnoreCase("object")) searchWhat = "I";
      if (searchWhat != null) commands.removeElementAt(1);
    }
    if (searchWhat == null) searchWhat = "ERIPM";
    final String destinationString = CMParms.combine(commands, 1).trim().toUpperCase();
    final List<Room> candidates =
        CMLib.map().findWorldRoomsLiberally(mob, destinationString, searchWhat, 10, 600000);
    if (candidates.size() == 0) {
      mob.tell(L("You don't know of a place called '@x1'.", destinationString.toLowerCase()));
      return false;
    }

    if (CMLib.flags().isSitting(mob) || CMLib.flags().isSleeping(mob)) {
      mob.tell(L("You need to stand up!"));
      return false;
    }

    Room newRoom = null;
    int tries = 0;
    while ((tries < 20) && (newRoom == null)) {
      newRoom = candidates.get(CMLib.dice().roll(1, candidates.size(), -1));
      if (((newRoom.roomID().length() == 0) && (CMLib.dice().rollPercentage() > 50))
          || ((newRoom.domainType() == Room.DOMAIN_OUTDOORS_AIR)
              && (CMLib.dice().rollPercentage() > 10))) {
        newRoom = null;
        continue;
      }
      final CMMsg enterMsg =
          CMClass.getMsg(
              mob,
              newRoom,
              null,
              CMMsg.MSG_ENTER,
              null,
              CMMsg.MSG_ENTER,
              null,
              CMMsg.MSG_ENTER,
              null);
      if (!newRoom.okMessage(mob, enterMsg)) newRoom = null;
      tries++;
    }

    if ((newRoom == null) || (newRoom == oldRoom)) {
      mob.tell(L("Your magic seems unable to send anything there."));
      return false;
    }

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

    boolean success = proficiencyCheck(mob, 0, auto);

    final CMMsg msg =
        CMClass.getMsg(
            mob,
            target,
            this,
            somanticCastCode(mob, target, auto),
            L("^S<S-NAME> invoke(s) a teleportation spell upon <T-NAME>.^?"));
    if (oldRoom.okMessage(mob, msg)) {
      oldRoom.send(mob, msg);
      newRoom.bringMobHere(mob, false);
      target.unWear();
      success = CMLib.commands().postDrop(mob, target, true, false, false) && (!mob.isMine(target));
      oldRoom.bringMobHere(mob, false);
      if (success) {
        oldRoom.show(mob, target, null, CMMsg.MSG_OK_VISUAL, L("<T-NAME> vanishes!"));
        newRoom.showOthers(
            mob, target, null, CMMsg.MSG_OK_VISUAL, L("<T-NAME> appear(s) out of nowhere!"));
      } else mob.tell(L("Nothing happens."));
    }
    // return whether it worked
    return success;
  }