Пример #1
0
  @Override
  public boolean tick(Tickable ticking, int tickID) {
    super.tick(ticking, tickID);
    if ((canAct(ticking, tickID)) && (ticking instanceof MOB)) {
      if (DoneEquipping) return true;

      final MOB mob = (MOB) ticking;
      final Room thisRoom = mob.location();
      if (thisRoom.numItems() == 0) return true;

      DoneEquipping = true;
      final Vector<Item> stuffIHad = new Vector<Item>();
      for (int i = 0; i < mob.numItems(); i++) stuffIHad.addElement(mob.getItem(i));
      mob.enqueCommand(new XVector<String>("GET", "ALL"), MUDCmdProcessor.METAFLAG_FORCED, 0);
      Item I = null;
      final Vector<Item> dropThisStuff = new Vector<Item>();
      for (int i = 0; i < mob.numItems(); i++) {
        I = mob.getItem(i);
        if ((I != null) && (!stuffIHad.contains(I))) {
          if (I instanceof DeadBody) dropThisStuff.addElement(I);
          else if ((I.container() != null) && (I.container() instanceof DeadBody))
            I.setContainer(null);
        }
      }
      for (int d = 0; d < dropThisStuff.size(); d++)
        mob.enqueCommand(
            new XVector<String>("DROP", "$" + dropThisStuff.elementAt(d).Name() + "$"),
            MUDCmdProcessor.METAFLAG_FORCED,
            0);
      mob.enqueCommand(new XVector<String>("WEAR", "ALL"), MUDCmdProcessor.METAFLAG_FORCED, 0);
    }
    return true;
  }
Пример #2
0
 public Set<MOB> getDeadMOBsFrom(Environmental whoE) {
   if (whoE instanceof MOB) {
     final MOB mob = (MOB) whoE;
     final Room room = mob.location();
     if (room != null) return getEveryoneHere(mob, room);
   } else if (whoE instanceof Item) {
     final Item item = (Item) whoE;
     final Environmental E = item.owner();
     if (E != null) {
       final Room room = getTickersRoom(whoE);
       if (room != null) {
         if ((E instanceof MOB) && ((mask == null) || (CMLib.masking().maskCheck(mask, E, false))))
           return new XHashSet<MOB>((MOB) E);
         else if (E instanceof Room) return getEveryoneHere(null, (Room) E);
         room.recoverRoomStats();
       }
     }
   } else if (whoE instanceof Room) return getEveryoneHere(null, (Room) whoE);
   else if (whoE instanceof Area) {
     final Set<MOB> allMobs = new HashSet<MOB>();
     for (final Enumeration r = ((Area) whoE).getMetroMap(); r.hasMoreElements(); ) {
       final Room R = (Room) r.nextElement();
       allMobs.addAll(getEveryoneHere(null, R));
     }
   }
   return new HashSet<MOB>();
 }
Пример #3
0
  @Override
  public boolean tick(Tickable ticking, int tickID) {
    super.tick(ticking, tickID);

    if (anyWetWeather(lastWeather)) {
      if (ticking instanceof Room) {
        final Room R = (Room) ticking;
        final Area A = R.getArea();
        if ((!anyWetWeather(A.getClimateObj().weatherType(R)))
            && (!dryWeather(A.getClimateObj().weatherType(R)))
            && (CMLib.dice().rollPercentage() < pct()))
          makePuddle(R, lastWeather, A.getClimateObj().weatherType(R));
      } else if (ticking instanceof Area) {
        final Area A = (Area) ticking;
        if ((!anyWetWeather(A.getClimateObj().weatherType(null)))
            && (!dryWeather(A.getClimateObj().weatherType(null)))) {
          for (final Enumeration<Room> e = A.getProperMap(); e.hasMoreElements(); ) {
            final Room R = e.nextElement();
            if (((R.domainType() & Room.INDOORS) == 0)
                && (R.domainType() != Room.DOMAIN_OUTDOORS_AIR)
                && (!CMLib.flags().isWateryRoom(R))
                && (CMLib.dice().rollPercentage() < pct()))
              makePuddle(R, lastWeather, A.getClimateObj().weatherType(null));
          }
        }
      }
    }

    if (ticking instanceof Room)
      lastWeather = ((Room) ticking).getArea().getClimateObj().weatherType((Room) ticking);
    else if (ticking instanceof Area)
      lastWeather = ((Area) ticking).getClimateObj().weatherType(null);
    return true;
  }
