Пример #1
0
 public boolean supportsMending(Physical item) {
   if (!(item instanceof MOB)) return false;
   MOB caster = CMClass.getFactoryMOB();
   caster.basePhyStats().setLevel(CMProps.getIntVar(CMProps.SYSTEMI_LASTPLAYERLEVEL));
   caster.phyStats().setLevel(CMProps.getIntVar(CMProps.SYSTEMI_LASTPLAYERLEVEL));
   boolean canMend = returnOffensiveAffects(caster, item).size() > 0;
   caster.destroy();
   return canMend;
 }
Пример #2
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;
     }
 }
Пример #3
0
  public boolean invoke(MOB mob, Vector commands, Physical givenTarget, boolean auto, int asLevel) {

    int type = mob.location().domainType();
    if (((type & Room.INDOORS) > 0)
        || (type == Room.DOMAIN_OUTDOORS_AIR)
        || (type == Room.DOMAIN_OUTDOORS_CITY)
        || (type == Room.DOMAIN_OUTDOORS_SPACEPORT)
        || (type == Room.DOMAIN_OUTDOORS_UNDERWATER)
        || (type == Room.DOMAIN_OUTDOORS_WATERSURFACE)) {
      mob.tell("That magic won't work 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,
              mob.location(),
              this,
              verbalCastCode(mob, mob.location(), auto),
              auto ? "" : "^S<S-NAME> " + prayForWord(mob) + " to make the land fruitful.^?");
      if (mob.location().okMessage(mob, msg)) {
        mob.location().send(mob, msg);
        beneficialAffect(
            mob,
            mob.location(),
            asLevel,
            CMLib.ableMapper().qualifyingClassLevel(mob, this)
                * (int)
                    ((CMProps.getMillisPerMudHour()
                            * ((long) mob.location().getArea().getTimeObj().getHoursInDay()))
                        / CMProps.getTickMillis()));
      }

    } else
      beneficialWordsFizzle(
          mob,
          null,
          "<S-NAME> " + prayForWord(mob) + " to make the land fruitful, but nothing happens.");

    // return whether it worked
    return success;
  }
Пример #4
0
 public String[] getStatCodes() {
   if (codes != null) return codes;
   String[] MYCODES = CMProps.getStatCodesList(GenDeity.MYCODES, this);
   String[] superCodes = GenericBuilder.GENMOBCODES;
   codes = new String[superCodes.length + MYCODES.length];
   int i = 0;
   for (; i < superCodes.length; i++) codes[i] = superCodes[i];
   for (int x = 0; x < MYCODES.length; i++, x++) codes[i] = MYCODES[x];
   return codes;
 }
Пример #5
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);
   }
 }
Пример #6
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;
 }
Пример #7
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;
     }
 }
Пример #8
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);
   }
 }
Пример #9
0
 public String text() {
   if (CMProps.getBoolVar(CMProps.SYSTEMB_MOBCOMPRESS))
     miscText = CMLib.encoder().compressString(CMLib.coffeeMaker().getPropertiesStr(this, false));
   else miscText = CMLib.coffeeMaker().getPropertiesStr(this, false);
   return super.text();
 }
Пример #10
0
  public boolean invoke(MOB mob, Vector commands, Physical givenTarget, boolean auto, int asLevel) {
    if (!super.invoke(mob, commands, givenTarget, auto, asLevel)) return false;

    Room target = mob.location();
    if ((auto) && (givenTarget != null) && (givenTarget instanceof Room))
      target = (Room) givenTarget;
    Ability A = target.fetchEffect(ID());
    if (A != null) {
      mob.tell("This place is already a safehouse.");
      return false;
    }
    if ((!auto) && (CMLib.law().getLegalBehavior(target) == null)) {
      mob.tell("There is no law here!");
      return false;
    }
    if (!isGoodSafehouse(target)) {
      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);
      List<Room> V =
          CMLib.tracking().getRadiantRooms(target, flags, 50 + (2 * getXLEVELLevel(mob)));
      Room R = null;
      int v = 0;
      for (; v < V.size(); v++) {
        R = (Room) V.get(v);
        if ((isGoodSafehouse(R)) && (!isLawHere(R))) break;
      }
      mob.tell("A place like this can't be a safehouse.");
      if ((isGoodSafehouse(R)) && (!isLawHere(R))) {
        V =
            CMLib.tracking()
                .findBastardTheBestWay(
                    target, new XVector(R), flags, 50 + (2 * getXLEVELLevel(mob)));
        StringBuffer trail = new StringBuffer("");
        int dir = CMLib.tracking().trackNextDirectionFromHere(V, target, true);
        while (target != R) {
          if ((dir < 0) || (dir >= Directions.NUM_DIRECTIONS()) || (target == null)) break;
          trail.append(Directions.getDirectionName(dir));
          if (target.getRoomInDir(dir) != R) trail.append(", ");
          target = target.getRoomInDir(dir);
          dir = CMLib.tracking().trackNextDirectionFromHere(V, target, true);
        }
        if (target == R)
          mob.tell("You happen to know of one nearby though.  Go: " + trail.toString());
      }
      return false;
    }

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

    CMMsg msg =
        CMClass.getMsg(
            mob,
            null,
            this,
            auto ? CMMsg.MASK_ALWAYS : CMMsg.MSG_DELICATE_HANDS_ACT,
            CMMsg.MSG_OK_VISUAL,
            CMMsg.MSG_OK_VISUAL,
            auto ? "" : "<S-NAME> hide(s) out from the law here.");
    if (!success)
      return beneficialVisualFizzle(
          mob,
          null,
          auto
              ? ""
              : "<S-NAME> attempt(s) hide out from the law here, but things are just too hot.");
    else if (mob.location().okMessage(mob, msg)) {
      mob.location().send(mob, msg);
      beneficialAffect(mob, target, asLevel, (CMProps.getIntVar(CMProps.SYSTEMI_TICKSPERMUDMONTH)));
    }
    return success;
  }
