Ejemplo n.º 1
0
  public List<Ability> getClanLevelEffectsList(final MOB mob, final Integer level) {
    if (clanEffectNames == null) return empty;

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

    if (clanEffectMap == null) return empty;

    if (clanEffectMap.containsKey(level)) return clanEffectMap.get(level);
    final CMObjUniqSortSVec<Ability> finalV = new CMObjUniqSortSVec<Ability>();
    for (int v = 0; v < clanEffectLevels.length; v++) {
      if ((clanEffectLevels[v] <= level.intValue())
          && (clanEffectNames.length > v)
          && (clanEffectParms.length > v)) {
        Ability A = CMClass.getAbility(clanEffectNames[v]);
        if (A != null) {
          // mob was set to null here to make the cache map actually relevant .. see caching below
          A.setProficiency(CMLib.ableMapper().getMaxProficiency((MOB) null, true, A.ID()));
          A.setMiscText(clanEffectParms[v]);
          A.makeNonUninvokable();
          A.setSavable(false); // must go AFTER the ablve
          finalV.add(A);
        }
      }
    }
    finalV.trimToSize();
    clanEffectMap.put(level, finalV);
    return finalV;
  }
Ejemplo n.º 2
0
  public boolean invoke(MOB mob, Vector commands, Physical givenTarget, boolean auto, int asLevel) {
    if (mob.fetchEffect("Thief_Hide") != null) {
      mob.tell("You are already hiding.");
      return false;
    }

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

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

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

    if (!success)
      beneficialVisualFizzle(mob, null, "<S-NAME> attempt(s) to set up an ambush, but fail(s).");
    else {
      CMMsg msg =
          CMClass.getMsg(
              mob,
              null,
              this,
              auto ? CMMsg.MSG_OK_ACTION : (CMMsg.MSG_DELICATE_HANDS_ACT | CMMsg.MASK_MOVE),
              "<S-NAME> set(s) up an ambush, directing everyone to hiding places.");
      if (mob.location().okMessage(mob, msg)) {
        mob.location().send(mob, msg);
        invoker = mob;
        Ability hide = CMClass.getAbility("Thief_Hide");
        for (Iterator e = H.iterator(); e.hasNext(); ) {
          MOB M = (MOB) e.next();
          hide.invoke(M, M, true, adjustedLevel(mob, asLevel));
        }
      } else success = false;
    }
    return success;
  }
Ejemplo n.º 3
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;
 }
Ejemplo n.º 4
0
 public List<Ability> getClanLevelAbilities(Integer level) {
   if ((clanAbilityMap == null)
       && (clanAbilityNames != null)
       && (clanAbilityLevels != null)
       && (clanAbilityProficiencies != null)
       && (clanAbilityQuals != null)) {
     CMLib.ableMapper().delCharMappings(ID()); // necessary for a "clean start"
     clanAbilityMap = new Hashtable<Integer, List<Ability>>();
     for (int i = 0; i < clanAbilityNames.length; i++) {
       CMLib.ableMapper()
           .addDynaAbilityMapping(
               ID(),
               clanAbilityLevels[i],
               clanAbilityNames[i],
               clanAbilityProficiencies[i],
               "",
               !clanAbilityQuals[i],
               false);
     }
   }
   if (clanAbilityMap == null) return empty;
   if (clanAbilityMap.containsKey(level)) return clanAbilityMap.get(level);
   List<AbilityMapper.AbilityMapping> V =
       CMLib.ableMapper().getUpToLevelListings(ID(), level.intValue(), true, true);
   CMObjUniqSortSVec<Ability> finalV = new CMObjUniqSortSVec<Ability>();
   for (AbilityMapper.AbilityMapping able : V) {
     Ability A = CMClass.getAbility(able.abilityID);
     if (A != null) {
       A.setProficiency(CMLib.ableMapper().getDefaultProficiency(ID(), false, A.ID()));
       A.setSavable(false);
       A.setMiscText(CMLib.ableMapper().getDefaultParm(ID(), false, A.ID()));
       finalV.add(A);
     }
   }
   finalV.trimToSize();
   clanAbilityMap.put(level, finalV);
   return finalV;
 }
Ejemplo n.º 5
0
 public TrappedLockedDoor() {
   super();
   Trap t = (Trap) CMClass.getAbility("Trap_Trap");
   if (t != null) CMLib.utensils().setTrapped(this, t, true);
 }
