Beispiel #1
0
  public String tickInfo(String which) {
    int grpstart = -1;
    for (int i = 0; i < which.length(); i++)
      if (Character.isDigit(which.charAt(i))) {
        grpstart = i;
        break;
      }
    if (which.equalsIgnoreCase("tickGroupSize")) return "" + ticks.size();
    else if (which.toLowerCase().startsWith("tickerssize")) {
      if (grpstart < 0) return "";
      int group = CMath.s_int(which.substring(grpstart));
      if ((group >= 0) && (group < ticks.size()))
        return "" + ((Tick) ticks.get(group)).numTickers();
      return "";
    }
    int group = -1;
    int client = -1;
    int clistart = which.indexOf("-");
    if ((grpstart >= 0) && (clistart > grpstart)) {
      group = CMath.s_int(which.substring(grpstart, clistart));
      client = CMath.s_int(which.substring(clistart + 1));
    }

    if ((group < 0) || (client < 0) || (group >= ticks.size())) return "";
    Tick almostTock = (Tick) ticks.get(group);

    if (client >= almostTock.numTickers()) return "";
    TockClient C = almostTock.fetchTickerByIndex(client);
    if (C == null) return "";

    if (which.toLowerCase().startsWith("tickername")) {
      Tickable E = C.clientObject;
      if ((E instanceof Ability) && (E.ID().equals("ItemRejuv"))) E = ((Ability) E).affecting();
      if (E instanceof Room) return CMLib.map().getExtendedRoomID((Room) E);
      if (E != null) return E.name();
      return "!NULL!";
    } else if (which.toLowerCase().startsWith("tickerid")) return "" + C.tickID;
    else if (which.toLowerCase().startsWith("tickerstatus"))
      return ((C.clientObject == null) ? "" : ("" + C.clientObject.getTickStatus()));
    else if (which.toLowerCase().startsWith("tickercodeword"))
      return getTickStatusSummary(C.clientObject);
    else if (which.toLowerCase().startsWith("tickertickdown")) return "" + C.tickDown;
    else if (which.toLowerCase().startsWith("tickerretickdown")) return "" + C.reTickDown;
    else if (which.toLowerCase().startsWith("tickermillitotal")) return "" + C.milliTotal;
    else if (which.toLowerCase().startsWith("tickermilliavg")) {
      if (C.tickTotal == 0) return "0";
      return "" + (C.milliTotal / C.tickTotal);
    } else if (which.toLowerCase().startsWith("tickerlaststartmillis")) return "" + C.lastStart;
    else if (which.toLowerCase().startsWith("tickerlaststopmillis")) return "" + C.lastStop;
    else if (which.toLowerCase().startsWith("tickerlaststartdate"))
      return CMLib.time().date2String(C.lastStart);
    else if (which.toLowerCase().startsWith("tickerlaststopdate"))
      return CMLib.time().date2String(C.lastStop);
    else if (which.toLowerCase().startsWith("tickerlastduration")) {
      if (C.lastStop >= C.lastStart) return CMLib.english().returnTime(C.lastStop - C.lastStart, 0);
      return CMLib.english().returnTime(System.currentTimeMillis() - C.lastStart, 0);
    } else if (which.toLowerCase().startsWith("tickersuspended")) return "" + C.suspended;
    return "";
  }
 @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;
 }
  @Override
  public boolean invoke(
      MOB mob, List<String> commands, Physical givenTarget, boolean auto, int asLevel) {
    Physical target = null;
    if (commands.size() > 0) {
      final String s = CMParms.combine(commands, 0);
      if (s.equalsIgnoreCase("room")) target = mob.location();
      else if (s.equalsIgnoreCase("here")) target = mob.location();
      else if (CMLib.english().containsString(mob.location().ID(), s)
          || CMLib.english().containsString(mob.location().name(), s)
          || CMLib.english().containsString(mob.location().displayText(), s))
        target = mob.location();
    }
    if (target == null) target = getTarget(mob, commands, givenTarget);
    if (target == null) return false;
    if ((target instanceof Room) && (target.fetchEffect(ID()) != null)) {
      mob.tell(L("This place is already under a teleportation ward."));
      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> seem(s) magically protected.")
                  : L("^S<S-NAME> invoke(s) a teleportation ward upon <T-NAMESELF>.^?"));
      if (mob.location().okMessage(mob, msg)) {
        mob.location().send(mob, msg);
        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> attempt(s) to invoke a teleportation ward, but fail(s)."));

    return success;
  }
  @Override
  public boolean invoke(
      MOB mob, List<String> commands, Physical givenTarget, boolean auto, int asLevel) {
    if (commands.size() < 1) {
      mob.tell(
          L(
              "You must specify an item to fence, and possibly a ShopKeeper (unless it is implied)."));
      return false;
    }

    commands.add(0, "SELL"); // will be instantly deleted by parseshopkeeper
    final Environmental shopkeeper =
        CMLib.english().parseShopkeeper(mob, commands, L("Fence what to whom?"));
    if (shopkeeper == null) return false;
    if (commands.size() == 0) {
      mob.tell(L("Fence what?"));
      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,
              shopkeeper,
              this,
              CMMsg.MSG_SPEAK,
              auto ? "" : L("<S-NAME> fence(s) stolen loot to <T-NAMESELF>."));
      if (mob.location().okMessage(mob, msg)) {
        mob.location().send(mob, msg);
        invoker = mob;
        addBackMap.clear();
        mob.addEffect(this);
        mob.recoverCharStats();
        commands.add(0, CMStrings.capitalizeAndLower("SELL"));
        mob.doCommand(commands, MUDCmdProcessor.METAFLAG_FORCED);
        commands.add(shopkeeper.name());
        mob.delEffect(this);
        for (Item I : addBackMap.keySet()) {
          if (mob.isMine(I)) {
            I.addEffect(addBackMap.get(I));
          }
        }
        addBackMap.clear();
        mob.recoverCharStats();
      }
    } else
      beneficialWordsFizzle(
          mob,
          shopkeeper,
          L(
              "<S-NAME> attempt(s) to fence stolen loot to <T-NAMESELF>, but make(s) <T-HIM-HER> too nervous."));

    // return whether it worked
    return success;
  }
  @Override
  public boolean invoke(
      MOB mob, List<String> commands, Physical givenTarget, boolean auto, int asLevel) {
    if (!super.invoke(mob, commands, givenTarget, auto, asLevel)) return false;

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

    final boolean success = proficiencyCheck(mob, 0, auto);
    if (success) {
      final CMMsg msg =
          CMClass.getMsg(
              mob,
              null,
              this,
              verbalCastCode(mob, null, auto),
              auto
                  ? ""
                  : L("^S<S-NAME> @x1 for knowledge of the lower law here.^?", prayWord(mob)));
      if (mob.location().okMessage(mob, msg)) {
        mob.location().send(mob, msg);
        final Area O = CMLib.law().getLegalObject(mob.location());
        final LegalBehavior B = CMLib.law().getLegalBehavior(mob.location());
        if ((B == null) || (O == null)) mob.tell(L("No lower law is established here."));
        else {
          final Law L = B.legalInfo(O);
          final Vector<String> crimes = new Vector<String>();
          possiblyAddLaw(L, crimes, "TRESPASSING");
          possiblyAddLaw(L, crimes, "ASSAULT");
          possiblyAddLaw(L, crimes, "MURDER");
          possiblyAddLaw(L, crimes, "NUDITY");
          possiblyAddLaw(L, crimes, "ARMED");
          possiblyAddLaw(L, crimes, "RESISTINGARREST");
          possiblyAddLaw(L, crimes, "PROPERTYROB");
          for (final String key : L.abilityCrimes().keySet())
            if (key.startsWith("$")) crimes.add(key.substring(1));
          if (L.taxLaws().containsKey("TAXEVASION"))
            crimes.add(((String[]) L.taxLaws().get("TAXEVASION"))[Law.BIT_CRIMENAME]);
          for (int x = 0; x < L.bannedSubstances().size(); x++) {
            final String name = L.bannedBits().get(x)[Law.BIT_CRIMENAME];
            if (!crimes.contains(name)) crimes.add(name);
          }
          for (int x = 0; x < L.otherCrimes().size(); x++) {
            final String name = L.otherBits().get(x)[Law.BIT_CRIMENAME];
            if (!crimes.contains(name)) crimes.add(name);
          }
          mob.tell(
              L(
                  "The following lower crimes are divinely revealed to you: @x1.",
                  CMLib.english().toEnglishStringList(crimes.toArray(new String[0]))));
        }
      }
    } else
      beneficialWordsFizzle(mob, null, L("<S-NAME> @x1, but nothing is revealed.", prayWord(mob)));

    return success;
  }
 @Override
 protected boolean canMend(MOB mob, Environmental E, boolean quiet) {
   if (!super.canMend(mob, E, quiet)) return false;
   if ((!(E instanceof Item)) || (!mayICraft((Item) E))) {
     if (!quiet)
       commonTell(
           mob, L("That's not @x1 item.", CMLib.english().startWithAorAn(Name().toLowerCase())));
     return false;
   }
   return true;
 }
