Пример #1
0
 @Override
 protected Item buildMyPlant(MOB mob, Room room) {
   final int code = material & RawMaterial.RESOURCE_MASK;
   final Item newItem = CMClass.getBasicItem("GenItem");
   final String name =
       CMLib.english().startWithAorAn(RawMaterial.CODES.NAME(code).toLowerCase() + " tree");
   newItem.setName(name);
   newItem.setDisplayText(L("@x1 grows here.", newItem.name()));
   newItem.setDescription("");
   newItem.basePhyStats().setWeight(10000);
   CMLib.flags().setGettable(newItem, false);
   newItem.setMaterial(material);
   newItem.setSecretIdentity(mob.Name());
   newItem.setMiscText(newItem.text());
   room.addItem(newItem);
   final Chant_SummonTree newChant = new Chant_SummonTree();
   newItem.basePhyStats().setLevel(10 + newChant.getX1Level(mob));
   newItem.setExpirationDate(0);
   room.showHappens(
       CMMsg.MSG_OK_ACTION,
       L("a tall, healthy @x1 tree sprouts up.", RawMaterial.CODES.NAME(code).toLowerCase()));
   room.recoverPhyStats();
   newChant.plantsLocationR = room;
   newChant.littlePlantsI = newItem;
   if (CMLib.law().doesOwnThisLand(mob, room)) {
     newChant.setInvoker(mob);
     newChant.setMiscText(mob.Name());
     newItem.addNonUninvokableEffect(newChant);
   } else newChant.beneficialAffect(mob, newItem, 0, (newChant.adjustedLevel(mob, 0) * 240) + 450);
   room.recoverPhyStats();
   return newItem;
 }
Пример #2
0
  @Override
  public boolean invoke(
      MOB mob, List<String> commands, Physical givenTarget, boolean auto, int asLevel) {
    MOB target = CMLib.players().getLoadPlayer(CMParms.combine(commands, 0));
    if (target == null) target = getTargetAnywhere(mob, commands, givenTarget, false, true, false);
    if (target == null) return false;

    final Archon_Record A = (Archon_Record) target.fetchEffect(ID());
    if (A != null) {
      target.delEffect(A);
      if (target.playerStats() != null) target.playerStats().setLastUpdated(0);
      mob.tell(L("@x1 will no longer be recorded.", target.Name()));
      return true;
    }

    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,
              CMMsg.MASK_MOVE | CMMsg.TYP_JUSTICE | (auto ? CMMsg.MASK_ALWAYS : 0),
              L("^F<S-NAME> begin(s) recording <T-NAMESELF>.^?"));
      CMLib.color().fixSourceFightColor(msg);
      if (mob.location().okMessage(mob, msg)) {
        mob.location().send(mob, msg);
        final String filename = "/" + target.Name() + System.currentTimeMillis() + ".log";
        final CMFile file = new CMFile(filename, null, CMFile.FLAG_LOGERRORS);
        if (!file.canWrite()) {
          if (!CMSecurity.isASysOp(mob) || (CMSecurity.isASysOp(target)))
            Log.sysOut("Record", mob.Name() + " failed to start recording " + target.name() + ".");
        } else {
          if (!CMSecurity.isASysOp(mob) || (CMSecurity.isASysOp(target)))
            Log.sysOut(
                "Record",
                mob.Name() + " started recording " + target.name() + " to /" + filename + ".");
          final Archon_Record A2 = (Archon_Record) copyOf();
          final Session F = (Session) CMClass.getCommon("FakeSession");
          F.initializeSession(null, Thread.currentThread().getThreadGroup().getName(), filename);
          if (target.session() == null) target.setSession(F);
          A2.sess = F;
          target.addNonUninvokableEffect(A2);
          mob.tell(L("Enter RECORD @x1 again to stop recording.", target.Name()));
        }
      }
    } else
      return beneficialVisualFizzle(
          mob, target, L("<S-NAME> attempt(s) to hush <T-NAMESELF>, but fail(s)."));
    return success;
  }
Пример #3
0
 @Override
 public boolean tick(Tickable ticking, int tickID) {
   if (!super.tick(ticking, tickID)) return false;
   if ((tickID == Tickable.TICKID_MOB) && (invoker() != null) && (affected instanceof MOB)) {
     final MOB mob = (MOB) affected;
     final Set<MOB> invokerGroup = invoker().getGroupMembers(new HashSet<MOB>());
     if (mob != invoker()) {
       if (mob.location() != invoker().location()) unInvoke();
       else {
         if (invokerGroup.contains(mob)) unInvoke();
         else if (mob.isInCombat()) {
           int levels = invoker().charStats().getClassLevel("Templar");
           if (levels < 0) levels = invoker().phyStats().level();
           if (CMLib.dice().rollPercentage() >= levels) {
             final MOB newvictim = mob.location().fetchRandomInhabitant();
             if (newvictim != mob) mob.setVictim(newvictim);
           }
         }
       }
     } else if ((mob.location() != null) && (CMLib.flags().isEvil(invoker()))) {
       for (int m = 0; m < mob.location().numInhabitants(); m++) {
         final MOB M = mob.location().fetchInhabitant(m);
         if ((M != null)
             && (M != invoker())
             && (!invokerGroup.contains(M))
             && (!M.Name().equals(mob.getLiegeID())))
           beneficialAffect(invoker, M, 0, Ability.TICKS_FOREVER);
       }
     }
   }
   return true;
 }
Пример #4
0
 @Override
 protected void finalize() {
   spellV = null;
   compiledMask = null;
   chanceToHappen = -1;
   unrevocableSpells = null;
   if ((invokerMOB != null) && (invokerMOB.Name().equals("invoker"))) invokerMOB.destroy();
 }
Пример #5
0
  @Override
  public boolean invoke(MOB mob, Vector commands, Physical givenTarget, boolean auto, int asLevel) {
    Item target = null;
    if ((commands.size() == 0) && (!auto) && (givenTarget == null))
      target = Prayer_Sacrifice.getBody(mob.location());
    if (target == null)
      target = getTarget(mob, mob.location(), givenTarget, commands, Wearable.FILTER_UNWORNONLY);
    if (target == null) return false;

    if ((!(target instanceof DeadBody))
        || (target.rawSecretIdentity().toUpperCase().indexOf("FAKE") >= 0)) {
      mob.tell(L("You may only desecrate the dead."));
      return false;
    }
    if ((((DeadBody) target).isPlayerCorpse())
        && (!((DeadBody) target).getMobName().equals(mob.Name()))
        && (((DeadBody) target).hasContent())) {
      mob.tell(L("You are not allowed to desecrate a players corpse."));
      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,
              verbalCastCode(mob, target, auto),
              auto
                  ? L("<T-NAME> feel(s) desecrated!")
                  : L("^S<S-NAME> desecrate(s) <T-NAMESELF> before @x1.^?", hisHerDiety(mob)));
      if (mob.location().okMessage(mob, msg)) {
        mob.location().send(mob, msg);
        if (CMLib.flags().isEvil(mob)) {
          double exp = 5.0;
          final int levelLimit = CMProps.getIntVar(CMProps.Int.EXPRATE);
          final int levelDiff = (mob.phyStats().level()) - target.phyStats().level();
          if (levelDiff > levelLimit) exp = 0.0;
          if (exp > 0.0)
            CMLib.leveler()
                .postExperience(
                    mob, null, null, (int) Math.round(exp) + super.getXPCOSTLevel(mob), false);
        }
        target.destroy();
        mob.location().recoverRoomStats();
      }
    } else
      beneficialWordsFizzle(
          mob, target, L("<S-NAME> attempt(s) to desecrate <T-NAMESELF>, but fail(s)."));

    // return whether it worked
    return success;
  }
Пример #6
0
 @Override
 public MOB invoker() {
   if (super.miscText.length() == 0) return super.invoker();
   MOB M = super.invoker();
   if ((M != null) && (M.Name().equals(miscText))) return M;
   M = CMLib.players().getLoadPlayer(miscText);
   if (M == null) miscText = "";
   else invoker = M;
   return super.invoker();
 }
Пример #7
0
  public boolean invoke(
      MOB mob, Vector commands, Environmental givenTarget, boolean auto, int asLevel) {
    Item myPlant = getTarget(mob, mob.location(), givenTarget, commands, Item.WORNREQ_ANY);
    if (myPlant == null) return false;

    if (isPlant(myPlant) == null) {
      mob.tell("You can't control " + myPlant.name() + ".");
      return false;
    }

    if (myPlant.rawSecretIdentity().equals(mob.Name())) {
      mob.tell("You already control " + myPlant.name() + ".");
      return false;
    }

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

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

    if (success) {
      CMMsg msg =
          CMClass.getMsg(
              mob,
              myPlant,
              this,
              verbalCastCode(mob, myPlant, auto),
              auto ? "" : "^S<S-NAME> chant(s) to <T-NAMESELF>!^?");
      if (mob.location().okMessage(mob, msg)) {
        mob.location().send(mob, msg);
        Ability A = isPlant(myPlant);
        if (A != null) A.setInvoker(mob);
        mob.tell(
            "You wrest control of " + myPlant.name() + " from " + myPlant.secretIdentity() + ".");
        myPlant.setSecretIdentity(mob.Name());
      }

    } else
      beneficialVisualFizzle(
          mob, myPlant, "<S-NAME> chant(s) to <T-NAMESELF>, but nothing happens.");

    // return whether it worked
    return success;
  }
Пример #8
0
  @Override
  public boolean invoke(
      MOB mob, List<String> commands, Physical givenTarget, boolean auto, int asLevel) {
    final MOB target = getTargetAnywhere(mob, commands, givenTarget, false, true, false);
    if (target == null) return false;

    final Ability A = target.fetchEffect(ID());
    if (A != null) {
      A.unInvoke();
      mob.tell(L("@x1 is released from his hushing.", target.Name()));
      return true;
    }

    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,
              CMMsg.MASK_MOVE | CMMsg.TYP_JUSTICE | (auto ? CMMsg.MASK_ALWAYS : 0),
              auto ? L("Silence falls upon <T-NAME>!") : L("^F<S-NAME> hush(es) <T-NAMESELF>.^?"));
      CMLib.color().fixSourceFightColor(msg);
      if (mob.location().okMessage(mob, msg)) {
        mob.location().send(mob, msg);
        mob.location().show(target, null, CMMsg.MSG_OK_VISUAL, L("<S-NAME> <S-IS-ARE> hushed!"));
        beneficialAffect(mob, target, asLevel, Ability.TICKS_ALMOST_FOREVER);
        Log.sysOut("Banish", mob.Name() + " hushed " + target.name() + ".");
      }
    } else
      return beneficialVisualFizzle(
          mob, target, L("<S-NAME> attempt(s) to hush <T-NAMESELF>, but fail(s)."));
    return success;
  }
Пример #9
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 (!super.invoke(mob, commands, givenTarget, auto, asLevel)) return false;

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

    if (success
        && (target.phyStats().level()
            < ((mob.phyStats().level() + super.getXLEVELLevel(mob)) / 2))) {
      final CMMsg msg =
          CMClass.getMsg(
              mob,
              target,
              this,
              verbalCastCode(mob, target, auto) | CMMsg.MASK_MALICIOUS,
              L("^S<S-NAME> @x1 for <T-NAME> to die.^?", prayForWord(mob)));
      if (mob.location().okMessage(mob, msg)) {
        mob.location().send(mob, msg);
        CMLib.combat().postDeath(target, target, null);
        DeadBody body = null;
        for (Enumeration<Item> i = mob.location().items(); i.hasMoreElements(); ) {
          final Item I = i.nextElement();
          if ((I instanceof DeadBody) && (((DeadBody) I).getMobName().equals(target.Name())))
            body = (DeadBody) I;
        }
        if (body == null) mob.tell(L("The death did not appear to create a body!"));
        else beneficialAffect(mob, body, asLevel, 0);
      }
    } else
      return maliciousFizzle(
          mob,
          target,
          L("^S<S-NAME> @x1 <T-NAME> to die, but nothing happens.^?", prayForWord(mob)));
    // return whether it worked
    return success;
  }
Пример #10
0
  @Override
  public boolean invoke(MOB mob, Vector commands, Physical givenTarget, boolean auto, int asLevel) {
    final Physical target = mob.location();
    if (target == null) return false;
    if (target.fetchEffect(ID()) != null) {
      mob.tell(L("This place is already consecrated."));
      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,
              verbalCastCode(mob, target, auto),
              auto ? "" : L("^S<S-NAME> @x1 to consecrate this place.^?", prayForWord(mob)));
      if (mob.location().okMessage(mob, msg)) {
        mob.location().send(mob, msg);
        setMiscText(mob.Name());
        if ((target instanceof Room) && (CMLib.law().doesOwnThisLand(mob, ((Room) target)))) {
          target.addNonUninvokableEffect((Ability) this.copyOf());
          CMLib.database().DBUpdateRoom((Room) target);
        } else beneficialAffect(mob, target, asLevel, 0);
      }
    } else
      beneficialWordsFizzle(
          mob,
          target,
          L(
              "<S-NAME> @x1 to consecrate this place, but <S-IS-ARE> not answered.",
              prayForWord(mob)));

    return success;
  }
