Example #1
0
 public boolean execute(MOB mob, Vector commands, int metaFlags) throws java.io.IOException {
   if (commands != null) commands.removeElementAt(0);
   if ((commands == null) || (commands.size() == 0)) {
     if (!CMLib.flags().isSleeping(mob)) mob.tell("You aren't sleeping!?");
     else {
       CMMsg msg =
           CMClass.getMsg(mob, null, null, CMMsg.MSG_STAND, "<S-NAME> awake(s) and stand(s) up.");
       if (mob.location().okMessage(mob, msg)) mob.location().send(mob, msg);
     }
   } else {
     String whom = CMParms.combine(commands, 0);
     MOB M = mob.location().fetchInhabitant(whom);
     if ((M == null) || (!CMLib.flags().canBeSeenBy(M, mob))) {
       mob.tell("You don't see '" + whom + "' here.");
       return false;
     }
     if (!CMLib.flags().isSleeping(M)) {
       mob.tell(M.name() + " is awake!");
       return false;
     }
     CMMsg msg =
         CMClass.getMsg(
             mob, M, null, CMMsg.MSG_NOISYMOVEMENT, "<S-NAME> attempt(s) to wake <T-NAME> up.");
     if (mob.location().okMessage(mob, msg)) {
       mob.location().send(mob, msg);
       execute(M, null, metaFlags | Command.METAFLAG_ORDER);
     }
   }
   return false;
 }
Example #2
0
  public InvisibleStalker() {
    super();
    Random randomizer = new Random(System.currentTimeMillis());

    username = "******";
    setDescription("A shimmering blob of energy.");
    setDisplayText("An invisible stalker hunts here.");
    CMLib.factions().setAlignment(this, Faction.ALIGN_NEUTRAL);
    setMoney(0);
    basePhyStats.setWeight(10 + Math.abs(randomizer.nextInt() % 10));

    baseCharStats().setStat(CharStats.STAT_INTELLIGENCE, 12 + Math.abs(randomizer.nextInt() % 3));
    baseCharStats().setStat(CharStats.STAT_STRENGTH, 20);
    baseCharStats().setStat(CharStats.STAT_DEXTERITY, 13);

    basePhyStats().setDamage(16);
    basePhyStats().setSpeed(1.0);
    basePhyStats().setAbility(0);
    basePhyStats().setLevel(4);
    basePhyStats().setArmor(0);
    basePhyStats().setDisposition(basePhyStats().disposition() | PhyStats.IS_INVISIBLE);

    baseState.setHitPoints(CMLib.dice().roll(basePhyStats().level(), 20, basePhyStats().level()));

    addBehavior(CMClass.getBehavior("Aggressive"));
    addBehavior(CMClass.getBehavior("Mobile"));

    recoverMaxState();
    resetToMaxState();
    recoverPhyStats();
    recoverCharStats();
  }
Example #3
0
  public HeavenlyServent() {
    super();

    Random randomizer = new Random(System.currentTimeMillis());

    username = "******";
    setDescription(
        "An angelic form in gowns of white, with golden hair, and an ever present smile.");
    setDisplayText("A servant of the Archons is running errands.");
    CMLib.factions().setAlignment(this, Faction.ALIGN_NEUTRAL);
    setMoney(0);
    basePhyStats.setWeight(20 + Math.abs(randomizer.nextInt() % 55));
    setWimpHitPoint(2);

    addBehavior(CMClass.getBehavior("Mobile"));
    addBehavior(CMClass.getBehavior("MudChat"));

    basePhyStats().setDamage(25);

    basePhyStats().setAbility(0);
    basePhyStats().setLevel(10);
    basePhyStats().setArmor(0);
    baseCharStats().setMyRace(CMClass.getRace("Human"));
    baseCharStats().getMyRace().startRacing(this, false);

    baseState.setHitPoints(CMLib.dice().roll(basePhyStats().level(), 20, basePhyStats().level()));

    recoverMaxState();
    resetToMaxState();
    recoverPhyStats();
    recoverCharStats();
  }
Example #4
0
 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;
     }
 }
Example #5
0
 public boolean isLaw(MOB mob) {
   if (mob == null) return false;
   if (affected instanceof Room) {
     LegalBehavior law = CMLib.law().getLegalBehavior((Room) affected);
     if (law != null) {
       Area A = CMLib.law().getLegalObject((Room) affected);
       if (law.isAnyOfficer(A, mob) || law.isJudge(A, mob)) return true;
     }
   }
   return false;
 }
