Пример #1
0
  @Override
  public boolean tick(Tickable ticking, int tickID) {
    super.tick(ticking, tickID);
    if ((canAct(ticking, tickID)) && (ticking instanceof MOB)) {
      if (DoneEquipping) return true;

      final MOB mob = (MOB) ticking;
      final Room thisRoom = mob.location();
      if (thisRoom.numItems() == 0) return true;

      DoneEquipping = true;
      final Vector<Item> stuffIHad = new Vector<Item>();
      for (int i = 0; i < mob.numItems(); i++) stuffIHad.addElement(mob.getItem(i));
      mob.enqueCommand(new XVector<String>("GET", "ALL"), MUDCmdProcessor.METAFLAG_FORCED, 0);
      Item I = null;
      final Vector<Item> dropThisStuff = new Vector<Item>();
      for (int i = 0; i < mob.numItems(); i++) {
        I = mob.getItem(i);
        if ((I != null) && (!stuffIHad.contains(I))) {
          if (I instanceof DeadBody) dropThisStuff.addElement(I);
          else if ((I.container() != null) && (I.container() instanceof DeadBody))
            I.setContainer(null);
        }
      }
      for (int d = 0; d < dropThisStuff.size(); d++)
        mob.enqueCommand(
            new XVector<String>("DROP", "$" + dropThisStuff.elementAt(d).Name() + "$"),
            MUDCmdProcessor.METAFLAG_FORCED,
            0);
      mob.enqueCommand(new XVector<String>("WEAR", "ALL"), MUDCmdProcessor.METAFLAG_FORCED, 0);
    }
    return true;
  }
Пример #2
0
  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();
    }
  }
Пример #3
0
  @Override
  public boolean invoke(MOB mob, Vector commands, Physical givenTarget, boolean auto, int asLevel) {
    if ((!auto) && (!(CMLib.flags().isGood(mob)))) {
      mob.tell(L("Your alignment has alienated you from your god."));
      return false;
    }
    final List<String> V = new Vector<String>();
    if (commands.size() > 0) {
      V.add((String) commands.elementAt(0));
      commands.removeElementAt(0);
    }

    final MOB target = getTarget(mob, V, givenTarget);
    if (target == null) return false;

    if (commands.size() == 0) {
      if (mob.isMonster()) commands.addElement("FLEE");
      else {
        if (V.size() > 0) mob.tell(L("Command @x1 to do what?", V.get(0)));
        return false;
      }
    }

    if (!target.charStats().getMyRace().racialCategory().equals("Equine")) {
      mob.tell(L("@x1 is not a horse!", target.name(mob)));
      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,
              target,
              this,
              verbalSpeakCode(mob, target, auto),
              auto
                  ? ""
                  : L(
                      "^S<S-NAME> command(s) <T-NAMESELF> to '@x1'.^?",
                      CMParms.combine(commands, 0)));
      final CMMsg msg2 =
          CMClass.getMsg(
              mob,
              target,
              this,
              CMMsg.MASK_MALICIOUS
                  | CMMsg.MASK_SOUND
                  | CMMsg.TYP_MIND
                  | (auto ? CMMsg.MASK_ALWAYS : 0),
              null);
      final CMMsg omsg = CMClass.getMsg(mob, target, null, CMMsg.MSG_ORDER, null);
      if ((mob.location().okMessage(mob, msg))
          && ((mob.location().okMessage(mob, msg2)))
          && (mob.location().okMessage(mob, omsg))) {
        mob.location().send(mob, msg);
        if (msg.value() <= 0) {
          mob.location().send(mob, msg2);
          mob.location().send(mob, omsg);
          if ((msg2.value() <= 0) && (omsg.sourceMinor() == CMMsg.TYP_ORDER)) {
            invoker = mob;
            target.makePeace();
            target.enqueCommand(commands, Command.METAFLAG_FORCED | Command.METAFLAG_ORDER, 0);
          }
        }
      }
    } else
      return maliciousFizzle(
          mob,
          target,
          L("<S-NAME> attempt(s) to command <T-NAMESELF>, but it definitely didn't work."));

    // return whether it worked
    return success;
  }