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; }
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; } } } }
@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; }
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; }
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; } } } }
/** 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; } }
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); } } }
@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); }
@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; }
@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; }
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; }
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; }
@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; }
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; }
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; }
public boolean invoke(MOB mob, Vector commands, Physical givenTarget, boolean auto, int asLevel) { String whom = CMParms.combine(commands, 0); int dirCode = Directions.getGoodDirectionCode(whom); if (!CMLib.flags().canHear(mob)) { mob.tell("You don't hear anything."); return false; } if (room != null) for (final Enumeration<Ability> a = room.effects(); a.hasMoreElements(); ) { final Ability A = a.nextElement(); if ((A.ID().equals(ID())) && (invoker() == mob)) A.unInvoke(); } room = null; if (dirCode < 0) room = mob.location(); else { if ((mob.location().getRoomInDir(dirCode) == null) || (mob.location().getExitInDir(dirCode) == null)) { mob.tell("Listen which direction?"); return false; } room = mob.location().getRoomInDir(dirCode); if ((room.domainType() & Room.INDOORS) == 0) { mob.tell("You can only listen indoors."); return false; } } if (!super.invoke(mob, commands, givenTarget, auto, asLevel)) return false; boolean success = false; CMMsg msg = CMClass.getMsg( mob, null, this, auto ? CMMsg.MSG_OK_ACTION : (CMMsg.MSG_DELICATE_SMALL_HANDS_ACT), CMMsg.MSG_OK_VISUAL, CMMsg.MSG_OK_VISUAL, "<S-NAME> listen(s)" + ((dirCode < 0) ? "" : " " + Directions.getDirectionName(dirCode)) + "."); if (mob.location().okMessage(mob, msg)) { mob.location().send(mob, msg); success = proficiencyCheck(mob, 0, auto); int numberHeard = 0; int levelsHeard = 0; for (int i = 0; i < room.numInhabitants(); i++) { MOB inhab = room.fetchInhabitant(i); if ((inhab != null) && (!CMLib.flags().isSneaking(inhab)) && (!CMLib.flags().isHidden(inhab)) && (inhab != mob)) { numberHeard++; if (inhab.phyStats().level() > (mob.phyStats().level() + (2 * super.getXLEVELLevel(mob)))) levelsHeard += (inhab.phyStats().level() - (mob.phyStats().level() + (2 * super.getXLEVELLevel(mob)))); } } if ((success) && (numberHeard > 0)) { if (((proficiency() + (getXLEVELLevel(mob) * 10)) > (50 + levelsHeard)) || (room == mob.location())) { mob.tell("You definitely hear " + numberHeard + " creature(s)."); if (proficiency() > ((room == mob.location()) ? 50 : 75)) { sourceRoom = mob.location(); beneficialAffect(mob, room, asLevel, ((room == mob.location()) ? 0 : 10)); } } else mob.tell("You definitely hear something."); } else mob.tell("You don't hear anything."); } return success; }