@Override
  public boolean tick(Tickable ticking, int tickID) {
    if (!super.tick(ticking, tickID)) return false;
    if ((tickID == Tickable.TICKID_MOB) && (affected instanceof MOB)) {
      final MOB mob = (MOB) affected;
      if (!DATA.containsKey(mob)) DATA.put(mob, new int[DATA_TOTAL]);
      final int[] data = DATA.get(mob);
      if ((mob.session() != null) && (mob.session().getPreviousCMD() != null)) {
        if ((lastCommand != null)
            && (!CMParms.combine(mob.session().getPreviousCMD(), 0).equals(lastCommand))) {
          data[DATA_TYPEDCOMMAND]++;
          List<MOB> V = null;
          if (mob.session().getAddress() != null) V = IPS.get(mob.session().getAddress());

          if (V != null)
            for (int v = 0; v < V.size(); v++) {
              final MOB M = V.get(v);
              if (M == mob) continue;
              if (M.session() == null) continue;
              if (!CMLib.flags().isInTheGame(M, true)) continue;
              final String hisLastCmd = CMParms.combine(mob.session().getPreviousCMD(), 0);
              final Archon_Multiwatch A = (Archon_Multiwatch) M.fetchEffect(ID());
              if (A != null) {
                if ((A.lastCommand != null) && (!A.lastCommand.equals(hisLastCmd)))
                  data[DATA_SYNCHROFOUND]++;
                break;
              }
            }
        }
        lastCommand = CMParms.combine(mob.session().getPreviousCMD(), 0);
      }
    }
    return true;
  }
Beispiel #2
0
  @Override
  public boolean execute(MOB mob, Vector commands, int metaFlags) throws java.io.IOException {
    if (!(CMLib.intermud().imc2online())) {
      mob.tell(L("IMC2 is unavailable."));
      return false;
    }
    commands.remove(0);
    if (commands.size() < 1) {
      IMC2Error(mob);
      return false;
    }
    final String str = (String) commands.get(0);
    if (!(CMLib.intermud().imc2online())) mob.tell(L("IMC2 is unavailable."));
    else if (str.equalsIgnoreCase("list")) CMLib.intermud().giveIMC2MudList(mob);
    else if (str.equalsIgnoreCase("locate"))
      CMLib.intermud().i3locate(mob, CMParms.combine(commands, 1));
    else if (str.equalsIgnoreCase("channels")
        && CMSecurity.isAllowed(mob, mob.location(), CMSecurity.SecFlag.IMC2))
      CMLib.intermud().giveIMC2ChannelsList(mob);
    else if (str.equalsIgnoreCase("info"))
      CMLib.intermud().imc2mudInfo(mob, CMParms.combine(commands, 1));
    else if (str.equalsIgnoreCase("restart")
        && CMSecurity.isAllowed(mob, mob.location(), CMSecurity.SecFlag.IMC2)) {
      try {
        mob.tell(CMLib.hosts().get(0).executeCommand("START IMC2"));
      } catch (final Exception e) {
        Log.errOut("IMC2Cmd", e);
      }
    } else IMC2Error(mob);

    return false;
  }
Beispiel #3
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;
 }
