Ejemplo n.º 1
0
 @Override
 public void setStat(String code, String val) {
   if (CMLib.coffeeMaker().getGenMobCodeNum(code) >= 0)
     CMLib.coffeeMaker().setGenMobStat(this, code, val);
   else
     switch (getCodeNum(code)) {
       case 0:
         setClericRequirements(val);
         break;
       case 1:
         setClericRitual(val);
         break;
       case 2:
         setWorshipRequirements(val);
         break;
       case 3:
         setWorshipRitual(val);
         break;
       case 4:
         setServiceRitual(val);
         break;
       default:
         CMProps.setStatCodeExtensionValue(getStatCodes(), xtraValues, code, val);
         break;
     }
 }
Ejemplo n.º 2
0
  @Override
  public void run() {

    nextTickTime = System.currentTimeMillis() + tickTime;
    // final String oldThreadName=Thread.currentThread().getName();
    try {
      currentThread = Thread.currentThread();
      lastStart = System.currentTimeMillis();
      lastClient = null;
      final boolean allSuspended = CMLib.threads().isAllSuspended();
      if ((CMProps.getBoolVar(CMProps.Bool.MUDSTARTED)) && (!allSuspended)) {
        for (final Iterator<TickClient> i = tickers(); i.hasNext(); ) {
          final TickClient client = i.next();
          lastClient = client;
          // if(client.getCurrentTickDown()<=1)
          // currentThread.setName(oldThreadName+":"+getName()+":"+client.getName());
          if (client.tickTicker(false)) {
            delTicker(client); // cant do i.remove, its an streeset
          }
        }
      }
    } finally {
      lastStop = System.currentTimeMillis();
      milliTotal += (lastStop - lastStart);
      tickTotal++;
      currentThread = null;
      // Thread.currentThread().setName(oldThreadName);
    }
    if (tickers.size() == 0) {
      if (CMLib.threads() instanceof ServiceEngine)
        ((ServiceEngine) CMLib.threads()).delTickGroup(this);
    }
  }
Ejemplo n.º 3
0
 public void setStat(String code, String val) {
   if (CMLib.coffeeMaker().getGenItemCodeNum(code) >= 0)
     CMLib.coffeeMaker().setGenItemStat(this, code, val);
   else
     switch (getCodeNum(code)) {
       case 0:
         setLidsNLocks(hasALid(), isOpen(), CMath.s_bool(val), false);
         break;
       case 1:
         setLidsNLocks(CMath.s_bool(val), isOpen(), hasALock(), false);
         break;
       case 2:
         setCapacity(CMath.s_parseIntExpression(val));
         break;
       case 3:
         setContainTypes(CMath.s_parseBitLongExpression(Container.CONTAIN_DESCS, val));
         break;
       case 4:
         {
           int x = CMath.s_parseListIntExpression(RawMaterial.CODES.NAMES(), val);
           x = ((x >= 0) && (x < RawMaterial.RESOURCE_MASK)) ? RawMaterial.CODES.GET(x) : x;
           setFuelType(x);
           break;
         }
       case 5:
         setPowerCapacity(CMath.s_parseLongExpression(val));
         break;
       default:
         CMProps.setStatCodeExtensionValue(getStatCodes(), xtraValues, code, val);
         break;
     }
 }
Ejemplo n.º 4
0
 @Override
 public String text() {
   if (CMProps.getBoolVar(CMProps.Bool.MOBCOMPRESS))
     miscText = CMLib.encoder().compressString(CMLib.coffeeMaker().getPropertiesStr(this, false));
   else miscText = CMLib.coffeeMaker().getPropertiesStr(this, false);
   return super.text();
 }
