@Override public boolean invoke( MOB mob, List<String> commands, Physical givenTarget, boolean auto, int asLevel) { if (commands.size() < 1) { mob.tell( L( "You must specify an item to fence, and possibly a ShopKeeper (unless it is implied).")); return false; } commands.add(0, "SELL"); // will be instantly deleted by parseshopkeeper final Environmental shopkeeper = CMLib.english().parseShopkeeper(mob, commands, L("Fence what to whom?")); if (shopkeeper == null) return false; if (commands.size() == 0) { mob.tell(L("Fence what?")); 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, shopkeeper, this, CMMsg.MSG_SPEAK, auto ? "" : L("<S-NAME> fence(s) stolen loot to <T-NAMESELF>.")); if (mob.location().okMessage(mob, msg)) { mob.location().send(mob, msg); invoker = mob; addBackMap.clear(); mob.addEffect(this); mob.recoverCharStats(); commands.add(0, CMStrings.capitalizeAndLower("SELL")); mob.doCommand(commands, MUDCmdProcessor.METAFLAG_FORCED); commands.add(shopkeeper.name()); mob.delEffect(this); for (Item I : addBackMap.keySet()) { if (mob.isMine(I)) { I.addEffect(addBackMap.get(I)); } } addBackMap.clear(); mob.recoverCharStats(); } } else beneficialWordsFizzle( mob, shopkeeper, L( "<S-NAME> attempt(s) to fence stolen loot to <T-NAMESELF>, but make(s) <T-HIM-HER> too nervous.")); // 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; }
@Override public boolean invoke(MOB mob, Vector commands, Physical givenTarget, boolean auto, int asLevel) { String cmd = ""; if (commands.size() > 0) cmd = ((String) commands.firstElement()).toUpperCase(); if ((commands.size() < 2) || ((!cmd.equals("BUY") && (!cmd.equals("SELL"))))) { mob.tell( L( "You must specify BUY, SELL, an item, and possibly a ShopKeeper (unless it is implied).")); return false; } final Environmental shopkeeper = CMLib.english() .parseShopkeeper(mob, commands, CMStrings.capitalizeAndLower(cmd) + " what to whom?"); if (shopkeeper == null) return false; if (commands.size() == 0) { mob.tell(L("@x1 what?", CMStrings.capitalizeAndLower(cmd))); 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, shopkeeper, this, CMMsg.MSG_SPEAK, auto ? "" : L("<S-NAME> haggle(s) with <T-NAMESELF>.")); if (mob.location().okMessage(mob, msg)) { mob.location().send(mob, msg); invoker = mob; mob.addEffect(this); mob.recoverCharStats(); commands.insertElementAt(CMStrings.capitalizeAndLower(cmd), 0); mob.doCommand(commands, Command.METAFLAG_FORCED); commands.addElement(shopkeeper.name()); mob.delEffect(this); mob.recoverCharStats(); } } else beneficialWordsFizzle( mob, shopkeeper, L("<S-NAME> haggle(s) with <T-NAMESELF>, but <S-IS-ARE> unconvincing.")); // 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); final List<Ability> offensiveAffects = returnOffensiveAffects(target); if ((success) && (offensiveAffects.size() > 0)) { final CMMsg msg = CMClass.getMsg( mob, target, this, verbalCastCode(mob, target, auto), auto ? L("<T-NAME> feel(s) the poison slowing down.") : L("^S<S-NAME> chant(s) for the poisons in <T-NAME> to be slowed down.^?")); if (mob.location().okMessage(mob, msg)) { mob.location().send(mob, msg); Chant_DelayPoison pA = (Chant_DelayPoison) beneficialAffect(mob, target, asLevel, 0); if (pA != null) { pA.poisonAffects = offensiveAffects; for (Ability A : offensiveAffects) { target.delEffect(A); A.setAffectedOne(target); } } target.recoverPhyStats(); } } else beneficialWordsFizzle( mob, target, auto ? "" : L("<S-NAME> chant(s) for <T-NAME>, but nothing happens.")); // return whether it worked return success; }
@Override public boolean invoke( MOB mob, List<String> commands, Physical givenTarget, boolean auto, int asLevel) { timeOut = 0; if (auto) return false; final Hashtable<String, String> H = getSongs(); if (commands.size() == 0) { final Song_Ode A = (Song_Ode) mob.fetchEffect(ID()); if ((A != null) && (A.whom != null) && (A.song == null)) { final String str = L("^S<S-NAME> finish(es) composing the @x1.^?", A.songOf()); final CMMsg msg = CMClass.getMsg( mob, null, this, (auto ? CMMsg.MASK_ALWAYS : 0) | CMMsg.MSG_DELICATE_SMALL_HANDS_ACT, str); if (mob.location().okMessage(mob, msg)) { mob.location().send(mob, msg); mob.delEffect(A); getSongs().put(A.whom.name(), A.composition()); whom = null; return true; } return false; } final StringBuffer str = new StringBuffer(""); for (final Enumeration<String> e = H.keys(); e.hasMoreElements(); ) str.append(e.nextElement() + " "); mob.tell(L("Compose or sing an ode about whom?")); if (str.length() > 0) mob.tell(L("You presently have odes written about: @x1.", str.toString().trim())); return false; } String name = CMParms.combine(commands, 0); for (final Enumeration<String> e = H.keys(); e.hasMoreElements(); ) { final String key = e.nextElement(); if (CMLib.english().containsString(key, name)) { invoker = mob; originRoom = mob.location(); commonRoomSet = getInvokerScopeRoomSet(null); name = key; song = H.get(name); benefits = null; whom = mob.location().fetchInhabitant(name); if ((whom == null) || (!whom.name().equals(name))) whom = CMLib.players().getPlayer(name); if ((whom == null) || (!whom.name().equals(name))) { whom = CMClass.getMOB("StdMOB"); whom.setName(name); whom.setLocation(mob.location()); } return super.invoke(mob, commands, givenTarget, auto, asLevel); } } final MOB target = getTarget(mob, commands, givenTarget); if (target == null) return false; if (target == mob) { mob.tell(L("You may not compose an ode about yourself!")); return false; } final boolean success = proficiencyCheck(mob, 0, auto); if (success) { unsingAll(mob, mob); invoker = mob; originRoom = mob.location(); commonRoomSet = getInvokerScopeRoomSet(null); whom = target; final String str = L("^S<S-NAME> begin(s) to compose an @x1.^?", songOf()); final CMMsg msg = CMClass.getMsg( mob, null, this, (auto ? CMMsg.MASK_ALWAYS : 0) | CMMsg.MSG_DELICATE_SMALL_HANDS_ACT, str); if (mob.location().okMessage(mob, msg)) { mob.location().send(mob, msg); invoker = mob; final Song_Ode newOne = (Song_Ode) copyOf(); newOne.whom = target; newOne.trail = new StringBuffer(""); newOne.song = null; mob.addEffect(newOne); } } else mob.location() .show(mob, null, CMMsg.MSG_NOISE, L("<S-NAME> lose(s) <S-HIS-HER> inspiration.")); return success; }
@Override public boolean invoke(MOB mob, Vector commands, Physical givenTarget, boolean auto, int asLevel) { if (CMParms.combine(commands, 0).equalsIgnoreCase("auto")) { DATA.clear(); IPS.clear(); final Hashtable<String, List<MOB>> ipes = new Hashtable<String, List<MOB>>(); for (final Session S : CMLib.sessions().localOnlineIterable()) { if ((S.getAddress().length() > 0) && (S.mob() != null)) { List V = ipes.get(S.getAddress()); if (V == null) { V = new Vector(); ipes.put(S.getAddress(), V); } if (!V.contains(S.mob())) V.add(S.mob()); } } final StringBuffer rpt = new StringBuffer(""); for (final Enumeration e = ipes.keys(); e.hasMoreElements(); ) { final String addr = (String) e.nextElement(); final List<MOB> names = ipes.get(addr); if (names.size() > 1) { IPS.put(addr, names); rpt.append("Watch #" + (IPS.size()) + " added: "); for (int n = 0; n < names.size(); n++) { final MOB MN = names.get(n); if (MN.fetchEffect(ID()) == null) { final Ability A = (Ability) copyOf(); MN.addNonUninvokableEffect(A); A.setSavable(false); } rpt.append(MN.Name() + " "); } rpt.append("\n\r"); } } if (rpt.length() == 0) rpt.append("No users with duplicate IDs found. Try MULTIWATCH ADD name1 name2 ... "); mob.tell(rpt.toString()); return true; } else if (CMParms.combine(commands, 0).equalsIgnoreCase("stop")) { boolean foundLegacy = false; for (final Session S : CMLib.sessions().localOnlineIterable()) { if ((S != null) && (S.mob() != null) && (S.mob().fetchEffect(ID()) != null)) { foundLegacy = true; break; } } if ((DATA.size() == 0) && (IPS.size() == 0) && (!foundLegacy)) { mob.tell(L("Multiwatch is already off.")); return false; } for (final Enumeration<List<MOB>> e = IPS.elements(); e.hasMoreElements(); ) { final List<MOB> V = e.nextElement(); for (int v = 0; v < V.size(); v++) { final MOB M = V.get(v); final Ability A = M.fetchEffect(ID()); if (A != null) M.delEffect(A); } } for (final Session S : CMLib.sessions().localOnlineIterable()) { if ((S != null) && (S.mob() != null)) { final MOB M = S.mob(); final Ability A = M.fetchEffect(ID()); if (A != null) M.delEffect(A); } } mob.tell(L("Multiplay watcher is now turned off.")); DATA.clear(); IPS.clear(); return true; } else if ((commands.size() > 1) && ((String) commands.firstElement()).equalsIgnoreCase("add")) { final Vector V = new Vector(); for (int i = 1; i < commands.size(); i++) { final String name = (String) commands.elementAt(i); final MOB M = CMLib.players().getPlayer(name); if ((M.session() != null) && (CMLib.flags().isInTheGame(M, true))) V.addElement(M); else mob.tell(L("'@x1' is not online.", name)); } if (V.size() > 1) { for (int n = 0; n < V.size(); n++) { final MOB MN = (MOB) V.elementAt(n); if (MN.fetchEffect(ID()) == null) { final Ability A = (Ability) copyOf(); MN.addNonUninvokableEffect(A); A.setSavable(false); } } IPS.put("MANUAL" + (IPS.size() + 1), V); mob.tell(L("Manual Watch #@x1 added.", "" + IPS.size())); } return true; } else if ((commands.size() == 0) && (DATA.size() > 0) && (IPS.size() > 0)) { final StringBuffer report = new StringBuffer(""); for (final Enumeration<String> e = IPS.keys(); e.hasMoreElements(); ) { final String key = e.nextElement(); int sync = 0; final List<MOB> V = IPS.get(key); for (int v = 0; v < V.size(); v++) { final MOB M = V.get(v); final int data[] = DATA.get(M); if (data != null) sync += data[DATA_SYNCHROFOUND]; } report.append("^x" + key + "^?^., Syncs: " + sync + "\n\r"); report.append( CMStrings.padRight(L("Name"), 25) + CMStrings.padRight(L("Speech"), 15) + CMStrings.padRight(L("Socials"), 15) + CMStrings.padRight(L("CMD"), 10) + CMStrings.padRight(L("ORDERS"), 10) + "\n\r"); for (int v = 0; v < V.size(); v++) { final MOB M = V.get(v); int data[] = DATA.get(M); if (data == null) data = new int[DATA_TOTAL]; report.append(CMStrings.padRight(M.Name(), 25)); report.append( CMStrings.padRight( data[DATA_GOODSPEECH] + "/" + data[DATA_DIRSPEECH] + "/" + data[DATA_ANYSPEECH], 15)); report.append( CMStrings.padRight( data[DATA_GOODSOCIAL] + "/" + data[DATA_DIRSOCIAL] + "/" + data[DATA_ANYSOCIAL], 15)); report.append(CMStrings.padRight(data[DATA_TYPEDCOMMAND] + "", 10)); report.append(CMStrings.padRight(data[DATA_ORDER] + "", 10)); report.append("\n\r"); } report.append("\n\r"); } mob.tell(report.toString()); return true; } else { mob.tell(L("Try MULTIWATCH AUTO, MULTIWATCH STOP, or MULTIWATCH ADD name1 name2..")); return false; } }
protected boolean stopFalling(MOB mob) { final Room R = mob.location(); if (reversed()) { if (!hitTheCeiling) { hitTheCeiling = true; if (R != null) R.show( mob, null, CMMsg.MSG_OK_ACTION, L("<S-NAME> hit(s) the ceiling.@x1", CMLib.protocol().msp("splat.wav", 50))); CMLib.combat() .postDamage( mob, mob, this, damageToTake, CMMsg.MASK_ALWAYS | CMMsg.TYP_JUSTICE, -1, null); } return true; } hitTheCeiling = false; unInvoke(); if (R != null) { if (isAirRoom(R)) R.show( mob, null, CMMsg.MSG_OK_ACTION, L("<S-NAME> stop(s) falling.@x1", CMLib.protocol().msp("splat.wav", 50))); else if (CMLib.flags().isWaterySurfaceRoom(R) || CMLib.flags().isUnderWateryRoom(R)) R.show( mob, null, CMMsg.MSG_OK_ACTION, L("<S-NAME> hit(s) the water.@x1", CMLib.protocol().msp("splat.wav", 50))); else { R.show( mob, null, CMMsg.MSG_OK_ACTION, L("<S-NAME> hit(s) the ground.@x1", CMLib.protocol().msp("splat.wav", 50))); if (CMath.div(damageToTake, mob.maxState().getHitPoints()) > 0.05) { LimbDamage damage = (LimbDamage) mob.fetchEffect("BrokenLimbs"); if (damage == null) { damage = (LimbDamage) CMClass.getAbility("BrokenLimbs"); damage.setAffectedOne(mob); } List<String> limbs = damage.unaffectedLimbSet(); if (limbs.size() > 0) { if (mob.fetchEffect(damage.ID()) == null) { mob.addEffect(damage); damage.makeLongLasting(); } damage.damageLimb(limbs.get(CMLib.dice().roll(1, limbs.size(), -1))); } } } CMLib.combat() .postDamage( mob, mob, this, damageToTake, CMMsg.MASK_ALWAYS | CMMsg.TYP_JUSTICE, -1, null); } mob.delEffect(this); return false; }