@Override public boolean tick(Tickable ticking, int tickID) { super.tick(ticking, tickID); if ((canAct(ticking, tickID)) && (ticking instanceof MOB)) { if (DoneEquipping) return true; final MOB mob = (MOB) ticking; final Room thisRoom = mob.location(); if (thisRoom.numItems() == 0) return true; DoneEquipping = true; final Vector<Item> stuffIHad = new Vector<Item>(); for (int i = 0; i < mob.numItems(); i++) stuffIHad.addElement(mob.getItem(i)); mob.enqueCommand(new XVector<String>("GET", "ALL"), MUDCmdProcessor.METAFLAG_FORCED, 0); Item I = null; final Vector<Item> dropThisStuff = new Vector<Item>(); for (int i = 0; i < mob.numItems(); i++) { I = mob.getItem(i); if ((I != null) && (!stuffIHad.contains(I))) { if (I instanceof DeadBody) dropThisStuff.addElement(I); else if ((I.container() != null) && (I.container() instanceof DeadBody)) I.setContainer(null); } } for (int d = 0; d < dropThisStuff.size(); d++) mob.enqueCommand( new XVector<String>("DROP", "$" + dropThisStuff.elementAt(d).Name() + "$"), MUDCmdProcessor.METAFLAG_FORCED, 0); mob.enqueCommand(new XVector<String>("WEAR", "ALL"), MUDCmdProcessor.METAFLAG_FORCED, 0); } return true; }
public Set<MOB> getDeadMOBsFrom(Environmental whoE) { if (whoE instanceof MOB) { final MOB mob = (MOB) whoE; final Room room = mob.location(); if (room != null) return getEveryoneHere(mob, room); } else if (whoE instanceof Item) { final Item item = (Item) whoE; final Environmental E = item.owner(); if (E != null) { final Room room = getTickersRoom(whoE); if (room != null) { if ((E instanceof MOB) && ((mask == null) || (CMLib.masking().maskCheck(mask, E, false)))) return new XHashSet<MOB>((MOB) E); else if (E instanceof Room) return getEveryoneHere(null, (Room) E); room.recoverRoomStats(); } } } else if (whoE instanceof Room) return getEveryoneHere(null, (Room) whoE); else if (whoE instanceof Area) { final Set<MOB> allMobs = new HashSet<MOB>(); for (final Enumeration r = ((Area) whoE).getMetroMap(); r.hasMoreElements(); ) { final Room R = (Room) r.nextElement(); allMobs.addAll(getEveryoneHere(null, R)); } } return new HashSet<MOB>(); }
@Override public void executeMsg(final Environmental myHost, final CMMsg msg) { super.executeMsg(myHost, msg); if (((msg.sourceMinor() == CMMsg.TYP_SHUTDOWN) || ((msg.targetMinor() == CMMsg.TYP_EXPIRE) && (msg.target() == affected)) || (msg.sourceMinor() == CMMsg.TYP_ROOMRESET)) && (affected instanceof Room)) { updateLot(null); final Vector mobs = new Vector(); Room R = (Room) affected; if (R != null) { synchronized (("SYNC" + R.roomID()).intern()) { R = CMLib.map().getRoom(R); for (int m = 0; m < R.numInhabitants(); m++) { final MOB M = R.fetchInhabitant(m); if ((M != null) && (M.isSavable()) && (M.getStartRoom() == R) && ((M.basePhyStats().rejuv() == 0) || (M.basePhyStats().rejuv() == PhyStats.NO_REJUV))) { CMLib.catalog().updateCatalogIntegrity(M); mobs.addElement(M); } } if (!CMSecurity.isSaveFlag(CMSecurity.SaveFlag.NOPROPERTYMOBS)) CMLib.database().DBUpdateTheseMOBs(R, mobs); } } } }
/** 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; } }
@Override public boolean invoke(MOB mob, Vector commands, Physical givenTarget, boolean auto, int asLevel) { MOB target = this.getTarget(mob, commands, givenTarget); if (target == null) return false; Room R = CMLib.map().roomLocation(target); if (R == null) R = mob.location(); if (!super.invoke(mob, commands, givenTarget, auto, asLevel)) return false; if ((auto) && (givenTarget != null) && (givenTarget instanceof MOB)) target = (MOB) givenTarget; // now see if it worked final boolean success = proficiencyCheck(mob, 0, auto); if (success) { final CMMsg msg = CMClass.getMsg( mob, target, this, somanticCastCode(mob, target, auto), auto ? "" : L("^S<S-NAME> speak(s) and gesture(s) to <T-NAMESELF>.^?")); if (R.okMessage(mob, msg)) { R.send(mob, msg); R.show(target, null, CMMsg.MSG_OK_VISUAL, L("<S-NAME> seem(s) much more likeable!")); beneficialAffect(mob, target, asLevel, 0); } } else return beneficialVisualFizzle( mob, target, L("<S-NAME> incant(s) gracefully to <T-NAMESELF>, but nothing more happens.")); // return whether it worked return success; }
public void makePuddle(Room R, int oldWeather, int newWeather) { for (int i = 0; i < R.numItems(); i++) { final Item I = R.getItem(i); if ((I instanceof Drink) && (!CMLib.flags().isGettable(I)) && ((I.name().toLowerCase().indexOf("puddle") >= 0) || (I.name().toLowerCase().indexOf("snow") >= 0))) return; } final Item I = CMClass.getItem("GenLiquidResource"); CMLib.flags().setGettable(I, false); ((Drink) I).setLiquidHeld(100); ((Drink) I).setLiquidRemaining(100); ((Drink) I).setLiquidType(RawMaterial.RESOURCE_FRESHWATER); I.setMaterial(RawMaterial.RESOURCE_FRESHWATER); I.basePhyStats().setDisposition(I.basePhyStats().disposition() | PhyStats.IS_UNSAVABLE); CMLib.materials().addEffectsToResource(I); I.recoverPhyStats(); if (coldWetWeather(oldWeather)) { I.setName(L("some snow")); I.setDisplayText(L("some snow rests on the ground here.")); I.setDescription(L("the snow is white and still quite cold!")); } else { I.setName(L("a puddle of water")); I.setDisplayText(L("a puddle of water has formed here.")); I.setDescription(L("It looks drinkable.")); } R.addItem(I, ItemPossessor.Expire.Monster_EQ); R.recoverRoomStats(); }
@Override protected Item buildMyPlant(MOB mob, Room room) { final int code = material & RawMaterial.RESOURCE_MASK; final Item newItem = CMClass.getBasicItem("GenItem"); final String name = CMLib.english().startWithAorAn(RawMaterial.CODES.NAME(code).toLowerCase() + " tree"); newItem.setName(name); newItem.setDisplayText(L("@x1 grows here.", newItem.name())); newItem.setDescription(""); newItem.basePhyStats().setWeight(10000); CMLib.flags().setGettable(newItem, false); newItem.setMaterial(material); newItem.setSecretIdentity(mob.Name()); newItem.setMiscText(newItem.text()); room.addItem(newItem); final Chant_SummonTree newChant = new Chant_SummonTree(); newItem.basePhyStats().setLevel(10 + newChant.getX1Level(mob)); newItem.setExpirationDate(0); room.showHappens( CMMsg.MSG_OK_ACTION, L("a tall, healthy @x1 tree sprouts up.", RawMaterial.CODES.NAME(code).toLowerCase())); room.recoverPhyStats(); newChant.plantsLocationR = room; newChant.littlePlantsI = newItem; if (CMLib.law().doesOwnThisLand(mob, room)) { newChant.setInvoker(mob); newChant.setMiscText(mob.Name()); newItem.addNonUninvokableEffect(newChant); } else newChant.beneficialAffect(mob, newItem, 0, (newChant.adjustedLevel(mob, 0) * 240) + 450); room.recoverPhyStats(); return newItem; }
@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; }
@Override public boolean invoke( MOB mob, List<String> commands, Physical givenTarget, boolean auto, int asLevel) { final MOB target = this.getTarget(mob, commands, givenTarget); if (target == null) return false; final boolean undead = CMLib.flags().isUndead(target); if (!super.invoke(mob, commands, givenTarget, auto, asLevel)) return false; final boolean success = proficiencyCheck(mob, 0, auto); if (success) { final CMMsg msg = CMClass.getMsg( mob, target, this, (undead ? 0 : CMMsg.MASK_MALICIOUS) | verbalCastCode(mob, target, auto), L( auto ? "A seriously painful burst assaults <T-NAME>." : "^S<S-NAME> " + prayWord(mob) + " for a serious burst of pain at <T-NAMESELF>!^?") + CMLib.protocol().msp("spelldam1.wav", 40)); final CMMsg msg2 = CMClass.getMsg( mob, target, this, CMMsg.MSK_CAST_MALICIOUS_VERBAL | CMMsg.TYP_UNDEAD | (auto ? CMMsg.MASK_ALWAYS : 0), null); final Room R = target.location(); if ((R != null) && (R.okMessage(mob, msg)) && ((R.okMessage(mob, msg2)))) { R.send(mob, msg); R.send(mob, msg2); if ((msg.value() <= 0) && (msg2.value() <= 0)) { final int harming = CMLib.dice().roll(1, adjustedLevel(mob, asLevel) + 6, 4); CMLib.combat() .postDamage( mob, target, this, harming, CMMsg.MASK_ALWAYS | CMMsg.TYP_UNDEAD, Weapon.TYPE_BURSTING, L("The unholy spell <DAMAGE> <T-NAME>!")); } } } else return maliciousFizzle( mob, target, L("<S-NAME> point(s) at <T-NAMESELF> and @x1, but nothing happens.", prayWord(mob))); // 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 boolean success = proficiencyCheck(mob, 0, auto); final String str = auto ? L("The unholy word is spoken.") : L("^S<S-NAME> speak(s) the unholy word@x1 to <T-NAMESELF>.^?", ofDiety(mob)); final Room room = mob.location(); if (room != null) for (int i = 0; i < room.numInhabitants(); i++) { final MOB target = room.fetchInhabitant(i); if (target == null) break; int affectType = CMMsg.MSG_CAST_VERBAL_SPELL; if (auto) affectType = affectType | CMMsg.MASK_ALWAYS; if (CMLib.flags().isGood(target)) affectType = affectType | CMMsg.MASK_MALICIOUS; if (success) { final CMMsg msg = CMClass.getMsg(mob, target, this, affectType, str); if (room.okMessage(mob, msg)) { room.send(mob, msg); if (msg.value() <= 0) { if (CMLib.flags().canBeHeardSpeakingBy(mob, target)) { final Item I = Prayer_Curse.getSomething(mob, true); if (I != null) { Prayer_Curse.endLowerBlessings(I, CMLib.ableMapper().lowestQualifyingLevel(ID())); I.recoverPhyStats(); } Prayer_Curse.endLowerBlessings( target, CMLib.ableMapper().lowestQualifyingLevel(ID())); beneficialAffect(mob, target, asLevel, 0); target.recoverPhyStats(); } else if (CMath.bset(affectType, CMMsg.MASK_MALICIOUS)) maliciousFizzle(mob, target, L("<T-NAME> did not hear the unholy word!")); else beneficialWordsFizzle(mob, target, L("<T-NAME> did not hear the unholy word!")); } } } else { if (CMath.bset(affectType, CMMsg.MASK_MALICIOUS)) maliciousFizzle( mob, target, L("<S-NAME> attempt(s) to speak the unholy word to <T-NAMESELF>, but flub(s) it.")); else beneficialWordsFizzle( mob, target, L("<S-NAME> attempt(s) to speak the unholy word to <T-NAMESELF>, but flub(s) it.")); return false; } } // return whether it worked return success; }
public boolean open( MOB mob, Environmental openThis, String openableWord, int dirCode, boolean quietly) { final String openWord = (!(openThis instanceof Exit)) ? "open" : ((Exit) openThis).openWord(); final String openMsg = quietly ? null : ("<S-NAME> " + openWord + "(s) <T-NAMESELF>.") + CMLib.protocol().msp("dooropen.wav", 10); final CMMsg msg = CMClass.getMsg(mob, openThis, null, CMMsg.MSG_OPEN, openMsg, openableWord, openMsg); if (openThis instanceof Exit) { final boolean open = ((Exit) openThis).isOpen(); if ((mob.location().okMessage(msg.source(), msg)) && (!open)) { mob.location().send(msg.source(), msg); if (dirCode < 0) for (int d = Directions.NUM_DIRECTIONS() - 1; d >= 0; d--) if (mob.location().getExitInDir(d) == openThis) { dirCode = d; break; } if ((dirCode >= 0) && (mob.location().getRoomInDir(dirCode) != null)) { final Room opR = mob.location().getRoomInDir(dirCode); final Exit opE = mob.location().getPairedExit(dirCode); if (opE != null) { final CMMsg altMsg = CMClass.getMsg( msg.source(), opE, msg.tool(), msg.sourceCode(), null, msg.targetCode(), null, msg.othersCode(), null); opE.executeMsg(msg.source(), altMsg); } final int opCode = Directions.getOpDirectionCode(dirCode); if ((opE != null) && (opE.isOpen()) && (((Exit) openThis).isOpen())) { final boolean useShipDirs = (opR instanceof BoardableShip) || (opR.getArea() instanceof BoardableShip); final String inDirName = useShipDirs ? Directions.getShipInDirectionName(opCode) : Directions.getInDirectionName(opCode); opR.showHappens(CMMsg.MSG_OK_ACTION, L("@x1 @x2 opens.", opE.name(), inDirName)); } return true; } } } else if (mob.location().okMessage(mob, msg)) { mob.location().send(mob, msg); return true; } return false; }
@Override public String runMacro(HTTPRequest httpReq, String parm, HTTPResponse httpResp) { final String last = httpReq.getUrlParameter("ROOM"); if (last == null) return " @break@"; if (last.length() > 0) { final Room R = MUDGrinder.getRoomObject(httpReq, last); if (R != null) return clearWebMacros(R.roomID()); } return ""; }
protected MOB getCharmer() { if (charmer != null) return charmer; if ((invoker != null) && (invoker != affected)) charmer = invoker; else if ((text().length() > 0) && (affected instanceof MOB)) { final Room R = ((MOB) affected).location(); if (R != null) charmer = R.fetchInhabitant(text()); } if (charmer == null) return invoker; return charmer; }
@Override public boolean invoke(MOB mob, Vector commands, Physical givenTarget, boolean auto, int asLevel) { final MOB target = this.getTarget(mob, commands, givenTarget); if (target == null) return false; Room R = CMLib.map().roomLocation(target); if (R == null) R = mob.location(); if (!super.invoke(mob, commands, givenTarget, auto, asLevel)) return false; final boolean success = proficiencyCheck(mob, 0, auto); if (success) { final CMMsg msg = CMClass.getMsg( mob, target, this, somanticCastCode(mob, target, auto), L( auto ? "<T-NAME> <T-IS-ARE> sprayed with acid." : "^S<S-NAME> reach(es) for <T-NAMESELF>, spraying acid all over <T-HIM-HER>!^?") + CMLib.protocol().msp("spelldam1.wav", 40)); final CMMsg msg2 = CMClass.getMsg( mob, target, this, CMMsg.MSK_CAST_MALICIOUS_VERBAL | CMMsg.TYP_ACID | (auto ? CMMsg.MASK_ALWAYS : 0), null); if ((R.okMessage(mob, msg)) && ((R.okMessage(mob, msg2)))) { R.send(mob, msg); R.send(mob, msg2); invoker = mob; final int numDice = (adjustedLevel(mob, asLevel) + (2 * super.getX1Level(invoker()))) / 2; int damage = CMLib.dice().roll(2, numDice, 1); if ((msg2.value() > 0) || (msg.value() > 0)) damage = (int) Math.round(CMath.div(damage, 2.0)); CMLib.combat() .postDamage( mob, target, this, damage, CMMsg.MASK_ALWAYS | CMMsg.TYP_ACID, Weapon.TYPE_MELTING, L("The acid <DAMAGE> <T-NAME>!")); maliciousAffect(mob, target, asLevel, 3, -1); } } else return maliciousFizzle( mob, target, L("<S-NAME> reach(es) for <T-NAMESELF>, but nothing more happens.")); return success; }
@Override public boolean tick(Tickable ticking, int tickID) { if (!super.tick(ticking, tickID)) return false; if (affected == null) return false; if (affected instanceof Room) { final Room R = (Room) affected; if ((R.getArea().getTimeObj().getTODCode() != TimeClock.TimeOfDay.DUSK) && (R.getArea().getTimeObj().getTODCode() != TimeClock.TimeOfDay.NIGHT)) unInvoke(); } return true; }
@Override public void unInvoke() { // undo the affects of this spell if (affected == null) return; if (canBeUninvoked()) { final Room R = CMLib.map().roomLocation(affected); if ((R != null) && (CMLib.flags().isInTheGame(affected, true))) R.showHappens(CMMsg.MSG_OK_VISUAL, L("The piercing moon sets.")); } super.unInvoke(); }
@Override public boolean invoke( MOB mob, List<String> commands, Physical givenTarget, boolean auto, int asLevel) { final MOB target = this.getTarget(mob, commands, givenTarget); if (target == null) return false; if (!super.invoke(mob, commands, givenTarget, auto, asLevel)) return false; final boolean success = proficiencyCheck(mob, 0, auto); final Room R = target.location(); if (success) { final Prayer_Thunderbolt newOne = (Prayer_Thunderbolt) this.copyOf(); final CMMsg msg = CMClass.getMsg( mob, target, newOne, verbalCastCode(mob, target, auto), L( auto ? "<T-NAME> is filled with a holy charge!" : "^S<S-NAME> " + prayForWord(mob) + " to strike down <T-NAMESELF>!^?") + CMLib.protocol().msp("lightning.wav", 40)); final CMMsg msg2 = CMClass.getMsg( mob, target, this, CMMsg.MSK_CAST_MALICIOUS_VERBAL | CMMsg.TYP_ELECTRIC | (auto ? CMMsg.MASK_ALWAYS : 0), null); if ((R.okMessage(mob, msg)) && ((R.okMessage(mob, msg2)))) { R.send(mob, msg); R.send(mob, msg2); if ((msg.value() <= 0) && (msg2.value() <= 0)) { final int harming = CMLib.dice().roll(1, adjustedLevel(mob, asLevel), adjustedLevel(mob, asLevel)); CMLib.combat() .postDamage( mob, target, this, harming, CMMsg.MASK_ALWAYS | CMMsg.TYP_ELECTRIC, Weapon.TYPE_STRIKING, L("^SThe STRIKE of @x1 <DAMAGES> <T-NAME>!^?", hisHerDiety(mob))); } } } else return maliciousFizzle(mob, target, L("<S-NAME> @x1, but nothing happens.", prayWord(mob))); // return whether it worked return success; }
@Override public void unInvoke() { // undo the affects of this spell if ((affected == null) || (!(affected instanceof Room))) return; final Room R = (Room) affected; super.unInvoke(); if (canBeUninvoked()) R.showHappens(CMMsg.MSG_OK_VISUAL, L("The harmful aura around you fades.")); }
public static boolean shopkeeperMobPresent(Room R) { if (R == null) return false; MOB M = null; for (int i = 0; i < R.numInhabitants(); i++) { M = R.fetchInhabitant(i); if ((M.getStartRoom() == R) && (M.isMonster()) && (CMLib.coffeeShops().getShopKeeper(M) != null)) return true; } return false; }
protected boolean canFallFrom(Room fromHere, int direction) { if ((fromHere == null) || (direction < 0) || (direction >= Directions.NUM_DIRECTIONS())) return false; final Room toHere = fromHere.getRoomInDir(direction); if ((toHere == null) || (fromHere.getExitInDir(direction) == null) || (!fromHere.getExitInDir(direction).isOpen())) return false; if (CMLib.flags().isWaterySurfaceRoom(fromHere) && CMLib.flags().isUnderWateryRoom(toHere)) return false; return true; }
@Override public boolean tick(Tickable ticking, int tickID) { if ((affected == null) || (!(affected instanceof Room))) return super.tick(ticking, tickID); if ((--damageTickDown) >= 0) return super.tick(ticking, tickID); damageTickDown = 4; HashSet H = null; if ((invoker() != null) && (invoker().location() == affected)) { H = new HashSet(); invoker().getGroupMembers(H); } final Room R = (Room) affected; for (int i = 0; i < R.numInhabitants(); i++) { final MOB M = R.fetchInhabitant(i); if ((M != null) && ((H == null) || (!H.contains(M)))) { if (invoker() != null) { final int harming = CMLib.dice().roll(1, adjustedLevel(invoker(), 0) / 3, 1); CMLib.combat() .postDamage( invoker(), M, this, harming, CMMsg.MASK_MALICIOUS | CMMsg.TYP_UNDEAD, Weapon.TYPE_BURSTING, L("The unholy aura <DAMAGE> <T-NAME>!")); } else { final int harming = CMLib.dice().roll(1, CMLib.ableMapper().lowestQualifyingLevel(ID()) / 3, 1); CMLib.combat() .postDamage( M, M, this, harming, CMMsg.MASK_MALICIOUS | CMMsg.TYP_UNDEAD, Weapon.TYPE_BURSTING, L("The unholy aura <DAMAGE> <T-NAME>!")); } if ((!M.isInCombat()) && (M.isMonster()) && (M != invoker) && (invoker != null) && (M.location() == invoker.location()) && (M.location().isInhabitant(invoker)) && (CMLib.flags().canBeSeenBy(invoker, M))) CMLib.combat().postAttack(M, invoker, M.fetchWieldedItem()); } } return super.tick(ticking, tickID); }
@Override public boolean okMessage(final Environmental myHost, final CMMsg msg) { if (affected == null) return super.okMessage(myHost, msg); if (affected instanceof MOB) { final MOB mob = (MOB) affected; if ((msg.amITarget(mob)) && (!msg.amISource(mob)) && (mob.location() != msg.source().location()) && (msg.tool() instanceof Ability) && (CMath.bset(((Ability) msg.tool()).flags(), Ability.FLAG_TRANSPORTING)) && (!mob.amDead())) { final Ability A = (Ability) msg.tool(); if (((A.classificationCode() & Ability.ALL_ACODES) == Ability.ACODE_CHANT) || ((A.classificationCode() & Ability.ALL_ACODES) == Ability.ACODE_SPELL) || ((A.classificationCode() & Ability.ALL_ACODES) == Ability.ACODE_PRAYER) || ((A.classificationCode() & Ability.ALL_ACODES) == Ability.ACODE_SONG)) msg.source() .location() .showHappens( CMMsg.MSG_OK_VISUAL, L("Magical energy fizzles and is absorbed into the air!")); return false; } } else if (affected instanceof Room) { final Room R = (Room) affected; if ((msg.tool() instanceof Ability) && (msg.source().location() != null) && (msg.sourceMinor() != CMMsg.TYP_LEAVE)) { final boolean summon = CMath.bset(((Ability) msg.tool()).flags(), Ability.FLAG_SUMMONING); final boolean teleport = CMath.bset(((Ability) msg.tool()).flags(), Ability.FLAG_TRANSPORTING); final boolean shere = (msg.source().location() == affected) || ((affected instanceof Area) && (((Area) affected).inMyMetroArea(msg.source().location().getArea()))); if ((!shere) && (!summon) && (teleport) && (!CMLib.law().doesHavePriviledgesHere(msg.source(), R))) { if ((msg.source().location() != null) && (msg.source().location() != R)) msg.source() .location() .showHappens( CMMsg.MSG_OK_VISUAL, L("Magical energy fizzles and is absorbed into the air!")); R.showHappens( CMMsg.MSG_OK_VISUAL, L("Magic energy fizzles and is absorbed into the air.")); return false; } } } return super.okMessage(myHost, msg); }
public MOB victimHere(Room room, MOB mob) { if (room == null) return null; if (mob == null) return null; for (int i = 0; i < room.numInhabitants(); i++) { final MOB M = room.fetchInhabitant(i); if ((M != null) && (M != mob) && (!CMLib.flags().isEvil(M)) && (mob.mayIFight(M)) && (M.phyStats().level() < (mob.phyStats().level() + 5))) return M; } return null; }
public Set<MOB> getEveryoneHere(MOB spareMe, Room R) { final Set<MOB> V = new HashSet<MOB>(); if (R == null) return V; for (int i = 0; i < R.numInhabitants(); i++) { final MOB M = R.fetchInhabitant(i); if ((spareMe != null) && (spareMe == M)) continue; if ((M != null) && (!CMSecurity.isAllowed(M, R, CMSecurity.SecFlag.IMMORT)) && ((mask == null) || (CMLib.masking().maskCheck(mask, M, false)))) V.add(M); } return V; // CMLib.combat().postDeath(null,M,null); }
public boolean nonIPnonMonsterWithMe(MOB me) { if ((me.location() != null) && (me.session() != null)) { final Room R = me.location(); for (int i = 0; i < R.numInhabitants(); i++) { final MOB M = R.fetchInhabitant(i); if ((M == null) || (M == me)) continue; if ((M.session() != null) && (M.session().getAddress().equals(me.session().getAddress()))) return true; } } return false; }
public static void doAnimalFreeingCheck(CharClass C, Environmental host, CMMsg msg) { if ((msg.source() != host) && (msg.sourceMinor() == CMMsg.TYP_NOFOLLOW) && (msg.source().isMonster()) && (host instanceof MOB) && (!((MOB) host).isMonster()) && (msg.target() == host) && (msg.source().getStartRoom() != null) && (CMLib.law().isACity(msg.source().getStartRoom().getArea())) && (((MOB) host).charStats().getCurrentClass().ID().equals(C.ID())) && (CMLib.flags().isAnimalIntelligence(msg.source()) || msg.source().charStats().getMyRace().racialCategory().equalsIgnoreCase("Vegetation") || msg.source() .charStats() .getMyRace() .racialCategory() .equalsIgnoreCase("Stone Golem")) && (CMLib.flags().flaggedAffects(msg.source(), Ability.FLAG_SUMMONING).size() == 0) && (msg.source().location() != null) && (!msg.source().amDestroyed()) && (CMLib.flags().isInTheGame((MOB) host, true)) && (!CMLib.law().isACity(msg.source().location().getArea()))) { Object[] stuff = (Object[]) animalChecking.get(host); final Room room = msg.source().location(); if ((stuff == null) || (System.currentTimeMillis() - ((Long) stuff[0]).longValue() > (room.getArea().getTimeObj().getDaysInMonth() * room.getArea().getTimeObj().getHoursInDay() * CMProps.getMillisPerMudHour()))) { stuff = new Object[3]; stuff[0] = Long.valueOf(System.currentTimeMillis()); animalChecking.remove(host); animalChecking.put(host, stuff); stuff[1] = Integer.valueOf(0); stuff[2] = new Vector(); } if ((((Integer) stuff[1]).intValue() < 19) && (!((List) stuff[2]).contains("" + msg.source()))) { stuff[1] = Integer.valueOf(((Integer) stuff[1]).intValue() + 1); ((MOB) host) .tell( CMLib.lang() .L( "You have freed @x1 from @x2.", msg.source().name((MOB) host), (msg.source().getStartRoom().getArea().name()))); CMLib.leveler() .postExperience((MOB) host, null, null, ((Integer) stuff[1]).intValue(), false); } } }
public void tickLycanthropically(MOB mob) { if (mob == null) return; if (mob.location() == null) return; if (mob.isInCombat()) return; if ((CMLib.dice().rollPercentage() < 15) && ((mob.location().domainType() & Room.INDOORS) > 0)) mob.location() .show(mob, null, CMMsg.MSG_NOISE, L("<S-NAME> howl(s) at the moon! ARROOOOOOOO!!!!")); // time to tick lycanthropically final MOB M = victimHere(mob.location(), mob); if (M != null) { deathTrail = null; CMLib.combat().postAttack(mob, M, mob.fetchWieldedItem()); return; } if ((deathTrail != null) && (!deathTrail.contains(mob.location()))) deathTrail = null; if (deathTrail == null) { final Vector rooms = new Vector(); if ((findVictim(mob, mob.location(), rooms, 0)) && (rooms.size() > 0)) { 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); deathTrail = CMLib.tracking().findBastardTheBestWay(mob.location(), rooms, flags, 50); if (deathTrail != null) deathTrail.add(mob.location()); } } if (deathTrail != null) { final int nextDirection = CMLib.tracking().trackNextDirectionFromHere(deathTrail, mob.location(), true); if ((nextDirection == 999) || (nextDirection == -1)) deathTrail = null; else if (nextDirection >= 0) { final Room nextRoom = mob.location().getRoomInDir(nextDirection); if ((nextRoom != null) && ((nextRoom.getArea() == mob.location().getArea())) || (!mob.isMonster())) { if (!CMLib.tracking().walk(mob, nextDirection, false, false)) deathTrail = null; else if (CMLib.dice().rollPercentage() < 15) mob.location().show(mob, null, CMMsg.MSG_NOISE, L("<S-NAME> sniff(s) at the air.")); } else deathTrail = null; } } }
@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 void unInvoke() { final Physical P = affected; super.unInvoke(); if ((P instanceof MOB) && (this.canBeUninvoked) && (this.unInvoked)) { if ((!P.amDestroyed()) && (((MOB) P).amFollowing() == null)) { final Room R = CMLib.map().roomLocation(P); if (CMLib.law().getLandOwnerName(R).length() == 0) { if (!CMLib.law().doesHavePriviledgesHere(invoker(), R)) { if ((R != null) && (!((MOB) P).amDead())) R.showHappens(CMMsg.MSG_OK_ACTION, P, L("<S-NAME> wander(s) off.")); P.destroy(); } } } } }
@Override public boolean invoke(MOB mob, Vector commands, Physical givenTarget, boolean auto, int asLevel) { final Item target = getTarget(mob, mob.location(), givenTarget, commands, Wearable.FILTER_ANY); if (target == null) return false; final Room room = CMLib.map().roomLocation(mob); if ((room == null) || (room.getArea() == null)) return false; final String roomID = CMLib.map().getExtendedRoomID(room); if ((CMath.bset(room.getArea().flags(), Area.FLAG_INSTANCE_CHILD)) || (roomID.length() == 0)) { mob.tell(L("The magic in this place will not permit it to become a refuge.")); return false; } if (!super.invoke(mob, commands, givenTarget, auto, asLevel)) return false; final boolean success = proficiencyCheck(mob, 0, auto); if (success) { final CMMsg msg = CMClass.getMsg( mob, target, this, verbalCastCode(mob, target, auto), auto ? "" : L("^S<S-NAME> point(s) at <T-NAMESELF> and @x1.^?", prayWord(mob))); if (mob.location().okMessage(mob, msg)) { mob.location().send(mob, msg); mob.location().show(mob, target, CMMsg.MSG_OK_VISUAL, L("<T-NAME> glows slightly!")); mob.tell( L( "@x1 will now await someone to 'SAYTO \"@x1\" Refuge' to it before teleporting you back here.", target.name(mob))); final Ability A = beneficialAffect(mob, target, asLevel, Ability.TICKS_ALMOST_FOREVER); if (A != null) A.setMiscText(roomID); target.recoverPhyStats(); mob.recoverPhyStats(); } } else beneficialVisualFizzle( mob, target, L("<S-NAME> point(s) at <T-NAMESELF>, but fail(s) to properly pray.")); // return whether it worked return success; }