Beispiel #7
0
  @Override
  public boolean invoke(MOB mob, Vector commands, Physical givenTarget, boolean auto, int asLevel) {
    String cmd = "";
    if (commands.size() > 0) cmd = ((String) commands.firstElement()).toUpperCase();

    if ((commands.size() < 2) || ((!cmd.equals("BUY") && (!cmd.equals("SELL"))))) {
      mob.tell(
          L(
              "You must specify BUY, SELL, an item, and possibly a ShopKeeper (unless it is implied)."));
      return false;
    }

    final Environmental shopkeeper =
        CMLib.english()
            .parseShopkeeper(mob, commands, CMStrings.capitalizeAndLower(cmd) + " what to whom?");
    if (shopkeeper == null) return false;
    if (commands.size() == 0) {
      mob.tell(L("@x1 what?", CMStrings.capitalizeAndLower(cmd)));
      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,
              shopkeeper,
              this,
              CMMsg.MSG_SPEAK,
              auto ? "" : L("<S-NAME> haggle(s) with <T-NAMESELF>."));
      if (mob.location().okMessage(mob, msg)) {
        mob.location().send(mob, msg);
        invoker = mob;
        mob.addEffect(this);
        mob.recoverCharStats();
        commands.insertElementAt(CMStrings.capitalizeAndLower(cmd), 0);
        mob.doCommand(commands, Command.METAFLAG_FORCED);
        commands.addElement(shopkeeper.name());
        mob.delEffect(this);
        mob.recoverCharStats();
      }
    } else
      beneficialWordsFizzle(
          mob, shopkeeper, L("<S-NAME> haggle(s) with <T-NAMESELF>, but <S-IS-ARE> unconvincing."));

    // return whether it worked
    return success;
  }
Beispiel #8
0
  public StringBuilder getInventory(MOB seer, MOB mob, String mask) {
    final StringBuilder msg = new StringBuilder("");
    final InventoryList list = fetchInventory(seer, mob);
    if (((list.viewItems.size() > 0) || (list.moneyItems.size() > 0)) && (!list.foundAndSeen)) {
      list.viewItems.clear();
      list.moneyItems.clear();
      list.foundButUnseen = true;
    } else if ((mask != null) && (mask.trim().length() > 0)) {
      mask = mask.trim().toUpperCase();
      if (!mask.startsWith("all")) mask = "all " + mask;
      final Vector<Item> V = (Vector<Item>) list.viewItems.clone();
      list.viewItems.clear();
      Item I = (V.size() > 0) ? (Item) V.get(0) : null;
      while (I != null) {
        I = (Item) CMLib.english().fetchEnvironmental(V, mask, false);
        if (I != null) {
          list.viewItems.add(I);
          V.remove(I);
        }
      }
    }
    if ((list.viewItems.size() == 0) && (list.moneyItems.size() == 0)) {
      if ((mask != null) && (mask.trim().length() > 0))
        msg.append(L("(nothing like that you can see right now)"));
      else msg.append(L("(nothing you can see right now)"));
    } else {
      if (list.viewItems.size() > 0)
        msg.append(
            CMLib.lister()
                .lister(
                    seer,
                    list.viewItems,
                    true,
                    "MItem",
                    "",
                    false,
                    seer.isAttribute(MOB.Attrib.COMPRESS)));
      if (list.foundButUnseen) msg.append(L("(stuff you can't see right now)"));

      msg.append(getShowableMoney(list));
    }
    return msg;
  }
