@Override public boolean tick(Tickable ticking, int tickID) { if (!(affected instanceof MOB)) return super.tick(ticking, tickID); final MOB mob = (MOB) affected; if (tickID != Tickable.TICKID_MOB) return true; if (!proficiencyCheck(null, 0, false)) return true; if ((!mob.isInCombat()) && (CMLib.flags().isSleeping(mob))) { roundsHibernating++; final double man = ((mob.charStats().getStat(CharStats.STAT_INTELLIGENCE) + mob.charStats().getStat(CharStats.STAT_WISDOM))); mob.curState() .adjMana( (int) Math.round( (man * .1) + ((mob.phyStats().level() + (2.0 * super.getXLEVELLevel(invoker()))) / 2.0)), mob.maxState()); mob.curState().setHunger(oldState.getHunger()); mob.curState().setThirst(oldState.getThirst()); final double move = mob.charStats().getStat(CharStats.STAT_STRENGTH); mob.curState() .adjMovement( (int) Math.round( (move * .1) + ((mob.phyStats().level() + (2.0 * super.getXLEVELLevel(invoker()))) / 2.0)), mob.maxState()); if (!CMLib.flags().isGolem(mob)) { final double hp = mob.charStats().getStat(CharStats.STAT_CONSTITUTION); if (!CMLib.combat() .postHealing( mob, mob, this, CMMsg.MASK_ALWAYS | CMMsg.TYP_CAST_SPELL, (int) Math.round( (hp * .1) + ((mob.phyStats().level() + (2.0 * super.getXLEVELLevel(invoker()))) / 2.0)), null)) unInvoke(); } } else { unInvoke(); return false; } return super.tick(ticking, tickID); }
@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))); }
@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 Trap makeADeprecatedTrap(Environmental unlockThis) { Trap theTrap = null; int roll = (int) Math.round(Math.random() * 100.0); if (unlockThis instanceof Exit) { if (((Exit) unlockThis).hasADoor()) { if (((Exit) unlockThis).hasALock()) { if (roll < 20) theTrap = (Trap) CMClass.getAbility("Trap_Open"); else if (roll < 80) theTrap = (Trap) CMClass.getAbility("Trap_Unlock"); else theTrap = (Trap) CMClass.getAbility("Trap_Enter"); } else { if (roll < 50) theTrap = (Trap) CMClass.getAbility("Trap_Open"); else theTrap = (Trap) CMClass.getAbility("Trap_Enter"); } } else theTrap = (Trap) CMClass.getAbility("Trap_Enter"); } else if (unlockThis instanceof Container) { if (((Container) unlockThis).hasALid()) { if (((Container) unlockThis).hasALock()) { if (roll < 20) theTrap = (Trap) CMClass.getAbility("Trap_Open"); else if (roll < 80) theTrap = (Trap) CMClass.getAbility("Trap_Unlock"); else theTrap = (Trap) CMClass.getAbility("Trap_Get"); } else { if (roll < 50) theTrap = (Trap) CMClass.getAbility("Trap_Open"); else theTrap = (Trap) CMClass.getAbility("Trap_Get"); } } else theTrap = (Trap) CMClass.getAbility("Trap_Get"); } else if (unlockThis instanceof Item) theTrap = (Trap) CMClass.getAbility("Trap_Get"); return theTrap; }
@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; }
protected String getDeviation(double val, double val2) { if (val == val2) return "0%"; final double oval = val2 - val; final int pval = (int) Math.round(CMath.div((oval < 0) ? (oval * -1) : oval, val2 == 0 ? 1 : val2) * 100.0); if (oval > 0) return "-" + pval + "%"; return "+" + pval + "%"; }
@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)); }
@Override public boolean invoke(MOB mob, Vector commands, Physical givenTarget, boolean auto, int asLevel) { Item target = null; if ((commands.size() == 0) && (!auto) && (givenTarget == null)) target = Prayer_Sacrifice.getBody(mob.location()); if (target == null) target = getTarget(mob, mob.location(), givenTarget, commands, Wearable.FILTER_UNWORNONLY); if (target == null) return false; if ((!(target instanceof DeadBody)) || (target.rawSecretIdentity().toUpperCase().indexOf("FAKE") >= 0)) { mob.tell(L("You may only desecrate the dead.")); return false; } if ((((DeadBody) target).isPlayerCorpse()) && (!((DeadBody) target).getMobName().equals(mob.Name())) && (((DeadBody) target).hasContent())) { mob.tell(L("You are not allowed to desecrate a players corpse.")); 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, target, this, verbalCastCode(mob, target, auto), auto ? L("<T-NAME> feel(s) desecrated!") : L("^S<S-NAME> desecrate(s) <T-NAMESELF> before @x1.^?", hisHerDiety(mob))); if (mob.location().okMessage(mob, msg)) { mob.location().send(mob, msg); if (CMLib.flags().isEvil(mob)) { double exp = 5.0; final int levelLimit = CMProps.getIntVar(CMProps.Int.EXPRATE); final int levelDiff = (mob.phyStats().level()) - target.phyStats().level(); if (levelDiff > levelLimit) exp = 0.0; if (exp > 0.0) CMLib.leveler() .postExperience( mob, null, null, (int) Math.round(exp) + super.getXPCOSTLevel(mob), false); } target.destroy(); mob.location().recoverRoomStats(); } } else beneficialWordsFizzle( mob, target, L("<S-NAME> attempt(s) to desecrate <T-NAMESELF>, but fail(s).")); // return whether it worked return success; }
@Override public void affectCharState(MOB affected, CharState affectableState) { super.affectCharState(affected, affectableState); if (affected == null) return; affectableState.setMovement( (int) Math.round( CMath.div( affectableState.getMovement(), drawups + (0.1 * super.getX1Level(invoker()))))); }
@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; Room R = CMLib.map().roomLocation(target); if (R == null) R = mob.location(); 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, somanticCastCode(mob, target, auto), L( auto ? "<T-NAME> <T-IS-ARE> sprayed with acid." : "^S<S-NAME> reach(es) for <T-NAMESELF>, spraying acid all over <T-HIM-HER>!^?") + CMLib.protocol().msp("spelldam1.wav", 40)); final CMMsg msg2 = CMClass.getMsg( mob, target, this, CMMsg.MSK_CAST_MALICIOUS_VERBAL | CMMsg.TYP_ACID | (auto ? CMMsg.MASK_ALWAYS : 0), null); if ((R.okMessage(mob, msg)) && ((R.okMessage(mob, msg2)))) { R.send(mob, msg); R.send(mob, msg2); invoker = mob; final int numDice = (adjustedLevel(mob, asLevel) + (2 * super.getX1Level(invoker()))) / 2; int damage = CMLib.dice().roll(2, numDice, 1); if ((msg2.value() > 0) || (msg.value() > 0)) damage = (int) Math.round(CMath.div(damage, 2.0)); CMLib.combat() .postDamage( mob, target, this, damage, CMMsg.MASK_ALWAYS | CMMsg.TYP_ACID, Weapon.TYPE_MELTING, L("The acid <DAMAGE> <T-NAME>!")); maliciousAffect(mob, target, asLevel, 3, -1); } } else return maliciousFizzle( mob, target, L("<S-NAME> reach(es) for <T-NAMESELF>, but nothing more happens.")); return success; }
@Override public void setRacialStat(final int abilityCode, final int racialMax) { if ((!CharStats.CODES.isBASE(abilityCode)) || (getStat(abilityCode) == VALUE_ALLSTATS_DEFAULT)) setPermanentStat(abilityCode, racialMax); else { final int baseMax = CMProps.getIntVar(CMProps.Int.BASEMAXSTAT); int currMax = getStat(CharStats.CODES.toMAXBASE(abilityCode)) + baseMax; if (currMax <= 0) currMax = 1; int curStat = getStat(abilityCode); if (curStat > currMax * 7) { final String errorMsg = "Detected mob with " + curStat + "/" + currMax + " " + CharStats.CODES.ABBR(abilityCode); @SuppressWarnings({"unchecked", "rawtypes"}) Set<String> errs = (Set) Resources.getResource("SYSTEM_DEFCHARSTATS_ERRORS"); if (errs == null) { errs = new TreeSet<String>(); Resources.submitResource("SYSTEM_DEFCHARSTATS_ERRORS", errs); } if (!errs.contains(errorMsg)) { errs.add(errorMsg); final StringBuilder str = new StringBuilder(errorMsg); // ByteArrayOutputStream stream=new ByteArrayOutputStream(); // new Exception().printStackTrace(new PrintStream(stream)); // str.append("\n\r"+new String(stream.toByteArray())); Log.errOut("DefCharStats", str.toString()); } curStat = currMax * 7; } final int pctOfMax = Math.round(((float) curStat / (float) currMax) * racialMax); final int stdMaxAdj = Math.round((((float) (currMax - VALUE_ALLSTATS_DEFAULT)) / (float) currMax) * racialMax); final int racialStat = pctOfMax + stdMaxAdj; setStat(abilityCode, ((racialStat < 1) && (racialMax > 0)) ? 1 : racialStat); setStat(CharStats.CODES.toMAXBASE(abilityCode), racialMax - baseMax); } }
@Override public boolean okMessage(Environmental host, CMMsg msg) { if (msg.amITarget(this)) { switch (msg.targetMinor()) { case CMMsg.TYP_ACTIVATE: if (!isInstalled()) { if (!CMath.bset(msg.targetMajor(), CMMsg.MASK_CNTRLMSG)) msg.source().tell(L("@x1 is not installed or connected.", name())); return false; } else if (!isAllWiringHot(this)) { if (!CMath.bset(msg.targetMajor(), CMMsg.MASK_CNTRLMSG)) msg.source() .tell(L("The panel containing @x1 is not activated or connected.", name())); return false; } break; case CMMsg.TYP_DEACTIVATE: break; case CMMsg.TYP_LOOK: break; case CMMsg.TYP_POWERCURRENT: if ((!(this instanceof FuelConsumer)) && (!(this instanceof PowerGenerator)) && activated() && (powerNeeds() > 0) && (msg.value() > 0)) { double amtToTake = Math.min((double) powerNeeds(), (double) msg.value()); msg.setValue(msg.value() - (int) Math.round(amtToTake)); amtToTake *= getFinalManufacturer().getEfficiencyPct(); if (subjectToWearAndTear() && (usesRemaining() <= 200)) amtToTake *= CMath.div(usesRemaining(), 100.0); setPowerRemaining(Math.min(powerCapacity(), Math.round(amtToTake) + powerRemaining())); } break; } } return super.okMessage(host, msg); }
@Override public void affectPhyStats(Physical affected, PhyStats affectableStats) { super.affectPhyStats(affected, affectableStats); if (affected instanceof MOB) { if (CMLib.flags().isStanding((MOB) affected)) { final MOB mob = (MOB) affected; final int attArmor = (((int) Math.round(CMath.div(mob.charStats().getStat(CharStats.STAT_DEXTERITY), 9.0))) + 1) * (mob.charStats().getClassLevel(this) - 1); affectableStats.setArmor(affectableStats.armor() - attArmor); } } }
public int getUndeadLevel(final MOB mob, double baseLvl, double corpseLevel) { final ExpertiseLibrary exLib = CMLib.expertises(); final double deathLoreExpertiseLevel = super.getXLEVELLevel(mob); final double appropriateLoreExpertiseLevel = super.getX1Level(mob); final double charLevel = mob.phyStats().level(); final double maxDeathLoreExpertiseLevel = exLib.getHighestListableStageBySkill(mob, ID(), ExpertiseLibrary.Flag.LEVEL); final double maxApproLoreExpertiseLevel = exLib.getHighestListableStageBySkill(mob, ID(), ExpertiseLibrary.Flag.X1); double lvl = (charLevel * appropriateLoreExpertiseLevel / maxApproLoreExpertiseLevel) - (baseLvl + 4 + (2 * maxDeathLoreExpertiseLevel)); if (lvl < 0.0) lvl = 0.0; lvl += baseLvl + (2 * deathLoreExpertiseLevel); if (lvl > corpseLevel) lvl = corpseLevel; return (int) Math.round(lvl); }
@Override public void setParms(String newParm) { super.setParms(newParm); rates.clear(); cut = 0.05; spaceMaxCut = 0.0; spaceMaxDistance = SpaceObject.Distance.GalaxyRadius.dm; newParm = newParm.toUpperCase(); int x = newParm.indexOf('='); while (x > 0) { int lastSp = newParm.lastIndexOf(' ', x); if (lastSp < 0) lastSp = 0; if ((lastSp >= 0) && (lastSp < x - 1) && (Character.isLetter(newParm.charAt(x - 1)))) { String parm = newParm.substring(lastSp, x).trim().toUpperCase(); while ((x < newParm.length()) && (newParm.charAt(x) != '=')) x++; if (x < newParm.length()) { while ((x < newParm.length()) && (!Character.isDigit(newParm.charAt(x))) && (newParm.charAt(x) != '.')) x++; if (x < newParm.length()) { newParm = newParm.substring(x); x = 0; while ((x < newParm.length()) && ((Character.isDigit(newParm.charAt(x))) || (newParm.charAt(x) == '.'))) x++; double val = CMath.s_double(newParm.substring(0, x)); if (newParm.substring(0, x).indexOf('.') < 0) val = CMath.s_long(newParm.substring(0, x)); if (x < newParm.length()) newParm = newParm.substring(x + 1); else newParm = ""; if (parm.equalsIgnoreCase("default")) parm = ""; if (parm.equalsIgnoreCase("spacemaxcut")) spaceMaxCut = val / 100.0; else if (parm.equalsIgnoreCase("spacemaxdistance")) spaceMaxDistance = Math.round(CMath.mul(SpaceObject.Distance.GalaxyRadius.dm, val / 100.0)); else if (parm.equalsIgnoreCase("cut")) cut = val / 100.0; else rates.put(parm, Double.valueOf(val / 100.0)); } } } x = newParm.indexOf('='); } }
@Override public boolean okMessage(final Environmental myHost, final CMMsg msg) { if (!super.okMessage(myHost, msg)) return false; if (!(affected instanceof MOB)) return true; final MOB mob = (MOB) affected; if ((msg.amITarget(mob)) && (msg.sourceMinor() == CMMsg.TYP_FIRE) && (msg.targetMinor() == CMMsg.TYP_DAMAGE)) { final int recovery = (int) Math.round(CMath.div((msg.value()), 2.0)); mob.location() .show( mob, null, CMMsg.MSG_OK_VISUAL, L("The flame attack heals <S-NAME> @x1 points.", "" + recovery)); CMLib.combat() .postHealing(mob, mob, this, recovery, CMMsg.MASK_ALWAYS | CMMsg.TYP_CAST_SPELL, null); return false; } return true; }
public StringBuffer deviations(MOB mob, String rest) { final Vector<String> V = CMParms.parse(rest); if ((V.size() == 0) || ((!V.get(0).equalsIgnoreCase("mobs")) && (!V.get(0).equalsIgnoreCase("items")) && (!V.get(0).equalsIgnoreCase("both")))) return new StringBuffer( "You must specify whether you want deviations on MOBS, ITEMS, or BOTH."); final String type = V.get(0).toLowerCase(); if (V.size() == 1) return new StringBuffer( "You must also specify a mob or item name, or the word room, or the word area."); final Room mobR = mob.location(); Faction useFaction = null; for (final Enumeration<Faction> e = CMLib.factions().factions(); e.hasMoreElements(); ) { final Faction F = e.nextElement(); if (F.showInSpecialReported()) useFaction = F; } final String where = V.get(1).toLowerCase(); final Environmental E = mobR.fetchFromMOBRoomFavorsItems(mob, null, where, Wearable.FILTER_ANY); final Vector<Environmental> check = new Vector<Environmental>(); if (where.equalsIgnoreCase("room")) fillCheckDeviations(mobR, type, check); else if (where.equalsIgnoreCase("area")) { for (final Enumeration<Room> r = mobR.getArea().getFilledCompleteMap(); r.hasMoreElements(); ) { final Room R = r.nextElement(); fillCheckDeviations(R, type, check); } } else if (where.equalsIgnoreCase("world")) { for (final Enumeration<Room> r = CMLib.map().roomsFilled(); r.hasMoreElements(); ) { final Room R = r.nextElement(); fillCheckDeviations(R, type, check); } } else if (E == null) return new StringBuffer("'" + where + "' is an unknown item or mob name."); else if (type.equals("items") && (!(E instanceof Weapon)) && (!(E instanceof Armor))) return new StringBuffer("'" + where + "' is not a weapon or armor item."); else if (type.equals("mobs") && (!(E instanceof MOB))) return new StringBuffer("'" + where + "' is not a MOB."); else if ((!(E instanceof Weapon)) && (!(E instanceof Armor)) && (!(E instanceof MOB))) return new StringBuffer("'" + where + "' is not a MOB, or Weapon, or Item."); else check.add(E); final StringBuffer str = new StringBuffer(""); str.append(L("Deviations Report:\n\r")); final StringBuffer itemResults = new StringBuffer(); final StringBuffer mobResults = new StringBuffer(); for (int c = 0; c < check.size(); c++) { if (check.get(c) instanceof Item) { final Item I = (Item) check.get(c); Weapon W = null; if (I instanceof Weapon) W = (Weapon) I; final Map<String, String> vals = CMLib.itemBuilder() .timsItemAdjustments( I, I.phyStats().level(), I.material(), I.rawLogicalAnd() ? 2 : 1, (W == null) ? 0 : W.weaponClassification(), I.maxRange(), I.rawProperLocationBitmap()); itemResults.append(CMStrings.padRight(I.name(), 20) + " "); itemResults.append(CMStrings.padRight(I.ID(), 10) + " "); itemResults.append(CMStrings.padRight("" + I.phyStats().level(), 4) + " "); itemResults.append( CMStrings.padRight( "" + getDeviation(I.basePhyStats().attackAdjustment(), vals, "ATTACK"), 5) + " "); itemResults.append( CMStrings.padRight("" + getDeviation(I.basePhyStats().damage(), vals, "DAMAGE"), 5) + " "); itemResults.append( CMStrings.padRight("" + getDeviation(I.basePhyStats().damage(), vals, "ARMOR"), 5) + " "); itemResults.append( CMStrings.padRight("" + getDeviation(I.baseGoldValue(), vals, "VALUE"), 5) + " "); itemResults.append( CMStrings.padRight( "" + ((I.phyStats().rejuv() == PhyStats.NO_REJUV) ? " MAX" : "" + I.phyStats().rejuv()), 5) + " "); if (I instanceof Weapon) itemResults.append(CMStrings.padRight("" + I.basePhyStats().weight(), 4)); else itemResults.append( CMStrings.padRight("" + getDeviation(I.basePhyStats().weight(), vals, "WEIGHT"), 4) + " "); if (I instanceof Armor) itemResults.append(CMStrings.padRight("" + ((Armor) I).phyStats().height(), 4)); else itemResults.append(CMStrings.padRight(" - ", 4) + " "); itemResults.append("\n\r"); } else { final MOB M = (MOB) check.get(c); mobResults.append(CMStrings.padRight(M.name(), 20) + " "); mobResults.append(CMStrings.padRight("" + M.phyStats().level(), 4) + " "); mobResults.append( CMStrings.padRight( "" + getDeviation( M.basePhyStats().attackAdjustment(), CMLib.leveler().getLevelAttack(M)), 5) + " "); mobResults.append( CMStrings.padRight( "" + getDeviation( M.basePhyStats().damage(), (int) Math.round( CMath.div( CMLib.leveler().getLevelMOBDamage(M), M.basePhyStats().speed()))), 5) + " "); mobResults.append( CMStrings.padRight( "" + getDeviation( M.basePhyStats().armor(), CMLib.leveler().getLevelMOBArmor(M)), 5) + " "); mobResults.append( CMStrings.padRight( "" + getDeviation( M.basePhyStats().speed(), CMLib.leveler().getLevelMOBSpeed(M)), 5) + " "); mobResults.append( CMStrings.padRight( "" + ((M.phyStats().rejuv() == PhyStats.NO_REJUV) ? " MAX" : "" + M.phyStats().rejuv()), 5) + " "); if (useFaction != null) mobResults.append( CMStrings.padRight( "" + (M.fetchFaction(useFaction.factionID()) == Integer.MAX_VALUE ? "N/A" : "" + M.fetchFaction(useFaction.factionID())), 7) + " "); double value = CMLib.beanCounter().getTotalAbsoluteNativeValue(M); double[] range = CMLib.leveler().getLevelMoneyRange(M); if (value < range[0]) mobResults.append(CMStrings.padRight("" + getDeviation(value, range[0]), 5) + " "); else if (value > range[1]) mobResults.append(CMStrings.padRight("" + getDeviation(value, range[1]), 5) + " "); else mobResults.append(CMStrings.padRight("0%", 5) + " "); int reallyWornCount = 0; for (int j = 0; j < M.numItems(); j++) { final Item Iw = M.getItem(j); if (!(Iw.amWearingAt(Wearable.IN_INVENTORY))) reallyWornCount++; } mobResults.append(CMStrings.padRight("" + reallyWornCount, 5) + " "); mobResults.append("\n\r"); } } if (itemResults.length() > 0) str.append(itemHeader() + itemResults.toString()); if (mobResults.length() > 0) str.append(mobHeader(useFaction) + mobResults.toString()); return str; }
public boolean resurrect(MOB tellMob, Room corpseRoom, DeadBody body, int XPLevel) { MOB rejuvedMOB = CMLib.players().getPlayer(((DeadBody) body).mobName()); if (rejuvedMOB != null) { rejuvedMOB.tell("You are being resurrected."); if (rejuvedMOB.location() != corpseRoom) { rejuvedMOB .location() .showOthers(rejuvedMOB, null, CMMsg.MSG_OK_VISUAL, "<S-NAME> disappears!"); corpseRoom.bringMobHere(rejuvedMOB, false); } Ability A = rejuvedMOB.fetchAbility("Prop_AstralSpirit"); if (A != null) rejuvedMOB.delAbility(A); A = rejuvedMOB.fetchEffect("Prop_AstralSpirit"); if (A != null) rejuvedMOB.delEffect(A); int it = 0; while (it < rejuvedMOB.location().numItems()) { Item item = rejuvedMOB.location().fetchItem(it); if ((item != null) && (item.container() == body)) { CMMsg msg2 = CMClass.getMsg(rejuvedMOB, body, item, CMMsg.MSG_GET, null); rejuvedMOB.location().send(rejuvedMOB, msg2); CMMsg msg3 = CMClass.getMsg(rejuvedMOB, item, null, CMMsg.MSG_GET, null); rejuvedMOB.location().send(rejuvedMOB, msg3); it = 0; } else it++; } body.delEffect(body.fetchEffect("Age")); // so misskids doesn't record it body.destroy(); rejuvedMOB .baseEnvStats() .setDisposition( CMath.unsetb(rejuvedMOB.baseEnvStats().disposition(), EnvStats.IS_SITTING)); rejuvedMOB .envStats() .setDisposition( CMath.unsetb(rejuvedMOB.baseEnvStats().disposition(), EnvStats.IS_SITTING)); rejuvedMOB.location().show(rejuvedMOB, null, CMMsg.MSG_NOISYMOVEMENT, "<S-NAME> get(s) up!"); corpseRoom.recoverRoomStats(); Vector whatsToDo = CMParms.parse(CMProps.getVar(CMProps.SYSTEM_PLAYERDEATH)); for (int w = 0; w < whatsToDo.size(); w++) { String whatToDo = (String) whatsToDo.elementAt(w); if (whatToDo.startsWith("UNL")) CMLib.leveler().level(rejuvedMOB); else if (whatToDo.startsWith("ASTR")) { } else if (whatToDo.startsWith("PUR")) { } else if ((whatToDo.trim().equals("0")) || (CMath.s_int(whatToDo) > 0)) { if (XPLevel >= 0) { int expLost = (CMath.s_int(whatToDo) + (2 * XPLevel)) / 2; rejuvedMOB.tell("^*You regain " + expLost + " experience points.^?^."); CMLib.leveler().postExperience(rejuvedMOB, null, null, expLost, false); } } else if (whatToDo.length() < 3) continue; else if (XPLevel >= 0) { double lvl = (double) body.envStats().level(); for (int l = body.envStats().level(); l < rejuvedMOB.envStats().level(); l++) lvl = lvl / 2.0; int expRestored = (int) Math.round(((100.0 + (2.0 * ((double) XPLevel))) * lvl) / 2.0); rejuvedMOB.tell("^*You regain " + expRestored + " experience points.^?^."); CMLib.leveler().postExperience(rejuvedMOB, null, null, expRestored, false); } } return true; } else corpseRoom.show( tellMob, body, CMMsg.MSG_OK_VISUAL, "<T-NAME> twitch(es) for a moment, but the spirit is too far gone."); return false; }
public static String getBasic(MOB M, int i) { StringBuffer str = new StringBuffer(""); switch (i) { case 0: str.append(M.Name() + ", "); break; case 1: str.append(M.description() + ", "); break; case 2: if (M.playerStats() != null) str.append(CMLib.time().date2String(M.playerStats().lastDateTime()) + ", "); break; case 3: if (M.playerStats() != null) str.append(M.playerStats().getEmail() + ", "); break; case 4: str.append(M.baseCharStats().getMyRace().name() + ", "); break; case 5: str.append( M.baseCharStats().getCurrentClass().name(M.baseCharStats().getCurrentClassLevel()) + ", "); break; case 6: str.append(M.baseEnvStats().level() + ", "); break; case 7: str.append(M.baseCharStats().displayClassLevel(M, true) + ", "); break; case 8: str.append(M.baseCharStats().getClassLevel(M.baseCharStats().getCurrentClass()) + ", "); break; case 9: { for (int c = M.charStats().numClasses() - 1; c >= 0; c--) { CharClass C = M.charStats().getMyClass(c); str.append( C.name(M.baseCharStats().getCurrentClassLevel()) + " (" + M.charStats().getClassLevel(C) + ") "); } str.append(", "); break; } case 10: if (M.maxCarry() > (Integer.MAX_VALUE / 3)) str.append("NA, "); else str.append(M.maxCarry() + ", "); break; case 11: str.append(CMStrings.capitalizeAndLower(CMLib.combat().fightingProwessStr(M)) + ", "); break; case 12: str.append(CMStrings.capitalizeAndLower(CMLib.combat().armorStr(M)) + ", "); break; case 13: str.append(CMLib.combat().adjustedDamage(M, null, null) + ", "); break; case 14: str.append(Math.round(CMath.div(M.getAgeHours(), 60.0)) + ", "); break; case 15: str.append(M.getPractices() + ", "); break; case 16: str.append(M.getExperience() + ", "); break; case 17: if (M.getExpNeededLevel() == Integer.MAX_VALUE) str.append("N/A, "); else str.append(M.getExpNextLevel() + ", "); break; case 18: str.append(M.getTrains() + ", "); break; case 19: str.append(CMLib.beanCounter().getMoney(M) + ", "); break; case 20: str.append(M.getWorshipCharID() + ", "); break; case 21: str.append(M.getLiegeID() + ", "); break; case 22: str.append(M.getClanID() + ", "); break; case 23: if (M.getClanID().length() > 0) { Clan C = CMLib.clans().getClan(M.getClanID()); if (C != null) str.append( CMLib.clans().getRoleName(C.getGovernment(), M.getClanRole(), true, false) + ", "); } break; case 24: str.append(M.fetchFaction(CMLib.factions().AlignID()) + ", "); break; case 25: { Faction.FactionRange FR = CMLib.factions() .getRange(CMLib.factions().AlignID(), M.fetchFaction(CMLib.factions().AlignID())); if (FR != null) str.append(FR.name() + ", "); else str.append(M.fetchFaction(CMLib.factions().AlignID())); break; } case 26: str.append(M.getWimpHitPoint() + ", "); break; case 27: if (M.getStartRoom() != null) str.append(M.getStartRoom().displayText() + ", "); break; case 28: if (M.location() != null) str.append(M.location().displayText() + ", "); break; case 29: if (M.getStartRoom() != null) str.append(M.getStartRoom().roomID() + ", "); break; case 30: if (M.location() != null) str.append(M.location().roomID() + ", "); break; case 31: { for (int inv = 0; inv < M.inventorySize(); inv++) { Item I = M.fetchInventory(inv); if ((I != null) && (I.container() == null)) str.append(I.name() + ", "); } break; } case 32: str.append(M.baseEnvStats().weight() + ", "); break; case 33: str.append(M.envStats().weight() + ", "); break; case 34: str.append(CMStrings.capitalizeAndLower(M.baseCharStats().genderName()) + ", "); break; case 35: if (M.playerStats() != null) str.append(M.playerStats().lastDateTime() + ", "); break; case 36: str.append(M.curState().getHitPoints() + ", "); break; case 37: str.append(M.curState().getMana() + ", "); break; case 38: str.append(M.curState().getMovement() + ", "); break; case 39: if (M.riding() != null) str.append(M.riding().name() + ", "); break; case 40: str.append(M.baseEnvStats().height() + ", "); break; case 41: if (!M.isMonster()) str.append(M.session().getAddress() + ", "); else if (M.playerStats() != null) str.append(M.playerStats().lastIP() + ", "); break; case 42: str.append(M.getQuestPoint() + ", "); break; case 43: str.append(M.maxState().getHitPoints() + ", "); break; case 44: str.append(M.maxState().getMana() + ", "); break; case 45: str.append(M.maxState().getMovement() + ", "); break; case 46: str.append(M.rawImage() + ", "); break; case 47: str.append(M.maxItems() + ", "); break; case 48: { String[] paths = CMProps.mxpImagePath(M.image()); if (paths[0].length() > 0) str.append(paths[0] + paths[1] + ", "); break; } case 49: if (CMProps.mxpImagePath(M.image())[0].length() > 0) str.append("true, "); else str.append("false, "); break; case 50: if (M.playerStats() != null) str.append(M.playerStats().notes() + ", "); break; case 51: if (M.playerStats() != null) { long lastDateTime = -1; for (int level = 0; level <= M.envStats().level(); level++) { long dateTime = M.playerStats().leveledDateTime(level); if ((dateTime > 1529122205) && (dateTime != lastDateTime)) { str.append("<TR>"); if (level == 0) str.append("<TD><FONT COLOR=WHITE>Created</FONT></TD>"); else str.append("<TD><FONT COLOR=WHITE>" + level + "</FONT></TD>"); str.append( "<TD><FONT COLOR=WHITE>" + CMLib.time().date2String(dateTime) + "</FONT></TD></TR>"); } } str.append(", "); } break; case 52: str.append(M.baseEnvStats().attackAdjustment() + ", "); break; case 53: str.append(M.baseEnvStats().damage() + ", "); break; case 54: str.append(M.baseEnvStats().armor() + ", "); break; case 55: str.append(M.envStats().speed() + ", "); break; case 56: str.append(M.baseEnvStats().speed() + ", "); break; case 57: { for (int e = 0; e < M.numExpertises(); e++) { String E = M.fetchExpertise(e); ExpertiseLibrary.ExpertiseDefinition X = CMLib.expertises().getDefinition(E); if (X == null) str.append(E + ", "); else str.append(X.name + ", "); } break; } case 58: { for (int t = 0; t < M.numTattoos(); t++) { String E = M.fetchTattoo(t); str.append(E + ", "); } break; } case 59: { if (M.playerStats() != null) for (int b = 0; b < M.playerStats().getSecurityGroups().size(); b++) { String B = (String) M.playerStats().getSecurityGroups().elementAt(b); if (B != null) str.append(B + ", "); } break; } case 60: { if (M.playerStats() != null) for (int b = 0; b < M.playerStats().getTitles().size(); b++) { String B = (String) M.playerStats().getTitles().elementAt(b); if (B != null) str.append(B + ", "); } break; } case 61: { for (Enumeration e = M.fetchFactions(); e.hasMoreElements(); ) { String FID = (String) e.nextElement(); Faction F = CMLib.factions().getFaction(FID); int value = M.fetchFaction(FID); if (F != null) str.append(F.name() + " (" + value + "), "); } break; } case 62: str.append(CMProps.getBoolVar(CMProps.SYSTEMB_ACCOUNTEXPIRATION) ? "true" : "false"); break; case 63: if (M.playerStats() != null) str.append(CMLib.time().date2String(M.playerStats().getAccountExpiration())); break; case 64: { for (int f = 0; f < M.numFollowers(); f++) str.append(M.fetchFollower(f).name()).append(", "); // Vector V=CMLib.database().DBScanFollowers(M); // for(int v=0;v<V.size();v++) // str.append(((MOB)V.elementAt(v)).name()).append(", "); break; } case 65: if ((M.playerStats() != null) && (M.playerStats().getAccount() != null)) str.append(M.playerStats().getAccount().accountName()); break; } return str.toString(); }
@Override public boolean invoke(MOB mob, Vector commands, Physical givenTarget, boolean auto, int asLevel) { final MOB mobTarget = getTarget(mob, commands, givenTarget, true, false); Item target = getPossibility(mobTarget); if (target == null) target = getTarget(mob, mob.location(), givenTarget, commands, Wearable.FILTER_ANY); if (target == null) return false; if (((target.material() & RawMaterial.MATERIAL_MASK) != RawMaterial.MATERIAL_WOODEN) || (!target.subjectToWearAndTear())) { mob.tell(L("That can't be warped.")); 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, target, this, verbalCastCode(mob, target, auto), auto ? L("<T-NAME> starts warping!") : L("^S<S-NAME> chant(s) at <T-NAMESELF>.^?")); final CMMsg msg2 = CMClass.getMsg(mob, mobTarget, this, verbalCastCode(mob, mobTarget, auto), null); if ((mob.location().okMessage(mob, msg)) && ((mobTarget == null) || (mob.location().okMessage(mob, msg2)))) { mob.location().send(mob, msg); if (mobTarget != null) mob.location().send(mob, msg2); if (msg.value() <= 0) { int damage = 100 + (mob.phyStats().level() + (2 * super.getXLEVELLevel(mob))) - target.phyStats().level(); if (CMLib.flags().isABonusItems(target)) damage = (int) Math.round(CMath.div(damage, 2.0)); target.setUsesRemaining(target.usesRemaining() - damage); if (mobTarget == null) mob.location() .show(mob, target, CMMsg.MSG_OK_VISUAL, L("<T-NAME> begin(s) to twist and warp!")); else mob.location() .show( mobTarget, target, CMMsg.MSG_OK_VISUAL, L("<T-NAME>, possessed by <S-NAME>, twists and warps!")); if (target.usesRemaining() > 0) target.recoverPhyStats(); else { target.setUsesRemaining(100); mob.location().show(mob, target, CMMsg.MSG_OK_VISUAL, L("<T-NAME> is destroyed!")); target.unWear(); target.destroy(); mob.location().recoverRoomStats(); } } } } else return maliciousFizzle(mob, null, L("<S-NAME> chant(s), but nothing happens.")); // return whether it worked return success; }
@Override public boolean tick(Tickable ticking, int tickID) { if (!super.tick(ticking, tickID)) return false; if (tickID != Tickable.TICKID_MOB) return true; if (affected == null) return false; if (--fallTickDown > 0) return true; fallTickDown = 1; int direction = Directions.DOWN; String addStr = L("down"); if (reversed()) { direction = Directions.UP; addStr = L("upwards"); } if (affected instanceof MOB) { final MOB mob = (MOB) affected; if (mob == null) return false; if (mob.location() == null) return false; if (CMLib.flags().isInFlight(mob)) { damageToTake = 0; unInvoke(); return false; } else if (!canFallFrom(mob.location(), direction)) return stopFalling(mob); else { if (mob.phyStats().weight() < 1) { mob.tell(L("\n\r\n\rYou are floating gently @x1.\n\r\n\r", addStr)); } else { mob.tell(L("\n\r\n\rYOU ARE FALLING @x1!!\n\r\n\r", addStr.toUpperCase())); int damage = CMLib.dice() .roll( 1, (int) Math.round( CMath.mul( CMath.mul(mob.maxState().getHitPoints(), 0.1), CMath.div(mob.baseWeight(), 150.0))), 0); if (damage > (mob.maxState().getHitPoints() / 3)) damage = (mob.maxState().getHitPoints() / 3); damageToTake = reversed() ? damage : (damageToTake + damage); } temporarilyDisable = true; CMLib.tracking().walk(mob, direction, false, false); temporarilyDisable = false; if (!canFallFrom(mob.location(), direction)) return stopFalling(mob); return true; } } else if (affected instanceof Item) { final Item item = (Item) affected; if ((room == null) && (item.owner() != null) && (item.owner() instanceof Room)) room = (Room) item.owner(); if ((room == null) || ((room != null) && (!room.isContent(item))) || (!CMLib.flags().isGettable(item)) || (item.container() != null) || (CMLib.flags().isInFlight(item.ultimateContainer(null))) || (room.getRoomInDir(direction) == null)) { unInvoke(); return false; } if (room.numItems() > 100) { fallTickDown = CMLib.dice().roll(1, room.numItems() / 50, 0); if ((--fallTickDown) > 0) return true; } final Room nextRoom = room.getRoomInDir(direction); if (canFallFrom(room, direction)) { room.show(invoker, null, item, CMMsg.MSG_OK_ACTION, L("<O-NAME> falls @x1.", addStr)); nextRoom.moveItemTo(item, ItemPossessor.Expire.Player_Drop); room = nextRoom; nextRoom.show( invoker, null, item, CMMsg.MSG_OK_ACTION, L("<O-NAME> falls in from @x1.", (reversed() ? "below" : "above"))); return true; } if (reversed()) return true; unInvoke(); return false; } return false; }
@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; }
public String builtPrompt(MOB mob) { StringBuffer buf = new StringBuffer("\n\r"); String prompt = mob.playerStats().getPrompt(); String promptUp = null; int c = 0; while (c < prompt.length()) if ((prompt.charAt(c) == '%') && (c < (prompt.length() - 1))) { switch (prompt.charAt(++c)) { case '-': if (c < (prompt.length() - 2)) { if (promptUp == null) promptUp = prompt.toUpperCase(); String promptSub = promptUp.substring(c + 1); Wearable.CODES wcodes = Wearable.CODES.instance(); boolean isFound = false; for (long code : wcodes.all()) if (promptSub.startsWith(wcodes.nameup(code))) { c += 1 + wcodes.nameup(code).length(); Item I = mob.fetchFirstWornItem(code); if (I != null) buf.append(I.name()); isFound = true; break; } if (!isFound) { CharStats.CODES ccodes = CharStats.CODES.instance(); for (int code : ccodes.all()) if (promptSub.startsWith(ccodes.name(code))) { c += 1 + ccodes.name(code).length(); buf.append(mob.charStats().getStat(code)); isFound = true; break; } if (!isFound) for (int code : ccodes.all()) if (promptSub.startsWith("BASE " + ccodes.name(code))) { buf.append(mob.baseCharStats().getStat(code)); c += 6 + ccodes.name(code).length(); isFound = true; break; } } if (!isFound) { for (String s : mob.envStats().getStatCodes()) if (promptSub.startsWith(s)) { c += 1 + s.length(); buf.append(mob.envStats().getStat(s)); isFound = true; break; } if (!isFound) for (String s : mob.baseEnvStats().getStatCodes()) if (promptSub.startsWith("BASE " + s)) { c += 6 + s.length(); buf.append(mob.baseEnvStats().getStat(s)); isFound = true; break; } } if (!isFound) { for (String s : mob.curState().getStatCodes()) if (promptSub.startsWith(s)) { c += 1 + s.length(); buf.append(mob.curState().getStat(s)); isFound = true; break; } if (!isFound) for (String s : mob.maxState().getStatCodes()) if (promptSub.startsWith("MAX " + s)) { c += 5 + s.length(); buf.append(mob.maxState().getStat(s)); isFound = true; break; } if (!isFound) for (String s : mob.baseState().getStatCodes()) if (promptSub.startsWith("BASE " + s)) { c += 6 + s.length(); buf.append(mob.baseState().getStat(s)); isFound = true; break; } } } break; case 'a': { buf.append( CMLib.factions() .getRangePercent( CMLib.factions().AlignID(), mob.fetchFaction(CMLib.factions().AlignID())) + "%"); c++; break; } case 'A': { Faction.FactionRange FR = CMLib.factions() .getRange( CMLib.factions().AlignID(), mob.fetchFaction(CMLib.factions().AlignID())); buf.append( (FR != null) ? FR.name() : "" + mob.fetchFaction(CMLib.factions().AlignID())); c++; break; } case 'B': { buf.append("\n\r"); c++; break; } case 'c': { buf.append(mob.inventorySize()); c++; break; } case 'C': { buf.append(mob.maxItems()); c++; break; } case 'd': { MOB victim = mob.getVictim(); if ((mob.isInCombat()) && (victim != null)) buf.append("" + mob.rangeToTarget()); c++; break; } case 'e': { MOB victim = mob.getVictim(); if ((mob.isInCombat()) && (victim != null) && (CMLib.flags().canBeSeenBy(victim, mob))) buf.append(victim.displayName(mob)); c++; break; } case 'E': { MOB victim = mob.getVictim(); if ((mob.isInCombat()) && (victim != null) && (!victim.amDead()) && (CMLib.flags().canBeSeenBy(victim, mob))) buf.append(victim.healthText(mob) + "\n\r"); c++; break; } case 'g': { buf.append( (int) Math.round( Math.floor( CMLib.beanCounter().getTotalAbsoluteNativeValue(mob) / CMLib.beanCounter() .getLowestDenomination( CMLib.beanCounter().getCurrency(mob))))); c++; break; } case 'G': { buf.append( CMLib.beanCounter() .nameCurrencyShort( mob, CMLib.beanCounter().getTotalAbsoluteNativeValue(mob))); c++; break; } case 'h': { buf.append("^<Hp^>" + mob.curState().getHitPoints() + "^</Hp^>"); c++; break; } case 'H': { buf.append("^<MaxHp^>" + mob.maxState().getHitPoints() + "^</MaxHp^>"); c++; break; } case 'I': { if ((CMLib.flags().isCloaked(mob)) && (((mob.envStats().disposition() & EnvStats.IS_NOT_SEEN) != 0))) buf.append("Wizinvisible"); else if (CMLib.flags().isCloaked(mob)) buf.append("Cloaked"); else if (!CMLib.flags().isSeen(mob)) buf.append("Undetectable"); else if (CMLib.flags().isInvisible(mob) && CMLib.flags().isHidden(mob)) buf.append("Hidden/Invisible"); else if (CMLib.flags().isInvisible(mob)) buf.append("Invisible"); else if (CMLib.flags().isHidden(mob)) buf.append("Hidden"); c++; break; } case 'K': case 'k': { MOB tank = mob; if ((tank.getVictim() != null) && (tank.getVictim().getVictim() != null) && (tank.getVictim().getVictim() != mob)) tank = tank.getVictim().getVictim(); if (((c + 1) < prompt.length()) && (tank != null)) switch (prompt.charAt(c + 1)) { case 'h': { buf.append(tank.curState().getHitPoints()); c++; break; } case 'H': { buf.append(tank.maxState().getHitPoints()); c++; break; } case 'm': { buf.append(tank.curState().getMana()); c++; break; } case 'M': { buf.append(tank.maxState().getMana()); c++; break; } case 'v': { buf.append(tank.curState().getMovement()); c++; break; } case 'V': { buf.append(tank.maxState().getMovement()); c++; break; } case 'e': { buf.append(tank.displayName(mob)); c++; break; } case 'E': { if ((mob.isInCombat()) && (CMLib.flags().canBeSeenBy(tank, mob))) buf.append(tank.healthText(mob) + "\n\r"); c++; break; } } c++; break; } case 'm': { buf.append("^<Mana^>" + mob.curState().getMana() + "^</Mana^>"); c++; break; } case 'M': { buf.append("^<MaxMana^>" + mob.maxState().getMana() + "^</MaxMana^>"); c++; break; } case 'r': { if (mob.location() != null) buf.append(mob.location().displayText()); c++; break; } case 'R': { if ((mob.location() != null) && CMSecurity.isAllowed(mob, mob.location(), "SYSMSGS")) buf.append(mob.location().roomID()); c++; break; } case 'v': { buf.append("^<Move^>" + mob.curState().getMovement() + "^</Move^>"); c++; break; } case 'V': { buf.append("^<MaxMove^>" + mob.maxState().getMovement() + "^</MaxMove^>"); c++; break; } case 'w': { buf.append(mob.envStats().weight()); c++; break; } case 'W': { buf.append(mob.maxCarry()); c++; break; } case 'x': { buf.append(mob.getExperience()); c++; break; } case 'X': { if (mob.getExpNeededLevel() == Integer.MAX_VALUE) buf.append("N/A"); else buf.append(mob.getExpNeededLevel()); c++; break; } case 'z': { if (mob.location() != null) buf.append(mob.location().getArea().name()); c++; break; } case 't': { if (mob.location() != null) buf.append( CMStrings.capitalizeAndLower( TimeClock.TOD_DESC[mob.location().getArea().getTimeObj().getTODCode()] .toLowerCase())); c++; break; } case 'T': { if (mob.location() != null) buf.append(mob.location().getArea().getTimeObj().getTimeOfDay()); c++; break; } case '@': { if (mob.location() != null) buf.append( mob.location().getArea().getClimateObj().weatherDescription(mob.location())); c++; break; } default: { buf.append("%" + prompt.charAt(c)); c++; break; } } } else buf.append(prompt.charAt(c++)); return buf.toString(); }
@Override public void executeMsg(Environmental host, CMMsg msg) { if (msg.amITarget(this)) { switch (msg.targetMinor()) { case CMMsg.TYP_ACTIVATE: if ((msg.source().location() != null) && (!CMath.bset(msg.targetMajor(), CMMsg.MASK_CNTRLMSG))) msg.source() .location() .show(msg.source(), this, CMMsg.MSG_OK_VISUAL, L("<S-NAME> activate(s) <T-NAME>.")); this.activate(true); break; case CMMsg.TYP_DEACTIVATE: if ((msg.source().location() != null) && (!CMath.bset(msg.targetMajor(), CMMsg.MASK_CNTRLMSG))) msg.source() .location() .show( msg.source(), this, CMMsg.MSG_OK_VISUAL, L("<S-NAME> deactivate(s) <T-NAME>.")); this.activate(false); break; case CMMsg.TYP_LOOK: super.executeMsg(host, msg); if (CMLib.flags().canBeSeenBy(this, msg.source())) msg.source() .tell( L( "@x1 is currently @x2", name(), (activated() ? "connected.\n\r" : "deactivated/disconnected.\n\r"))); return; case CMMsg.TYP_REPAIR: if (CMLib.dice().rollPercentage() < msg.value()) { setUsesRemaining(usesRemaining() < 100 ? 100 : usesRemaining()); msg.source().tell(L("@x1 is now repaired.\n\r", name())); } else { final int repairRequired = 100 - usesRemaining(); if (repairRequired > 0) { int repairApplied = (int) Math.round(CMath.mul(repairRequired, CMath.div(msg.value(), 100))); if (repairApplied < 0) repairApplied = 1; setUsesRemaining(usesRemaining() + repairApplied); msg.source().tell(L("@x1 is now @x2% repaired.\n\r", name(), "" + usesRemaining())); } } break; case CMMsg.TYP_ENHANCE: if ((CMLib.dice().rollPercentage() < msg.value()) && (CMLib.dice().rollPercentage() < 50)) { float addAmt = 0.01f; if (getInstalledFactor() < 1.0) { addAmt = (float) (CMath.div(100.0, msg.value()) * 0.1); if (addAmt < 0.1f) addAmt = 0.1f; } setInstalledFactor(this.getInstalledFactor() + addAmt); msg.source().tell(msg.source(), this, null, L("<T-NAME> is now enhanced.\n\r")); } else { msg.source() .tell( msg.source(), this, null, L("Your attempt to enhance <T-NAME> has failed.\n\r")); } break; } } super.executeMsg(host, msg); }
@Override public int getSave(int which) { switch (which) { case STAT_SAVE_PARALYSIS: return getStat(STAT_SAVE_PARALYSIS) + (int) Math.round(CMath.div(getStat(STAT_CONSTITUTION) + getStat(STAT_STRENGTH), 2.0)); case STAT_SAVE_FIRE: return getStat(STAT_SAVE_FIRE) + (int) Math.round(CMath.div(getStat(STAT_CONSTITUTION) + getStat(STAT_DEXTERITY), 2.0)); case STAT_SAVE_COLD: return getStat(STAT_SAVE_COLD) + (int) Math.round(CMath.div(getStat(STAT_CONSTITUTION) + getStat(STAT_DEXTERITY), 2.0)); case STAT_SAVE_WATER: return getStat(STAT_SAVE_WATER) + (int) Math.round(CMath.div(getStat(STAT_CONSTITUTION) + getStat(STAT_DEXTERITY), 2.0)); case STAT_SAVE_GAS: return getStat(STAT_SAVE_GAS) + (int) Math.round(CMath.div(getStat(STAT_CONSTITUTION) + getStat(STAT_STRENGTH), 2.0)); case STAT_SAVE_MIND: return getStat(STAT_SAVE_MIND) + (int) Math.round( CMath.div( getStat(STAT_WISDOM) + getStat(STAT_INTELLIGENCE) + getStat(STAT_CHARISMA), 3.0)); case STAT_SAVE_GENERAL: return getStat(STAT_SAVE_GENERAL) + getStat(STAT_CONSTITUTION); case STAT_SAVE_JUSTICE: return getStat(STAT_SAVE_JUSTICE) + getStat(STAT_CHARISMA); case STAT_SAVE_ACID: return getStat(STAT_SAVE_ACID) + (int) Math.round(CMath.div(getStat(STAT_CONSTITUTION) + getStat(STAT_DEXTERITY), 2.0)); case STAT_SAVE_ELECTRIC: return getStat(STAT_SAVE_ELECTRIC) + (int) Math.round(CMath.div(getStat(STAT_CONSTITUTION) + getStat(STAT_DEXTERITY), 2.0)); case STAT_SAVE_POISON: return getStat(STAT_SAVE_POISON) + getStat(STAT_CONSTITUTION); case STAT_SAVE_UNDEAD: return getStat(STAT_SAVE_UNDEAD) + getStat(STAT_WISDOM) + getStat(STAT_FAITH); case STAT_SAVE_DISEASE: return getStat(STAT_SAVE_DISEASE) + getStat(STAT_CONSTITUTION); case STAT_SAVE_MAGIC: return getStat(STAT_SAVE_MAGIC) + getStat(STAT_INTELLIGENCE); case STAT_SAVE_TRAPS: return getStat(STAT_SAVE_TRAPS) + getStat(STAT_DEXTERITY); case STAT_SAVE_OVERLOOKING: return getStat(STAT_SAVE_OVERLOOKING); case STAT_SAVE_DETECTION: return getStat(STAT_SAVE_DETECTION); case STAT_FAITH: return getStat(STAT_FAITH); case STAT_SAVE_BLUNT: return getStat(STAT_SAVE_BLUNT); case STAT_SAVE_PIERCE: return getStat(STAT_SAVE_PIERCE); case STAT_SAVE_SLASH: return getStat(STAT_SAVE_SLASH); case STAT_SAVE_SPELLS: return getStat(STAT_SAVE_SPELLS); case STAT_SAVE_PRAYERS: return getStat(STAT_SAVE_PRAYERS); case STAT_SAVE_SONGS: return getStat(STAT_SAVE_SONGS); case STAT_SAVE_CHANTS: return getStat(STAT_SAVE_CHANTS); } return getStat(which); }