Пример #1
0
 public DVector parseLootPolicyFor(MOB mob) {
   if (mob == null) return new DVector(3);
   Vector lootPolicy =
       (!mob.isMonster())
           ? new Vector()
           : CMParms.parseCommas(CMProps.getVar(CMProps.SYSTEM_ITEMLOOTPOLICY), true);
   DVector policies = new DVector(3);
   for (int p = 0; p < lootPolicy.size(); p++) {
     String s = ((String) lootPolicy.elementAt(p)).toUpperCase().trim();
     if (s.length() == 0) continue;
     Vector compiledMask = null;
     int maskDex = s.indexOf("MASK=");
     if (maskDex >= 0) {
       s = s.substring(0, maskDex).trim();
       compiledMask =
           CMLib.masking()
               .maskCompile(((String) lootPolicy.elementAt(p)).substring(maskDex + 5).trim());
     } else compiledMask = new Vector();
     Vector parsed = CMParms.parse(s);
     int pct = 100;
     for (int x = 0; x < parsed.size(); x++)
       if (CMath.isInteger((String) parsed.elementAt(x)))
         pct = CMath.s_int((String) parsed.elementAt(x));
       else if (CMath.isPct((String) parsed.elementAt(x)))
         pct = (int) Math.round(CMath.s_pct((String) parsed.elementAt(x)) * 100.0);
     int flags = 0;
     if (parsed.contains("RUIN")) flags |= CMMiscUtils.LOOTFLAG_RUIN;
     else if (parsed.contains("LOSS")) flags |= CMMiscUtils.LOOTFLAG_LOSS;
     if (flags == 0) flags |= CMMiscUtils.LOOTFLAG_LOSS;
     if (parsed.contains("WORN")) flags |= CMMiscUtils.LOOTFLAG_WORN;
     else if (parsed.contains("UNWORN")) flags |= CMMiscUtils.LOOTFLAG_UNWORN;
     policies.addElement(Integer.valueOf(pct), Integer.valueOf(flags), compiledMask);
   }
   return policies;
 }
Пример #2
0
 public String niceCommaList(Vector V, boolean andTOrF) {
   String id = "";
   for (int v = 0; v < V.size(); v++) {
     String s = null;
     if (V.elementAt(v) instanceof Environmental) s = ((Environmental) V.elementAt(v)).name();
     else if (V.elementAt(v) instanceof String) s = (String) V.elementAt(v);
     else continue;
     if (V.size() == 1) id += s;
     else if (v == (V.size() - 1)) id += ((andTOrF) ? "and " : "or ") + s;
     else id += s + ", ";
   }
   return id;
 }
Пример #3
0
  public String composition() {
    String comp = "";
    if (trail != null) {
      String t = trail.toString();
      final int[] counts = new int[stuff.length];
      int x = t.indexOf(';');
      while (x >= 0) {
        final int q = CMath.s_int(t.substring(0, x));
        t = t.substring(x + 1);
        if (q >= 0) {
          for (int i = 0; i < stuff.length; i++) {
            if (CMath.s_int(stuff[i][0]) == q) counts[i]++;
          }
        }
        x = t.indexOf(';');
      }
      int wa = -1;
      for (int i = 0; i < stuff.length; i++)
        if (CMath.s_int(stuff[i][0]) == CMMsg.TYP_WEAPONATTACK) {
          wa = i;
          break;
        }

      if (wa >= 0) counts[wa] = counts[wa] / 25;

      final Vector<Integer> V = new Vector<Integer>();
      while (V.size() < counts.length) {
        int high = -1;
        int which = -1;
        for (int i = 0; i < counts.length; i++) {
          if ((counts[i] > high) && (!V.contains(Integer.valueOf(i)))) {
            high = counts[i];
            which = i;
          }
        }
        if (which >= 0) V.addElement(Integer.valueOf(which));
      }
      final Vector<Integer> V2 = new Vector<Integer>();
      for (int i = 0; i < 3; i++) {
        final Integer ref = V.elementAt(i);
        Integer which = null;
        while ((which == null) || (V2.contains(which))) {
          final Integer w = V.elementAt(CMLib.dice().roll(1, V.size(), -1));
          if (counts[w.intValue()] == counts[ref.intValue()]) which = w;
        }
        V2.addElement(which);
        comp += which.intValue() + ";" + counts[which.intValue()] + ";";
      }
    }
    return comp;
  }
Пример #4
0
  @Override
  public boolean tick(Tickable ticking, int tickID) {
    if ((!built) && (affected instanceof MOB)) {
      built = true;
      CharClass C = null;
      final Vector allowedClasses = new Vector();
      final Vector allowedExpertises = new Vector();
      final Vector<String> V = CMParms.parse(text());
      String s = null;
      for (int v = 0; v < V.size(); v++) {
        s = V.elementAt(v);
        if (s.equalsIgnoreCase("all")) continue;
        C = CMClass.getCharClass(s);
        if (C != null) {
          if ((v > 0) && (V.elementAt(v - 1).equalsIgnoreCase("ALL"))) {
            final String baseClass = C.baseClass();
            for (final Enumeration c = CMClass.charClasses(); c.hasMoreElements(); ) {
              C = (CharClass) c.nextElement();
              if ((C.baseClass().equalsIgnoreCase(baseClass)) && (!allowedClasses.contains(C)))
                allowedClasses.addElement(C);
            }
          } else allowedClasses.addElement(C);
        } else {
          final ExpertiseLibrary.ExpertiseDefinition def = CMLib.expertises().getDefinition(s);
          if (def != null) allowedExpertises.addElement(def);
        }
      }
      if (allowedClasses.size() == 0)
        for (final Enumeration c = CMClass.charClasses(); c.hasMoreElements(); )
          allowedClasses.addElement(c.nextElement());
      if (allowedExpertises.size() == 0)
        for (final Enumeration e = CMLib.expertises().definitions(); e.hasMoreElements(); )
          allowedExpertises.addElement(e.nextElement());

      final MOB mob = (MOB) affected;
      for (int c = 0; c < allowedClasses.size(); c++) {
        C = (CharClass) allowedClasses.elementAt(c);
        addCharClassIfNotFound(mob, C);
      }
      for (int e = 0; e < allowedExpertises.size(); e++)
        mob.addExpertise(
            ((ExpertiseLibrary.ExpertiseDefinition) allowedExpertises.elementAt(e)).ID);
      mob.recoverCharStats();
      mob.recoverPhyStats();
      mob.recoverMaxState();
    }
    return super.tick(ticking, tickID);
  }