Beispiel #4
0
 private void clearAbilityFromSpellcraftList(MOB mob, Ability A) {
   final Ability enabledA = mob.fetchAbility("Skill_Spellcraft");
   if (enabledA != null) {
     final List<String> ables = CMParms.parseCommas(enabledA.text(), true);
     if (ables.contains(A.ID())) {
       if (!CMSecurity.isAllowed(mob, mob.location(), CMSecurity.SecFlag.ALLSKILLS)) {
         ables.remove(A.ID());
         enabledA.setMiscText(CMParms.toListString(ables));
         mob.delAbility(A);
       }
     }
   }
 }
  @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 true;

    final MOB mob = (MOB) affected;
    if ((!mob.amDead()) && ((--diseaseTick) <= 0)) {
      diseaseTick = DISEASE_DELAY();
      if (mob.maxState().getFatigue() > Long.MIN_VALUE / 2)
        mob.curState()
            .adjFatigue(mob.curState().getFatigue() + CharState.FATIGUED_MILLIS, mob.maxState());
      mob.location().show(mob, null, CMMsg.MSG_NOISE, DISEASE_AFFECT());
      if (!CMLib.flags().isSleeping(mob)) {
        final Command C = CMClass.getCommand("Sleep");
        try {
          if (C != null) C.execute(mob, CMParms.parse("Sleep"), Command.METAFLAG_FORCED);
        } catch (final Exception e) {
        }
      }
      return true;
    }
    return true;
  }
 @Override
 public String[] getStatCodes() {
   if (codes == null)
     codes =
         CMProps.getStatCodesList(
             CMParms.toStringArray(GenericBuilder.GenItemCode.values()), this);
   return codes;
 }
 @Override
 public void setMiscText(String newMiscText) {
   super.setMiscText(newMiscText);
   final String maskStr = CMParms.getParmStr(newMiscText, "mask", "");
   mask = null;
   if ((maskStr != null) && (maskStr.trim().length() > 0))
     mask = CMLib.masking().getPreCompiledMask(maskStr);
 }
 @Override
 public int backTaxes() {
   final int dex = text().indexOf('/');
   if (dex < 0) return 0;
   final int x = text().indexOf("TAX", dex);
   if (x < 0) return 0;
   final String s = CMParms.parse(text().substring(x + 3)).firstElement();
   return CMath.s_int(s.substring(0, s.length() - 1));
 }
Beispiel #9
0
 @Override
 public void setMiscText(String newMiscText) {
   super.setMiscText(newMiscText);
   if ((newMiscText != null) && (newMiscText.length() > 0)) {
     for (final String parm : CMParms.parse(newMiscText.toUpperCase())) {
       if (parm.equals("REVERSED")) this.setProficiency(100);
       else if (parm.equals("NORMAL")) this.setProficiency(0);
     }
   }
 }
Beispiel #10
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();
 }
 @Override
 public void setBodyPartsFromStringAfterRace(String str) {
   final List<String> V = CMParms.parseSemicolons(str, true);
   bodyAlterations = null;
   for (int i = 0; i < getMyRace().bodyMask().length; i++) {
     if (V.size() <= i) break;
     final int val = CMath.s_int(V.get(i));
     final int num = getMyRace().bodyMask()[i];
     if (num != val) alterBodypart(i, val - num);
   }
 }
Beispiel #12
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;
 }
  @Override
  public String getStat(String abilityName) {
    final int dex = CMParms.indexOfIgnoreCase(getStatCodes(), abilityName);
    if (dex >= 0) return Integer.toString(getStat(dex));

    final String[] DESCS = CODES.DESCS();
    for (final int i : CharStats.CODES.ALLCODES()) {
      if (DESCS[i].startsWith(abilityName)) return Integer.toString(getStat(i));
    }
    return null;
  }
  @Override
  public boolean invoke(
      MOB mob, List<String> commands, Physical givenTarget, boolean auto, int asLevel) {
    MOB target = CMLib.players().getLoadPlayer(CMParms.combine(commands, 0));
    if (target == null) target = getTargetAnywhere(mob, commands, givenTarget, false, true, false);
    if (target == null) return false;

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

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

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

    if (success) {
      final CMMsg msg =
          CMClass.getMsg(
              mob,
              target,
              this,
              CMMsg.MASK_MOVE | CMMsg.TYP_JUSTICE | (auto ? CMMsg.MASK_ALWAYS : 0),
              L("^F<S-NAME> begin(s) recording <T-NAMESELF>.^?"));
      CMLib.color().fixSourceFightColor(msg);
      if (mob.location().okMessage(mob, msg)) {
        mob.location().send(mob, msg);
        final String filename = "/" + target.Name() + System.currentTimeMillis() + ".log";
        final CMFile file = new CMFile(filename, null, CMFile.FLAG_LOGERRORS);
        if (!file.canWrite()) {
          if (!CMSecurity.isASysOp(mob) || (CMSecurity.isASysOp(target)))
            Log.sysOut("Record", mob.Name() + " failed to start recording " + target.name() + ".");
        } else {
          if (!CMSecurity.isASysOp(mob) || (CMSecurity.isASysOp(target)))
            Log.sysOut(
                "Record",
                mob.Name() + " started recording " + target.name() + " to /" + filename + ".");
          final Archon_Record A2 = (Archon_Record) copyOf();
          final Session F = (Session) CMClass.getCommon("FakeSession");
          F.initializeSession(null, Thread.currentThread().getThreadGroup().getName(), filename);
          if (target.session() == null) target.setSession(F);
          A2.sess = F;
          target.addNonUninvokableEffect(A2);
          mob.tell(L("Enter RECORD @x1 again to stop recording.", target.Name()));
        }
      }
    } else
      return beneficialVisualFizzle(
          mob, target, L("<S-NAME> attempt(s) to hush <T-NAMESELF>, but fail(s)."));
    return success;
  }
 @Override
 public void setStat(String code, String val) {
   final int dex = CMParms.indexOfIgnoreCase(getStatCodes(), code);
   if (dex >= 0) setStat(dex, CMath.s_parseIntExpression(val));
   else
     for (final int i : CharStats.CODES.ALLCODES()) {
       if (CODES.DESC(i).startsWith(code)) {
         setStat(dex, CMath.s_parseIntExpression(val));
         return;
       }
     }
 }