Пример #4
0
  @Override
  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;
    Room R = CMLib.map().roomLocation(target);
    if (R == null) R = mob.location();

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

    if ((auto) && (givenTarget != null) && (givenTarget instanceof MOB)) target = (MOB) givenTarget;
    // now see if it worked
    final boolean success = proficiencyCheck(mob, 0, auto);

    if (success) {
      final CMMsg msg =
          CMClass.getMsg(
              mob,
              target,
              this,
              somanticCastCode(mob, target, auto),
              auto ? "" : L("^S<S-NAME> speak(s) and gesture(s) to <T-NAMESELF>.^?"));
      if (R.okMessage(mob, msg)) {
        R.send(mob, msg);
        R.show(target, null, CMMsg.MSG_OK_VISUAL, L("<S-NAME> seem(s) much more likeable!"));
        beneficialAffect(mob, target, asLevel, 0);
      }
    } else
      return beneficialVisualFizzle(
          mob,
          target,
          L("<S-NAME> incant(s) gracefully to <T-NAMESELF>, but nothing more happens."));

    // return whether it worked
    return success;
  }
Пример #5
0
  public void recursiveDropMOB(MOB mob, Room room, Item thisContainer, boolean bodyFlag) {
    // caller is responsible for recovering any env
    // stat changes!

    if (CMLib.flags().isHidden(thisContainer))
      thisContainer
          .baseEnvStats()
          .setDisposition(
              thisContainer.baseEnvStats().disposition()
                  & ((int) EnvStats.ALLMASK - EnvStats.IS_HIDDEN));
    mob.delInventory(thisContainer);
    thisContainer.unWear();
    if (!bodyFlag) bodyFlag = (thisContainer instanceof DeadBody);
    if (bodyFlag) {
      room.addItem(thisContainer);
      thisContainer.setExpirationDate(0);
    } else room.addItemRefuse(thisContainer, CMProps.getIntVar(CMProps.SYSTEMI_EXPIRE_PLAYER_DROP));
    thisContainer.recoverEnvStats();
    boolean nothingDone = true;
    do {
      nothingDone = true;
      for (int i = 0; i < mob.inventorySize(); i++) {
        Item thisItem = mob.fetchInventory(i);
        if ((thisItem != null) && (thisItem.container() == thisContainer)) {
          recursiveDropMOB(mob, room, thisItem, bodyFlag);
          nothingDone = false;
          break;
        }
      }
    } while (!nothingDone);
  }
Пример #6
0
 @Override
 public void executeMsg(final Environmental myHost, final CMMsg msg) {
   super.executeMsg(myHost, msg);
   if (((msg.sourceMinor() == CMMsg.TYP_SHUTDOWN)
           || ((msg.targetMinor() == CMMsg.TYP_EXPIRE) && (msg.target() == affected))
           || (msg.sourceMinor() == CMMsg.TYP_ROOMRESET))
       && (affected instanceof Room)) {
     updateLot(null);
     final Vector mobs = new Vector();
     Room R = (Room) affected;
     if (R != null) {
       synchronized (("SYNC" + R.roomID()).intern()) {
         R = CMLib.map().getRoom(R);
         for (int m = 0; m < R.numInhabitants(); m++) {
           final MOB M = R.fetchInhabitant(m);
           if ((M != null)
               && (M.isSavable())
               && (M.getStartRoom() == R)
               && ((M.basePhyStats().rejuv() == 0)
                   || (M.basePhyStats().rejuv() == PhyStats.NO_REJUV))) {
             CMLib.catalog().updateCatalogIntegrity(M);
             mobs.addElement(M);
           }
         }
         if (!CMSecurity.isSaveFlag(CMSecurity.SaveFlag.NOPROPERTYMOBS))
           CMLib.database().DBUpdateTheseMOBs(R, mobs);
       }
     }
   }
 }
Пример #7
0
 /** codes: -1=do nothing, 1=wind, 2=rain, 4=hot, 8=cold, 16=calm */
 public int weatherQue(Room R) {
   if (R == null) return WEATHERQUE_NADA;
   if ((R.domainType() & Room.INDOORS) > 0) return WEATHERQUE_NADA;
   switch (R.getArea().getClimateObj().weatherType(R)) {
     case Climate.WEATHER_BLIZZARD:
     case Climate.WEATHER_THUNDERSTORM:
     case Climate.WEATHER_HEAT_WAVE:
       return WEATHERQUE_NADA;
     case Climate.WEATHER_CLEAR:
       return WEATHERQUE_WIND | WEATHERQUE_RAIN | WEATHERQUE_HOT | WEATHERQUE_COLD;
     case Climate.WEATHER_CLOUDY:
       return WEATHERQUE_WIND | WEATHERQUE_RAIN;
     case Climate.WEATHER_DROUGHT:
       return WEATHERQUE_RAIN | WEATHERQUE_COLD;
     case Climate.WEATHER_DUSTSTORM:
       return WEATHERQUE_RAIN | WEATHERQUE_CALM | WEATHERQUE_COLD;
     case Climate.WEATHER_HAIL:
       return WEATHERQUE_HOT | WEATHERQUE_CALM;
     case Climate.WEATHER_RAIN:
       return WEATHERQUE_WIND | WEATHERQUE_RAIN;
     case Climate.WEATHER_SLEET:
       return WEATHERQUE_HOT;
     case Climate.WEATHER_SNOW:
       return WEATHERQUE_WIND;
     case Climate.WEATHER_WINDY:
       return WEATHERQUE_RAIN;
     case Climate.WEATHER_WINTER_COLD:
       return WEATHERQUE_RAIN;
     default:
       return WEATHERQUE_CALM;
   }
 }
