@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 void executeMsg(final Environmental myHost, final CMMsg msg) { super.executeMsg(myHost, msg); if ((reRollFlag) && (affected instanceof MOB) && (msg.sourceMinor() == CMMsg.TYP_LOOK) && (msg.source() == affected)) { final MOB M = msg.source(); if ((M.session() != null) && (M.playerStats() != null)) { final Ability me = this; CMLib.threads() .executeRunnable( new Runnable() { @Override public void run() { try { CMLib.login() .promptBaseCharStats( M.playerStats().getTheme(), M, 300, M.session(), bonusPointsPerStat); M.recoverCharStats(); if (rePickClass) M.baseCharStats() .setCurrentClass( CMLib.login() .promptCharClass(M.playerStats().getTheme(), M, M.session())); M.recoverCharStats(); M.delEffect(me); M.baseCharStats().getCurrentClass().grantAbilities(M, false); } catch (final IOException e) { } } }); } } }
@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); } } }
@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_SONG) && (!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); } } }
@Override public boolean invoke( MOB mob, List<String> commands, Physical givenTarget, boolean auto, int asLevel) { final Physical target = getAnyTarget(mob, commands, givenTarget, Wearable.FILTER_ANY, true); if (target == null) return false; if (!super.invoke(mob, commands, givenTarget, auto, asLevel)) return false; int type = verbalCastCode(mob, target, auto); if ((target instanceof MOB) && (CMath.bset(type, CMMsg.MASK_MALICIOUS)) && (((MOB) target).charStats().getStat(CharStats.STAT_AGE) > 0)) { final MOB mobt = (MOB) target; if (mobt.charStats().ageCategory() <= Race.AGE_CHILD) type = CMath.unsetb(type, CMMsg.MASK_MALICIOUS); else if ((mobt.getLiegeID().equals(mob.Name())) || (mobt.amFollowing() == mob)) type = CMath.unsetb(type, CMMsg.MASK_MALICIOUS); else if ((mobt.charStats().ageCategory() <= Race.AGE_MATURE) && (mobt.getLiegeID().length() > 0)) type = CMath.unsetb(type, CMMsg.MASK_MALICIOUS); } if ((target instanceof Item) || ((target instanceof MOB) && (((MOB) target).isMonster()) && (CMLib.flags().isAnimalIntelligence((MOB) target)) && (CMLib.law().doesHavePriviledgesHere(mob, mob.location())))) { type = CMath.unsetb(type, CMMsg.MASK_MALICIOUS); } boolean success = proficiencyCheck(mob, 0, auto); if (success) { final CMMsg msg = CMClass.getMsg( mob, target, this, type, auto ? "" : L("^S<S-NAME> chant(s) to <T-NAMESELF>.^?")); if (mob.location().okMessage(mob, msg)) { mob.location().send(mob, msg); final Ability A = target.fetchEffect("Age"); if ((!(target instanceof MOB)) && (!(target instanceof CagedAnimal)) && (A == null)) { if (target instanceof Food) { mob.tell(L("@x1 rots away!", target.name(mob))); ((Item) target).destroy(); } else if (target instanceof Item) { switch (((Item) target).material() & RawMaterial.MATERIAL_MASK) { case RawMaterial.MATERIAL_CLOTH: case RawMaterial.MATERIAL_FLESH: case RawMaterial.MATERIAL_LEATHER: case RawMaterial.MATERIAL_PAPER: case RawMaterial.MATERIAL_VEGETATION: case RawMaterial.MATERIAL_WOODEN: { mob.location() .showHappens(CMMsg.MSG_OK_VISUAL, L("@x1 rots away!", target.name())); if (target instanceof Container) ((Container) target).emptyPlease(false); ((Item) target).destroy(); break; } default: mob.location() .showHappens( CMMsg.MSG_OK_VISUAL, L("@x1 ages, but nothing happens to it.", target.name())); break; } } else mob.location() .showHappens( CMMsg.MSG_OK_VISUAL, L("@x1 ages, but nothing happens to it.", target.name())); success = false; } else if ((target instanceof MOB) && ((A == null) || (A.displayText().length() == 0))) { final MOB M = (MOB) target; mob.location().show(M, null, CMMsg.MSG_OK_VISUAL, L("<S-NAME> age(s) a bit.")); if (M.baseCharStats().getStat(CharStats.STAT_AGE) <= 0) M.setAgeMinutes(M.getAgeMinutes() + (M.getAgeMinutes() / 10)); else if ((M.playerStats() != null) && (M.playerStats().getBirthday() != null)) { final TimeClock C = CMLib.time().localClock(M.getStartRoom()); final double aging = CMath.mul(M.baseCharStats().getStat(CharStats.STAT_AGE), .10); int years = (int) Math.round(Math.floor(aging)); final int monthsInYear = C.getMonthsInYear(); int months = (int) Math.round(CMath.mul(aging - Math.floor(aging), monthsInYear)); if ((years <= 0) && (months == 0)) months++; M.playerStats().getBirthday()[PlayerStats.BIRTHDEX_YEAR] -= years; M.playerStats().getBirthday()[PlayerStats.BIRTHDEX_MONTH] -= months; if (M.playerStats().getBirthday()[PlayerStats.BIRTHDEX_MONTH] < 1) { M.playerStats().getBirthday()[PlayerStats.BIRTHDEX_YEAR]--; years++; M.playerStats().getBirthday()[PlayerStats.BIRTHDEX_MONTH] = monthsInYear + M.playerStats().getBirthday()[PlayerStats.BIRTHDEX_MONTH]; } M.baseCharStats() .setStat(CharStats.STAT_AGE, M.baseCharStats().getStat(CharStats.STAT_AGE) + years); } M.recoverPhyStats(); M.recoverCharStats(); } else if (A != null) { final long start = CMath.s_long(A.text()); long age = System.currentTimeMillis() - start; final long millisPerMudday = CMProps.getIntVar(CMProps.Int.TICKSPERMUDDAY) * CMProps.getTickMillis(); if (age < millisPerMudday) age = millisPerMudday; final long millisPerMonth = CMLib.time().globalClock().getDaysInMonth() * millisPerMudday; final long millisPerYear = CMLib.time().globalClock().getMonthsInYear() * millisPerMonth; long ageBy = age / 10; if (ageBy < millisPerMonth) ageBy = millisPerMonth + 1; else if (ageBy < millisPerYear) ageBy = millisPerYear + 1; A.setMiscText("" + (start - ageBy)); if (target instanceof MOB) mob.location() .show((MOB) target, null, CMMsg.MSG_OK_VISUAL, L("<S-NAME> age(s) a bit.")); else mob.location().showHappens(CMMsg.MSG_OK_VISUAL, L("@x1 ages a bit.", target.name())); target.recoverPhyStats(); } else return beneficialWordsFizzle( mob, target, L("<S-NAME> chant(s) to <T-NAMESELF>, but the magic fades.")); } } else if (CMath.bset(type, CMMsg.MASK_MALICIOUS)) return maliciousFizzle( mob, target, L("<S-NAME> chant(s) to <T-NAMESELF>, but the magic fades.")); else return beneficialWordsFizzle( mob, target, L("<S-NAME> chant(s) to <T-NAMESELF>, but the magic fades.")); // return whether it worked return success; }
@Override public void grantAbilities(MOB mob, boolean isBorrowedClass) { super.grantAbilities(mob, isBorrowedClass); // if he already has one, don't give another! if (mob.playerStats() != null) { final int classLevel = mob.baseCharStats().getClassLevel(this); if (classLevel < 2) return; if ((classLevel % 2) != 0) return; int maxSkills = classLevel / 2; // now only give one, for current level, respecting alignment! // first, get a list of all skills you don't qualify for that you MIGHT have gained or will // gain final List<Ability> choices = new Vector<Ability>(); for (final Enumeration<Ability> a = CMClass.abilities(); a.hasMoreElements(); ) { final Ability A = a.nextElement(); final int lql = CMLib.ableMapper().lowestQualifyingLevel(A.ID()); if ((CMLib.ableMapper().qualifyingLevel(mob, A) <= 0) && (lql < 25) && (lql > 0) && (!CMLib.ableMapper().getSecretSkill(A.ID())) && (CMLib.ableMapper().qualifiesByAnyCharClass(A.ID())) && (CMLib.ableMapper().availableToTheme(A.ID(), Area.THEME_FANTASY, true)) && (!CMLib.ableMapper().qualifiesOnlyByClan(mob, A)) && (!CMLib.ableMapper().qualifiesOnlyByRace(mob, A)) && (A.isAutoInvoked() || ((A.triggerStrings() != null) && (A.triggerStrings().length > 0)))) choices.add(A); } // now count those you already have for (int a = choices.size() - 1; a >= 0; a--) { final Ability A = choices.get(a); if (mob.fetchAbility(A.ID()) != null) maxSkills--; } if (maxSkills < 1) // if that reduced you to 0, you are done. return; // now eliminate those you already have, and those that are // above your level, if you are <25 for (int a = choices.size() - 1; a >= 0; a--) { final Ability A = choices.get(a); final int lql = CMLib.ableMapper().lowestQualifyingLevel(A.ID()); if ((mob.fetchAbility(ID()) != null) || ((lql != classLevel) && (lql != classLevel - 1) && (classLevel < 25))) choices.remove(a); } if (choices.size() == 0) return; final Ability A = choices.get(CMLib.dice().roll(1, choices.size(), -1)); if (A != null) giveMobAbility(mob, A, 0, "", isBorrowedClass); } else { 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) && (!CMLib.ableMapper().getAllQualified(ID(), true, A.ID())) && (!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); } } }
@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 String runMacro(HTTPRequest httpReq, String parm) { final java.util.Map<String, String> parms = parseParms(parm); final String last = httpReq.getUrlParameter("JOURNAL"); if (last == null) return " @break@"; boolean securityOverride = false; if ((Thread.currentThread() instanceof CWThread) && CMath.s_bool(((CWThread) Thread.currentThread()).getConfig().getMiscProp("ADMIN")) && parms.containsKey("ALLFORUMJOURNALS")) securityOverride = true; final MOB M = Authenticate.getAuthenticatedMob(httpReq); if ((!securityOverride) && (CMLib.journals().isArchonJournalName(last)) && ((M == null) || (!CMSecurity.isASysOp(M)))) return " @break@"; final Clan setClan = CMLib.clans().getClan(httpReq.getUrlParameter("CLAN")); final JournalsLibrary.ForumJournal journal = CMLib.journals().getForumJournal(last, setClan); if (journal == null) return " @break@"; final StringBuffer str = new StringBuffer(""); if (parms.containsKey("ISSMTPFORWARD")) { @SuppressWarnings("unchecked") final TreeMap<String, JournalsLibrary.SMTPJournal> set = (TreeMap<String, JournalsLibrary.SMTPJournal>) Resources.getResource("SYSTEM_SMTP_JOURNALS"); final JournalsLibrary.SMTPJournal entry = (set != null) ? set.get(last.toUpperCase().trim()) : null; final String email = ((M != null) && (M.playerStats() != null) && (M.playerStats().getEmail() != null)) ? M.playerStats().getEmail() : ""; str.append( ((entry != null) && (email.length() > 0)) ? Boolean.toString(entry.forward) : "false") .append(", "); } if (parms.containsKey("ISSMTPSUBSCRIBER")) { final Map<String, List<String>> lists = Resources.getCachedMultiLists("mailinglists.txt", true); final List<String> mylist = lists.get(last); str.append( ((mylist != null) && (M != null)) ? Boolean.toString(mylist.contains(M.Name())) : "false") .append(", "); } if (parms.containsKey("SMTPADDRESS")) { @SuppressWarnings("unchecked") final TreeMap<String, JournalsLibrary.SMTPJournal> set = (TreeMap<String, JournalsLibrary.SMTPJournal>) Resources.getResource("SYSTEM_SMTP_JOURNALS"); final JournalsLibrary.SMTPJournal entry = (set != null) ? set.get(last.toUpperCase().trim()) : null; if ((entry != null) && (entry.forward)) { str.append(entry.name.replace(' ', '_') + "@" + CMProps.getVar(CMProps.Str.MUDDOMAIN)) .append(", "); } } if (parms.containsKey("CANADMIN") || parms.containsKey("ISADMIN")) str.append("" + journal.authorizationCheck(M, ForumJournalFlags.ADMIN)).append(", "); if (parms.containsKey("CANPOST")) str.append("" + journal.authorizationCheck(M, ForumJournalFlags.POST)).append(", "); if (parms.containsKey("CANREAD")) str.append("" + journal.authorizationCheck(M, ForumJournalFlags.READ)).append(", "); if (parms.containsKey("CANREPLY")) str.append("" + journal.authorizationCheck(M, ForumJournalFlags.REPLY)).append(", "); if (parms.containsKey("ADMINMASK")) str.append("" + journal.adminMask()).append(", "); if (parms.containsKey("READMASK")) str.append("" + journal.readMask()).append(", "); if (parms.containsKey("POSTMASK")) str.append("" + journal.postMask()).append(", "); if (parms.containsKey("REPLYMASK")) str.append("" + journal.replyMask()).append(", "); if (parms.containsKey("ID")) str.append("" + journal.NAME()).append(", "); if (parms.containsKey("NAME")) str.append("" + journal.NAME()).append(", "); if (parms.containsKey("EXPIRE")) str.append("").append(", "); final JournalsLibrary.JournalSummaryStats stats = CMLib.journals().getJournalStats(journal); if (stats == null) return " @break@"; if (parms.containsKey("POSTS")) str.append("" + stats.posts).append(", "); if (parms.containsKey("THREADS")) str.append("" + stats.threads).append(", "); if (parms.containsKey("SHORTDESC")) str.append("" + stats.shortIntro).append(", "); if (parms.containsKey("LONGDESC")) str.append("" + stats.longIntro).append(", "); if (parms.containsKey("IMAGEPATH")) { if ((stats.imagePath == null) || (stats.imagePath.trim().length() == 0)) str.append(L("images/lilcm.jpg")).append(", "); else str.append("" + stats.threads).append(", "); } String strstr = str.toString(); if (strstr.endsWith(", ")) strstr = strstr.substring(0, strstr.length() - 2); return clearWebMacros(strstr); }