Beispiel #16
0
 @Override
 public boolean execute(MOB mob, Vector commands, int metaFlags) throws java.io.IOException {
   if ((commands.size() == 1) && (commands.get(0) instanceof MOB)) {
     commands.add(getInventory((MOB) commands.get(0), mob, null));
     return true;
   }
   final StringBuilder msg = getInventory(mob, mob, CMParms.combine(commands, 1));
   if (msg.length() == 0) mob.tell(L("^HYou are carrying:\n\r^!Nothing!^?\n\r"));
   else if (!mob.isMonster())
     mob.session().wraplessPrintln(L("^HYou are carrying:^?\n\r@x1", msg.toString()));
   return false;
 }
Beispiel #17
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;
     }
 }
Beispiel #18
0
 @Override
 public void setMiscText(String txt) {
   noFollow = false;
   noSneak = false;
   final Vector<String> parms = CMParms.parse(txt.toUpperCase());
   String s;
   for (final Enumeration<String> p = parms.elements(); p.hasMoreElements(); ) {
     s = p.nextElement();
     if ("NOFOLLOW".startsWith(s)) noFollow = true;
     else if (s.startsWith("NOSNEAK")) noSneak = true;
   }
   super.setMiscText(txt);
 }
Beispiel #19
0
 private void addAbilityToSpellcraftList(MOB mob, Ability A) {
   final Ability enabledA = mob.fetchAbility("Skill_Spellcraft");
   if (enabledA != null) {
     final List<String> ables = CMParms.parseCommas(enabledA.text(), true);
     if (!ables.contains(A.ID())) {
       if (enabledA.text().length() == 0) enabledA.setMiscText(A.ID());
       else enabledA.setMiscText(enabledA.text() + ", " + A.ID());
       mob.addAbility(A);
     } else if (mob.isMine(A) && (A.proficiency() < 75) && (!A.isSavable()))
       A.setProficiency(
           A.proficiency() + (mob.baseCharStats().getStat(CharStats.STAT_INTELLIGENCE) / 3));
   }
 }
 @Override
 public void setNonBaseStatsFromString(String str) {
   final List<String> V = CMParms.parseSemicolons(str, false);
   final CharStats.CODES C = CharStats.CODES.instance();
   for (final int x : C.all()) {
     if ((!C.isBase(x)) && (x != CharStats.STAT_GENDER) && (V.size() > 0)) {
       final long val = CMath.s_long(V.remove(0));
       if ((val > Short.MAX_VALUE) || (val < Short.MIN_VALUE))
         Log.errOut(
             "Value out of range", "Value out of range: " + val + " for " + x + " from " + str);
       stats[x] = (short) val;
     }
   }
 }
