Пример #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 boolean invoke(MOB mob, Vector commands, Physical givenTarget, boolean auto, int asLevel) {
    if (commands != null) commands = new XVector(commands);
    if (!conCheck(mob, commands, givenTarget, auto, asLevel)) return false;
    Vector V = new Vector();
    V.addElement(commands.elementAt(0));
    MOB target = this.getTarget(mob, V, givenTarget);
    if (target == null) return false;
    commands.removeElementAt(0);

    int oldProficiency = proficiency();

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

    int levelDiff =
        ((mob.phyStats().level() + (2 * super.getXLEVELLevel(mob))) - target.phyStats().level())
            * 10;
    if (levelDiff > 0) levelDiff = 0;
    boolean success =
        proficiencyCheck(
            mob, (mob.charStats().getStat(CharStats.STAT_CHARISMA) * 2) + levelDiff, auto);

    if (!success) {
      CMMsg msg =
          CMClass.getMsg(
              mob,
              target,
              this,
              CMMsg.MSG_SPEAK,
              "^T<S-NAME> tr(ys) to con <T-NAMESELF> to '"
                  + CMParms.combine(commands, 0)
                  + "', but <S-IS-ARE> unsuccessful.^?");
      if (mob.location().okMessage(mob, msg)) mob.location().send(mob, msg);
    } else {
      CMMsg msg =
          CMClass.getMsg(
              mob,
              target,
              this,
              CMMsg.MSG_SPEAK,
              "^T<S-NAME> con(s) <T-NAMESELF> to '" + CMParms.combine(commands, 0) + "'.^?");
      mob.recoverPhyStats();
      CMMsg omsg = CMClass.getMsg(mob, target, null, CMMsg.MSG_ORDER, null);
      if ((mob.location().okMessage(mob, msg)) && (mob.location().okMessage(mob, omsg))) {
        mob.location().send(mob, msg);
        mob.location().send(mob, omsg);
        if (omsg.sourceMinor() == CMMsg.TYP_ORDER)
          target.enqueCommand(commands, Command.METAFLAG_FORCED | Command.METAFLAG_ORDER, 0);
      }
      target.recoverPhyStats();
    }
    if (target == lastChecked) setProficiency(oldProficiency);
    lastChecked = target;
    return success;
  }
Пример #3
0
 protected void initializeAllManaged(MOB affected) {
   if (unmanagedYet.size() == 0) return;
   initializeManagedObjects(affected);
   while (unmanagedYet.size() > 0) {
     Object[] thing = unmanagedYet.removeFirst();
     if (thing[0] instanceof Command) {
       Command C = (Command) thing[0];
       try {
         String cmdparms =
             C.getAccessWords()[0]
                 + " "
                 + CMStrings.replaceAll((String) thing[1], "<TARGET>", reactToM.Name());
         affected.enqueCommand(CMParms.parse(cmdparms), Command.METAFLAG_FORCED, 0);
       } catch (Exception e) {
       }
       managed.add(C);
       continue;
     }
   }
 }
Пример #4
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;
  }