Пример #11
0
 public double actionsCost(final MOB mob, final List<String> cmds) {
   return CMProps.getActionCost(ID());
 }
Пример #12
0
  public boolean tick(Tickable ticking, int tickID) {
    int realLastWeather = super.lastWeather;
    if (!super.tick(ticking, tickID)) return false;
    Area A = CMLib.map().areaLocation(ticking);
    if (A == null) return false;
    Climate C = A.getClimateObj();
    if (C == null) return false;
    lastWeather = realLastWeather;

    // handle freeze overs
    if ((coldWeather(lastWeather))
        && (coldWeather(C.weatherType(null)))
        && (lastWeather != C.weatherType(null))
        && (A.getTimeObj().getSeasonCode() == TimeClock.SEASON_WINTER)
        && (CMLib.dice().rollPercentage() < freezeOverChance)) {
      if (ticking instanceof Room) {
        Room R = (Room) ticking;
        if ((R.domainType() == Room.DOMAIN_OUTDOORS_WATERSURFACE)
            && (CMLib.dice().rollPercentage() < freezeOverChance)
            && (R instanceof Drink)
            && (((Drink) R).liquidType() == RawMaterial.RESOURCE_FRESHWATER)) {
          Ability A2 = CMClass.getAbility("Spell_IceSheet");
          if (A2 != null) {
            MOB mob = CMLib.map().getFactoryMOB(R);
            A2.invoke(mob, R, true, 0);
            mob.destroy();
          }
        }
      } else
        for (Enumeration<Room> e = A.getProperMap(); e.hasMoreElements(); ) {
          Room R = (Room) e.nextElement();
          if ((R.domainType() == Room.DOMAIN_OUTDOORS_WATERSURFACE)
              && (CMLib.dice().rollPercentage() < freezeOverChance)) {
            Ability A2 = CMClass.getAbility("Spell_IceSheet");
            if (A2 != null) {
              MOB mob = CMLib.map().getFactoryMOB(R);
              A2.invoke(mob, R, true, 0);
              mob.destroy();
            }
          }
        }
    }
    if ((botherDown--) == 1) {
      resetBotherTicks();
      switch (C.weatherType(null)) {
        case Climate.WEATHER_BLIZZARD:
        case Climate.WEATHER_SLEET:
        case Climate.WEATHER_SNOW:
        case Climate.WEATHER_HAIL:
        case Climate.WEATHER_THUNDERSTORM:
        case Climate.WEATHER_RAIN:
          for (Enumeration<Room> r = A.getProperMap(); r.hasMoreElements(); ) {
            Room R = (Room) r.nextElement();
            if (CMLib.map().hasASky(R))
              for (int i = 0; i < R.numInhabitants(); i++) {
                MOB mob = R.fetchInhabitant(i);
                if ((mob != null)
                    && (!mob.isMonster())
                    && (CMLib.flags().aliveAwakeMobile(mob, true))
                    && (CMath.bset(mob.getBitmap(), MOB.ATT_AUTOWEATHER)))
                  mob.tell(C.getWeatherDescription(A));
              }
          }
          break;
      }
    }
    if ((diseaseDown--) == 1) {
      resetDiseaseTicks();
      int coldChance = 0;
      int fluChance = 0;
      int frostBiteChance = 0;
      int heatExhaustionChance = 0;
      switch (C.weatherType(null)) {
        case Climate.WEATHER_BLIZZARD:
        case Climate.WEATHER_SLEET:
        case Climate.WEATHER_SNOW:
          coldChance = 99;
          fluChance = 25;
          frostBiteChance = 15;
          break;
        case Climate.WEATHER_HAIL:
          coldChance = 50;
          frostBiteChance = 10;
          break;
        case Climate.WEATHER_THUNDERSTORM:
        case Climate.WEATHER_RAIN:
          coldChance = 25;
          break;
        case Climate.WEATHER_WINTER_COLD:
          coldChance = 75;
          fluChance = 10;
          frostBiteChance = 5;
          break;
        case Climate.WEATHER_HEAT_WAVE:
          heatExhaustionChance = 15;
          break;
        case Climate.WEATHER_DROUGHT:
          heatExhaustionChance = 20;
          break;
      }

      for (Session S : CMLib.sessions().localOnlineIterable()) {
        if ((S.mob() == null)
            || (S.mob().location() == null)
            || (S.mob().location().getArea() != A)
            || (S.mob().isMonster())) continue;

        MOB M = S.mob();
        Room R = M.location();

        if ((R.domainConditions() & Room.CONDITION_COLD) > 0) {
          if (coldChance > 0) coldChance += 10;
          if (coldChance > 0) fluChance += 5; // yes, cold is related this way to flu
          if (frostBiteChance > 0)
            frostBiteChance = frostBiteChance + (int) Math.round(CMath.mul(frostBiteChance, 0.5));
        }
        if ((R.domainConditions() & Room.CONDITION_HOT) > 0) {
          if (heatExhaustionChance > 0) heatExhaustionChance += 10;
        }
        if ((R.domainConditions() & Room.CONDITION_WET) > 0) {
          if (coldChance > 0) coldChance += 5;
          if (heatExhaustionChance > 5) heatExhaustionChance -= 5;
          if (frostBiteChance > 0)
            frostBiteChance = frostBiteChance + (int) Math.round(CMath.mul(frostBiteChance, 0.25));
        }
        int save =
            (M.charStats().getSave(CharStats.STAT_SAVE_COLD)
                    + M.charStats().getSave(CharStats.STAT_SAVE_WATER))
                / 2;
        if ((CMLib.dice().rollPercentage() < (coldChance - save))
            && ((C.weatherType(M.location()) != Climate.WEATHER_CLEAR))) {
          long coveredPlaces = 0;
          for (int l = 0; l < ALL_COVERED_SPOTS.length; l++)
            if (M.getWearPositions(ALL_COVERED_SPOTS[l]) == 0)
              coveredPlaces = coveredPlaces | ALL_COVERED_SPOTS[l];
          Item I = null;
          for (int i = 0; i < M.numItems(); i++) {
            I = M.getItem(i);
            if ((I == null) || (I.amWearingAt(Wearable.IN_INVENTORY))) continue;
            if (I.amWearingAt(Wearable.WORN_ABOUT_BODY))
              coveredPlaces = coveredPlaces | Wearable.WORN_TORSO | Wearable.WORN_LEGS;
            for (int l = 0; l < ALL_COVERED_SPOTS.length; l++)
              if (I.amWearingAt(ALL_COVERED_SPOTS[l]))
                coveredPlaces = coveredPlaces | ALL_COVERED_SPOTS[l];
          }
          if ((coveredPlaces != ALL_COVERED_CODE)
              && (!CMSecurity.isDisabled(CMSecurity.DisFlag.AUTODISEASE))) {
            Ability COLD = CMClass.getAbility("Disease_Cold");
            if (CMLib.dice().rollPercentage()
                < (fluChance
                    + (((M.location().domainConditions() & Room.CONDITION_WET) > 0) ? 10 : 0)))
              COLD = CMClass.getAbility("Disease_Flu");
            if ((COLD != null) && (M.fetchEffect(COLD.ID()) == null)) COLD.invoke(M, M, true, 0);
          }
        }
        if ((CMLib.dice().rollPercentage() < (frostBiteChance - save))
            && ((C.weatherType(M.location()) != Climate.WEATHER_CLEAR))) {
          long unfrostedPlaces = 0;
          for (int l = 0; l < ALL_FROST_SPOTS.length; l++)
            if (M.getWearPositions(ALL_FROST_SPOTS[l]) == 0)
              unfrostedPlaces = unfrostedPlaces | ALL_FROST_SPOTS[l];
          Item I = null;
          for (int i = 0; i < M.numItems(); i++) {
            I = M.getItem(i);
            if ((I == null) || (I.amWearingAt(Wearable.IN_INVENTORY))) continue;
            for (int l = 0; l < ALL_FROST_SPOTS.length; l++)
              if (I.amWearingAt(ALL_FROST_SPOTS[l]))
                unfrostedPlaces = unfrostedPlaces | ALL_FROST_SPOTS[l];
          }
          if ((unfrostedPlaces != ALL_FROST_CODE)
              && (!CMSecurity.isDisabled(CMSecurity.DisFlag.AUTODISEASE))) {
            Ability COLD = CMClass.getAbility("Disease_FrostBite");
            if ((COLD != null) && (M.fetchEffect(COLD.ID()) == null)) COLD.invoke(M, M, true, 0);
          }
        }
        if ((heatExhaustionChance > 0)
            && (CMLib.dice().rollPercentage()
                < (heatExhaustionChance - M.charStats().getSave(CharStats.STAT_SAVE_FIRE)))
            && (C.weatherType(M.location()) != Climate.WEATHER_CLEAR)
            && (!CMSecurity.isDisabled(CMSecurity.DisFlag.AUTODISEASE))) {
          Ability COLD = CMClass.getAbility("Disease_HeatExhaustion");
          if ((COLD != null) && (M.fetchEffect(COLD.ID()) == null)) COLD.invoke(M, M, true, 0);
        }
      }
    }
    if ((rumbleDown--) == 1) {
      resetRumbleTicks();
      for (Session S : CMLib.sessions().localOnlineIterable()) {
        if ((S.mob() == null)
            || (S.mob().location() == null)
            || (S.mob().location().getArea() != A)
            || (S.mob().isMonster())
            || (!CMath.bset(S.mob().getBitmap(), MOB.ATT_AUTOWEATHER))) continue;
        Room R = S.mob().location();
        if (R != null) {
          switch (C.weatherType(null)) {
            case Climate.WEATHER_THUNDERSTORM:
              {
                if (C.weatherType(R) != Climate.WEATHER_THUNDERSTORM) {
                  if ((R.domainType() & Room.INDOORS) > 0) {
                    if ((R.getArea() != null)
                        && CMath.div(
                                R.getArea().getAreaIStats()[Area.Stats.INDOOR_ROOMS.ordinal()],
                                R.getArea().properSize())
                            < 0.90)
                      S.mob()
                          .tell(
                              "^JA thunderous rumble and CRACK of lightning can be heard outside.^?"
                                  + CMProps.msp("thunder.wav", 40));
                  } else
                    S.mob()
                        .tell(
                            "^JA thunderous rumble and CRACK of lightning can be heard.^?"
                                + CMProps.msp("thunder.wav", 40));
                } else if (R.getArea().getTimeObj().getTODCode() == TimeClock.TIME_DAY)
                  S.mob()
                      .tell(
                          "^JA thunderous rumble and CRACK of lightning can be heard as the pounding rain soaks you.^?"
                              + CMProps.msp("thunderandrain.wav", 40));
                else
                  S.mob()
                      .tell(
                          "^JA bolt of lightning streaks across the sky as the pounding rain soaks you!^?"
                              + CMProps.msp("thunderandrain.wav", 40));
                break;
              }
            case Climate.WEATHER_BLIZZARD:
              if (C.weatherType(R) == Climate.WEATHER_BLIZZARD)
                S.mob()
                    .tell(
                        "^JSwirling clouds of snow buffet you.^?"
                            + CMProps.msp("blizzard.wav", 40));
              break;
            case Climate.WEATHER_SNOW:
              if (C.weatherType(R) == Climate.WEATHER_SNOW)
                S.mob().tell("^JSnowflakes fall lightly on you.^?");
              break;
            case Climate.WEATHER_DUSTSTORM:
              if (C.weatherType(R) == Climate.WEATHER_DUSTSTORM)
                S.mob()
                    .tell(
                        "^JSwirling clouds of dust assault you.^?" + CMProps.msp("windy.wav", 40));
              break;
            case Climate.WEATHER_HAIL:
              if (C.weatherType(R) == Climate.WEATHER_HAIL)
                S.mob()
                    .tell(
                        "^JYou are being pelleted by hail! Ouch!^?" + CMProps.msp("hail.wav", 40));
              break;
            case Climate.WEATHER_RAIN:
              if (C.weatherType(R) == Climate.WEATHER_RAIN)
                S.mob().tell("^JThe rain is soaking you!^?" + CMProps.msp("rainlong.wav", 40));
              break;
            case Climate.WEATHER_SLEET:
              if (C.weatherType(R) == Climate.WEATHER_SLEET)
                S.mob()
                    .tell(
                        "^JCold and blistering sleet is soaking you numb!^?"
                            + CMProps.msp("rain.wav", 40));
              break;
            case Climate.WEATHER_WINDY:
              if (C.weatherType(R) == Climate.WEATHER_WINDY)
                S.mob().tell("^JThe wind gusts around you.^?" + CMProps.msp("wind.wav", 40));
              break;
          }
        }
      }
    }
    if ((lightningDown--) == 1) {
      resetLightningTicks();
      if (C.weatherType(null) == Climate.WEATHER_THUNDERSTORM) {
        boolean playerAround = false;
        for (Session S : CMLib.sessions().localOnlineIterable()) {
          if ((S.mob() == null)
              || (S.mob().location() == null)
              || (S.mob().location().getArea() != A)
              || (S.mob().isMonster())
              || (C.weatherType(S.mob().location()) != Climate.WEATHER_THUNDERSTORM)) continue;
          playerAround = true;
        }
        if (playerAround) {
          Room R = A.getRandomProperRoom();
          MOB M = R.fetchRandomInhabitant();
          if (M != null) {
            Ability A2 = CMClass.getAbility("Chant_SummonLightning");
            if (A2 != null) {
              A2.setMiscText("RENDER MUNDANE");
              A2.invoke(M, M, true, M.phyStats().level());
            }
          } else R = null;
          Room R2 = null;
          for (Enumeration<Room> e = A.getProperMap(); e.hasMoreElements(); ) {
            R2 = (Room) e.nextElement();
            if ((R2 != R) && (R2.numInhabitants() > 0))
              if ((A.getTimeObj().getTODCode() == TimeClock.TIME_DAY)
                  || (C.weatherType(R2) != Climate.WEATHER_THUNDERSTORM)) {
                if ((R2.domainType() & Room.INDOORS) > 0)
                  R2.showHappens(
                      CMMsg.MSG_OK_ACTION,
                      "^JA thunderous rumble and crack of lightning can be heard outside.^?"
                          + CMProps.msp("thunder2.wav", 40));
                else
                  R2.showHappens(
                      CMMsg.MSG_OK_ACTION,
                      "^JA thunderous rumble and crack of lightning can be heard.^?"
                          + CMProps.msp("thunder2.wav", 40));
              } else
                R2.showHappens(
                    CMMsg.MSG_OK_ACTION,
                    "^JYou hear a thunderous rumble as a bolt of lightning streaks across the sky!^?"
                        + CMProps.msp("thunder3.wav", 40));
          }
        }
      }
    }
    if ((tornadoDown--) == 1) {
      resetTornadoTicks();
      if ((C.weatherType(null) == Climate.WEATHER_THUNDERSTORM)
          || (C.weatherType(null) == Climate.WEATHER_WINDY)) {
        boolean playerAround = false;
        for (Session S : CMLib.sessions().localOnlineIterable()) {
          if ((S.mob() == null)
              || (S.mob().location() == null)
              || (S.mob().location().getArea() != A)
              || (S.mob().isMonster())
              || (C.weatherType(S.mob().location()) != Climate.WEATHER_THUNDERSTORM)) continue;
          playerAround = true;
        }
        if (playerAround) {
          Room R = A.getRandomProperRoom();
          MOB M = R.fetchRandomInhabitant();
          if (M != null) {
            Ability A2 = CMClass.getAbility("Chant_SummonTornado");
            if (A2 != null) {
              A2.setMiscText("RENDER MUNDANE");
              MOB mob = CMLib.map().getFactoryMOB(R);
              A2.invoke(mob, null, true, 0);
              mob.destroy();
            }
          } else R = null;
          Room R2 = null;
          for (Enumeration<Room> e = A.getProperMap(); e.hasMoreElements(); ) {
            R2 = (Room) e.nextElement();
            if ((R2 != R) && (R2.numInhabitants() > 0))
              if ((A.getTimeObj().getTODCode() == TimeClock.TIME_DAY)
                  || (C.weatherType(R2) != Climate.WEATHER_THUNDERSTORM)) {
                if ((R2.domainType() & Room.INDOORS) > 0)
                  R2.showHappens(
                      CMMsg.MSG_OK_ACTION,
                      "^JThe terrible rumble of a tornado can be heard outside.^?"
                          + CMProps.msp("tornado.wav", 40));
                else
                  R2.showHappens(
                      CMMsg.MSG_OK_ACTION,
                      "^JThe terrible rumble of a tornado can be heard.^?"
                          + CMProps.msp("tornado.wav", 40));
              } else
                R2.showHappens(
                    CMMsg.MSG_OK_ACTION,
                    "^JA huge and terrible tornado touches down somewhere near by.^?"
                        + CMProps.msp("tornado.wav", 40));
          }
        }
      }
    }
    if ((dustDown--) == 1) {
      resetDustTicks();
      if (C.weatherType(null) == Climate.WEATHER_DUSTSTORM) {
        Vector choices = new Vector();
        Room R = null;
        for (Session S : CMLib.sessions().localOnlineIterable()) {
          if ((S.mob() == null)
              || (S.mob().location() == null)
              || (S.mob().location().getArea() != A)
              || (S.mob().isMonster())
              || (C.weatherType(S.mob().location()) != Climate.WEATHER_DUSTSTORM)) continue;
          R = S.mob().location();
          if ((R != null) && (!choices.contains(R))) choices.addElement(R);
        }
        if (choices.size() > 0) {
          R = (Room) choices.elementAt(CMLib.dice().roll(1, choices.size(), -1));
          MOB M = R.fetchRandomInhabitant();
          if ((M != null)
              && (C.weatherType(R) == Climate.WEATHER_DUSTSTORM)
              && (!CMLib.flags().isSleeping(M))) {
            Ability A2 = CMClass.getAbility("Skill_Dirt");
            if (A2 != null) A2.invoke(M, M, true, 0);
          }
        }
      }
    }
    if ((hailDown--) == 1) {
      resetHailTicks();
      if (C.weatherType(null) == Climate.WEATHER_HAIL) {
        Vector choices = new Vector();
        Room R = null;
        for (Session S : CMLib.sessions().localOnlineIterable()) {
          if ((S.mob() == null)
              || (S.mob().location() == null)
              || (S.mob().location().getArea() != A)
              || (S.mob().isMonster())
              || (C.weatherType(S.mob().location()) != Climate.WEATHER_HAIL)) continue;
          R = S.mob().location();
          if ((R != null) && (!choices.contains(R))) choices.addElement(R);
        }
        if (choices.size() > 0) {
          R = (Room) choices.elementAt(CMLib.dice().roll(1, choices.size(), -1));
          MOB M = R.fetchRandomInhabitant();
          Ability A2 = CMClass.getAbility("Chant_SummonHail");
          if ((A2 != null) && (C.weatherType(R) == Climate.WEATHER_HAIL)) {
            A2.setMiscText("RENDER MUNDANE");
            A2.invoke(M, M, true, M.phyStats().level());
          }
        }
      }
    }
    if ((C.weatherType(null) == Climate.WEATHER_DROUGHT)
        && (CMLib.dice().rollPercentage() < droughtFireChance)) {
      Room R = CMLib.map().roomLocation((Environmental) ticking);
      if ((R == null) && (ticking instanceof Area)) R = ((Area) ticking).getRandomProperRoom();
      if ((R != null)
          && ((R.domainType() & Room.INDOORS) == 0)
          && (R.domainType() != Room.DOMAIN_OUTDOORS_SWAMP)
          && (R.domainType() != Room.DOMAIN_OUTDOORS_UNDERWATER)
          && (R.domainType() != Room.DOMAIN_OUTDOORS_WATERSURFACE)
          && ((R.domainConditions() & Room.CONDITION_WET) == 0)) {
        Item I = R.getRandomItem();
        if ((I != null) && (CMLib.flags().isGettable(I)))
          switch (I.material() & RawMaterial.MATERIAL_MASK) {
            case RawMaterial.MATERIAL_CLOTH:
            case RawMaterial.MATERIAL_LEATHER:
            case RawMaterial.MATERIAL_PAPER:
            case RawMaterial.MATERIAL_VEGETATION:
            case RawMaterial.MATERIAL_WOODEN:
              {
                Ability A2 = CMClass.getAbility("Burning");
                MOB mob = CMLib.map().getFactoryMOB(R);
                R.showHappens(
                    CMMsg.MSG_OK_VISUAL,
                    I.Name()
                        + " spontaneously combusts in the seering heat!"
                        + CMProps.msp("fire.wav", 40));
                A2.invoke(mob, I, true, 0);
                mob.destroy();
              }
              break;
          }
      }
    }
    if ((gustDown--) == 1) {
      resetGustTicks();
      if ((C.weatherType(null) == Climate.WEATHER_WINDY)
          || (C.weatherType(null) == Climate.WEATHER_BLIZZARD)
          || (C.weatherType(null) == Climate.WEATHER_DUSTSTORM)) {
        Vector choices = new Vector();
        Room R = null;
        for (Session S : CMLib.sessions().localOnlineIterable()) {
          if ((S.mob() == null)
              || (S.mob().location() == null)
              || (S.mob().location().getArea() != A)
              || (S.mob().isMonster())
              || ((C.weatherType(S.mob().location()) != Climate.WEATHER_WINDY)
                  && (C.weatherType(S.mob().location()) != Climate.WEATHER_BLIZZARD)
                  && (C.weatherType(S.mob().location()) != Climate.WEATHER_DUSTSTORM))) continue;
          R = S.mob().location();
          if ((R != null) && (!choices.contains(R))) choices.addElement(R);
        }
        if (choices.size() > 0) {
          R = (Room) choices.elementAt(CMLib.dice().roll(1, choices.size(), -1));
          MOB M = CMLib.map().getFactoryMOB(R);
          Ability A2 = CMClass.getAbility("Chant_WindGust");
          if (A2 != null) {
            A2.setMiscText("RENDER MUNDANE");
            A2.invoke(M, M, true, M.phyStats().level());
          }
          M.destroy();
        }
      }
    }
    if ((rustDown--) == 1) {
      resetRustTicks();
      for (Session S : CMLib.sessions().localOnlineIterable()) {
        if ((S.mob() == null)
            || (S.mob().location() == null)
            || (S.mob().location().getArea() != A)
            || (S.mob().isMonster())) continue;
        int rustChance = 0;
        switch (C.weatherType(S.mob().location())) {
          case Climate.WEATHER_BLIZZARD:
          case Climate.WEATHER_SLEET:
          case Climate.WEATHER_SNOW:
            rustChance = 5;
            break;
          case Climate.WEATHER_HAIL:
            rustChance = 5;
            break;
          case Climate.WEATHER_THUNDERSTORM:
          case Climate.WEATHER_RAIN:
            rustChance = 5;
            break;
        }

        MOB M = S.mob();
        Room R = M.location();

        switch (R.domainType()) {
          case Room.DOMAIN_INDOORS_UNDERWATER:
          case Room.DOMAIN_INDOORS_WATERSURFACE:
          case Room.DOMAIN_OUTDOORS_WATERSURFACE:
          case Room.DOMAIN_OUTDOORS_UNDERWATER:
            rustChance += 5;
            break;
          default:
            break;
        }
        if ((R.domainConditions() & Room.CONDITION_WET) > 0) rustChance += 2;
        if (CMLib.dice().rollPercentage() < rustChance) {
          int weatherType = C.weatherType(R);
          Vector rustThese = new Vector();
          for (int i = 0; i < M.numItems(); i++) {
            Item I = M.getItem(i);
            if (I == null) continue;
            if ((!I.amWearingAt(Wearable.IN_INVENTORY))
                && (((I.material() & RawMaterial.MATERIAL_MASK) == RawMaterial.MATERIAL_METAL))
                && (I.subjectToWearAndTear())
                && ((CMLib.dice().rollPercentage() > I.phyStats().ability() * 25)))
              rustThese.addElement(I);
            else if (I.amWearingAt(Wearable.WORN_ABOUT_BODY)
                && (((I.material() & RawMaterial.MATERIAL_MASK) != RawMaterial.MATERIAL_METAL))) {
              rustThese.clear();
              break;
            }
          }
          if (R != null)
            for (int i = 0; i < rustThese.size(); i++) {
              Item I = (Item) rustThese.elementAt(i);
              CMMsg msg =
                  CMClass.getMsg(
                      M,
                      I,
                      null,
                      CMMsg.MASK_ALWAYS | CMMsg.TYP_WATER,
                      (weatherType != 0) ? "<T-NAME> rusts." : "<T-NAME> rusts in the water.",
                      CMMsg.TYP_WATER,
                      null,
                      CMMsg.NO_EFFECT,
                      null);
              if (R.okMessage(M, msg)) {
                R.send(M, msg);
                if (msg.value() <= 0) {
                  I.setUsesRemaining(I.usesRemaining() - 1);
                  if (I.usesRemaining() <= 0) {
                    msg =
                        CMClass.getMsg(
                            M,
                            null,
                            null,
                            CMMsg.MSG_OK_VISUAL,
                            I.name() + " is destroyed!",
                            null,
                            I.name() + " carried by " + M.name() + " is destroyed!");
                    if (R.okMessage(M, msg)) R.send(M, msg);
                    I.destroy();
                  }
                }
              }
            }
        }
      }
    }
    if (ticking instanceof Room) lastWeather = C.weatherType((Room) ticking);
    else lastWeather = C.weatherType(null);
    return true;
  }