Beispiel #21
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);
  }
  @Override
  public boolean invoke(
      MOB mob, List<String> commands, Physical givenTarget, boolean auto, int asLevel) {
    Physical target = null;
    if (commands.size() > 0) {
      final String s = CMParms.combine(commands, 0);
      if (s.equalsIgnoreCase("room")) target = mob.location();
      else if (s.equalsIgnoreCase("here")) target = mob.location();
      else if (CMLib.english().containsString(mob.location().ID(), s)
          || CMLib.english().containsString(mob.location().name(), s)
          || CMLib.english().containsString(mob.location().displayText(), s))
        target = mob.location();
    }
    if (target == null) target = getTarget(mob, commands, givenTarget);
    if (target == null) return false;
    if ((target instanceof Room) && (target.fetchEffect(ID()) != null)) {
      mob.tell(L("This place is already under a teleportation ward."));
      return false;
    }

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

    final boolean success = proficiencyCheck(mob, 0, auto);
    if (success) {
      final CMMsg msg =
          CMClass.getMsg(
              mob,
              target,
              this,
              verbalCastCode(mob, target, auto),
              auto
                  ? L("<T-NAME> seem(s) magically protected.")
                  : L("^S<S-NAME> invoke(s) a teleportation ward upon <T-NAMESELF>.^?"));
      if (mob.location().okMessage(mob, msg)) {
        mob.location().send(mob, msg);
        if ((target instanceof Room) && (CMLib.law().doesOwnThisLand(mob, ((Room) target)))) {
          target.addNonUninvokableEffect((Ability) this.copyOf());
          CMLib.database().DBUpdateRoom((Room) target);
        } else beneficialAffect(mob, target, asLevel, 0);
      }
    } else
      beneficialWordsFizzle(
          mob, target, L("<S-NAME> attempt(s) to invoke a teleportation ward, but fail(s)."));

    return success;
  }
Beispiel #23
0
 public static void waveIfAble(MOB mob, Physical afftarget, String message, Wand me) {
   if ((mob.isMine(me)) && (message != null) && (!me.amWearingAt(Wearable.IN_INVENTORY))) {
     Physical target = null;
     if (mob.location() != null) target = afftarget;
     final int x = message.toUpperCase().indexOf(me.magicWord().toUpperCase());
     if (x >= 0) {
       message = message.substring(x + me.magicWord().length());
       final int y = message.indexOf('\'');
       if (y >= 0) message = message.substring(0, y);
       message = message.trim();
       final Ability wandUse = mob.fetchAbility("Skill_WandUse");
       if ((wandUse == null) || (!wandUse.proficiencyCheck(null, 0, false)))
         mob.tell(CMLib.lang().L("@x1 glows faintly for a moment, then fades.", me.name()));
       else {
         Ability A = me.getSpell();
         if (A == null) mob.tell(CMLib.lang().L("Something seems wrong with @x1.", me.name()));
         else if (me.usesRemaining() <= 0) mob.tell(CMLib.lang().L("@x1 seems spent.", me.name()));
         else {
           wandUse.setInvoker(mob);
           A = (Ability) A.newInstance();
           if (useTheWand(A, mob, wandUse.abilityCode())) {
             final Vector V = new Vector();
             if (target != null) V.addElement(target.name());
             V.addAll(CMParms.parse(message));
             mob.location()
                 .show(
                     mob,
                     null,
                     CMMsg.MSG_OK_VISUAL,
                     CMLib.lang().L("@x1 glows brightly.", me.name()));
             me.setUsesRemaining(me.usesRemaining() - 1);
             int level = me.phyStats().level();
             final int lowest = CMLib.ableMapper().lowestQualifyingLevel(A.ID());
             if (level < lowest) level = lowest;
             A.invoke(mob, V, target, true, level);
             wandUse.helpProficiency(mob, 0);
             return;
           }
         }
       }
     }
   }
 }
Beispiel #24
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;
  }
