public boolean execute(MOB mob, Vector commands, int metaFlags) throws java.io.IOException { if (!mob.isMonster()) { if ((CMath.bset(mob.getBitmap(), MOB.ATT_MXP)) || (mob.session().clientTelnetMode(Session.TELNET_MXP))) { if (mob.session().clientTelnetMode(Session.TELNET_MXP)) mob.session().rawOut("\033[3z \033[7z"); mob.setBitmap(CMath.unsetb(mob.getBitmap(), MOB.ATT_MXP)); mob.session().changeTelnetMode(Session.TELNET_MXP, false); mob.session().setClientTelnetMode(Session.TELNET_MXP, false); mob.tell("MXP codes are disabled.\n\r"); } else mob.tell("MXP codes are already disabled.\n\r"); } return false; }
public boolean execute(MOB mob, Vector commands, int metaFlags) throws java.io.IOException { boolean quiet = false; if (mob == null) return false; Room R = mob.location(); if (R == null) return false; if ((commands.size() > 2) && (commands.lastElement() instanceof String) && (((String) commands.lastElement()).equalsIgnoreCase("UNOBTRUSIVELY"))) { commands.removeElementAt(commands.size() - 1); quiet = true; } if ((commands.size() > 1) && (commands.elementAt(1) instanceof MOB)) return processFollow(mob, (MOB) commands.elementAt(1), quiet); if (commands.size() < 2) { mob.tell("Follow whom?"); return false; } String whomToFollow = CMParms.combine(commands, 1); if ((whomToFollow.equalsIgnoreCase("self") || whomToFollow.equalsIgnoreCase("me")) || (mob.name().toUpperCase().startsWith(whomToFollow))) { nofollow(mob, true, quiet); return false; } MOB target = R.fetchInhabitant(whomToFollow); if ((target == null) || (!CMLib.flags().canBeSeenBy(target, mob))) { mob.tell("I don't see them here."); return false; } if ((target.isMonster()) && (!mob.isMonster())) { mob.tell("You cannot follow '" + target.name() + "'."); return false; } if (CMath.bset(target.getBitmap(), MOB.ATT_NOFOLLOW)) { mob.tell(target.name() + " is not accepting followers."); return false; } MOB ultiTarget = target.amUltimatelyFollowing(); if ((ultiTarget != null) && (CMath.bset(ultiTarget.getBitmap(), MOB.ATT_NOFOLLOW))) { mob.tell(ultiTarget.name() + " is not accepting followers."); return false; } processFollow(mob, target, quiet); return false; }
public boolean execute(MOB mob, Vector commands, int metaFlags) throws java.io.IOException { if (mob.session() == null) return true; PlayerStats pstats = mob.playerStats(); if (pstats == null) return true; if ((commands != null) && (commands.size() > 1) && (commands.elementAt(1) instanceof String) && (CMProps.getVar(CMProps.SYSTEM_MAILBOX).length() > 0)) { String name = CMParms.combine(commands, 1); if (name.equalsIgnoreCase("BOX")) { String journalName = CMProps.getVar(CMProps.SYSTEM_MAILBOX); Vector<JournalsLibrary.JournalEntry> msgs = CMLib.database().DBReadJournalMsgs(journalName); while ((mob.session() != null) && (!mob.session().killFlag())) { Vector mymsgs = new Vector(); StringBuffer messages = new StringBuffer( "^X" + CMStrings.padCenter(mob.Name() + "'s MailBox", 48) + "^?^.\n\r"); messages.append( "^X### " + CMStrings.padRight("From", 15) + " " + CMStrings.padRight("Date", 20) + " Subject^?^.\n\r"); for (int num = 0; num < msgs.size(); num++) { JournalsLibrary.JournalEntry thismsg = msgs.elementAt(num); String to = (String) thismsg.to; if (to.equalsIgnoreCase("ALL") || to.equalsIgnoreCase(mob.Name()) || (to.toUpperCase().trim().startsWith("MASK=") && CMLib.masking().maskCheck(to.trim().substring(5), mob, true))) { mymsgs.addElement(thismsg); messages.append( CMStrings.padRight("" + mymsgs.size(), 4) + CMStrings.padRight((thismsg.from), 16) + CMStrings.padRight(CMLib.time().date2String(thismsg.date), 21) + (thismsg.subj) + "\n\r"); } } if ((mymsgs.size() == 0) || (CMath.bset(metaFlags, Command.METAFLAG_POSSESSED)) || (CMath.bset(metaFlags, Command.METAFLAG_AS))) { if (CMath.bset(mob.getBitmap(), MOB.ATT_AUTOFORWARD)) mob.tell( "You have no email waiting, but then, it's probably been forwarded to you already."); else mob.tell("You have no email waiting."); return false; } Session S = mob.session(); try { if (S != null) S.snoopSuspension(1); mob.tell(messages.toString()); } finally { if (S != null) S.snoopSuspension(-1); } String s = mob.session().prompt("Enter a message #", ""); if ((!CMath.isInteger(s)) || (mob.session().killFlag())) return false; int num = CMath.s_int(s); if ((num <= 0) || (num > mymsgs.size())) mob.tell("That is not a valid number."); else while ((mob.session() != null) && (!mob.session().killFlag())) { JournalsLibrary.JournalEntry thismsg = (JournalsLibrary.JournalEntry) mymsgs.elementAt(num - 1); String key = thismsg.key; String from = thismsg.from; String date = CMLib.time().date2String(thismsg.date); String subj = thismsg.subj; String message = thismsg.msg; messages = new StringBuffer(""); messages.append("^XMessage :^?^." + num + "\n\r"); messages.append("^XFrom :^?^." + from + "\n\r"); messages.append("^XDate :^?^." + date + "\n\r"); messages.append("^XSubject :^?^." + subj + "\n\r"); messages.append("^X------------------------------------------------^?^.\n\r"); messages.append(message + "\n\r\n\r"); try { if (S != null) S.snoopSuspension(1); mob.tell(messages.toString()); } finally { if (S != null) S.snoopSuspension(-1); } s = mob.session() .choose("Would you like to D)elete, H)old, or R)eply (D/H/R)? ", "DHR", "H"); if (s.equalsIgnoreCase("H")) break; if (s.equalsIgnoreCase("R")) { if ((from.length() > 0) && (!from.equals(mob.Name())) && (!from.equalsIgnoreCase("BOX")) && (CMLib.players().getLoadPlayer(from) != null)) execute(mob, CMParms.makeVector(getAccessWords()[0], from), metaFlags); else mob.tell("You can not reply to this email."); } else if (s.equalsIgnoreCase("D")) { CMLib.database().DBDeleteJournal(journalName, key); msgs.remove(thismsg); mob.tell("Deleted."); break; } } } } else { MOB M = CMLib.players().getLoadPlayer(name); if (M == null) { mob.tell( "There is no player called '" + name + "' to send email to. If you were trying to read your mail, try EMAIL BOX. If you were trying to change your email address, just enter EMAIL without any parameters."); return false; } if (!CMath.bset(M.getBitmap(), MOB.ATT_AUTOFORWARD)) { if (!mob.session().confirm("Send email to '" + M.Name() + "' (Y/n)?", "Y")) return false; } else { if (!mob.session() .confirm( "Send email to '" + M.Name() + "', even though their AUTOFORWARD is turned off (y/N)?", "N")) return false; } if (CMProps.getIntVar(CMProps.SYSTEMI_MAXMAILBOX) > 0) { int count = CMLib.database() .DBCountJournal(CMProps.getVar(CMProps.SYSTEM_MAILBOX), null, M.Name()); if (count >= CMProps.getIntVar(CMProps.SYSTEMI_MAXMAILBOX)) { mob.tell(M.Name() + "'s mailbox is full."); return false; } } String subject = mob.session().prompt("Email Subject: ", "").trim(); if (subject.length() == 0) { mob.tell("Aborted"); return false; } String message = mob.session().prompt("Enter your message\n\r: ", "").trim(); if (message.trim().length() == 0) { mob.tell("Aborted"); return false; } message += "\n\r\n\rThis message was sent through the " + CMProps.getVar(CMProps.SYSTEM_MUDNAME) + " mail server at " + CMProps.getVar(CMProps.SYSTEM_MUDDOMAIN) + ", port" + CMProps.getVar(CMProps.SYSTEM_MUDPORTS) + ". Please contact the administrators regarding any abuse of this system.\n\r"; CMLib.database() .DBWriteJournal( CMProps.getVar(CMProps.SYSTEM_MAILBOX), mob.Name(), M.Name(), subject, message); mob.tell("Your email has been sent."); return true; } } if ((pstats.getEmail() == null) || (pstats.getEmail().length() == 0)) mob.session().println("\n\rYou have no email address on file for this character."); else { if (commands == null) return true; String change = mob.session() .prompt( "You currently have '" + pstats.getEmail() + "' set as the email address for this character.\n\rChange it (y/N)?", "N"); if (change.toUpperCase().startsWith("N")) return false; } if ((CMProps.getVar(CMProps.SYSTEM_EMAILREQ).toUpperCase().startsWith("PASS")) && (commands != null) && (CMProps.getVar(CMProps.SYSTEM_MAILBOX).length() > 0)) mob.session() .println( "\n\r** Changing your email address will cause you to be logged off, and a new password to be generated and emailed to the new address. **\n\r"); String newEmail = mob.session().prompt("New E-mail Address:"); if (newEmail == null) return false; newEmail = newEmail.trim(); if (!CMProps.getVar(CMProps.SYSTEM_EMAILREQ).toUpperCase().startsWith("OPTION")) { if (newEmail.length() < 6) return false; if (newEmail.indexOf("@") < 0) return false; String confirmEmail = mob.session() .prompt("Confirm that '" + newEmail + "' is correct by re-entering.\n\rRe-enter:"); if (confirmEmail == null) return false; confirmEmail = confirmEmail.trim(); if (confirmEmail.length() == 0) return false; if (!(newEmail.equalsIgnoreCase(confirmEmail))) return false; } pstats.setEmail(newEmail); CMLib.database().DBUpdateEmail(mob); if ((commands != null) && (CMProps.getVar(CMProps.SYSTEM_EMAILREQ).toUpperCase().startsWith("PASS")) && (CMProps.getVar(CMProps.SYSTEM_MAILBOX).length() > 0)) { String password = ""; for (int i = 0; i < 6; i++) password += (char) ('a' + CMLib.dice().roll(1, 26, -1)); pstats.setPassword(password); CMLib.database().DBUpdatePassword(mob.Name(), password); CMLib.database() .DBWriteJournal( CMProps.getVar(CMProps.SYSTEM_MAILBOX), mob.Name(), mob.Name(), "Password for " + mob.Name(), "Your new password for " + mob.Name() + " is: " + pstats.password() + "\n\rYou can login by pointing your mud client at " + CMProps.getVar(CMProps.SYSTEM_MUDDOMAIN) + " port(s):" + CMProps.getVar(CMProps.SYSTEM_MUDPORTS) + ".\n\rYou may use the PASSWORD command to change it once you are online."); mob.tell("You will receive an email with your new password shortly. Goodbye."); if (mob.session() != null) { try { Thread.sleep(1000); } catch (Exception e) { } mob.session().kill(false, false, false); } } return true; }
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 String runMacro(ExternalHTTPRequests httpReq, String parm) { if (!CMProps.getBoolVar(CMProps.SYSTEMB_MUDSTARTED)) return CMProps.getVar(CMProps.SYSTEM_MUDSTATUS); Hashtable parms = parseParms(parm); String last = httpReq.getRequestParameter("PLAYER"); if (last == null) return " @break@"; if (last.length() > 0) { MOB M = CMLib.players().getLoadPlayer(last); if (M == null) { MOB authM = Authenticate.getAuthenticatedMob(httpReq); if ((authM != null) && (authM.Name().equalsIgnoreCase(last))) M = authM; else return " @break@"; } boolean firstTime = (!httpReq.isRequestParameter("ACTION")) || (httpReq.getRequestParameter("ACTION")).equals("FIRSTTIME"); StringBuffer str = new StringBuffer(""); for (int i = 0; i < MOB.AUTODESC.length; i++) { if (parms.containsKey(MOB.AUTODESC[i])) { boolean set = CMath.isSet(M.getBitmap(), i); if (MOB.AUTOREV[i]) set = !set; str.append((set ? "ON" : "OFF") + ","); } } for (int i : CharStats.CODES.ALL()) { String stat = CharStats.CODES.NAME(i); if (!stat.equalsIgnoreCase("GENDER")) { CharStats C = M.charStats(); if (parms.containsKey(stat)) { String old = httpReq.getRequestParameter(stat); if ((firstTime) || (old.length() == 0)) { if ((!CharStats.CODES.isBASE(i)) && (i != CharStats.STAT_GENDER)) old = "" + C.getSave(i); else old = "" + C.getStat(i); } str.append(old + ", "); } } } for (int i : CharStats.CODES.ALL()) { String stat = CharStats.CODES.NAME(i); if (!stat.equalsIgnoreCase("GENDER")) { CharStats C = M.baseCharStats(); if (parms.containsKey("BASE" + stat)) { String old = httpReq.getRequestParameter("BASE" + stat); if ((firstTime) || (old.length() == 0)) old = "" + C.getStat(i); str.append(old + ", "); } } } for (int i = 0; i < BASICS.length; i++) { if (parms.containsKey(BASICS[i])) { if (httpReq.isRequestParameter(BASICS[i])) str.append(httpReq.getRequestParameter(BASICS[i]) + ", "); else str.append(getBasic(M, i)); } } if (parms.containsKey("RACE")) { String old = httpReq.getRequestParameter("RACE"); if ((firstTime) || (old.length() == 0)) old = "" + M.baseCharStats().getMyRace().ID(); for (Enumeration r = CMClass.races(); r.hasMoreElements(); ) { Race R2 = (Race) r.nextElement(); str.append("<OPTION VALUE=\"" + R2.ID() + "\""); if (R2.ID().equals(old)) str.append(" SELECTED"); str.append(">" + R2.name()); } } if (parms.containsKey("DEITY")) { String old = httpReq.getRequestParameter("DEITY"); if (firstTime) old = M.getWorshipCharID(); str.append("<OPTION " + ((old.length() == 0) ? "SELECTED" : "") + " VALUE=\"\">Godless"); for (Enumeration e = CMLib.map().deities(); e.hasMoreElements(); ) { Deity E = (Deity) e.nextElement(); str.append("<OPTION VALUE=\"" + E.Name() + "\""); if (E.Name().equalsIgnoreCase(old)) str.append(" SELECTED"); str.append(">" + E.Name()); } } if (parms.containsKey("TITLELIST")) { if (M.playerStats() != null) { int b = 0; Vector titles = new Vector(); if (firstTime) CMParms.addToVector(M.playerStats().getTitles(), titles); else while (httpReq.isRequestParameter("TITLE" + b)) { String B = httpReq.getRequestParameter("TITLE" + b); if ((B != null) && (B.trim().length() > 0)) titles.addElement(B); b++; } for (b = 0; b < titles.size(); b++) { String B = (String) titles.elementAt(b); if (B != null) str.append( "<INPUT TYPE=TEXT NAME=TITLE" + b + " SIZE=" + B.length() + " VALUE=\"" + CMStrings.replaceAll(B, "\"", """) + "\"><BR>"); } str.append("<INPUT TYPE=TEXT NAME=TITLE" + titles.size() + " SIZE=60 VALUE=\"\">"); } } if (parms.containsKey("CLAN")) { String old = httpReq.getRequestParameter("CLAN"); if (firstTime) old = M.getClanID(); str.append("<OPTION " + ((old.length() == 0) ? "SELECTED" : "") + " VALUE=\"\">Clanless"); for (Enumeration e = CMLib.clans().allClans(); e.hasMoreElements(); ) { Clan C = (Clan) e.nextElement(); str.append("<OPTION VALUE=\"" + C.clanID() + "\""); if (C.clanID().equalsIgnoreCase(old)) str.append(" SELECTED"); str.append(">" + C.getName()); } } if (parms.containsKey("ALIGNMENT")) { String old = httpReq.getRequestParameter("ALIGNMENT"); if ((firstTime) || (old.length() == 0)) old = "" + M.fetchFaction(CMLib.factions().AlignID()); if (CMLib.factions().getFaction(CMLib.factions().AlignID()) != null) { for (int v = 1; v < Faction.ALIGN_NAMES.length; v++) { str.append("<OPTION VALUE=" + Faction.ALIGN_NAMES[v]); if (old.equalsIgnoreCase(Faction.ALIGN_NAMES[v])) str.append(" SELECTED"); str.append(">" + CMStrings.capitalizeAndLower(Faction.ALIGN_NAMES[v].toLowerCase())); } } } if (parms.containsKey("BASEGENDER")) { String old = httpReq.getRequestParameter("BASEGENDER"); if (firstTime) old = "" + M.baseCharStats().getStat(CharStats.STAT_GENDER); str.append("<OPTION VALUE=M " + ((old.equalsIgnoreCase("M")) ? "SELECTED" : "") + ">M"); str.append("<OPTION VALUE=F " + ((old.equalsIgnoreCase("F")) ? "SELECTED" : "") + ">F"); str.append("<OPTION VALUE=N " + ((old.equalsIgnoreCase("N")) ? "SELECTED" : "") + ">N"); } str.append(MobData.expertiseList(M, httpReq, parms)); str.append(MobData.classList(M, httpReq, parms)); str.append(MobData.itemList(M, M, httpReq, parms, 0)); str.append(MobData.abilities(M, httpReq, parms, 0)); str.append(MobData.factions(M, httpReq, parms, 0)); str.append(AreaData.affectsNBehaves(M, httpReq, parms, 0)); str.append(ExitData.dispositions(M, firstTime, httpReq, parms)); str.append(MobData.senses(M, firstTime, httpReq, parms)); String strstr = str.toString(); if (strstr.endsWith(", ")) strstr = strstr.substring(0, strstr.length() - 2); return clearWebMacros(strstr); } return ""; }
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; }