Ejemplo n.º 5
0
  public void recursiveDropMOB(MOB mob, Room room, Item thisContainer, boolean bodyFlag) {
    // caller is responsible for recovering any env
    // stat changes!

    if (CMLib.flags().isHidden(thisContainer))
      thisContainer
          .baseEnvStats()
          .setDisposition(
              thisContainer.baseEnvStats().disposition()
                  & ((int) EnvStats.ALLMASK - EnvStats.IS_HIDDEN));
    mob.delInventory(thisContainer);
    thisContainer.unWear();
    if (!bodyFlag) bodyFlag = (thisContainer instanceof DeadBody);
    if (bodyFlag) {
      room.addItem(thisContainer);
      thisContainer.setExpirationDate(0);
    } else room.addItemRefuse(thisContainer, CMProps.getIntVar(CMProps.SYSTEMI_EXPIRE_PLAYER_DROP));
    thisContainer.recoverEnvStats();
    boolean nothingDone = true;
    do {
      nothingDone = true;
      for (int i = 0; i < mob.inventorySize(); i++) {
        Item thisItem = mob.fetchInventory(i);
        if ((thisItem != null) && (thisItem.container() == thisContainer)) {
          recursiveDropMOB(mob, room, thisItem, bodyFlag);
          nothingDone = false;
          break;
        }
      }
    } while (!nothingDone);
  }
Ejemplo n.º 6
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;
 }
Ejemplo n.º 7
0
 @Override
 public String getStat(String code) {
   if (CMLib.coffeeMaker().getGenItemCodeNum(code) >= 0)
     return CMLib.coffeeMaker().getGenItemStat(this, code);
   switch (getCodeNum(code)) {
     case 0:
       return "" + hasALock();
     case 1:
       return "" + hasADoor();
     case 2:
       return "" + capacity();
     case 3:
       return "" + containTypes();
     case 4:
       return "" + openDelayTicks();
     case 5:
       return "" + getClothingLayer();
     case 6:
       return "" + getLayerAttributes();
     case 7:
       return "" + defaultsClosed();
     case 8:
       return "" + defaultsLocked();
     default:
       return CMProps.getStatCodeExtensionValue(getStatCodes(), xtraValues, code);
   }
 }
Ejemplo n.º 8
0
 @Override
 public String[] getStatCodes() {
   if (codes == null)
     codes =
         CMProps.getStatCodesList(
             CMParms.toStringArray(GenericBuilder.GenItemCode.values()), this);
   return codes;
 }
Ejemplo n.º 9
0
 @Override
 public boolean execute(MOB mob, Vector commands, int metaFlags) throws java.io.IOException {
   mob.tell(L("CoffeeMud v@x1", CMProps.getVar(CMProps.Str.MUDVER)));
   mob.tell(L("(C) 2000-2015 Bo Zimmerman"));
   mob.tell(L("^<A HREF=\"mailto:[email protected]\"^>[email protected]^</A^>"));
   mob.tell(L("^<A HREF=\"http://www.coffeemud.org\"^>http://www.coffeemud.org^</A^>"));
   return false;
 }
Ejemplo n.º 10
0
 @Override
 public void setPermanentStat(int abilityCode, int value) {
   setStat(abilityCode, value);
   if (CharStats.CODES.isBASE(abilityCode))
     setStat(
         CharStats.CODES.toMAXBASE(abilityCode),
         value - CMProps.getIntVar(CMProps.Int.BASEMAXSTAT));
 }