Пример #8
0
 @Override
 protected Item buildMyPlant(MOB mob, Room room) {
   final int code = material & RawMaterial.RESOURCE_MASK;
   final Item newItem = CMClass.getBasicItem("GenItem");
   final String name =
       CMLib.english().startWithAorAn(RawMaterial.CODES.NAME(code).toLowerCase() + " tree");
   newItem.setName(name);
   newItem.setDisplayText(L("@x1 grows here.", newItem.name()));
   newItem.setDescription("");
   newItem.basePhyStats().setWeight(10000);
   CMLib.flags().setGettable(newItem, false);
   newItem.setMaterial(material);
   newItem.setSecretIdentity(mob.Name());
   newItem.setMiscText(newItem.text());
   room.addItem(newItem);
   final Chant_SummonTree newChant = new Chant_SummonTree();
   newItem.basePhyStats().setLevel(10 + newChant.getX1Level(mob));
   newItem.setExpirationDate(0);
   room.showHappens(
       CMMsg.MSG_OK_ACTION,
       L("a tall, healthy @x1 tree sprouts up.", RawMaterial.CODES.NAME(code).toLowerCase()));
   room.recoverPhyStats();
   newChant.plantsLocationR = room;
   newChant.littlePlantsI = newItem;
   if (CMLib.law().doesOwnThisLand(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;
 }
Пример #9
0
 public void reloadCharClasses(CharClass oldC) {
   for (Enumeration e = CMLib.map().rooms(); e.hasMoreElements(); ) {
     Room room = (Room) e.nextElement();
     for (int i = 0; i < room.numInhabitants(); i++) {
       MOB M = room.fetchInhabitant(i);
       if (M == null) continue;
       for (int c = 0; c < M.baseCharStats().numClasses(); c++)
         if (M.baseCharStats().getMyClass(c) == oldC) {
           M.baseCharStats().setMyClasses(M.baseCharStats().getMyClassesStr());
           break;
         }
       for (int c = 0; c < M.charStats().numClasses(); c++)
         if (M.charStats().getMyClass(c) == oldC) {
           M.charStats().setMyClasses(M.charStats().getMyClassesStr());
           break;
         }
     }
     for (e = CMLib.players().players(); e.hasMoreElements(); ) {
       MOB M = (MOB) e.nextElement();
       for (int c = 0; c < M.baseCharStats().numClasses(); c++)
         if (M.baseCharStats().getMyClass(c) == oldC) {
           M.baseCharStats().setMyClasses(M.baseCharStats().getMyClassesStr());
           break;
         }
       for (int c = 0; c < M.charStats().numClasses(); c++)
         if (M.charStats().getMyClass(c) == oldC) {
           M.charStats().setMyClasses(M.charStats().getMyClassesStr());
           break;
         }
     }
   }
 }
Пример #10
0
 public void makePuddle(Room R, int oldWeather, int newWeather) {
   for (int i = 0; i < R.numItems(); i++) {
     final Item I = R.getItem(i);
     if ((I instanceof Drink)
         && (!CMLib.flags().isGettable(I))
         && ((I.name().toLowerCase().indexOf("puddle") >= 0)
             || (I.name().toLowerCase().indexOf("snow") >= 0))) return;
   }
   final Item I = CMClass.getItem("GenLiquidResource");
   CMLib.flags().setGettable(I, false);
   ((Drink) I).setLiquidHeld(100);
   ((Drink) I).setLiquidRemaining(100);
   ((Drink) I).setLiquidType(RawMaterial.RESOURCE_FRESHWATER);
   I.setMaterial(RawMaterial.RESOURCE_FRESHWATER);
   I.basePhyStats().setDisposition(I.basePhyStats().disposition() | PhyStats.IS_UNSAVABLE);
   CMLib.materials().addEffectsToResource(I);
   I.recoverPhyStats();
   if (coldWetWeather(oldWeather)) {
     I.setName(L("some snow"));
     I.setDisplayText(L("some snow rests on the ground here."));
     I.setDescription(L("the snow is white and still quite cold!"));
   } else {
     I.setName(L("a puddle of water"));
     I.setDisplayText(L("a puddle of water has formed here."));
     I.setDescription(L("It looks drinkable."));
   }
   R.addItem(I, ItemPossessor.Expire.Monster_EQ);
   R.recoverRoomStats();
 }
Пример #11
0
 public Room prepareRoomInDir(Room fromRoom, int direction) {
   if (amDestroyed) {
     Room R = CMLib.map().getRoom(roomID());
     if (R != null) return R.prepareRoomInDir(fromRoom, direction);
     return super.prepareRoomInDir(fromRoom, direction);
   }
   return getAltRoomFrom(fromRoom, direction);
 }
Пример #12
0
  @Override
  public boolean invoke(
      MOB mob, List<String> commands, Physical givenTarget, boolean auto, int asLevel) {
    final MOB target = this.getTarget(mob, commands, givenTarget);
    if (target == null) return false;
    final boolean undead = CMLib.flags().isUndead(target);

    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,
              (undead ? 0 : CMMsg.MASK_MALICIOUS) | verbalCastCode(mob, target, auto),
              L(
                      auto
                          ? "A seriously painful burst assaults <T-NAME>."
                          : "^S<S-NAME> "
                              + prayWord(mob)
                              + " for a serious burst of pain at <T-NAMESELF>!^?")
                  + CMLib.protocol().msp("spelldam1.wav", 40));
      final CMMsg msg2 =
          CMClass.getMsg(
              mob,
              target,
              this,
              CMMsg.MSK_CAST_MALICIOUS_VERBAL | CMMsg.TYP_UNDEAD | (auto ? CMMsg.MASK_ALWAYS : 0),
              null);
      final Room R = target.location();
      if ((R != null) && (R.okMessage(mob, msg)) && ((R.okMessage(mob, msg2)))) {
        R.send(mob, msg);
        R.send(mob, msg2);
        if ((msg.value() <= 0) && (msg2.value() <= 0)) {
          final int harming = CMLib.dice().roll(1, adjustedLevel(mob, asLevel) + 6, 4);
          CMLib.combat()
              .postDamage(
                  mob,
                  target,
                  this,
                  harming,
                  CMMsg.MASK_ALWAYS | CMMsg.TYP_UNDEAD,
                  Weapon.TYPE_BURSTING,
                  L("The unholy spell <DAMAGE> <T-NAME>!"));
        }
      }
    } else
      return maliciousFizzle(
          mob,
          target,
          L("<S-NAME> point(s) at <T-NAMESELF> and @x1, but nothing happens.", prayWord(mob)));

    // return whether it worked
    return success;
  }
