@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); }
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; }
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; }
@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); }
@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; }
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; }
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; }
@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; } } }
@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); }
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 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; }
@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 ""; }
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 setStat(String code, String val) { switch (getCodeNum(code)) { case 0: return; case 1: basePhyStats().setLevel(CMath.s_parseIntExpression(val)); break; case 2: basePhyStats().setAbility(CMath.s_parseIntExpression(val)); break; case 3: setMiscText(val); break; } }
@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); }
@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); }
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 invoke(MOB mob, Vector commands, Physical givenTarget, boolean auto, int asLevel) { final MOB target = this.getTarget(mob, commands, givenTarget); if (target == null) return false; if (!super.invoke(mob, commands, givenTarget, auto, asLevel)) return false; // now see if it worked final boolean success = proficiencyCheck(mob, 0, auto); if (success) { final CMMsg msg = CMClass.getMsg( mob, target, this, somanticCastCode(mob, target, auto), L( (auto ? "A " : "^S<S-NAME> incant(s) and point(s) at <T-NAMESELF>. A ") + "long shard of ice streaks through the air!^?") + CMLib.protocol().msp("spelldam2.wav", 40)); final CMMsg msg2 = CMClass.getMsg( mob, target, this, CMMsg.MSK_CAST_MALICIOUS_VERBAL | CMMsg.TYP_COLD | (auto ? CMMsg.MASK_ALWAYS : 0), null); if ((mob.location().okMessage(mob, msg)) && (mob.location().okMessage(mob, msg2))) { mob.location().send(mob, msg); invoker = mob; int damage = 0; final int maxDie = (adjustedLevel(mob, asLevel) + (2 * super.getX1Level(mob))) / 2; damage += CMLib.dice().roll(maxDie, 6, 15); mob.location().send(mob, msg2); if ((msg2.value() > 0) || (msg.value() > 0)) damage = (int) Math.round(CMath.div(damage, 2.0)); if (target.location() == mob.location()) CMLib.combat() .postDamage( mob, target, this, damage, CMMsg.MASK_ALWAYS | CMMsg.TYP_COLD, Weapon.TYPE_FROSTING, L("The lance <DAMAGE> <T-NAME>!")); } } else return maliciousFizzle( mob, target, L("<S-NAME> incant(s) and point(s) at <T-NAMESELF>, but flub(s) the spell.")); // return whether it worked return success; }
@Override public void level(MOB mob, List<String> newAbilityIDs) { super.level(mob, newAbilityIDs); if (CMSecurity.isDisabled(CMSecurity.DisFlag.LEVELS)) return; final int attArmor = (((int) Math.round(CMath.div(mob.charStats().getStat(CharStats.STAT_DEXTERITY), 9.0))) + 1); mob.tell(L("^NYour grace grants you a defensive bonus of ^H@x1^?.^N", "" + attArmor)); }