Пример #11
0
  @Override
  public boolean invoke(
      MOB mob, List<String> commands, Physical givenTarget, boolean auto, int asLevel) {
    final Physical target = getAnyTarget(mob, commands, givenTarget, Wearable.FILTER_UNWORNONLY);
    if (target == null) return false;

    if (target == mob) {
      mob.tell(L("@x1 doesn't look dead yet.", target.name(mob)));
      return false;
    }
    if (!(target instanceof DeadBody)) {
      mob.tell(L("You can't animate that."));
      return false;
    }

    final DeadBody body = (DeadBody) target;
    if (body.isPlayerCorpse()
        || (body.getMobName().length() == 0)
        || ((body.charStats() != null)
            && (body.charStats().getMyRace() != null)
            && (body.charStats().getMyRace().racialCategory().equalsIgnoreCase("Undead")))) {
      mob.tell(L("You can't animate that."));
      return false;
    }
    String race = "a";
    if ((body.charStats() != null) && (body.charStats().getMyRace() != null))
      race = CMLib.english().startWithAorAn(body.charStats().getMyRace().name()).toLowerCase();

    String description = body.getMobDescription();
    if (description.trim().length() == 0) description = "It looks dead.";
    else description += "\n\rIt also looks dead.";

    if (body.basePhyStats().level() < 7) {
      mob.tell(L("This creature is too weak to create a ghast from."));
      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,
              verbalCastCode(mob, target, auto),
              auto
                  ? ""
                  : L("^S<S-NAME> @x1 to animate <T-NAMESELF> as a ghast.^?", prayForWord(mob)));
      if (mob.location().okMessage(mob, msg)) {
        mob.location().send(mob, msg);
        int undeadLevel = this.getUndeadLevel(mob, 6, body.phyStats().level());
        final MOB newMOB = CMClass.getMOB("GenUndead");
        newMOB.setName(L("@x1 ghast", race));
        newMOB.setDescription(description);
        newMOB.setDisplayText(L("@x1 ghast is here", race));
        newMOB.basePhyStats().setLevel(undeadLevel);
        newMOB
            .baseCharStats()
            .setStat(CharStats.STAT_GENDER, body.charStats().getStat(CharStats.STAT_GENDER));
        newMOB.baseCharStats().setMyRace(CMClass.getRace("Undead"));
        newMOB
            .baseCharStats()
            .setBodyPartsFromStringAfterRace(body.charStats().getBodyPartsAsString());
        final Ability P = CMClass.getAbility("Prop_StatTrainer");
        if (P != null) {
          P.setMiscText("NOTEACH STR=20 INT=10 WIS=10 CON=10 DEX=15 CHA=2");
          newMOB.addNonUninvokableEffect(P);
        }
        newMOB.recoverCharStats();
        newMOB.basePhyStats().setAttackAdjustment(CMLib.leveler().getLevelAttack(newMOB));
        newMOB.basePhyStats().setDamage(CMLib.leveler().getLevelMOBDamage(newMOB));
        newMOB.basePhyStats().setSensesMask(PhyStats.CAN_SEE_DARK);
        CMLib.factions().setAlignment(newMOB, Faction.Align.EVIL);
        newMOB.baseState().setHitPoints(25 * newMOB.basePhyStats().level());
        newMOB.baseState().setMovement(CMLib.leveler().getLevelMove(newMOB));
        newMOB.basePhyStats().setArmor(CMLib.leveler().getLevelMOBArmor(newMOB));
        newMOB.baseState().setMana(100);
        newMOB.recoverCharStats();
        newMOB.recoverPhyStats();
        newMOB.recoverMaxState();
        newMOB.resetToMaxState();
        newMOB.addAbility(CMClass.getAbility("Paralysis"));
        Behavior B = CMClass.getBehavior("CombatAbilities");
        if (B != null) newMOB.addBehavior(B);
        B = CMClass.getBehavior("Aggressive");
        if (B != null) {
          B.setParms("+NAMES \"-" + mob.Name() + "\" -LEVEL +>" + newMOB.basePhyStats().level());
          newMOB.addBehavior(B);
        }
        newMOB.addNonUninvokableEffect(CMClass.getAbility("Spell_CauseStink"));
        newMOB.addNonUninvokableEffect(CMClass.getAbility("Prop_ModExperience"));
        newMOB.text();
        newMOB.bringToLife(mob.location(), true);
        CMLib.beanCounter().clearZeroMoney(newMOB, null);
        // newMOB.location().showOthers(newMOB,null,CMMsg.MSG_OK_ACTION,L("<S-NAME> appears!"));
        int it = 0;
        while (it < newMOB.location().numItems()) {
          final Item item = newMOB.location().getItem(it);
          if ((item != null) && (item.container() == body)) {
            final CMMsg msg2 = CMClass.getMsg(newMOB, body, item, CMMsg.MSG_GET, null);
            newMOB.location().send(newMOB, msg2);
            final CMMsg msg4 = CMClass.getMsg(newMOB, item, null, CMMsg.MSG_GET, null);
            newMOB.location().send(newMOB, msg4);
            final CMMsg msg3 = CMClass.getMsg(newMOB, item, null, CMMsg.MSG_WEAR, null);
            newMOB.location().send(newMOB, msg3);
            if (!newMOB.isMine(item)) it++;
            else it = 0;
          } else it++;
        }
        body.destroy();
        mob.location().show(newMOB, null, CMMsg.MSG_OK_ACTION, L("<S-NAME> begin(s) to rise!"));
        newMOB.setStartRoom(null);
        beneficialAffect(mob, newMOB, 0, 0);
        mob.location().recoverRoomStats();
      }
    } else
      return beneficialWordsFizzle(
          mob,
          target,
          L("<S-NAME> @x1 to animate <T-NAMESELF>, but fail(s) miserably.", prayForWord(mob)));

    // return whether it worked
    return success;
  }
Пример #12
0
  @Override
  public boolean invoke(MOB mob, Vector commands, Physical givenTarget, boolean auto, int asLevel) {
    boolean announce = false;
    if (commands.size() > 0) {
      if (((String) commands.lastElement()).equals("!")) {
        commands.removeElementAt(commands.size() - 1);
        announce = true;
      }
    }
    final MOB target = getTargetAnywhere(mob, commands, givenTarget, true);
    if (target == null) 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,
              CMMsg.MASK_MOVE | CMMsg.TYP_JUSTICE | (auto ? CMMsg.MASK_ALWAYS : 0),
              auto
                  ? L("<T-NAME> <T-IS-ARE> knocked out of <T-HIS-HER> shoes!!!")
                  : L(
                      "^F**<S-NAME> BLAST(S) <T-NAMESELF>**, knocking <T-HIM-HER> out of <T-HIS-HER> shoes!!^?"));
      CMLib.color().fixSourceFightColor(msg);
      if (target.location().okMessage(mob, msg)) {
        target.location().send(mob, msg);
        if (target.curState().getHitPoints() > 2)
          target.curState().setHitPoints(target.curState().getHitPoints() / 2);
        if (target.curState().getMana() > 2)
          target.curState().setMana(target.curState().getMana() / 2);
        if (target.curState().getMovement() > 2)
          target.curState().setMovement(target.curState().getMovement() / 2);
        final Item I = target.fetchFirstWornItem(Wearable.WORN_FEET);
        if (I != null) {
          I.unWear();
          I.removeFromOwnerContainer();
          target.location().addItem(I, ItemPossessor.Expire.Player_Drop);
        }
        Log.sysOut("Banish", mob.Name() + " wrathed " + target.name() + ".");
        if (announce) {
          final Command C = CMClass.getCommand("Announce");
          try {
            C.execute(
                mob,
                new XVector(
                    "ANNOUNCE",
                    target.name()
                        + " is knocked out of "
                        + target.charStats().hisher()
                        + " shoes!!!"),
                Command.METAFLAG_FORCED);
          } catch (final Exception e) {
          }
        }
      }
    } else
      return beneficialVisualFizzle(
          mob,
          target,
          L("<S-NAME> attempt(s) to inflict <S-HIS-HER> wrath upon <T-NAMESELF>, but fail(s)."));
    return success;
  }
Пример #13
0
  public boolean doArchonDBCompare(MOB mob, String scope, String firstWord, Vector commands)
      throws java.io.IOException {
    CMClass.CMObjectType doType = OBJECT_TYPES.get(firstWord.toUpperCase());
    if (doType == null) doType = OBJECT_TYPES.get(firstWord.toUpperCase() + "S");
    if (doType != null) commands.remove(0);
    else doType = CMClass.CMObjectType.LOCALE;

    final String theRest = CMParms.combineQuoted(commands, 0);
    DBConnector dbConnector = null;
    final String dbClass = CMParms.getParmStr(theRest, "DBCLASS", "");
    final String dbService = CMParms.getParmStr(theRest, "DBSERVICE", "");
    final String dbUser = CMParms.getParmStr(theRest, "DBUSER", "");
    final String dbPass = CMParms.getParmStr(theRest, "DBPASS", "");
    final int dbConns = CMParms.getParmInt(theRest, "DBCONNECTIONS", 3);
    final int dbPingIntMins = CMParms.getParmInt(theRest, "DBPINGINTERVALMINS", 30);
    final boolean dbReuse = CMParms.getParmBool(theRest, "DBREUSE", true);
    final String ignore = CMParms.getParmStr(theRest, "IGNORE", "");
    final String maskStr = CMParms.getParmStr(theRest, "MASK", "");
    final Set<String> ignores = new SHashSet(CMParms.parseCommas(ignore.toUpperCase(), true));
    final MaskingLibrary.CompiledZapperMask mask = CMLib.masking().maskCompile(maskStr);
    if (dbClass.length() == 0) {
      mob.tell(L("This command requires DBCLASS= to be set."));
      return false;
    }
    if (dbService.length() == 0) {
      mob.tell(L("This command requires DBSERVICE= to be set."));
      return false;
    }
    if (dbUser.length() == 0) {
      mob.tell(L("This command requires DBUSER= to be set."));
      return false;
    }
    if (dbPass.length() == 0) {
      mob.tell(L("This command requires DBPASS= to be set."));
      return false;
    }

    dbConnector =
        new DBConnector(
            dbClass, dbService, dbUser, dbPass, dbConns, dbPingIntMins, dbReuse, false, false);
    dbConnector.reconnect();
    final DBInterface dbInterface = new DBInterface(dbConnector, null);

    final DBConnection DBTEST = dbConnector.DBFetch();
    if (DBTEST != null) dbConnector.DBDone(DBTEST);
    mob.tell(L("Loading database rooms..."));
    final List<Room> rooms = new LinkedList<Room>();
    if ((!dbConnector.amIOk()) || (!dbInterface.isConnected())) {
      mob.tell(L("Failed to connect to database."));
      return false;
    }
    if (scope.equalsIgnoreCase("AREA"))
      rooms.addAll(
          Arrays.asList(dbInterface.DBReadRoomObjects(mob.location().getArea().Name(), false)));
    else if (scope.equalsIgnoreCase("ROOM")) {
      final Room R = dbInterface.DBReadRoomObject(mob.location().roomID(), false);
      if (R != null) rooms.add(R);
    } else
      for (final Enumeration<Area> e = CMLib.map().areas(); e.hasMoreElements(); )
        rooms.addAll(Arrays.asList(dbInterface.DBReadRoomObjects(e.nextElement().Name(), false)));
    if (rooms.size() == 0) {
      mob.tell(L("No rooms found."));
      return false;
    }
    for (final Room R : rooms) dbInterface.DBReadContent(R.roomID(), R, false);
    mob.tell(L("Data loaded, starting scan."));
    final Comparator<MOB> convM =
        new Comparator<MOB>() {
          @Override
          public int compare(MOB arg0, MOB arg1) {
            final int x = arg0.ID().compareTo(arg1.ID());
            return (x != 0) ? x : arg0.Name().compareTo(arg1.Name());
          }
        };
    final Comparator<Item> convI =
        new Comparator<Item>() {
          @Override
          public int compare(Item arg0, Item arg1) {
            final int x = arg0.ID().compareTo(arg1.ID());
            return (x != 0) ? x : arg0.Name().compareTo(arg1.Name());
          }
        };
    try {
      for (final Room dbR : rooms) {
        Room R = CMLib.map().getRoom(dbR.roomID());
        if (R == null) {
          if (doType == CMClass.CMObjectType.LOCALE)
            Log.sysOut("Merge", dbR.roomID() + " not in database");
          // import, including exits!
          continue;
        }
        synchronized (("SYNC" + dbR.roomID()).intern()) {
          final Area.State oldFlags = R.getArea().getAreaState();
          R.getArea().setAreaState(Area.State.FROZEN);

          boolean updateMobs = false;
          boolean updateItems = false;
          final boolean updateRoom = false;
          R = CMLib.map().getRoom(R);
          CMLib.map().resetRoom(R);
          final List<MOB> mobSetL = new Vector<MOB>();
          for (final Enumeration<MOB> e = dbR.inhabitants(); e.hasMoreElements(); )
            mobSetL.add(e.nextElement());
          final MOB[] mobSet = mobSetL.toArray(new MOB[0]);
          Arrays.sort(mobSet, convM);
          String lastName = "";
          int ct = 1;
          final HashSet<MOB> doneM = new HashSet<MOB>();
          for (final MOB dbM : mobSet) {
            if (!lastName.equals(dbM.Name())) ct = 1;
            else ct++;
            final String rName = dbM.Name() + "." + ct;
            MOB M = null;
            int ctr = ct;
            for (final Enumeration<MOB> m = R.inhabitants(); m.hasMoreElements(); ) {
              final MOB M1 = m.nextElement();
              if (M1.Name().equalsIgnoreCase(dbM.Name()) && ((--ctr) <= 0)) {
                M = M1;
                break;
              }
            }
            if (M == null) {
              if (amMerging(doType, mask, dbM) && (!ignore.contains("MISSING"))) {
                if (mob.session()
                    .confirm(
                        L(
                            "MOB: @x1.@x2 not in local room.\n\rWould you like to add it (y/N)?",
                            dbR.roomID(),
                            rName),
                        L("N"))) {
                  M = (MOB) dbM.copyOf();
                  M.bringToLife(R, true);
                  doneM.add(M);
                  updateMobs = true;
                  Log.sysOut("Merge", mob.Name() + " added mob " + dbR.roomID() + "." + rName);
                }
              }
            } else {
              doneM.add(M);
              if (amMerging(doType, mask, dbM)) {
                if (!dbM.sameAs(M)) {
                  final MOB oldM = (MOB) M.copyOf();
                  if ((dbMerge(mob, "^MMOB " + dbR.roomID() + "." + rName + "^N", dbM, M, ignores))
                      && (!oldM.sameAs(M))) {
                    Log.sysOut("Merge", mob.Name() + " modified mob " + dbR.roomID() + "." + rName);
                    updateMobs = true;
                  }
                }
              }
              final STreeSet<Item> itemSetL = new STreeSet<Item>(convI);
              for (final Enumeration<Item> e = dbM.items(); e.hasMoreElements(); )
                itemSetL.add(e.nextElement());
              final Item[] itemSet = itemSetL.toArray(new Item[0]);
              Arrays.sort(itemSet, convI);
              String lastIName = "";
              int ict = 1;
              final HashSet<Item> doneI = new HashSet<Item>();
              for (final Item dbI : itemSet) {
                if (!lastIName.equals(dbI.Name())) ict = 1;
                else ict++;
                final String rIName = dbI.Name() + "." + ict;
                Item I = null;
                ctr = ict;
                for (final Enumeration<Item> i = M.items(); i.hasMoreElements(); ) {
                  final Item I1 = i.nextElement();
                  if (I1.Name().equalsIgnoreCase(dbI.Name()) && ((--ctr) <= 0)) {
                    I = I1;
                    break;
                  }
                }
                if (I == null) {
                  if (amMerging(doType, mask, dbI) && (!ignore.contains("MISSING"))) {
                    if (mob.session()
                        .confirm(
                            L(
                                "Item: @x1.@x2.@x3 not in local room.\n\rWould you like to add it (y/N)?",
                                dbR.roomID(),
                                dbM.Name(),
                                rIName),
                            L("N"))) {
                      I = (Item) dbI.copyOf();
                      M.addItem(I);
                      doneI.add(I);
                      final Item cI =
                          (dbI.container() == null) ? null : M.findItem(dbI.container().Name());
                      if (cI instanceof Container) I.setContainer((Container) cI);
                      updateMobs = true;
                      Log.sysOut(
                          "Merge",
                          mob.Name()
                              + " added item "
                              + dbR.roomID()
                              + "."
                              + dbM.Name()
                              + "."
                              + rIName);
                    }
                  }
                } else if (amMerging(doType, mask, dbI)) {
                  doneI.add(I);
                  if (!dbI.sameAs(I)) {
                    final Item oldI = (Item) I.copyOf();
                    if ((dbMerge(
                            mob,
                            "^IITEM ^M" + dbR.roomID() + "." + dbM.Name() + "." + rIName + "^N",
                            dbI,
                            I,
                            ignores))
                        && (!oldI.sameAs(I))) {
                      Log.sysOut(
                          "Merge",
                          mob.Name()
                              + " modified item "
                              + dbR.roomID()
                              + "."
                              + dbM.Name()
                              + "."
                              + rIName);
                      updateMobs = true;
                    }
                  }
                }
                lastIName = dbI.Name();
              }
              for (final Enumeration<Item> i = M.items(); i.hasMoreElements(); ) {
                final Item I = i.nextElement();
                if (amMerging(doType, mask, I)
                    && (!doneI.contains(I))
                    && (!ignore.contains("EXTRA"))) {
                  if (mob.session()
                      .confirm(
                          L(
                              "Item: @x1.@x2.@x3 not in database.\n\rWould you like to delete it (y/N)?",
                              R.roomID(),
                              M.Name(),
                              I.Name()),
                          L("N"))) {
                    M.delItem(I);
                    updateMobs = true;
                    Log.sysOut(
                        "Merge",
                        mob.Name()
                            + " deleted item "
                            + R.roomID()
                            + "."
                            + M.Name()
                            + "."
                            + I.Name());
                  }
                }
              }
            }
            lastName = dbM.Name();
          }
          for (final Enumeration<MOB> r = R.inhabitants(); r.hasMoreElements(); ) {
            final MOB M = r.nextElement();
            if (amMerging(doType, mask, M)
                && (!doneM.contains(M))
                && (M.isMonster())
                && (!ignore.contains("EXTRA"))) {
              if (mob.session()
                  .confirm(
                      L(
                          "MOB: @x1.@x2 not in database.\n\rWould you like to delete it (y/N)?",
                          R.roomID(),
                          M.Name()),
                      L("N"))) {
                R.delInhabitant(M);
                updateMobs = true;
                Log.sysOut("Merge", mob.Name() + " deleted mob " + R.roomID() + "." + M.Name());
              }
            }
          }

          final STreeSet<Item> itemSetL = new STreeSet<Item>(convI);
          for (final Enumeration<Item> e = dbR.items(); e.hasMoreElements(); )
            itemSetL.add(e.nextElement());
          final Item[] itemSet = itemSetL.toArray(new Item[0]);
          Arrays.sort(itemSet, convI);
          lastName = "";
          ct = 1;
          final HashSet<Item> doneI = new HashSet<Item>();
          for (final Item dbI : itemSet) {
            if (!lastName.equals(dbI.Name())) ct = 1;
            else ct++;
            final String rName = dbI.Name() + "." + ct;
            Item I = null;
            int ctr = ct;
            for (final Enumeration<Item> i = R.items(); i.hasMoreElements(); ) {
              final Item I1 = i.nextElement();
              if (I1.Name().equalsIgnoreCase(dbI.Name()) && ((--ctr) <= 0)) {
                I = I1;
                break;
              }
            }
            if (I == null) {
              if (amMerging(doType, mask, dbI) && (!ignore.contains("MISSING"))) {
                if (mob.session()
                    .confirm(
                        L(
                            "Item: @x1.@x2 not in local room.\n\rWould you like to add it (y/N)?",
                            dbR.roomID(),
                            rName),
                        L("N"))) {
                  I = (Item) dbI.copyOf();
                  R.addItem(I);
                  doneI.add(I);
                  final Item cI =
                      (dbI.container() == null) ? null : R.findItem(dbI.container().Name());
                  if (cI instanceof Container) I.setContainer((Container) cI);
                  updateItems = true;
                  Log.sysOut("Merge", mob.Name() + " added item " + dbR.roomID() + "." + rName);
                }
              }
            } else if (amMerging(doType, mask, dbI)) {
              doneI.add(I);
              if (!dbI.sameAs(I)) {
                final Item oldI = (Item) I.copyOf();
                if ((dbMerge(mob, "^IITEM " + dbR.roomID() + "." + rName + "^N", dbI, I, ignores))
                    && (!oldI.sameAs(I))) {
                  Log.sysOut("Merge", mob.Name() + " modified item " + dbR.roomID() + "." + rName);
                  updateItems = true;
                }
              }
            }
            lastName = dbI.Name();
          }
          for (final Enumeration<Item> i = R.items(); i.hasMoreElements(); ) {
            final Item I = i.nextElement();
            if (amMerging(doType, mask, I) && (!doneI.contains(I)) && (!ignore.contains("EXTRA"))) {
              if (mob.session()
                  .confirm(
                      L(
                          "Item: @x1.@x2 not in database.\n\rWould you like to delete it (y/N)?",
                          R.roomID(),
                          I.Name()),
                      L("N"))) {
                R.delItem(I);
                updateItems = true;
                Log.sysOut("Merge", mob.Name() + " deleted item " + R.roomID() + "." + I.Name());
              }
            }
          }
          if (updateRoom) CMLib.database().DBUpdateRoom(R);
          if (updateItems) CMLib.database().DBUpdateItems(R);
          if (updateMobs) CMLib.database().DBUpdateMOBs(R);
          CMLib.map().resetRoom(R);
          R.getArea().setAreaState(oldFlags);
        }
        dbR.destroy();
      }
      mob.tell(L("Done"));
    } catch (final CMException cme) {
      mob.tell(L("Cancelled."));
    }
    dbInterface.shutdown();
    return true;
  }