Пример #13
0
  @Override
  public boolean invoke(MOB mob, Vector commands, Physical givenTarget, boolean auto, int asLevel) {
    if (!super.invoke(mob, commands, givenTarget, auto, asLevel)) return false;

    final boolean success = proficiencyCheck(mob, 0, auto);
    final String str =
        auto
            ? L("The unholy word is spoken.")
            : L("^S<S-NAME> speak(s) the unholy word@x1 to <T-NAMESELF>.^?", ofDiety(mob));

    final Room room = mob.location();
    if (room != null)
      for (int i = 0; i < room.numInhabitants(); i++) {
        final MOB target = room.fetchInhabitant(i);
        if (target == null) break;
        int affectType = CMMsg.MSG_CAST_VERBAL_SPELL;
        if (auto) affectType = affectType | CMMsg.MASK_ALWAYS;
        if (CMLib.flags().isGood(target)) affectType = affectType | CMMsg.MASK_MALICIOUS;

        if (success) {
          final CMMsg msg = CMClass.getMsg(mob, target, this, affectType, str);
          if (room.okMessage(mob, msg)) {
            room.send(mob, msg);
            if (msg.value() <= 0) {
              if (CMLib.flags().canBeHeardSpeakingBy(mob, target)) {
                final Item I = Prayer_Curse.getSomething(mob, true);
                if (I != null) {
                  Prayer_Curse.endLowerBlessings(I, CMLib.ableMapper().lowestQualifyingLevel(ID()));
                  I.recoverPhyStats();
                }
                Prayer_Curse.endLowerBlessings(
                    target, CMLib.ableMapper().lowestQualifyingLevel(ID()));
                beneficialAffect(mob, target, asLevel, 0);
                target.recoverPhyStats();
              } else if (CMath.bset(affectType, CMMsg.MASK_MALICIOUS))
                maliciousFizzle(mob, target, L("<T-NAME> did not hear the unholy word!"));
              else beneficialWordsFizzle(mob, target, L("<T-NAME> did not hear the unholy word!"));
            }
          }
        } else {
          if (CMath.bset(affectType, CMMsg.MASK_MALICIOUS))
            maliciousFizzle(
                mob,
                target,
                L("<S-NAME> attempt(s) to speak the unholy word to <T-NAMESELF>, but flub(s) it."));
          else
            beneficialWordsFizzle(
                mob,
                target,
                L("<S-NAME> attempt(s) to speak the unholy word to <T-NAMESELF>, but flub(s) it."));
          return false;
        }
      }

    // return whether it worked
    return success;
  }