Пример #5
0
  @Override
  public boolean tick(Tickable ticking, int tickID) {
    final MOB mob = (MOB) affected;
    if (mob == null) return false;
    if (song == null) {
      if ((whom == null)
          || (commonRoomSet == null)
          || (!commonRoomSet.contains(whom.location()))
          || (CMLib.flags().isSleeping(invoker))
          || (!CMLib.flags().canBeSeenBy(whom, invoker))) return unsingMe(mob, null);
    }

    if ((whom != null)
        && (song != null)
        && (affected == invoker())
        && (CMLib.dice().rollPercentage() < 10)) {
      final Hashtable<Integer, Integer> H = getSongBenefits(song);
      final Vector<Integer> V = new Vector<Integer>();
      for (final Enumeration<Integer> e = H.keys(); e.hasMoreElements(); )
        V.addElement(e.nextElement());
      final Integer I = V.elementAt(CMLib.dice().roll(1, V.size(), -1));
      final String[] chk = stuff[I.intValue()];
      invoker()
          .location()
          .show(invoker(), this, whom, CMMsg.MSG_SPEAK, L("<S-NAME> sing(s) '@x1'.", chk[3]));
    }

    if (!super.tick(ticking, tickID)) return false;

    return true;
  }
Пример #6
0
 private Item getItem(MOB mobTarget) {
   final Vector goodPossibilities = new Vector();
   final Vector possibilities = new Vector();
   for (int i = 0; i < mobTarget.numItems(); i++) {
     final Item item = mobTarget.getItem(i);
     if (item != null) {
       if (item.amWearingAt(Wearable.IN_INVENTORY)) possibilities.addElement(item);
       else goodPossibilities.addElement(item);
     }
   }
   if (goodPossibilities.size() > 0)
     return (Item) goodPossibilities.elementAt(CMLib.dice().roll(1, goodPossibilities.size(), -1));
   else if (possibilities.size() > 0)
     return (Item) possibilities.elementAt(CMLib.dice().roll(1, possibilities.size(), -1));
   return null;
 }
Пример #7
0
  @Override
  public boolean tick(Tickable ticking, int tickID) {
    if (!super.tick(ticking, tickID)) return false;

    if (affected == null) return false;
    if (!(affected instanceof MOB)) return false;
    final MOB mob = (MOB) affected;
    if (mob.location().numInhabitants() == 1) return true;
    final Vector choices = new Vector();
    for (final Enumeration<Ability> a = mob.effects(); a.hasMoreElements(); ) {
      final Ability A = a.nextElement();
      if ((A != null)
          && (A.canBeUninvoked())
          && (!A.ID().equals(ID()))
          && (A.abstractQuality() == Ability.QUALITY_MALICIOUS)
          && (((A.classificationCode() & Ability.ALL_ACODES) == Ability.ACODE_SPELL)
              || ((A.classificationCode() & Ability.ALL_ACODES) == Ability.ACODE_PRAYER))
          && (!A.isAutoInvoked())) choices.addElement(A);
    }
    if (choices.size() == 0) return true;
    final MOB target = mob.location().fetchRandomInhabitant();
    final Ability thisOne = (Ability) choices.elementAt(CMLib.dice().roll(1, choices.size(), -1));
    if ((target == null) || (thisOne == null) || (target.fetchEffect(ID()) != null)) return true;
    if (CMLib.dice().rollPercentage() > (target.charStats().getSave(CharStats.STAT_SAVE_DISEASE))) {
      ((Ability) this.copyOf()).invoke(target, target, true, 0);
      if (target.fetchEffect(ID()) != null)
        ((Ability) thisOne.copyOf()).invoke(target, target, true, 0);
    } else spreadImmunity(target);
    return true;
  }
Пример #8
0
  public void removeMyAffectsFrom(Physical P) {
    if (P == null) return;

    int x = 0;
    final Vector<Ability> eff = new Vector<Ability>();
    Ability thisAffect = null;
    for (x = 0; x < P.numEffects(); x++) // personal
    {
      thisAffect = P.fetchEffect(x);
      if (thisAffect != null) eff.addElement(thisAffect);
    }
    if (eff.size() > 0) {
      final Map<String, String> h = makeMySpellsH(getMySpellsV());
      if (unrevocableSpells != null) {
        for (int v = unrevocableSpells.size() - 1; v >= 0; v--) {
          thisAffect = unrevocableSpells.get(v);
          if (h.containsKey(thisAffect.ID())) P.delEffect(thisAffect);
        }
      } else
        for (x = 0; x < eff.size(); x++) {
          thisAffect = eff.elementAt(x);
          final String ID = h.get(thisAffect.ID());
          if ((ID != null) && (thisAffect.invoker() == getInvokerMOB(P, P))) {
            thisAffect.unInvoke();
            if ((!uninvocable) && (!thisAffect.canBeUninvoked())) P.delEffect(thisAffect);
          }
        }
      unrevocableSpells = null;
    }
  }
Пример #9
0
  @Override
  public boolean tick(Tickable ticking, int tickID) {
    super.tick(ticking, tickID);
    if ((canAct(ticking, tickID)) && (ticking instanceof MOB)) {
      if (DoneEquipping) return true;

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

      DoneEquipping = true;
      final Vector<Item> stuffIHad = new Vector<Item>();
      for (int i = 0; i < mob.numItems(); i++) stuffIHad.addElement(mob.getItem(i));
      mob.enqueCommand(new XVector<String>("GET", "ALL"), MUDCmdProcessor.METAFLAG_FORCED, 0);
      Item I = null;
      final Vector<Item> dropThisStuff = new Vector<Item>();
      for (int i = 0; i < mob.numItems(); i++) {
        I = mob.getItem(i);
        if ((I != null) && (!stuffIHad.contains(I))) {
          if (I instanceof DeadBody) dropThisStuff.addElement(I);
          else if ((I.container() != null) && (I.container() instanceof DeadBody))
            I.setContainer(null);
        }
      }
      for (int d = 0; d < dropThisStuff.size(); d++)
        mob.enqueCommand(
            new XVector<String>("DROP", "$" + dropThisStuff.elementAt(d).Name() + "$"),
            MUDCmdProcessor.METAFLAG_FORCED,
            0);
      mob.enqueCommand(new XVector<String>("WEAR", "ALL"), MUDCmdProcessor.METAFLAG_FORCED, 0);
    }
    return true;
  }
