public void unInvoke() { if (canBeUninvoked()) { if (newRoom != null) { newRoom.showHappens(CMMsg.MSG_OK_VISUAL, "The divine gateway closes."); newRoom.rawDoors()[Directions.GATE] = null; newRoom.setRawExit(Directions.GATE, null); } if (oldRoom != null) { oldRoom.showHappens(CMMsg.MSG_OK_VISUAL, "The divine gateway closes."); oldRoom.rawDoors()[Directions.GATE] = null; oldRoom.setRawExit(Directions.GATE, null); } } super.unInvoke(); }
@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; }
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 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 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.")); }
@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); }
@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(); } } } } }
public boolean execute(MOB mob, Vector commands, int metaFlags) throws java.io.IOException { String whatToOpen = CMParms.combine(commands, 1); if (whatToOpen.length() == 0) { mob.tell("Open what?"); return false; } Environmental openThis = null; int dirCode = Directions.getGoodDirectionCode(whatToOpen); if (dirCode >= 0) openThis = mob.location().getExitInDir(dirCode); if (openThis == null) openThis = mob.location().fetchFromMOBRoomItemExit(mob, null, whatToOpen, Item.WORNREQ_ANY); if ((openThis == null) || (!CMLib.flags().canBeSeenBy(openThis, mob))) { mob.tell("You don't see '" + whatToOpen + "' here."); return false; } String openWord = (!(openThis instanceof Exit)) ? "open" : ((Exit) openThis).openWord(); CMMsg msg = CMClass.getMsg( mob, openThis, null, CMMsg.MSG_OPEN, ("<S-NAME> " + openWord + "(s) <T-NAMESELF>.") + CMProps.msp("dooropen.wav", 10)); if (openThis instanceof Exit) { 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)) { Room opR = mob.location().getRoomInDir(dirCode); Exit opE = mob.location().getPairedExit(dirCode); if (opE != null) { CMMsg altMsg = CMClass.getMsg( msg.source(), opE, msg.tool(), msg.sourceCode(), null, msg.targetCode(), null, msg.othersCode(), null); opE.executeMsg(msg.source(), altMsg); } int opCode = Directions.getOpDirectionCode(dirCode); if ((opE != null) && (opE.isOpen()) && (((Exit) openThis).isOpen())) opR.showHappens( CMMsg.MSG_OK_ACTION, opE.name() + " " + Directions.getInDirectionName(opCode) + " opens."); } } } else if (mob.location().okMessage(mob, msg)) mob.location().send(mob, msg); return false; }