Пример #14
0
  public boolean open(
      MOB mob, Environmental openThis, String openableWord, int dirCode, boolean quietly) {
    final String openWord = (!(openThis instanceof Exit)) ? "open" : ((Exit) openThis).openWord();
    final String openMsg =
        quietly
            ? null
            : ("<S-NAME> " + openWord + "(s) <T-NAMESELF>.")
                + CMLib.protocol().msp("dooropen.wav", 10);
    final CMMsg msg =
        CMClass.getMsg(mob, openThis, null, CMMsg.MSG_OPEN, openMsg, openableWord, openMsg);
    if (openThis instanceof Exit) {
      final boolean open = ((Exit) openThis).isOpen();
      if ((mob.location().okMessage(msg.source(), msg)) && (!open)) {
        mob.location().send(msg.source(), msg);

        if (dirCode < 0)
          for (int d = Directions.NUM_DIRECTIONS() - 1; d >= 0; d--)
            if (mob.location().getExitInDir(d) == openThis) {
              dirCode = d;
              break;
            }
        if ((dirCode >= 0) && (mob.location().getRoomInDir(dirCode) != null)) {
          final Room opR = mob.location().getRoomInDir(dirCode);
          final Exit opE = mob.location().getPairedExit(dirCode);
          if (opE != null) {
            final CMMsg altMsg =
                CMClass.getMsg(
                    msg.source(),
                    opE,
                    msg.tool(),
                    msg.sourceCode(),
                    null,
                    msg.targetCode(),
                    null,
                    msg.othersCode(),
                    null);
            opE.executeMsg(msg.source(), altMsg);
          }
          final int opCode = Directions.getOpDirectionCode(dirCode);
          if ((opE != null) && (opE.isOpen()) && (((Exit) openThis).isOpen())) {
            final boolean useShipDirs =
                (opR instanceof BoardableShip) || (opR.getArea() instanceof BoardableShip);
            final String inDirName =
                useShipDirs
                    ? Directions.getShipInDirectionName(opCode)
                    : Directions.getInDirectionName(opCode);
            opR.showHappens(CMMsg.MSG_OK_ACTION, L("@x1 @x2 opens.", opE.name(), inDirName));
          }
          return true;
        }
      }
    } else if (mob.location().okMessage(mob, msg)) {
      mob.location().send(mob, msg);
      return true;
    }
    return false;
  }
Пример #15
0
 protected MOB getCharmer() {
   if (charmer != null) return charmer;
   if ((invoker != null) && (invoker != affected)) charmer = invoker;
   else if ((text().length() > 0) && (affected instanceof MOB)) {
     final Room R = ((MOB) affected).location();
     if (R != null) charmer = R.fetchInhabitant(text());
   }
   if (charmer == null) return invoker;
   return charmer;
 }
Пример #16
0
 @Override
 public String runMacro(HTTPRequest httpReq, String parm, HTTPResponse httpResp) {
   final String last = httpReq.getUrlParameter("ROOM");
   if (last == null) return " @break@";
   if (last.length() > 0) {
     final Room R = MUDGrinder.getRoomObject(httpReq, last);
     if (R != null) return clearWebMacros(R.roomID());
   }
   return "";
 }
Пример #17
0
  @Override
  public boolean invoke(MOB mob, Vector commands, Physical givenTarget, boolean auto, int asLevel) {
    final MOB target = this.getTarget(mob, commands, givenTarget);
    if (target == null) return false;
    Room R = CMLib.map().roomLocation(target);
    if (R == null) R = mob.location();

    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,
              somanticCastCode(mob, target, auto),
              L(
                      auto
                          ? "<T-NAME> <T-IS-ARE> sprayed with acid."
                          : "^S<S-NAME> reach(es) for <T-NAMESELF>, spraying acid all over <T-HIM-HER>!^?")
                  + CMLib.protocol().msp("spelldam1.wav", 40));
      final CMMsg msg2 =
          CMClass.getMsg(
              mob,
              target,
              this,
              CMMsg.MSK_CAST_MALICIOUS_VERBAL | CMMsg.TYP_ACID | (auto ? CMMsg.MASK_ALWAYS : 0),
              null);
      if ((R.okMessage(mob, msg)) && ((R.okMessage(mob, msg2)))) {
        R.send(mob, msg);
        R.send(mob, msg2);
        invoker = mob;
        final int numDice = (adjustedLevel(mob, asLevel) + (2 * super.getX1Level(invoker()))) / 2;
        int damage = CMLib.dice().roll(2, numDice, 1);
        if ((msg2.value() > 0) || (msg.value() > 0))
          damage = (int) Math.round(CMath.div(damage, 2.0));
        CMLib.combat()
            .postDamage(
                mob,
                target,
                this,
                damage,
                CMMsg.MASK_ALWAYS | CMMsg.TYP_ACID,
                Weapon.TYPE_MELTING,
                L("The acid <DAMAGE> <T-NAME>!"));
        maliciousAffect(mob, target, asLevel, 3, -1);
      }
    } else
      return maliciousFizzle(
          mob, target, L("<S-NAME> reach(es) for <T-NAMESELF>, but nothing more happens."));

    return success;
  }
