Esempio n. 1
0
  public void setTrapped(Environmental myThang, Trap theTrap, boolean isTrapped) {
    for (int a = 0; a < myThang.numEffects(); a++) {
      Ability A = myThang.fetchEffect(a);
      if ((A != null) && (A instanceof Trap)) A.unInvoke();
    }

    if ((isTrapped) && (myThang.fetchEffect(theTrap.ID()) == null)) myThang.addEffect(theTrap);
  }
Esempio n. 2
0
  @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;
  }
Esempio n. 3
0
 public Trap fetchMyTrap(Environmental myThang) {
   if (myThang == null) return null;
   Ability A = null;
   for (int a = 0; a < myThang.numEffects(); a++) {
     A = myThang.fetchEffect(a);
     if ((A != null) && (A instanceof Trap)) return (Trap) A;
   }
   return null;
 }
Esempio n. 4
0
 public void sortEnumeratedList(
     Enumeration e, List<String> allKnownFields, StringBuffer allFieldsMsg) {
   for (; e.hasMoreElements(); ) {
     final Environmental E = (Environmental) e.nextElement();
     final String[] fields = E.getStatCodes();
     for (int x = 0; x < fields.length; x++)
       if (!allKnownFields.contains(fields[x])) {
         allKnownFields.add(fields[x]);
         allFieldsMsg.append(fields[x] + " ");
       }
   }
 }
Esempio n. 5
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;
  }
Esempio n. 6
0
 public static void setStat(Environmental E, String stat, String value) {
   if ((stat != null)
       && (stat.length() > 0)
       && (stat.equalsIgnoreCase("REJUV"))
       && (E instanceof Physical)) ((Physical) E).basePhyStats().setRejuv(CMath.s_int(value));
   else E.setStat(stat, value);
 }
Esempio n. 7
0
 public boolean sameAs(Environmental E) {
   if (!(E instanceof GenShipComponent)) return false;
   String[] theCodes = getStatCodes();
   for (int i = 0; i < theCodes.length; i++)
     if (!E.getStat(theCodes[i]).equals(getStat(theCodes[i]))) return false;
   return true;
 }
Esempio n. 8
0
 @Override
 public boolean sameAs(Environmental E) {
   if (!(E instanceof GenSoftware)) return false;
   final String[] theCodes = getStatCodes();
   for (int i = 0; i < theCodes.length; i++)
     if (!E.getStat(theCodes[i]).equals(getStat(theCodes[i]))) return false;
   return true;
 }
Esempio n. 9
0
 @Override
 public boolean sameAs(Environmental E) {
   if (!(E instanceof GenLightSource)) return false;
   for (int i = 0; i < getStatCodes().length; i++) {
     if (!E.getStat(getStatCodes()[i]).equals(getStat(getStatCodes()[i]))) return false;
   }
   return true;
 }
Esempio n. 10
0
 @Override
 public boolean sameAs(Environmental E) {
   if (!(E instanceof GenArmor)) return false;
   final String[] codes = getStatCodes();
   for (int i = 0; i < codes.length; i++) {
     if (!E.getStat(codes[i]).equals(getStat(codes[i]))) return false;
   }
   return true;
 }
Esempio n. 11
0
 public double memoryUse(Environmental E, int number) {
   double s = -1.0;
   try {
     int n = number;
     Object[] objs = new Object[n];
     Environmental cl = E;
     Runtime rt = Runtime.getRuntime();
     long m0 = rt.totalMemory() - rt.freeMemory();
     System.gc();
     Thread.sleep(500);
     for (int i = 0; i < n; ++i) objs[i] = E = (Environmental) cl.copyOf();
     System.gc();
     Thread.sleep(1000);
     long m1 = rt.totalMemory() - rt.freeMemory();
     long dm = m1 - m0;
     s = (double) dm / (double) n;
     if (s < 0.0) return memoryUse(E, number);
   } catch (Exception e) {
     return -1;
   }
   return s;
 }