Пример #10
0
  @Override
  public void grantAbilities(MOB mob, boolean isBorrowedClass) {
    super.grantAbilities(mob, isBorrowedClass);

    if (mob.playerStats() == null) {
      final List<AbilityMapper.AbilityMapping> V =
          CMLib.ableMapper()
              .getUpToLevelListings(ID(), mob.charStats().getClassLevel(ID()), false, false);
      for (final AbilityMapper.AbilityMapping able : V) {
        final Ability A = CMClass.getAbility(able.abilityID);
        if ((A != null)
            && ((A.classificationCode() & Ability.ALL_ACODES) == Ability.ACODE_CHANT)
            && (!CMLib.ableMapper().getDefaultGain(ID(), true, A.ID())))
          giveMobAbility(
              mob,
              A,
              CMLib.ableMapper().getDefaultProficiency(ID(), true, A.ID()),
              CMLib.ableMapper().getDefaultParm(ID(), true, A.ID()),
              isBorrowedClass);
      }
      return;
    }

    final Vector grantable = new Vector();

    final int level = mob.charStats().getClassLevel(this);
    int numChants = 2;
    for (final Enumeration<Ability> a = CMClass.abilities(); a.hasMoreElements(); ) {
      final Ability A = a.nextElement();
      if ((CMLib.ableMapper().getQualifyingLevel(ID(), true, A.ID()) == level)
          && ((CMLib.ableMapper().getQualifyingLevel(ID(), true, A.ID()) <= 25)
              && (!CMLib.ableMapper().getSecretSkill(ID(), true, A.ID()))
              && (!CMLib.ableMapper().getDefaultGain(ID(), true, A.ID()))
              && ((A.classificationCode() & Ability.ALL_ACODES) == Ability.ACODE_CHANT))) {
        if (!grantable.contains(A.ID())) grantable.addElement(A.ID());
      }
    }
    for (int a = 0; a < mob.numAbilities(); a++) {
      final Ability A = mob.fetchAbility(a);
      if (grantable.contains(A.ID())) {
        grantable.remove(A.ID());
        numChants--;
      }
    }
    for (int i = 0; i < numChants; i++) {
      if (grantable.size() == 0) break;
      final String AID = (String) grantable.elementAt(CMLib.dice().roll(1, grantable.size(), -1));
      if (AID != null) {
        grantable.removeElement(AID);
        giveMobAbility(
            mob,
            CMClass.getAbility(AID),
            CMLib.ableMapper().getDefaultProficiency(ID(), true, AID),
            CMLib.ableMapper().getDefaultParm(ID(), true, AID),
            isBorrowedClass);
      }
    }
  }
Пример #11
0
 public Vector getDeadBodies(Environmental E) {
   if (E instanceof DeadBody) return CMParms.makeVector(E);
   if (E instanceof Container) {
     Vector Bs = new Vector();
     Vector V = ((Container) E).getContents();
     for (int v = 0; v < V.size(); v++) Bs.addAll(getDeadBodies((Environmental) V.elementAt(v)));
     return Bs;
   }
   return new Vector();
 }
Пример #12
0
 public Item targetItem(MOB target) {
   final Vector<Item> V = new Vector<Item>();
   for (int i = 0; i < target.numItems(); i++) {
     final Item I2 = target.getItem(i);
     if ((!I2.amWearingAt(Wearable.IN_INVENTORY))
         && (((I2 instanceof Weapon) && (I2.basePhyStats().damage() > 1))
             || ((I2 instanceof Armor) && (I2.basePhyStats().armor() > 1)))
         && (I2.container() == null)) V.addElement(I2);
   }
   if (V.size() > 0) return V.elementAt(CMLib.dice().roll(1, V.size(), -1));
   return null;
 }
Пример #13
0
 @Override
 public void endCharacter(MOB mob) {
   final Vector<Ability> otherChoices = new Vector<Ability>();
   for (int a = 0; a < mob.numAbilities(); a++) {
     final Ability A2 = mob.fetchAbility(a);
     if ((A2 != null)
         && (!A2.isSavable())
         && ((A2.classificationCode() & Ability.ALL_ACODES) == Ability.ACODE_SPELL))
       otherChoices.addElement(A2);
   }
   for (int a = 0; a < otherChoices.size(); a++) mob.delAbility(otherChoices.elementAt(a));
 }
Пример #14
0
 public Item getPossibility(MOB mobTarget) {
   if (mobTarget != null) {
     final Vector goodPossibilities = new Vector();
     final Vector possibilities = new Vector();
     for (int i = 0; i < mobTarget.numItems(); i++) {
       final Item item = mobTarget.getItem(i);
       if ((item != null)
           && ((item.material() & RawMaterial.MATERIAL_MASK) == RawMaterial.MATERIAL_WOODEN)
           && (item.subjectToWearAndTear())) {
         if (item.amWearingAt(Wearable.IN_INVENTORY)) possibilities.addElement(item);
         else goodPossibilities.addElement(item);
       }
       if (goodPossibilities.size() > 0)
         return (Item)
             goodPossibilities.elementAt(CMLib.dice().roll(1, goodPossibilities.size(), -1));
       else if (possibilities.size() > 0)
         return (Item) possibilities.elementAt(CMLib.dice().roll(1, possibilities.size(), -1));
     }
   }
   return null;
 }
Пример #15
0
 protected Vector loadRecipes() {
   String filename = parametersFile();
   Vector recipes = (Vector) Resources.getResource("PARSED: " + filename);
   if (recipes == null) {
     StringBuffer str =
         new CMFile(Resources.buildResourcePath("skills") + filename, null, true).text();
     recipes = loadList(str);
     if (recipes.size() == 0) Log.errOut("LeatherWorking", "Recipes not found!");
     else {
       Vector pleaseAdd1 = new Vector();
       Vector pleaseAdd2 = new Vector();
       for (int r = 0; r < recipes.size(); r++) {
         Vector V = (Vector) recipes.elementAt(r);
         if (V.size() > 0) {
           Vector V1 = (Vector) V.clone();
           Vector V2 = (Vector) V.clone();
           String name = (String) V.elementAt(RCP_FINALNAME);
           V1.setElementAt("Hard " + name, RCP_FINALNAME);
           V1.setElementAt("" + (CMath.s_int((String) V.elementAt(RCP_LEVEL)) + 5), RCP_LEVEL);
           V2.setElementAt("Studded " + name, RCP_FINALNAME);
           V2.setElementAt("" + (CMath.s_int((String) V.elementAt(RCP_LEVEL)) + 11), RCP_LEVEL);
           pleaseAdd1.addElement(V1);
           pleaseAdd2.addElement(V2);
         }
       }
       for (int i = 0; i < pleaseAdd1.size(); i++) recipes.addElement(pleaseAdd1.elementAt(i));
       for (int i = 0; i < pleaseAdd2.size(); i++) recipes.addElement(pleaseAdd2.elementAt(i));
     }
     Resources.submitResource("PARSED: " + filename, recipes);
   }
   return recipes;
 }