Example #6
0
 public String getStat(String code) {
   if (CMLib.coffeeMaker().getGenItemCodeNum(code) >= 0)
     return CMLib.coffeeMaker().getGenItemStat(this, code);
   switch (getCodeNum(code)) {
     case 0:
       return clanID();
     case 1:
       return "" + ciType();
     default:
       return CMProps.getStatCodeExtensionValue(getStatCodes(), xtraValues, code);
   }
 }
Example #7
0
  public boolean invoke(MOB mob, Vector commands, Physical givenTarget, boolean auto, int asLevel) {
    Physical target = null;
    if (commands.size() > 0) {
      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("This place is already under a summoning ward.");
      return false;
    }

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

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

    return success;
  }
Example #8
0
 public Item buildMyThing(MOB mob, Room room) {
   Area A = room.getArea();
   boolean bonusWorthy = (Druid_MyPlants.myPlant(room, mob, 0) == null);
   Vector V = Druid_MyPlants.myAreaPlantRooms(mob, room.getArea());
   int pct = 0;
   if (A.getAreaIStats()[Area.Stats.VISITABLE_ROOMS.ordinal()] > 10)
     pct =
         (int)
             Math.round(
                 100.0
                     * CMath.div(
                         V.size(), A.getAreaIStats()[Area.Stats.VISITABLE_ROOMS.ordinal()]));
   Item I = buildMyPlant(mob, room);
   if ((I != null)
       && ((mob.charStats().getCurrentClass().baseClass().equalsIgnoreCase("Druid"))
           || (CMSecurity.isASysOp(mob)))) {
     if (!CMLib.law().isACity(A)) {
       if (pct > 0) {
         int newPct =
             (int)
                 Math.round(
                     100.0
                         * CMath.div(
                             V.size(), A.getAreaIStats()[Area.Stats.VISITABLE_ROOMS.ordinal()]));
         if ((newPct >= 50) && (A.fetchEffect("Chant_DruidicConnection") == null)) {
           Ability A2 = CMClass.getAbility("Chant_DruidicConnection");
           if (A2 != null) A2.invoke(mob, A, true, 0);
         }
       }
     } else if ((bonusWorthy) && (!mob.isMonster())) {
       long[] num = (long[]) plantBonuses.get(mob.Name() + "/" + room.getArea().Name());
       if ((num == null)
           || (System.currentTimeMillis() - num[1]
               > (room.getArea().getTimeObj().getDaysInMonth()
                   * room.getArea().getTimeObj().getHoursInDay()
                   * CMProps.getMillisPerMudHour()))) {
         num = new long[2];
         plantBonuses.remove(mob.Name() + "/" + room.getArea().Name());
         plantBonuses.put(mob.Name() + "/" + room.getArea().Name(), num);
         num[1] = System.currentTimeMillis();
       }
       if (V.size() >= num[0]) {
         num[0]++;
         if (num[0] < 19) {
           mob.tell("You have made this city greener.");
           CMLib.leveler().postExperience(mob, null, null, (int) num[0], false);
         }
       }
     }
   }
   return I;
 }