Ejemplo n.º 11
0
 @Override
 public boolean execute(MOB mob, List<String> commands, int metaFlags) throws java.io.IOException {
   final StringBuffer head = new StringBuffer("");
   final boolean isArchonLooker = CMSecurity.isASysOp(mob);
   head.append("^x[");
   head.append(CMStrings.padRight(L("Class"), 16) + " ");
   head.append(CMStrings.padRight(L("Race"), 8) + " ");
   head.append(CMStrings.padRight(L("Lvl"), 4) + " ");
   if (isArchonLooker) head.append(CMStrings.padRight(L("Last"), 18) + " ");
   head.append("] Character Name^.^?\n\r");
   mob.tell(
       "^x["
           + CMStrings.centerPreserve(
               L("The Administrators of @x1", CMProps.getVar(CMProps.Str.MUDNAME)),
               head.length() - 10)
           + "]^.^?");
   final java.util.List<PlayerLibrary.ThinPlayer> allUsers =
       CMLib.database().getExtendedUserList();
   String mask = CMProps.getVar(CMProps.Str.WIZLISTMASK);
   if (mask.length() == 0) mask = "-ANYCLASS +Archon";
   final MaskingLibrary.CompiledZMask compiledMask = CMLib.masking().maskCompile(mask);
   for (final PlayerLibrary.ThinPlayer U : allUsers) {
     CharClass C;
     final MOB player = CMLib.players().getPlayer(U.name());
     if (player != null) C = player.charStats().getCurrentClass();
     else C = CMClass.getCharClass(U.charClass());
     if (C == null) C = CMClass.findCharClass(U.charClass());
     if (((player != null) && (CMLib.masking().maskCheck(compiledMask, player, true)))
         || (CMLib.masking().maskCheck(compiledMask, U))) {
       head.append("[");
       if (C != null) head.append(CMStrings.padRight(C.name(), 16) + " ");
       else head.append(CMStrings.padRight(L("Unknown"), 16) + " ");
       head.append(CMStrings.padRight(U.race(), 8) + " ");
       if ((C == null) || (!C.leveless()))
         head.append(CMStrings.padRight("" + U.level(), 4) + " ");
       else head.append(CMStrings.padRight("    ", 4) + " ");
       if (isArchonLooker)
         head.append(CMStrings.padRight(CMLib.time().date2String(U.last()), 18) + " ");
       head.append("] " + U.name());
       head.append("\n\r");
     }
   }
   mob.tell(head.toString());
   return false;
 }
Ejemplo n.º 12
0
  @Override
  public boolean invoke(MOB mob, Vector commands, Physical givenTarget, boolean auto, int asLevel) {
    Item target = null;
    if ((commands.size() == 0) && (!auto) && (givenTarget == null))
      target = Prayer_Sacrifice.getBody(mob.location());
    if (target == null)
      target = getTarget(mob, mob.location(), givenTarget, commands, Wearable.FILTER_UNWORNONLY);
    if (target == null) return false;

    if ((!(target instanceof DeadBody))
        || (target.rawSecretIdentity().toUpperCase().indexOf("FAKE") >= 0)) {
      mob.tell(L("You may only desecrate the dead."));
      return false;
    }
    if ((((DeadBody) target).isPlayerCorpse())
        && (!((DeadBody) target).getMobName().equals(mob.Name()))
        && (((DeadBody) target).hasContent())) {
      mob.tell(L("You are not allowed to desecrate a players corpse."));
      return false;
    }

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

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

    if (success) {
      final CMMsg msg =
          CMClass.getMsg(
              mob,
              target,
              this,
              verbalCastCode(mob, target, auto),
              auto
                  ? L("<T-NAME> feel(s) desecrated!")
                  : L("^S<S-NAME> desecrate(s) <T-NAMESELF> before @x1.^?", hisHerDiety(mob)));
      if (mob.location().okMessage(mob, msg)) {
        mob.location().send(mob, msg);
        if (CMLib.flags().isEvil(mob)) {
          double exp = 5.0;
          final int levelLimit = CMProps.getIntVar(CMProps.Int.EXPRATE);
          final int levelDiff = (mob.phyStats().level()) - target.phyStats().level();
          if (levelDiff > levelLimit) exp = 0.0;
          if (exp > 0.0)
            CMLib.leveler()
                .postExperience(
                    mob, null, null, (int) Math.round(exp) + super.getXPCOSTLevel(mob), false);
        }
        target.destroy();
        mob.location().recoverRoomStats();
      }
    } else
      beneficialWordsFizzle(
          mob, target, L("<S-NAME> attempt(s) to desecrate <T-NAMESELF>, but fail(s)."));

    // return whether it worked
    return success;
  }
Ejemplo n.º 13
0
 public String[] getStatCodes() {
   if (codes != null) return codes;
   String[] MYCODES = CMProps.getStatCodesList(GenShipContainer.MYCODES, this);
   String[] superCodes = GenericBuilder.GENITEMCODES;
   codes = new String[superCodes.length + MYCODES.length];
   int i = 0;
   for (; i < superCodes.length; i++) codes[i] = superCodes[i];
   for (int x = 0; x < MYCODES.length; i++, x++) codes[i] = MYCODES[x];
   return codes;
 }