Пример #13
0
 public double combatCastingTime(final MOB mob, final List<String> cmds) {
   return CMProps.getCombatActionSkillCost(
       ID(), CMath.div(CMProps.getIntVar(CMProps.SYSTEMI_DEFCOMABLETIME), 50.0));
 }
Пример #14
0
  public boolean execute(MOB mob, Vector commands, int metaFlags) throws java.io.IOException {
    if ((commands.size() == 1) && (((String) commands.firstElement()).startsWith("QUESTW")))
      commands.addElement("WON");
    if ((commands.size() > 1) && (((String) commands.elementAt(1)).equalsIgnoreCase("WON"))) {
      Vector qVec = new Vector();
      for (int q = 0; q < CMLib.quests().numQuests(); q++) {
        Quest Q = CMLib.quests().fetchQuest(q);
        if (Q.wasWinner(mob.Name())) {
          String name = Q.displayName().trim().length() > 0 ? Q.displayName() : Q.name();
          if (!qVec.contains(name)) qVec.addElement(name);
        }
      }
      Collections.sort(qVec);
      StringBuffer msg = new StringBuffer("^HQuests you are listed as having won:^?^N\n\r");
      for (int i = 0; i < qVec.size(); i++) msg.append(((String) qVec.elementAt(i)) + "^N\n\r");
      if (!mob.isMonster()) mob.tell(msg.toString());
    } else if ((commands.size() > 2)
        && (((String) commands.elementAt(1)).equalsIgnoreCase("DROP"))) {
      ScriptingEngine foundS = null;
      for (Enumeration<ScriptingEngine> e = mob.scripts(); e.hasMoreElements(); ) {
        ScriptingEngine SE = e.nextElement();
        if (SE == null) continue;
        if ((SE.defaultQuestName().length() > 0)
            && (CMLib.quests().findQuest(SE.defaultQuestName()) == null)) foundS = SE;
      }
      if (foundS != null) mob.delScript(foundS);
      foundS = null;

      String rest = CMParms.combine(commands, 2);
      Quest Q = CMLib.quests().findQuest(rest);
      if (Q == null) {
        mob.tell("There is no such quest as '" + rest + "'.");
        return false;
      }
      for (Enumeration<ScriptingEngine> e = mob.scripts(); e.hasMoreElements(); ) {
        ScriptingEngine SE = e.nextElement();
        if (SE == null) continue;
        if ((SE.defaultQuestName().length() > 0)
            && (SE.defaultQuestName().equalsIgnoreCase(Q.name()))) foundS = SE;
      }
      if (foundS == null) {
        mob.tell("You have not accepted a quest called '" + rest + "'.  Enter QUESTS for a list.");
        return false;
      }
      if ((!mob.isMonster()
          && (mob.session()
              .confirm("Drop the quest '" + Q.name() + "', are you sure (y/N)?", "N")))) {
        CMLib.coffeeTables().bump(Q, CoffeeTableRow.STAT_QUESTDROPPED);
        mob.delScript(foundS);
        mob.tell("Quest dropped.");
        return false;
      }
    } else if (commands.size() == 1) {
      List<Quest> qQVec = CMLib.quests().getPlayerPersistantQuests(mob);
      Vector<String> qVec = new Vector<String>();
      for (Quest Q : qQVec) {
        String name = Q.displayName().trim().length() > 0 ? Q.displayName() : Q.name();
        if (!qVec.contains(name)) qVec.addElement(name);
      }
      Collections.sort(qVec);
      StringBuffer msg = new StringBuffer("^HQuests you are listed as having accepted:^?^N\n\r");
      for (int i = 0; i < qVec.size(); i++) msg.append(((String) qVec.elementAt(i)) + "^N\n\r");
      if (!mob.isMonster())
        mob.tell(msg.toString() + "\n\r^HEnter QUEST [QUEST NAME] for more information.^N^.");

    } else {
      String rest = CMParms.combine(commands, 1);
      Quest Q = CMLib.quests().findQuest(rest);
      if (Q == null) {
        mob.tell("There is no such quest as '" + rest + "'.");
        return false;
      }
      ScriptingEngine foundS = null;
      for (Enumeration<ScriptingEngine> e = mob.scripts(); e.hasMoreElements(); ) {
        ScriptingEngine SE = e.nextElement();
        if (SE == null) continue;
        if ((SE.defaultQuestName().length() > 0)
            && (SE.defaultQuestName().equalsIgnoreCase(Q.name()))) foundS = SE;
      }
      if (foundS == null) {
        mob.tell("You have not accepted a quest called '" + rest + "'.  Enter QUESTS for a list.");
        return false;
      }
      String name = Q.displayName().trim().length() > 0 ? Q.displayName() : Q.name();
      if (!Q.name().equals(name)) name += " (" + Q.name() + ")";
      mob.tell("^HQuest Information: ^w" + name + "^N");
      String instructions = null;
      if ((instructions == null) || (instructions.length() == 0))
        instructions = foundS.getVar("*", "INSTRUCTIONS");
      if ((instructions == null) || (instructions.length() == 0))
        instructions = Q.isStat("INSTRUCTIONS") ? Q.getStat("INSTRUCTIONS") : null;
      if ((instructions == null) || (instructions.length() == 0))
        instructions = "No further information available.";
      String timeRemaining = foundS.getVar("*", "TIME_REMAINING");
      if ((timeRemaining != null) && (timeRemaining.length() > 0)) {
        String timeRemainingType = foundS.getVar("*", "TIME_REMAINING_TYPE");
        if (((timeRemainingType.equalsIgnoreCase("TICKS") || (timeRemainingType.length() == 0))
            && (CMath.isInteger(timeRemaining)))) {
          long ticks = CMath.s_int(timeRemaining);
          ticks *= CMProps.getTickMillis();
          if (ticks > 60000) timeRemaining = (ticks / 60000) + " minutes";
          else timeRemaining = (ticks / 1000) + " seconds";
        } else if (timeRemainingType.length() > 0) timeRemaining += " " + timeRemainingType;
      }
      String progress = foundS.getVar("*", "PROGRESS");
      mob.tell("^w" + instructions + "^N");
      if ((timeRemaining != null) && (timeRemaining.length() > 0))
        mob.tell("\n\r^yTime Remaining: ^w" + timeRemaining + "^N");
      if ((progress != null) && (progress.length() > 0))
        mob.tell("\n\r^yProgress: ^w" + progress + "^N");
    }
    return false;
  }