Example #9
0
  public boolean invoke(MOB mob, Vector commands, Physical givenTarget, boolean auto, int asLevel) {
    MOB target = this.getTarget(mob, commands, givenTarget);
    if (target == null) return false;

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

    boolean success = proficiencyCheck(mob, 0, auto);
    CMMsg msg2 = null;
    if ((mob != target) && (!mob.getGroupMembers(new HashSet<MOB>()).contains(target)))
      msg2 =
          CMClass.getMsg(
              mob,
              target,
              this,
              verbalCastCode(mob, target, auto) | CMMsg.MASK_MALICIOUS,
              "<T-NAME> do(es) not seem to like <S-NAME> messing with <T-HIS-HER> head.");

    if (success && (CMLib.factions().getFaction(CMLib.factions().AlignID()) != null)) {
      // it worked, so build a copy of this ability,
      // and add it to the affects list of the
      // affected MOB.  Then tell everyone else
      // what happened.
      CMMsg msg =
          CMClass.getMsg(
              mob,
              target,
              this,
              verbalCastCode(mob, target, auto),
              (auto
                  ? "<T-NAME> feel(s) more good."
                  : "^S<S-NAME> " + prayWord(mob) + " to atone <T-NAMESELF>!^?"));
      if ((mob.location().okMessage(mob, msg))
          && ((msg2 == null) || (mob.location().okMessage(mob, msg2)))) {
        mob.location().send(mob, msg);
        if ((msg.value() <= 0) && ((msg2 == null) || (msg2.value() <= 0))) {
          target.tell("Good, pure thoughts fill your head.");
          int evilness = CMLib.dice().roll(10, adjustedLevel(mob, asLevel), 0);
          CMLib.factions().postFactionChange(target, this, CMLib.factions().AlignID(), evilness);
        }
        if (msg2 != null) mob.location().send(mob, msg2);
      }
    } else {
      if ((msg2 != null) && (mob.location().okMessage(mob, msg2))) mob.location().send(mob, msg2);
      return beneficialWordsFizzle(
          mob,
          target,
          "<S-NAME> point(s) at <T-NAMESELF> and " + prayWord(mob) + ", but nothing happens.");
    }

    // return whether it worked
    return success;
  }
Example #10
0
 public boolean isLawHere(Room R) {
   if (R != null) {
     LegalBehavior law = CMLib.law().getLegalBehavior(R);
     if (law != null) {
       Area A = CMLib.law().getLegalObject(R);
       MOB M = null;
       for (int r = 0; r < R.numInhabitants(); r++) {
         M = R.fetchInhabitant(r);
         if ((M != null) && (law.isAnyOfficer(A, M) || law.isJudge(A, M))) return true;
       }
     }
   }
   return false;
 }
Example #11
0
 public static Item buildPlant(MOB mob, Room room) {
   Item newItem = CMClass.getItem("GenItem");
   newItem.setMaterial(RawMaterial.RESOURCE_GREENS);
   switch (CMLib.dice().roll(1, 5, 0)) {
     case 1:
       newItem.setName("some happy flowers");
       newItem.setDisplayText("some happy flowers are growing here.");
       newItem.setDescription("Happy flowers with little red and yellow blooms.");
       break;
     case 2:
       newItem.setName("some happy weeds");
       newItem.setDisplayText("some happy weeds are growing here.");
       newItem.setDescription("Long stalked little plants with tiny bulbs on top.");
       break;
     case 3:
       newItem.setName("a pretty fern");
       newItem.setDisplayText("a pretty fern is growing here.");
       newItem.setDescription("Like a tiny bush, this dark green plant is lovely.");
       break;
     case 4:
       newItem.setName("a patch of sunflowers");
       newItem.setDisplayText("a patch of sunflowers is growing here.");
       newItem.setDescription("Happy flowers with little yellow blooms.");
       break;
     case 5:
       newItem.setName("a patch of bluebonnets");
       newItem.setDisplayText("a patch of bluebonnets is growing here.");
       newItem.setDescription("Happy flowers with little blue and purple blooms.");
       break;
   }
   Chant_SummonPlants newChant = new Chant_SummonPlants();
   newItem.basePhyStats().setLevel(10 + (10 * newChant.getX1Level(mob)));
   newItem.basePhyStats().setWeight(1);
   newItem.setSecretIdentity(mob.Name());
   newItem.setMiscText(newItem.text());
   room.addItem(newItem);
   newItem.setExpirationDate(0);
   room.showHappens(CMMsg.MSG_OK_ACTION, "Suddenly, " + newItem.name() + " sprout(s) up here.");
   newChant.PlantsLocation = room;
   newChant.littlePlants = newItem;
   if (CMLib.law().doesOwnThisProperty(mob, room)) {
     newChant.setInvoker(mob);
     newChant.setMiscText(mob.Name());
     newItem.addNonUninvokableEffect(newChant);
   } else newChant.beneficialAffect(mob, newItem, 0, (newChant.adjustedLevel(mob, 0) * 240) + 450);
   room.recoverPhyStats();
   return newItem;
 }