Ejemplo n.º 14
0
 @Override
 public String[] getStatCodes() {
   if (codes != null) return codes;
   final String[] MYCODES = CMProps.getStatCodesList(GenThinArmor.MYCODES, this);
   final String[] superCodes = CMParms.toStringArray(GenericBuilder.GenItemCode.values());
   codes = new String[superCodes.length + MYCODES.length];
   int i = 0;
   for (; i < superCodes.length; i++) codes[i] = superCodes[i];
   for (int x = 0; x < MYCODES.length; i++, x++) codes[i] = MYCODES[x];
   return codes;
 }
Ejemplo n.º 15
0
 @Override
 public String[] getStatCodes() {
   if (codes != null) return codes;
   final String[] MYCODES = CMProps.getStatCodesList(GenShopkeeper.MYCODES, this);
   final String[] superCodes = GenericBuilder.GENMOBCODES;
   codes = new String[superCodes.length + MYCODES.length];
   int i = 0;
   for (; i < superCodes.length; i++) codes[i] = superCodes[i];
   for (int x = 0; x < MYCODES.length; i++, x++) codes[i] = MYCODES[x];
   return codes;
 }
Ejemplo n.º 16
0
 @Override
 public void setStat(String code, String val) {
   if (CMLib.coffeeMaker().getGenItemCodeNum(code) >= 0)
     CMLib.coffeeMaker().setGenItemStat(this, code, val);
   else
     switch (getCodeNum(code)) {
       case 0:
         setDoorsNLocks(
             hasADoor(),
             isOpen(),
             defaultsClosed(),
             CMath.s_bool(val),
             false,
             CMath.s_bool(val) && defaultsLocked());
         break;
       case 1:
         setDoorsNLocks(
             CMath.s_bool(val),
             isOpen(),
             CMath.s_bool(val) && defaultsClosed(),
             hasALock(),
             false,
             defaultsLocked());
         break;
       case 2:
         setCapacity(CMath.s_parseIntExpression(val));
         break;
       case 3:
         setContainTypes(CMath.s_parseBitLongExpression(Container.CONTAIN_DESCS, val));
         break;
       case 4:
         setOpenDelayTicks(CMath.s_parseIntExpression(val));
         break;
       case 5:
         setClothingLayer((short) CMath.s_parseIntExpression(val));
         break;
       case 6:
         setLayerAttributes((short) CMath.s_parseListLongExpression(Armor.LAYERMASK_DESCS, val));
         break;
       case 7:
         setDoorsNLocks(
             hasADoor(), isOpen(), CMath.s_bool(val), hasALock(), isLocked(), defaultsLocked());
         break;
       case 8:
         setDoorsNLocks(
             hasADoor(), isOpen(), defaultsClosed(), hasALock(), isLocked(), CMath.s_bool(val));
         break;
       default:
         CMProps.setStatCodeExtensionValue(getStatCodes(), xtraValues, code, val);
         break;
     }
 }
Ejemplo n.º 17
0
 @Override
 public String getStat(String code) {
   if (CMLib.coffeeMaker().getGenItemCodeNum(code) >= 0)
     return CMLib.coffeeMaker().getGenItemStat(this, code);
   switch (getCodeNum(code)) {
     case 0:
       return "" + getClothingLayer();
     case 1:
       return "" + getLayerAttributes();
     default:
       return CMProps.getStatCodeExtensionValue(getStatCodes(), xtraValues, code);
   }
 }
Ejemplo n.º 18
0
 @Override
 public Trap setTrap(MOB mob, Physical P, int trapBonus, int qualifyingClassLevel, boolean perm) {
   if (P == null) return null;
   final Trap T = (Trap) copyOf();
   T.setInvoker(mob);
   P.addEffect(T);
   CMLib.threads()
       .startTickDown(
           T,
           Tickable.TICKID_TRAP_DESTRUCTION,
           CMProps.getIntVar(CMProps.Int.TICKSPERMUDDAY) + (2 * getXLEVELLevel(mob)));
   return T;
 }
