public void removeMyAffectsFrom(Physical P) {
    if (P == null) return;

    int x = 0;
    final Vector<Ability> eff = new Vector<Ability>();
    Ability thisAffect = null;
    for (x = 0; x < P.numEffects(); x++) // personal
    {
      thisAffect = P.fetchEffect(x);
      if (thisAffect != null) eff.addElement(thisAffect);
    }
    if (eff.size() > 0) {
      final Map<String, String> h = makeMySpellsH(getMySpellsV());
      if (unrevocableSpells != null) {
        for (int v = unrevocableSpells.size() - 1; v >= 0; v--) {
          thisAffect = unrevocableSpells.get(v);
          if (h.containsKey(thisAffect.ID())) P.delEffect(thisAffect);
        }
      } else
        for (x = 0; x < eff.size(); x++) {
          thisAffect = eff.elementAt(x);
          final String ID = h.get(thisAffect.ID());
          if ((ID != null) && (thisAffect.invoker() == getInvokerMOB(P, P))) {
            thisAffect.unInvoke();
            if ((!uninvocable) && (!thisAffect.canBeUninvoked())) P.delEffect(thisAffect);
          }
        }
      unrevocableSpells = null;
    }
  }
  @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;
  }
 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;
 }
 @Override
 public List<Item> getTrapComponents() {
   final List<Item> V = new Vector<Item>();
   for (int i = 0; i < 100; i++)
     V.add(CMLib.materials().makeItemResource(RawMaterial.RESOURCE_IRON));
   return V;
 }
  @Override
  public boolean invoke(
      MOB mob, List<String> commands, Physical givenTarget, boolean auto, int asLevel) {
    if (commands.size() < 1) {
      mob.tell(
          L(
              "You must specify an item to fence, and possibly a ShopKeeper (unless it is implied)."));
      return false;
    }

    commands.add(0, "SELL"); // will be instantly deleted by parseshopkeeper
    final Environmental shopkeeper =
        CMLib.english().parseShopkeeper(mob, commands, L("Fence what to whom?"));
    if (shopkeeper == null) return false;
    if (commands.size() == 0) {
      mob.tell(L("Fence what?"));
      return false;
    }

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

    final boolean success = proficiencyCheck(mob, 0, auto);
    if (success) {
      final CMMsg msg =
          CMClass.getMsg(
              mob,
              shopkeeper,
              this,
              CMMsg.MSG_SPEAK,
              auto ? "" : L("<S-NAME> fence(s) stolen loot to <T-NAMESELF>."));
      if (mob.location().okMessage(mob, msg)) {
        mob.location().send(mob, msg);
        invoker = mob;
        addBackMap.clear();
        mob.addEffect(this);
        mob.recoverCharStats();
        commands.add(0, CMStrings.capitalizeAndLower("SELL"));
        mob.doCommand(commands, MUDCmdProcessor.METAFLAG_FORCED);
        commands.add(shopkeeper.name());
        mob.delEffect(this);
        for (Item I : addBackMap.keySet()) {
          if (mob.isMine(I)) {
            I.addEffect(addBackMap.get(I));
          }
        }
        addBackMap.clear();
        mob.recoverCharStats();
      }
    } else
      beneficialWordsFizzle(
          mob,
          shopkeeper,
          L(
              "<S-NAME> attempt(s) to fence stolen loot to <T-NAMESELF>, but make(s) <T-HIM-HER> too nervous."));

    // return whether it worked
    return success;
  }
 @Override
 public List<Room> getAllTitledRooms() {
   final List<Room> V = new Vector();
   if (affected instanceof Room) V.add((Room) affected);
   else {
     final Room R = CMLib.map().getRoom(landPropertyID());
     if (R != null) V.add(R);
   }
   return V;
 }
 @Override
 public int castingQuality(MOB mob, Physical target) {
   if (mob != null) {
     if (target instanceof MOB) {
       final List<Ability> offensiveAffects = returnOffensiveAffects(target);
       if (offensiveAffects.size() == 0) return Ability.QUALITY_INDIFFERENT;
     }
   }
   return super.castingQuality(mob, target);
 }
 @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);
   }
 }
 @Override
 public Ability fetchAbility(int index) {
   final List<Ability> spellsV = getMySpellsV();
   if (spellsV.size() == 0) return null;
   if ((index < 0) || (index >= spellsV.size())) return null;
   try {
     return spellsV.get(index);
   } catch (final Exception e) {
     return null;
   }
 }