Beispiel #25
0
 @Override
 public boolean execute(MOB mob, List<String> commands, int metaFlags) throws java.io.IOException {
   String parm = (commands.size() > 1) ? CMParms.combine(commands, 1) : "";
   if ((mob.isAttributeSet(MOB.Attrib.AUTOASSIST) && (parm.length() == 0))
       || (parm.equalsIgnoreCase("ON"))) {
     mob.setAttribute(MOB.Attrib.AUTOASSIST, false);
     mob.tell(L("Autoassist has been turned on."));
   } else if ((!mob.isAttributeSet(MOB.Attrib.AUTOASSIST) && (parm.length() == 0))
       || (parm.equalsIgnoreCase("OFF"))) {
     mob.setAttribute(MOB.Attrib.AUTOASSIST, true);
     mob.tell(L("Autoassist has been turned off."));
   } else if (parm.length() > 0) {
     mob.tell(
         L(
             "Illegal @x1 argument: '@x2'.  Try ON or OFF, or nothing to toggle.",
             getAccessWords()[0],
             parm));
   }
   return false;
 }
  @Override
  public boolean tick(Tickable ticking, int tickID) {
    if (!(affected instanceof MOB)) return super.tick(ticking, tickID);

    if (!super.tick(ticking, tickID)) return false;
    if ((--plagueDown) <= 0) {
      final MOB mob = (MOB) affected;
      plagueDown = 10;
      if (invoker == null) invoker = mob;
      drawups += .1;
      if (drawups >= 3.1) {
        if ((mob.location() != null) && (CMLib.flags().isInTheGame(mob, false))) {
          mob.location().show(mob, null, CMMsg.MSG_OK_VISUAL, L("<S-YOU-POSS> feet rot off!"));
          final Ability A = CMClass.getAbility("Amputation");
          if (A != null) {
            int x = 100;
            while (((--x) > 0) && A.invoke(mob, CMParms.parse("foot"), mob, true, 0)) {
              /*do nothing */
            }
            mob.recoverCharStats();
            mob.recoverPhyStats();
            mob.recoverMaxState();
          }
          unInvoke();
        }
      } else {
        final MOB invoker = (invoker() != null) ? invoker() : mob;
        CMLib.combat()
            .postDamage(
                invoker,
                mob,
                this,
                1,
                CMMsg.TYP_DISEASE,
                -1,
                L(
                    "<T-NAME> feel(s) the fungus between <T-HIS-HER> toes eating <T-HIS-HER> feet away!"));
      }
    }
    return true;
  }
Beispiel #27
0
  @Override
  public boolean execute(MOB mob, Vector commands, int metaFlags) throws java.io.IOException {
    final String whatToOpen = CMParms.combine(commands, 1);
    if (whatToOpen.length() == 0) {
      mob.tell(L("Open what?"));
      return false;
    }
    Environmental openThis = null;
    final int dirCode = Directions.getGoodDirectionCode(whatToOpen);
    if (dirCode >= 0) openThis = mob.location().getExitInDir(dirCode);
    if (openThis == null)
      openThis =
          mob.location().fetchFromMOBRoomItemExit(mob, null, whatToOpen, Wearable.FILTER_ANY);

    if ((openThis == null) || (!CMLib.flags().canBeSeenBy(openThis, mob))) {
      mob.tell(L("You don't see '@x1' here.", whatToOpen));
      return false;
    }
    open(mob, openThis, whatToOpen, dirCode, false);
    return false;
  }
Beispiel #28
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);
   }
 }
  @Override
  public boolean invoke(
      MOB mob, List<String> commands, Physical givenTarget, boolean auto, int asLevel) {

    if (commands.size() < 2) {
      mob.tell(L("You must specify what to cast this on, and then what you want it to emote."));
      return false;
    }
    final Vector<String> V = new Vector<String>();
    V.addElement(commands.get(0));
    final Item target = getTarget(mob, mob.location(), givenTarget, V, Wearable.FILTER_ANY);
    if (target == null) return false;

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

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

    if (success) {
      final CMMsg msg = CMClass.getMsg(mob, target, this, verbalCastCode(mob, target, auto), null);
      if (mob.location().okMessage(mob, msg)) {
        mob.location().send(mob, msg);
        mob.location()
            .show(
                mob, target, CMMsg.MSG_OK_ACTION, L("<T-NAME> @x1.", CMParms.combine(commands, 1)));
      }
    } else
      mob.location()
          .show(
              mob,
              target,
              CMMsg.MSG_OK_ACTION,
              L("<T-NAME> twitch(es) oddly, but does nothing more."));

    // return whether it worked
    return success;
  }
Beispiel #30
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;
  }