Ejemplo n.º 19
0
 public static void doAnimalFreeingCheck(CharClass C, Environmental host, CMMsg msg) {
   if ((msg.source() != host)
       && (msg.sourceMinor() == CMMsg.TYP_NOFOLLOW)
       && (msg.source().isMonster())
       && (host instanceof MOB)
       && (!((MOB) host).isMonster())
       && (msg.target() == host)
       && (msg.source().getStartRoom() != null)
       && (CMLib.law().isACity(msg.source().getStartRoom().getArea()))
       && (((MOB) host).charStats().getCurrentClass().ID().equals(C.ID()))
       && (CMLib.flags().isAnimalIntelligence(msg.source())
           || msg.source().charStats().getMyRace().racialCategory().equalsIgnoreCase("Vegetation")
           || msg.source()
               .charStats()
               .getMyRace()
               .racialCategory()
               .equalsIgnoreCase("Stone Golem"))
       && (CMLib.flags().flaggedAffects(msg.source(), Ability.FLAG_SUMMONING).size() == 0)
       && (msg.source().location() != null)
       && (!msg.source().amDestroyed())
       && (CMLib.flags().isInTheGame((MOB) host, true))
       && (!CMLib.law().isACity(msg.source().location().getArea()))) {
     Object[] stuff = (Object[]) animalChecking.get(host);
     final Room room = msg.source().location();
     if ((stuff == null)
         || (System.currentTimeMillis() - ((Long) stuff[0]).longValue()
             > (room.getArea().getTimeObj().getDaysInMonth()
                 * room.getArea().getTimeObj().getHoursInDay()
                 * CMProps.getMillisPerMudHour()))) {
       stuff = new Object[3];
       stuff[0] = Long.valueOf(System.currentTimeMillis());
       animalChecking.remove(host);
       animalChecking.put(host, stuff);
       stuff[1] = Integer.valueOf(0);
       stuff[2] = new Vector();
     }
     if ((((Integer) stuff[1]).intValue() < 19)
         && (!((List) stuff[2]).contains("" + msg.source()))) {
       stuff[1] = Integer.valueOf(((Integer) stuff[1]).intValue() + 1);
       ((MOB) host)
           .tell(
               CMLib.lang()
                   .L(
                       "You have freed @x1 from @x2.",
                       msg.source().name((MOB) host),
                       (msg.source().getStartRoom().getArea().name())));
       CMLib.leveler()
           .postExperience((MOB) host, null, null, ((Integer) stuff[1]).intValue(), false);
     }
   }
 }
Ejemplo n.º 20
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;
 }
Ejemplo n.º 21
0
 @Override
 public void setStat(String code, String val) {
   if (CMLib.coffeeMaker().getGenItemCodeNum(code) >= 0)
     CMLib.coffeeMaker().setGenItemStat(this, code, val);
   else
     switch (getCodeNum(code)) {
       case 0:
         setClothingLayer((short) CMath.s_parseIntExpression(val));
         break;
       case 1:
         setLayerAttributes((short) CMath.s_parseListLongExpression(Armor.LAYERMASK_DESCS, val));
         break;
       default:
         CMProps.setStatCodeExtensionValue(getStatCodes(), xtraValues, code, val);
         break;
     }
 }
Ejemplo n.º 22
0
 @Override
 public String getStat(String code) {
   if (CMLib.coffeeMaker().getGenMobCodeNum(code) >= 0)
     return CMLib.coffeeMaker().getGenMobStat(this, code);
   switch (getCodeNum(code)) {
     case 0:
       return getClericRequirements();
     case 1:
       return getClericRitual();
     case 2:
       return getWorshipRequirements();
     case 3:
       return getWorshipRitual();
     case 4:
       return getServiceRitual();
     default:
       return CMProps.getStatCodeExtensionValue(getStatCodes(), xtraValues, code);
   }
 }