Exemple #10
0
 @Override
 public Trap setTrap(MOB mob, Physical P, int trapBonus, int qualifyingClassLevel, boolean perm) {
   if (P == null) return null;
   final Item I = getPoison(mob);
   if (I != null) {
     final List<Ability> V = returnOffensiveAffects(I);
     if (V.size() > 0) setMiscText(V.get(0).ID());
     I.destroy();
   }
   return super.setTrap(mob, P, trapBonus, qualifyingClassLevel, perm);
 }
Exemple #11
0
 public void sortEnumeratedList(
     Enumeration e, List<String> allKnownFields, StringBuffer allFieldsMsg) {
   for (; e.hasMoreElements(); ) {
     final Environmental E = (Environmental) e.nextElement();
     final String[] fields = E.getStatCodes();
     for (int x = 0; x < fields.length; x++)
       if (!allKnownFields.contains(fields[x])) {
         allKnownFields.add(fields[x]);
         allFieldsMsg.append(fields[x] + " ");
       }
   }
 }
Exemple #12
0
 protected Item getPoison(MOB mob) {
   if (mob == null) return null;
   if (mob.location() == null) return null;
   for (int i = 0; i < mob.location().numItems(); i++) {
     final Item I = mob.location().getItem(i);
     if ((I != null) && (I instanceof Drink)) {
       final List<Ability> V = returnOffensiveAffects(I);
       if (V.size() > 0) return I;
     }
   }
   return null;
 }
Exemple #13
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);
       }
     }
   }
 }
Exemple #14
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;
     }
   }
 }
  public void tickLycanthropically(MOB mob) {
    if (mob == null) return;
    if (mob.location() == null) return;
    if (mob.isInCombat()) return;

    if ((CMLib.dice().rollPercentage() < 15) && ((mob.location().domainType() & Room.INDOORS) > 0))
      mob.location()
          .show(mob, null, CMMsg.MSG_NOISE, L("<S-NAME> howl(s) at the moon! ARROOOOOOOO!!!!"));
    // time to tick lycanthropically
    final MOB M = victimHere(mob.location(), mob);
    if (M != null) {
      deathTrail = null;
      CMLib.combat().postAttack(mob, M, mob.fetchWieldedItem());
      return;
    }
    if ((deathTrail != null) && (!deathTrail.contains(mob.location()))) deathTrail = null;
    if (deathTrail == null) {
      final Vector rooms = new Vector();
      if ((findVictim(mob, mob.location(), rooms, 0)) && (rooms.size() > 0)) {
        TrackingLibrary.TrackingFlags flags;
        flags =
            new TrackingLibrary.TrackingFlags()
                .plus(TrackingLibrary.TrackingFlag.OPENONLY)
                .plus(TrackingLibrary.TrackingFlag.AREAONLY)
                .plus(TrackingLibrary.TrackingFlag.NOEMPTYGRIDS)
                .plus(TrackingLibrary.TrackingFlag.NOAIR)
                .plus(TrackingLibrary.TrackingFlag.NOWATER);
        deathTrail = CMLib.tracking().findBastardTheBestWay(mob.location(), rooms, flags, 50);
        if (deathTrail != null) deathTrail.add(mob.location());
      }
    }
    if (deathTrail != null) {
      final int nextDirection =
          CMLib.tracking().trackNextDirectionFromHere(deathTrail, mob.location(), true);
      if ((nextDirection == 999) || (nextDirection == -1)) deathTrail = null;
      else if (nextDirection >= 0) {
        final Room nextRoom = mob.location().getRoomInDir(nextDirection);
        if ((nextRoom != null) && ((nextRoom.getArea() == mob.location().getArea()))
            || (!mob.isMonster())) {
          if (!CMLib.tracking().walk(mob, nextDirection, false, false)) deathTrail = null;
          else if (CMLib.dice().rollPercentage() < 15)
            mob.location().show(mob, null, CMMsg.MSG_NOISE, L("<S-NAME> sniff(s) at the air."));

        } else deathTrail = null;
      }
    }
  }
 protected void clearWarrants(
     final MOB officer, final MOB invoker, final Room R, final Area A, final LegalBehavior B) {
   final List<LegalWarrant> warrants = B.getWarrantsOf(A, invoker);
   if ((warrants != null) && (warrants.size() > 0)) {
     boolean didSomething = false;
     for (LegalWarrant W : warrants) {
       if ((W.arrestingOfficer() == officer)
           && (System.currentTimeMillis() > W.getIgnoreUntilTime())) {
         if (W.state() != Law.STATE_SEEKING) didSomething = true;
         B.release(A, W);
       }
     }
     if (didSomething && (officer.location() == invoker.location())) {
       R.show(officer, invoker, CMMsg.MSG_HANDS, L("<S-NAME> wink(s) at <T-NAME>."));
     }
   }
 }
