Exemplo n.º 1
0
  @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;
  }
Exemplo n.º 2
0
 public List<Object> convertToV2(List<Ability> spellsV, Physical target) {
   final List<Object> VTOO = new Vector<Object>();
   for (int v = 0; v < spellsV.size(); v++) {
     Ability A = spellsV.get(v);
     final Ability EA = (target != null) ? target.fetchEffect(A.ID()) : null;
     if ((EA == null) && (didHappen())) {
       final String t = A.text();
       A = (Ability) A.copyOf();
       Vector<String> V2 = new Vector<String>();
       if (t.length() > 0) {
         final int x = t.indexOf('/');
         if (x < 0) {
           V2 = CMParms.parse(t);
           A.setMiscText("");
         } else {
           V2 = CMParms.parse(t.substring(0, x));
           A.setMiscText(t.substring(x + 1));
         }
       }
       VTOO.add(A);
       VTOO.add(V2);
     }
   }
   return VTOO;
 }
Exemplo n.º 3
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;
  }
Exemplo n.º 4
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;
 }
Exemplo n.º 5
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);
       }
     }
   }
 }
Exemplo n.º 6
0
 @Override
 public boolean execute(MOB mob, Vector commands, int metaFlags) throws java.io.IOException {
   final StringBuilder msg = new StringBuilder("");
   final Vector V = new Vector();
   V.add(Integer.valueOf(Ability.ACODE_THIEF_SKILL));
   V.add(Integer.valueOf(Ability.ACODE_SKILL));
   V.add(Integer.valueOf(Ability.ACODE_COMMON_SKILL));
   final String qual = CMParms.combine(commands, 1).toUpperCase();
   if (parsedOutIndividualSkill(mob, qual, V)) return true;
   final int[] level = new int[1];
   final int[] domain = new int[1];
   final String[] domainName = new String[1];
   domainName[0] = "";
   level[0] = -1;
   parseDomainInfo(mob, commands, V, level, domain, domainName);
   int mask = Ability.ALL_ACODES;
   if (domain[0] >= 0) {
     mask = mask | Ability.ALL_DOMAINS;
     for (int v = 0; v < V.size(); v++)
       V.setElementAt(Integer.valueOf(((Integer) V.get(v)).intValue() + domain[0]), v);
   }
   if ((domain[0] >= 0) || (qual.length() == 0))
     msg.append(
         L(
             "\n\r^HYour @x1skills:^? @x2",
             domainName[0].replace('_', ' '),
             getAbilities(mob, mob, V, mask, true, level[0]).toString()));
   if (!mob.isMonster()) mob.session().wraplessPrintln(msg.toString());
   return false;
 }
Exemplo n.º 7
0
 public void setMiscText(String text) {
   super.setMiscText(text);
   if (!(affected instanceof MOB)) {
     Vector parms = CMParms.parse(text.toUpperCase());
     unLocatable = parms.contains("UNLOCATABLE");
   }
 }
Exemplo n.º 8
0
  @Override
  public boolean tick(Tickable ticking, int tickID) {

    if (!super.tick(ticking, tickID)) return false;
    if (affected == null) return false;
    if (!(affected instanceof MOB)) return 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;
  }
Exemplo n.º 9
0
  public boolean execute(MOB mob, Vector commands, int metaFlags) throws java.io.IOException {
    if ((mob == null) || (mob.playerStats() == null)) return false;

    if (commands.size() < 2) {
      String pageBreak =
          (mob.playerStats().getPageBreak() != 0)
              ? ("" + mob.playerStats().getPageBreak())
              : "Disabled";
      mob.tell(
          "Change your page break to what? Your current page break setting is: "
              + pageBreak
              + ". Enter a number larger than 0 or 'disable'.");
      return false;
    }
    String newBreak = CMParms.combine(commands, 1);
    int newVal = mob.playerStats().getWrap();
    if ((CMath.isInteger(newBreak)) && (CMath.s_int(newBreak) > 0)) newVal = CMath.s_int(newBreak);
    else if ("DISABLED".startsWith(newBreak.toUpperCase())) newVal = 0;
    else {
      mob.tell(
          "'" + newBreak + "' is not a valid setting. Enter a number larger than 0 or 'disable'.");
      return false;
    }
    mob.playerStats().setPageBreak(newVal);
    String pageBreak =
        (mob.playerStats().getPageBreak() != 0)
            ? ("" + mob.playerStats().getPageBreak())
            : "Disabled";
    mob.tell("Your new page break setting is: " + pageBreak + ".");
    return false;
  }