Пример #18
0
 public static boolean shopkeeperMobPresent(Room R) {
   if (R == null) return false;
   MOB M = null;
   for (int i = 0; i < R.numInhabitants(); i++) {
     M = R.fetchInhabitant(i);
     if ((M.getStartRoom() == R)
         && (M.isMonster())
         && (CMLib.coffeeShops().getShopKeeper(M) != null)) return true;
   }
   return false;
 }
Пример #19
0
 @Override
 public boolean tick(Tickable ticking, int tickID) {
   if (!super.tick(ticking, tickID)) return false;
   if (affected == null) return false;
   if (affected instanceof Room) {
     final Room R = (Room) affected;
     if ((R.getArea().getTimeObj().getTODCode() != TimeClock.TimeOfDay.DUSK)
         && (R.getArea().getTimeObj().getTODCode() != TimeClock.TimeOfDay.NIGHT)) unInvoke();
   }
   return true;
 }
Пример #20
0
  @Override
  public boolean invoke(
      MOB mob, List<String> commands, Physical givenTarget, boolean auto, int asLevel) {
    final MOB target = this.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 Room R = target.location();
    if (success) {
      final Prayer_Thunderbolt newOne = (Prayer_Thunderbolt) this.copyOf();
      final CMMsg msg =
          CMClass.getMsg(
              mob,
              target,
              newOne,
              verbalCastCode(mob, target, auto),
              L(
                      auto
                          ? "<T-NAME> is filled with a holy charge!"
                          : "^S<S-NAME> " + prayForWord(mob) + " to strike down <T-NAMESELF>!^?")
                  + CMLib.protocol().msp("lightning.wav", 40));
      final CMMsg msg2 =
          CMClass.getMsg(
              mob,
              target,
              this,
              CMMsg.MSK_CAST_MALICIOUS_VERBAL | CMMsg.TYP_ELECTRIC | (auto ? CMMsg.MASK_ALWAYS : 0),
              null);
      if ((R.okMessage(mob, msg)) && ((R.okMessage(mob, msg2)))) {
        R.send(mob, msg);
        R.send(mob, msg2);
        if ((msg.value() <= 0) && (msg2.value() <= 0)) {
          final int harming =
              CMLib.dice().roll(1, adjustedLevel(mob, asLevel), adjustedLevel(mob, asLevel));
          CMLib.combat()
              .postDamage(
                  mob,
                  target,
                  this,
                  harming,
                  CMMsg.MASK_ALWAYS | CMMsg.TYP_ELECTRIC,
                  Weapon.TYPE_STRIKING,
                  L("^SThe STRIKE of @x1 <DAMAGES> <T-NAME>!^?", hisHerDiety(mob)));
        }
      }
    } else
      return maliciousFizzle(mob, target, L("<S-NAME> @x1, but nothing happens.", prayWord(mob)));

    // return whether it worked
    return success;
  }
Пример #21
0
  @Override
  public void unInvoke() {
    // undo the affects of this spell
    if ((affected == null) || (!(affected instanceof Room))) return;
    final Room R = (Room) affected;

    super.unInvoke();

    if (canBeUninvoked())
      R.showHappens(CMMsg.MSG_OK_VISUAL, L("The harmful aura around you fades."));
  }
Пример #22
0
 @Override
 public void unInvoke() {
   // undo the affects of this spell
   if (affected == null) return;
   if (canBeUninvoked()) {
     final Room R = CMLib.map().roomLocation(affected);
     if ((R != null) && (CMLib.flags().isInTheGame(affected, true)))
       R.showHappens(CMMsg.MSG_OK_VISUAL, L("The piercing moon sets."));
   }
   super.unInvoke();
 }
Пример #23
0
  protected boolean canFallFrom(Room fromHere, int direction) {
    if ((fromHere == null) || (direction < 0) || (direction >= Directions.NUM_DIRECTIONS()))
      return false;

    final Room toHere = fromHere.getRoomInDir(direction);
    if ((toHere == null)
        || (fromHere.getExitInDir(direction) == null)
        || (!fromHere.getExitInDir(direction).isOpen())) return false;
    if (CMLib.flags().isWaterySurfaceRoom(fromHere) && CMLib.flags().isUnderWateryRoom(toHere))
      return false;
    return true;
  }