Exemple #18
0
  @Override
  public boolean execute(MOB mob, List<String> commands, int metaFlags) throws java.io.IOException {
    if (!mob.isMonster()) {
      if ((commands != null)
          && (commands.size() > 1)
          && (commands.get(1).toUpperCase().equals("OFF"))) {
        final Command C = CMClass.getCommand("NoSounds");
        if (C != null) {
          return C.execute(mob, commands, metaFlags);
        }
      }

      boolean force = false;
      if (commands != null) {
        for (final Object o : commands) {
          if (o.toString().equalsIgnoreCase("force")) force = true;
        }
      }
      final Session session = mob.session();
      if ((!mob.isAttributeSet(MOB.Attrib.SOUND))
          || (!session.getClientTelnetMode(Session.TELNET_MSP))) {
        session.changeTelnetMode(Session.TELNET_MSP, true);
        for (int i = 0; ((i < 5) && (!session.getClientTelnetMode(Session.TELNET_MSP))); i++) {
          try {
            mob.session().prompt("", 500);
          } catch (final Exception e) {
          }
        }
        if (session.getClientTelnetMode(Session.TELNET_MSP)) {
          mob.setAttribute(MOB.Attrib.SOUND, true);
          mob.tell(L("MSP Sound/Music enabled.\n\r"));
        } else if (force) {
          session.setClientTelnetMode(Session.TELNET_MSP, true);
          session.setServerTelnetMode(Session.TELNET_MSP, true);
          mob.setAttribute(MOB.Attrib.SOUND, true);
          mob.tell(L("MSP Sound/Music has been forceably enabled.\n\r"));
        } else mob.tell(L("Your client does not appear to support MSP."));
      } else {
        mob.tell(L("MSP Sound/Music is already enabled.\n\r"));
      }
    }
    return false;
  }