Example #12
0
  public boolean invoke(MOB mob, Vector commands, Physical givenTarget, boolean auto, int asLevel) {
    String dir = CMParms.combine(commands, 0);
    if (commands.size() > 0) dir = (String) commands.lastElement();
    int dirCode = Directions.getGoodDirectionCode(dir);
    if (!preInvoke(mob, commands, givenTarget, auto, asLevel, 0, 0.0)) return false;

    MOB highestMOB = getHighestLevelMOB(mob, null);
    int levelDiff =
        mob.phyStats().level() + (2 * super.getXLEVELLevel(mob)) - getMOBLevel(highestMOB);

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

    boolean success = false;
    CMMsg msg =
        CMClass.getMsg(
            mob,
            null,
            this,
            auto ? CMMsg.MSG_OK_VISUAL : CMMsg.MSG_DELICATE_HANDS_ACT,
            "<S-NAME> walk(s) carefully " + Directions.getDirectionName(dirCode) + ".");
    if (mob.location().okMessage(mob, msg)) {
      mob.location().send(mob, msg);
      if (levelDiff < 0) levelDiff = levelDiff * 8;
      else levelDiff = levelDiff * 10;
      success = proficiencyCheck(mob, levelDiff, auto);
      int oldDex = mob.baseCharStats().getStat(CharStats.STAT_DEXTERITY);
      if (success) mob.baseCharStats().setStat(CharStats.STAT_DEXTERITY, oldDex + 100);
      mob.recoverCharStats();
      CMLib.tracking().walk(mob, dirCode, false, false);
      if (oldDex != mob.baseCharStats().getStat(CharStats.STAT_DEXTERITY))
        mob.baseCharStats().setStat(CharStats.STAT_DEXTERITY, oldDex);
      mob.recoverCharStats();
    }
    return success;
  }
Example #13
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:
         setClanID(val);
         break;
       case 1:
         setCIType(CMath.s_parseListIntExpression(ClanItem.CI_DESC, val));
         break;
       default:
         CMProps.setStatCodeExtensionValue(getStatCodes(), xtraValues, code, val);
         break;
     }
 }
Example #14
0
  public void unInvoke() {
    // undo the affects of this spell
    if ((affected == null) || (!(affected instanceof MOB))) return;
    MOB mob = (MOB) affected;
    super.unInvoke();

    if ((canBeUninvoked()) && (mob.location() != null)) {
      if ((failed)
          || (!CMLib.flags().isSitting(mob))
          || (room == null)
          || (title == null)
          || (mob.location() != room)) mob.tell("You are no longer squatting.");
      else if (title.landOwner().length() > 0) {
        mob.tell(
            "Your squat has succeeded.  This property no longer belongs to "
                + title.landOwner()
                + ".");
        title.setLandOwner("");
        title.updateTitle();
        title.updateLot(null);
      } else if (title.landOwner().length() > 0) {
        mob.tell("Your squat has succeeded.  This property now belongs to you.");
        title.setLandOwner(mob.Name());
        title.updateTitle();
        title.updateLot(new XVector(mob.name()));
      }
    }
    failed = false;
  }
Example #15
0
 public static void pickAWimpyFight(
     MOB observer, boolean mobKiller, boolean misBehave, String attackMsg, String zapStr) {
   if (!canFreelyBehaveNormal(observer)) return;
   Room R = observer.location();
   if (R != null)
     for (int i = 0; i < R.numInhabitants(); i++) {
       MOB mob = R.fetchInhabitant(i);
       if ((mob != null)
           && (mob != observer)
           && (CMLib.flags().isSleeping(mob))
           && (CMLib.masking().maskCheck(zapStr, observer, false))) {
         startFight(observer, mob, mobKiller, misBehave, attackMsg);
         if (observer.isInCombat()) break;
       }
     }
 }
Example #16
0
 public Room room() {
   if ((roomID.length() > 0) && ((roomCache == null) || (roomCache.amDestroyed()))) {
     roomCache = CMLib.map().getRoom(roomID);
     if (roomCache != null) fixExits(roomCache);
   }
   return roomCache;
 }
