@Override public boolean okMessage(final Environmental myHost, final CMMsg msg) { if (!(affected instanceof MOB)) return true; final MOB mob = (MOB) affected; // when this spell is on a MOBs Affected list, // it should consistantly prevent the mob // from trying to do ANYTHING except sleep if ((msg.amITarget(mob)) && (CMath.bset(msg.targetMajor(), CMMsg.MASK_MALICIOUS)) && (msg.source() == mob.amFollowing())) unInvoke(); if ((msg.amISource(mob)) && (CMath.bset(msg.targetMajor(), CMMsg.MASK_MALICIOUS)) && (msg.target() == mob.amFollowing())) { mob.tell(L("You like @x1 too much.", mob.amFollowing().charStats().himher())); return false; } else if ((msg.amISource(mob)) && (!mob.isMonster()) && (msg.target() instanceof Room) && ((msg.targetMinor() == CMMsg.TYP_LEAVE) || (msg.sourceMinor() == CMMsg.TYP_RECALL)) && (mob.amFollowing() != null) && (((Room) msg.target()).isInhabitant(mob.amFollowing()))) { mob.tell(L("You don't want to leave your friend.")); return false; } else if ((msg.amISource(mob)) && (mob.amFollowing() != null) && (msg.sourceMinor() == CMMsg.TYP_NOFOLLOW)) { mob.tell(L("You like @x1 too much.", mob.amFollowing().name())); return false; } return super.okMessage(myHost, msg); }
protected Vector loadRecipes() { String filename = parametersFile(); Vector recipes = (Vector) Resources.getResource("PARSED: " + filename); if (recipes == null) { StringBuffer str = new CMFile(Resources.buildResourcePath("skills") + filename, null, true).text(); recipes = loadList(str); if (recipes.size() == 0) Log.errOut("LeatherWorking", "Recipes not found!"); else { Vector pleaseAdd1 = new Vector(); Vector pleaseAdd2 = new Vector(); for (int r = 0; r < recipes.size(); r++) { Vector V = (Vector) recipes.elementAt(r); if (V.size() > 0) { Vector V1 = (Vector) V.clone(); Vector V2 = (Vector) V.clone(); String name = (String) V.elementAt(RCP_FINALNAME); V1.setElementAt("Hard " + name, RCP_FINALNAME); V1.setElementAt("" + (CMath.s_int((String) V.elementAt(RCP_LEVEL)) + 5), RCP_LEVEL); V2.setElementAt("Studded " + name, RCP_FINALNAME); V2.setElementAt("" + (CMath.s_int((String) V.elementAt(RCP_LEVEL)) + 11), RCP_LEVEL); pleaseAdd1.addElement(V1); pleaseAdd2.addElement(V2); } } for (int i = 0; i < pleaseAdd1.size(); i++) recipes.addElement(pleaseAdd1.elementAt(i)); for (int i = 0; i < pleaseAdd2.size(); i++) recipes.addElement(pleaseAdd2.elementAt(i)); } Resources.submitResource("PARSED: " + filename, recipes); } return recipes; }
public boolean execute(MOB mob, Vector commands, int metaFlags) throws java.io.IOException { if ((mob == null) || (mob.playerStats() == null)) return false; if (commands.size() < 2) { String pageBreak = (mob.playerStats().getPageBreak() != 0) ? ("" + mob.playerStats().getPageBreak()) : "Disabled"; mob.tell( "Change your page break to what? Your current page break setting is: " + pageBreak + ". Enter a number larger than 0 or 'disable'."); return false; } String newBreak = CMParms.combine(commands, 1); int newVal = mob.playerStats().getWrap(); if ((CMath.isInteger(newBreak)) && (CMath.s_int(newBreak) > 0)) newVal = CMath.s_int(newBreak); else if ("DISABLED".startsWith(newBreak.toUpperCase())) newVal = 0; else { mob.tell( "'" + newBreak + "' is not a valid setting. Enter a number larger than 0 or 'disable'."); return false; } mob.playerStats().setPageBreak(newVal); String pageBreak = (mob.playerStats().getPageBreak() != 0) ? ("" + mob.playerStats().getPageBreak()) : "Disabled"; mob.tell("Your new page break setting is: " + pageBreak + "."); return false; }
@Override public boolean okMessage(final Environmental myHost, final CMMsg msg) { if ((affected instanceof MOB) && (msg.amISource((MOB) affected)) && (msg.targetMinor() == CMMsg.TYP_DAMAGE) && (msg.tool() instanceof Weapon) && (msg.value() > 0) && (msg.target() instanceof MOB) && (((Weapon) msg.tool()).weaponClassification() == Weapon.CLASS_THROWN)) { if (CMLib.dice().rollPercentage() < 25) helpProficiency((MOB) affected, 0); final CMMsg msg2 = CMClass.getMsg( (MOB) msg.target(), msg.tool(), this, CMMsg.MSG_OK_VISUAL, L("^F^<FIGHT^><T-NAME> fragment(s) in <S-NAME>!^</FIGHT^>^?")); CMLib.color().fixSourceFightColor(msg2); msg.addTrailerMsg(msg2); msg.setValue( msg.value() + (int) Math.round( CMath.mul( 3.0 * msg.value(), CMath.div(proficiency(), 100.0 - (10.0 * getXLEVELLevel(invoker())))))); } return super.okMessage(myHost, msg); }
public DVector parseLootPolicyFor(MOB mob) { if (mob == null) return new DVector(3); Vector lootPolicy = (!mob.isMonster()) ? new Vector() : CMParms.parseCommas(CMProps.getVar(CMProps.SYSTEM_ITEMLOOTPOLICY), true); DVector policies = new DVector(3); for (int p = 0; p < lootPolicy.size(); p++) { String s = ((String) lootPolicy.elementAt(p)).toUpperCase().trim(); if (s.length() == 0) continue; Vector compiledMask = null; int maskDex = s.indexOf("MASK="); if (maskDex >= 0) { s = s.substring(0, maskDex).trim(); compiledMask = CMLib.masking() .maskCompile(((String) lootPolicy.elementAt(p)).substring(maskDex + 5).trim()); } else compiledMask = new Vector(); Vector parsed = CMParms.parse(s); int pct = 100; for (int x = 0; x < parsed.size(); x++) if (CMath.isInteger((String) parsed.elementAt(x))) pct = CMath.s_int((String) parsed.elementAt(x)); else if (CMath.isPct((String) parsed.elementAt(x))) pct = (int) Math.round(CMath.s_pct((String) parsed.elementAt(x)) * 100.0); int flags = 0; if (parsed.contains("RUIN")) flags |= CMMiscUtils.LOOTFLAG_RUIN; else if (parsed.contains("LOSS")) flags |= CMMiscUtils.LOOTFLAG_LOSS; if (flags == 0) flags |= CMMiscUtils.LOOTFLAG_LOSS; if (parsed.contains("WORN")) flags |= CMMiscUtils.LOOTFLAG_WORN; else if (parsed.contains("UNWORN")) flags |= CMMiscUtils.LOOTFLAG_UNWORN; policies.addElement(Integer.valueOf(pct), Integer.valueOf(flags), compiledMask); } return policies; }
public String tickInfo(String which) { int grpstart = -1; for (int i = 0; i < which.length(); i++) if (Character.isDigit(which.charAt(i))) { grpstart = i; break; } if (which.equalsIgnoreCase("tickGroupSize")) return "" + ticks.size(); else if (which.toLowerCase().startsWith("tickerssize")) { if (grpstart < 0) return ""; int group = CMath.s_int(which.substring(grpstart)); if ((group >= 0) && (group < ticks.size())) return "" + ((Tick) ticks.get(group)).numTickers(); return ""; } int group = -1; int client = -1; int clistart = which.indexOf("-"); if ((grpstart >= 0) && (clistart > grpstart)) { group = CMath.s_int(which.substring(grpstart, clistart)); client = CMath.s_int(which.substring(clistart + 1)); } if ((group < 0) || (client < 0) || (group >= ticks.size())) return ""; Tick almostTock = (Tick) ticks.get(group); if (client >= almostTock.numTickers()) return ""; TockClient C = almostTock.fetchTickerByIndex(client); if (C == null) return ""; if (which.toLowerCase().startsWith("tickername")) { Tickable E = C.clientObject; if ((E instanceof Ability) && (E.ID().equals("ItemRejuv"))) E = ((Ability) E).affecting(); if (E instanceof Room) return CMLib.map().getExtendedRoomID((Room) E); if (E != null) return E.name(); return "!NULL!"; } else if (which.toLowerCase().startsWith("tickerid")) return "" + C.tickID; else if (which.toLowerCase().startsWith("tickerstatus")) return ((C.clientObject == null) ? "" : ("" + C.clientObject.getTickStatus())); else if (which.toLowerCase().startsWith("tickercodeword")) return getTickStatusSummary(C.clientObject); else if (which.toLowerCase().startsWith("tickertickdown")) return "" + C.tickDown; else if (which.toLowerCase().startsWith("tickerretickdown")) return "" + C.reTickDown; else if (which.toLowerCase().startsWith("tickermillitotal")) return "" + C.milliTotal; else if (which.toLowerCase().startsWith("tickermilliavg")) { if (C.tickTotal == 0) return "0"; return "" + (C.milliTotal / C.tickTotal); } else if (which.toLowerCase().startsWith("tickerlaststartmillis")) return "" + C.lastStart; else if (which.toLowerCase().startsWith("tickerlaststopmillis")) return "" + C.lastStop; else if (which.toLowerCase().startsWith("tickerlaststartdate")) return CMLib.time().date2String(C.lastStart); else if (which.toLowerCase().startsWith("tickerlaststopdate")) return CMLib.time().date2String(C.lastStop); else if (which.toLowerCase().startsWith("tickerlastduration")) { if (C.lastStop >= C.lastStart) return CMLib.english().returnTime(C.lastStop - C.lastStart, 0); return CMLib.english().returnTime(System.currentTimeMillis() - C.lastStart, 0); } else if (which.toLowerCase().startsWith("tickersuspended")) return "" + C.suspended; return ""; }
@Override public void setStat(String code, String val) { if (code == null) return; if (code.equalsIgnoreCase("DAMAGE")) this.damageToTake = CMath.s_int(val); else if (code.equalsIgnoreCase("REVERSED")) this.setProficiency(CMath.s_bool(val) ? 100 : 0); else if (code.equalsIgnoreCase("NORMAL")) this.setProficiency(CMath.s_bool(val) ? 0 : 100); else super.setStat(code, val); }
/** * Converts a string of some form into a Calendar object. <br> * <br> * <b>Usage:</b> Calendar.string2Date(GetRes(Results,"StartDateTime")); * * @param TheDate The string to retrieve from * @return Calendar Calendar object */ public Calendar string2Date(String TheDate) { Calendar D = Calendar.getInstance(); if (TheDate == null) return D; if (TheDate.trim().length() == 0) return D; // for those stupid SQLServer date formats, clean them up! if ((TheDate.indexOf(".") == 19) || ((TheDate.indexOf("-") == 4) && (TheDate.indexOf(":") == 13))) { // String TheOldDate=TheDate; int HH = CMath.s_int(TheDate.substring(11, 13)); int MM = CMath.s_int(TheDate.substring(14, 16)); int AP = Calendar.AM; if (TheDate.trim().endsWith("PM")) AP = Calendar.PM; else if (TheDate.trim().endsWith("AM")) AP = Calendar.AM; else if (HH == 0) { HH = 12; AP = Calendar.AM; } else if (HH > 12) { HH = HH - 12; AP = Calendar.PM; } else if (TheDate.toUpperCase().substring(10).indexOf("P") >= 0) AP = Calendar.PM; else if (TheDate.toUpperCase().substring(10).indexOf("A") >= 0) AP = Calendar.AM; else if (HH == 12) // as 12 always means 12 noon in international date/time -- 0 = 12am AP = Calendar.PM; if ((AP == Calendar.PM) && (HH == 12)) D.set(Calendar.HOUR, 0); else if ((AP == Calendar.AM) && (HH == 12)) D.set(Calendar.HOUR, 0); else D.set(Calendar.HOUR, HH); D.set(Calendar.AM_PM, AP); D.set(Calendar.MINUTE, MM); D.set(Calendar.SECOND, 0); D.set(Calendar.MILLISECOND, 0); int YY = CMath.s_int(TheDate.substring(0, 4)); D.set(Calendar.YEAR, YY); int MN = CMath.s_int(TheDate.substring(5, 7)); D.set(Calendar.MONTH, MN - 1); int DA = CMath.s_int(TheDate.substring(8, 10)); D.set(Calendar.DATE, DA); D.set(Calendar.AM_PM, AP); } else { // If it has no time, give it one! if ((TheDate.indexOf(":") < 0) && (TheDate.indexOf("AM") < 0) && (TheDate.indexOf("PM") < 0)) TheDate = TheDate + " 5:00 PM"; try { DateFormat fmt = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT); fmt.parse(TheDate); D = fmt.getCalendar(); D.set(Calendar.SECOND, 0); D.set(Calendar.MILLISECOND, 0); } catch (ParseException e) { } } confirmDateAMPM(TheDate, D); return D; }
public boolean isTickExpression(String val) { val = val.trim(); if (CMath.isMathExpression(val)) return true; int x = val.lastIndexOf(' '); if (x < 0) return CMath.isMathExpression(val); double multiPlier = getTickExpressionMultiPlier(val.substring(x + 1)); if (multiPlier == 0.0) return CMath.isMathExpression(val); return CMath.isMathExpression(val.substring(0, x).trim()); }
@Override public boolean invoke(MOB mob, Vector commands, Physical givenTarget, boolean auto, int asLevel) { if (!super.invoke(mob, commands, givenTarget, auto, asLevel)) return false; final boolean success = proficiencyCheck(mob, 0, auto); final String str = auto ? L("The unholy word is spoken.") : L("^S<S-NAME> speak(s) the unholy word@x1 to <T-NAMESELF>.^?", ofDiety(mob)); final Room room = mob.location(); if (room != null) for (int i = 0; i < room.numInhabitants(); i++) { final MOB target = room.fetchInhabitant(i); if (target == null) break; int affectType = CMMsg.MSG_CAST_VERBAL_SPELL; if (auto) affectType = affectType | CMMsg.MASK_ALWAYS; if (CMLib.flags().isGood(target)) affectType = affectType | CMMsg.MASK_MALICIOUS; if (success) { final CMMsg msg = CMClass.getMsg(mob, target, this, affectType, str); if (room.okMessage(mob, msg)) { room.send(mob, msg); if (msg.value() <= 0) { if (CMLib.flags().canBeHeardSpeakingBy(mob, target)) { final Item I = Prayer_Curse.getSomething(mob, true); if (I != null) { Prayer_Curse.endLowerBlessings(I, CMLib.ableMapper().lowestQualifyingLevel(ID())); I.recoverPhyStats(); } Prayer_Curse.endLowerBlessings( target, CMLib.ableMapper().lowestQualifyingLevel(ID())); beneficialAffect(mob, target, asLevel, 0); target.recoverPhyStats(); } else if (CMath.bset(affectType, CMMsg.MASK_MALICIOUS)) maliciousFizzle(mob, target, L("<T-NAME> did not hear the unholy word!")); else beneficialWordsFizzle(mob, target, L("<T-NAME> did not hear the unholy word!")); } } } else { if (CMath.bset(affectType, CMMsg.MASK_MALICIOUS)) maliciousFizzle( mob, target, L("<S-NAME> attempt(s) to speak the unholy word to <T-NAMESELF>, but flub(s) it.")); else beneficialWordsFizzle( mob, target, L("<S-NAME> attempt(s) to speak the unholy word to <T-NAMESELF>, but flub(s) it.")); return false; } } // return whether it worked return success; }
public Room getGridChild(String childCode) { if (childCode.equalsIgnoreCase(roomID())) return this; if (!childCode.toUpperCase().startsWith(roomID().toUpperCase() + "#(")) return null; int len = roomID().length() + 2; int comma = childCode.indexOf(',', len); if (comma < 0) return null; int x = CMath.s_int(childCode.substring(len, comma)); int y = CMath.s_int(childCode.substring(comma + 1, childCode.length() - 1)); return getMakeGridRoom(x, y); }
protected Area getParentArea() { int x = Name().indexOf("_"); if (x < 0) return null; if (!CMath.isNumber(Name().substring(0, x))) return null; Area parentA = CMLib.map().getArea(Name().substring(x + 1)); if ((parentA == null) || (!CMath.bset(parentA.flags(), Area.FLAG_INSTANCE_PARENT)) || (CMath.bset(parentA.flags(), Area.FLAG_INSTANCE_CHILD))) return null; return parentA; }
protected int parseOutLevel(Vector commands) { if ((commands.size() > 1) && (commands.lastElement() instanceof String) && (CMath.isNumber((String) commands.lastElement()))) { final int x = CMath.s_int((String) commands.lastElement()); commands.remove(commands.size() - 1); return x; } return -1; }
@Override public String ageName() { final int cat = ageCategory(); if (cat < Race.AGE_ANCIENT) return Race.AGE_DESCS[cat]; int age = getStat(STAT_AGE); final int[] chart = getMyRace().getAgingChart(); final int diff = chart[Race.AGE_ANCIENT] - chart[Race.AGE_VENERABLE]; age = age - chart[Race.AGE_ANCIENT]; final int num = (diff > 0) ? (int) Math.abs(Math.floor(CMath.div(age, diff))) : 0; if (num <= 0) return Race.AGE_DESCS[cat]; return Race.AGE_DESCS[cat] + " " + CMath.convertToRoman(num); }
@Override public void setStat(String code, String val) { final int dex = CMParms.indexOfIgnoreCase(getStatCodes(), code); if (dex >= 0) setStat(dex, CMath.s_parseIntExpression(val)); else for (final int i : CharStats.CODES.ALLCODES()) { if (CODES.DESC(i).startsWith(code)) { setStat(dex, CMath.s_parseIntExpression(val)); return; } } }
public boolean invoke( MOB mob, Vector commands, Environmental givenTarget, boolean auto, int asLevel) { Item target = super.getTarget(mob, mob.location(), givenTarget, commands, Wearable.FILTER_ANY); if (target == null) return false; if ((!(target instanceof Ammunition)) || (!((Ammunition) target).ammunitionType().equalsIgnoreCase("arrows"))) { mob.tell(mob, target, null, "You can't enchant <T-NAME> ith an Enchant Arrows spell!"); return false; } if (!super.invoke(mob, commands, givenTarget, auto, asLevel)) return false; int experienceToLose = getXPCOSTAdjustment(mob, 5); CMLib.leveler().postExperience(mob, null, null, -experienceToLose, false); boolean success = proficiencyCheck(mob, 0, auto); if (success) { CMMsg msg = CMClass.getMsg( mob, target, this, verbalCastCode(mob, target, auto), auto ? "" : "^S<S-NAME> hold(s) <T-NAMESELF> and cast(s) a spell.^?"); if (mob.location().okMessage(mob, msg)) { mob.location().send(mob, msg); Ability A = target.fetchEffect(ID()); if ((A != null) && (CMath.s_int(A.text()) > 2)) mob.tell("You are not able to enchant " + target.name() + " further."); else { mob.location().show(mob, target, CMMsg.MSG_OK_VISUAL, "<T-NAME> glows!"); if (A == null) { A = (Ability) copyOf(); target.addNonUninvokableEffect(A); } A.setMiscText("" + (CMath.s_int(A.text()) + 1)); target.recoverEnvStats(); mob.recoverEnvStats(); } } } else beneficialWordsFizzle( mob, target, "<S-NAME> hold(s) <T-NAMESELF> tightly and whisper(s), but fail(s) to cast a spell."); // return whether it worked return success; }
@Override public boolean okMessage(final Environmental myHost, final CMMsg msg) { if (affected == null) return super.okMessage(myHost, msg); if (affected instanceof MOB) { final MOB mob = (MOB) affected; if ((msg.amITarget(mob)) && (!msg.amISource(mob)) && (mob.location() != msg.source().location()) && (msg.tool() instanceof Ability) && (CMath.bset(((Ability) msg.tool()).flags(), Ability.FLAG_TRANSPORTING)) && (!mob.amDead())) { final Ability A = (Ability) msg.tool(); if (((A.classificationCode() & Ability.ALL_ACODES) == Ability.ACODE_CHANT) || ((A.classificationCode() & Ability.ALL_ACODES) == Ability.ACODE_SPELL) || ((A.classificationCode() & Ability.ALL_ACODES) == Ability.ACODE_PRAYER) || ((A.classificationCode() & Ability.ALL_ACODES) == Ability.ACODE_SONG)) msg.source() .location() .showHappens( CMMsg.MSG_OK_VISUAL, L("Magical energy fizzles and is absorbed into the air!")); return false; } } else if (affected instanceof Room) { final Room R = (Room) affected; if ((msg.tool() instanceof Ability) && (msg.source().location() != null) && (msg.sourceMinor() != CMMsg.TYP_LEAVE)) { final boolean summon = CMath.bset(((Ability) msg.tool()).flags(), Ability.FLAG_SUMMONING); final boolean teleport = CMath.bset(((Ability) msg.tool()).flags(), Ability.FLAG_TRANSPORTING); final boolean shere = (msg.source().location() == affected) || ((affected instanceof Area) && (((Area) affected).inMyMetroArea(msg.source().location().getArea()))); if ((!shere) && (!summon) && (teleport) && (!CMLib.law().doesHavePriviledgesHere(msg.source(), R))) { if ((msg.source().location() != null) && (msg.source().location() != R)) msg.source() .location() .showHappens( CMMsg.MSG_OK_VISUAL, L("Magical energy fizzles and is absorbed into the air!")); R.showHappens( CMMsg.MSG_OK_VISUAL, L("Magic energy fizzles and is absorbed into the air.")); return false; } } } return super.okMessage(myHost, msg); }
@Override public String runMacro(HTTPRequest httpReq, String parm, HTTPResponse httpResp) { final String last = httpReq.getUrlParameter("GOVERNMENT"); if (last == null) return " @break@"; if (last.length() > 0) { if (CMath.isInteger(last)) { final ClanGovernment G = CMLib.clans().getStockGovernment(CMath.s_int(last)); if (G != null) return clearWebMacros(Integer.toString(G.getID())); } return clearWebMacros(last); } return ""; }
@Override public void executeMsg(final Environmental myHost, final CMMsg msg) { super.executeMsg(myHost, msg); if (!(affected instanceof MOB)) return; final MOB mob = (MOB) affected; if ((msg.amISource(mob)) && (!CMath.bset(msg.sourceMajor(), CMMsg.MASK_CHANNEL)) && ((CMath.bset(msg.sourceMajor(), CMMsg.MASK_MOVE)) || (CMath.bset(msg.sourceMajor(), CMMsg.MASK_HANDS)) || (CMath.bset(msg.sourceMajor(), CMMsg.MASK_MOUTH)))) unInvoke(); return; }
@Override public Tattoo parse(final String tattooCode) { if ((tattooCode == null) || (tattooCode.length() == 0)) return this; tattooName = tattooCode; if (Character.isDigit(tattooName.charAt(0))) { final int x = tattooName.indexOf(' '); if ((x > 0) && (CMath.isNumber(tattooName.substring(0, x).trim()))) { tickDown = CMath.s_int(tattooName.substring(0, x)); tattooName = tattooName.substring(x + 1).trim(); } } return this; }
public String composition() { String comp = ""; if (trail != null) { String t = trail.toString(); final int[] counts = new int[stuff.length]; int x = t.indexOf(';'); while (x >= 0) { final int q = CMath.s_int(t.substring(0, x)); t = t.substring(x + 1); if (q >= 0) { for (int i = 0; i < stuff.length; i++) { if (CMath.s_int(stuff[i][0]) == q) counts[i]++; } } x = t.indexOf(';'); } int wa = -1; for (int i = 0; i < stuff.length; i++) if (CMath.s_int(stuff[i][0]) == CMMsg.TYP_WEAPONATTACK) { wa = i; break; } if (wa >= 0) counts[wa] = counts[wa] / 25; final Vector<Integer> V = new Vector<Integer>(); while (V.size() < counts.length) { int high = -1; int which = -1; for (int i = 0; i < counts.length; i++) { if ((counts[i] > high) && (!V.contains(Integer.valueOf(i)))) { high = counts[i]; which = i; } } if (which >= 0) V.addElement(Integer.valueOf(which)); } final Vector<Integer> V2 = new Vector<Integer>(); for (int i = 0; i < 3; i++) { final Integer ref = V.elementAt(i); Integer which = null; while ((which == null) || (V2.contains(which))) { final Integer w = V.elementAt(CMLib.dice().roll(1, V.size(), -1)); if (counts[w.intValue()] == counts[ref.intValue()]) which = w; } V2.addElement(which); comp += which.intValue() + ";" + counts[which.intValue()] + ";"; } } return comp; }
@Override public void setMyLevels(String levels) { if ((levels.length() == 0) && (myClasses != null) && (myClasses.length > 0)) levels = "0"; int x = levels.indexOf(';'); final ArrayList<Integer> levelV = new ArrayList<Integer>(); while (x >= 0) { final String theLevel = levels.substring(0, x).trim(); levels = levels.substring(x + 1); if (theLevel.length() > 0) levelV.add(Integer.valueOf(CMath.s_int(theLevel))); x = levels.indexOf(';'); } if (levels.trim().length() > 0) levelV.add(Integer.valueOf(CMath.s_int(levels))); myLevels = levelV.toArray(new Integer[0]); }
@Override public boolean okMessage(final Environmental myHost, final CMMsg msg) { if (affected == null) return super.okMessage(myHost, msg); if ((msg.sourceMinor() == CMMsg.TYP_CAST_SPELL) && (msg.tool() instanceof Ability) && ((((Ability) msg.tool()).classificationCode() & Ability.ALL_ACODES) == Ability.ACODE_PRAYER) && (CMath.bset(((Ability) msg.tool()).flags(), Ability.FLAG_UNHOLY)) && (!CMath.bset(((Ability) msg.tool()).flags(), Ability.FLAG_HOLY))) { msg.source().tell(L("This place is blocking unholy magic!")); return false; } return super.okMessage(myHost, msg); }
@Override public void affectCharStats(MOB affected, CharStats affectableStats) { super.affectCharStats(affected, affectableStats); affectableStats.setStat( CharStats.STAT_STRENGTH, (int) Math.round(CMath.div(affectableStats.getStat(CharStats.STAT_STRENGTH), 2.0))); }
public boolean okMessage(Environmental myHost, CMMsg msg) { if (affected == null) return true; if (!super.okMessage(myHost, msg)) return false; MOB mob = msg.source(); if (((!msg.amITarget(affected)) && (msg.tool() != affected)) || (msg.source() == invoker()) || (CMLib.law().doesHavePriviledgesHere(mob, msg.source().location())) && (text().toUpperCase().indexOf("MALICIOUS") < 0)) return true; switch (msg.targetMinor()) { case CMMsg.TYP_OPEN: mob.tell(affected.name() + " appears to be magically locked."); return false; case CMMsg.TYP_UNLOCK: mob.tell(affected.name() + " appears to be magically locked."); return false; case CMMsg.TYP_JUSTICE: if (!CMath.bset(msg.targetMajor(), CMMsg.MASK_DELICATE)) return true; case CMMsg.TYP_DELICATE_HANDS_ACT: mob.tell(affected.name() + " appears to be magically protected."); return false; default: break; } return true; }
public static void setStat(Environmental E, String stat, String value) { if ((stat != null) && (stat.length() > 0) && (stat.equalsIgnoreCase("REJUV")) && (E instanceof Physical)) ((Physical) E).basePhyStats().setRejuv(CMath.s_int(value)); else E.setStat(stat, value); }
@Override public void executeMsg(final Environmental myHost, final CMMsg msg) { if (msg.amITarget(this)) { final MOB mob = msg.source(); switch (msg.targetMinor()) { case CMMsg.TYP_GET: case CMMsg.TYP_REMOVE: { unWear(); setContainer(null); if (!mob.isMine(this)) { mob.setQuestPoint(mob.getQuestPoint() + 1); CMLib.players().bumpPrideStat(mob, PrideStat.QUESTPOINTS_EARNED, 1); } if (!CMath.bset(msg.targetMajor(), CMMsg.MASK_OPTIMIZE)) mob.location().recoverRoomStats(); destroy(); return; } default: break; } } super.executeMsg(myHost, msg); }
public String date2String(Calendar C) { String MINUTE = Integer.toString(C.get(Calendar.MINUTE)).trim(); if (MINUTE.length() == 1) MINUTE = "0" + MINUTE; String AMPM = "AM"; if (C.get(Calendar.AM_PM) == Calendar.PM) AMPM = "PM"; int Hour = C.get(Calendar.HOUR); if (Hour == 0) Hour = 12; String Year = Integer.toString(C.get(Calendar.YEAR)); if (Year.length() < 4) { if (Year.length() < 2) Year = ("0" + Year); if (Year.length() < 2) Year = ("0" + Year); int Yr = CMath.s_int(Year); if (Yr < 50) Year = "20" + Year; else Year = "19" + Year; } return (C.get(Calendar.MONTH) + 1) + "/" + C.get(Calendar.DATE) + "/" + Year + " " + Hour + ":" + MINUTE + " " + AMPM; }
public void executeMsg(Environmental affecting, CMMsg msg) { super.executeMsg(affecting, msg); if ((msg.target() == null) || (!(msg.target() instanceof MOB))) return; MOB source = msg.source(); MOB observer = (MOB) affecting; MOB target = (MOB) msg.target(); if ((source != observer) && (target != observer) && (source != target) && (CMath.bset(msg.targetCode(), CMMsg.MASK_MALICIOUS)) && (!observer.isInCombat()) && (CMLib.flags().canBeSeenBy(source, observer)) && (CMLib.flags().canBeSeenBy(target, observer)) && (!BrotherHelper.isBrother(source, observer, false)) && ((CMLib.flags().isEvil(target) && CMLib.flags().isEvil(observer)) || (CMLib.flags().isNeutral(target) && CMLib.flags().isNeutral(observer)) || (CMLib.flags().isGood(target) && CMLib.flags().isGood(observer)))) { Aggressive.startFight( observer, source, true, false, CMLib.flags().getAlignmentName(observer) + " PEOPLE UNITE! CHARGE!"); } }
@Override public boolean okMessage(final Environmental myHost, final CMMsg msg) { if ((myHost != null) && (myHost instanceof MOB) && (msg.amISource((MOB) myHost))) { if (((msg.targetMinor() == CMMsg.TYP_LEAVE) || (msg.sourceMinor() == CMMsg.TYP_ADVANCE) || (msg.sourceMinor() == CMMsg.TYP_RETREAT) || (msg.sourceMinor() == CMMsg.TYP_RECALL))) { msg.source().tell(L("You can't really go anywhere -- you're a rock!")); return false; } } else if (((msg.targetMajor() & CMMsg.MASK_MALICIOUS) > 0) && (myHost instanceof MOB) && (msg.amITarget(myHost)) && (!CMath.bset(msg.sourceMajor(), CMMsg.MASK_ALWAYS))) { final MOB target = (MOB) msg.target(); if ((!target.isInCombat()) && (msg.source().isMonster()) && (msg.source().location() == target.location()) && (msg.source().getVictim() != target)) { msg.source().tell(L("Attack a rock?!")); if (target.getVictim() == msg.source()) { target.makePeace(); target.setVictim(null); } return false; } } return super.okMessage(myHost, msg); }