Пример #16
0
  protected Room getMakeSingleGridRoom(int x, int y) {
    if ((x < 0) || (y < 0) || (y >= yGridSize()) || (x >= xGridSize())) return null;

    Room R = getGridRoomIfExists(x, y);
    if (R == null) {
      synchronized (rooms) {
        R = getGridRoomIfExists(x, y);
        if (R != null) return R;
        R = CMClass.getLocale(getGridChildLocaleID());
        if (R == null) return null;
        R.setGridParent(this);
        R.setRoomID("");
        R.setDisplayText(displayText());
        R.setDescription(description());
        int c = -1;
        if (displayTexts != null)
          if (displayTexts.size() > 0) {
            c = CMLib.dice().roll(1, displayTexts.size(), -1);
            R.setDisplayText((String) displayTexts.elementAt(c));
          }
        if (descriptions != null)
          if (descriptions.size() > 0) {
            if ((c < 0)
                || (c > descriptions.size())
                || (descriptions.size() != displayTexts.size()))
              c = CMLib.dice().roll(1, descriptions.size(), -1);
            R.setDescription((String) descriptions.elementAt(c));
          }

        for (int a = 0; a < numEffects(); a++) R.addEffect((Ability) fetchEffect(a).copyOf());
        for (int b = 0; b < numBehaviors(); b++)
          R.addBehavior((Behavior) fetchBehavior(b).copyOf());
        R.setExpirationDate(System.currentTimeMillis() + WorldMap.ROOM_EXPIRATION_MILLIS);
        addSortedRoom(R, x, y);
        R.setArea(getArea());
      }
    }
    return R;
  }
Пример #17
0
  @Override
  public boolean invoke(MOB mob, Vector commands, Physical givenTarget, boolean auto, int asLevel) {
    if (!super.invoke(mob, commands, givenTarget, auto, asLevel)) return false;

    final Vector V = new Vector();
    TrackingLibrary.TrackingFlags flags;
    flags =
        new TrackingLibrary.TrackingFlags()
            .plus(TrackingLibrary.TrackingFlag.OPENONLY)
            .plus(TrackingLibrary.TrackingFlag.AREAONLY)
            .plus(TrackingLibrary.TrackingFlag.NOEMPTYGRIDS)
            .plus(TrackingLibrary.TrackingFlag.NOAIR)
            .plus(TrackingLibrary.TrackingFlag.NOWATER);
    CMLib.tracking()
        .getRadiantRooms(mob.location(), V, flags, null, adjustedLevel(mob, asLevel), null);
    for (int v = V.size() - 1; v >= 0; v--) {
      final Room R = (Room) V.elementAt(v);
      if ((R.domainType() != Room.DOMAIN_INDOORS_CAVE) || (R == mob.location()))
        V.removeElementAt(v);
    }
    if (V.size() > 0) {
      mob.location()
          .show(
              mob,
              null,
              CMMsg.MASK_ALWAYS | CMMsg.TYP_NOISE,
              L("The faint sound of fungus popping into existence can be heard."));
      int done = 0;
      for (int v = 0; v < V.size(); v++) {
        final Room R = (Room) V.elementAt(v);
        if (R == mob.location()) continue;
        buildMyThing(mob, R);
        if ((done++) == adjustedLevel(mob, asLevel)) break;
      }
    }

    return true;
  }
Пример #18
0
 public boolean tick(Tickable ticking, int tickID) {
   if (!super.tick(ticking, tickID)) return false;
   if (CMath.bset(flags(), Area.FLAG_INSTANCE_CHILD)) return true;
   if ((--childCheckDown) <= 0) {
     childCheckDown = CHILD_CHECK_INTERVAL;
     synchronized (children) {
       for (int i = children.size() - 1; i >= 0; i--) {
         StdThinInstance childA = (StdThinInstance) children.elementAt(i, 2);
         if (childA.getAreaState() > Area.STATE_ACTIVE) {
           Vector V = (Vector) children.elementAt(i, 3);
           boolean anyInside = false;
           for (int v = 0; v < V.size(); v++) {
             MOB M = (MOB) V.elementAt(v);
             if (CMLib.flags().isInTheGame(M, true)
                 && (M.location() != null)
                 && (M.location().getArea() == childA)) anyInside = true;
           }
           if (!anyInside) {
             children.removeElementsAt(i);
             for (int v = 0; v < V.size(); v++) {
               MOB M = (MOB) V.elementAt(v);
               if ((M.location() != null) && (M.location().getArea() == this))
                 M.setLocation(M.getStartRoom());
             }
             MOB mob = CMClass.sampleMOB();
             for (Enumeration e = childA.getProperMap(); e.hasMoreElements(); ) {
               Room R = (Room) e.nextElement();
               R.executeMsg(mob, CMClass.getMsg(mob, R, null, CMMsg.MSG_EXPIRE, null));
             }
             CMLib.map().delArea(childA);
             childA.destroy();
           }
         }
       }
     }
   }
   return true;
 }
Пример #19
0
 public void unInvoke() {
   if ((affected instanceof MOB) && (myChants != null)) {
     Vector V = myChants;
     myChants = null;
     for (int i = 0; i < V.size(); i++) {
       Ability A = (Ability) V.elementAt(i);
       if ((A.affecting() != null) && (A.ID().equals(ID())) && (A.affecting() instanceof Item)) {
         Item I = (Item) A.affecting();
         I.delEffect(A);
       }
     }
   }
   super.unInvoke();
 }