Example #17
0
  public boolean invoke(MOB mob, Vector commands, Physical givenTarget, boolean auto, int asLevel) {
    Physical target = getAnyTarget(mob, commands, givenTarget, Wearable.FILTER_ANY);
    if (target == null) return false;

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

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

    if (success) {
      // it worked, so build a copy of this ability,
      // and add it to the affects list of the
      // affected MOB.  Then tell everyone else
      // what happened.
      CMMsg msg =
          CMClass.getMsg(
              mob,
              target,
              this,
              verbalCastCode(mob, target, auto),
              auto ? "" : "^S<S-NAME> " + prayWord(mob) + " to extinguish <T-NAMESELF>.^?");
      if (mob.location().okMessage(mob, msg)) {
        mob.location().send(mob, msg);
        CMLib.utensils().extinguish(mob, target, false);
        target.recoverPhyStats();
        mob.location().recoverRoomStats();
      }
    } else
      return beneficialWordsFizzle(
          mob,
          target,
          "<S-NAME> " + prayWord(mob) + " to extinguish <T-NAMESELF>, but nothing happens.");
    // return whether it worked
    return success;
  }
  public List<Ability> getClanLevelEffectsList(final MOB mob, final Integer level) {
    if (clanEffectNames == null) return empty;

    if ((clanEffectMap == null)
        && (clanEffectNames != null)
        && (clanEffectLevels != null)
        && (clanEffectParms != null)) clanEffectMap = new Hashtable<Integer, List<Ability>>();

    if (clanEffectMap == null) return empty;

    if (clanEffectMap.containsKey(level)) return clanEffectMap.get(level);
    final CMObjUniqSortSVec<Ability> finalV = new CMObjUniqSortSVec<Ability>();
    for (int v = 0; v < clanEffectLevels.length; v++) {
      if ((clanEffectLevels[v] <= level.intValue())
          && (clanEffectNames.length > v)
          && (clanEffectParms.length > v)) {
        Ability A = CMClass.getAbility(clanEffectNames[v]);
        if (A != null) {
          // mob was set to null here to make the cache map actually relevant .. see caching below
          A.setProficiency(CMLib.ableMapper().getMaxProficiency((MOB) null, true, A.ID()));
          A.setMiscText(clanEffectParms[v]);
          A.makeNonUninvokable();
          A.setSavable(false); // must go AFTER the ablve
          finalV.add(A);
        }
      }
    }
    finalV.trimToSize();
    clanEffectMap.put(level, finalV);
    return finalV;
  }
Example #19
0
 public boolean okMessage(final Environmental myHost, final CMMsg msg) {
   if (!super.okMessage(myHost, msg)) return false;
   if (msg.amITarget(this)) {
     MOB mob = msg.source();
     switch (msg.targetMinor()) {
       case CMMsg.TYP_DRINK:
         if ((mob.isMine(this))
             || (phyStats().weight() > 1000)
             || (!CMLib.flags().isGettable(this))) {
           if (!containsDrink()) {
             mob.tell(name() + " is empty.");
             return false;
           }
           if ((liquidType() == RawMaterial.RESOURCE_SALTWATER)
               || (liquidType() == RawMaterial.RESOURCE_LAMPOIL)) {
             mob.tell(
                 "You don't want to be drinking "
                     + RawMaterial.CODES.NAME(liquidType()).toLowerCase()
                     + ".");
             return false;
           }
           return true;
         }
         mob.tell("You don't have that.");
         return false;
       case CMMsg.TYP_FILL:
         if ((liquidRemaining() >= amountOfLiquidHeld) && (liquidHeld() < 500000)) {
           mob.tell(name() + " is full.");
           return false;
         }
         if ((msg.tool() != null)
             && (msg.tool() != msg.target())
             && (msg.tool() instanceof Drink)) {
           Drink thePuddle = (Drink) msg.tool();
           if (!thePuddle.containsDrink()) {
             mob.tell(thePuddle.name() + " is empty.");
             return false;
           }
           if ((liquidRemaining() > 0) && (liquidType() != thePuddle.liquidType())) {
             mob.tell(
                 "There is still some "
                     + RawMaterial.CODES.NAME(liquidType()).toLowerCase()
                     + " left in "
                     + name()
                     + ".  You must empty it before you can fill it with "
                     + RawMaterial.CODES.NAME(thePuddle.liquidType()).toLowerCase()
                     + ".");
             return false;
           }
           return true;
         }
         mob.tell("You can't fill " + name() + " from that.");
         return false;
       default:
         break;
     }
   }
   return true;
 }
Example #20
0
 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);
   }
 }
