public boolean execute(MOB mob, Vector commands, int metaFlags) throws java.io.IOException { if (commands != null) commands.removeElementAt(0); if ((commands == null) || (commands.size() == 0)) { if (!CMLib.flags().isSleeping(mob)) mob.tell("You aren't sleeping!?"); else { CMMsg msg = CMClass.getMsg(mob, null, null, CMMsg.MSG_STAND, "<S-NAME> awake(s) and stand(s) up."); if (mob.location().okMessage(mob, msg)) mob.location().send(mob, msg); } } else { String whom = CMParms.combine(commands, 0); MOB M = mob.location().fetchInhabitant(whom); if ((M == null) || (!CMLib.flags().canBeSeenBy(M, mob))) { mob.tell("You don't see '" + whom + "' here."); return false; } if (!CMLib.flags().isSleeping(M)) { mob.tell(M.name() + " is awake!"); return false; } CMMsg msg = CMClass.getMsg( mob, M, null, CMMsg.MSG_NOISYMOVEMENT, "<S-NAME> attempt(s) to wake <T-NAME> up."); if (mob.location().okMessage(mob, msg)) { mob.location().send(mob, msg); execute(M, null, metaFlags | Command.METAFLAG_ORDER); } } return false; }
@Override public void destroy() { try { CharStats savedCStats = charStats; if (charStats == baseCharStats) savedCStats = (CharStats) CMClass.getCommon("DefaultCharStats"); PhyStats savedPStats = phyStats; if (phyStats == basePhyStats) savedPStats = (PhyStats) CMClass.getCommon("DefaultPhyStats"); final CharState savedCState = curState; if ((curState == baseState) || (curState == maxState)) curState = (CharState) CMClass.getCommon("DefaultCharState"); super.destroy(); removeFromGame = false; charStats = savedCStats; phyStats = savedPStats; curState = savedCState; baseCharStats.reset(); basePhyStats.reset(); baseState.reset(); maxState.reset(); curState.reset(); phyStats.reset(); charStats.reset(); finalize(); } catch (final Throwable t) { Log.errOut(ID(), t); } }
@Override public void executeMsg(final Environmental myHost, final CMMsg msg) { if ((msg.amITarget(this) || (msg.targetMinor() == CMMsg.TYP_ADVANCE) || (msg.targetMinor() == CMMsg.TYP_RETREAT)) && (!msg.source().isMonster()) && (msg.source().curState().getHitPoints() < msg.source().maxState().getHitPoints()) && (CMLib.dice().rollPercentage() == 1) && (CMLib.dice().rollPercentage() == 1) && (!CMSecurity.isDisabled(CMSecurity.DisFlag.AUTODISEASE))) { Ability A = null; if (CMLib.dice().rollPercentage() > 50) A = CMClass.getAbility("Disease_Chlamydia"); else A = CMClass.getAbility("Disease_Malaria"); if ((A != null) && (msg.source().fetchEffect(A.ID()) == null)) A.invoke(msg.source(), msg.source(), true, 0); } if (msg.amITarget(this) && (msg.targetMinor() == CMMsg.TYP_DRINK)) { final MOB mob = msg.source(); final boolean thirsty = mob.curState().getThirst() <= 0; final boolean full = !mob.curState().adjThirst(thirstQuenched(), mob.maxState().maxThirst(mob.baseWeight())); if (thirsty) mob.tell(L("You are no longer thirsty.")); else if (full) mob.tell(L("You have drunk all you can.")); if (CMLib.dice().rollPercentage() < 10) { Ability A = CMClass.getAbility("Disease_Malaria"); if ((A != null) && (msg.source().fetchEffect(A.ID()) == null)) A.invoke(msg.source(), msg.source(), true, 0); } } super.executeMsg(myHost, msg); }
public InvisibleStalker() { super(); Random randomizer = new Random(System.currentTimeMillis()); username = "******"; setDescription("A shimmering blob of energy."); setDisplayText("An invisible stalker hunts here."); CMLib.factions().setAlignment(this, Faction.ALIGN_NEUTRAL); setMoney(0); basePhyStats.setWeight(10 + Math.abs(randomizer.nextInt() % 10)); baseCharStats().setStat(CharStats.STAT_INTELLIGENCE, 12 + Math.abs(randomizer.nextInt() % 3)); baseCharStats().setStat(CharStats.STAT_STRENGTH, 20); baseCharStats().setStat(CharStats.STAT_DEXTERITY, 13); basePhyStats().setDamage(16); basePhyStats().setSpeed(1.0); basePhyStats().setAbility(0); basePhyStats().setLevel(4); basePhyStats().setArmor(0); basePhyStats().setDisposition(basePhyStats().disposition() | PhyStats.IS_INVISIBLE); baseState.setHitPoints(CMLib.dice().roll(basePhyStats().level(), 20, basePhyStats().level())); addBehavior(CMClass.getBehavior("Aggressive")); addBehavior(CMClass.getBehavior("Mobile")); recoverMaxState(); resetToMaxState(); recoverPhyStats(); recoverCharStats(); }
@Override public void spring(MOB target) { if ((target != invoker()) && (target.location() != null)) { if ((doesSaveVsTraps(target)) || (invoker().getGroupMembers(new HashSet<MOB>()).contains(target))) target .location() .show( target, null, null, CMMsg.MASK_ALWAYS | CMMsg.MSG_NOISE, L("<S-NAME> avoid(s) setting off a gas trap!")); else if (target .location() .show( target, target, this, CMMsg.MASK_ALWAYS | CMMsg.MSG_NOISE, L("<S-NAME> set(s) off a trap! The room fills with gas!"))) { super.spring(target); Ability A = CMClass.getAbility(text()); if (A == null) A = CMClass.getAbility("Poison"); for (int i = 0; i < target.location().numInhabitants(); i++) { final MOB M = target.location().fetchInhabitant(i); if ((M != null) && (M != invoker()) && (A != null)) if (invoker().mayIFight(M)) A.invoke(invoker(), M, true, 0); } if ((canBeUninvoked()) && (affected instanceof Item)) disable(); } } }
public boolean invoke( MOB mob, Vector commands, Environmental givenTarget, boolean auto, int asLevel) { if (!super.invoke(mob, commands, givenTarget, auto, asLevel)) return false; HashSet h = properTargets(mob, givenTarget, auto); if (h == null) return false; boolean success = proficiencyCheck(mob, 0, auto); boolean nothingDone = true; if (success) { for (Iterator e = h.iterator(); e.hasNext(); ) { MOB target = (MOB) e.next(); // it worked, so build a copy of this ability, // and add it to the affects list of the // affected MOB. Then tell everyone else // what happened. CMMsg msg = CMClass.getMsg( mob, target, this, verbalCastCode(mob, target, auto) | CMMsg.MASK_MALICIOUS, auto ? "" : "^S<S-NAME> " + prayForWord(mob) + " an unholy paralysis upon <T-NAMESELF>.^?"); CMMsg msg2 = CMClass.getMsg( mob, target, this, CMMsg.MASK_MALICIOUS | CMMsg.TYP_PARALYZE | (auto ? CMMsg.MASK_ALWAYS : 0), null); if ((target != mob) && (mob.location().okMessage(mob, msg)) && (mob.location().okMessage(mob, msg2))) { int levelDiff = target.envStats().level() - (mob.envStats().level() + (2 * super.getXLEVELLevel(mob))); if (levelDiff < 0) levelDiff = 0; if (levelDiff > 6) levelDiff = 6; mob.location().send(mob, msg); mob.location().send(mob, msg2); if ((msg.value() <= 0) && (msg2.value() <= 0)) { success = maliciousAffect(mob, target, asLevel, 8 - levelDiff, -1); mob.location().show(target, null, CMMsg.MSG_OK_VISUAL, "<S-NAME> can't move!"); } nothingDone = false; } } } if (nothingDone) return maliciousFizzle( mob, null, "<S-NAME> attempt(s) to paralyze everyone, but flub(s) it."); // return whether it worked return success; }
public HeavenlyServent() { super(); Random randomizer = new Random(System.currentTimeMillis()); username = "******"; setDescription( "An angelic form in gowns of white, with golden hair, and an ever present smile."); setDisplayText("A servant of the Archons is running errands."); CMLib.factions().setAlignment(this, Faction.ALIGN_NEUTRAL); setMoney(0); basePhyStats.setWeight(20 + Math.abs(randomizer.nextInt() % 55)); setWimpHitPoint(2); addBehavior(CMClass.getBehavior("Mobile")); addBehavior(CMClass.getBehavior("MudChat")); basePhyStats().setDamage(25); basePhyStats().setAbility(0); basePhyStats().setLevel(10); basePhyStats().setArmor(0); baseCharStats().setMyRace(CMClass.getRace("Human")); baseCharStats().getMyRace().startRacing(this, false); baseState.setHitPoints(CMLib.dice().roll(basePhyStats().level(), 20, basePhyStats().level())); recoverMaxState(); resetToMaxState(); recoverPhyStats(); recoverCharStats(); }
@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; if (!super.invoke(mob, commands, givenTarget, auto, asLevel)) return false; // 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), L( (auto ? "A " : "^S<S-NAME> incant(s) and point(s) at <T-NAMESELF>. A ") + "long shard of ice streaks through the air!^?") + CMLib.protocol().msp("spelldam2.wav", 40)); final CMMsg msg2 = CMClass.getMsg( mob, target, this, CMMsg.MSK_CAST_MALICIOUS_VERBAL | CMMsg.TYP_COLD | (auto ? CMMsg.MASK_ALWAYS : 0), null); if ((mob.location().okMessage(mob, msg)) && (mob.location().okMessage(mob, msg2))) { mob.location().send(mob, msg); invoker = mob; int damage = 0; final int maxDie = (adjustedLevel(mob, asLevel) + (2 * super.getX1Level(mob))) / 2; damage += CMLib.dice().roll(maxDie, 6, 15); mob.location().send(mob, msg2); if ((msg2.value() > 0) || (msg.value() > 0)) damage = (int) Math.round(CMath.div(damage, 2.0)); if (target.location() == mob.location()) CMLib.combat() .postDamage( mob, target, this, damage, CMMsg.MASK_ALWAYS | CMMsg.TYP_COLD, Weapon.TYPE_FROSTING, L("The lance <DAMAGE> <T-NAME>!")); } } else return maliciousFizzle( mob, target, L("<S-NAME> incant(s) and point(s) at <T-NAMESELF>, but flub(s) the spell.")); // return whether it worked return success; }
@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 void grantAbilities(MOB mob, boolean isBorrowedClass) { super.grantAbilities(mob, isBorrowedClass); if (mob.playerStats() == null) { final List<AbilityMapper.AbilityMapping> V = CMLib.ableMapper() .getUpToLevelListings(ID(), mob.charStats().getClassLevel(ID()), false, false); for (final AbilityMapper.AbilityMapping able : V) { final Ability A = CMClass.getAbility(able.abilityID); if ((A != null) && ((A.classificationCode() & Ability.ALL_ACODES) == Ability.ACODE_CHANT) && (!CMLib.ableMapper().getDefaultGain(ID(), true, A.ID()))) giveMobAbility( mob, A, CMLib.ableMapper().getDefaultProficiency(ID(), true, A.ID()), CMLib.ableMapper().getDefaultParm(ID(), true, A.ID()), isBorrowedClass); } return; } final Vector grantable = new Vector(); final int level = mob.charStats().getClassLevel(this); int numChants = 2; for (final Enumeration<Ability> a = CMClass.abilities(); a.hasMoreElements(); ) { final Ability A = a.nextElement(); if ((CMLib.ableMapper().getQualifyingLevel(ID(), true, A.ID()) == level) && ((CMLib.ableMapper().getQualifyingLevel(ID(), true, A.ID()) <= 25) && (!CMLib.ableMapper().getSecretSkill(ID(), true, A.ID())) && (!CMLib.ableMapper().getDefaultGain(ID(), true, A.ID())) && ((A.classificationCode() & Ability.ALL_ACODES) == Ability.ACODE_CHANT))) { if (!grantable.contains(A.ID())) grantable.addElement(A.ID()); } } for (int a = 0; a < mob.numAbilities(); a++) { final Ability A = mob.fetchAbility(a); if (grantable.contains(A.ID())) { grantable.remove(A.ID()); numChants--; } } for (int i = 0; i < numChants; i++) { if (grantable.size() == 0) break; final String AID = (String) grantable.elementAt(CMLib.dice().roll(1, grantable.size(), -1)); if (AID != null) { grantable.removeElement(AID); giveMobAbility( mob, CMClass.getAbility(AID), CMLib.ableMapper().getDefaultProficiency(ID(), true, AID), CMLib.ableMapper().getDefaultParm(ID(), true, AID), isBorrowedClass); } } }
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; }
public boolean invoke(MOB mob, Vector commands, Physical givenTarget, boolean auto, int asLevel) { if (commands.size() < 1) { mob.tell("Chant to whom?"); return false; } String mobName = CMParms.combine(commands, 0).trim().toUpperCase(); MOB target = getTarget(mob, commands, givenTarget); Room newRoom = mob.location(); if (target != null) { newRoom = target.location(); if ((!CMLib.flags().isAnimalIntelligence(target)) || (target.amFollowing() != mob)) { mob.tell("You have no animal follower named '" + mobName + "' here."); return false; } } else { mob.tell("You have no animal follower named '" + mobName + "' here."); 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, target, this, verbalCastCode(mob, target, auto), auto ? "" : "^S<S-NAME> chant(s) to <T-NAMESELF>, invoking the a mystical connection.^?"); CMMsg msg2 = CMClass.getMsg(mob, target, this, verbalCastCode(mob, target, auto), null); if ((mob.location().okMessage(mob, msg)) && ((newRoom == mob.location()) || (newRoom.okMessage(mob, msg2)))) { mob.location().send(mob, msg); if (newRoom != mob.location()) newRoom.send(target, msg2); spy = target; beneficialAffect(mob, spy, asLevel, 0); Ability A = spy.fetchEffect(ID()); if (A != null) { mob.addNonUninvokableEffect((Ability) A.copyOf()); A.setAffectedOne(spy); } } } else beneficialVisualFizzle( mob, target, "<S-NAME> chant(s) to <T-NAMESELF>, but the magic fades."); // return whether it worked return success; }
@Override public List<Item> getTrapComponents() { final Vector V = new Vector(); final Item I = CMLib.materials().makeItemResource(RawMaterial.RESOURCE_POISON); Ability A = CMClass.getAbility(text()); if (A == null) A = CMClass.getAbility("Poison"); I.addNonUninvokableEffect(A); V.addElement(I); return V; }
public boolean invoke(MOB mob, Vector commands, Physical givenTarget, boolean auto, int asLevel) { if (mob.fetchEffect("Thief_Hide") != null) { mob.tell("You are already hiding."); return false; } if (mob.isInCombat()) { mob.tell("Not while in combat!"); return false; } if (!super.invoke(mob, commands, givenTarget, auto, asLevel)) return false; Set<MOB> H = mob.getGroupMembers(new HashSet<MOB>()); if (!H.contains(mob)) H.add(mob); int numBesidesMe = 0; for (Iterator e = H.iterator(); e.hasNext(); ) { MOB M = (MOB) e.next(); if ((M != mob) && (mob.location().isInhabitant(M))) numBesidesMe++; } if (numBesidesMe == 0) { mob.tell("You need a group to set up an ambush!"); return false; } for (int i = 0; i < mob.location().numInhabitants(); i++) { MOB M = mob.location().fetchInhabitant(i); if ((M != null) && (M != mob) && (!H.contains(M)) && (CMLib.flags().canSee(M))) { mob.tell(M, null, null, "<S-NAME> is watching you too closely."); return false; } } boolean success = proficiencyCheck(mob, 0, auto); if (!success) beneficialVisualFizzle(mob, null, "<S-NAME> attempt(s) to set up an ambush, but fail(s)."); else { CMMsg msg = CMClass.getMsg( mob, null, this, auto ? CMMsg.MSG_OK_ACTION : (CMMsg.MSG_DELICATE_HANDS_ACT | CMMsg.MASK_MOVE), "<S-NAME> set(s) up an ambush, directing everyone to hiding places."); if (mob.location().okMessage(mob, msg)) { mob.location().send(mob, msg); invoker = mob; Ability hide = CMClass.getAbility("Thief_Hide"); for (Iterator e = H.iterator(); e.hasNext(); ) { MOB M = (MOB) e.next(); hide.invoke(M, M, true, adjustedLevel(mob, asLevel)); } } else success = false; } return success; }
@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 invoke(MOB mob, Vector 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); if (success) { final CMMsg msg = CMClass.getMsg( mob, target, this, CMMsg.MSK_CAST_MALICIOUS_VERBAL | CMMsg.TYP_UNDEAD | (auto ? CMMsg.MASK_ALWAYS : 0), null); final CMMsg msg2 = CMClass.getMsg( mob, target, this, verbalCastCode(mob, target, auto), auto ? "" : L("^S<S-NAME> reach(es) at <T-NAMESELF>, @x1!^?", prayingWord(mob))); if ((mob.location().okMessage(mob, msg)) && (mob.location().okMessage(mob, msg2))) { mob.location().send(mob, msg2); mob.location().send(mob, msg); if ((msg.value() <= 0) && (msg2.value() <= 0)) { final int damage = CMLib.dice().roll(1, adjustedLevel(mob, asLevel), 0); CMLib.combat() .postDamage( mob, target, this, damage, CMMsg.MASK_ALWAYS | CMMsg.TYP_UNDEAD, Weapon.TYPE_BURSTING, auto ? L("<T-NAME> shudder(s) in a draining magical wake.") : L("The draining grasp <DAMAGE> <T-NAME>.")); if (mob != target) CMLib.combat() .postHealing( mob, mob, this, CMMsg.MASK_ALWAYS | CMMsg.TYP_CAST_SPELL, damage, null); } } } else return maliciousFizzle( mob, target, L("<S-NAME> reach(es) for <T-NAMESELF>, @x1, but the spell fades.", prayingWord(mob))); // return whether it worked return success; }
@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 boolean invoke( MOB mob, List<String> commands, Physical givenTarget, boolean auto, int asLevel) { MOB target = CMLib.players().getLoadPlayer(CMParms.combine(commands, 0)); if (target == null) target = getTargetAnywhere(mob, commands, givenTarget, false, true, false); if (target == null) return false; final Archon_Record A = (Archon_Record) target.fetchEffect(ID()); if (A != null) { target.delEffect(A); if (target.playerStats() != null) target.playerStats().setLastUpdated(0); mob.tell(L("@x1 will no longer be recorded.", target.Name())); return true; } 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, CMMsg.MASK_MOVE | CMMsg.TYP_JUSTICE | (auto ? CMMsg.MASK_ALWAYS : 0), L("^F<S-NAME> begin(s) recording <T-NAMESELF>.^?")); CMLib.color().fixSourceFightColor(msg); if (mob.location().okMessage(mob, msg)) { mob.location().send(mob, msg); final String filename = "/" + target.Name() + System.currentTimeMillis() + ".log"; final CMFile file = new CMFile(filename, null, CMFile.FLAG_LOGERRORS); if (!file.canWrite()) { if (!CMSecurity.isASysOp(mob) || (CMSecurity.isASysOp(target))) Log.sysOut("Record", mob.Name() + " failed to start recording " + target.name() + "."); } else { if (!CMSecurity.isASysOp(mob) || (CMSecurity.isASysOp(target))) Log.sysOut( "Record", mob.Name() + " started recording " + target.name() + " to /" + filename + "."); final Archon_Record A2 = (Archon_Record) copyOf(); final Session F = (Session) CMClass.getCommon("FakeSession"); F.initializeSession(null, Thread.currentThread().getThreadGroup().getName(), filename); if (target.session() == null) target.setSession(F); A2.sess = F; target.addNonUninvokableEffect(A2); mob.tell(L("Enter RECORD @x1 again to stop recording.", target.Name())); } } } else return beneficialVisualFizzle( mob, target, L("<S-NAME> attempt(s) to hush <T-NAMESELF>, but fail(s).")); return success; }
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; if (!super.invoke(mob, commands, givenTarget, auto, asLevel)) return false; boolean success = proficiencyCheck(mob, 0, auto); CMMsg msg2 = null; if ((mob != target) && (!mob.getGroupMembers(new HashSet<MOB>()).contains(target))) msg2 = CMClass.getMsg( mob, target, this, verbalCastCode(mob, target, auto) | CMMsg.MASK_MALICIOUS, "<T-NAME> do(es) not seem to like <S-NAME> messing with <T-HIS-HER> head."); if (success && (CMLib.factions().getFaction(CMLib.factions().AlignID()) != null)) { // it worked, so build a copy of this ability, // and add it to the affects list of the // affected MOB. Then tell everyone else // what happened. CMMsg msg = CMClass.getMsg( mob, target, this, verbalCastCode(mob, target, auto), (auto ? "<T-NAME> feel(s) more good." : "^S<S-NAME> " + prayWord(mob) + " to atone <T-NAMESELF>!^?")); if ((mob.location().okMessage(mob, msg)) && ((msg2 == null) || (mob.location().okMessage(mob, msg2)))) { mob.location().send(mob, msg); if ((msg.value() <= 0) && ((msg2 == null) || (msg2.value() <= 0))) { target.tell("Good, pure thoughts fill your head."); int evilness = CMLib.dice().roll(10, adjustedLevel(mob, asLevel), 0); CMLib.factions().postFactionChange(target, this, CMLib.factions().AlignID(), evilness); } if (msg2 != null) mob.location().send(mob, msg2); } } else { if ((msg2 != null) && (mob.location().okMessage(mob, msg2))) mob.location().send(mob, msg2); return beneficialWordsFizzle( mob, target, "<S-NAME> point(s) at <T-NAMESELF> and " + prayWord(mob) + ", but nothing happens."); } // return whether it worked return success; }
@Override public void setMiscText(String txt) { super.setMiscText(""); if (txt.startsWith("-")) { txt = txt.substring(1).toLowerCase().trim(); for (final Object[] A : affects) if (((CMObject) A[0]).ID().toLowerCase().equals(txt)) { unAffectAffected(A); return; } for (final Object[] A : affects) if ((A[0] instanceof Ability) && (((Environmental) A[0]).name().toLowerCase().startsWith(txt))) { unAffectAffected(A); return; } for (final Object[] A : affects) if ((A[0] instanceof Behavior) && (((Behavior) A[0]).name().toLowerCase().startsWith(txt))) { unAffectAffected(A); return; } } else if (txt.trim().length() > 0) { if (txt.startsWith("+")) txt = txt.substring(1); else for (final Object[] A : affects) unAffectAffected(A); int x = txt.indexOf(' '); if (x < 0) return; final String abilityStr = txt.substring(0, x).trim(); String numTicksStr = txt.substring(x + 1).trim(); String parms = ""; x = numTicksStr.indexOf(' '); if (x > 0) { parms = numTicksStr.substring(x + 1).trim(); numTicksStr = numTicksStr.substring(0, x); } CMObject A = CMClass.getAbility(abilityStr); if (A == null) A = CMClass.getBehavior(abilityStr); if (A == null) A = CMClass.findAbility(abilityStr); if (A == null) A = CMClass.findBehavior(abilityStr); if (A != null) { affects.addElement(new Object[] {A, new int[] {CMath.s_int(numTicksStr)}}); if (A instanceof Ability) ((Ability) A).setMiscText(parms); if ((A instanceof Behavior) && (affected instanceof PhysicalAgent)) ((Behavior) A).setParms(parms); finishInit(A); } } }
@Override public boolean tick(Tickable ticking, int tickID) { if ((!built) && (affected instanceof MOB)) { built = true; CharClass C = null; final Vector allowedClasses = new Vector(); final Vector allowedExpertises = new Vector(); final Vector<String> V = CMParms.parse(text()); String s = null; for (int v = 0; v < V.size(); v++) { s = V.elementAt(v); if (s.equalsIgnoreCase("all")) continue; C = CMClass.getCharClass(s); if (C != null) { if ((v > 0) && (V.elementAt(v - 1).equalsIgnoreCase("ALL"))) { final String baseClass = C.baseClass(); for (final Enumeration c = CMClass.charClasses(); c.hasMoreElements(); ) { C = (CharClass) c.nextElement(); if ((C.baseClass().equalsIgnoreCase(baseClass)) && (!allowedClasses.contains(C))) allowedClasses.addElement(C); } } else allowedClasses.addElement(C); } else { final ExpertiseLibrary.ExpertiseDefinition def = CMLib.expertises().getDefinition(s); if (def != null) allowedExpertises.addElement(def); } } if (allowedClasses.size() == 0) for (final Enumeration c = CMClass.charClasses(); c.hasMoreElements(); ) allowedClasses.addElement(c.nextElement()); if (allowedExpertises.size() == 0) for (final Enumeration e = CMLib.expertises().definitions(); e.hasMoreElements(); ) allowedExpertises.addElement(e.nextElement()); final MOB mob = (MOB) affected; for (int c = 0; c < allowedClasses.size(); c++) { C = (CharClass) allowedClasses.elementAt(c); addCharClassIfNotFound(mob, C); } for (int e = 0; e < allowedExpertises.size(); e++) mob.addExpertise( ((ExpertiseLibrary.ExpertiseDefinition) allowedExpertises.elementAt(e)).ID); mob.recoverCharStats(); mob.recoverPhyStats(); mob.recoverMaxState(); } return super.tick(ticking, tickID); }
public Python() { super(); username = "******"; setDescription("A humungous snake that is known for squeezing you to DEATH."); setDisplayText("A python wants to give you a hug."); CMLib.factions().setAlignment(this, Faction.Align.NEUTRAL); setMoney(0); basePhyStats().setDamage(7); baseCharStats().setStat(CharStats.STAT_INTELLIGENCE, 1); basePhyStats().setAbility(0); basePhyStats().setLevel(1); basePhyStats().setArmor(90); baseCharStats().setMyRace(CMClass.getRace("Snake")); baseCharStats().getMyRace().startRacing(this, false); baseState.setHitPoints(CMLib.dice().roll(basePhyStats().level(), 20, basePhyStats().level())); recoverMaxState(); resetToMaxState(); recoverPhyStats(); recoverCharStats(); }
@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 void spring(MOB target) { if (target.location() != null) { if ((!invoker().mayIFight(target)) || (isLocalExempt(target)) || (invoker().getGroupMembers(new HashSet<MOB>()).contains(target)) || (target == invoker()) || (doesSaveVsTraps(target))) target .location() .show( target, null, null, CMMsg.MASK_ALWAYS | CMMsg.MSG_NOISE, L("<S-NAME> avoid(s) the water bomb!")); else if (target .location() .show( invoker(), target, this, CMMsg.MASK_ALWAYS | CMMsg.MSG_NOISE, L("@x1 explodes water all over <T-NAME>!", affected.name()))) { super.spring(target); final Ability A = CMClass.getAbility("Spell_Irritation"); if (A != null) A.invoke(target, target, true, invoker().phyStats().level() + abilityCode()); } } }
@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; if (!super.invoke(mob, commands, givenTarget, auto, asLevel)) return false; 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> incant(s) at <T-NAMESELF>.^?")); if (mob.location().okMessage(mob, msg)) { mob.location().send(mob, msg); if (msg.value() <= 0) { mob.location().show(target, null, CMMsg.MSG_OK_VISUAL, L("<S-NAME> get(s) sick!")); success = maliciousAffect(mob, target, asLevel, 0, -1) != null; } } } else return maliciousFizzle( mob, target, L("<S-NAME> incant(s) at <T-NAMESELF>, but the spell fizzles.")); // return whether it worked return success; }
@Override public boolean invoke(MOB mob, Vector commands, Physical givenTarget, boolean auto, int asLevel) { final MOB target = 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); if (success) { final CMMsg msg = CMClass.getMsg( mob, target, this, verbalCastCode(mob, target, auto), auto ? "" : L("^S<S-NAME> whistle(s) to <T-NAMESELF>.^?")); if (mob.location().okMessage(mob, msg)) { mob.location().send(mob, msg); mob.location() .show(target, null, CMMsg.MSG_OK_VISUAL, L("<S-NAME> attain(s) an aquatic aura!")); beneficialAffect(mob, target, asLevel, 0); } } else beneficialWordsFizzle( mob, target, L("<S-NAME> whistle(s) to <T-NAMESELF>, but nothing happens.")); return success; }
public boolean invoke(MOB mob, Vector commands, Physical givenTarget, boolean auto, int asLevel) { Physical target = getAnyTarget(mob, commands, givenTarget, Wearable.FILTER_ANY); if (target == null) return false; if (!super.invoke(mob, commands, givenTarget, auto, asLevel)) return false; boolean success = proficiencyCheck(mob, 0, auto); if (success) { // it worked, so build a copy of this ability, // and add it to the affects list of the // affected MOB. Then tell everyone else // what happened. CMMsg msg = CMClass.getMsg( mob, target, this, verbalCastCode(mob, target, auto), auto ? "" : "^S<S-NAME> " + prayWord(mob) + " to extinguish <T-NAMESELF>.^?"); if (mob.location().okMessage(mob, msg)) { mob.location().send(mob, msg); CMLib.utensils().extinguish(mob, target, false); target.recoverPhyStats(); mob.location().recoverRoomStats(); } } else return beneficialWordsFizzle( mob, target, "<S-NAME> " + prayWord(mob) + " to extinguish <T-NAMESELF>, but nothing happens."); // return whether it worked return success; }
@Override protected Ability getSpell() { if (theSpell != null) return theSpell; if (mimicSpell().length() == 0) return null; theSpell = CMClass.getAbility(mimicSpell()); return theSpell; }
public void initializeClass() { super.initializeClass(); CMLib.ableMapper().addCharAbilityMapping(ID(), 1, "Skill_Spellcraft", 50, true); CMLib.ableMapper().addCharAbilityMapping(ID(), 1, "Skill_ScrollCopy", 100, true); CMLib.ableMapper().addCharAbilityMapping(ID(), 1, "Spell_Scribe", 75, true); CMLib.ableMapper().addCharAbilityMapping(ID(), 1, "Papermaking", 75, true); CMLib.ableMapper().addCharAbilityMapping(ID(), 1, "Spell_ReadMagic", 100, true); CMLib.ableMapper().addCharAbilityMapping(ID(), 1, "Spell_MagicMissile", false); CMLib.ableMapper().addCharAbilityMapping(ID(), 1, "Spell_ResistMagicMissiles", false); CMLib.ableMapper().addCharAbilityMapping(ID(), 1, "Spell_Shield", false); CMLib.ableMapper().addCharAbilityMapping(ID(), 1, "Spell_IronGrip", false); for (Enumeration a = CMClass.abilities(); a.hasMoreElements(); ) { Ability A = (Ability) a.nextElement(); if ((A != null) && ((A.classificationCode() & Ability.ALL_ACODES) == Ability.ACODE_SPELL)) { int level = CMLib.ableMapper().getQualifyingLevel(ID(), true, A.ID()); if (level > 0) { AbilityMapper.AbilityMapping able = CMLib.ableMapper().getAbleMap(ID(), A.ID()); if ((able != null) && (!CMLib.ableMapper().getDefaultGain(ID(), true, A.ID()))) { able.costOverrides = new Integer[] { Integer.valueOf(0), Integer.valueOf(0), Integer.valueOf(0), Integer.valueOf(0) }; able.defaultProficiency = 100; } } } } }
@Override public boolean tick(Tickable ticking, int tickID) { if (!super.tick(ticking, tickID)) return false; if (affected == null) return false; if (!(affected instanceof MOB)) return true; final MOB mob = (MOB) affected; if ((!mob.amDead()) && ((--diseaseTick) <= 0)) { diseaseTick = DISEASE_DELAY(); if (mob.maxState().getFatigue() > Long.MIN_VALUE / 2) mob.curState() .adjFatigue(mob.curState().getFatigue() + CharState.FATIGUED_MILLIS, mob.maxState()); mob.location().show(mob, null, CMMsg.MSG_NOISE, DISEASE_AFFECT()); if (!CMLib.flags().isSleeping(mob)) { final Command C = CMClass.getCommand("Sleep"); try { if (C != null) C.execute(mob, CMParms.parse("Sleep"), Command.METAFLAG_FORCED); } catch (final Exception e) { } } return true; } return true; }