Beispiel #9
0
  @Override
  public boolean invoke(
      MOB mob, List<String> commands, Physical givenTarget, boolean auto, int asLevel) {
    timeOut = 0;
    if (auto) return false;

    final Hashtable<String, String> H = getSongs();
    if (commands.size() == 0) {
      final Song_Ode A = (Song_Ode) mob.fetchEffect(ID());
      if ((A != null) && (A.whom != null) && (A.song == null)) {
        final String str = L("^S<S-NAME> finish(es) composing the @x1.^?", A.songOf());
        final CMMsg msg =
            CMClass.getMsg(
                mob,
                null,
                this,
                (auto ? CMMsg.MASK_ALWAYS : 0) | CMMsg.MSG_DELICATE_SMALL_HANDS_ACT,
                str);
        if (mob.location().okMessage(mob, msg)) {
          mob.location().send(mob, msg);
          mob.delEffect(A);
          getSongs().put(A.whom.name(), A.composition());
          whom = null;
          return true;
        }
        return false;
      }

      final StringBuffer str = new StringBuffer("");
      for (final Enumeration<String> e = H.keys(); e.hasMoreElements(); )
        str.append(e.nextElement() + " ");
      mob.tell(L("Compose or sing an ode about whom?"));
      if (str.length() > 0)
        mob.tell(L("You presently have odes written about: @x1.", str.toString().trim()));
      return false;
    }
    String name = CMParms.combine(commands, 0);
    for (final Enumeration<String> e = H.keys(); e.hasMoreElements(); ) {
      final String key = e.nextElement();
      if (CMLib.english().containsString(key, name)) {
        invoker = mob;
        originRoom = mob.location();
        commonRoomSet = getInvokerScopeRoomSet(null);
        name = key;
        song = H.get(name);
        benefits = null;
        whom = mob.location().fetchInhabitant(name);
        if ((whom == null) || (!whom.name().equals(name))) whom = CMLib.players().getPlayer(name);
        if ((whom == null) || (!whom.name().equals(name))) {
          whom = CMClass.getMOB("StdMOB");
          whom.setName(name);
          whom.setLocation(mob.location());
        }
        return super.invoke(mob, commands, givenTarget, auto, asLevel);
      }
    }

    final MOB target = getTarget(mob, commands, givenTarget);
    if (target == null) return false;
    if (target == mob) {
      mob.tell(L("You may not compose an ode about yourself!"));
      return false;
    }

    final boolean success = proficiencyCheck(mob, 0, auto);
    if (success) {
      unsingAll(mob, mob);
      invoker = mob;
      originRoom = mob.location();
      commonRoomSet = getInvokerScopeRoomSet(null);
      whom = target;
      final String str = L("^S<S-NAME> begin(s) to compose an @x1.^?", songOf());
      final CMMsg msg =
          CMClass.getMsg(
              mob,
              null,
              this,
              (auto ? CMMsg.MASK_ALWAYS : 0) | CMMsg.MSG_DELICATE_SMALL_HANDS_ACT,
              str);
      if (mob.location().okMessage(mob, msg)) {
        mob.location().send(mob, msg);
        invoker = mob;
        final Song_Ode newOne = (Song_Ode) copyOf();
        newOne.whom = target;
        newOne.trail = new StringBuffer("");
        newOne.song = null;
        mob.addEffect(newOne);
      }
    } else
      mob.location()
          .show(mob, null, CMMsg.MSG_NOISE, L("<S-NAME> lose(s) <S-HIS-HER> inspiration."));
    return success;
  }