Пример #14
0
  @Override
  public boolean execute(MOB mob, Vector commands, int metaFlags) throws java.io.IOException {
    final boolean noisy = CMSecurity.isDebugging(CMSecurity.DbgFlag.MERGE);
    Vector placesToDo = new Vector();
    commands.remove(0);
    if (commands.size() == 0) {
      mob.tell(L("Merge what? Try DATABASE or a filename"));
      return false;
    }
    if (mob.isMonster()) {
      mob.tell(L("No can do."));
      return false;
    }
    if ((commands.size() > 0) && ((String) commands.get(0)).equalsIgnoreCase("noprompt"))
      commands.remove(0);

    if ((commands.size() > 0) && ((String) commands.get(0)).equalsIgnoreCase("?")) {
      final StringBuffer allFieldsMsg = new StringBuffer("");
      final Vector allKnownFields = new Vector();
      sortEnumeratedList(CMClass.mobTypes(), allKnownFields, allFieldsMsg);
      sortEnumeratedList(CMClass.basicItems(), allKnownFields, allFieldsMsg);
      sortEnumeratedList(CMClass.weapons(), allKnownFields, allFieldsMsg);
      sortEnumeratedList(CMClass.armor(), allKnownFields, allFieldsMsg);
      sortEnumeratedList(CMClass.clanItems(), allKnownFields, allFieldsMsg);
      sortEnumeratedList(CMClass.miscMagic(), allKnownFields, allFieldsMsg);
      sortEnumeratedList(CMClass.tech(), allKnownFields, allFieldsMsg);
      mob.tell(L("Valid field names are @x1", allFieldsMsg.toString()));
      return false;
    }
    String scope = "WORLD";
    if ((commands.size() > 0) && ((String) commands.get(0)).equalsIgnoreCase("room")) {
      if (!CMSecurity.isAllowed(mob, mob.location(), CMSecurity.SecFlag.MERGE)) {
        mob.tell(L("You are not allowed to do that here."));
        return false;
      }
      commands.remove(0);
      placesToDo.add(mob.location());
      scope = "ROOM";
    }
    if ((commands.size() > 0) && ((String) commands.get(0)).equalsIgnoreCase("area")) {
      if (!CMSecurity.isAllowed(mob, mob.location(), CMSecurity.SecFlag.MERGE)) {
        mob.tell(L("You are not allowed to do that here."));
        return false;
      }
      commands.remove(0);
      placesToDo.add(mob.location().getArea());
      scope = "AREA";
    }
    if ((commands.size() > 0) && ((String) commands.get(0)).equalsIgnoreCase("world")) {
      if (!CMSecurity.isAllowedEverywhere(mob, CMSecurity.SecFlag.MERGE)) {
        mob.tell(L("You are not allowed to do that."));
        return false;
      }
      commands.remove(0);
      placesToDo = new Vector();
      scope = "WORLD";
    }
    if (commands.size() == 0) {
      mob.tell(L("Merge what? DATABASE or filename"));
      return false;
    }
    String firstWord = (String) commands.get(0);
    if (firstWord.equalsIgnoreCase("DATABASE")) {
      commands.remove(0);
      if (commands.size() == 0) {
        mob.tell(L("Merge parameters missing: DBCLASS, DBSERVICE, DBUSER, DBPASS"));
        return false;
      }
      firstWord = (String) commands.get(0);
      return doArchonDBCompare(mob, scope, firstWord, commands);
    }
    final String filename = (String) commands.lastElement();
    commands.remove(filename);
    final StringBuffer buf = new CMFile(filename, mob, CMFile.FLAG_LOGERRORS).text();
    if ((buf == null) || (buf.length() == 0)) {
      mob.tell(L("File not found at: '@x1'!", filename));
      return false;
    }

    final List<String> changes = new Vector();
    final List<String> onfields = new Vector();
    final List<String> ignore = new Vector();
    List<String> use = null;
    final List<String> allKnownFields = new Vector();
    final List things = new Vector();
    boolean aremobs = false;
    if ((buf.length() > 20) && (buf.substring(0, 20).indexOf("<MOBS>") >= 0)) {
      if (mob.session() != null)
        mob.session().rawPrint(L("Unpacking mobs from file: '@x1'...", filename));
      final String error =
          CMLib.coffeeMaker().addMOBsFromXML(buf.toString(), things, mob.session());
      if (mob.session() != null) mob.session().rawPrintln("!");
      if (error.length() > 0) {
        mob.tell(L("An error occurred on merge: @x1", error));
        mob.tell(L("Please correct the problem and try the import again."));
        return false;
      }
      aremobs = true;
    } else if ((buf.length() > 20) && (buf.substring(0, 20).indexOf("<ITEMS>") >= 0)) {
      if (mob.session() != null)
        mob.session().rawPrint(L("Unpacking items from file: '@x1'...", filename));
      final String error =
          CMLib.coffeeMaker().addItemsFromXML(buf.toString(), things, mob.session());
      if (mob.session() != null) mob.session().rawPrintln("!");
      if (error.length() > 0) {
        mob.tell(L("An error occurred on merge: @x1", error));
        mob.tell(L("Please correct the problem and try the import again."));
        return false;
      }
    } else {
      mob.tell(
          L(
              "Files of this type are not yet supported by MERGE.  You must merge an ITEMS or MOBS file at this time."));
      return false;
    }
    if (things.size() == 0) {
      mob.tell(L("Nothing was found in the file to merge!"));
      return false;
    }
    final StringBuffer allFieldsMsg = new StringBuffer("");
    if (aremobs) sortEnumeratedList(CMClass.mobTypes(), allKnownFields, allFieldsMsg);
    else {
      sortEnumeratedList(CMClass.basicItems(), allKnownFields, allFieldsMsg);
      sortEnumeratedList(CMClass.weapons(), allKnownFields, allFieldsMsg);
      sortEnumeratedList(CMClass.armor(), allKnownFields, allFieldsMsg);
      sortEnumeratedList(CMClass.clanItems(), allKnownFields, allFieldsMsg);
      sortEnumeratedList(CMClass.miscMagic(), allKnownFields, allFieldsMsg);
      sortEnumeratedList(CMClass.tech(), allKnownFields, allFieldsMsg);
    }

    allKnownFields.add("REJUV");
    allFieldsMsg.append(L("REJUV "));

    for (int i = 0; i < commands.size(); i++) {
      String str = ((String) commands.get(i)).toUpperCase();
      if (str.startsWith("CHANGE=")) {
        use = changes;
        str = str.substring(7).trim();
      }
      if (str.startsWith("ON=")) {
        use = onfields;
        str = str.substring(3).trim();
      }
      if (str.startsWith("IGNORE=")) {
        use = ignore;
        str = str.substring(7).trim();
      }
      int x = str.indexOf(',');
      while (x >= 0) {
        final String s = str.substring(0, x).trim();
        if (s.length() > 0) {
          if (use == null) {
            mob.tell(L("'@x1' is an unknown parameter!", str));
            return false;
          }
          if (allKnownFields.contains(s)) use.add(s);
          else {
            mob.tell(
                L(
                    "'@x1' is an unknown field name.  Valid fields include: @x2",
                    s,
                    allFieldsMsg.toString()));
            return false;
          }
        }
        str = str.substring(x + 1).trim();
        x = str.indexOf(',');
      }
      if (str.length() > 0) {
        if (use == null) {
          mob.tell(L("'@x1' is an unknown parameter!", str));
          return false;
        }
        if (allKnownFields.contains(str)) use.add(str);
        else {
          mob.tell(
              L(
                  "'@x1' is an unknown field name.  Valid fields include: @x2",
                  str,
                  allFieldsMsg.toString()));
          return false;
        }
      }
    }
    if ((onfields.size() == 0) && (ignore.size() == 0) && (changes.size() == 0)) {
      mob.tell(
          L(
              "You must specify either an ON, CHANGES, or IGNORE parameter for valid matches to be made."));
      return false;
    }
    if (placesToDo.size() == 0)
      for (final Enumeration a = CMLib.map().areas(); a.hasMoreElements(); ) {
        final Area A = (Area) a.nextElement();
        if (A.getCompleteMap().hasMoreElements()
            && CMSecurity.isAllowed(
                mob, (A.getCompleteMap().nextElement()), CMSecurity.SecFlag.MERGE))
          placesToDo.add(A);
      }
    if (placesToDo.size() == 0) {
      mob.tell(L("There are no rooms to merge into!"));
      return false;
    }
    for (int i = placesToDo.size() - 1; i >= 0; i--) {
      if (placesToDo.get(i) instanceof Area) {
        final Area A = (Area) placesToDo.get(i);
        placesToDo.removeElement(A);
        for (final Enumeration r = A.getCompleteMap(); r.hasMoreElements(); ) {
          final Room R = (Room) r.nextElement();
          if (CMSecurity.isAllowed(mob, R, CMSecurity.SecFlag.MERGE)) placesToDo.add(R);
        }
      } else if (placesToDo.get(i) instanceof Room)
        if (mob.session() != null) mob.session().rawPrint(".");
        else return false;
    }
    // now do the merge...
    if (mob.session() != null) mob.session().rawPrint(L("Merging and saving..."));
    if (noisy) mergedebugtell(mob, "Rooms to do: " + placesToDo.size());
    if (noisy) mergedebugtell(mob, "Things loaded: " + things.size());
    if (noisy) mergedebugtell(mob, "On fields=" + CMParms.toStringList(onfields));
    if (noisy) mergedebugtell(mob, "Ignore fields=" + CMParms.toStringList(ignore));
    if (noisy) mergedebugtell(mob, "Change fields=" + CMParms.toStringList(changes));
    Log.sysOut("Import", mob.Name() + " merge '" + filename + "'.");
    for (int r = 0; r < placesToDo.size(); r++) {
      Room R = (Room) placesToDo.get(r);
      if (!CMSecurity.isAllowed(mob, R, CMSecurity.SecFlag.MERGE)) continue;
      if (R.roomID().length() == 0) continue;
      synchronized (("SYNC" + R.roomID()).intern()) {
        R = CMLib.map().getRoom(R);
        final Area.State oldFlags = R.getArea().getAreaState();
        R.getArea().setAreaState(Area.State.FROZEN);
        CMLib.map().resetRoom(R);
        boolean savemobs = false;
        boolean saveitems = false;
        if (aremobs) {
          for (int m = 0; m < R.numInhabitants(); m++) {
            final MOB M = R.fetchInhabitant(m);
            if ((M != null) && (M.isSavable()))
              if (tryMerge(mob, R, M, things, changes, onfields, ignore, noisy)) savemobs = true;
          }
        } else {
          for (int i = 0; i < R.numItems(); i++) {
            final Item I = R.getItem(i);
            if ((I != null) && (tryMerge(mob, R, I, things, changes, onfields, ignore, noisy)))
              saveitems = true;
          }
          for (int m = 0; m < R.numInhabitants(); m++) {
            final MOB M = R.fetchInhabitant(m);
            if ((M != null) && (M.isSavable())) {
              for (int i = 0; i < M.numItems(); i++) {
                final Item I = M.getItem(i);
                if ((I != null) && (tryMerge(mob, R, I, things, changes, onfields, ignore, noisy)))
                  savemobs = true;
              }
              final ShopKeeper SK = CMLib.coffeeShops().getShopKeeper(M);
              if (SK != null) {
                for (final Iterator<Environmental> i = SK.getShop().getStoreInventory();
                    i.hasNext(); ) {
                  final Environmental E = i.next();
                  if (E instanceof Item) {
                    final Item I = (Item) E;
                    if (tryMerge(mob, R, I, things, changes, onfields, ignore, noisy))
                      savemobs = true;
                  }
                }
              }
            }
          }
        }
        if (saveitems) CMLib.database().DBUpdateItems(R);
        if (savemobs) CMLib.database().DBUpdateMOBs(R);
        if (mob.session() != null) mob.session().rawPrint(".");
        R.getArea().setAreaState(oldFlags);
      }
    }

    if (mob.session() != null) mob.session().rawPrintln(L("!\n\rDone!"));
    Area A = null;
    for (int i = 0; i < placesToDo.size(); i++) {
      A = ((Room) placesToDo.get(i)).getArea();
      if ((A != null) && (A.getAreaState() != Area.State.ACTIVE)) A.setAreaState(Area.State.ACTIVE);
    }
    return false;
  }