Esempio n. 12
0
 public void extinguish(MOB source, Environmental target, boolean mundane) {
   if (target instanceof Room) {
     Room R = (Room) target;
     for (int m = 0; m < R.numInhabitants(); m++) {
       MOB M = R.fetchInhabitant(m);
       if (M != null) extinguish(source, M, mundane);
     }
     for (int i = 0; i < R.numItems(); i++) {
       Item I = R.fetchItem(i);
       if (I != null) extinguish(source, I, mundane);
     }
     return;
   }
   for (int a = target.numEffects() - 1; a >= 0; a--) {
     Ability A = target.fetchEffect(a);
     if ((A != null)
         && ((!mundane)
             || ((A.classificationCode() & Ability.ALL_ACODES) == Ability.ACODE_PROPERTY))) {
       if ((CMath.bset(A.flags(), Ability.FLAG_HEATING) && (!mundane))
           || (CMath.bset(A.flags(), Ability.FLAG_FIREBASED))
           || ((A.ID().equalsIgnoreCase("Spell_SummonElemental")
               && A.text().toUpperCase().indexOf("FIRE") >= 0))) A.unInvoke();
     }
   }
   if ((target instanceof MOB) && (!mundane)) {
     MOB tmob = (MOB) target;
     if (tmob.charStats().getMyRace().ID().equals("FireElemental"))
       CMLib.combat().postDeath(source, (MOB) target, null);
     for (int i = 0; i < tmob.inventorySize(); i++) {
       Item I = tmob.fetchInventory(i);
       if (I != null) extinguish(tmob, I, mundane);
     }
   }
   if ((target instanceof Light) && (((Light) target).isLit())) {
     ((Light) target).tick(target, Tickable.TICKID_LIGHT_FLICKERS);
     ((Light) target).light(false);
   }
 }
Esempio n. 13
0
  protected final Map<String, Double> getRatesFor(final Environmental affecting, String currency) {
    if (spaceMaxCut <= 0.0) return rates;
    currency = currency.toUpperCase();
    if (rates.containsKey(currency)) return rates;
    String myCurrency = CMLib.beanCounter().getCurrency(affecting);
    if (myCurrency.equalsIgnoreCase(currency)) {
      rates.put(currency, Double.valueOf(cut));
      return rates;
    }
    SpaceObject homeO = CMLib.map().getSpaceObject(affecting, false);
    if (homeO != null) {
      myCurrency = CMLib.beanCounter().getCurrency(homeO);
      if (myCurrency.equalsIgnoreCase(currency)) {
        rates.put(currency, Double.valueOf(cut));
        return rates;
      }
    } else {
      // no space object, wtf? this SHOULD fail
      if (!complainedAboutSpaceError) {
        complainedAboutSpaceError = true;
        Log.errOut(
            "MoneyChanger", affecting.Name() + " is not on a planet, so space rates cannot apply!");
      }
      return rates;
    }
    for (Enumeration<Area> a = CMLib.map().spaceAreas(); a.hasMoreElements(); ) {
      Area A = a.nextElement();
      if ((A != null) && (A != homeO)) {
        myCurrency = CMLib.beanCounter().getCurrency(A);
        if (myCurrency.equalsIgnoreCase(currency)) {
          SpaceObject oA = (SpaceObject) A;
          long distance = CMLib.map().getDistanceFrom(homeO, oA);
          if ((distance < 0) || (distance > spaceMaxDistance)) {
            rates.put(currency, Double.valueOf(spaceMaxCut));
          } else {
            double pct = CMath.div(distance, spaceMaxDistance);
            double amt = spaceMaxCut * pct;
            if (amt < cut) amt = cut;
            rates.put(currency, Double.valueOf(cut));
          }
          return rates;
        }
      }
    }

    return rates;
  }
