@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 execute(MOB mob, List<String> commands, int metaFlags) throws java.io.IOException { if (!mob.isMonster()) { if ((commands != null) && (commands.size() > 1) && (commands.get(1).toUpperCase().equals("OFF"))) { final Command C = CMClass.getCommand("NoSounds"); if (C != null) { return C.execute(mob, commands, metaFlags); } } boolean force = false; if (commands != null) { for (final Object o : commands) { if (o.toString().equalsIgnoreCase("force")) force = true; } } final Session session = mob.session(); if ((!mob.isAttributeSet(MOB.Attrib.SOUND)) || (!session.getClientTelnetMode(Session.TELNET_MSP))) { session.changeTelnetMode(Session.TELNET_MSP, true); for (int i = 0; ((i < 5) && (!session.getClientTelnetMode(Session.TELNET_MSP))); i++) { try { mob.session().prompt("", 500); } catch (final Exception e) { } } if (session.getClientTelnetMode(Session.TELNET_MSP)) { mob.setAttribute(MOB.Attrib.SOUND, true); mob.tell(L("MSP Sound/Music enabled.\n\r")); } else if (force) { session.setClientTelnetMode(Session.TELNET_MSP, true); session.setServerTelnetMode(Session.TELNET_MSP, true); mob.setAttribute(MOB.Attrib.SOUND, true); mob.tell(L("MSP Sound/Music has been forceably enabled.\n\r")); } else mob.tell(L("Your client does not appear to support MSP.")); } else { mob.tell(L("MSP Sound/Music is already enabled.\n\r")); } } return false; }
@Override public boolean execute(final MOB mob, List<String> commands, int metaFlags) throws java.io.IOException { final PlayerStats pstats = mob.playerStats(); if (pstats == null) return false; if (mob.isMonster()) return false; final Session sess = mob.session(); if (sess != null) { sess.prompt( new InputCallback(InputCallback.Type.PROMPT) { @Override public void showPrompt() { sess.promptPrint(L("Enter your old password : "******"Enter a new password : "******"Enter new password again: ")); } @Override public void timedOut() {} @Override public void callBack() { final String ne2 = this.input; if (!pstats.matchesPassword(old)) mob.tell(L("Your old password was not entered correctly.")); else if (!nep.equals(ne2)) mob.tell( L("Your new password was not entered the same way twice!")); else { pstats.setPassword(nep); mob.tell(L("Your password has been changed.")); if (pstats.getAccount() != null) CMLib.database().DBUpdateAccount(pstats.getAccount()); CMLib.database() .DBUpdatePassword(mob.Name(), pstats.getPasswordStr()); } } }); } }); } }); } return false; }
@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; } }
@Override public boolean invoke( final MOB mob, Vector commands, Physical givenTarget, final boolean auto, final int asLevel) { final Vector originalCommands = (Vector) commands.clone(); if (super.checkStop(mob, commands)) return true; fireRequired = true; final CraftParms parsedVars = super.parseAutoGenerate(auto, givenTarget, commands); givenTarget = parsedVars.givenTarget; final PairVector<Integer, Integer> enhancedTypes = enhancedTypes(mob, commands); randomRecipeFix(mob, addRecipes(mob, loadRecipes()), commands, parsedVars.autoGenerate); if (commands.size() == 0) { commonTell( mob, L( "Make what? Enter \"@x1 list\" for a list, \"@x2 learn <item>\" to gain recipes, or \"@x3 stop\" to cancel.", triggerStrings()[0].toLowerCase(), triggerStrings()[0].toLowerCase(), triggerStrings()[0].toLowerCase())); return false; } if ((!auto) && (commands.size() > 0) && (((String) commands.firstElement()).equalsIgnoreCase("bundle"))) { bundling = true; if (super.invoke(mob, commands, givenTarget, auto, asLevel)) return super.bundle(mob, commands); return false; } final List<List<String>> recipes = addRecipes(mob, loadRecipes()); final String str = (String) commands.elementAt(0); String startStr = null; bundling = false; int duration = 4; final int[] cols = { ListingLibrary.ColFixer.fixColWidth(16, mob.session()), ListingLibrary.ColFixer.fixColWidth(3, mob.session()) }; if (str.equalsIgnoreCase("list")) { String mask = CMParms.combine(commands, 1); boolean allFlag = false; if (mask.equalsIgnoreCase("all")) { allFlag = true; mask = ""; } final StringBuffer buf = new StringBuffer( L( "@x1 @x2 Metals required\n\r", CMStrings.padRight(L("Item"), cols[0]), CMStrings.padRight(L("Lvl"), cols[1]))); for (int r = 0; r < recipes.size(); r++) { final List<String> V = recipes.get(r); if (V.size() > 0) { final String item = replacePercent(V.get(RCP_FINALNAME), ""); final int level = CMath.s_int(V.get(RCP_LEVEL)); final String wood = getComponentDescription(mob, V, RCP_WOOD); if (((level <= xlevel(mob)) || allFlag) && ((mask.length() == 0) || mask.equalsIgnoreCase("all") || CMLib.english().containsString(item, mask))) buf.append( CMStrings.padRight(item, cols[0]) + " " + CMStrings.padRight("" + level, cols[1]) + " " + wood + "\n\r"); } } commonTell(mob, buf.toString()); enhanceList(mob); return true; } else if ((commands.firstElement() instanceof String) && (((String) commands.firstElement())).equalsIgnoreCase("learn")) { return doLearnRecipe(mob, commands, givenTarget, auto, asLevel); } activity = CraftingActivity.CRAFTING; buildingI = null; messedUp = false; String statue = null; if ((commands.size() > 1) && ((String) commands.lastElement()).startsWith("STATUE=")) { statue = (((String) commands.lastElement()).substring(7)).trim(); if (statue.length() == 0) statue = null; else commands.removeElementAt(commands.size() - 1); } int amount = -1; if ((commands.size() > 1) && (CMath.isNumber((String) commands.lastElement()))) { amount = CMath.s_int((String) commands.lastElement()); commands.removeElementAt(commands.size() - 1); } final String recipeName = CMParms.combine(commands, 0); List<String> foundRecipe = null; final List<List<String>> matches = matchingRecipeNames(recipes, recipeName, true); for (int r = 0; r < matches.size(); r++) { final List<String> V = matches.get(r); if (V.size() > 0) { final int level = CMath.s_int(V.get(RCP_LEVEL)); if ((parsedVars.autoGenerate > 0) || (level <= xlevel(mob))) { foundRecipe = V; break; } } } if (foundRecipe == null) { commonTell( mob, L( "You don't know how to make a '@x1'. Try \"@x2 list\" for a list.", recipeName, triggerStrings[0].toLowerCase())); return false; } final String woodRequiredStr = foundRecipe.get(RCP_WOOD); final List<Object> componentsFoundList = getAbilityComponents( mob, woodRequiredStr, "make " + CMLib.english().startWithAorAn(recipeName), parsedVars.autoGenerate); if (componentsFoundList == null) return false; int woodRequired = CMath.s_int(woodRequiredStr); woodRequired = adjustWoodRequired(woodRequired, mob); if (amount > woodRequired) woodRequired = amount; final String misctype = foundRecipe.get(RCP_MISCTYPE); final int[] pm = {RawMaterial.MATERIAL_METAL, RawMaterial.MATERIAL_MITHRIL}; bundling = misctype.equalsIgnoreCase("BUNDLE"); final int[][] data = fetchFoundResourceData( mob, woodRequired, "metal", pm, 0, null, null, bundling, parsedVars.autoGenerate, enhancedTypes); if (data == null) return false; fixDataForComponents(data, componentsFoundList); woodRequired = data[0][FOUND_AMT]; if (!bundling) { fireRequired = true; final Item fire = getRequiredFire(mob, parsedVars.autoGenerate); if (fire == null) return false; } else fireRequired = false; final Session session = mob.session(); if ((misctype.equalsIgnoreCase("statue")) && (session != null) && ((statue == null) || (statue.trim().length() == 0))) { final Ability me = this; final Physical target = givenTarget; session.prompt( new InputCallback(InputCallback.Type.PROMPT, "", 0) { @Override public void showPrompt() { session.promptPrint(L("What is a statue this of?\n\r: ")); } @Override public void timedOut() {} @Override public void callBack() { final String of = this.input; if ((of.trim().length() == 0) || (of.indexOf('<') >= 0)) return; final Vector newCommands = (Vector) originalCommands.clone(); newCommands.add("STATUE=" + of); me.invoke(mob, newCommands, target, auto, asLevel); } }); return false; } if (!super.invoke(mob, commands, givenTarget, auto, asLevel)) return false; final int lostValue = parsedVars.autoGenerate > 0 ? 0 : CMLib.materials() .destroyResourcesValue( mob.location(), data[0][FOUND_AMT], data[0][FOUND_CODE], 0, null) + CMLib.ableMapper().destroyAbilityComponents(componentsFoundList); buildingI = CMClass.getItem(foundRecipe.get(RCP_CLASSTYPE)); if (buildingI == null) { commonTell(mob, L("There's no such thing as a @x1!!!", foundRecipe.get(RCP_CLASSTYPE))); return false; } duration = getDuration( CMath.s_int(foundRecipe.get(RCP_TICKS)), mob, CMath.s_int(foundRecipe.get(RCP_LEVEL)), 4); String itemName = replacePercent(foundRecipe.get(RCP_FINALNAME), RawMaterial.CODES.NAME(data[0][FOUND_CODE])) .toLowerCase(); if (bundling) itemName = "a " + woodRequired + "# " + itemName; else itemName = CMLib.english().startWithAorAn(itemName); buildingI.setName(itemName); startStr = L("<S-NAME> start(s) smithing @x1.", buildingI.name()); displayText = L("You are smithing @x1", buildingI.name()); verb = L("smithing @x1", buildingI.name()); playSound = "tinktinktink2.wav"; buildingI.setDisplayText(L("@x1 lies here", itemName)); buildingI.setDescription(itemName + ". "); buildingI.basePhyStats().setWeight(getStandardWeight(woodRequired, bundling)); buildingI.setBaseValue( CMath.s_int(foundRecipe.get(RCP_VALUE)) + (woodRequired * (RawMaterial.CODES.VALUE(data[0][FOUND_CODE])))); buildingI.setMaterial(data[0][FOUND_CODE]); buildingI.basePhyStats().setLevel(CMath.s_int(foundRecipe.get(RCP_LEVEL))); buildingI.setSecretIdentity(getBrand(mob)); final int capacity = CMath.s_int(foundRecipe.get(RCP_CAPACITY)); final String spell = (foundRecipe.size() > RCP_SPELL) ? foundRecipe.get(RCP_SPELL).trim() : ""; addSpells(buildingI, spell); if ((misctype.equalsIgnoreCase("statue")) && (statue != null) && (statue.trim().length() > 0)) { buildingI.setName(L("@x1 of @x2", itemName, statue.trim())); buildingI.setDisplayText(L("@x1 of @x2 is here", itemName, statue.trim())); buildingI.setDescription(L("@x1 of @x2. ", itemName, statue.trim())); } else if (buildingI instanceof Rideable) { setRideBasis((Rideable) buildingI, misctype); if (capacity == 0) ((Rideable) buildingI).setRiderCapacity(1); else if (capacity < 5) ((Rideable) buildingI).setRiderCapacity(capacity); } else if (buildingI instanceof Container) { ((Container) buildingI).setCapacity(capacity + woodRequired); if (misctype.equalsIgnoreCase("LID")) ((Container) buildingI).setDoorsNLocks(true, false, true, false, false, false); else if (misctype.equalsIgnoreCase("LOCK")) { ((Container) buildingI).setDoorsNLocks(true, false, true, true, false, true); ((Container) buildingI).setKeyName(Double.toString(Math.random())); } else ((Container) buildingI).setContainTypes(getContainerType(misctype)); } if (buildingI instanceof Drink) { if (CMLib.flags().isGettable(buildingI)) { ((Drink) buildingI).setLiquidHeld(capacity * 50); ((Drink) buildingI).setThirstQuenched(250); if ((capacity * 50) < 250) ((Drink) buildingI).setThirstQuenched(capacity * 50); ((Drink) buildingI).setLiquidRemaining(0); } } if (bundling) buildingI.setBaseValue(lostValue); buildingI.recoverPhyStats(); buildingI.text(); buildingI.recoverPhyStats(); messedUp = !proficiencyCheck(mob, 0, auto); if (bundling) { messedUp = false; duration = 1; verb = L("bundling @x1", RawMaterial.CODES.NAME(buildingI.material()).toLowerCase()); startStr = L("<S-NAME> start(s) @x1.", verb); displayText = L("You are @x1", verb); } if (parsedVars.autoGenerate > 0) { commands.addElement(buildingI); return true; } final CMMsg msg = CMClass.getMsg(mob, buildingI, this, getActivityMessageType(), startStr); if (mob.location().okMessage(mob, msg)) { mob.location().send(mob, msg); buildingI = (Item) msg.target(); beneficialAffect(mob, mob, asLevel, duration); enhanceItem(mob, buildingI, enhancedTypes); } else if (bundling) { messedUp = false; aborted = false; unInvoke(); } return true; }