public void unInvoke() { // undo the affects of this spell if (!(affected instanceof MOB)) return; super.unInvoke(); if ((canBeUninvoked()) && (clan1 != null) && (clan2 != null)) { final Clan C1 = clan1; final Clan C2 = clan2; if ((C1 != null) && (C2 != null)) { if (C1.getClanRelations(C2.clanID()) == Clan.REL_WAR) { C1.setClanRelations(C2.clanID(), Clan.REL_HOSTILE, System.currentTimeMillis()); C1.update(); } if (C2.getClanRelations(C1.clanID()) == Clan.REL_WAR) { C2.setClanRelations(C1.clanID(), Clan.REL_HOSTILE, System.currentTimeMillis()); C2.update(); } List<String> channels = CMLib.channels().getFlaggedChannelNames(ChannelsLibrary.ChannelFlag.CLANINFO); for (int i = 0; i < channels.size(); i++) CMLib.commands() .postChannel( channels.get(i), CMLib.clans().clanRoles(), "There is now peace between " + C1.name() + " and " + C2.name() + ".", false); } } }
@Override public boolean invoke( MOB mob, List<String> commands, Physical givenTarget, boolean auto, int asLevel) { if (!mob.clans().iterator().hasNext()) { mob.tell(L("You aren't even a member of a clan.")); return false; } final Pair<Clan, Integer> clanPair = CMLib.clans().findPrivilegedClan(mob, Clan.Function.CLAN_BENEFITS); if (clanPair == null) { mob.tell(L("You are not authorized to draw from the power of your clan.")); return false; } final Clan C = clanPair.first; Room clanHomeRoom = null; clanHomeRoom = CMLib.map().getRoom(C.getRecall()); if (clanHomeRoom == null) { mob.tell(L("Your clan does not have a clan home.")); return false; } if (!CMLib.flags().canAccess(mob, clanHomeRoom)) { mob.tell(L("You can't use this magic to get there from here.")); return false; } if (!CMLib.law().doesOwnThisProperty(C.clanID(), clanHomeRoom)) { mob.tell(L("Your clan no longer owns that room.")); 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, null, this, CMMsg.MASK_MOVE | verbalCastCode(mob, mob, auto), L("^S<S-NAME> invoke(s) a teleportation spell.^?")); if (mob.location().okMessage(mob, msg)) { mob.location().send(mob, msg); final Set<MOB> h = properTargets(mob, givenTarget, false); if (h == null) return false; final Room thisRoom = mob.location(); for (final Object element : h) { final MOB follower = (MOB) element; final CMMsg enterMsg = CMClass.getMsg( follower, clanHomeRoom, this, CMMsg.MSG_ENTER, null, CMMsg.MSG_ENTER, null, CMMsg.MSG_ENTER, L("<S-NAME> appears in a puff of red smoke.")); final CMMsg leaveMsg = CMClass.getMsg( follower, thisRoom, this, CMMsg.MSG_LEAVE | CMMsg.MASK_MAGIC, L("<S-NAME> disappear(s) in a puff of red smoke.")); if (thisRoom.okMessage(follower, leaveMsg) && clanHomeRoom.okMessage(follower, enterMsg)) { if (follower.isInCombat()) { CMLib.commands().postFlee(follower, ("NOWHERE")); follower.makePeace(false); } thisRoom.send(follower, leaveMsg); clanHomeRoom.bringMobHere(follower, false); clanHomeRoom.send(follower, enterMsg); follower.tell(L("\n\r\n\r")); CMLib.commands().postLook(follower, true); } } } } else beneficialWordsFizzle( mob, null, L("<S-NAME> attempt(s) to invoke transportation, but fizzle(s) the spell.")); // return whether it worked return success; }
public boolean invoke( MOB mob, Vector commands, Environmental givenTarget, boolean auto, int asLevel) { if (type.length() == 0) return false; if ((mob.getClanID() == null) || (mob.getClanID().equalsIgnoreCase("")) || (mob.getClanRole() == 0)) { mob.tell("You aren't even a member of a clan."); return false; } Clan C = CMLib.clans().getClan(mob.getClanID()); if (C == null) { mob.tell("You aren't even a member of a clan."); return false; } if (C.allowedToDoThis(mob, Clan.FUNC_CLANENCHANT) != 1) { mob.tell("You are not authorized to draw from the power of your " + C.typeName() + "."); return false; } String ClanName = C.clanID(); String ClanType = C.typeName(); // Invoking will be like: // CAST [CLANEQSPELL] ITEM QUANTITY // -2 -1 0 1 if (commands.size() < 1) { mob.tell("Enchant which spell onto what?"); return false; } if (commands.size() < 2) { mob.tell("Use how much clan enchantment power?"); return false; } Environmental target = mob.location() .fetchFromMOBRoomFavorsItems( mob, null, (String) commands.elementAt(0), Item.WORNREQ_UNWORNONLY); if ((target == null) || (!CMLib.flags().canBeSeenBy(target, mob))) { mob.tell("You don't see '" + ((String) commands.elementAt(0)) + "' here."); return false; } // Add clan power check start int points = CMath.s_int((String) commands.elementAt(1)); if (points <= 0) { mob.tell("You need to use at least 1 enchantment point."); return false; } long exp = points * CMProps.getIntVar(CMProps.SYSTEMI_CLANENCHCOST); if ((C.getExp() < exp) || (exp < 0)) { mob.tell( "You need " + exp + " to do that, but your " + C.typeName() + " has only " + C.getExp() + " experience points."); return false; } // Add clan power check end if (target.fetchEffect("Prop_ClanEquipment") != null) { mob.tell(target.name() + " is already clan enchanted."); return false; } // lose all the mana! if (!super.invoke(mob, commands, givenTarget, auto, asLevel)) return false; boolean success = proficiencyCheck(mob, 0, auto); C.setExp(C.getExp() - exp); C.update(); if (success) { CMMsg msg = CMClass.getMsg( mob, target, this, verbalCastCode(mob, target, auto), "^S<S-NAME> move(s) <S-HIS-HER> fingers around <T-NAMESELF>, encanting intensely.^?"); if (mob.location().okMessage(mob, msg)) { mob.location().send(mob, msg); Ability A = CMClass.getAbility("Prop_ClanEquipment"); StringBuffer str = new StringBuffer(""); str.append(type); // Type of Enchantment str.append(" "); str.append("" + points); // Power of Enchantment str.append(" \""); str.append(ClanName); // Clan Name str.append("\" \""); str.append(ClanType); // Clan Type str.append("\""); A.setMiscText(str.toString()); target.addEffect(A); } } else beneficialWordsFizzle( mob, target, "<S-NAME> move(s) <S-HIS-HER> fingers around <T-NAMESELF>, encanting intensely, and looking very frustrated."); return success; }
public boolean execute(MOB mob, Vector commands, int metaFlags) throws java.io.IOException { String memberStr = (commands.size() > 1) ? (String) commands.get(commands.size() - 1) : ""; String clanName = (commands.size() > 2) ? CMParms.combine(commands, 1, commands.size() - 1) : ""; Clan C = null; boolean skipChecks = mob.getClanRole(mob.Name()) != null; if (skipChecks) C = mob.getClanRole(mob.Name()).first; if (C == null) for (Pair<Clan, Integer> c : mob.clans()) if ((clanName.length() == 0) || (CMLib.english().containsString(c.first.getName(), clanName)) && (c.first.getAuthority(c.second.intValue(), Clan.Function.EXILE) != Authority.CAN_NOT_DO)) { C = c.first; break; } commands.clear(); commands.addElement(getAccessWords()[0]); commands.addElement(memberStr); StringBuffer msg = new StringBuffer(""); boolean found = false; if (memberStr.length() > 0) { if (C == null) { mob.tell( "You aren't allowed to exile anyone from " + ((clanName.length() == 0) ? "anything" : clanName) + "."); return false; } if (skipChecks || CMLib.clans().goForward(mob, C, commands, Clan.Function.EXILE, false)) { List<MemberRecord> apps = C.getMemberList(); if (apps.size() < 1) { mob.tell("There are no members in your " + C.getGovernmentName() + "."); return false; } for (MemberRecord member : apps) { if (member.name.equalsIgnoreCase(memberStr)) { found = true; } } if (found) { MOB M = CMLib.players().getLoadPlayer(memberStr); if (M == null) { mob.tell( memberStr + " was not found. Could not exile from " + C.getGovernmentName() + "."); return false; } if (skipChecks || CMLib.clans().goForward(mob, C, commands, Clan.Function.EXILE, true)) { if (C.getGovernment().getExitScript().trim().length() > 0) { Pair<Clan, Integer> curClanRole = M.getClanRole(C.clanID()); if (curClanRole != null) M.setClan(C.clanID(), curClanRole.second.intValue()); ScriptingEngine S = (ScriptingEngine) CMClass.getCommon("DefaultScriptingEngine"); S.setSavable(false); S.setVarScope("*"); S.setScript(C.getGovernment().getExitScript()); CMMsg msg2 = CMClass.getMsg(M, M, null, CMMsg.MSG_OK_VISUAL, null, null, "CLANEXIT"); S.executeMsg(M, msg2); S.dequeResponses(); S.tick(M, Tickable.TICKID_MOB); } CMLib.clans() .clanAnnounce( mob, "Member exiled from " + C.getGovernmentName() + " " + C.name() + ": " + M.Name()); mob.tell( M.Name() + " has been exiled from " + C.getGovernmentName() + " '" + C.clanID() + "'."); if ((M.session() != null) && (M.session().mob() == M)) M.tell( "You have been exiled from " + C.getGovernmentName() + " '" + C.clanID() + "'."); C.delMember(M); return false; } } else { msg.append(memberStr + " isn't a member of your " + C.getGovernmentName() + "."); } } else { msg.append( "You aren't in the right position to exile anyone from your " + C.getGovernmentName() + "."); } } else { msg.append("You haven't specified which member you are exiling."); } mob.tell(msg.toString()); return false; }
public String runMacro(ExternalHTTPRequests httpReq, String parm) { if (!CMProps.getBoolVar(CMProps.SYSTEMB_MUDSTARTED)) return CMProps.getVar(CMProps.SYSTEM_MUDSTATUS); Hashtable parms = parseParms(parm); String last = httpReq.getRequestParameter("PLAYER"); if (last == null) return " @break@"; if (last.length() > 0) { MOB M = CMLib.players().getLoadPlayer(last); if (M == null) { MOB authM = Authenticate.getAuthenticatedMob(httpReq); if ((authM != null) && (authM.Name().equalsIgnoreCase(last))) M = authM; else return " @break@"; } boolean firstTime = (!httpReq.isRequestParameter("ACTION")) || (httpReq.getRequestParameter("ACTION")).equals("FIRSTTIME"); StringBuffer str = new StringBuffer(""); for (int i = 0; i < MOB.AUTODESC.length; i++) { if (parms.containsKey(MOB.AUTODESC[i])) { boolean set = CMath.isSet(M.getBitmap(), i); if (MOB.AUTOREV[i]) set = !set; str.append((set ? "ON" : "OFF") + ","); } } for (int i : CharStats.CODES.ALL()) { String stat = CharStats.CODES.NAME(i); if (!stat.equalsIgnoreCase("GENDER")) { CharStats C = M.charStats(); if (parms.containsKey(stat)) { String old = httpReq.getRequestParameter(stat); if ((firstTime) || (old.length() == 0)) { if ((!CharStats.CODES.isBASE(i)) && (i != CharStats.STAT_GENDER)) old = "" + C.getSave(i); else old = "" + C.getStat(i); } str.append(old + ", "); } } } for (int i : CharStats.CODES.ALL()) { String stat = CharStats.CODES.NAME(i); if (!stat.equalsIgnoreCase("GENDER")) { CharStats C = M.baseCharStats(); if (parms.containsKey("BASE" + stat)) { String old = httpReq.getRequestParameter("BASE" + stat); if ((firstTime) || (old.length() == 0)) old = "" + C.getStat(i); str.append(old + ", "); } } } for (int i = 0; i < BASICS.length; i++) { if (parms.containsKey(BASICS[i])) { if (httpReq.isRequestParameter(BASICS[i])) str.append(httpReq.getRequestParameter(BASICS[i]) + ", "); else str.append(getBasic(M, i)); } } if (parms.containsKey("RACE")) { String old = httpReq.getRequestParameter("RACE"); if ((firstTime) || (old.length() == 0)) old = "" + M.baseCharStats().getMyRace().ID(); for (Enumeration r = CMClass.races(); r.hasMoreElements(); ) { Race R2 = (Race) r.nextElement(); str.append("<OPTION VALUE=\"" + R2.ID() + "\""); if (R2.ID().equals(old)) str.append(" SELECTED"); str.append(">" + R2.name()); } } if (parms.containsKey("DEITY")) { String old = httpReq.getRequestParameter("DEITY"); if (firstTime) old = M.getWorshipCharID(); str.append("<OPTION " + ((old.length() == 0) ? "SELECTED" : "") + " VALUE=\"\">Godless"); for (Enumeration e = CMLib.map().deities(); e.hasMoreElements(); ) { Deity E = (Deity) e.nextElement(); str.append("<OPTION VALUE=\"" + E.Name() + "\""); if (E.Name().equalsIgnoreCase(old)) str.append(" SELECTED"); str.append(">" + E.Name()); } } if (parms.containsKey("TITLELIST")) { if (M.playerStats() != null) { int b = 0; Vector titles = new Vector(); if (firstTime) CMParms.addToVector(M.playerStats().getTitles(), titles); else while (httpReq.isRequestParameter("TITLE" + b)) { String B = httpReq.getRequestParameter("TITLE" + b); if ((B != null) && (B.trim().length() > 0)) titles.addElement(B); b++; } for (b = 0; b < titles.size(); b++) { String B = (String) titles.elementAt(b); if (B != null) str.append( "<INPUT TYPE=TEXT NAME=TITLE" + b + " SIZE=" + B.length() + " VALUE=\"" + CMStrings.replaceAll(B, "\"", """) + "\"><BR>"); } str.append("<INPUT TYPE=TEXT NAME=TITLE" + titles.size() + " SIZE=60 VALUE=\"\">"); } } if (parms.containsKey("CLAN")) { String old = httpReq.getRequestParameter("CLAN"); if (firstTime) old = M.getClanID(); str.append("<OPTION " + ((old.length() == 0) ? "SELECTED" : "") + " VALUE=\"\">Clanless"); for (Enumeration e = CMLib.clans().allClans(); e.hasMoreElements(); ) { Clan C = (Clan) e.nextElement(); str.append("<OPTION VALUE=\"" + C.clanID() + "\""); if (C.clanID().equalsIgnoreCase(old)) str.append(" SELECTED"); str.append(">" + C.getName()); } } if (parms.containsKey("ALIGNMENT")) { String old = httpReq.getRequestParameter("ALIGNMENT"); if ((firstTime) || (old.length() == 0)) old = "" + M.fetchFaction(CMLib.factions().AlignID()); if (CMLib.factions().getFaction(CMLib.factions().AlignID()) != null) { for (int v = 1; v < Faction.ALIGN_NAMES.length; v++) { str.append("<OPTION VALUE=" + Faction.ALIGN_NAMES[v]); if (old.equalsIgnoreCase(Faction.ALIGN_NAMES[v])) str.append(" SELECTED"); str.append(">" + CMStrings.capitalizeAndLower(Faction.ALIGN_NAMES[v].toLowerCase())); } } } if (parms.containsKey("BASEGENDER")) { String old = httpReq.getRequestParameter("BASEGENDER"); if (firstTime) old = "" + M.baseCharStats().getStat(CharStats.STAT_GENDER); str.append("<OPTION VALUE=M " + ((old.equalsIgnoreCase("M")) ? "SELECTED" : "") + ">M"); str.append("<OPTION VALUE=F " + ((old.equalsIgnoreCase("F")) ? "SELECTED" : "") + ">F"); str.append("<OPTION VALUE=N " + ((old.equalsIgnoreCase("N")) ? "SELECTED" : "") + ">N"); } str.append(MobData.expertiseList(M, httpReq, parms)); str.append(MobData.classList(M, httpReq, parms)); str.append(MobData.itemList(M, M, httpReq, parms, 0)); str.append(MobData.abilities(M, httpReq, parms, 0)); str.append(MobData.factions(M, httpReq, parms, 0)); str.append(AreaData.affectsNBehaves(M, httpReq, parms, 0)); str.append(ExitData.dispositions(M, firstTime, httpReq, parms)); str.append(MobData.senses(M, firstTime, httpReq, parms)); String strstr = str.toString(); if (strstr.endsWith(", ")) strstr = strstr.substring(0, strstr.length() - 2); return clearWebMacros(strstr); } return ""; }
public boolean invoke(MOB mob, Vector commands, Physical givenTarget, boolean auto, int asLevel) { Physical target = mob; if ((auto) && (givenTarget != null)) target = givenTarget; if (target.fetchEffect(this.ID()) != null) { mob.tell(mob, target, null, "<T-NAME> <T-IS-ARE> already affected by " + name() + "."); return false; } clan1 = CMLib.clans().findRivalrousClan(mob); if (clan1 == null) { mob.tell("You must belong to a clan to use this prayer."); return false; } if (commands.size() < 1) { mob.tell("You must specify the clan you wish to see peace with."); return false; } String clan2Name = CMParms.combine(commands, 0); clan2 = CMLib.clans().findClan(clan2Name); if ((clan2 == null) || ((clan1.getClanRelations(clan2.clanID()) != Clan.REL_WAR) && (clan2.getClanRelations(clan1.clanID()) != Clan.REL_WAR))) { mob.tell("Your " + clan1.getGovernmentName() + " is not at war with " + clan2 + "!"); return false; } boolean found = false; for (Enumeration e = CMLib.players().players(); e.hasMoreElements(); ) { MOB M = (MOB) e.nextElement(); if (M.getClanRole(clan2.clanID()) != null) { found = true; break; } } if (!found) { mob.tell( "You must wait until a member of " + clan2 + " is online before beginning the ritual."); 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 ? "<T-NAME> begin(s) a peace ritual." : "^S<S-NAME> " + prayWord(mob) + " for peace between " + clan1.name() + " and " + clan2.name() + ".^?"); if (mob.location().okMessage(mob, msg)) { mob.location().send(mob, msg); beneficialAffect(mob, target, asLevel, (int) CMProps.getTicksPerMinute() * 5); } } else return beneficialWordsFizzle( mob, null, "<S-NAME> " + prayWord(mob) + " for peace between " + clan1.name() + " and " + clan2.name() + ", but there is no answer."); // return whether it worked return success; }