Ejemplo n.º 1
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;
  }
Ejemplo n.º 2
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;
   }
 }
Ejemplo n.º 3
0
 public static void colorForSale(Room R, boolean rental, boolean reset) {
   synchronized (("SYNC" + R.roomID()).intern()) {
     R = CMLib.map().getRoom(R);
     final String theStr = rental ? RENTSTR : SALESTR;
     final String otherStr = rental ? SALESTR : RENTSTR;
     int x = R.description().indexOf(otherStr);
     while (x >= 0) {
       R.setDescription(R.description().substring(0, x));
       CMLib.database().DBUpdateRoom(R);
       x = R.description().indexOf(otherStr);
     }
     final String oldDescription = R.description();
     x = R.description().indexOf(theStr.trim());
     if ((x < 0)
         || (reset
             && (!R.displayText()
                 .equals(CMath.bset(R.domainType(), Room.INDOORS) ? INDOORSTR : OUTDOORSTR)))) {
       if (reset) {
         R.setDescription("");
         R.setDisplayText(CMath.bset(R.domainType(), Room.INDOORS) ? INDOORSTR : OUTDOORSTR);
         x = -1;
       }
       if (x < 0) R.setDescription(R.description() + theStr);
       else if (!reset) R.setDescription(R.description().substring(0, x + theStr.trim().length()));
       if (!R.description().equals(oldDescription)) CMLib.database().DBUpdateRoom(R);
     } else {
       R.setDescription(R.description().substring(0, x + theStr.trim().length()));
       if (!R.description().equals(oldDescription)) CMLib.database().DBUpdateRoom(R);
     }
     Item I = R.findItem(null, "$id$");
     if ((I == null) || (!I.ID().equals("GenWallpaper"))) {
       I = CMClass.getItem("GenWallpaper");
       CMLib.flags().setReadable(I, true);
       I.setName(("id"));
       I.setReadableText(CMLib.lang().L("This room is " + CMLib.map().getExtendedRoomID(R)));
       I.setDescription(CMLib.lang().L("This room is @x1", CMLib.map().getExtendedRoomID(R)));
       R.addItem(I);
       CMLib.database().DBUpdateItems(R);
     }
   }
 }
Ejemplo n.º 4
0
 @Override
 public int castingQuality(MOB mob, Physical target) {
   if (mob != null) {
     final Room R = mob.location();
     if ((R != null) && (!R.getArea().getClimateObj().canSeeTheMoon(R, null))) {
       if ((R.getArea().getTimeObj().getTODCode() != TimeClock.TimeOfDay.DUSK)
           && (R.getArea().getTimeObj().getTODCode() != TimeClock.TimeOfDay.NIGHT))
         return Ability.QUALITY_INDIFFERENT;
       if ((R.domainType() & Room.INDOORS) > 0) return Ability.QUALITY_INDIFFERENT;
       if (R.fetchEffect(ID()) != null) return Ability.QUALITY_INDIFFERENT;
       return super.castingQuality(mob, target, Ability.QUALITY_BENEFICIAL_SELF);
     }
   }
   return super.castingQuality(mob, target);
 }
Ejemplo n.º 5
0
  @Override
  public boolean invoke(MOB mob, Vector commands, Physical givenTarget, boolean auto, int asLevel) {
    final Room target = mob.location();
    if (target == null) return false;
    if ((target.getArea().getTimeObj().getTODCode() != TimeClock.TimeOfDay.DUSK)
        && (target.getArea().getTimeObj().getTODCode() != TimeClock.TimeOfDay.NIGHT)) {
      mob.tell(L("You can only start this chant at night."));
      return false;
    }
    if ((target.domainType() & Room.INDOORS) > 0) {
      mob.tell(L("This chant only works outdoors."));
      return false;
    }

    if (target.fetchEffect(ID()) != null) {
      mob.tell(L("This place is already under the piercing moon."));
      return false;
    }

    if (!super.invoke(mob, commands, givenTarget, auto, asLevel)) return false;
    final boolean success = proficiencyCheck(mob, 0, auto);

    if (success) {
      invoker = mob;
      final CMMsg msg =
          CMClass.getMsg(
              mob,
              target,
              this,
              verbalCastCode(mob, target, auto),
              auto ? "" : L("^S<S-NAME> chant(s) to the sky.^?"));
      if (mob.location().okMessage(mob, msg)) {
        mob.location().send(mob, msg);
        if (msg.value() <= 0) {
          if (!mob.location().getArea().getClimateObj().canSeeTheStars(mob.location()))
            mob.location()
                .showHappens(CMMsg.MSG_OK_VISUAL, L("The Moon pierces through the clouds!"));
          else mob.location().showHappens(CMMsg.MSG_OK_VISUAL, L("The Moon brightens!"));
          beneficialAffect(mob, target, asLevel, 0);
        }
      }
    } else
      return maliciousFizzle(mob, target, L("<S-NAME> chant(s) to the sky, but the magic fades."));
    // return whether it worked
    return success;
  }