Пример #24
0
 public void destroy() {
   super.destroy();
   Room R = null;
   for (int i = rooms.size() - 1; i >= 0; i--) {
     R = (Room) rooms.elementAt(i, 1);
     if (R != null) R.destroy();
   }
   rooms.clear();
   descriptions = new Vector(1);
   displayTexts = new Vector(1);
   gridexits = new Vector(1);
 }
  @Override
  public boolean okMessage(final Environmental myHost, final CMMsg msg) {
    if (affected == null) return super.okMessage(myHost, msg);

    if (affected instanceof MOB) {
      final MOB mob = (MOB) affected;
      if ((msg.amITarget(mob))
          && (!msg.amISource(mob))
          && (mob.location() != msg.source().location())
          && (msg.tool() instanceof Ability)
          && (CMath.bset(((Ability) msg.tool()).flags(), Ability.FLAG_TRANSPORTING))
          && (!mob.amDead())) {
        final Ability A = (Ability) msg.tool();
        if (((A.classificationCode() & Ability.ALL_ACODES) == Ability.ACODE_CHANT)
            || ((A.classificationCode() & Ability.ALL_ACODES) == Ability.ACODE_SPELL)
            || ((A.classificationCode() & Ability.ALL_ACODES) == Ability.ACODE_PRAYER)
            || ((A.classificationCode() & Ability.ALL_ACODES) == Ability.ACODE_SONG))
          msg.source()
              .location()
              .showHappens(
                  CMMsg.MSG_OK_VISUAL, L("Magical energy fizzles and is absorbed into the air!"));
        return false;
      }
    } else if (affected instanceof Room) {
      final Room R = (Room) affected;
      if ((msg.tool() instanceof Ability)
          && (msg.source().location() != null)
          && (msg.sourceMinor() != CMMsg.TYP_LEAVE)) {
        final boolean summon = CMath.bset(((Ability) msg.tool()).flags(), Ability.FLAG_SUMMONING);
        final boolean teleport =
            CMath.bset(((Ability) msg.tool()).flags(), Ability.FLAG_TRANSPORTING);
        final boolean shere =
            (msg.source().location() == affected)
                || ((affected instanceof Area)
                    && (((Area) affected).inMyMetroArea(msg.source().location().getArea())));
        if ((!shere)
            && (!summon)
            && (teleport)
            && (!CMLib.law().doesHavePriviledgesHere(msg.source(), R))) {
          if ((msg.source().location() != null) && (msg.source().location() != R))
            msg.source()
                .location()
                .showHappens(
                    CMMsg.MSG_OK_VISUAL, L("Magical energy fizzles and is absorbed into the air!"));
          R.showHappens(
              CMMsg.MSG_OK_VISUAL, L("Magic energy fizzles and is absorbed into the air."));
          return false;
        }
      }
    }
    return super.okMessage(myHost, msg);
  }
Пример #26
0
  @Override
  public boolean tick(Tickable ticking, int tickID) {
    if ((affected == null) || (!(affected instanceof Room))) return super.tick(ticking, tickID);

    if ((--damageTickDown) >= 0) return super.tick(ticking, tickID);
    damageTickDown = 4;

    HashSet H = null;
    if ((invoker() != null) && (invoker().location() == affected)) {
      H = new HashSet();
      invoker().getGroupMembers(H);
    }
    final Room R = (Room) affected;
    for (int i = 0; i < R.numInhabitants(); i++) {
      final MOB M = R.fetchInhabitant(i);
      if ((M != null) && ((H == null) || (!H.contains(M)))) {
        if (invoker() != null) {
          final int harming = CMLib.dice().roll(1, adjustedLevel(invoker(), 0) / 3, 1);
          CMLib.combat()
              .postDamage(
                  invoker(),
                  M,
                  this,
                  harming,
                  CMMsg.MASK_MALICIOUS | CMMsg.TYP_UNDEAD,
                  Weapon.TYPE_BURSTING,
                  L("The unholy aura <DAMAGE> <T-NAME>!"));
        } else {
          final int harming =
              CMLib.dice().roll(1, CMLib.ableMapper().lowestQualifyingLevel(ID()) / 3, 1);
          CMLib.combat()
              .postDamage(
                  M,
                  M,
                  this,
                  harming,
                  CMMsg.MASK_MALICIOUS | CMMsg.TYP_UNDEAD,
                  Weapon.TYPE_BURSTING,
                  L("The unholy aura <DAMAGE> <T-NAME>!"));
        }
        if ((!M.isInCombat())
            && (M.isMonster())
            && (M != invoker)
            && (invoker != null)
            && (M.location() == invoker.location())
            && (M.location().isInhabitant(invoker))
            && (CMLib.flags().canBeSeenBy(invoker, M)))
          CMLib.combat().postAttack(M, invoker, M.fetchWieldedItem());
      }
    }
    return super.tick(ticking, tickID);
  }