Ejemplo n.º 23
0
 public String getStat(String code) {
   if (CMLib.coffeeMaker().getGenItemCodeNum(code) >= 0)
     return CMLib.coffeeMaker().getGenItemStat(this, code);
   switch (getCodeNum(code)) {
     case 0:
       return "" + hasALock();
     case 1:
       return "" + hasALid();
     case 2:
       return "" + capacity();
     case 3:
       return "" + containTypes();
     case 4:
       return "" + fuelType();
     case 5:
       return "" + powerCapacity();
     default:
       return CMProps.getStatCodeExtensionValue(getStatCodes(), xtraValues, code);
   }
 }
Ejemplo n.º 24
0
 @Override
 public void setRacialStat(final int abilityCode, final int racialMax) {
   if ((!CharStats.CODES.isBASE(abilityCode)) || (getStat(abilityCode) == VALUE_ALLSTATS_DEFAULT))
     setPermanentStat(abilityCode, racialMax);
   else {
     final int baseMax = CMProps.getIntVar(CMProps.Int.BASEMAXSTAT);
     int currMax = getStat(CharStats.CODES.toMAXBASE(abilityCode)) + baseMax;
     if (currMax <= 0) currMax = 1;
     int curStat = getStat(abilityCode);
     if (curStat > currMax * 7) {
       final String errorMsg =
           "Detected mob with "
               + curStat
               + "/"
               + currMax
               + " "
               + CharStats.CODES.ABBR(abilityCode);
       @SuppressWarnings({"unchecked", "rawtypes"})
       Set<String> errs = (Set) Resources.getResource("SYSTEM_DEFCHARSTATS_ERRORS");
       if (errs == null) {
         errs = new TreeSet<String>();
         Resources.submitResource("SYSTEM_DEFCHARSTATS_ERRORS", errs);
       }
       if (!errs.contains(errorMsg)) {
         errs.add(errorMsg);
         final StringBuilder str = new StringBuilder(errorMsg);
         // ByteArrayOutputStream stream=new ByteArrayOutputStream();
         // new Exception().printStackTrace(new PrintStream(stream));
         // str.append("\n\r"+new String(stream.toByteArray()));
         Log.errOut("DefCharStats", str.toString());
       }
       curStat = currMax * 7;
     }
     final int pctOfMax = Math.round(((float) curStat / (float) currMax) * racialMax);
     final int stdMaxAdj =
         Math.round((((float) (currMax - VALUE_ALLSTATS_DEFAULT)) / (float) currMax) * racialMax);
     final int racialStat = pctOfMax + stdMaxAdj;
     setStat(abilityCode, ((racialStat < 1) && (racialMax > 0)) ? 1 : racialStat);
     setStat(CharStats.CODES.toMAXBASE(abilityCode), racialMax - baseMax);
   }
 }
Ejemplo n.º 25
0
 @Override
 public void setStat(String code, String val) {
   if (CMLib.coffeeMaker().getGenMobCodeNum(code) >= 0)
     CMLib.coffeeMaker().setGenMobStat(this, code, val);
   else
     switch (getCodeNum(code)) {
       case 0:
         {
           if ((val.length() == 0) || (CMath.isLong(val))) setWhatIsSoldMask(CMath.s_long(val));
           else if (CMParms.containsIgnoreCase(ShopKeeper.DEAL_DESCS, val))
             setWhatIsSoldMask(CMParms.indexOfIgnoreCase(ShopKeeper.DEAL_DESCS, val));
           break;
         }
       case 1:
         setPrejudiceFactors(val);
         break;
       case 2:
         setBudget(val);
         break;
       case 3:
         setDevalueRate(val);
         break;
       case 4:
         setInvResetRate(CMath.s_parseIntExpression(val));
         break;
       case 5:
         setIgnoreMask(val);
         break;
       case 6:
         setItemPricingAdjustments(
             (val.trim().length() == 0)
                 ? new String[0]
                 : CMParms.toStringArray(CMParms.parseCommas(val, true)));
         break;
       default:
         CMProps.setStatCodeExtensionValue(getStatCodes(), xtraValues, code, val);
         break;
     }
 }
