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
 public boolean okMessage(Environmental myHost, CMMsg msg) {
   if (!super.okMessage(myHost, msg)) return false;
   if (affected == null) return true;
   MOB mob = (MOB) affected;
   if ((msg.amISource(mob))
       && (mob.location() != null)
       && (msg.target() != null)
       && (msg.target() instanceof Room)) {
     if ((msg.sourceMinor() == CMMsg.TYP_ENTER)
         && ((mob.location().domainType() == Room.DOMAIN_OUTDOORS_WATERSURFACE)
             || (mob.location().domainType() == Room.DOMAIN_INDOORS_WATERSURFACE))
         && (msg.target() == mob.location().getRoomInDir(Directions.UP))) {
       msg.source()
           .tell("Your water walking magic prevents you from ascending from the water surface.");
       return false;
     } else if ((msg.sourceMinor() == CMMsg.TYP_LEAVE)
         && (mob.location().domainType() != Room.DOMAIN_OUTDOORS_WATERSURFACE)
         && (mob.location().domainType() != Room.DOMAIN_INDOORS_WATERSURFACE)
         && (msg.tool() != null)
         && (msg.tool() instanceof Exit)) {
       for (int d = Directions.NUM_DIRECTIONS() - 1; d >= 0; d--) {
         Room R = mob.location().getRoomInDir(d);
         if ((R != null)
             && (mob.location().getReverseExit(d) == msg.tool())
             && ((R.domainType() == Room.DOMAIN_OUTDOORS_WATERSURFACE)
                 || (R.domainType() == Room.DOMAIN_INDOORS_WATERSURFACE))) {
           triggerNow = true;
           msg.source().recoverEnvStats();
           return true;
         }
       }
     }
   }
   return true;
 }
Ejemplo n.º 3
0
  public void affectEnvStats(Environmental affected, EnvStats affectableStats) {
    super.affectEnvStats(affected, affectableStats);
    if ((affected instanceof MOB) && (((MOB) affected).location() != null)) {
      MOB mob = (MOB) affected;
      Room room = mob.location();
      int classLevel = mob.charStats().getClassLevel(this);
      if ((CMLib.flags().isHidden(mob))
          && (classLevel >= 30)
          && ((room.domainType() & Room.INDOORS) == 0)
          && (room.domainType() != Room.DOMAIN_OUTDOORS_CITY))
        affectableStats.setDisposition(affectableStats.disposition() | EnvStats.IS_NOT_SEEN);

      if (classLevel >= 5) {
        if (CMLib.flags().isInDark(room))
          affectableStats.setAttackAdjustment(
              affectableStats.attackAdjustment() - ((classLevel / 5) + 1));
        else if ((room.domainType() & Room.INDOORS) == 0)
          switch (room.getArea().getClimateObj().weatherType(room)) {
            case Climate.WEATHER_BLIZZARD:
            case Climate.WEATHER_CLOUDY:
            case Climate.WEATHER_DUSTSTORM:
            case Climate.WEATHER_HAIL:
            case Climate.WEATHER_RAIN:
            case Climate.WEATHER_SLEET:
            case Climate.WEATHER_SNOW:
            case Climate.WEATHER_THUNDERSTORM:
              break;
            default:
              affectableStats.setAttackAdjustment(
                  affectableStats.attackAdjustment() + ((classLevel / 5) + 1));
              break;
          }
      }
    }
  }
Ejemplo n.º 4
0
 public boolean isGoodSafehouse(Room target) {
   if (target == null) return false;
   if ((target.domainType() == Room.DOMAIN_INDOORS_WOOD)
       || (target.domainType() == Room.DOMAIN_INDOORS_STONE))
     for (int d = Directions.NUM_DIRECTIONS() - 1; d >= 0; d--) {
       Room R = target.getRoomInDir(d);
       if ((R != null) && (R.domainType() == Room.DOMAIN_OUTDOORS_CITY)) return true;
     }
   return false;
 }