Пример #27
0
  public boolean nonIPnonMonsterWithMe(MOB me) {
    if ((me.location() != null) && (me.session() != null)) {
      final Room R = me.location();
      for (int i = 0; i < R.numInhabitants(); i++) {
        final MOB M = R.fetchInhabitant(i);
        if ((M == null) || (M == me)) continue;

        if ((M.session() != null) && (M.session().getAddress().equals(me.session().getAddress())))
          return true;
      }
    }
    return false;
  }
Пример #28
0
 public Set<MOB> getEveryoneHere(MOB spareMe, Room R) {
   final Set<MOB> V = new HashSet<MOB>();
   if (R == null) return V;
   for (int i = 0; i < R.numInhabitants(); i++) {
     final MOB M = R.fetchInhabitant(i);
     if ((spareMe != null) && (spareMe == M)) continue;
     if ((M != null)
         && (!CMSecurity.isAllowed(M, R, CMSecurity.SecFlag.IMMORT))
         && ((mask == null) || (CMLib.masking().maskCheck(mask, M, false)))) V.add(M);
   }
   return V;
   // CMLib.combat().postDeath(null,M,null);
 }
Пример #29
0
 public static void doAnimalFreeingCheck(CharClass C, Environmental host, CMMsg msg) {
   if ((msg.source() != host)
       && (msg.sourceMinor() == CMMsg.TYP_NOFOLLOW)
       && (msg.source().isMonster())
       && (host instanceof MOB)
       && (!((MOB) host).isMonster())
       && (msg.target() == host)
       && (msg.source().getStartRoom() != null)
       && (CMLib.law().isACity(msg.source().getStartRoom().getArea()))
       && (((MOB) host).charStats().getCurrentClass().ID().equals(C.ID()))
       && (CMLib.flags().isAnimalIntelligence(msg.source())
           || msg.source().charStats().getMyRace().racialCategory().equalsIgnoreCase("Vegetation")
           || msg.source()
               .charStats()
               .getMyRace()
               .racialCategory()
               .equalsIgnoreCase("Stone Golem"))
       && (CMLib.flags().flaggedAffects(msg.source(), Ability.FLAG_SUMMONING).size() == 0)
       && (msg.source().location() != null)
       && (!msg.source().amDestroyed())
       && (CMLib.flags().isInTheGame((MOB) host, true))
       && (!CMLib.law().isACity(msg.source().location().getArea()))) {
     Object[] stuff = (Object[]) animalChecking.get(host);
     final Room room = msg.source().location();
     if ((stuff == null)
         || (System.currentTimeMillis() - ((Long) stuff[0]).longValue()
             > (room.getArea().getTimeObj().getDaysInMonth()
                 * room.getArea().getTimeObj().getHoursInDay()
                 * CMProps.getMillisPerMudHour()))) {
       stuff = new Object[3];
       stuff[0] = Long.valueOf(System.currentTimeMillis());
       animalChecking.remove(host);
       animalChecking.put(host, stuff);
       stuff[1] = Integer.valueOf(0);
       stuff[2] = new Vector();
     }
     if ((((Integer) stuff[1]).intValue() < 19)
         && (!((List) stuff[2]).contains("" + msg.source()))) {
       stuff[1] = Integer.valueOf(((Integer) stuff[1]).intValue() + 1);
       ((MOB) host)
           .tell(
               CMLib.lang()
                   .L(
                       "You have freed @x1 from @x2.",
                       msg.source().name((MOB) host),
                       (msg.source().getStartRoom().getArea().name())));
       CMLib.leveler()
           .postExperience((MOB) host, null, null, ((Integer) stuff[1]).intValue(), false);
     }
   }
 }
Пример #30
0
 public void swapRaces(Race newR, Race oldR) {
   for (Enumeration e = CMLib.map().rooms(); e.hasMoreElements(); ) {
     Room room = (Room) e.nextElement();
     for (int i = 0; i < room.numInhabitants(); i++) {
       MOB M = room.fetchInhabitant(i);
       if (M == null) continue;
       if (M.baseCharStats().getMyRace() == oldR) M.baseCharStats().setMyRace(newR);
       if (M.charStats().getMyRace() == oldR) M.charStats().setMyRace(newR);
     }
     for (e = CMLib.players().players(); e.hasMoreElements(); ) {
       MOB M = (MOB) e.nextElement();
       if (M.baseCharStats().getMyRace() == oldR) M.baseCharStats().setMyRace(newR);
       if (M.charStats().getMyRace() == oldR) M.charStats().setMyRace(newR);
     }
   }
 }