Пример #15
0
  public boolean execute(MOB mob, Vector commands, int metaFlags) throws java.io.IOException {
    if ((!mob.isMonster()) && CMath.bset(mob.getBitmap(), MOB.ATT_QUIET)) {
      mob.tell("You have QUIET mode on.  You must turn it off first.");
      return false;
    }

    if (commands.size() < 3) {
      mob.tell("Tell whom what?");
      return false;
    }
    commands.removeElementAt(0);

    if (((String) commands.firstElement()).equalsIgnoreCase("last")
        && (CMath.isNumber(CMParms.combine(commands, 1)))
        && (mob.playerStats() != null)) {
      java.util.List<String> V = mob.playerStats().getTellStack();
      if ((V.size() == 0)
          || (CMath.bset(metaFlags, Command.METAFLAG_AS))
          || (CMath.bset(metaFlags, Command.METAFLAG_POSSESSED))) mob.tell("No telling.");
      else {
        int num = CMath.s_int(CMParms.combine(commands, 1));
        if (num > V.size()) num = V.size();
        Session S = mob.session();
        try {
          if (S != null) S.snoopSuspension(1);
          for (int i = V.size() - num; i < V.size(); i++) mob.tell((String) V.get(i));
        } finally {
          if (S != null) S.snoopSuspension(-1);
        }
      }
      return false;
    }

    MOB targetM = null;
    String targetName = ((String) commands.elementAt(0)).toUpperCase();
    targetM = CMLib.sessions().findPlayerOnline(targetName, true);
    if (targetM == null) targetM = CMLib.sessions().findPlayerOnline(targetName, false);
    for (int i = 1; i < commands.size(); i++) {
      String s = (String) commands.elementAt(i);
      if (s.indexOf(' ') >= 0) commands.setElementAt("\"" + s + "\"", i);
    }
    String combinedCommands = CMParms.combine(commands, 1);
    if (combinedCommands.equals("")) {
      mob.tell("Tell them what?");
      return false;
    }
    combinedCommands = CMProps.applyINIFilter(combinedCommands, CMProps.SYSTEM_SAYFILTER);
    if (targetM == null) {
      if (targetName.indexOf('@') >= 0) {
        String mudName = targetName.substring(targetName.indexOf('@') + 1);
        targetName = targetName.substring(0, targetName.indexOf('@'));
        if (CMLib.intermud().i3online() || CMLib.intermud().imc2online())
          CMLib.intermud().i3tell(mob, targetName, mudName, combinedCommands);
        else mob.tell("Intermud is unavailable.");
        return false;
      }
      mob.tell("That person doesn't appear to be online.");
      return false;
    }

    if (CMath.bset(targetM.getBitmap(), MOB.ATT_QUIET)) {
      mob.tell("That person can not hear you.");
      return false;
    }

    Session ts = targetM.session();
    try {
      if (ts != null) ts.snoopSuspension(1);
      CMLib.commands().postSay(mob, targetM, combinedCommands, true, true);
    } finally {
      if (ts != null) ts.snoopSuspension(-1);
    }

    if ((targetM.session() != null) && (targetM.session().afkFlag()))
      mob.tell(targetM.session().afkMessage());
    return false;
  }