Example #21
0
 public boolean tick(Tickable ticking, int tickID) {
   if (!super.tick(ticking, tickID)) return false;
   if ((tickID == Tickable.TICKID_MOB) && (affected == spy)) {
     if (spy.amDead()
         || (spy.amFollowing() != invoker)
         || (!CMLib.flags().isInTheGame(spy, false))) unInvoke();
   }
   return true;
 }
Example #22
0
  public boolean invoke(MOB mob, Vector commands, Physical givenTarget, boolean auto, int asLevel) {

    if (commands.size() < 1) {
      mob.tell("Chant to whom?");
      return false;
    }
    String mobName = CMParms.combine(commands, 0).trim().toUpperCase();
    MOB target = getTarget(mob, commands, givenTarget);

    Room newRoom = mob.location();
    if (target != null) {
      newRoom = target.location();
      if ((!CMLib.flags().isAnimalIntelligence(target)) || (target.amFollowing() != mob)) {
        mob.tell("You have no animal follower named '" + mobName + "' here.");
        return false;
      }
    } else {
      mob.tell("You have no animal follower named '" + mobName + "' here.");
      return false;
    }

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

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

    if (success) {
      CMMsg msg =
          CMClass.getMsg(
              mob,
              target,
              this,
              verbalCastCode(mob, target, auto),
              auto
                  ? ""
                  : "^S<S-NAME> chant(s) to <T-NAMESELF>, invoking the a mystical connection.^?");
      CMMsg msg2 = CMClass.getMsg(mob, target, this, verbalCastCode(mob, target, auto), null);
      if ((mob.location().okMessage(mob, msg))
          && ((newRoom == mob.location()) || (newRoom.okMessage(mob, msg2)))) {
        mob.location().send(mob, msg);
        if (newRoom != mob.location()) newRoom.send(target, msg2);
        spy = target;
        beneficialAffect(mob, spy, asLevel, 0);
        Ability A = spy.fetchEffect(ID());
        if (A != null) {
          mob.addNonUninvokableEffect((Ability) A.copyOf());
          A.setAffectedOne(spy);
        }
      }

    } else
      beneficialVisualFizzle(
          mob, target, "<S-NAME> chant(s) to <T-NAMESELF>, but the magic fades.");

    // return whether it worked
    return success;
  }
Example #23
0
  public void executeMsg(final Environmental myHost, final CMMsg msg) {
    try {
      super.executeMsg(myHost, msg);
      if (spy == null) return;
      if (invoker == null) return;

      if ((msg.amISource(spy))
          && ((msg.sourceMinor() == CMMsg.TYP_LOOK) || (msg.sourceMinor() == CMMsg.TYP_EXAMINE))
          && (msg.target() != null)
          && ((invoker.location() != spy.location()) || (!(msg.target() instanceof Room)))) {
        disable = true;
        CMMsg newAffect = CMClass.getMsg(invoker, msg.target(), msg.sourceMinor(), null);
        msg.target().executeMsg(invoker, newAffect);
      } else if ((!msg.amISource(invoker))
          && (invoker.location() != spy.location())
          && (msg.source().location() == spy.location())
          && (msg.othersCode() != CMMsg.NO_EFFECT)
          && (msg.othersMessage() != null)
          && (!disable)) {
        disable = true;
        invoker.executeMsg(invoker, msg);
      } else if (msg.amISource(invoker)
          && (!disable)
          && (msg.sourceMinor() == CMMsg.TYP_SPEAK)
          && (msg.sourceMessage() != null)
          && ((msg.sourceMajor() & CMMsg.MASK_MAGIC) == 0)) {
        int start = msg.sourceMessage().indexOf("\'");
        int end = msg.sourceMessage().lastIndexOf("\'");
        if ((start > 0) && (end > start)) {
          String msg2 = msg.sourceMessage().substring(start + 1, end).trim();
          if (msg2.length() > 0)
            spy.enqueCommand(CMParms.parse(msg2.trim()), Command.METAFLAG_FORCED, 0);
        }
      }
    } finally {
      disable = false;
      if ((spy != null)
          && ((spy.amFollowing() != invoker)
              || (spy.amDead())
              || (!CMLib.flags().isInTheGame(spy, false))
              || (!CMLib.flags().isInTheGame(invoker, true)))) unInvoke();
    }
  }