Ejemplo n.º 26
0
 // update lot, since its called by the savethread, ONLY worries about itself
 @Override
 public void updateLot(List optPlayerList) {
   if (affected instanceof Room) {
     Room R = (Room) affected;
     synchronized (("SYNC" + R.roomID()).intern()) {
       R = CMLib.map().getRoom(R);
       lastItemNums =
           updateLotWithThisData(R, this, false, scheduleReset, optPlayerList, lastItemNums);
       if ((lastDayDone != R.getArea().getTimeObj().getDayOfMonth())
           && (CMProps.getBoolVar(CMProps.Bool.MUDSTARTED))) {
         lastDayDone = R.getArea().getTimeObj().getDayOfMonth();
         if ((getOwnerName().length() > 0) && rentalProperty() && (R.roomID().length() > 0))
           if (doRentalProperty(R.getArea(), R.roomID(), getOwnerName(), getPrice())) {
             setOwnerName("");
             CMLib.database().DBUpdateRoom(R);
             lastItemNums =
                 updateLotWithThisData(R, this, false, scheduleReset, optPlayerList, lastItemNums);
           }
       }
       scheduleReset = false;
     }
   }
 }
Ejemplo n.º 27
0
 @Override
 public String getStat(String code) {
   if (CMLib.coffeeMaker().getGenMobCodeNum(code) >= 0)
     return CMLib.coffeeMaker().getGenMobStat(this, code);
   switch (getCodeNum(code)) {
     case 0:
       return "" + getWhatIsSoldMask();
     case 1:
       return prejudiceFactors();
     case 2:
       return budget();
     case 3:
       return devalueRate();
     case 4:
       return "" + invResetRate();
     case 5:
       return ignoreMask();
     case 6:
       return CMParms.toStringList(itemPricingAdjustments());
     default:
       return CMProps.getStatCodeExtensionValue(getStatCodes(), xtraValues, code);
   }
 }
Ejemplo n.º 28
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;
  }
Ejemplo n.º 29
0
 @Override
 protected int DISEASE_DELAY() {
   return (int) (CMProps.getMillisPerMudHour() / CMProps.getTickMillis());
 }