Пример #16
0
  public boolean invoke(MOB mob, Vector commands, Physical givenTarget, boolean auto, int asLevel) {
    MOB target = mob;
    if ((auto) && (givenTarget != null) && (givenTarget instanceof MOB)) target = (MOB) givenTarget;
    if (target.fetchEffect(ID()) != null) {
      mob.tell(target, null, null, "<S-NAME> <S-IS-ARE> already squatting.");
      return false;
    }
    if (!super.invoke(mob, commands, givenTarget, auto, asLevel)) return false;

    if (CMLib.law().doesHavePriviledgesHere(mob, mob.location())) {
      mob.tell("This is your place already!");
      return false;
    }
    LandTitle T = CMLib.law().getLandTitle(mob.location());
    boolean confirmed = false;
    for (final Enumeration<Ability> a = mob.location().effects(); a.hasMoreElements(); ) {
      final Ability A = a.nextElement();
      if (A == T) confirmed = true;
    }
    if (T == null) {
      mob.tell("This property is not available for sale, and cannot be squatted upon.");
      return false;
    }
    MOB warnMOB = null;
    if (T.landOwner().length() > 0) {
      Clan C = CMLib.clans().getClan(T.landOwner());
      if (C == null) {
        MOB M = CMLib.players().getLoadPlayer(T.landOwner());
        if (M != null) warnMOB = M;
      } else {
        for (Session S : CMLib.sessions().localOnlineIterable()) {
          if ((S.mob() != null) && (S.mob() != mob) && (S.mob().getClanID().equals(C.clanID())))
            warnMOB = S.mob();
        }
      }
      if ((warnMOB == null) || (!CMLib.flags().isInTheGame(warnMOB, true))) {
        mob.tell("The owners must be in the game for you to begin squatting.");
        return false;
      }
    }
    if (!confirmed) {
      mob.tell("You cannot squat on an area for sale.");
      return false;
    }
    if (!CMLib.flags().isSitting(mob)) {
      mob.tell("You must be sitting!");
      return false;
    }

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

    CMMsg msg =
        CMClass.getMsg(
            mob,
            null,
            this,
            auto ? CMMsg.MASK_ALWAYS : CMMsg.MSG_DELICATE_SMALL_HANDS_ACT,
            CMMsg.MSG_DELICATE_SMALL_HANDS_ACT,
            CMMsg.MSG_DELICATE_SMALL_HANDS_ACT,
            auto ? "" : "<S-NAME> start(s) squatting.");
    if (!success)
      return beneficialVisualFizzle(
          mob, null, auto ? "" : "<S-NAME> can't seem to get comfortable here.");
    else if (mob.location().okMessage(mob, msg)) {
      mob.location().send(mob, msg);
      failed = false;
      room = mob.location();
      title = T;
      beneficialAffect(mob, target, asLevel, (CMProps.getIntVar(CMProps.SYSTEMI_TICKSPERMUDMONTH)));
      if (warnMOB != null)
        warnMOB.tell(
            "You've heard a rumor that someone is squatting on " + T.landOwner() + "'s property.");
    }
    return success;
  }