Esempio n. 14
0
  @Override
  public boolean invoke(
      MOB mob, List<String> commands, Physical givenTarget, boolean auto, int asLevel) {
    final MOB target = this.getTarget(mob, commands, givenTarget);
    if (target == null) return false;

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

    int levelDiff =
        target.phyStats().level() - (mob.phyStats().level() + (2 * getXLEVELLevel(mob)));
    if (levelDiff < 0) levelDiff = 0;
    final boolean success = proficiencyCheck(mob, -(levelDiff * 25), auto);
    Item Bread = null;
    Item BreadContainer = null;
    for (int i = 0; i < target.numItems(); i++) {
      final Item I = target.getItem(i);
      if ((I != null) && (I instanceof Food)) {
        if (I.container() != null) {
          Bread = I;
          BreadContainer = I.container();
        } else {
          Bread = I;
          BreadContainer = null;
          break;
        }
      }
    }
    if ((Bread != null) && (BreadContainer != null))
      CMLib.commands().postGet(target, BreadContainer, Bread, false);
    if (Bread == null) {
      final ShopKeeper SK = CMLib.coffeeShops().getShopKeeper(target);
      if (SK != null) {
        for (final Iterator<Environmental> i = SK.getShop().getStoreInventory(); i.hasNext(); ) {
          final Environmental E2 = i.next();
          if ((E2 != null) && (E2 instanceof Food)) {
            Bread = (Item) E2.copyOf();
            target.addItem(Bread);
            break;
          }
        }
      }
    }
    if ((success) && (Bread != null)) {
      CMMsg msg =
          CMClass.getMsg(
              mob,
              target,
              this,
              verbalCastCode(mob, target, auto),
              L(
                  "^S<S-NAME> @x1 for <T-NAMESELF> to provide <S-HIS-HER> daily bread!^?",
                  prayWord(mob)));
      final CMMsg msg2 =
          CMClass.getMsg(
              mob,
              target,
              this,
              CMMsg.MSK_CAST_MALICIOUS_VERBAL | CMMsg.TYP_MIND | (auto ? CMMsg.MASK_ALWAYS : 0),
              null);
      if ((mob.location().okMessage(mob, msg)) && (mob.location().okMessage(mob, msg2))) {
        mob.location().send(mob, msg);
        mob.location().send(mob, msg2);
        if ((msg.value() <= 0) && (msg2.value() <= 0)) {
          msg =
              CMClass.getMsg(
                  target,
                  mob,
                  Bread,
                  CMMsg.MSG_GIVE,
                  L("<S-NAME> gladly donate(s) <O-NAME> to <T-NAMESELF>."));
          if (mob.location().okMessage(mob, msg)) mob.location().send(mob, msg);
        }
      }
    } else
      maliciousFizzle(
          mob,
          target,
          auto
              ? ""
              : L(
                  "<S-NAME> @x1 for <T-NAMESELF> to provide <S-HIS-HER> daily bread, but nothing happens.",
                  prayWord(mob)));

    // return whether it worked
    return success;
  }
Esempio n. 15
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;
 }
Esempio n. 16
0
 public String getTickStatusSummary(Tickable obj) {
   if (obj == null) return "";
   long code = obj.getTickStatus();
   if (obj instanceof Environmental) {
     if (CMath.bset(code, Tickable.STATUS_BEHAVIOR)) {
       long b = (code - Tickable.STATUS_BEHAVIOR);
       String codeWord = "Behavior #" + b;
       if ((b >= 0) && (b < ((Environmental) obj).numBehaviors())) {
         Behavior B = ((Environmental) obj).fetchBehavior((int) b);
         codeWord += " (" + B.name() + ": " + B.getTickStatus();
       } else codeWord += " (#Error#)";
       return codeWord;
     } else if (CMath.bset(code, Tickable.STATUS_SCRIPT) && (obj instanceof MOB)) {
       long b = (code - Tickable.STATUS_SCRIPT);
       String codeWord = "Script #" + b;
       if ((b >= 0) && (b < ((MOB) obj).numScripts())) {
         ScriptingEngine S = ((MOB) obj).fetchScript((int) b);
         codeWord += " (" + CMStrings.limit(S.getScript(), 20) + ": " + S.getTickStatus();
       }
       return codeWord;
     } else if ((code & STATUS_ALLMISCTICKS) > 0) {
       long base = (code & STATUS_ALLMISCTICKS);
       int num = 0;
       for (int i = 1; i < 6; i++)
         if ((1 << (10 + i)) == base) {
           num = i;
           break;
         }
       return "Misc" + num + " Activity #" + (code - base);
     } else if (CMath.bset(code, Tickable.STATUS_AFFECT)) {
       long b = (code - Tickable.STATUS_AFFECT);
       String codeWord = "Effect #" + b;
       if ((b >= 0) && (b < ((Environmental) obj).numEffects())) {
         Environmental E = ((Environmental) obj).fetchEffect((int) b);
         codeWord += " (" + E.name() + ": " + E.getTickStatus() + ")";
       }
       return codeWord;
     }
   }
   String codeWord = null;
   if (CMath.bset(code, Tickable.STATUS_BEHAVIOR)) codeWord = "Behavior?!";
   else if (CMath.bset(code, Tickable.STATUS_SCRIPT)) codeWord = "Script?!";
   else if (CMath.bset(code, Tickable.STATUS_AFFECT)) codeWord = "Effect?!";
   else
     switch ((int) code) {
       case (int) Tickable.STATUS_ALIVE:
         codeWord = "Alive";
         break;
       case (int) Tickable.STATUS_REBIRTH:
         codeWord = "Rebirth";
         break;
       case (int) Tickable.STATUS_CLASS:
         codeWord = "Class";
         break;
       case (int) Tickable.STATUS_DEAD:
         codeWord = "Dead";
         break;
       case (int) Tickable.STATUS_END:
         codeWord = "End";
         break;
       case (int) Tickable.STATUS_FIGHT:
         codeWord = "Fighting";
         break;
       case (int) Tickable.STATUS_NOT:
         codeWord = "!";
         break;
       case (int) Tickable.STATUS_OTHER:
         codeWord = "Other";
         break;
       case (int) Tickable.STATUS_RACE:
         codeWord = "Race";
         break;
       case (int) Tickable.STATUS_START:
         codeWord = "Start";
         break;
       case (int) Tickable.STATUS_WEATHER:
         codeWord = "Weather";
         break;
       default:
         codeWord = "?";
         break;
     }
   return codeWord;
 }