Пример #15
0
  @Override
  public boolean invoke(
      MOB mob, List<String> commands, Physical givenTarget, boolean auto, int asLevel) {
    final Room trapThis = mob.location();

    Item resource =
        CMLib.materials().findMostOfMaterial(mob.location(), RawMaterial.MATERIAL_METAL);
    if (resource == null)
      resource = CMLib.materials().findMostOfMaterial(mob.location(), RawMaterial.MATERIAL_MITHRIL);
    int amount = 0;
    if (resource != null)
      amount = CMLib.materials().findNumberOfResource(mob.location(), resource.material());
    if (amount < 100) {
      mob.tell(L("You need 100 pounds of raw metal to build this trap."));
      return false;
    }
    if (mob.isInCombat()) {
      mob.tell(L("You are too busy to get that done right now."));
      return false;
    }

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

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

    if (resource != null)
      CMLib.materials().destroyResourcesValue(mob.location(), 100, resource.material(), -1, null);

    final CMMsg msg =
        CMClass.getMsg(
            mob,
            trapThis,
            this,
            auto ? CMMsg.MSG_OK_ACTION : CMMsg.MSG_THIEF_ACT,
            CMMsg.MASK_ALWAYS | CMMsg.MSG_DELICATE_HANDS_ACT,
            CMMsg.MSG_OK_ACTION,
            (auto
                ? L("@x1 begins to glow!", trapThis.name())
                : L("<S-NAME> attempt(s) to lay a trap here.")));
    if (mob.location().okMessage(mob, msg)) {
      mob.location().send(mob, msg);
      if (success) {
        mob.tell(L("You have set the trap."));
        setTrap(
            mob,
            trapThis,
            mob.charStats().getClassLevel(mob.charStats().getCurrentClass()),
            (CMLib.ableMapper().qualifyingClassLevel(mob, this)
                    - CMLib.ableMapper().lowestQualifyingLevel(ID()))
                + 1,
            false);
        final Thief_DeathTrap T = (Thief_DeathTrap) trapThis.fetchEffect(ID());
        if (T != null) T.setMiscText(mob.Name());
      } else {
        if (CMLib.dice().rollPercentage() > 50) {
          final Trap T =
              setTrap(
                  mob,
                  trapThis,
                  mob.charStats().getClassLevel(mob.charStats().getCurrentClass()),
                  (CMLib.ableMapper().qualifyingClassLevel(mob, this)
                          - CMLib.ableMapper().lowestQualifyingLevel(ID()))
                      + 1,
                  false);
          mob.location()
              .show(mob, null, CMMsg.MSG_OK_ACTION, L("<S-NAME> trigger(s) the trap on accident!"));
          T.spring(mob);
        } else {
          mob.tell(L("You fail in your attempt to set the death trap."));
        }
      }
    }
    return success;
  }
Пример #16
0
  @Override
  public String runMacro(HTTPRequest httpReq, String parm) {
    final java.util.Map<String, String> parms = parseParms(parm);
    final String last = httpReq.getUrlParameter("JOURNAL");
    if (last == null) return " @break@";
    boolean securityOverride = false;
    if ((Thread.currentThread() instanceof CWThread)
        && CMath.s_bool(((CWThread) Thread.currentThread()).getConfig().getMiscProp("ADMIN"))
        && parms.containsKey("ALLFORUMJOURNALS")) securityOverride = true;

    final MOB M = Authenticate.getAuthenticatedMob(httpReq);
    if ((!securityOverride)
        && (CMLib.journals().isArchonJournalName(last))
        && ((M == null) || (!CMSecurity.isASysOp(M)))) return " @break@";

    final Clan setClan = CMLib.clans().getClan(httpReq.getUrlParameter("CLAN"));
    final JournalsLibrary.ForumJournal journal = CMLib.journals().getForumJournal(last, setClan);
    if (journal == null) return " @break@";

    final StringBuffer str = new StringBuffer("");
    if (parms.containsKey("ISSMTPFORWARD")) {
      @SuppressWarnings("unchecked")
      final TreeMap<String, JournalsLibrary.SMTPJournal> set =
          (TreeMap<String, JournalsLibrary.SMTPJournal>)
              Resources.getResource("SYSTEM_SMTP_JOURNALS");
      final JournalsLibrary.SMTPJournal entry =
          (set != null) ? set.get(last.toUpperCase().trim()) : null;
      final String email =
          ((M != null) && (M.playerStats() != null) && (M.playerStats().getEmail() != null))
              ? M.playerStats().getEmail()
              : "";
      str.append(
              ((entry != null) && (email.length() > 0)) ? Boolean.toString(entry.forward) : "false")
          .append(", ");
    }

    if (parms.containsKey("ISSMTPSUBSCRIBER")) {
      final Map<String, List<String>> lists =
          Resources.getCachedMultiLists("mailinglists.txt", true);
      final List<String> mylist = lists.get(last);
      str.append(
              ((mylist != null) && (M != null))
                  ? Boolean.toString(mylist.contains(M.Name()))
                  : "false")
          .append(", ");
    }

    if (parms.containsKey("SMTPADDRESS")) {
      @SuppressWarnings("unchecked")
      final TreeMap<String, JournalsLibrary.SMTPJournal> set =
          (TreeMap<String, JournalsLibrary.SMTPJournal>)
              Resources.getResource("SYSTEM_SMTP_JOURNALS");
      final JournalsLibrary.SMTPJournal entry =
          (set != null) ? set.get(last.toUpperCase().trim()) : null;
      if ((entry != null) && (entry.forward)) {
        str.append(entry.name.replace(' ', '_') + "@" + CMProps.getVar(CMProps.Str.MUDDOMAIN))
            .append(", ");
      }
    }

    if (parms.containsKey("CANADMIN") || parms.containsKey("ISADMIN"))
      str.append("" + journal.authorizationCheck(M, ForumJournalFlags.ADMIN)).append(", ");

    if (parms.containsKey("CANPOST"))
      str.append("" + journal.authorizationCheck(M, ForumJournalFlags.POST)).append(", ");

    if (parms.containsKey("CANREAD"))
      str.append("" + journal.authorizationCheck(M, ForumJournalFlags.READ)).append(", ");

    if (parms.containsKey("CANREPLY"))
      str.append("" + journal.authorizationCheck(M, ForumJournalFlags.REPLY)).append(", ");

    if (parms.containsKey("ADMINMASK")) str.append("" + journal.adminMask()).append(", ");

    if (parms.containsKey("READMASK")) str.append("" + journal.readMask()).append(", ");

    if (parms.containsKey("POSTMASK")) str.append("" + journal.postMask()).append(", ");

    if (parms.containsKey("REPLYMASK")) str.append("" + journal.replyMask()).append(", ");

    if (parms.containsKey("ID")) str.append("" + journal.NAME()).append(", ");

    if (parms.containsKey("NAME")) str.append("" + journal.NAME()).append(", ");

    if (parms.containsKey("EXPIRE")) str.append("").append(", ");

    final JournalsLibrary.JournalSummaryStats stats = CMLib.journals().getJournalStats(journal);
    if (stats == null) return " @break@";

    if (parms.containsKey("POSTS")) str.append("" + stats.posts).append(", ");

    if (parms.containsKey("THREADS")) str.append("" + stats.threads).append(", ");

    if (parms.containsKey("SHORTDESC")) str.append("" + stats.shortIntro).append(", ");

    if (parms.containsKey("LONGDESC")) str.append("" + stats.longIntro).append(", ");

    if (parms.containsKey("IMAGEPATH")) {
      if ((stats.imagePath == null) || (stats.imagePath.trim().length() == 0))
        str.append(L("images/lilcm.jpg")).append(", ");
      else str.append("" + stats.threads).append(", ");
    }

    String strstr = str.toString();
    if (strstr.endsWith(", ")) strstr = strstr.substring(0, strstr.length() - 2);
    return clearWebMacros(strstr);
  }
Пример #17
0
  public boolean invoke(
      MOB mob, Vector commands, Environmental givenTarget, boolean auto, int asLevel) {
    int autoGenerate = 0;
    if ((auto)
        && (givenTarget == this)
        && (commands.size() > 0)
        && (commands.firstElement() instanceof Integer)) {
      autoGenerate = ((Integer) commands.firstElement()).intValue();
      commands.removeElementAt(0);
      givenTarget = null;
    }
    DVector enhancedTypes = enhancedTypes(mob, commands);
    randomRecipeFix(mob, addRecipes(mob, loadRecipes()), commands, autoGenerate);
    if (commands.size() == 0) {
      commonTell(
          mob,
          "Knit what? Enter \"knit list\" for a list, \"knit refit <item>\" to resize, \"knit scan\", or \"knit mend <item>\".");
      return false;
    }
    if ((!auto)
        && (commands.size() > 0)
        && (((String) commands.firstElement()).equalsIgnoreCase("bundle"))) {
      bundling = true;
      if (super.invoke(mob, commands, givenTarget, auto, asLevel))
        return super.bundle(mob, commands);
      return false;
    }
    Vector recipes = addRecipes(mob, loadRecipes());
    String str = (String) commands.elementAt(0);
    String startStr = null;
    bundling = false;
    int duration = 4;
    if (str.equalsIgnoreCase("list")) {
      String mask = CMParms.combine(commands, 1);
      StringBuffer buf = new StringBuffer("");
      int toggler = 1;
      int toggleTop = 2;
      for (int r = 0; r < toggleTop; r++)
        buf.append(CMStrings.padRight("Item", 28) + " Lvl " + CMStrings.padRight("Cloth", 5) + " ");
      buf.append("\n\r");
      for (int r = 0; r < recipes.size(); r++) {
        Vector V = (Vector) recipes.elementAt(r);
        if (V.size() > 0) {
          String item = replacePercent((String) V.elementAt(RCP_FINALNAME), "");
          int level = CMath.s_int((String) V.elementAt(RCP_LEVEL));
          int wood = CMath.s_int((String) V.elementAt(RCP_WOOD));
          wood = adjustWoodRequired(wood, mob);
          if ((level <= xlevel(mob))
              && ((mask == null)
                  || (mask.length() == 0)
                  || mask.equalsIgnoreCase("all")
                  || CMLib.english().containsString(item, mask))) {
            buf.append(
                CMStrings.padRight(item, 28)
                    + " "
                    + CMStrings.padRight("" + level, 3)
                    + " "
                    + CMStrings.padRight("" + wood, 5)
                    + ((toggler != toggleTop) ? " " : "\n\r"));
            if (++toggler > toggleTop) toggler = 1;
          }
        }
      }
      if (toggler != 1) buf.append("\n\r");
      commonTell(mob, buf.toString());
      enhanceList(mob);
      return true;
    }
    if (str.equalsIgnoreCase("scan")) return publicScan(mob, commands);
    else if (str.equalsIgnoreCase("mend")) {
      building = null;
      mending = false;
      messedUp = false;
      Vector newCommands = CMParms.parse(CMParms.combine(commands, 1));
      building =
          getTarget(mob, mob.location(), givenTarget, newCommands, Wearable.FILTER_UNWORNONLY);
      if (!canMend(mob, building, false)) return false;
      mending = true;
      if (!super.invoke(mob, commands, givenTarget, auto, asLevel)) return false;
      startStr = "<S-NAME> start(s) mending " + building.name() + ".";
      displayText = "You are mending " + building.name();
      verb = "mending " + building.name();
    } else if (str.equalsIgnoreCase("refit")) {
      building = null;
      mending = false;
      refitting = false;
      messedUp = false;
      Vector newCommands = CMParms.parse(CMParms.combine(commands, 1));
      building =
          getTarget(mob, mob.location(), givenTarget, newCommands, Wearable.FILTER_UNWORNONLY);
      if (building == null) return false;
      if ((building.material() & RawMaterial.MATERIAL_MASK) != RawMaterial.MATERIAL_CLOTH) {
        commonTell(mob, "That's not made of cloth.  It can't be refitted.");
        return false;
      }
      if (!(building instanceof Armor)) {
        commonTell(mob, "You don't know how to refit that sort of thing.");
        return false;
      }
      if (building.envStats().height() == 0) {
        commonTell(mob, building.name() + " is already the right size.");
        return false;
      }
      refitting = true;
      if (!super.invoke(mob, commands, givenTarget, auto, asLevel)) return false;
      startStr = "<S-NAME> start(s) refitting " + building.name() + ".";
      displayText = "You are refitting " + building.name();
      verb = "refitting " + building.name();
    } else {
      building = null;
      mending = false;
      messedUp = false;
      refitting = false;
      aborted = false;
      int amount = -1;
      if ((commands.size() > 1) && (CMath.isNumber((String) commands.lastElement()))) {
        amount = CMath.s_int((String) commands.lastElement());
        commands.removeElementAt(commands.size() - 1);
      }
      String recipeName = CMParms.combine(commands, 0);
      Vector foundRecipe = null;
      Vector matches = matchingRecipeNames(recipes, recipeName, true);
      for (int r = 0; r < matches.size(); r++) {
        Vector V = (Vector) matches.elementAt(r);
        if (V.size() > 0) {
          int level = CMath.s_int((String) V.elementAt(RCP_LEVEL));
          if ((autoGenerate > 0) || (level <= xlevel(mob))) {
            foundRecipe = V;
            break;
          }
        }
      }
      if (foundRecipe == null) {
        commonTell(
            mob,
            "You don't know how to knit a '"
                + recipeName
                + "'.  Try \""
                + triggerStrings()[0].toLowerCase()
                + " list\" for a list.");
        return false;
      }
      int woodRequired = CMath.s_int((String) foundRecipe.elementAt(RCP_WOOD));
      woodRequired = adjustWoodRequired(woodRequired, mob);
      if (amount > woodRequired) woodRequired = amount;
      String misctype = (String) foundRecipe.elementAt(RCP_MISCTYPE);
      bundling = misctype.equalsIgnoreCase("BUNDLE");
      int[] pm = {RawMaterial.MATERIAL_CLOTH};
      int[][] data =
          fetchFoundResourceData(
              mob, woodRequired, "cloth", pm, 0, null, null, bundling, autoGenerate, enhancedTypes);
      if (data == null) return false;
      woodRequired = data[0][FOUND_AMT];
      if (!super.invoke(mob, commands, givenTarget, auto, asLevel)) return false;
      int lostValue =
          autoGenerate > 0
              ? 0
              : CMLib.materials()
                  .destroyResources(mob.location(), woodRequired, data[0][FOUND_CODE], 0, null);
      building = CMClass.getItem((String) foundRecipe.elementAt(RCP_CLASSTYPE));
      if (building == null) {
        commonTell(
            mob, "There's no such thing as a " + foundRecipe.elementAt(RCP_CLASSTYPE) + "!!!");
        return false;
      }
      duration =
          getDuration(
              CMath.s_int((String) foundRecipe.elementAt(RCP_TICKS)),
              mob,
              CMath.s_int((String) foundRecipe.elementAt(RCP_LEVEL)),
              4);
      String itemName =
          replacePercent(
                  (String) foundRecipe.elementAt(RCP_FINALNAME),
                  RawMaterial.CODES.NAME(data[0][FOUND_CODE]))
              .toLowerCase();
      if (bundling) itemName = "a " + woodRequired + "# " + itemName;
      else if (itemName.endsWith("s")) itemName = "some " + itemName;
      else itemName = CMLib.english().startWithAorAn(itemName);
      building.setName(itemName);
      startStr = "<S-NAME> start(s) knitting " + building.name() + ".";
      displayText = "You are knitting " + building.name();
      verb = "knitting " + building.name();
      playSound = "scissor.wav";
      building.setDisplayText(itemName + " lies here");
      building.setDescription(itemName + ". ");
      if (bundling) building.baseEnvStats().setWeight(woodRequired);
      else building.baseEnvStats().setWeight(woodRequired / 2);
      int hardness = RawMaterial.CODES.HARDNESS(data[0][FOUND_CODE]) - 1;
      building.setBaseValue(CMath.s_int((String) foundRecipe.elementAt(RCP_VALUE)));
      building.setMaterial(data[0][FOUND_CODE]);
      building.baseEnvStats().setLevel(CMath.s_int((String) foundRecipe.elementAt(RCP_LEVEL)));
      building.setSecretIdentity("This is the work of " + mob.Name() + ".");
      int capacity = CMath.s_int((String) foundRecipe.elementAt(RCP_CAPACITY));
      int canContain = CMath.s_int((String) foundRecipe.elementAt(RCP_CONTAINMASK));
      int armordmg = CMath.s_int((String) foundRecipe.elementAt(RCP_ARMORDMG));
      String spell =
          (foundRecipe.size() > RCP_SPELL)
              ? ((String) foundRecipe.elementAt(RCP_SPELL)).trim()
              : "";
      if (bundling) building.setBaseValue(lostValue);
      addSpells(building, spell);
      if (building instanceof Weapon) {
        ((Weapon) building).setWeaponClassification(Weapon.CLASS_NATURAL);
        setWeaponTypeClass((Weapon) building, misctype);
        building.baseEnvStats().setDamage(armordmg);
        ((Weapon) building).setRawProperLocationBitmap(Wearable.WORN_WIELD | Wearable.WORN_HELD);
        ((Weapon) building).setRawLogicalAnd((capacity > 1));
      }
      if (building instanceof Armor) {
        if (capacity > 0) {
          ((Armor) building).setCapacity(capacity + woodRequired);
          ((Armor) building).setContainTypes(canContain);
        }
        ((Armor) building).baseEnvStats().setArmor(0);
        if (armordmg != 0)
          ((Armor) building).baseEnvStats().setArmor(armordmg + (abilityCode() - 1) + hardness);
        setWearLocation(building, misctype, 0);
      }
      if (building instanceof Rideable) {
        setRideBasis((Rideable) building, misctype);
      }
      building.recoverEnvStats();
      building.text();
      building.recoverEnvStats();
    }

    messedUp = !proficiencyCheck(mob, 0, auto);

    if (bundling) {
      messedUp = false;
      duration = 1;
      verb = "bundling " + RawMaterial.CODES.NAME(building.material()).toLowerCase();
      startStr = "<S-NAME> start(s) " + verb + ".";
      displayText = "You are " + verb;
    }

    if (autoGenerate > 0) {
      commands.addElement(building);
      return true;
    }

    CMMsg msg = CMClass.getMsg(mob, building, this, CMMsg.MSG_NOISYMOVEMENT, startStr);
    if (mob.location().okMessage(mob, msg)) {
      mob.location().send(mob, msg);
      building = (Item) msg.target();
      beneficialAffect(mob, mob, asLevel, duration);
      enhanceItem(mob, building, enhancedTypes);
    } else if (bundling) {
      messedUp = false;
      aborted = false;
      unInvoke();
    }
    return true;
  }