Exemplo n.º 10
0
 @Override
 public boolean invoke(
     MOB mob, List<String> commands, Physical givenTarget, boolean auto, int asLevel) {
   final String s = CMParms.combine(commands, 0);
   if (s.length() > 0) setMiscText(s);
   if (givenTarget != null) addMeIfNeccessary(mob, givenTarget, false, asLevel, maxTicks);
   return true;
 }
Exemplo n.º 11
0
 @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);
 }
Exemplo n.º 12
0
 @Override
 public String[] getStatCodes() {
   if (codes == null)
     codes =
         CMProps.getStatCodesList(
             CMParms.toStringArray(GenericBuilder.GenItemCode.values()), this);
   return codes;
 }
Exemplo n.º 13
0
 @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));
 }
Exemplo n.º 14
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();
 }
Exemplo n.º 15
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);
     }
   }
 }
Exemplo n.º 16
0
  public List<Ability> getMySpellsV() {
    if (spellV != null) return spellV;
    spellV = new Vector<Ability>();
    final String names = getParmString(text());
    final List<String> set = CMParms.parseSemicolons(names, true);
    String thisOne = null;
    for (int s = 0; s < set.size(); s++) {
      thisOne = set.get(s);
      if (thisOne.equalsIgnoreCase("NOUNINVOKE")) {
        this.uninvocable = false;
        continue;
      }
      if (thisOne.toUpperCase().startsWith("LEVEL")) {
        level = (short) CMParms.getParmInt(thisOne, "LEVEL", -1);
        if (level >= 0) continue;
      }
      if (thisOne.toUpperCase().startsWith("MAXTICKS")) {
        maxTicks = (short) CMParms.getParmInt(thisOne, "MAXTICKS", -1);
        if (maxTicks != -1) continue;
      }
      final int pctDex = thisOne.indexOf("% ");
      if ((pctDex > 0) && (thisOne.substring(pctDex + 1).trim().length() > 0))
        thisOne = thisOne.substring(pctDex + 1).trim();
      String parm = "";
      if ((thisOne != null) && (thisOne.endsWith(")"))) {
        final int x = thisOne.indexOf('(');
        if (x > 0) {
          parm = thisOne.substring(x + 1, thisOne.length() - 1);
          thisOne = thisOne.substring(0, x).trim();
        }
      }

      Ability A = CMClass.getAbility(thisOne);
      if ((A != null)
          && ((A.classificationCode() & Ability.ALL_DOMAINS) != Ability.DOMAIN_ARCHON)) {
        A = (Ability) A.copyOf();
        A.setMiscText(parm);
        spellV.add(A);
      }
    }
    return spellV;
  }
Exemplo n.º 17
0
  @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;
  }
Exemplo n.º 18
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;
 }
Exemplo n.º 19
0
  @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;
  }
Exemplo n.º 20
0
 @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);
   }
 }
Exemplo n.º 21
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;
 }
Exemplo n.º 22
0
 @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;
       }
     }
 }
Exemplo n.º 23
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);
 }
Exemplo n.º 24
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));
   }
 }
Exemplo 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;
     }
 }
Exemplo n.º 26
0
 @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;
     }
   }
 }
Exemplo n.º 27
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;
  }
Exemplo n.º 29
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;
           }
         }
       }
     }
   }
 }
Exemplo n.º 30
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;
  }