Beispiel #10
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;
  }
  @Override
  protected boolean autoGenInvoke(
      final MOB mob,
      List<String> commands,
      Physical givenTarget,
      final boolean auto,
      final int asLevel,
      int autoGenerate,
      boolean forceLevels,
      List<Item> crafted) {
    if (super.checkStop(mob, commands)) return true;

    if (super.checkInfo(mob, commands)) return true;

    final PairVector<EnhancedExpertise, Integer> enhancedTypes = enhancedTypes(mob, commands);
    randomRecipeFix(mob, addRecipes(mob, loadRecipes()), commands, autoGenerate);
    if (commands.size() == 0) {
      commonTell(
          mob,
          L(
              "Make what? Enter \"mleatherwork list\" for a list, \"mleatherworkd info <item>\", \"mleatherwork refit <item>\" to resize,"
                  + " \"mleatherwork learn <item>\", \"mleatherwork scan\", \"mleatherwork mend <item>\", or \"mleatherwork stop\" to cancel."));
      return false;
    }
    if ((!auto) && (commands.size() > 0) && ((commands.get(0)).equalsIgnoreCase("bundle"))) {
      bundling = true;
      if (super.invoke(mob, commands, givenTarget, auto, asLevel))
        return super.bundle(mob, commands);
      return false;
    }
    final List<List<String>> recipes = addRecipes(mob, loadRecipes());
    final String str = commands.get(0);
    playSound = "scissor.wav";
    String startStr = null;
    bundling = false;
    int multiplier = 4;
    int duration = 4;
    if (str.equalsIgnoreCase("list")) {
      String mask = CMParms.combine(commands, 1);
      boolean allFlag = false;
      if (mask.equalsIgnoreCase("all")) {
        allFlag = true;
        mask = "";
      }
      final StringBuffer buf = new StringBuffer("");
      int toggler = 1;
      final int toggleTop = 2;
      final int[] cols = {
        CMLib.lister().fixColWidth(30, mob.session()),
        CMLib.lister().fixColWidth(3, mob.session()),
        CMLib.lister().fixColWidth(3, mob.session())
      };
      for (int r = 0; r < toggleTop; r++)
        buf.append(
            (r > 0 ? " " : "")
                + CMStrings.padRight(L("Item"), cols[0])
                + " "
                + CMStrings.padRight(L("Lvl"), cols[1])
                + " "
                + CMStrings.padRight(L("Amt"), cols[2]));
      buf.append("\n\r");
      for (int r = 0; r < recipes.size(); r++) {
        final List<String> V = recipes.get(r);
        if (V.size() > 0) {
          final String item = replacePercent(V.get(RCP_FINALNAME), "");
          final int level = CMath.s_int(V.get(RCP_LEVEL));
          final String wood = getComponentDescription(mob, V, RCP_WOOD);
          if (wood.length() > 5) {
            if (toggler > 1) buf.append("\n\r");
            toggler = toggleTop;
          }
          if (((level <= xlevel(mob)) || allFlag)
              && ((mask.length() == 0)
                  || mask.equalsIgnoreCase("all")
                  || CMLib.english().containsString(item, mask))) {
            buf.append(
                CMStrings.padRight(item, cols[0])
                    + " "
                    + CMStrings.padRight("" + (level), cols[1])
                    + " "
                    + CMStrings.padRightPreserve("" + wood, cols[2])
                    + ((toggler != toggleTop) ? " " : "\n\r"));
            if (++toggler > toggleTop) toggler = 1;
          }
        }
      }
      if (toggler != 1) buf.append("\n\r");
      commonTell(mob, buf.toString());
      enhanceList(mob);
      return true;
    } else if (((commands.get(0))).equalsIgnoreCase("learn")) {
      return doLearnRecipe(mob, commands, givenTarget, auto, asLevel);
    } else if (str.equalsIgnoreCase("scan")) return publicScan(mob, commands);
    else if (str.equalsIgnoreCase("mend")) {
      buildingI = null;
      activity = CraftingActivity.CRAFTING;
      messedUp = false;
      final Vector<String> newCommands = CMParms.parse(CMParms.combine(commands, 1));
      buildingI =
          getTarget(mob, mob.location(), givenTarget, newCommands, Wearable.FILTER_UNWORNONLY);
      if (!canMend(mob, buildingI, false)) return false;
      activity = CraftingActivity.MENDING;
      if (!super.invoke(mob, commands, givenTarget, auto, asLevel)) return false;
      startStr = L("<S-NAME> start(s) mending @x1.", buildingI.name());
      displayText = L("You are mending @x1", buildingI.name());
      verb = L("mending @x1", buildingI.name());
    } else if (str.equalsIgnoreCase("refit")) {
      buildingI = null;
      activity = CraftingActivity.CRAFTING;
      messedUp = false;
      final Vector<String> newCommands = CMParms.parse(CMParms.combine(commands, 1));
      buildingI =
          getTarget(mob, mob.location(), givenTarget, newCommands, Wearable.FILTER_UNWORNONLY);
      if (buildingI == null) return false;
      if ((buildingI.material() & RawMaterial.MATERIAL_MASK) != RawMaterial.MATERIAL_LEATHER) {
        commonTell(mob, L("That's not made of leather.  That can't be refitted."));
        return false;
      }
      if (!(buildingI instanceof Armor)) {
        commonTell(mob, L("You don't know how to refit that sort of thing."));
        return false;
      }
      if (buildingI.phyStats().height() == 0) {
        commonTell(mob, L("@x1 is already the right size.", buildingI.name(mob)));
        return false;
      }
      activity = CraftingActivity.REFITTING;
      if (!super.invoke(mob, commands, givenTarget, auto, asLevel)) return false;
      startStr = L("<S-NAME> start(s) refitting @x1.", buildingI.name());
      displayText = L("You are refitting @x1", buildingI.name());
      verb = L("refitting @x1", buildingI.name());
    } else {
      buildingI = null;
      activity = CraftingActivity.CRAFTING;
      messedUp = false;
      aborted = false;
      int amount = -1;
      if ((commands.size() > 1) && (CMath.isNumber(commands.get(commands.size() - 1)))) {
        amount = CMath.s_int(commands.get(commands.size() - 1));
        commands.remove(commands.size() - 1);
      }
      final String recipeName = CMParms.combine(commands, 0);
      List<String> foundRecipe = null;
      final List<List<String>> matches = matchingRecipeNames(recipes, recipeName, true);
      for (int r = 0; r < matches.size(); r++) {
        final List<String> V = matches.get(r);
        if (V.size() > 0) {
          final String name = V.get(RCP_FINALNAME);
          final int level = CMath.s_int(V.get(RCP_LEVEL));
          if (level <= xlevel(mob)) {
            final int x = name.indexOf(' ');
            final Stage stage = Stage.valueOf(name.substring(0, x));
            multiplier = stage.multiplier;
            foundRecipe = V;
            break;
          }
        }
      }
      if (foundRecipe == null) {
        commonTell(
            mob,
            L(
                "You don't know how to make a '@x1'.  Try \"mleatherwork list\" for a list.",
                recipeName));
        return false;
      }

      final String woodRequiredStr = foundRecipe.get(RCP_WOOD);
      final int[] compData = new int[CF_TOTAL];
      final List<Object> componentsFoundList =
          getAbilityComponents(
              mob,
              woodRequiredStr,
              "make " + CMLib.english().startWithAorAn(recipeName),
              autoGenerate,
              compData);
      if (componentsFoundList == null) return false;
      int woodRequired = CMath.s_int(woodRequiredStr);
      woodRequired = adjustWoodRequired(woodRequired, mob);

      if (amount > woodRequired) woodRequired = amount;
      final int[] pm = {RawMaterial.MATERIAL_LEATHER};
      final int[] pm1 = {RawMaterial.MATERIAL_METAL, RawMaterial.MATERIAL_MITHRIL};
      final String misctype = foundRecipe.get(RCP_MISCTYPE);
      bundling = misctype.equalsIgnoreCase("BUNDLE");
      final int[][] data =
          fetchFoundResourceData(
              mob,
              woodRequired,
              "leather",
              pm,
              (multiplier == 6) ? 1 : 0,
              (multiplier == 6) ? "metal" : null,
              (multiplier == 6) ? pm1 : null,
              bundling,
              autoGenerate,
              enhancedTypes);
      if (data == null) return false;
      fixDataForComponents(data, componentsFoundList);
      woodRequired = data[0][FOUND_AMT];
      if (!super.invoke(mob, commands, givenTarget, auto, asLevel)) return false;
      final int lostValue =
          autoGenerate > 0
              ? 0
              : CMLib.materials()
                      .destroyResourcesValue(
                          mob.location(),
                          woodRequired,
                          data[0][FOUND_CODE],
                          data[1][FOUND_CODE],
                          null)
                  + CMLib.ableComponents().destroyAbilityComponents(componentsFoundList);
      buildingI = CMClass.getItem(foundRecipe.get(RCP_CLASSTYPE));
      if (buildingI == null) {
        commonTell(mob, L("There's no such thing as a @x1!!!", foundRecipe.get(RCP_CLASSTYPE)));
        return false;
      }
      duration = getDuration(multiplier * CMath.s_int(foundRecipe.get(RCP_TICKS)), mob, 30, 4);
      buildingI.setMaterial(super.getBuildingMaterial(woodRequired, data, compData));
      String itemName =
          (replacePercent(
                  foundRecipe.get(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);
      buildingI.setName(itemName);
      startStr = L("<S-NAME> start(s) making @x1.", buildingI.name());
      displayText = L("You are making @x1", buildingI.name());
      verb = L("making @x1", buildingI.name());
      buildingI.setDisplayText(L("@x1 lies here", itemName));
      buildingI.setDescription(itemName + ". ");
      buildingI
          .basePhyStats()
          .setWeight(getStandardWeight(woodRequired + compData[CF_AMOUNT], bundling));
      buildingI.setBaseValue(CMath.s_int(foundRecipe.get(RCP_VALUE)) * multiplier);
      buildingI.setSecretIdentity(getBrand(mob));
      final int hardness = RawMaterial.CODES.HARDNESS(buildingI.material()) - 2;
      buildingI.basePhyStats().setLevel(CMath.s_int(foundRecipe.get(RCP_LEVEL)) + hardness);
      final int capacity = CMath.s_int(foundRecipe.get(RCP_CAPACITY));
      final long canContain = getContainerType(foundRecipe.get(RCP_CONTAINMASK));
      int armordmg = CMath.s_int(foundRecipe.get(RCP_ARMORDMG));
      if (armordmg != 0) armordmg = armordmg + (multiplier - 1);
      if (bundling) buildingI.setBaseValue(lostValue);
      final String spell =
          (foundRecipe.size() > RCP_SPELL) ? foundRecipe.get(RCP_SPELL).trim() : "";
      addSpells(buildingI, spell);
      if (buildingI instanceof Weapon) {
        ((Weapon) buildingI)
            .basePhyStats()
            .setAttackAdjustment(baseYield() + abilityCode() + (hardness * 5) - 1);
        ((Weapon) buildingI).setWeaponClassification(Weapon.CLASS_FLAILED);
        setWeaponTypeClass((Weapon) buildingI, misctype, Weapon.TYPE_SLASHING);
        buildingI.basePhyStats().setDamage(armordmg + hardness);
        ((Weapon) buildingI).setRawProperLocationBitmap(Wearable.WORN_WIELD | Wearable.WORN_HELD);
        ((Weapon) buildingI).setRawLogicalAnd((capacity > 1));
      }
      if ((buildingI instanceof Armor) && (!(buildingI instanceof FalseLimb))) {
        if ((capacity > 0) && (buildingI instanceof Container)) {
          ((Container) buildingI).setCapacity(capacity + woodRequired);
          ((Container) buildingI).setContainTypes(canContain);
        }
        ((Armor) buildingI).basePhyStats().setArmor(0);
        if (armordmg != 0)
          ((Armor) buildingI)
              .basePhyStats()
              .setArmor(armordmg + (baseYield() + abilityCode() - 1) + hardness);
        setWearLocation(buildingI, misctype, 0);
      }
      if (buildingI instanceof Drink) {
        if (CMLib.flags().isGettable(buildingI)) {
          ((Drink) buildingI).setLiquidRemaining(0);
          ((Drink) buildingI).setLiquidHeld(capacity * 50);
          ((Drink) buildingI).setThirstQuenched(250);
          if ((capacity * 50) < 250) ((Drink) buildingI).setThirstQuenched(capacity * 50);
        }
      }
      buildingI.recoverPhyStats();
      buildingI.text();
      buildingI.recoverPhyStats();
    }

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

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

    if (autoGenerate > 0) {
      crafted.add(buildingI);
      return true;
    }

    final CMMsg msg = CMClass.getMsg(mob, buildingI, this, getActivityMessageType(), startStr);
    if (mob.location().okMessage(mob, msg)) {
      mob.location().send(mob, msg);
      buildingI = (Item) msg.target();
      beneficialAffect(mob, mob, asLevel, duration);
      enhanceItem(mob, buildingI, enhancedTypes);
    } else if (bundling) {
      messedUp = false;
      aborted = false;
      unInvoke();
    }
    return true;
  }
Beispiel #12
0
 @Override
 public void executeMsg(Environmental host, CMMsg msg) {
   super.executeMsg(host, msg);
   if ((affected instanceof Item) && (text().length() > 0)) {
     final Item I = (Item) affected;
     if ((msg.sourceMinor() == CMMsg.TYP_SPEAK)
         && (msg.target() == I)
         && ((msg.source() == I.owner()) || (I.owner() instanceof Room))
         && (msg.sourceMessage() != null)
         && (CMLib.english()
             .containsString(
                 CMStrings.getSayFromMessage(msg.sourceMessage()).toUpperCase(), "REFUGE"))) {
       final Room newRoom = this.getRefuge(I);
       if ((newRoom != null) && (newRoom != msg.source().location())) {
         final Set<MOB> h = properTargets(msg.source(), null, false);
         if (h == null) return;
         final Room thisRoom = msg.source().location();
         final Ability thisA = this;
         msg.addTrailerRunnable(
             new Runnable() {
               @Override
               public void run() {
                 for (final Object element : h) {
                   final MOB follower = (MOB) element;
                   final CMMsg enterMsg =
                       CMClass.getMsg(
                           follower,
                           newRoom,
                           thisA,
                           CMMsg.MSG_ENTER,
                           null,
                           CMMsg.MSG_ENTER,
                           null,
                           CMMsg.MSG_ENTER,
                           L(
                               "<S-NAME> appears in a puff of smoke.@x1",
                               CMLib.protocol().msp("appear.wav", 10)));
                   final CMMsg leaveMsg =
                       CMClass.getMsg(
                           follower,
                           thisRoom,
                           thisA,
                           CMMsg.MSG_LEAVE | CMMsg.MASK_MAGIC,
                           L("<S-NAME> disappear(s) in a puff of smoke."));
                   if (thisRoom.okMessage(follower, leaveMsg)
                       && newRoom.okMessage(follower, enterMsg)) {
                     if (follower.isInCombat()) {
                       CMLib.commands().postFlee(follower, ("NOWHERE"));
                       follower.makePeace();
                     }
                     thisRoom.send(follower, leaveMsg);
                     newRoom.bringMobHere(follower, false);
                     newRoom.send(follower, enterMsg);
                     follower.tell(L("\n\r\n\r"));
                     CMLib.commands().postLook(follower, true);
                   }
                 }
               }
             });
         unInvoke();
       }
     }
   }
 }
Beispiel #13
0
  @Override
  public boolean invoke(MOB mob, Vector commands, Physical givenTarget, boolean auto, int asLevel) {
    final Vector areas = new Vector();
    if (commands.size() == 0) areas.addElement(mob.location().getArea());
    else if (((String) commands.lastElement()).equalsIgnoreCase("far")) {
      commands.removeElementAt(commands.size() - 1);
      for (final Enumeration e = CMLib.map().areas(); e.hasMoreElements(); )
        areas.addElement(e.nextElement());
    } else if (((String) commands.lastElement()).equalsIgnoreCase("near")) {
      commands.removeElementAt(commands.size() - 1);
      areas.addElement(mob.location().getArea());
    } else areas.addElement(mob.location().getArea());
    final MOB mobTarget = getTarget(mob, commands, givenTarget, true, false);
    Item target = null;
    if (mobTarget != null) {
      target = getItem(mobTarget);
      if (target == null)
        return maliciousFizzle(
            mob,
            mobTarget,
            L("<S-NAME> attempt(s) a scattering spell at <T-NAMESELF>, but nothing happens."));
    }

    List<Item> targets = new Vector();
    if (givenTarget instanceof Item) targets.add((Item) givenTarget);
    else if (target != null) targets.add(target);
    else {
      targets = CMLib.english().fetchItemList(mob, mob, null, commands, Wearable.FILTER_ANY, true);
      if (targets.size() == 0) mob.tell(L("You don't seem to be carrying that."));
    }

    if (targets.size() == 0) return false;

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

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

    if (success) {
      String str = null;
      if (mobTarget == null)
        str =
            auto
                ? L("<S-NAME> <S-IS-ARE> enveloped in a scattering field!")
                : L("^S<S-NAME> utter(s) a scattering spell!^?");
      else
        str =
            auto
                ? L("<T-NAME> <T-IS-ARE> enveloped in a scattering field!")
                : L("^S<S-NAME> utter(s) a scattering spell, causing <T-NAMESELF> to resonate.^?");
      CMMsg msg = CMClass.getMsg(mob, mobTarget, this, verbalCastCode(mob, target, auto), str);
      if (mob.location().okMessage(mob, msg)) {
        mob.location().send(mob, msg);
        if (msg.value() <= 0) {
          for (int i = 0; i < targets.size(); i++) {
            target = targets.get(i);
            msg = CMClass.getMsg(mob, target, this, verbalCastCode(mob, target, auto), null);
            Room room = null;
            for (int x = 0; (x < 10) && (room == null); x++)
              room =
                  ((Area) areas.elementAt(CMLib.dice().roll(1, areas.size(), -1)))
                      .getRandomMetroRoom();
            if (mob.location().okMessage(mob, msg) && (room != null)) {
              mob.location().send(mob, msg);
              if (msg.value() <= 0) {
                target.unWear();
                if (target.owner() instanceof MOB) {
                  final MOB owner = (MOB) target.owner();
                  mob.location()
                      .show(
                          owner,
                          room,
                          target,
                          CMMsg.MASK_ALWAYS | CMMsg.MSG_THROW,
                          L("<O-NAME> vanishes from <S-YOUPOSS> inventory!"));
                  room.showOthers(
                      owner,
                      room,
                      target,
                      CMMsg.MASK_ALWAYS | CMMsg.MSG_THROW,
                      L("<O-NAME> appears from out of nowhere!"));
                } else {
                  mob.location()
                      .show(
                          mob,
                          room,
                          target,
                          CMMsg.MASK_ALWAYS | CMMsg.MSG_THROW,
                          L("<O-NAME> vanishes!"));
                  room.showOthers(
                      mob,
                      room,
                      target,
                      CMMsg.MASK_ALWAYS | CMMsg.MSG_THROW,
                      L("<O-NAME> appears from out of nowhere!"));
                }
                if (!room.isContent(target))
                  room.moveItemTo(
                      target, ItemPossessor.Expire.Player_Drop, ItemPossessor.Move.Followers);
                room.recoverRoomStats();
              }
            }
          }
        }
      }
    } else
      return maliciousFizzle(
          mob, mobTarget, L("<S-NAME> attempt(s) a scattering spell, but nothing happens."));

    // return whether it worked
    return success;
  }
Beispiel #14
0
  @Override
  public boolean invoke(
      final MOB mob, Vector commands, Physical givenTarget, final boolean auto, final int asLevel) {
    final Vector originalCommands = (Vector) commands.clone();
    if (super.checkStop(mob, commands)) return true;

    fireRequired = true;

    final CraftParms parsedVars = super.parseAutoGenerate(auto, givenTarget, commands);
    givenTarget = parsedVars.givenTarget;

    final PairVector<Integer, Integer> enhancedTypes = enhancedTypes(mob, commands);
    randomRecipeFix(mob, addRecipes(mob, loadRecipes()), commands, parsedVars.autoGenerate);
    if (commands.size() == 0) {
      commonTell(
          mob,
          L(
              "Make what? Enter \"@x1 list\" for a list, \"@x2 learn <item>\" to gain recipes, or \"@x3 stop\" to cancel.",
              triggerStrings()[0].toLowerCase(),
              triggerStrings()[0].toLowerCase(),
              triggerStrings()[0].toLowerCase()));
      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;
    }
    final List<List<String>> recipes = addRecipes(mob, loadRecipes());
    final String str = (String) commands.elementAt(0);
    String startStr = null;
    bundling = false;
    int duration = 4;
    final int[] cols = {
      ListingLibrary.ColFixer.fixColWidth(16, mob.session()),
      ListingLibrary.ColFixer.fixColWidth(3, mob.session())
    };
    if (str.equalsIgnoreCase("list")) {
      String mask = CMParms.combine(commands, 1);
      boolean allFlag = false;
      if (mask.equalsIgnoreCase("all")) {
        allFlag = true;
        mask = "";
      }
      final StringBuffer buf =
          new StringBuffer(
              L(
                  "@x1 @x2 Metals required\n\r",
                  CMStrings.padRight(L("Item"), cols[0]),
                  CMStrings.padRight(L("Lvl"), cols[1])));
      for (int r = 0; r < recipes.size(); r++) {
        final List<String> V = recipes.get(r);
        if (V.size() > 0) {
          final String item = replacePercent(V.get(RCP_FINALNAME), "");
          final int level = CMath.s_int(V.get(RCP_LEVEL));
          final String wood = getComponentDescription(mob, V, RCP_WOOD);
          if (((level <= xlevel(mob)) || allFlag)
              && ((mask.length() == 0)
                  || mask.equalsIgnoreCase("all")
                  || CMLib.english().containsString(item, mask)))
            buf.append(
                CMStrings.padRight(item, cols[0])
                    + " "
                    + CMStrings.padRight("" + level, cols[1])
                    + " "
                    + wood
                    + "\n\r");
        }
      }
      commonTell(mob, buf.toString());
      enhanceList(mob);
      return true;
    } else if ((commands.firstElement() instanceof String)
        && (((String) commands.firstElement())).equalsIgnoreCase("learn")) {
      return doLearnRecipe(mob, commands, givenTarget, auto, asLevel);
    }

    activity = CraftingActivity.CRAFTING;
    buildingI = null;
    messedUp = false;
    String statue = null;
    if ((commands.size() > 1) && ((String) commands.lastElement()).startsWith("STATUE=")) {
      statue = (((String) commands.lastElement()).substring(7)).trim();
      if (statue.length() == 0) statue = null;
      else commands.removeElementAt(commands.size() - 1);
    }
    int amount = -1;
    if ((commands.size() > 1) && (CMath.isNumber((String) commands.lastElement()))) {
      amount = CMath.s_int((String) commands.lastElement());
      commands.removeElementAt(commands.size() - 1);
    }
    final String recipeName = CMParms.combine(commands, 0);
    List<String> foundRecipe = null;
    final List<List<String>> matches = matchingRecipeNames(recipes, recipeName, true);
    for (int r = 0; r < matches.size(); r++) {
      final List<String> V = matches.get(r);
      if (V.size() > 0) {
        final int level = CMath.s_int(V.get(RCP_LEVEL));
        if ((parsedVars.autoGenerate > 0) || (level <= xlevel(mob))) {
          foundRecipe = V;
          break;
        }
      }
    }
    if (foundRecipe == null) {
      commonTell(
          mob,
          L(
              "You don't know how to make a '@x1'.  Try \"@x2 list\" for a list.",
              recipeName,
              triggerStrings[0].toLowerCase()));
      return false;
    }

    final String woodRequiredStr = foundRecipe.get(RCP_WOOD);
    final List<Object> componentsFoundList =
        getAbilityComponents(
            mob,
            woodRequiredStr,
            "make " + CMLib.english().startWithAorAn(recipeName),
            parsedVars.autoGenerate);
    if (componentsFoundList == null) return false;
    int woodRequired = CMath.s_int(woodRequiredStr);
    woodRequired = adjustWoodRequired(woodRequired, mob);

    if (amount > woodRequired) woodRequired = amount;
    final String misctype = foundRecipe.get(RCP_MISCTYPE);
    final int[] pm = {RawMaterial.MATERIAL_METAL, RawMaterial.MATERIAL_MITHRIL};
    bundling = misctype.equalsIgnoreCase("BUNDLE");
    final int[][] data =
        fetchFoundResourceData(
            mob,
            woodRequired,
            "metal",
            pm,
            0,
            null,
            null,
            bundling,
            parsedVars.autoGenerate,
            enhancedTypes);
    if (data == null) return false;
    fixDataForComponents(data, componentsFoundList);
    woodRequired = data[0][FOUND_AMT];
    if (!bundling) {
      fireRequired = true;
      final Item fire = getRequiredFire(mob, parsedVars.autoGenerate);
      if (fire == null) return false;
    } else fireRequired = false;

    final Session session = mob.session();
    if ((misctype.equalsIgnoreCase("statue"))
        && (session != null)
        && ((statue == null) || (statue.trim().length() == 0))) {
      final Ability me = this;
      final Physical target = givenTarget;
      session.prompt(
          new InputCallback(InputCallback.Type.PROMPT, "", 0) {
            @Override
            public void showPrompt() {
              session.promptPrint(L("What is a statue this of?\n\r: "));
            }

            @Override
            public void timedOut() {}

            @Override
            public void callBack() {
              final String of = this.input;
              if ((of.trim().length() == 0) || (of.indexOf('<') >= 0)) return;
              final Vector newCommands = (Vector) originalCommands.clone();
              newCommands.add("STATUE=" + of);
              me.invoke(mob, newCommands, target, auto, asLevel);
            }
          });
      return false;
    }

    if (!super.invoke(mob, commands, givenTarget, auto, asLevel)) return false;
    final int lostValue =
        parsedVars.autoGenerate > 0
            ? 0
            : CMLib.materials()
                    .destroyResourcesValue(
                        mob.location(), data[0][FOUND_AMT], data[0][FOUND_CODE], 0, null)
                + CMLib.ableMapper().destroyAbilityComponents(componentsFoundList);
    buildingI = CMClass.getItem(foundRecipe.get(RCP_CLASSTYPE));
    if (buildingI == null) {
      commonTell(mob, L("There's no such thing as a @x1!!!", foundRecipe.get(RCP_CLASSTYPE)));
      return false;
    }
    duration =
        getDuration(
            CMath.s_int(foundRecipe.get(RCP_TICKS)),
            mob,
            CMath.s_int(foundRecipe.get(RCP_LEVEL)),
            4);
    String itemName =
        replacePercent(foundRecipe.get(RCP_FINALNAME), RawMaterial.CODES.NAME(data[0][FOUND_CODE]))
            .toLowerCase();
    if (bundling) itemName = "a " + woodRequired + "# " + itemName;
    else itemName = CMLib.english().startWithAorAn(itemName);
    buildingI.setName(itemName);
    startStr = L("<S-NAME> start(s) smithing @x1.", buildingI.name());
    displayText = L("You are smithing @x1", buildingI.name());
    verb = L("smithing @x1", buildingI.name());
    playSound = "tinktinktink2.wav";
    buildingI.setDisplayText(L("@x1 lies here", itemName));
    buildingI.setDescription(itemName + ". ");
    buildingI.basePhyStats().setWeight(getStandardWeight(woodRequired, bundling));
    buildingI.setBaseValue(
        CMath.s_int(foundRecipe.get(RCP_VALUE))
            + (woodRequired * (RawMaterial.CODES.VALUE(data[0][FOUND_CODE]))));
    buildingI.setMaterial(data[0][FOUND_CODE]);
    buildingI.basePhyStats().setLevel(CMath.s_int(foundRecipe.get(RCP_LEVEL)));
    buildingI.setSecretIdentity(getBrand(mob));
    final int capacity = CMath.s_int(foundRecipe.get(RCP_CAPACITY));
    final String spell = (foundRecipe.size() > RCP_SPELL) ? foundRecipe.get(RCP_SPELL).trim() : "";
    addSpells(buildingI, spell);

    if ((misctype.equalsIgnoreCase("statue")) && (statue != null) && (statue.trim().length() > 0)) {
      buildingI.setName(L("@x1 of @x2", itemName, statue.trim()));
      buildingI.setDisplayText(L("@x1 of @x2 is here", itemName, statue.trim()));
      buildingI.setDescription(L("@x1 of @x2. ", itemName, statue.trim()));
    } else if (buildingI instanceof Rideable) {
      setRideBasis((Rideable) buildingI, misctype);
      if (capacity == 0) ((Rideable) buildingI).setRiderCapacity(1);
      else if (capacity < 5) ((Rideable) buildingI).setRiderCapacity(capacity);
    } else if (buildingI instanceof Container) {
      ((Container) buildingI).setCapacity(capacity + woodRequired);
      if (misctype.equalsIgnoreCase("LID"))
        ((Container) buildingI).setDoorsNLocks(true, false, true, false, false, false);
      else if (misctype.equalsIgnoreCase("LOCK")) {
        ((Container) buildingI).setDoorsNLocks(true, false, true, true, false, true);
        ((Container) buildingI).setKeyName(Double.toString(Math.random()));
      } else ((Container) buildingI).setContainTypes(getContainerType(misctype));
    }
    if (buildingI instanceof Drink) {
      if (CMLib.flags().isGettable(buildingI)) {
        ((Drink) buildingI).setLiquidHeld(capacity * 50);
        ((Drink) buildingI).setThirstQuenched(250);
        if ((capacity * 50) < 250) ((Drink) buildingI).setThirstQuenched(capacity * 50);
        ((Drink) buildingI).setLiquidRemaining(0);
      }
    }
    if (bundling) buildingI.setBaseValue(lostValue);
    buildingI.recoverPhyStats();
    buildingI.text();
    buildingI.recoverPhyStats();

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

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

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

    final CMMsg msg = CMClass.getMsg(mob, buildingI, this, getActivityMessageType(), startStr);
    if (mob.location().okMessage(mob, msg)) {
      mob.location().send(mob, msg);
      buildingI = (Item) msg.target();
      beneficialAffect(mob, mob, asLevel, duration);
      enhanceItem(mob, buildingI, enhancedTypes);
    } else if (bundling) {
      messedUp = false;
      aborted = false;
      unInvoke();
    }
    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;
  }
Beispiel #16
0
 @Override
 protected String songOf() {
   return CMLib.english().startWithAorAn(name());
 }
Beispiel #17
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 "";
  }
Beispiel #18
0
 public Item isRuinedLoot(DVector policies, Item I) {
   if (I == null) return null;
   if ((CMath.bset(I.envStats().disposition(), EnvStats.IS_UNSAVABLE))
       || (CMath.bset(I.envStats().sensesMask(), EnvStats.SENSE_ITEMNORUIN))
       || (I instanceof Coins)) return I;
   if (I.name().toLowerCase().indexOf("ruined ") >= 0) return I;
   for (int d = 0; d < policies.size(); d++) {
     if ((((Vector) policies.elementAt(d, 3)).size() > 0)
         && (!CMLib.masking().maskCheck((Vector) policies.elementAt(d, 3), I, true))) continue;
     if (CMLib.dice().rollPercentage() > ((Integer) policies.elementAt(d, 1)).intValue()) continue;
     int flags = ((Integer) policies.elementAt(d, 2)).intValue();
     if (CMath.bset(flags, CMMiscUtils.LOOTFLAG_WORN) && I.amWearingAt(Wearable.IN_INVENTORY))
       continue;
     else if (CMath.bset(flags, CMMiscUtils.LOOTFLAG_UNWORN)
         && (!I.amWearingAt(Wearable.IN_INVENTORY))) continue;
     if (CMath.bset(flags, CMMiscUtils.LOOTFLAG_LOSS)) return null;
     Item I2 = CMClass.getItem("GenItem");
     I2.baseEnvStats().setWeight(I.baseEnvStats().weight());
     I2.setName(I.Name());
     I2.setDisplayText(I.displayText());
     I2.setDescription(I2.description());
     I2.recoverEnvStats();
     I2.setMaterial(I.material());
     String ruinDescAdder = null;
     switch (I2.material() & RawMaterial.MATERIAL_MASK) {
       case RawMaterial.MATERIAL_LEATHER:
       case RawMaterial.MATERIAL_CLOTH:
       case RawMaterial.MATERIAL_VEGETATION:
       case RawMaterial.MATERIAL_FLESH:
       case RawMaterial.MATERIAL_PAPER:
         ruinDescAdder =
             CMStrings.capitalizeFirstLetter(I2.name()) + " is torn and ruined beyond repair.";
         break;
       case RawMaterial.MATERIAL_METAL:
       case RawMaterial.MATERIAL_MITHRIL:
       case RawMaterial.MATERIAL_WOODEN:
         ruinDescAdder =
             CMStrings.capitalizeFirstLetter(I2.name()) + " is battered and ruined beyond repair.";
         break;
       case RawMaterial.MATERIAL_GLASS:
         ruinDescAdder =
             CMStrings.capitalizeFirstLetter(I2.name())
                 + " is shattered and ruined beyond repair.";
         break;
       case RawMaterial.MATERIAL_ROCK:
       case RawMaterial.MATERIAL_PRECIOUS:
       case RawMaterial.MATERIAL_PLASTIC:
         ruinDescAdder =
             CMStrings.capitalizeFirstLetter(I2.name()) + " is cracked and ruined beyond repair.";
         break;
       case RawMaterial.MATERIAL_UNKNOWN:
       case RawMaterial.MATERIAL_ENERGY:
       case RawMaterial.MATERIAL_LIQUID:
       default:
         ruinDescAdder = CMStrings.capitalizeFirstLetter(I2.name()) + " is ruined beyond repair.";
         break;
     }
     I2.setDescription(CMStrings.endWithAPeriod(I2.description()) + " " + ruinDescAdder);
     String oldName = I2.Name();
     I2.setName(CMLib.english().insertUnColoredAdjective(I2.Name(), "ruined"));
     int x = I2.displayText().toUpperCase().indexOf(oldName.toUpperCase());
     I2.setBaseValue(0);
     if (x >= 0)
       I2.setDisplayText(
           I2.displayText().substring(0, x)
               + I2.Name()
               + I2.displayText().substring(x + oldName.length()));
     return I2;
   }
   return I;
 }
  @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;
  }