Пример #20
0
 public void outfit(MOB mob, Vector items) {
   if ((mob == null) || (items == null) || (items.size() == 0)) return;
   for (int i = 0; i < items.size(); i++) {
     Item I = (Item) items.elementAt(i);
     if (mob.fetchInventory("$" + I.name() + "$") == null) {
       I = (Item) I.copyOf();
       I.text();
       I.recoverEnvStats();
       mob.addInventory(I);
       if (I.whereCantWear(mob) <= 0) I.wearIfPossible(mob);
       if (((I instanceof Armor) || (I instanceof Weapon))
           && (I.amWearingAt(Wearable.IN_INVENTORY))) I.destroy();
     }
   }
 }
Пример #21
0
 protected Room alternativeLink(Room room, Room defaultRoom, int dir) {
   if (room.getGridParent() == this)
     for (int d = 0; d < gridexits.size(); d++) {
       WorldMap.CrossExit EX = (WorldMap.CrossExit) gridexits.elementAt(d);
       try {
         if ((EX.out) && (EX.dir == dir) && (getGridRoomIfExists(EX.x, EX.y) == room)) {
           Room R = CMLib.map().getRoom(EX.destRoomID);
           if (R != null) {
             if (R.getGridParent() != null) return R.getGridParent();
             return R;
           }
         }
       } catch (Exception e) {
       }
     }
   return defaultRoom;
 }
Пример #22
0
  @Override
  public boolean invoke(MOB mob, Vector commands, Physical givenTarget, boolean auto, int asLevel) {
    if (commands.size() < 3) {
      mob.tell(
          L("Specify a target, a property, number of ticks, and (optionally) some misc text!"));
      return false;
    }
    final Vector V = new XVector(commands.firstElement());
    final Physical target = getAnyTarget(mob, V, givenTarget, Wearable.FILTER_ANY);
    if (target == null) return false;
    commands.removeElementAt(0);

    final String abilityStr = (String) commands.firstElement();
    CMObject A = CMClass.getAbility(abilityStr);
    if (A == null) A = CMClass.getBehavior(abilityStr);
    if (A == null) A = CMClass.findAbility(abilityStr);
    if (A == null) A = CMClass.findBehavior(abilityStr);
    if (A == null) {
      mob.tell(L("No such ability or behavior as @x1!", abilityStr));
      return false;
    }
    final String numTicks = ((String) commands.elementAt(1)).trim();
    if ((!CMath.isInteger(numTicks)) || (CMath.s_int(numTicks) <= 0)) {
      mob.tell(L("'@x1' is not a number of ticks!", numTicks));
      return false;
    }
    final String parms = CMParms.combine(commands, 2);

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

    TemporaryAffects T = (TemporaryAffects) target.fetchEffect(ID());
    if (T == null) {
      T = (TemporaryAffects) this.newInstance();
      T.affects = new SVector<Object[]>();
      T.startTickDown(mob, target, 10);
      T = (TemporaryAffects) target.fetchEffect(ID());
    }
    if (T != null) {
      T.setMiscText("+" + A.ID() + " " + numTicks.trim() + " " + parms.trim());
      T.makeLongLasting();
    }
    return true;
  }
Пример #23
0
  @Override
  public boolean invoke(MOB mob, Vector commands, Physical givenTarget, boolean auto, int asLevel) {

    material = RawMaterial.RESOURCE_OAK;
    if ((mob.location().myResource() & RawMaterial.MATERIAL_MASK) == RawMaterial.MATERIAL_WOODEN)
      material = mob.location().myResource();
    else {
      final List<Integer> V = mob.location().resourceChoices();
      final Vector V2 = new Vector();
      if (V != null)
        for (int v = 0; v < V.size(); v++) {
          if (((V.get(v).intValue() & RawMaterial.MATERIAL_MASK) == RawMaterial.MATERIAL_WOODEN)
              && ((V.get(v).intValue()) != RawMaterial.RESOURCE_WOOD)) V2.addElement(V.get(v));
        }
      if (V2.size() > 0)
        material = ((Integer) V2.elementAt(CMLib.dice().roll(1, V2.size(), -1))).intValue();
    }

    return super.invoke(mob, commands, givenTarget, auto, asLevel);
  }
Пример #24
0
 public boolean shutdown() {
   // int numTicks=tickGroup.size();
   int which = 0;
   while (ticks.size() > 0) {
     // Log.sysOut("ServiceEngine","Shutting down all tick "+which+"/"+numTicks+"...");
     Tick tock = ticks.getFirst();
     if (tock != null) {
       CMProps.setUpAllLowVar(
           CMProps.SYSTEM_MUDSTATUS,
           "Shutting down...shutting down Service Engine: killing Tick#"
               + tock.getCounter()
               + ": "
               + tock.getStatus());
       tock.shutdown();
     }
     try {
       Thread.sleep(100);
     } catch (Exception e) {
     }
     which++;
   }
   CMProps.setUpAllLowVar(
       CMProps.SYSTEM_MUDSTATUS,
       "Shutting down...shutting down Service Engine: " + ID() + ": thread shutdown");
   thread.shutdown();
   // force final time tick!
   Vector timeObjects = new Vector();
   for (Enumeration e = CMLib.map().areas(); e.hasMoreElements(); ) {
     Area A = ((Area) e.nextElement());
     if (!timeObjects.contains(A.getTimeObj())) timeObjects.addElement(A.getTimeObj());
   }
   CMProps.setUpAllLowVar(
       CMProps.SYSTEM_MUDSTATUS,
       "Shutting down...shutting down Service Engine: " + ID() + ": saving time objects");
   for (int t = 0; t < timeObjects.size(); t++) ((TimeClock) timeObjects.elementAt(t)).save();
   Log.sysOut("ServiceEngine", "Shutdown complete.");
   return true;
 }