Example #24
0
  public boolean invoke(MOB mob, Vector commands, Physical givenTarget, boolean auto, int asLevel) {
    if (mob.fetchEffect("Thief_Hide") != null) {
      mob.tell("You are already hiding.");
      return false;
    }

    if (mob.isInCombat()) {
      mob.tell("Not while in combat!");
      return false;
    }

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

    Set<MOB> H = mob.getGroupMembers(new HashSet<MOB>());
    if (!H.contains(mob)) H.add(mob);
    int numBesidesMe = 0;
    for (Iterator e = H.iterator(); e.hasNext(); ) {
      MOB M = (MOB) e.next();
      if ((M != mob) && (mob.location().isInhabitant(M))) numBesidesMe++;
    }
    if (numBesidesMe == 0) {
      mob.tell("You need a group to set up an ambush!");
      return false;
    }
    for (int i = 0; i < mob.location().numInhabitants(); i++) {
      MOB M = mob.location().fetchInhabitant(i);
      if ((M != null) && (M != mob) && (!H.contains(M)) && (CMLib.flags().canSee(M))) {
        mob.tell(M, null, null, "<S-NAME> is watching you too closely.");
        return false;
      }
    }
    boolean success = proficiencyCheck(mob, 0, auto);

    if (!success)
      beneficialVisualFizzle(mob, null, "<S-NAME> attempt(s) to set up an ambush, but fail(s).");
    else {
      CMMsg msg =
          CMClass.getMsg(
              mob,
              null,
              this,
              auto ? CMMsg.MSG_OK_ACTION : (CMMsg.MSG_DELICATE_HANDS_ACT | CMMsg.MASK_MOVE),
              "<S-NAME> set(s) up an ambush, directing everyone to hiding places.");
      if (mob.location().okMessage(mob, msg)) {
        mob.location().send(mob, msg);
        invoker = mob;
        Ability hide = CMClass.getAbility("Thief_Hide");
        for (Iterator e = H.iterator(); e.hasNext(); ) {
          MOB M = (MOB) e.next();
          hide.invoke(M, M, true, adjustedLevel(mob, asLevel));
        }
      } else success = false;
    }
    return success;
  }
Example #25
0
  public boolean execute(MOB mob, Vector commands, int metaFlags) throws java.io.IOException {
    boolean skipChecks = mob.Name().equals(mob.getClanID());
    Room R = mob.location();
    if (skipChecks) {
      commands.setElementAt(getAccessWords()[0], 0);
      R = CMLib.map().getRoom(CMParms.combine(commands, 1));
    } else {
      commands.clear();
      commands.addElement(getAccessWords()[0]);
      commands.addElement(CMLib.map().getExtendedRoomID(R));
    }

    if ((mob.getClanID() == null) || (R == null) || (mob.getClanID().equalsIgnoreCase(""))) {
      mob.tell("You aren't even a member of a clan.");
      return false;
    }
    Clan C = mob.getMyClan();
    if (C == null) {
      mob.tell("There is no longer a clan called " + mob.getClanID() + ".");
      return false;
    }
    if (C.getStatus() > Clan.CLANSTATUS_ACTIVE) {
      mob.tell(
          "You cannot set a morgue.  Your "
              + C.getGovernmentName()
              + " does not have enough members to be considered active.");
      return false;
    }
    if (skipChecks || CMLib.clans().goForward(mob, C, commands, Clan.Function.SET_HOME, false)) {
      if (!CMLib.law().doesOwnThisProperty(C.clanID(), R)) {
        mob.tell("Your " + C.getGovernmentName() + " does not own this room.");
        return false;
      }
      if (skipChecks || CMLib.clans().goForward(mob, C, commands, Clan.Function.SET_HOME, true)) {
        C.setMorgue(CMLib.map().getExtendedRoomID(R));
        C.update();
        mob.tell(
            "Your " + C.getGovernmentName() + " morgue is now set to " + R.roomTitle(mob) + ".");
        CMLib.clans()
            .clanAnnounce(
                mob,
                "The morgue of "
                    + C.getGovernmentName()
                    + " "
                    + C.clanID()
                    + " is now set to "
                    + R.roomTitle(mob)
                    + ".");
        return true;
      }
    } else {
      mob.tell(
          "You aren't in the right position to set your " + C.getGovernmentName() + "'s morgue.");
      return false;
    }
    return false;
  }