Esempio n. 17
0
  public boolean invoke(
      MOB mob, Vector commands, Environmental givenTarget, boolean auto, int asLevel) {
    if ((commands.size() < 1) && (givenTarget == null)) {
      mob.tell("Wizard Lock what?.");
      return false;
    }
    String targetName = CMParms.combine(commands, 0);

    Environmental target = null;
    int dirCode = Directions.getGoodDirectionCode(targetName);
    if (dirCode >= 0) target = mob.location().getExitInDir(dirCode);
    if (target == null)
      target = getTarget(mob, mob.location(), givenTarget, commands, Wearable.FILTER_ANY);
    if (target == null) return false;

    if ((!(target instanceof Container)) && (!(target instanceof Exit))) {
      mob.tell("You can't lock that.");
      return false;
    }

    if (target instanceof Container) {
      Container container = (Container) target;
      if ((!container.hasALid()) || (!container.hasALock())) {
        mob.tell("You can't lock that!");
        return false;
      }
    } else if (target instanceof Exit) {
      Exit exit = (Exit) target;
      if (!exit.hasADoor()) {
        mob.tell("You can't lock that!");
        return false;
      }
    }

    if (target.fetchEffect(this.ID()) != null) {
      mob.tell(target.name() + " is already magically locked!");
      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,
              target,
              this,
              verbalCastCode(mob, target, auto),
              auto ? "" : "^S<S-NAME> point(s) <S-HIS-HER> finger at <T-NAMESELF>, incanting.^?");
      if (mob.location().okMessage(mob, msg)) {
        mob.location().send(mob, msg);
        if (target instanceof Exit) {
          Exit exit = (Exit) target;
          exit.setDoorsNLocks(
              exit.hasADoor(),
              false,
              exit.defaultsClosed(),
              exit.hasALock(),
              true,
              exit.defaultsLocked());
          Room R = mob.location();
          Room R2 = null;
          for (int d = Directions.NUM_DIRECTIONS() - 1; d >= 0; d--)
            if (R.getExitInDir(d) == target) {
              R2 = R.getRoomInDir(d);
              break;
            }
          if ((CMLib.law().doesOwnThisProperty(mob, R))
              || ((R2 != null) && (CMLib.law().doesOwnThisProperty(mob, R2)))) {
            target.addNonUninvokableEffect((Ability) copyOf());
            CMLib.database().DBUpdateExits(R);
          } else beneficialAffect(mob, target, asLevel, Integer.MAX_VALUE / 2);
          mob.location().show(mob, target, CMMsg.MSG_OK_VISUAL, "<T-NAME> look(s) shut tight!");
        } else if (target instanceof Container) {
          beneficialAffect(mob, target, asLevel, Integer.MAX_VALUE / 2);
          Container container = (Container) target;
          container.setLidsNLocks(container.hasALid(), false, container.hasALock(), true);
          mob.location().show(mob, target, CMMsg.MSG_OK_VISUAL, "<T-NAME> look(s) shut tight!");
        }
        Ability lock = target.fetchEffect(ID());
        if (lock != null) {
          lock.setMiscText(Integer.toString(mob.envStats().level()));
          if (target instanceof Exit) {
            Room R = mob.location();
            if (!CMLib.law().doesHavePriviledgesHere(mob, R))
              for (int a = 0; a < R.numEffects(); a++)
                if ((R.fetchEffect(a) instanceof LandTitle)
                    && (((LandTitle) R.fetchEffect(a)).landOwner().length() > 0))
                  lock.setMiscText(lock.text() + " MALICIOUS");
          }
        }
      }

    } else
      beneficialWordsFizzle(
          mob, target, "<S-NAME> point(s) at <T-NAMESELF>, incanting, but nothing happens.");

    // return whether it worked
    return success;
  }