Exemple #19
0
 public static java.util.List<Ability> returnOffensiveAffects(Physical fromMe) {
   final MOB newMOB = CMClass.getFactoryMOB();
   newMOB.setLocation(CMLib.map().roomLocation(fromMe));
   final List<Ability> offenders = new Vector<Ability>();
   for (int a = 0; a < fromMe.numEffects(); a++) // personal
   {
     final Ability A = fromMe.fetchEffect(a);
     if ((A != null) && (A.canBeUninvoked())) {
       try {
         newMOB.recoverPhyStats();
         A.affectPhyStats(newMOB, newMOB.phyStats());
         if (CMLib.flags().isInvisible(newMOB) || CMLib.flags().isHidden(newMOB)) offenders.add(A);
       } catch (final Exception e) {
       }
     }
   }
   newMOB.destroy();
   return offenders;
 }
  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;
  }
  @Override
  public boolean invoke(MOB mob, Vector commands, Physical givenTarget, boolean auto, int asLevel) {

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

    return super.invoke(mob, commands, givenTarget, auto, asLevel);
  }
 @Override
 @SuppressWarnings("rawtypes")
 public boolean invoke(MOB mob, Vector commands, Physical givenTarget, boolean auto, int asLevel) {
   try {
     cookingID = "";
     int num = 1;
     while (mob.fetchEffect("MasterDistilling" + cookingID) != null)
       cookingID = Integer.toString(++num);
     final List<String> noUninvokes = new Vector<String>(1);
     for (int i = 0; i < mob.numEffects(); i++) {
       final Ability A = mob.fetchEffect(i);
       if (((A instanceof MasterDistilling) || A.ID().equals("Distilling"))
           && (noUninvokes.size() < 5)) noUninvokes.add(A.ID());
     }
     this.noUninvokes = noUninvokes;
     return super.invoke(mob, commands, givenTarget, auto, asLevel);
   } finally {
     cookingID = "";
   }
 }
 @Override
 public int castingQuality(MOB mob, Physical target) {
   if ((mob != null) && (target != null) && (target instanceof MOB)) {
     final Race R = ((MOB) target).charStats().getMyRace();
     if (R.bodyMask()[Race.BODY_HEAD] <= 0) return Ability.QUALITY_INDIFFERENT;
     LegalBehavior B = null;
     if (mob.location() != null) B = CMLib.law().getLegalBehavior(mob.location());
     List<LegalWarrant> warrants = new Vector<LegalWarrant>();
     if (B != null)
       warrants = B.getWarrantsOf(CMLib.law().getLegalObject(mob.location()), (MOB) target);
     if (warrants.size() == 0) return Ability.QUALITY_INDIFFERENT;
     final Item w = mob.fetchWieldedItem();
     Weapon ww = null;
     if ((w == null) || (!(w instanceof Weapon))) return Ability.QUALITY_INDIFFERENT;
     ww = (Weapon) w;
     if (ww.weaponDamageType() != Weapon.TYPE_SLASHING) return Ability.QUALITY_INDIFFERENT;
     if (mob.isInCombat() && (mob.rangeToTarget() > 0)) return Ability.QUALITY_INDIFFERENT;
     if (!CMLib.flags().isBoundOrHeld(target)) return Ability.QUALITY_INDIFFERENT;
   }
   return super.castingQuality(mob, target);
 }
  @Override
  public boolean invoke(MOB mob, Vector commands, Physical givenTarget, boolean auto, int asLevel) {
    final MOB target = getTarget(mob, commands, givenTarget);
    if (target == null) return false;

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

    final boolean success = proficiencyCheck(mob, 0, auto);
    final List<Ability> offensiveAffects = returnOffensiveAffects(target);

    if ((success) && (offensiveAffects.size() > 0)) {
      final CMMsg msg =
          CMClass.getMsg(
              mob,
              target,
              this,
              verbalCastCode(mob, target, auto),
              auto
                  ? L("<T-NAME> feel(s) the poison slowing down.")
                  : L("^S<S-NAME> chant(s) for the poisons in <T-NAME> to be slowed down.^?"));
      if (mob.location().okMessage(mob, msg)) {
        mob.location().send(mob, msg);
        Chant_DelayPoison pA = (Chant_DelayPoison) beneficialAffect(mob, target, asLevel, 0);
        if (pA != null) {
          pA.poisonAffects = offensiveAffects;
          for (Ability A : offensiveAffects) {
            target.delEffect(A);
            A.setAffectedOne(target);
          }
        }
        target.recoverPhyStats();
      }
    } else
      beneficialWordsFizzle(
          mob, target, auto ? "" : L("<S-NAME> chant(s) for <T-NAME>, but nothing happens."));

    // return whether it worked
    return success;
  }
  @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;
  }
  @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;
  }
 public String spellAccountingsWithMask(String pre, String post) {
   final List<Ability> spellList = getMySpellsV();
   String id = "";
   for (int v = 0; v < spellList.size(); v++) {
     final Ability A = spellList.get(v);
     if (spellList.size() == 1) id += A.name();
     else if (v == (spellList.size() - 1)) id += "and " + A.name();
     else id += A.name() + ", ";
   }
   if (spellList.size() > 0) id = pre + id + post;
   final String maskString = getMaskString(text());
   if (maskString.length() > 0) id += "  Restrictions: " + CMLib.masking().maskDesc(maskString);
   return id;
 }