Пример #25
0
  public boolean invoke(
      MOB mob, Vector commands, Environmental givenTarget, boolean auto, int asLevel) {
    if ((mob.fetchEffect(ID()) != null) || (mob.fetchEffect("Chant_Grapevine") != null)) {
      mob.tell("You are already listening through a grapevine.");
      return false;
    }
    MOB tapped = null;
    for (int i = 0; i < mob.location().numItems(); i++) {
      Item I = mob.location().fetchItem(i);
      if ((I != null) && (isPlant(I) != null)) {
        Ability A = isPlant(I);
        if ((A != null) && (A.invoker() != mob)) tapped = A.invoker();
      }
    }

    Vector myRooms = (tapped == null) ? null : Druid_MyPlants.myPlantRooms(tapped);
    if ((myRooms == null) || (myRooms.size() == 0)) {
      mob.tell("There doesn't appear to be any plants around here to listen through.");
      return false;
    }
    Item myPlant = Druid_MyPlants.myPlant(mob.location(), tapped, 0);
    if ((!auto) && (myPlant == null)) {
      mob.tell("You must be in the same room as someone elses plants to initiate this chant.");
      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> and listen(s) carefully to <T-HIM-HER>!^?");
      if (mob.location().okMessage(mob, msg)) {
        mob.location().send(mob, msg);
        myChants = new Vector();
        beneficialAffect(mob, mob, asLevel, 0);
        Chant_TapGrapevine C = (Chant_TapGrapevine) mob.fetchEffect(ID());
        if (C == null) return false;
        for (int i = 0; i < myRooms.size(); i++) {
          Room R = (Room) myRooms.elementAt(i);
          int ii = 0;
          myPlant = Druid_MyPlants.myPlant(R, tapped, ii);
          while (myPlant != null) {
            Ability A = myPlant.fetchEffect(ID());
            if (A != null) myPlant.delEffect(A);
            myPlant.addNonUninvokableEffect((Ability) C.copyOf());
            A = myPlant.fetchEffect(ID());
            if (A != null) myChants.addElement(A);
            ii++;
            myPlant = Druid_MyPlants.myPlant(R, tapped, ii);
          }
        }
        C.myChants = (Vector) myChants.clone();
        myChants = new Vector();
      }

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

    // return whether it worked
    return success;
  }
Пример #26
0
  public boolean resurrect(MOB tellMob, Room corpseRoom, DeadBody body, int XPLevel) {
    MOB rejuvedMOB = CMLib.players().getPlayer(((DeadBody) body).mobName());
    if (rejuvedMOB != null) {
      rejuvedMOB.tell("You are being resurrected.");
      if (rejuvedMOB.location() != corpseRoom) {
        rejuvedMOB
            .location()
            .showOthers(rejuvedMOB, null, CMMsg.MSG_OK_VISUAL, "<S-NAME> disappears!");
        corpseRoom.bringMobHere(rejuvedMOB, false);
      }
      Ability A = rejuvedMOB.fetchAbility("Prop_AstralSpirit");
      if (A != null) rejuvedMOB.delAbility(A);
      A = rejuvedMOB.fetchEffect("Prop_AstralSpirit");
      if (A != null) rejuvedMOB.delEffect(A);

      int it = 0;
      while (it < rejuvedMOB.location().numItems()) {
        Item item = rejuvedMOB.location().fetchItem(it);
        if ((item != null) && (item.container() == body)) {
          CMMsg msg2 = CMClass.getMsg(rejuvedMOB, body, item, CMMsg.MSG_GET, null);
          rejuvedMOB.location().send(rejuvedMOB, msg2);
          CMMsg msg3 = CMClass.getMsg(rejuvedMOB, item, null, CMMsg.MSG_GET, null);
          rejuvedMOB.location().send(rejuvedMOB, msg3);
          it = 0;
        } else it++;
      }
      body.delEffect(body.fetchEffect("Age")); // so misskids doesn't record it
      body.destroy();
      rejuvedMOB
          .baseEnvStats()
          .setDisposition(
              CMath.unsetb(rejuvedMOB.baseEnvStats().disposition(), EnvStats.IS_SITTING));
      rejuvedMOB
          .envStats()
          .setDisposition(
              CMath.unsetb(rejuvedMOB.baseEnvStats().disposition(), EnvStats.IS_SITTING));
      rejuvedMOB.location().show(rejuvedMOB, null, CMMsg.MSG_NOISYMOVEMENT, "<S-NAME> get(s) up!");
      corpseRoom.recoverRoomStats();
      Vector whatsToDo = CMParms.parse(CMProps.getVar(CMProps.SYSTEM_PLAYERDEATH));
      for (int w = 0; w < whatsToDo.size(); w++) {
        String whatToDo = (String) whatsToDo.elementAt(w);
        if (whatToDo.startsWith("UNL")) CMLib.leveler().level(rejuvedMOB);
        else if (whatToDo.startsWith("ASTR")) {
        } else if (whatToDo.startsWith("PUR")) {
        } else if ((whatToDo.trim().equals("0")) || (CMath.s_int(whatToDo) > 0)) {
          if (XPLevel >= 0) {
            int expLost = (CMath.s_int(whatToDo) + (2 * XPLevel)) / 2;
            rejuvedMOB.tell("^*You regain " + expLost + " experience points.^?^.");
            CMLib.leveler().postExperience(rejuvedMOB, null, null, expLost, false);
          }
        } else if (whatToDo.length() < 3) continue;
        else if (XPLevel >= 0) {
          double lvl = (double) body.envStats().level();
          for (int l = body.envStats().level(); l < rejuvedMOB.envStats().level(); l++)
            lvl = lvl / 2.0;
          int expRestored = (int) Math.round(((100.0 + (2.0 * ((double) XPLevel))) * lvl) / 2.0);
          rejuvedMOB.tell("^*You regain " + expRestored + " experience points.^?^.");
          CMLib.leveler().postExperience(rejuvedMOB, null, null, expRestored, false);
        }
      }
      return true;
    } else
      corpseRoom.show(
          tellMob,
          body,
          CMMsg.MSG_OK_VISUAL,
          "<T-NAME> twitch(es) for a moment, but the spirit is too far gone.");
    return false;
  }
Пример #27
0
 public int processVariableEquipment(MOB mob) {
   int newLastTickedDateTime = 0;
   if (mob != null) {
     Room R = mob.location();
     if (R != null) {
       for (int i = 0; i < R.numInhabitants(); i++) {
         MOB M = R.fetchInhabitant(i);
         if ((M != null) && (!M.isMonster()) && (CMSecurity.isAllowed(M, R, "CMDMOBS"))) {
           newLastTickedDateTime = -1;
           break;
         }
       }
       if (newLastTickedDateTime == 0) {
         Vector rivals = new Vector();
         for (int i = 0; i < mob.inventorySize(); i++) {
           Item I = mob.fetchInventory(i);
           if ((I != null)
               && (I.baseEnvStats().rejuv() > 0)
               && (I.baseEnvStats().rejuv() < Integer.MAX_VALUE)) {
             Vector V = null;
             for (int r = 0; r < rivals.size(); r++) {
               Vector V2 = (Vector) rivals.elementAt(r);
               Item I2 = (Item) V2.firstElement();
               if (I2.rawWornCode() == I.rawWornCode()) {
                 V = V2;
                 break;
               }
             }
             if (V == null) {
               V = new Vector();
               rivals.addElement(V);
             }
             V.addElement(I);
           }
         }
         for (int i = 0; i < rivals.size(); i++) {
           Vector V = (Vector) rivals.elementAt(i);
           if ((V.size() == 1) || (((Item) V.firstElement()).rawWornCode() == 0)) {
             for (int r = 0; r < V.size(); r++) {
               Item I = (Item) V.elementAt(r);
               if (CMLib.dice().rollPercentage() < I.baseEnvStats().rejuv()) mob.delInventory(I);
               else {
                 I.baseEnvStats().setRejuv(0);
                 I.envStats().setRejuv(0);
               }
             }
           } else {
             int totalChance = 0;
             for (int r = 0; r < V.size(); r++) {
               Item I = (Item) V.elementAt(r);
               totalChance += I.baseEnvStats().rejuv();
             }
             int chosenChance = CMLib.dice().roll(1, totalChance, 0);
             totalChance = 0;
             Item chosenI = null;
             for (int r = 0; r < V.size(); r++) {
               Item I = (Item) V.elementAt(r);
               if (chosenChance <= (totalChance + I.baseEnvStats().rejuv())) {
                 chosenI = I;
                 break;
               }
               totalChance += I.baseEnvStats().rejuv();
             }
             for (int r = 0; r < V.size(); r++) {
               Item I = (Item) V.elementAt(r);
               if (chosenI != I) mob.delInventory(I);
               else {
                 I.baseEnvStats().setRejuv(0);
                 I.envStats().setRejuv(0);
               }
             }
           }
         }
         if (mob instanceof ShopKeeper) {
           rivals = new Vector();
           CoffeeShop shop = ((ShopKeeper) mob).getShop();
           for (int v = 0; v < shop.getBaseInventory().size(); v++) {
             Environmental E = (Environmental) shop.getBaseInventory().elementAt(v);
             if ((E.baseEnvStats().rejuv() > 0) && (E.baseEnvStats().rejuv() < Integer.MAX_VALUE))
               rivals.addElement(E);
           }
           for (int r = 0; r < rivals.size(); r++) {
             Environmental E = (Environmental) rivals.elementAt(r);
             if (CMLib.dice().rollPercentage() > E.baseEnvStats().rejuv())
               shop.delAllStoreInventory(E);
             else {
               E.baseEnvStats().setRejuv(0);
               E.envStats().setRejuv(0);
             }
           }
         }
         mob.recoverEnvStats();
         mob.recoverCharStats();
         mob.recoverMaxState();
       }
     }
   }
   return newLastTickedDateTime;
 }
Пример #28
0
  @Override
  public boolean invoke(
      MOB mob, List<String> commands, Physical givenTarget, boolean auto, int asLevel) {
    if (commands.size() < 2) {
      if (mob.isMonster() && (commands.size() == 1)) {
        final String parm = correctItem(mob);
        if (parm != null) commands.add(parm);
      }
      if (commands.size() < 2) {
        mob.tell(L("You must specify a target, and what item to swap on the target!"));
        return false;
      }
    }
    final Item I = mob.findItem(null, commands.get(commands.size() - 1));
    if ((I == null) || (!CMLib.flags().canBeSeenBy(I, mob))) {
      mob.tell(L("You don't seem to have '@x1'.", (commands.get(commands.size() - 1))));
      return false;
    }
    if (((I instanceof Armor) && (I.basePhyStats().armor() > 1))
        || ((I instanceof Weapon) && (I.basePhyStats().damage() > 1))) {
      mob.tell(L("@x1 is not buffoonish enough!", I.name(mob)));
      return false;
    }
    commands.remove(commands.size() - 1);

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

    final Item targetItem = targetItem(target);
    if (targetItem == null) {
      if (!freePosition(target)) {
        mob.tell(L("@x1 has no free wearing positions!", target.name(mob)));
        return false;
      }
    }

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

    int levelDiff = target.phyStats().level() - mob.phyStats().level();

    final boolean success = proficiencyCheck(mob, 0, auto);
    if (levelDiff > 0)
      levelDiff = -(levelDiff * ((!CMLib.flags().canBeSeenBy(mob, target)) ? 5 : 15));
    else levelDiff = -(levelDiff * ((!CMLib.flags().canBeSeenBy(mob, target)) ? 1 : 2));

    if (success) {
      final CMMsg msg =
          CMClass.getMsg(
              mob,
              target,
              this,
              (CMMsg.MSG_NOISYMOVEMENT | CMMsg.MASK_DELICATE | CMMsg.MASK_MALICIOUS)
                  | (auto ? CMMsg.MASK_ALWAYS : 0),
              auto ? "" : L("<S-NAME> do(es) buffoonery to <T-NAMESELF>."));
      if (mob.location().okMessage(mob, msg)) {
        mob.location().send(mob, msg);
        long position = -1;
        if (targetItem != null) {
          position = targetItem.rawWornCode();
          targetItem.unWear();
        } else {
          final Vector<Long> free = getFreeWearingPositions(target);
          if (free.size() < 1) {
            mob.tell(L("@x1 has no free wearing positions!", target.name(mob)));
            return false;
          }
          if ((free.contains(Long.valueOf(Wearable.WORN_WIELD)))
              && ((I instanceof Weapon) || (!(I instanceof Armor)))) position = Wearable.WORN_WIELD;
          else position = free.elementAt(CMLib.dice().roll(1, free.size(), -1)).longValue();
        }
        if (position >= 0) {
          I.unWear();
          target.moveItemTo(I);
          I.wearAt(position);
        }
      }
    } else
      return beneficialVisualFizzle(
          mob, target, L("<S-NAME> attempt(s) buffoonery on <T-NAMESELF>, but fail(s)."));

    return success;
  }
Пример #29
0
  public boolean invoke(
      MOB mob, Vector commands, Environmental givenTarget, boolean auto, int asLevel) {
    if (type.length() == 0) return false;
    if ((mob.getClanID() == null)
        || (mob.getClanID().equalsIgnoreCase(""))
        || (mob.getClanRole() == 0)) {
      mob.tell("You aren't even a member of a clan.");
      return false;
    }
    Clan C = CMLib.clans().getClan(mob.getClanID());
    if (C == null) {
      mob.tell("You aren't even a member of a clan.");
      return false;
    }
    if (C.allowedToDoThis(mob, Clan.FUNC_CLANENCHANT) != 1) {
      mob.tell("You are not authorized to draw from the power of your " + C.typeName() + ".");
      return false;
    }
    String ClanName = C.clanID();
    String ClanType = C.typeName();

    // Invoking will be like:
    //   CAST [CLANEQSPELL] ITEM QUANTITY
    //   -2   -1            0    1
    if (commands.size() < 1) {
      mob.tell("Enchant which spell onto what?");
      return false;
    }
    if (commands.size() < 2) {
      mob.tell("Use how much clan enchantment power?");
      return false;
    }
    Environmental target =
        mob.location()
            .fetchFromMOBRoomFavorsItems(
                mob, null, (String) commands.elementAt(0), Item.WORNREQ_UNWORNONLY);
    if ((target == null) || (!CMLib.flags().canBeSeenBy(target, mob))) {
      mob.tell("You don't see '" + ((String) commands.elementAt(0)) + "' here.");
      return false;
    }
    // Add clan power check start
    int points = CMath.s_int((String) commands.elementAt(1));
    if (points <= 0) {
      mob.tell("You need to use at least 1 enchantment point.");
      return false;
    }
    long exp = points * CMProps.getIntVar(CMProps.SYSTEMI_CLANENCHCOST);
    if ((C.getExp() < exp) || (exp < 0)) {
      mob.tell(
          "You need "
              + exp
              + " to do that, but your "
              + C.typeName()
              + " has only "
              + C.getExp()
              + " experience points.");
      return false;
    }

    // Add clan power check end
    if (target.fetchEffect("Prop_ClanEquipment") != null) {
      mob.tell(target.name() + " is already clan enchanted.");
      return false;
    }

    // lose all the mana!
    if (!super.invoke(mob, commands, givenTarget, auto, asLevel)) return false;

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

    C.setExp(C.getExp() - exp);
    C.update();

    if (success) {
      CMMsg msg =
          CMClass.getMsg(
              mob,
              target,
              this,
              verbalCastCode(mob, target, auto),
              "^S<S-NAME> move(s) <S-HIS-HER> fingers around <T-NAMESELF>, encanting intensely.^?");
      if (mob.location().okMessage(mob, msg)) {
        mob.location().send(mob, msg);
        Ability A = CMClass.getAbility("Prop_ClanEquipment");
        StringBuffer str = new StringBuffer("");
        str.append(type); // Type of Enchantment
        str.append(" ");
        str.append("" + points); // Power of Enchantment
        str.append(" \"");
        str.append(ClanName); // Clan Name
        str.append("\" \"");
        str.append(ClanType); // Clan Type
        str.append("\"");
        A.setMiscText(str.toString());
        target.addEffect(A);
      }
    } else
      beneficialWordsFizzle(
          mob,
          target,
          "<S-NAME> move(s) <S-HIS-HER> fingers around <T-NAMESELF>, encanting intensely, and looking very frustrated.");
    return success;
  }
Пример #30
0
 @Override
 public void executeMsg(final Environmental myHost, final CMMsg msg) {
   super.executeMsg(myHost, msg);
   if ((myHost == null) || (!(myHost instanceof MOB))) return;
   final MOB mob = (MOB) myHost;
   if (msg.amISource(mob)) {
     if (((msg.sourceMinor() == CMMsg.TYP_LOOK) || (msg.sourceMinor() == CMMsg.TYP_EXAMINE))
         && (msg.target() instanceof Wand)
         && (mob.charStats().getClassLevel(this) >= 30)) {
       final String message =
           "<O-NAME> has " + ((Wand) msg.target()).usesRemaining() + " charges remaining.";
       msg.addTrailerMsg(
           CMClass.getMsg(
               mob,
               null,
               msg.target(),
               CMMsg.MSG_OK_VISUAL,
               CMMsg.NO_EFFECT,
               CMMsg.NO_EFFECT,
               message));
     } else if (msg.tool() != null) {
       if (msg.tool().ID().equals("Skill_Spellcraft")) {
         if ((msg.tool().text().length() > 0) && (msg.target() instanceof MOB)) {
           Ability A = ((MOB) msg.target()).fetchAbility(msg.tool().text());
           if (A == null) return;
           final Ability myA = mob.fetchAbility(A.ID());
           if (myA != null) {
             if ((!A.isSavable())
                 && ((A.classificationCode() & Ability.ALL_ACODES) == Ability.ACODE_SPELL)
                 && (CMLib.ableMapper().lowestQualifyingLevel(A.ID()) < 30))
               addAbilityToSpellcraftList(mob, A);
           } else if (CMLib.ableMapper().lowestQualifyingLevel(A.ID()) < 30) {
             final Vector<Ability> otherChoices = new Vector<Ability>();
             for (int a = 0; a < mob.numAbilities(); a++) {
               final Ability A2 = mob.fetchAbility(a);
               if ((A2 != null)
                   && (!A2.isSavable())
                   && ((A2.classificationCode() & Ability.ALL_ACODES) == Ability.ACODE_SPELL))
                 otherChoices.addElement(A2);
             }
             A = (Ability) A.copyOf();
             A.setProficiency(0);
             A.setSavable(false);
             if (otherChoices.size() > (mob.charStats().getClassLevel(this) / 3)) {
               final Ability A2 =
                   otherChoices.elementAt(CMLib.dice().roll(1, otherChoices.size(), -1));
               clearAbilityFromSpellcraftList(mob, A2);
             }
             addAbilityToSpellcraftList(mob, A);
           }
         }
       } else if (msg.tool().ID().equals("Spell_Scribe")
           || msg.tool().ID().equals("Spell_EnchantWand")
           || msg.tool().ID().equals("Spell_MagicItem")
           || msg.tool().ID().equals("Spell_StoreSpell")
           || msg.tool().ID().equals("Spell_WardArea")) {
         final Ability A = mob.fetchAbility(msg.tool().text());
         if ((A != null) && (!A.isSavable())) clearAbilityFromSpellcraftList(mob, A);
       } else if (msg.tool() instanceof Ability) {
         final Ability A = mob.fetchAbility(msg.tool().ID());
         if ((A != null)
             && (!A.isSavable())
             && ((A.classificationCode() & Ability.ALL_ACODES) == Ability.ACODE_SPELL))
           clearAbilityFromSpellcraftList(mob, A);
       }
     }
   }
 }