Пример #18
0
  public String runMacro(ExternalHTTPRequests httpReq, String parm) {
    if (!CMProps.getBoolVar(CMProps.SYSTEMB_MUDSTARTED))
      return CMProps.getVar(CMProps.SYSTEM_MUDSTATUS);

    Hashtable parms = parseParms(parm);
    String last = httpReq.getRequestParameter("PLAYER");
    if (last == null) return " @break@";
    if (last.length() > 0) {
      MOB M = CMLib.players().getLoadPlayer(last);
      if (M == null) {
        MOB authM = Authenticate.getAuthenticatedMob(httpReq);
        if ((authM != null) && (authM.Name().equalsIgnoreCase(last))) M = authM;
        else return " @break@";
      }

      boolean firstTime =
          (!httpReq.isRequestParameter("ACTION"))
              || (httpReq.getRequestParameter("ACTION")).equals("FIRSTTIME");
      StringBuffer str = new StringBuffer("");
      for (int i = 0; i < MOB.AUTODESC.length; i++) {
        if (parms.containsKey(MOB.AUTODESC[i])) {
          boolean set = CMath.isSet(M.getBitmap(), i);
          if (MOB.AUTOREV[i]) set = !set;
          str.append((set ? "ON" : "OFF") + ",");
        }
      }
      for (int i : CharStats.CODES.ALL()) {
        String stat = CharStats.CODES.NAME(i);
        if (!stat.equalsIgnoreCase("GENDER")) {
          CharStats C = M.charStats();
          if (parms.containsKey(stat)) {
            String old = httpReq.getRequestParameter(stat);
            if ((firstTime) || (old.length() == 0)) {
              if ((!CharStats.CODES.isBASE(i)) && (i != CharStats.STAT_GENDER))
                old = "" + C.getSave(i);
              else old = "" + C.getStat(i);
            }
            str.append(old + ", ");
          }
        }
      }
      for (int i : CharStats.CODES.ALL()) {
        String stat = CharStats.CODES.NAME(i);
        if (!stat.equalsIgnoreCase("GENDER")) {
          CharStats C = M.baseCharStats();
          if (parms.containsKey("BASE" + stat)) {
            String old = httpReq.getRequestParameter("BASE" + stat);
            if ((firstTime) || (old.length() == 0)) old = "" + C.getStat(i);
            str.append(old + ", ");
          }
        }
      }
      for (int i = 0; i < BASICS.length; i++) {
        if (parms.containsKey(BASICS[i])) {
          if (httpReq.isRequestParameter(BASICS[i]))
            str.append(httpReq.getRequestParameter(BASICS[i]) + ", ");
          else str.append(getBasic(M, i));
        }
      }
      if (parms.containsKey("RACE")) {
        String old = httpReq.getRequestParameter("RACE");
        if ((firstTime) || (old.length() == 0)) old = "" + M.baseCharStats().getMyRace().ID();
        for (Enumeration r = CMClass.races(); r.hasMoreElements(); ) {
          Race R2 = (Race) r.nextElement();
          str.append("<OPTION VALUE=\"" + R2.ID() + "\"");
          if (R2.ID().equals(old)) str.append(" SELECTED");
          str.append(">" + R2.name());
        }
      }
      if (parms.containsKey("DEITY")) {
        String old = httpReq.getRequestParameter("DEITY");
        if (firstTime) old = M.getWorshipCharID();
        str.append("<OPTION " + ((old.length() == 0) ? "SELECTED" : "") + " VALUE=\"\">Godless");
        for (Enumeration e = CMLib.map().deities(); e.hasMoreElements(); ) {
          Deity E = (Deity) e.nextElement();
          str.append("<OPTION VALUE=\"" + E.Name() + "\"");
          if (E.Name().equalsIgnoreCase(old)) str.append(" SELECTED");
          str.append(">" + E.Name());
        }
      }
      if (parms.containsKey("TITLELIST")) {
        if (M.playerStats() != null) {
          int b = 0;
          Vector titles = new Vector();
          if (firstTime) CMParms.addToVector(M.playerStats().getTitles(), titles);
          else
            while (httpReq.isRequestParameter("TITLE" + b)) {
              String B = httpReq.getRequestParameter("TITLE" + b);
              if ((B != null) && (B.trim().length() > 0)) titles.addElement(B);
              b++;
            }
          for (b = 0; b < titles.size(); b++) {
            String B = (String) titles.elementAt(b);
            if (B != null)
              str.append(
                  "<INPUT TYPE=TEXT NAME=TITLE"
                      + b
                      + " SIZE="
                      + B.length()
                      + " VALUE=\""
                      + CMStrings.replaceAll(B, "\"", "&quot;")
                      + "\"><BR>");
          }
          str.append("<INPUT TYPE=TEXT NAME=TITLE" + titles.size() + " SIZE=60 VALUE=\"\">");
        }
      }
      if (parms.containsKey("CLAN")) {
        String old = httpReq.getRequestParameter("CLAN");
        if (firstTime) old = M.getClanID();
        str.append("<OPTION " + ((old.length() == 0) ? "SELECTED" : "") + " VALUE=\"\">Clanless");
        for (Enumeration e = CMLib.clans().allClans(); e.hasMoreElements(); ) {
          Clan C = (Clan) e.nextElement();
          str.append("<OPTION VALUE=\"" + C.clanID() + "\"");
          if (C.clanID().equalsIgnoreCase(old)) str.append(" SELECTED");
          str.append(">" + C.getName());
        }
      }
      if (parms.containsKey("ALIGNMENT")) {
        String old = httpReq.getRequestParameter("ALIGNMENT");
        if ((firstTime) || (old.length() == 0))
          old = "" + M.fetchFaction(CMLib.factions().AlignID());
        if (CMLib.factions().getFaction(CMLib.factions().AlignID()) != null) {
          for (int v = 1; v < Faction.ALIGN_NAMES.length; v++) {
            str.append("<OPTION VALUE=" + Faction.ALIGN_NAMES[v]);
            if (old.equalsIgnoreCase(Faction.ALIGN_NAMES[v])) str.append(" SELECTED");
            str.append(">" + CMStrings.capitalizeAndLower(Faction.ALIGN_NAMES[v].toLowerCase()));
          }
        }
      }
      if (parms.containsKey("BASEGENDER")) {
        String old = httpReq.getRequestParameter("BASEGENDER");
        if (firstTime) old = "" + M.baseCharStats().getStat(CharStats.STAT_GENDER);
        str.append("<OPTION VALUE=M " + ((old.equalsIgnoreCase("M")) ? "SELECTED" : "") + ">M");
        str.append("<OPTION VALUE=F " + ((old.equalsIgnoreCase("F")) ? "SELECTED" : "") + ">F");
        str.append("<OPTION VALUE=N " + ((old.equalsIgnoreCase("N")) ? "SELECTED" : "") + ">N");
      }
      str.append(MobData.expertiseList(M, httpReq, parms));
      str.append(MobData.classList(M, httpReq, parms));
      str.append(MobData.itemList(M, M, httpReq, parms, 0));
      str.append(MobData.abilities(M, httpReq, parms, 0));
      str.append(MobData.factions(M, httpReq, parms, 0));
      str.append(AreaData.affectsNBehaves(M, httpReq, parms, 0));
      str.append(ExitData.dispositions(M, firstTime, httpReq, parms));
      str.append(MobData.senses(M, firstTime, httpReq, parms));
      String strstr = str.toString();
      if (strstr.endsWith(", ")) strstr = strstr.substring(0, strstr.length() - 2);
      return clearWebMacros(strstr);
    }
    return "";
  }
Пример #19
0
  @Override
  public boolean invoke(MOB mob, Vector commands, Physical givenTarget, boolean auto, int asLevel) {
    if (CMParms.combine(commands, 0).equalsIgnoreCase("auto")) {
      DATA.clear();
      IPS.clear();
      final Hashtable<String, List<MOB>> ipes = new Hashtable<String, List<MOB>>();
      for (final Session S : CMLib.sessions().localOnlineIterable()) {
        if ((S.getAddress().length() > 0) && (S.mob() != null)) {
          List V = ipes.get(S.getAddress());
          if (V == null) {
            V = new Vector();
            ipes.put(S.getAddress(), V);
          }
          if (!V.contains(S.mob())) V.add(S.mob());
        }
      }
      final StringBuffer rpt = new StringBuffer("");
      for (final Enumeration e = ipes.keys(); e.hasMoreElements(); ) {
        final String addr = (String) e.nextElement();
        final List<MOB> names = ipes.get(addr);
        if (names.size() > 1) {
          IPS.put(addr, names);
          rpt.append("Watch #" + (IPS.size()) + " added: ");
          for (int n = 0; n < names.size(); n++) {
            final MOB MN = names.get(n);
            if (MN.fetchEffect(ID()) == null) {
              final Ability A = (Ability) copyOf();
              MN.addNonUninvokableEffect(A);
              A.setSavable(false);
            }
            rpt.append(MN.Name() + " ");
          }
          rpt.append("\n\r");
        }
      }
      if (rpt.length() == 0)
        rpt.append("No users with duplicate IDs found.  Try MULTIWATCH ADD name1 name2 ... ");
      mob.tell(rpt.toString());
      return true;
    } else if (CMParms.combine(commands, 0).equalsIgnoreCase("stop")) {
      boolean foundLegacy = false;
      for (final Session S : CMLib.sessions().localOnlineIterable()) {
        if ((S != null) && (S.mob() != null) && (S.mob().fetchEffect(ID()) != null)) {
          foundLegacy = true;
          break;
        }
      }
      if ((DATA.size() == 0) && (IPS.size() == 0) && (!foundLegacy)) {
        mob.tell(L("Multiwatch is already off."));
        return false;
      }
      for (final Enumeration<List<MOB>> e = IPS.elements(); e.hasMoreElements(); ) {
        final List<MOB> V = e.nextElement();
        for (int v = 0; v < V.size(); v++) {
          final MOB M = V.get(v);
          final Ability A = M.fetchEffect(ID());
          if (A != null) M.delEffect(A);
        }
      }
      for (final Session S : CMLib.sessions().localOnlineIterable()) {
        if ((S != null) && (S.mob() != null)) {
          final MOB M = S.mob();
          final Ability A = M.fetchEffect(ID());
          if (A != null) M.delEffect(A);
        }
      }
      mob.tell(L("Multiplay watcher is now turned off."));
      DATA.clear();
      IPS.clear();
      return true;
    } else if ((commands.size() > 1)
        && ((String) commands.firstElement()).equalsIgnoreCase("add")) {
      final Vector V = new Vector();
      for (int i = 1; i < commands.size(); i++) {
        final String name = (String) commands.elementAt(i);
        final MOB M = CMLib.players().getPlayer(name);
        if ((M.session() != null) && (CMLib.flags().isInTheGame(M, true))) V.addElement(M);
        else mob.tell(L("'@x1' is not online.", name));
      }
      if (V.size() > 1) {
        for (int n = 0; n < V.size(); n++) {
          final MOB MN = (MOB) V.elementAt(n);
          if (MN.fetchEffect(ID()) == null) {
            final Ability A = (Ability) copyOf();
            MN.addNonUninvokableEffect(A);
            A.setSavable(false);
          }
        }
        IPS.put("MANUAL" + (IPS.size() + 1), V);
        mob.tell(L("Manual Watch #@x1 added.", "" + IPS.size()));
      }
      return true;
    } else if ((commands.size() == 0) && (DATA.size() > 0) && (IPS.size() > 0)) {
      final StringBuffer report = new StringBuffer("");
      for (final Enumeration<String> e = IPS.keys(); e.hasMoreElements(); ) {
        final String key = e.nextElement();
        int sync = 0;
        final List<MOB> V = IPS.get(key);
        for (int v = 0; v < V.size(); v++) {
          final MOB M = V.get(v);
          final int data[] = DATA.get(M);
          if (data != null) sync += data[DATA_SYNCHROFOUND];
        }
        report.append("^x" + key + "^?^., Syncs: " + sync + "\n\r");
        report.append(
            CMStrings.padRight(L("Name"), 25)
                + CMStrings.padRight(L("Speech"), 15)
                + CMStrings.padRight(L("Socials"), 15)
                + CMStrings.padRight(L("CMD"), 10)
                + CMStrings.padRight(L("ORDERS"), 10)
                + "\n\r");
        for (int v = 0; v < V.size(); v++) {
          final MOB M = V.get(v);
          int data[] = DATA.get(M);
          if (data == null) data = new int[DATA_TOTAL];
          report.append(CMStrings.padRight(M.Name(), 25));
          report.append(
              CMStrings.padRight(
                  data[DATA_GOODSPEECH] + "/" + data[DATA_DIRSPEECH] + "/" + data[DATA_ANYSPEECH],
                  15));
          report.append(
              CMStrings.padRight(
                  data[DATA_GOODSOCIAL] + "/" + data[DATA_DIRSOCIAL] + "/" + data[DATA_ANYSOCIAL],
                  15));
          report.append(CMStrings.padRight(data[DATA_TYPEDCOMMAND] + "", 10));
          report.append(CMStrings.padRight(data[DATA_ORDER] + "", 10));
          report.append("\n\r");
        }
        report.append("\n\r");
      }

      mob.tell(report.toString());
      return true;
    } else {
      mob.tell(L("Try MULTIWATCH AUTO, MULTIWATCH STOP, or MULTIWATCH ADD name1 name2.."));
      return false;
    }
  }