Ejemplo n.º 6
0
  public String getHelpStr() {
    if (getLongDesc().length() == 0) return null;
    if (helpStr == null) {
      StringBuilder str = new StringBuilder("\n\rOrganization type: " + getName() + "\n\r\n\r");
      str.append(getLongDesc()).append("\n\r");
      str.append("\n\rAuthority Chart:\n\r\n\r");
      final List<ClanPosition> showablePositions = new Vector<ClanPosition>();
      for (ClanPosition P : getPositions()) {
        boolean showMe = false;
        for (Clan.Authority a : P.getFunctionChart()) if (a == Authority.CAN_DO) showMe = true;
        if (showMe) showablePositions.add(P);
      }
      final List<ClanPosition> sortedPositions = new Vector<ClanPosition>();
      while (sortedPositions.size() < showablePositions.size()) {
        ClanPosition highPos = null;
        for (ClanPosition P : showablePositions)
          if ((!sortedPositions.contains(P))
              && ((highPos == null) || (highPos.getRank() < P.getRank()))) highPos = P;
        sortedPositions.add(highPos);
      }
      final int[] posses = new int[sortedPositions.size()];
      int posTotalLen = 0;
      for (int p = 0; p < sortedPositions.size(); p++) {
        posses[p] = sortedPositions.get(p).getName().length() + 2;
        posTotalLen += posses[p];
      }
      int funcMaxLen = 0;
      int funcTotal = 0;
      String[] functionNames = new String[Clan.Function.values().length];
      for (int f = 0; f < Clan.Function.values().length; f++) {
        Clan.Function func = Clan.Function.values()[f];
        funcTotal += func.name().length() + 1;
        if (func.name().length() > funcMaxLen) funcMaxLen = func.name().length() + 1;
        functionNames[f] = func.name();
      }
      int funcAvg = funcTotal / Clan.Function.values().length;
      int funcMaxAvg = (int) CMath.round((double) funcAvg * 1.3);
      while ((funcMaxLen > funcMaxAvg) && ((funcMaxAvg + posTotalLen) > 78)) funcMaxLen--;
      if (posses.length > 0)
        while ((funcMaxLen + posTotalLen) > 78) {
          int highPos = 0;
          for (int p = 1; p < sortedPositions.size(); p++)
            if (posses[p] > posses[highPos]) highPos = p;
          posTotalLen--;
          posses[highPos]--;
        }

      final int commandColLen = funcMaxLen;
      str.append(CMStrings.padRight("Command", commandColLen - 1)).append("!");
      for (int p = 0; p < posses.length; p++) {
        ClanPosition pos = sortedPositions.get(p);
        String name = CMStrings.capitalizeAndLower(pos.getName().replace('_', ' '));
        str.append(CMStrings.padRight(name, posses[p] - 1));
        if (p < posses.length - 1) str.append("!");
      }
      str.append("\n\r");
      Object lineDraw =
          new Object() {
            private static final String line =
                "----------------------------------------------------------------------------";

            public String toString() {
              StringBuilder s = new StringBuilder("");
              s.append(line.substring(0, commandColLen - 1)).append("+");
              for (int p = 0; p < posses.length; p++) {
                s.append(CMStrings.padRight(line, posses[p] - 1));
                if (p < posses.length - 1) s.append("+");
              }
              return s.toString();
            }
          };
      str.append(lineDraw.toString()).append("\n\r");
      for (Clan.Function func : Clan.Function.values()) {
        String fname = CMStrings.capitalizeAndLower(func.toString().replace('_', ' '));
        str.append(CMStrings.padRight(fname, commandColLen - 1)).append("!");
        for (int p = 0; p < sortedPositions.size(); p++) {
          ClanPosition pos = sortedPositions.get(p);
          Authority auth = pos.getFunctionChart()[func.ordinal()];
          String x = "";
          if (auth == Authority.CAN_DO) x = "X";
          else if (auth == Authority.MUST_VOTE_ON) x = "v";
          str.append(CMStrings.padCenter(x, posses[p] - 1));
          if (p < posses.length - 1) str.append("!");
        }
        str.append("\n\r").append(lineDraw.toString()).append("\n\r");
      }
      /*
      protected String[] 	clanEffectNames			=null;
      protected int[] 	clanEffectLevels		=null;
      protected String[] 	clanEffectParms			=null;
      protected String[] 	clanAbilityNames		=null;
      protected int[] 	clanAbilityLevels		=null;
      protected int[] 	clanAbilityProficiencies=null;
      protected boolean[] clanAbilityQuals		=null;
      */

      if ((clanAbilityLevels != null)
          && (clanEffectLevels != null)
          && (clanAbilityLevels.length > 0)
          && (clanEffectLevels.length > 0)) {
        str.append("\n\rBenefits per Clan Level:\n\r");
        int maxLevel = -1;
        for (int x : clanEffectLevels) if (x > maxLevel) maxLevel = x;
        for (int x : clanAbilityLevels) if (x > maxLevel) maxLevel = x;
        for (int l = 1; l <= maxLevel; l++) {
          final List<String> levelBenefits = new LinkedList<String>();
          for (int x = 0; x < clanEffectLevels.length; x++)
            if (clanEffectLevels[x] == l) {
              final Ability A = CMClass.getAbility(clanEffectNames[x]);
              if (A != null) {
                A.setMiscText(clanEffectParms[x]);
                String desc = A.accountForYourself();
                if ((desc == null) || (desc.length() == 0))
                  desc = "Members gain the following effect: " + A.name();
                levelBenefits.add(desc);
              }
            }
          for (int x = 0; x < clanAbilityLevels.length; x++)
            if (clanAbilityLevels[x] == l) {
              final Ability A = CMClass.getAbility(clanAbilityNames[x]);
              if (A != null) {
                if (clanAbilityQuals[x]) levelBenefits.add("Members qualify for: " + A.name());
                else levelBenefits.add("Members automatically gain: " + A.name());
              }
            }
          for (final String bene : levelBenefits) str.append("Level " + l + ": " + bene + "\n\r");
        }
      }
      helpStr = str.toString();
    }
    return helpStr;
  }