Exemple #28
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
 protected List<List<String>> loadRecipes() {
   final String filename = parametersFile();
   @SuppressWarnings("unchecked")
   List<List<String>> recipes =
       (List<List<String>>) Resources.getResource("PARSED_RECIPE: " + filename);
   if (recipes == null) {
     final StringBuffer str =
         new CMFile(Resources.buildResourcePath("skills") + filename, null, CMFile.FLAG_LOGERRORS)
             .text();
     recipes = loadList(str);
     if (recipes.size() == 0) Log.errOut("LeatherWorking", "Recipes not found!");
     else {
       final List<List<String>> newRecipes = new Vector<List<String>>();
       for (int r = 0; r < recipes.size(); r++) {
         final List<String> V = recipes.get(r);
         if (V.size() > 0) {
           final String name = V.get(RCP_FINALNAME);
           final int baseLevel = CMath.s_int(V.get(RCP_LEVEL)) + 2;
           for (final Stage s : Stage.values()) {
             final List<String> V1 = new XVector<String>(V);
             V1.set(RCP_FINALNAME, s.name() + " " + name);
             final int level = baseLevel + s.recipeLevel;
             V1.set(RCP_LEVEL, "" + level);
             for (int i = 0; i <= newRecipes.size(); i++) {
               if (newRecipes.size() == i) {
                 newRecipes.add(V1);
                 break;
               } else if (CMath.s_int(newRecipes.get(i).get(RCP_LEVEL)) > level) {
                 newRecipes.add(i, V1);
                 break;
               }
             }
           }
         }
       }
       recipes.clear();
       recipes = newRecipes;
     }
     Resources.submitResource("PARSED_RECIPE: " + filename, recipes);
   }
   return recipes;
 }
 public boolean addMeIfNeccessary(
     PhysicalAgent source, Physical target, boolean makeLongLasting, int asLevel, short maxTicks) {
   final List<Ability> V = getMySpellsV();
   if ((target == null)
       || (V.size() == 0)
       || ((compiledMask != null) && (!CMLib.masking().maskCheck(compiledMask, target, true))))
     return false;
   final List VTOO = convertToV2(V, target);
   if (VTOO.size() == 0) return false;
   final MOB qualMOB = getInvokerMOB(source, target);
   for (int v = 0; v < VTOO.size(); v += 2) {
     final Ability A = (Ability) VTOO.get(v);
     final Vector V2 = (Vector) VTOO.get(v + 1);
     if (level >= 0) asLevel = level;
     else if (asLevel <= 0) asLevel = (affected != null) ? affected.phyStats().level() : 0;
     A.invoke(qualMOB, V2, target, true, asLevel);
     final Ability EA = target.fetchEffect(A.ID());
     lastMOB = target;
     // this needs to go here because otherwise it makes non-item-invoked spells long lasting,
     // which means they dont go away when item is removed.
     if (EA != null) {
       if ((maxTicks > 0)
           && (maxTicks < Short.MAX_VALUE)
           && (CMath.s_int(EA.getStat("TICKDOWN")) > maxTicks))
         EA.setStat("TICKDOWN", Short.toString(maxTicks));
       else if (makeLongLasting) {
         EA.makeLongLasting();
         if (!uninvocable) {
           EA.makeNonUninvokable();
           if (unrevocableSpells == null) unrevocableSpells = new Vector<Ability>();
           unrevocableSpells.add(EA);
         }
       }
     }
   }
   return true;
 }