Пример #20
0
  @Override
  public boolean invoke(
      MOB mob, List<String> commands, Physical givenTarget, boolean auto, int asLevel) {
    final MOB target = super.getTarget(mob, commands, givenTarget);
    if (target == null) return false;
    final Race R = target.charStats().getMyRace();
    if (R.bodyMask()[Race.BODY_HEAD] <= 0) {
      mob.tell(L("@x1 has no head!", target.name(mob)));
      return false;
    }

    LegalBehavior B = null;
    if (mob.location() != null) B = CMLib.law().getLegalBehavior(mob.location());
    List<LegalWarrant> warrants = new Vector<LegalWarrant>();
    if (B != null) warrants = B.getWarrantsOf(CMLib.law().getLegalObject(mob.location()), target);
    if ((warrants.size() == 0)
        && (!CMSecurity.isAllowed(mob, mob.location(), CMSecurity.SecFlag.ABOVELAW))) {
      mob.tell(L("You are not allowed to behead @x1 at this time.", target.Name()));
      return false;
    }

    final Item w = mob.fetchWieldedItem();
    Weapon ww = null;
    if ((w == null) || (!(w instanceof Weapon))) {
      mob.tell(L("You cannot behead without a weapon!"));
      return false;
    }
    ww = (Weapon) w;
    if ((!auto) && (!CMSecurity.isASysOp(mob))) {
      if (ww.weaponDamageType() != Weapon.TYPE_SLASHING) {
        mob.tell(L("You cannot behead with a @x1!", ww.name()));
        return false;
      }
      if (mob.isInCombat() && (mob.rangeToTarget() > 0)) {
        mob.tell(L("You are too far away to try that!"));
        return false;
      }
      if (!CMLib.flags().isBoundOrHeld(target)) {
        mob.tell(L("@x1 is not bound and would resist.", target.charStats().HeShe()));
        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 = levelDiff * 3;
    else levelDiff = 0;
    final boolean hit = (auto) || CMLib.combat().rollToHit(mob, target);
    boolean success = proficiencyCheck(mob, 0, auto) && (hit);
    if (success) {
      final CMMsg msg =
          CMClass.getMsg(
              mob,
              target,
              this,
              CMMsg.MASK_MALICIOUS
                  | CMMsg.MASK_MOVE
                  | CMMsg.MASK_SOUND
                  | CMMsg.TYP_JUSTICE
                  | (auto ? CMMsg.MASK_ALWAYS : 0),
              null);
      if (mob.location().okMessage(mob, msg)) {
        mob.location().send(mob, msg);
        target.curState().setHitPoints(1);
        final Ability A2 = target.fetchEffect("Injury");
        if (A2 != null) A2.setMiscText(mob.Name() + "/head");
        CMLib.combat()
            .postDamage(
                mob,
                target,
                ww,
                Integer.MAX_VALUE / 2,
                CMMsg.MSG_WEAPONATTACK,
                ww.weaponClassification(),
                auto
                    ? ""
                    : L(
                        "^F^<FIGHT^><S-NAME> rear(s) back and behead(s) <T-NAME>!^</FIGHT^>^?@x1",
                        CMLib.protocol().msp("decap.wav", 30)));
        mob.location().recoverRoomStats();
        final Item limb = CMClass.getItem("GenLimb");
        limb.setName(L("@x1`s head", target.Name()));
        limb.basePhyStats().setAbility(1);
        limb.setDisplayText(L("the bloody head of @x1 is sitting here.", target.Name()));
        limb.setSecretIdentity(target.name() + "`s bloody head.");
        int material = RawMaterial.RESOURCE_MEAT;
        for (int r = 0; r < R.myResources().size(); r++) {
          final Item I = R.myResources().get(r);
          final int mat = I.material() & RawMaterial.MATERIAL_MASK;
          if (((mat == RawMaterial.MATERIAL_FLESH)) || (r == R.myResources().size() - 1)) {
            material = I.material();
            break;
          }
        }
        limb.setMaterial(material);
        limb.basePhyStats().setLevel(1);
        limb.basePhyStats().setWeight(5);
        limb.recoverPhyStats();
        mob.location().addItem(limb, ItemPossessor.Expire.Player_Drop);
        for (int i = 0; i < warrants.size(); i++) {
          final LegalWarrant W = warrants.get(i);
          W.setCrime("pardoned");
          W.setOffenses(0);
        }
      } else success = false;
      if (mob.getVictim() == target) mob.makePeace(true);
      if (target.getVictim() == mob) target.makePeace(true);
    } else maliciousFizzle(mob, target, L("<S-NAME> attempt(s) a beheading and fail(s)!"));
    return success;
  }
Пример #21
0
  public boolean execute(MOB mob, Vector commands, int metaFlags) throws java.io.IOException {
    if (mob.session() == null) return true;
    PlayerStats pstats = mob.playerStats();
    if (pstats == null) return true;

    if ((commands != null)
        && (commands.size() > 1)
        && (commands.elementAt(1) instanceof String)
        && (CMProps.getVar(CMProps.SYSTEM_MAILBOX).length() > 0)) {
      String name = CMParms.combine(commands, 1);
      if (name.equalsIgnoreCase("BOX")) {
        String journalName = CMProps.getVar(CMProps.SYSTEM_MAILBOX);
        Vector<JournalsLibrary.JournalEntry> msgs = CMLib.database().DBReadJournalMsgs(journalName);
        while ((mob.session() != null) && (!mob.session().killFlag())) {
          Vector mymsgs = new Vector();
          StringBuffer messages =
              new StringBuffer(
                  "^X" + CMStrings.padCenter(mob.Name() + "'s MailBox", 48) + "^?^.\n\r");
          messages.append(
              "^X### "
                  + CMStrings.padRight("From", 15)
                  + " "
                  + CMStrings.padRight("Date", 20)
                  + " Subject^?^.\n\r");
          for (int num = 0; num < msgs.size(); num++) {
            JournalsLibrary.JournalEntry thismsg = msgs.elementAt(num);
            String to = (String) thismsg.to;
            if (to.equalsIgnoreCase("ALL")
                || to.equalsIgnoreCase(mob.Name())
                || (to.toUpperCase().trim().startsWith("MASK=")
                    && CMLib.masking().maskCheck(to.trim().substring(5), mob, true))) {
              mymsgs.addElement(thismsg);
              messages.append(
                  CMStrings.padRight("" + mymsgs.size(), 4)
                      + CMStrings.padRight((thismsg.from), 16)
                      + CMStrings.padRight(CMLib.time().date2String(thismsg.date), 21)
                      + (thismsg.subj)
                      + "\n\r");
            }
          }
          if ((mymsgs.size() == 0)
              || (CMath.bset(metaFlags, Command.METAFLAG_POSSESSED))
              || (CMath.bset(metaFlags, Command.METAFLAG_AS))) {
            if (CMath.bset(mob.getBitmap(), MOB.ATT_AUTOFORWARD))
              mob.tell(
                  "You have no email waiting, but then, it's probably been forwarded to you already.");
            else mob.tell("You have no email waiting.");
            return false;
          }
          Session S = mob.session();
          try {
            if (S != null) S.snoopSuspension(1);
            mob.tell(messages.toString());
          } finally {
            if (S != null) S.snoopSuspension(-1);
          }
          String s = mob.session().prompt("Enter a message #", "");
          if ((!CMath.isInteger(s)) || (mob.session().killFlag())) return false;
          int num = CMath.s_int(s);
          if ((num <= 0) || (num > mymsgs.size())) mob.tell("That is not a valid number.");
          else
            while ((mob.session() != null) && (!mob.session().killFlag())) {
              JournalsLibrary.JournalEntry thismsg =
                  (JournalsLibrary.JournalEntry) mymsgs.elementAt(num - 1);
              String key = thismsg.key;
              String from = thismsg.from;
              String date = CMLib.time().date2String(thismsg.date);
              String subj = thismsg.subj;
              String message = thismsg.msg;
              messages = new StringBuffer("");
              messages.append("^XMessage :^?^." + num + "\n\r");
              messages.append("^XFrom    :^?^." + from + "\n\r");
              messages.append("^XDate    :^?^." + date + "\n\r");
              messages.append("^XSubject :^?^." + subj + "\n\r");
              messages.append("^X------------------------------------------------^?^.\n\r");
              messages.append(message + "\n\r\n\r");
              try {
                if (S != null) S.snoopSuspension(1);
                mob.tell(messages.toString());
              } finally {
                if (S != null) S.snoopSuspension(-1);
              }
              s =
                  mob.session()
                      .choose("Would you like to D)elete, H)old, or R)eply (D/H/R)? ", "DHR", "H");
              if (s.equalsIgnoreCase("H")) break;
              if (s.equalsIgnoreCase("R")) {
                if ((from.length() > 0)
                    && (!from.equals(mob.Name()))
                    && (!from.equalsIgnoreCase("BOX"))
                    && (CMLib.players().getLoadPlayer(from) != null))
                  execute(mob, CMParms.makeVector(getAccessWords()[0], from), metaFlags);
                else mob.tell("You can not reply to this email.");
              } else if (s.equalsIgnoreCase("D")) {
                CMLib.database().DBDeleteJournal(journalName, key);
                msgs.remove(thismsg);
                mob.tell("Deleted.");
                break;
              }
            }
        }
      } else {
        MOB M = CMLib.players().getLoadPlayer(name);
        if (M == null) {
          mob.tell(
              "There is no player called '"
                  + name
                  + "' to send email to.  If you were trying to read your mail, try EMAIL BOX.  If you were trying to change your email address, just enter EMAIL without any parameters.");
          return false;
        }
        if (!CMath.bset(M.getBitmap(), MOB.ATT_AUTOFORWARD)) {
          if (!mob.session().confirm("Send email to '" + M.Name() + "' (Y/n)?", "Y")) return false;
        } else {
          if (!mob.session()
              .confirm(
                  "Send email to '"
                      + M.Name()
                      + "', even though their AUTOFORWARD is turned off (y/N)?",
                  "N")) return false;
        }
        if (CMProps.getIntVar(CMProps.SYSTEMI_MAXMAILBOX) > 0) {
          int count =
              CMLib.database()
                  .DBCountJournal(CMProps.getVar(CMProps.SYSTEM_MAILBOX), null, M.Name());
          if (count >= CMProps.getIntVar(CMProps.SYSTEMI_MAXMAILBOX)) {
            mob.tell(M.Name() + "'s mailbox is full.");
            return false;
          }
        }
        String subject = mob.session().prompt("Email Subject: ", "").trim();
        if (subject.length() == 0) {
          mob.tell("Aborted");
          return false;
        }
        String message = mob.session().prompt("Enter your message\n\r: ", "").trim();
        if (message.trim().length() == 0) {
          mob.tell("Aborted");
          return false;
        }
        message +=
            "\n\r\n\rThis message was sent through the "
                + CMProps.getVar(CMProps.SYSTEM_MUDNAME)
                + " mail server at "
                + CMProps.getVar(CMProps.SYSTEM_MUDDOMAIN)
                + ", port"
                + CMProps.getVar(CMProps.SYSTEM_MUDPORTS)
                + ".  Please contact the administrators regarding any abuse of this system.\n\r";
        CMLib.database()
            .DBWriteJournal(
                CMProps.getVar(CMProps.SYSTEM_MAILBOX), mob.Name(), M.Name(), subject, message);
        mob.tell("Your email has been sent.");
        return true;
      }
    }
    if ((pstats.getEmail() == null) || (pstats.getEmail().length() == 0))
      mob.session().println("\n\rYou have no email address on file for this character.");
    else {
      if (commands == null) return true;
      String change =
          mob.session()
              .prompt(
                  "You currently have '"
                      + pstats.getEmail()
                      + "' set as the email address for this character.\n\rChange it (y/N)?",
                  "N");
      if (change.toUpperCase().startsWith("N")) return false;
    }
    if ((CMProps.getVar(CMProps.SYSTEM_EMAILREQ).toUpperCase().startsWith("PASS"))
        && (commands != null)
        && (CMProps.getVar(CMProps.SYSTEM_MAILBOX).length() > 0))
      mob.session()
          .println(
              "\n\r** Changing your email address will cause you to be logged off, and a new password to be generated and emailed to the new address. **\n\r");
    String newEmail = mob.session().prompt("New E-mail Address:");
    if (newEmail == null) return false;
    newEmail = newEmail.trim();
    if (!CMProps.getVar(CMProps.SYSTEM_EMAILREQ).toUpperCase().startsWith("OPTION")) {
      if (newEmail.length() < 6) return false;
      if (newEmail.indexOf("@") < 0) return false;
      String confirmEmail =
          mob.session()
              .prompt("Confirm that '" + newEmail + "' is correct by re-entering.\n\rRe-enter:");
      if (confirmEmail == null) return false;
      confirmEmail = confirmEmail.trim();
      if (confirmEmail.length() == 0) return false;
      if (!(newEmail.equalsIgnoreCase(confirmEmail))) return false;
    }
    pstats.setEmail(newEmail);
    CMLib.database().DBUpdateEmail(mob);
    if ((commands != null)
        && (CMProps.getVar(CMProps.SYSTEM_EMAILREQ).toUpperCase().startsWith("PASS"))
        && (CMProps.getVar(CMProps.SYSTEM_MAILBOX).length() > 0)) {
      String password = "";
      for (int i = 0; i < 6; i++) password += (char) ('a' + CMLib.dice().roll(1, 26, -1));
      pstats.setPassword(password);
      CMLib.database().DBUpdatePassword(mob.Name(), password);
      CMLib.database()
          .DBWriteJournal(
              CMProps.getVar(CMProps.SYSTEM_MAILBOX),
              mob.Name(),
              mob.Name(),
              "Password for " + mob.Name(),
              "Your new password for "
                  + mob.Name()
                  + " is: "
                  + pstats.password()
                  + "\n\rYou can login by pointing your mud client at "
                  + CMProps.getVar(CMProps.SYSTEM_MUDDOMAIN)
                  + " port(s):"
                  + CMProps.getVar(CMProps.SYSTEM_MUDPORTS)
                  + ".\n\rYou may use the PASSWORD command to change it once you are online.");
      mob.tell("You will receive an email with your new password shortly.  Goodbye.");
      if (mob.session() != null) {
        try {
          Thread.sleep(1000);
        } catch (Exception e) {
        }
        mob.session().kill(false, false, false);
      }
    }
    return true;
  }
  public boolean invoke(
      MOB mob, Vector commands, Environmental givenTarget, boolean auto, int asLevel) {
    int autoGenerate = 0;
    if ((auto)
        && (givenTarget == this)
        && (commands.size() > 0)
        && (commands.firstElement() instanceof Integer)) {
      autoGenerate = ((Integer) commands.firstElement()).intValue();
      commands.removeElementAt(0);
      givenTarget = null;
    }
    randomRecipeFix(mob, addRecipes(mob, loadRecipes()), commands, autoGenerate);
    if (commands.size() == 0) {
      commonTell(mob, "Papermake what? Enter \"Papermake list\" for a list.");
      return false;
    }
    if ((!auto)
        && (commands.size() > 0)
        && (((String) commands.firstElement()).equalsIgnoreCase("bundle"))) {
      bundling = true;
      if (super.invoke(mob, commands, givenTarget, auto, asLevel))
        return super.bundle(mob, commands);
      return false;
    }
    Vector recipes = addRecipes(mob, loadRecipes());
    String str = (String) commands.elementAt(0);
    String startStr = null;
    int duration = 4;
    if (str.equalsIgnoreCase("list")) {
      String mask = CMParms.combine(commands, 1);
      StringBuffer buf =
          new StringBuffer(CMStrings.padRight("Item", 22) + " Lvl Material required\n\r");
      for (int r = 0; r < recipes.size(); r++) {
        Vector V = (Vector) recipes.elementAt(r);
        if (V.size() > 0) {
          String item = replacePercent((String) V.elementAt(RCP_FINALNAME), "");
          int level = CMath.s_int((String) V.elementAt(RCP_LEVEL));
          int wood = CMath.s_int((String) V.elementAt(RCP_WOOD));
          wood = adjustWoodRequired(wood, mob);
          String material = (String) V.elementAt(RCP_WOODTYPE);
          if ((level <= xlevel(mob))
              && ((mask == null)
                  || (mask.length() == 0)
                  || mask.equalsIgnoreCase("all")
                  || CMLib.english().containsString(item, mask)))
            buf.append(
                CMStrings.padRight(item, 22)
                    + " "
                    + CMStrings.padRight("" + level, 3)
                    + " "
                    + wood
                    + " "
                    + material.toLowerCase()
                    + "\n\r");
        }
      }
      commonTell(mob, buf.toString());
      return true;
    }
    building = null;
    messedUp = false;
    String materialDesc = "";
    String recipeName = CMParms.combine(commands, 0);
    Vector foundRecipe = null;
    Vector matches = matchingRecipeNames(recipes, recipeName, true);
    for (int r = 0; r < matches.size(); r++) {
      Vector V = (Vector) matches.elementAt(r);
      if (V.size() > 0) {
        int level = CMath.s_int((String) V.elementAt(RCP_LEVEL));
        if ((autoGenerate > 0) || (level <= xlevel(mob))) {
          foundRecipe = V;
          materialDesc = (String) foundRecipe.elementAt(RCP_WOODTYPE);
          if (materialDesc.equalsIgnoreCase("WOOD")) materialDesc = "WOODEN";
          break;
        }
      }
    }
    if (materialDesc.length() == 0) materialDesc = "WOODEN";
    if (foundRecipe == null) {
      commonTell(
          mob, "You don't know how to make a '" + recipeName + "'.  Try \"make list\" for a list.");
      return false;
    }
    int woodRequired = CMath.s_int((String) foundRecipe.elementAt(RCP_WOOD));
    woodRequired = adjustWoodRequired(woodRequired, mob);
    int[][] data =
        fetchFoundResourceData(
            mob, woodRequired, materialDesc, null, 0, null, null, false, autoGenerate, null);
    if (data == null) return false;
    woodRequired = data[0][FOUND_AMT];
    if (!super.invoke(mob, commands, givenTarget, auto, asLevel)) return false;
    if (autoGenerate <= 0)
      CMLib.materials()
          .destroyResources(mob.location(), woodRequired, data[0][FOUND_CODE], 0, null);
    building = CMClass.getItem((String) foundRecipe.elementAt(RCP_CLASSTYPE));
    if (building == null) {
      commonTell(mob, "There's no such thing as a " + foundRecipe.elementAt(RCP_CLASSTYPE) + "!!!");
      return false;
    }
    duration =
        getDuration(
            CMath.s_int((String) foundRecipe.elementAt(RCP_TICKS)),
            mob,
            CMath.s_int((String) foundRecipe.elementAt(RCP_LEVEL)),
            4);
    String itemName =
        replacePercent(
                (String) foundRecipe.elementAt(RCP_FINALNAME),
                RawMaterial.RESOURCE_DESCS[(data[0][FOUND_CODE] & RawMaterial.RESOURCE_MASK)])
            .toLowerCase();
    itemName = CMLib.english().startWithAorAn(itemName);
    building.setName(itemName);
    startStr = "<S-NAME> start(s) making " + building.name() + ".";
    displayText = "You are making " + building.name();
    verb = "making " + building.name();
    playSound = "crumple.wav";
    building.setDisplayText(itemName + " lies here");
    building.setDescription(itemName + ". ");
    building.baseEnvStats().setWeight(woodRequired);
    building.setBaseValue(
        CMath.s_int((String) foundRecipe.elementAt(RCP_VALUE))
            + (woodRequired
                * (RawMaterial.RESOURCE_DATA[data[0][FOUND_CODE] & RawMaterial.RESOURCE_MASK][
                    RawMaterial.DATA_VALUE])));
    building.setMaterial(data[0][FOUND_CODE]);
    String spell =
        (foundRecipe.size() > RCP_SPELL) ? ((String) foundRecipe.elementAt(RCP_SPELL)).trim() : "";
    addSpells(building, spell);
    building.setSecretIdentity("This is the work of " + mob.Name() + ".");
    if (((data[0][FOUND_CODE] & RawMaterial.MATERIAL_MASK) == RawMaterial.MATERIAL_WOODEN)
        || (data[0][FOUND_CODE] == RawMaterial.RESOURCE_RICE))
      building.setMaterial(RawMaterial.RESOURCE_PAPER);
    building.baseEnvStats().setLevel(CMath.s_int((String) foundRecipe.elementAt(RCP_LEVEL)));
    building.recoverEnvStats();
    building.text();
    building.recoverEnvStats();

    messedUp = !proficiencyCheck(mob, 0, auto);

    if (autoGenerate > 0) {
      commands.addElement(building);
      return true;
    }

    CMMsg msg = CMClass.getMsg(mob, building, this, CMMsg.MSG_NOISYMOVEMENT, startStr);
    if (mob.location().okMessage(mob, msg)) {
      mob.location().send(mob, msg);
      building = (Item) msg.target();
      beneficialAffect(mob, mob, asLevel, duration);
    }
    return true;
  }
Пример #23
0
 public static String getBasic(MOB M, int i) {
   StringBuffer str = new StringBuffer("");
   switch (i) {
     case 0:
       str.append(M.Name() + ", ");
       break;
     case 1:
       str.append(M.description() + ", ");
       break;
     case 2:
       if (M.playerStats() != null)
         str.append(CMLib.time().date2String(M.playerStats().lastDateTime()) + ", ");
       break;
     case 3:
       if (M.playerStats() != null) str.append(M.playerStats().getEmail() + ", ");
       break;
     case 4:
       str.append(M.baseCharStats().getMyRace().name() + ", ");
       break;
     case 5:
       str.append(
           M.baseCharStats().getCurrentClass().name(M.baseCharStats().getCurrentClassLevel())
               + ", ");
       break;
     case 6:
       str.append(M.baseEnvStats().level() + ", ");
       break;
     case 7:
       str.append(M.baseCharStats().displayClassLevel(M, true) + ", ");
       break;
     case 8:
       str.append(M.baseCharStats().getClassLevel(M.baseCharStats().getCurrentClass()) + ", ");
       break;
     case 9:
       {
         for (int c = M.charStats().numClasses() - 1; c >= 0; c--) {
           CharClass C = M.charStats().getMyClass(c);
           str.append(
               C.name(M.baseCharStats().getCurrentClassLevel())
                   + " ("
                   + M.charStats().getClassLevel(C)
                   + ") ");
         }
         str.append(", ");
         break;
       }
     case 10:
       if (M.maxCarry() > (Integer.MAX_VALUE / 3)) str.append("NA, ");
       else str.append(M.maxCarry() + ", ");
       break;
     case 11:
       str.append(CMStrings.capitalizeAndLower(CMLib.combat().fightingProwessStr(M)) + ", ");
       break;
     case 12:
       str.append(CMStrings.capitalizeAndLower(CMLib.combat().armorStr(M)) + ", ");
       break;
     case 13:
       str.append(CMLib.combat().adjustedDamage(M, null, null) + ", ");
       break;
     case 14:
       str.append(Math.round(CMath.div(M.getAgeHours(), 60.0)) + ", ");
       break;
     case 15:
       str.append(M.getPractices() + ", ");
       break;
     case 16:
       str.append(M.getExperience() + ", ");
       break;
     case 17:
       if (M.getExpNeededLevel() == Integer.MAX_VALUE) str.append("N/A, ");
       else str.append(M.getExpNextLevel() + ", ");
       break;
     case 18:
       str.append(M.getTrains() + ", ");
       break;
     case 19:
       str.append(CMLib.beanCounter().getMoney(M) + ", ");
       break;
     case 20:
       str.append(M.getWorshipCharID() + ", ");
       break;
     case 21:
       str.append(M.getLiegeID() + ", ");
       break;
     case 22:
       str.append(M.getClanID() + ", ");
       break;
     case 23:
       if (M.getClanID().length() > 0) {
         Clan C = CMLib.clans().getClan(M.getClanID());
         if (C != null)
           str.append(
               CMLib.clans().getRoleName(C.getGovernment(), M.getClanRole(), true, false) + ", ");
       }
       break;
     case 24:
       str.append(M.fetchFaction(CMLib.factions().AlignID()) + ", ");
       break;
     case 25:
       {
         Faction.FactionRange FR =
             CMLib.factions()
                 .getRange(CMLib.factions().AlignID(), M.fetchFaction(CMLib.factions().AlignID()));
         if (FR != null) str.append(FR.name() + ", ");
         else str.append(M.fetchFaction(CMLib.factions().AlignID()));
         break;
       }
     case 26:
       str.append(M.getWimpHitPoint() + ", ");
       break;
     case 27:
       if (M.getStartRoom() != null) str.append(M.getStartRoom().displayText() + ", ");
       break;
     case 28:
       if (M.location() != null) str.append(M.location().displayText() + ", ");
       break;
     case 29:
       if (M.getStartRoom() != null) str.append(M.getStartRoom().roomID() + ", ");
       break;
     case 30:
       if (M.location() != null) str.append(M.location().roomID() + ", ");
       break;
     case 31:
       {
         for (int inv = 0; inv < M.inventorySize(); inv++) {
           Item I = M.fetchInventory(inv);
           if ((I != null) && (I.container() == null)) str.append(I.name() + ", ");
         }
         break;
       }
     case 32:
       str.append(M.baseEnvStats().weight() + ", ");
       break;
     case 33:
       str.append(M.envStats().weight() + ", ");
       break;
     case 34:
       str.append(CMStrings.capitalizeAndLower(M.baseCharStats().genderName()) + ", ");
       break;
     case 35:
       if (M.playerStats() != null) str.append(M.playerStats().lastDateTime() + ", ");
       break;
     case 36:
       str.append(M.curState().getHitPoints() + ", ");
       break;
     case 37:
       str.append(M.curState().getMana() + ", ");
       break;
     case 38:
       str.append(M.curState().getMovement() + ", ");
       break;
     case 39:
       if (M.riding() != null) str.append(M.riding().name() + ", ");
       break;
     case 40:
       str.append(M.baseEnvStats().height() + ", ");
       break;
     case 41:
       if (!M.isMonster()) str.append(M.session().getAddress() + ", ");
       else if (M.playerStats() != null) str.append(M.playerStats().lastIP() + ", ");
       break;
     case 42:
       str.append(M.getQuestPoint() + ", ");
       break;
     case 43:
       str.append(M.maxState().getHitPoints() + ", ");
       break;
     case 44:
       str.append(M.maxState().getMana() + ", ");
       break;
     case 45:
       str.append(M.maxState().getMovement() + ", ");
       break;
     case 46:
       str.append(M.rawImage() + ", ");
       break;
     case 47:
       str.append(M.maxItems() + ", ");
       break;
     case 48:
       {
         String[] paths = CMProps.mxpImagePath(M.image());
         if (paths[0].length() > 0) str.append(paths[0] + paths[1] + ", ");
         break;
       }
     case 49:
       if (CMProps.mxpImagePath(M.image())[0].length() > 0) str.append("true, ");
       else str.append("false, ");
       break;
     case 50:
       if (M.playerStats() != null) str.append(M.playerStats().notes() + ", ");
       break;
     case 51:
       if (M.playerStats() != null) {
         long lastDateTime = -1;
         for (int level = 0; level <= M.envStats().level(); level++) {
           long dateTime = M.playerStats().leveledDateTime(level);
           if ((dateTime > 1529122205) && (dateTime != lastDateTime)) {
             str.append("<TR>");
             if (level == 0) str.append("<TD><FONT COLOR=WHITE>Created</FONT></TD>");
             else str.append("<TD><FONT COLOR=WHITE>" + level + "</FONT></TD>");
             str.append(
                 "<TD><FONT COLOR=WHITE>"
                     + CMLib.time().date2String(dateTime)
                     + "</FONT></TD></TR>");
           }
         }
         str.append(", ");
       }
       break;
     case 52:
       str.append(M.baseEnvStats().attackAdjustment() + ", ");
       break;
     case 53:
       str.append(M.baseEnvStats().damage() + ", ");
       break;
     case 54:
       str.append(M.baseEnvStats().armor() + ", ");
       break;
     case 55:
       str.append(M.envStats().speed() + ", ");
       break;
     case 56:
       str.append(M.baseEnvStats().speed() + ", ");
       break;
     case 57:
       {
         for (int e = 0; e < M.numExpertises(); e++) {
           String E = M.fetchExpertise(e);
           ExpertiseLibrary.ExpertiseDefinition X = CMLib.expertises().getDefinition(E);
           if (X == null) str.append(E + ", ");
           else str.append(X.name + ", ");
         }
         break;
       }
     case 58:
       {
         for (int t = 0; t < M.numTattoos(); t++) {
           String E = M.fetchTattoo(t);
           str.append(E + ", ");
         }
         break;
       }
     case 59:
       {
         if (M.playerStats() != null)
           for (int b = 0; b < M.playerStats().getSecurityGroups().size(); b++) {
             String B = (String) M.playerStats().getSecurityGroups().elementAt(b);
             if (B != null) str.append(B + ", ");
           }
         break;
       }
     case 60:
       {
         if (M.playerStats() != null)
           for (int b = 0; b < M.playerStats().getTitles().size(); b++) {
             String B = (String) M.playerStats().getTitles().elementAt(b);
             if (B != null) str.append(B + ", ");
           }
         break;
       }
     case 61:
       {
         for (Enumeration e = M.fetchFactions(); e.hasMoreElements(); ) {
           String FID = (String) e.nextElement();
           Faction F = CMLib.factions().getFaction(FID);
           int value = M.fetchFaction(FID);
           if (F != null) str.append(F.name() + " (" + value + "), ");
         }
         break;
       }
     case 62:
       str.append(CMProps.getBoolVar(CMProps.SYSTEMB_ACCOUNTEXPIRATION) ? "true" : "false");
       break;
     case 63:
       if (M.playerStats() != null)
         str.append(CMLib.time().date2String(M.playerStats().getAccountExpiration()));
       break;
     case 64:
       {
         for (int f = 0; f < M.numFollowers(); f++)
           str.append(M.fetchFollower(f).name()).append(", ");
         // Vector V=CMLib.database().DBScanFollowers(M);
         // for(int v=0;v<V.size();v++)
         //    str.append(((MOB)V.elementAt(v)).name()).append(", ");
         break;
       }
     case 65:
       if ((M.playerStats() != null) && (M.playerStats().getAccount() != null))
         str.append(M.playerStats().getAccount().accountName());
       break;
   }
   return str.toString();
 }
Пример #24
0
  @Override
  public boolean invoke(
      MOB mob, List<String> commands, Physical givenTarget, boolean auto, int asLevel) {
    final Physical target = getAnyTarget(mob, commands, givenTarget, Wearable.FILTER_ANY, true);
    if (target == null) return false;

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

    int type = verbalCastCode(mob, target, auto);
    if ((target instanceof MOB)
        && (CMath.bset(type, CMMsg.MASK_MALICIOUS))
        && (((MOB) target).charStats().getStat(CharStats.STAT_AGE) > 0)) {
      final MOB mobt = (MOB) target;
      if (mobt.charStats().ageCategory() <= Race.AGE_CHILD)
        type = CMath.unsetb(type, CMMsg.MASK_MALICIOUS);
      else if ((mobt.getLiegeID().equals(mob.Name())) || (mobt.amFollowing() == mob))
        type = CMath.unsetb(type, CMMsg.MASK_MALICIOUS);
      else if ((mobt.charStats().ageCategory() <= Race.AGE_MATURE)
          && (mobt.getLiegeID().length() > 0)) type = CMath.unsetb(type, CMMsg.MASK_MALICIOUS);
    }

    if ((target instanceof Item)
        || ((target instanceof MOB)
            && (((MOB) target).isMonster())
            && (CMLib.flags().isAnimalIntelligence((MOB) target))
            && (CMLib.law().doesHavePriviledgesHere(mob, mob.location())))) {
      type = CMath.unsetb(type, CMMsg.MASK_MALICIOUS);
    }

    boolean success = proficiencyCheck(mob, 0, auto);
    if (success) {
      final CMMsg msg =
          CMClass.getMsg(
              mob, target, this, type, auto ? "" : L("^S<S-NAME> chant(s) to <T-NAMESELF>.^?"));
      if (mob.location().okMessage(mob, msg)) {
        mob.location().send(mob, msg);
        final Ability A = target.fetchEffect("Age");
        if ((!(target instanceof MOB)) && (!(target instanceof CagedAnimal)) && (A == null)) {
          if (target instanceof Food) {
            mob.tell(L("@x1 rots away!", target.name(mob)));
            ((Item) target).destroy();
          } else if (target instanceof Item) {
            switch (((Item) target).material() & RawMaterial.MATERIAL_MASK) {
              case RawMaterial.MATERIAL_CLOTH:
              case RawMaterial.MATERIAL_FLESH:
              case RawMaterial.MATERIAL_LEATHER:
              case RawMaterial.MATERIAL_PAPER:
              case RawMaterial.MATERIAL_VEGETATION:
              case RawMaterial.MATERIAL_WOODEN:
                {
                  mob.location()
                      .showHappens(CMMsg.MSG_OK_VISUAL, L("@x1 rots away!", target.name()));
                  if (target instanceof Container) ((Container) target).emptyPlease(false);
                  ((Item) target).destroy();
                  break;
                }
              default:
                mob.location()
                    .showHappens(
                        CMMsg.MSG_OK_VISUAL,
                        L("@x1 ages, but nothing happens to it.", target.name()));
                break;
            }
          } else
            mob.location()
                .showHappens(
                    CMMsg.MSG_OK_VISUAL, L("@x1 ages, but nothing happens to it.", target.name()));
          success = false;
        } else if ((target instanceof MOB) && ((A == null) || (A.displayText().length() == 0))) {
          final MOB M = (MOB) target;
          mob.location().show(M, null, CMMsg.MSG_OK_VISUAL, L("<S-NAME> age(s) a bit."));
          if (M.baseCharStats().getStat(CharStats.STAT_AGE) <= 0)
            M.setAgeMinutes(M.getAgeMinutes() + (M.getAgeMinutes() / 10));
          else if ((M.playerStats() != null) && (M.playerStats().getBirthday() != null)) {
            final TimeClock C = CMLib.time().localClock(M.getStartRoom());
            final double aging = CMath.mul(M.baseCharStats().getStat(CharStats.STAT_AGE), .10);
            int years = (int) Math.round(Math.floor(aging));
            final int monthsInYear = C.getMonthsInYear();
            int months = (int) Math.round(CMath.mul(aging - Math.floor(aging), monthsInYear));
            if ((years <= 0) && (months == 0)) months++;
            M.playerStats().getBirthday()[PlayerStats.BIRTHDEX_YEAR] -= years;
            M.playerStats().getBirthday()[PlayerStats.BIRTHDEX_MONTH] -= months;
            if (M.playerStats().getBirthday()[PlayerStats.BIRTHDEX_MONTH] < 1) {
              M.playerStats().getBirthday()[PlayerStats.BIRTHDEX_YEAR]--;
              years++;
              M.playerStats().getBirthday()[PlayerStats.BIRTHDEX_MONTH] =
                  monthsInYear + M.playerStats().getBirthday()[PlayerStats.BIRTHDEX_MONTH];
            }
            M.baseCharStats()
                .setStat(CharStats.STAT_AGE, M.baseCharStats().getStat(CharStats.STAT_AGE) + years);
          }
          M.recoverPhyStats();
          M.recoverCharStats();
        } else if (A != null) {
          final long start = CMath.s_long(A.text());
          long age = System.currentTimeMillis() - start;
          final long millisPerMudday =
              CMProps.getIntVar(CMProps.Int.TICKSPERMUDDAY) * CMProps.getTickMillis();
          if (age < millisPerMudday) age = millisPerMudday;
          final long millisPerMonth = CMLib.time().globalClock().getDaysInMonth() * millisPerMudday;
          final long millisPerYear = CMLib.time().globalClock().getMonthsInYear() * millisPerMonth;
          long ageBy = age / 10;
          if (ageBy < millisPerMonth) ageBy = millisPerMonth + 1;
          else if (ageBy < millisPerYear) ageBy = millisPerYear + 1;
          A.setMiscText("" + (start - ageBy));
          if (target instanceof MOB)
            mob.location()
                .show((MOB) target, null, CMMsg.MSG_OK_VISUAL, L("<S-NAME> age(s) a bit."));
          else mob.location().showHappens(CMMsg.MSG_OK_VISUAL, L("@x1 ages a bit.", target.name()));
          target.recoverPhyStats();
        } else
          return beneficialWordsFizzle(
              mob, target, L("<S-NAME> chant(s) to <T-NAMESELF>, but the magic fades."));
      }
    } else if (CMath.bset(type, CMMsg.MASK_MALICIOUS))
      return maliciousFizzle(
          mob, target, L("<S-NAME> chant(s) to <T-NAMESELF>, but the magic fades."));
    else
      return beneficialWordsFizzle(
          mob, target, L("<S-NAME> chant(s) to <T-NAMESELF>, but the magic fades."));

    // return whether it worked
    return success;
  }
Пример #25
0
  public String systemReport(String itemCode) {
    long totalMOBMillis = 0;
    long totalMOBTicks = 0;
    long topMOBMillis = 0;
    long topMOBTicks = 0;
    MOB topMOBClient = null;
    for (int s = 0; s < CMLib.sessions().size(); s++) {
      Session S = CMLib.sessions().elementAt(s);
      totalMOBMillis += S.getTotalMillis();
      totalMOBTicks += S.getTotalTicks();
      if (S.getTotalMillis() > topMOBMillis) {
        topMOBMillis = S.getTotalMillis();
        topMOBTicks = S.getTotalTicks();
        topMOBClient = S.mob();
      }
    }

    if (itemCode.equalsIgnoreCase("totalMOBMillis")) return "" + totalMOBMillis;
    else if (itemCode.equalsIgnoreCase("totalMOBMillisTime"))
      return CMLib.english().returnTime(totalMOBMillis, 0);
    else if (itemCode.equalsIgnoreCase("totalMOBMillisTimePlusAverage"))
      return CMLib.english().returnTime(totalMOBMillis, totalMOBTicks);
    else if (itemCode.equalsIgnoreCase("totalMOBTicks")) return "" + totalMOBTicks;
    else if (itemCode.equalsIgnoreCase("topMOBMillis")) return "" + topMOBMillis;
    else if (itemCode.equalsIgnoreCase("topMOBMillisTime"))
      return CMLib.english().returnTime(topMOBMillis, 0);
    else if (itemCode.equalsIgnoreCase("topMOBMillisTimePlusAverage"))
      return CMLib.english().returnTime(topMOBMillis, topMOBTicks);
    else if (itemCode.equalsIgnoreCase("topMOBTicks")) return "" + topMOBTicks;
    else if (itemCode.equalsIgnoreCase("topMOBClient")) {
      if (topMOBClient != null) return topMOBClient.Name();
      return "";
    }

    int totalTickers = 0;
    long totalMillis = 0;
    long totalTicks = 0;
    int topGroupNumber = -1;
    long topGroupMillis = -1;
    long topGroupTicks = 0;
    long topObjectMillis = -1;
    long topObjectTicks = 0;
    int topObjectGroup = 0;
    Tickable topObjectClient = null;
    int num = 0;
    Tick almostTock = null;
    for (Iterator<Tick> e = tickGroups(); e.hasNext(); ) {
      almostTock = e.next();
      totalTickers += almostTock.numTickers();
      totalMillis += almostTock.milliTotal;
      totalTicks += almostTock.tickTotal;
      if (almostTock.milliTotal > topGroupMillis) {
        topGroupMillis = almostTock.milliTotal;
        topGroupTicks = almostTock.tickTotal;
        topGroupNumber = num;
      }
      try {
        for (Iterator et = almostTock.tickers(); et.hasNext(); ) {
          TockClient C = (TockClient) et.next();
          if (C.milliTotal > topObjectMillis) {
            topObjectMillis = C.milliTotal;
            topObjectTicks = C.tickTotal;
            topObjectClient = C.clientObject;
            topObjectGroup = num;
          }
        }
      } catch (NoSuchElementException ex) {
      }
      num++;
    }
    if (itemCode.equalsIgnoreCase("freeMemory"))
      return "" + (Runtime.getRuntime().freeMemory() / 1000);
    else if (itemCode.equalsIgnoreCase("totalMemory"))
      return "" + (Runtime.getRuntime().totalMemory() / 1000);
    else if (itemCode.equalsIgnoreCase("totalTime"))
      return ""
          + CMLib.english().returnTime(System.currentTimeMillis() - CMSecurity.getStartTime(), 0);
    else if (itemCode.equalsIgnoreCase("startTime"))
      return CMLib.time().date2String(CMSecurity.getStartTime());
    else if (itemCode.equalsIgnoreCase("currentTime"))
      return CMLib.time().date2String(System.currentTimeMillis());
    else if (itemCode.equalsIgnoreCase("totalTickers")) return "" + totalTickers;
    else if (itemCode.equalsIgnoreCase("totalMillis")) return "" + totalMillis;
    else if (itemCode.equalsIgnoreCase("totalMillisTime"))
      return CMLib.english().returnTime(totalMillis, 0);
    else if (itemCode.equalsIgnoreCase("totalMillisTimePlusAverage"))
      return CMLib.english().returnTime(totalMillis, totalTicks);
    else if (itemCode.equalsIgnoreCase("totalTicks")) return "" + totalTicks;
    else if (itemCode.equalsIgnoreCase("tickgroupsize")) return "" + ticks.size();
    else if (itemCode.equalsIgnoreCase("topGroupNumber")) return "" + topGroupNumber;
    else if (itemCode.equalsIgnoreCase("topGroupMillis")) return "" + topGroupMillis;
    else if (itemCode.equalsIgnoreCase("topGroupMillisTime"))
      return CMLib.english().returnTime(topGroupMillis, 0);
    else if (itemCode.equalsIgnoreCase("topGroupMillisTimePlusAverage"))
      return CMLib.english().returnTime(topGroupMillis, topGroupTicks);
    else if (itemCode.equalsIgnoreCase("topGroupTicks")) return "" + topGroupTicks;
    else if (itemCode.equalsIgnoreCase("topObjectMillis")) return "" + topObjectMillis;
    else if (itemCode.equalsIgnoreCase("topObjectMillisTime"))
      return CMLib.english().returnTime(topObjectMillis, 0);
    else if (itemCode.equalsIgnoreCase("topObjectMillisTimePlusAverage"))
      return CMLib.english().returnTime(topObjectMillis, topObjectTicks);
    else if (itemCode.equalsIgnoreCase("topObjectTicks")) return "" + topObjectTicks;
    else if (itemCode.equalsIgnoreCase("topObjectGroup")) return "" + topObjectGroup;
    else if (itemCode.toLowerCase().startsWith("thread")) {
      int xstart = "thread".length();
      int xend = xstart;
      while ((xend < itemCode.length()) && (Character.isDigit(itemCode.charAt(xend)))) xend++;
      int threadNum = CMath.s_int(itemCode.substring(xstart, xend));
      int curThreadNum = 0;
      for (Enumeration e = CMLib.libraries(); e.hasMoreElements(); ) {
        CMLibrary lib = (CMLibrary) e.nextElement();
        ThreadEngine.SupportThread thread = lib.getSupportThread();
        if (thread != null) {
          if (curThreadNum == threadNum) {
            String instrCode = itemCode.substring(xend);
            if (instrCode.equalsIgnoreCase("miliTotal")) return "" + thread.milliTotal;
            if (instrCode.equalsIgnoreCase("milliTotal")) return "" + thread.milliTotal;
            if (instrCode.equalsIgnoreCase("status")) return "" + thread.status;
            if (instrCode.equalsIgnoreCase("name")) return "" + thread.getName();
            if (instrCode.equalsIgnoreCase("MilliTotalTime"))
              return CMLib.english().returnTime(thread.milliTotal, 0);
            if (instrCode.equalsIgnoreCase("MiliTotalTime"))
              return CMLib.english().returnTime(thread.milliTotal, 0);
            if (instrCode.equalsIgnoreCase("MilliTotalTimePlusAverage"))
              return CMLib.english().returnTime(thread.milliTotal, thread.tickTotal);
            if (instrCode.equalsIgnoreCase("MiliTotalTimePlusAverage"))
              return CMLib.english().returnTime(thread.milliTotal, thread.tickTotal);
            if (instrCode.equalsIgnoreCase("TickTotal")) return "" + thread.tickTotal;
            break;
          }
          curThreadNum++;
        }
      }
    }
    if (itemCode.equalsIgnoreCase("topObjectClient")) {
      if (topObjectClient != null) return topObjectClient.name();
      return "";
    }

    return "";
  }