Ejemplo n.º 7
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;
  }
Ejemplo n.º 8
0
  public boolean okMessage(Environmental host, CMMsg msg) {
    if (!super.okMessage(host, msg)) return false;

    Room R = msg.source().location();
    if ((host instanceof Area) && (R != null) && (R.getArea() != host)) return true;
    int weather = weather(host, R);
    // first handle the effect of storms on ranged
    // weapons

    if ((msg.targetMinor() == CMMsg.TYP_WEAPONATTACK)
        && (msg.source().rangeToTarget() != 0)
        && (msg.tool() instanceof Item)
        && (!(msg.tool() instanceof Electronics))
        && ((msg.sourceMinor() == CMMsg.TYP_THROW)
            || ((msg.tool() instanceof Weapon)
                && ((((Weapon) msg.tool()).weaponClassification() == Weapon.CLASS_RANGED)
                    || (((Weapon) msg.tool()).weaponClassification() == Weapon.CLASS_THROWN))))) {
      switch (weather) {
        case Climate.WEATHER_WINDY:
        case Climate.WEATHER_THUNDERSTORM:
        case Climate.WEATHER_BLIZZARD:
        case Climate.WEATHER_DUSTSTORM:
          {
            if ((CMLib.dice().rollPercentage() < windsheer) && (R != null)) {
              R.show(
                  msg.source(),
                  msg.target(),
                  msg.tool(),
                  CMMsg.MSG_OK_ACTION,
                  "^WThe strong wind blows <S-YOUPOSS> attack against <T-NAMESELF> with <O-NAME> off target.^?");
              return false;
            }
            break;
          }
      }
    }
    // then try to handle slippage in wet weather
    if (((msg.sourceMajor(CMMsg.MASK_MOVE))) && (R != null)) {
      String what = null;
      switch (weather) {
        case Climate.WEATHER_BLIZZARD:
        case Climate.WEATHER_SNOW:
          if (CMLib.dice().rollPercentage() < snowSlipChance) what = "cold wet";
          break;
        case Climate.WEATHER_RAIN:
        case Climate.WEATHER_THUNDERSTORM:
          if (CMLib.dice().rollPercentage() < rainSlipChance) what = "slippery wet";
          break;
        case Climate.WEATHER_SLEET:
          if (CMLib.dice().rollPercentage() < sleetSlipChance) what = "icy";
          break;
      }
      if ((what != null)
          && (!CMLib.flags().isInFlight(msg.source()))
          && (R.domainType() != Room.DOMAIN_OUTDOORS_AIR)
          && (R.domainType() != Room.DOMAIN_OUTDOORS_WATERSURFACE)
          && (R.domainType() != Room.DOMAIN_OUTDOORS_UNDERWATER)
          && (CMLib.dice().rollPercentage()
              > ((msg.source().charStats().getStat(CharStats.STAT_DEXTERITY) * 3) + 25))) {
        int oldDisposition = msg.source().basePhyStats().disposition();
        oldDisposition =
            oldDisposition & (~(PhyStats.IS_SLEEPING | PhyStats.IS_SNEAKING | PhyStats.IS_SITTING));
        msg.source().basePhyStats().setDisposition(oldDisposition | PhyStats.IS_SITTING);
        msg.source().recoverPhyStats();
        R.show(
            msg.source(),
            null,
            CMMsg.MSG_OK_ACTION,
            "^W<S-NAME> slip(s) on the " + what + " ground.^?");
        return false;
      }
    }
    if ((R != null) && (weather == Climate.WEATHER_BLIZZARD)) {
      Ability A = CMClass.getAbility("Spell_ObscureSelf");
      if (A != null) {
        A.setAffectedOne(msg.source());
        if (!A.okMessage(msg.source(), msg)) return false;
      }
    }
    return true;
  }