Ejemplo n.º 30
0
  @Override
  public boolean execute(MOB mob, Vector commands, int metaFlags) throws java.io.IOException {
    final Room R = mob.location();
    boolean quiet = false;
    if ((commands != null)
        && (commands.size() > 1)
        && (((String) commands.lastElement()).equalsIgnoreCase("UNOBTRUSIVELY"))) {
      commands.remove(commands.size() - 1);
      quiet = true;
    }
    final String textMsg = "<S-NAME> look(s) ";
    if (R == null) return false;
    if ((commands != null) && (commands.size() > 1)) {
      Environmental thisThang = null;

      if ((commands.size() > 2) && (((String) commands.get(1)).equalsIgnoreCase("at")))
        commands.remove(1);
      else if ((commands.size() > 2) && (((String) commands.get(1)).equalsIgnoreCase("to")))
        commands.remove(1);
      final String ID = CMParms.combine(commands, 1);

      if ((ID.toUpperCase().startsWith("EXIT") && (commands.size() == 2))
          && (CMProps.getIntVar(CMProps.Int.EXVIEW) != 1)) {
        final CMMsg exitMsg = CMClass.getMsg(mob, R, null, CMMsg.MSG_LOOK_EXITS, null);
        if ((CMProps.getIntVar(CMProps.Int.EXVIEW) >= 2) != mob.isAttribute(MOB.Attrib.BRIEF))
          exitMsg.setValue(CMMsg.MASK_OPTIMIZE);
        if (R.okMessage(mob, exitMsg)) R.send(mob, exitMsg);
        return false;
      }
      if (ID.equalsIgnoreCase("SELF") || ID.equalsIgnoreCase("ME")) thisThang = mob;

      if (thisThang == null) thisThang = R.fetchFromMOBRoomFavorsItems(mob, null, ID, noCoinFilter);
      if (thisThang == null)
        thisThang = R.fetchFromMOBRoomFavorsItems(mob, null, ID, Wearable.FILTER_ANY);
      if ((thisThang == null)
          && (commands.size() > 2)
          && (((String) commands.get(1)).equalsIgnoreCase("in"))) {
        commands.remove(1);
        final String ID2 = CMParms.combine(commands, 1);
        thisThang = R.fetchFromMOBRoomFavorsItems(mob, null, ID2, Wearable.FILTER_ANY);
        if ((thisThang != null)
            && ((!(thisThang instanceof Container)) || (((Container) thisThang).capacity() == 0))) {
          mob.tell(L("That's not a container."));
          return false;
        }
      }
      int dirCode = -1;
      Environmental lookingTool = null;
      if (thisThang == null) {
        dirCode = Directions.getGoodDirectionCode(ID);
        if (dirCode >= 0) {
          final Room room = R.getRoomInDir(dirCode);
          final Exit exit = R.getExitInDir(dirCode);
          if ((room != null) && (exit != null)) {
            thisThang = exit;
            lookingTool = room;
          } else {
            mob.tell(L("You don't see anything that way."));
            return false;
          }
        }
      }
      if (thisThang != null) {
        String name = "at <T-NAMESELF>";
        if ((thisThang instanceof Room) || (thisThang instanceof Exit)) {
          if (thisThang == R) name = "around";
          else if (dirCode >= 0)
            name =
                ((R instanceof BoardableShip) || (R.getArea() instanceof BoardableShip))
                    ? Directions.getShipDirectionName(dirCode)
                    : Directions.getDirectionName(dirCode);
        }
        final CMMsg msg =
            CMClass.getMsg(mob, thisThang, lookingTool, CMMsg.MSG_LOOK, textMsg + name + ".");
        if ((thisThang instanceof Room)
            && (mob.isAttribute(MOB.Attrib.AUTOEXITS))
            && (CMProps.getIntVar(CMProps.Int.EXVIEW) != 1)) {
          final CMMsg exitMsg =
              CMClass.getMsg(mob, thisThang, lookingTool, CMMsg.MSG_LOOK_EXITS, null);
          if ((CMProps.getIntVar(CMProps.Int.EXVIEW) >= 2) != mob.isAttribute(MOB.Attrib.BRIEF))
            exitMsg.setValue(CMMsg.MASK_OPTIMIZE);
          msg.addTrailerMsg(exitMsg);
        }
        if (R.okMessage(mob, msg)) R.send(mob, msg);
      } else mob.tell(L("You don't see that here!"));
    } else {
      if ((commands != null) && (commands.size() > 0))
        if (((String) commands.get(0)).toUpperCase().startsWith("E")) {
          mob.tell(L("Examine what?"));
          return false;
        }

      final CMMsg msg =
          CMClass.getMsg(
              mob,
              R,
              null,
              CMMsg.MSG_LOOK,
              (quiet ? null : textMsg + "around."),
              CMMsg.MSG_LOOK,
              (quiet ? null : textMsg + "at you."),
              CMMsg.MSG_LOOK,
              (quiet ? null : textMsg + "around."));
      if ((mob.isAttribute(MOB.Attrib.AUTOEXITS))
          && (CMProps.getIntVar(CMProps.Int.EXVIEW) != 1)
          && (CMLib.flags().canBeSeenBy(R, mob))) {
        final CMMsg exitMsg = CMClass.getMsg(mob, R, null, CMMsg.MSG_LOOK_EXITS, null);
        if ((CMProps.getIntVar(CMProps.Int.EXVIEW) >= 2) != mob.isAttribute(MOB.Attrib.BRIEF))
          exitMsg.setValue(CMMsg.MASK_OPTIMIZE);
        msg.addTrailerMsg(exitMsg);
      }
      if (R.okMessage(mob, msg)) R.send(mob, msg);
    }
    return false;
  }