Esempio n. 18
0
  protected static boolean tryMerge(
      MOB mob,
      Room room,
      Environmental E,
      List things,
      List<String> changes,
      List<String> onfields,
      List<String> ignore,
      boolean noisy) {
    boolean didAnything = false;
    final List<String> efields = new Vector();
    List<String> allMyFields = new Vector();
    final String[] EFIELDS = E.getStatCodes();
    for (int i = 0; i < EFIELDS.length; i++)
      if (!efields.contains(EFIELDS[i])) efields.add(EFIELDS[i]);
    efields.add("REJUV");
    allMyFields = new XVector<String>(efields);
    for (int v = 0; v < ignore.size(); v++)
      if (efields.contains(ignore.get(v))) efields.remove(ignore.get(v));
    for (int v = 0; v < changes.size(); v++)
      if (efields.contains(changes.get(v))) efields.remove(changes.get(v));
    if (noisy) mergedebugtell(mob, "AllMy-" + CMParms.toStringList(allMyFields));
    if (noisy) mergedebugtell(mob, "efields-" + CMParms.toStringList(efields));
    for (int t = 0; t < things.size(); t++) {
      final Environmental E2 = (Environmental) things.get(t);
      if (noisy)
        mergedebugtell(
            mob, E.name() + "/" + E2.name() + "/" + CMClass.classID(E) + "/" + CMClass.classID(E2));
      if (CMClass.classID(E).equals(CMClass.classID(E2))) {
        Vector fieldsToCheck = null;
        if (onfields.size() > 0) {
          fieldsToCheck = new Vector();
          for (int v = 0; v < onfields.size(); v++)
            if (efields.contains(onfields.get(v))) fieldsToCheck.add(onfields.get(v));
        } else fieldsToCheck = new XVector<String>(efields);

        boolean checkedOut = fieldsToCheck.size() > 0;
        if (noisy) mergedebugtell(mob, "fieldsToCheck-" + CMParms.toStringList(fieldsToCheck));
        if (checkedOut)
          for (int i = 0; i < fieldsToCheck.size(); i++) {
            final String field = (String) fieldsToCheck.get(i);
            if (noisy)
              mergedebugtell(
                  mob,
                  field
                      + "/"
                      + getStat(E, field)
                      + "/"
                      + getStat(E2, field)
                      + "/"
                      + getStat(E, field).equals(getStat(E2, field)));
            if (!getStat(E, field).equals(getStat(E2, field))) {
              checkedOut = false;
              break;
            }
          }
        if (checkedOut) {
          List<String> fieldsToChange = null;
          if (changes.size() == 0) fieldsToChange = new XVector<String>(allMyFields);
          else {
            fieldsToChange = new Vector();
            for (int v = 0; v < changes.size(); v++)
              if (allMyFields.contains(changes.get(v))) fieldsToChange.add(changes.get(v));
          }
          if (noisy) mergedebugtell(mob, "fieldsToChange-" + CMParms.toStringList(fieldsToChange));
          for (int i = 0; i < fieldsToChange.size(); i++) {
            final String field = fieldsToChange.get(i);
            if (noisy)
              mergedebugtell(
                  mob,
                  E.name()
                      + " wants to change "
                      + field
                      + " value "
                      + getStat(E, field)
                      + " to "
                      + getStat(E2, field)
                      + "/"
                      + (!getStat(E, field).equals(getStat(E2, field))));
            if (!getStat(E, field).equals(getStat(E2, field))) {
              setStat(E, field, getStat(E2, field));
              Log.sysOut(
                  "Merge",
                  "The "
                      + CMStrings.capitalizeAndLower(field)
                      + " field on "
                      + E.Name()
                      + " in "
                      + room.roomID()
                      + " was changed to "
                      + getStat(E2, field)
                      + ".");
              didAnything = true;
            }
          }
        }
      }
    }
    if (didAnything) {
      if (E instanceof Physical) ((Physical) E).recoverPhyStats();
      if (E instanceof MOB) {
        ((MOB) E).recoverCharStats();
        ((MOB) E).recoverMaxState();
      }
      E.text();
    }
    return didAnything;
  }
Esempio n. 19
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;
  }