Ejemplo n.º 5
0
 public void affectCharState(MOB affected, CharState affectableState) {
   super.affectCharState(affected, affectableState);
   if (affected.location() != null) {
     Room room = affected.location();
     if (affected.charStats().getClassLevel(this) >= 5) {
       if (CMLib.flags().isInDark(room)) {
         affectableState.setMana(affectableState.getMana() - (affectableState.getMana() / 4));
         affectableState.setMovement(
             affectableState.getMovement() - (affectableState.getMovement() / 4));
       } else if ((room.domainType() & Room.INDOORS) == 0)
         switch (room.getArea().getClimateObj().weatherType(room)) {
           case Climate.WEATHER_BLIZZARD:
           case Climate.WEATHER_CLOUDY:
           case Climate.WEATHER_DUSTSTORM:
           case Climate.WEATHER_HAIL:
           case Climate.WEATHER_RAIN:
           case Climate.WEATHER_SLEET:
           case Climate.WEATHER_SNOW:
           case Climate.WEATHER_THUNDERSTORM:
             break;
           default:
             affectableState.setMana(affectableState.getMana() + (affectableState.getMana() / 4));
             affectableState.setMovement(
                 affectableState.getMovement() + (affectableState.getMovement() / 4));
             break;
         }
     }
   }
 }
Ejemplo n.º 6
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.º 7
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.º 8
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.º 9
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.º 10
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 Vector V = new Vector();
    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);
    CMLib.tracking()
        .getRadiantRooms(mob.location(), V, flags, null, adjustedLevel(mob, asLevel), null);
    for (int v = V.size() - 1; v >= 0; v--) {
      final Room R = (Room) V.elementAt(v);
      if ((R.domainType() != Room.DOMAIN_INDOORS_CAVE) || (R == mob.location()))
        V.removeElementAt(v);
    }
    if (V.size() > 0) {
      mob.location()
          .show(
              mob,
              null,
              CMMsg.MASK_ALWAYS | CMMsg.TYP_NOISE,
              L("The faint sound of fungus popping into existence can be heard."));
      int done = 0;
      for (int v = 0; v < V.size(); v++) {
        final Room R = (Room) V.elementAt(v);
        if (R == mob.location()) continue;
        buildMyThing(mob, R);
        if ((done++) == adjustedLevel(mob, asLevel)) break;
      }
    }

    return true;
  }
Ejemplo n.º 11
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.º 12
0
  public boolean invoke(
      MOB mob, Vector commands, Environmental givenTarget, boolean auto, int asLevel) {

    if (commands.size() < 1) {
      mob.tell("Create overgrowth where?");
      return false;
    }

    String areaName = CMParms.combine(commands, 0).trim().toUpperCase();
    Room anyRoom = null;
    Room newRoom = null;
    try {
      Vector rooms = CMLib.map().findRooms(CMLib.map().rooms(), mob, areaName, true, 10);
      for (Enumeration r = rooms.elements(); r.hasMoreElements(); ) {
        Room R = (Room) r.nextElement();
        anyRoom = R;
        if ((R.domainType() & Room.INDOORS) == 0) {
          newRoom = R;
          break;
        }
      }
    } catch (NoSuchElementException e) {
    }

    if (newRoom == null) {
      if (anyRoom == null)
        mob.tell("You don't know of an place called '" + CMParms.combine(commands, 0) + "'.");
      else mob.tell("There IS such a place, but its not outdoors, so your magic would fail.");
      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,
              null,
              this,
              verbalCastCode(mob, null, auto),
              "^S<S-NAME> chant(s) about a far away place.^?");
      if (mob.location().okMessage(mob, msg)) {
        mob.location().send(mob, msg);
        Item newItem = null;
        if (newRoom.domainType() == Room.DOMAIN_INDOORS_CAVE)
          newItem = Chant_SummonFungus.buildFungus(mob, newRoom);
        else if ((newRoom.domainType() == Room.DOMAIN_OUTDOORS_UNDERWATER)
            || (newRoom.domainType() == Room.DOMAIN_OUTDOORS_WATERSURFACE))
          newItem = Chant_SummonSeaweed.buildSeaweed(mob, newRoom);
        else if ((newRoom.domainType() == Room.DOMAIN_INDOORS_STONE)
            || (newRoom.domainType() == Room.DOMAIN_INDOORS_WOOD))
          newItem = Chant_SummonHouseplant.buildHouseplant(mob, newRoom);
        else newItem = Chant_SummonPlants.buildPlant(mob, newRoom);
        mob.tell("You feel a distant connection with " + newItem.name());
      }
    } else
      beneficialWordsFizzle(
          mob, null, "<S-NAME> chant(s) about a far away place, but the magic fades.");

    // return whether it worked
    return success;
  }
Ejemplo n.º 13
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;
  }