Example #26
0
 public String runMacro(ExternalHTTPRequests httpReq, String parm) {
   java.util.Map<String, String> parms = parseParms(parm);
   String last = httpReq.getRequestParameter("COMPONENT");
   StringBuilder str = new StringBuilder("");
   if (parms.containsKey("DESC")) {
     str.append(CMLib.ableMapper().getAbilityComponentDesc(null, last));
   }
   String strstr = str.toString();
   if (strstr.endsWith(", ")) strstr = strstr.substring(0, strstr.length() - 2);
   return clearWebMacros(strstr);
 }
Example #27
0
 public boolean tick(Tickable ticking, int tickID) {
   if (tickID == Tickable.TICKID_MOB) {
     Room R = CMLib.map().roomLocation(affected);
     if ((R != null)
         && (invoker != null)
         && ((!R.isInhabitant(invoker)) || (!invoker.isInCombat()))) {
       unInvoke();
       return false;
     }
   }
   return super.tick(ticking, tickID);
 }
Example #28
0
 public boolean tick(Tickable ticking, int tickID) {
   if (!super.tick(ticking, tickID)) return false;
   if ((tickID == Tickable.TICKID_MOB) && (affected != null) && (affected instanceof MOB)) {
     MOB mob = (MOB) affected;
     if ((mob.isInCombat())
         && (CMLib.flags().aliveAwakeMobileUnbound(mob, true))
         && (mob.rangeToTarget() == 0)
         && (mob.charStats().getBodyPart(Race.BODY_HAND) > 1)
         && (!anyWeapons(mob))) {
       if (CMLib.dice().rollPercentage() > 95) helpProficiency(mob, 0);
       if ((naturalWeapon == null) || (naturalWeapon.amDestroyed())) {
         naturalWeapon = CMClass.getWeapon("GenWeapon");
         naturalWeapon.setName("a knife hand");
         naturalWeapon.setWeaponType(Weapon.TYPE_PIERCING);
         naturalWeapon.basePhyStats().setDamage(7);
         naturalWeapon.recoverPhyStats();
       }
       CMLib.combat().postAttack(mob, mob.getVictim(), naturalWeapon);
     }
   }
   return true;
 }
 public List<Ability> getClanLevelAbilities(Integer level) {
   if ((clanAbilityMap == null)
       && (clanAbilityNames != null)
       && (clanAbilityLevels != null)
       && (clanAbilityProficiencies != null)
       && (clanAbilityQuals != null)) {
     CMLib.ableMapper().delCharMappings(ID()); // necessary for a "clean start"
     clanAbilityMap = new Hashtable<Integer, List<Ability>>();
     for (int i = 0; i < clanAbilityNames.length; i++) {
       CMLib.ableMapper()
           .addDynaAbilityMapping(
               ID(),
               clanAbilityLevels[i],
               clanAbilityNames[i],
               clanAbilityProficiencies[i],
               "",
               !clanAbilityQuals[i],
               false);
     }
   }
   if (clanAbilityMap == null) return empty;
   if (clanAbilityMap.containsKey(level)) return clanAbilityMap.get(level);
   List<AbilityMapper.AbilityMapping> V =
       CMLib.ableMapper().getUpToLevelListings(ID(), level.intValue(), true, true);
   CMObjUniqSortSVec<Ability> finalV = new CMObjUniqSortSVec<Ability>();
   for (AbilityMapper.AbilityMapping able : V) {
     Ability A = CMClass.getAbility(able.abilityID);
     if (A != null) {
       A.setProficiency(CMLib.ableMapper().getDefaultProficiency(ID(), false, A.ID()));
       A.setSavable(false);
       A.setMiscText(CMLib.ableMapper().getDefaultParm(ID(), false, A.ID()));
       finalV.add(A);
     }
   }
   finalV.trimToSize();
   clanAbilityMap.put(level, finalV);
   return finalV;
 }
Example #30
0
 public void executeMsg(Environmental host, CMMsg msg) {
   if (affected instanceof MOB) {
     MOB mob = (MOB) affected;
     if ((msg.source() == mob)
         && (msg.target() == mob.location())
         && (msg.targetMinor() == CMMsg.TYP_LEAVE)) {
       failed = true;
       unInvoke();
     } else if ((CMLib.flags().isStanding(mob)) || (mob.location() != room)) {
       failed = true;
       unInvoke();
     }
   }
   super.executeMsg(host, msg);
 }