Ejemplo n.º 6
0
 protected boolean isAirRoom(Room R) {
   if (R == null) return false;
   if ((R.domainType() == Room.DOMAIN_INDOORS_AIR) || (R.domainType() == Room.DOMAIN_OUTDOORS_AIR))
     return true;
   return false;
 }
Ejemplo n.º 7
0
  @Override
  public boolean invoke(MOB mob, Vector commands, Physical givenTarget, boolean auto, int asLevel) {

    if ((auto || mob.isMonster())
        && ((commands.size() < 1) || (((String) commands.firstElement()).equals(mob.name())))) {
      commands.clear();
      if (mob.numItems() > 0) commands.addElement(mob.getRandomItem());
      commands.addElement(CMLib.map().getRandomArea().Name());
    }
    final Room oldRoom = mob.location();
    if (commands.size() < 2) {
      mob.tell(L("Teleport what object to what place or person?"));
      return false;
    }
    final String objectName = (String) commands.firstElement();
    final Item target = mob.findItem(null, objectName);
    if (target == null) {
      mob.tell(L("You don't seem to have an item '@x1'.", objectName));
      return false;
    }
    if (target.amWearingAt(Wearable.IN_INVENTORY)) {
      mob.tell(L("You seem to be wearing or holding the item '@x1'.", objectName));
      return false;
    }
    String searchWhat = null;
    if (commands.size() > 2) {
      final String s = (String) commands.elementAt(1);
      if (s.equalsIgnoreCase("room")) searchWhat = "R";
      if (s.equalsIgnoreCase("area")) searchWhat = "E";
      if (s.equalsIgnoreCase("mob")) searchWhat = "M";
      if (s.equalsIgnoreCase("monster")) searchWhat = "M";
      if (s.equalsIgnoreCase("player")) searchWhat = "P";
      if (s.equalsIgnoreCase("user")) searchWhat = "P";
      if (s.equalsIgnoreCase("item")) searchWhat = "I";
      if (s.equalsIgnoreCase("object")) searchWhat = "I";
      if (searchWhat != null) commands.removeElementAt(1);
    }
    if (searchWhat == null) searchWhat = "ERIPM";
    final String destinationString = CMParms.combine(commands, 1).trim().toUpperCase();
    final List<Room> candidates =
        CMLib.map().findWorldRoomsLiberally(mob, destinationString, searchWhat, 10, 600000);
    if (candidates.size() == 0) {
      mob.tell(L("You don't know of a place called '@x1'.", destinationString.toLowerCase()));
      return false;
    }

    if (CMLib.flags().isSitting(mob) || CMLib.flags().isSleeping(mob)) {
      mob.tell(L("You need to stand up!"));
      return false;
    }

    Room newRoom = null;
    int tries = 0;
    while ((tries < 20) && (newRoom == null)) {
      newRoom = candidates.get(CMLib.dice().roll(1, candidates.size(), -1));
      if (((newRoom.roomID().length() == 0) && (CMLib.dice().rollPercentage() > 50))
          || ((newRoom.domainType() == Room.DOMAIN_OUTDOORS_AIR)
              && (CMLib.dice().rollPercentage() > 10))) {
        newRoom = null;
        continue;
      }
      final CMMsg enterMsg =
          CMClass.getMsg(
              mob,
              newRoom,
              null,
              CMMsg.MSG_ENTER,
              null,
              CMMsg.MSG_ENTER,
              null,
              CMMsg.MSG_ENTER,
              null);
      if (!newRoom.okMessage(mob, enterMsg)) newRoom = null;
      tries++;
    }

    if ((newRoom == null) || (newRoom == oldRoom)) {
      mob.tell(L("Your magic seems unable to send anything there."));
      return false;
    }

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

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

    final CMMsg msg =
        CMClass.getMsg(
            mob,
            target,
            this,
            somanticCastCode(mob, target, auto),
            L("^S<S-NAME> invoke(s) a teleportation spell upon <T-NAME>.^?"));
    if (oldRoom.okMessage(mob, msg)) {
      oldRoom.send(mob, msg);
      newRoom.bringMobHere(mob, false);
      target.unWear();
      success = CMLib.commands().postDrop(mob, target, true, false, false) && (!mob.isMine(target));
      oldRoom.bringMobHere(mob, false);
      if (success) {
        oldRoom.show(mob, target, null, CMMsg.MSG_OK_VISUAL, L("<T-NAME> vanishes!"));
        newRoom.showOthers(
            mob, target, null, CMMsg.MSG_OK_VISUAL, L("<T-NAME> appear(s) out of nowhere!"));
      } else mob.tell(L("Nothing happens."));
    }
    // return whether it worked
    return success;
  }