@Override public boolean tick(Tickable ticking, int tickID) { if (!super.tick(ticking, tickID)) return false; if (affected == null) return false; if (!(affected instanceof MOB)) return true; final MOB mob = (MOB) affected; if ((!mob.amDead()) && ((--diseaseTick) <= 0)) { diseaseTick = DISEASE_DELAY(); if (mob.maxState().getFatigue() > Long.MIN_VALUE / 2) mob.curState() .adjFatigue(mob.curState().getFatigue() + CharState.FATIGUED_MILLIS, mob.maxState()); mob.location().show(mob, null, CMMsg.MSG_NOISE, DISEASE_AFFECT()); if (!CMLib.flags().isSleeping(mob)) { final Command C = CMClass.getCommand("Sleep"); try { if (C != null) C.execute(mob, CMParms.parse("Sleep"), Command.METAFLAG_FORCED); } catch (final Exception e) { } } return true; } return true; }
@Override public void executeMsg(final Environmental myHost, final CMMsg msg) { super.executeMsg(myHost, msg); if (msg.amITarget(this) && (msg.targetMinor() == CMMsg.TYP_DRINK)) { final MOB mob = msg.source(); final boolean thirsty = mob.curState().getThirst() <= 0; final boolean full = !mob.curState().adjThirst(thirstQuenched(), mob.maxState().maxThirst(mob.baseWeight())); if (thirsty) mob.tell(L("You are no longer thirsty.")); else if (full) mob.tell(L("You have drunk all you can.")); } else if ((msg.tool() == this) && (msg.targetMinor() == CMMsg.TYP_FILL) && (msg.target() instanceof Container) && (((Container) msg.target()).capacity() > 0)) { final Container container = (Container) msg.target(); final Item I = CMClass.getItem("GenLiquidResource"); I.setName(L("some milk")); I.setDisplayText(L("some milk has been left here.")); I.setDescription(L("It looks like milk")); I.setMaterial(RawMaterial.RESOURCE_MILK); I.setBaseValue(RawMaterial.CODES.VALUE(RawMaterial.RESOURCE_MILK)); I.basePhyStats().setWeight(1); CMLib.materials().addEffectsToResource(I); I.recoverPhyStats(); I.setContainer(container); if (container.owner() != null) if (container.owner() instanceof MOB) ((MOB) container.owner()).addItem(I); else if (container.owner() instanceof Room) ((Room) container.owner()).addItem(I, ItemPossessor.Expire.Resource); } }
@Override public void executeMsg(final Environmental myHost, final CMMsg msg) { if ((msg.amITarget(this) || (msg.targetMinor() == CMMsg.TYP_ADVANCE) || (msg.targetMinor() == CMMsg.TYP_RETREAT)) && (!msg.source().isMonster()) && (msg.source().curState().getHitPoints() < msg.source().maxState().getHitPoints()) && (CMLib.dice().rollPercentage() == 1) && (CMLib.dice().rollPercentage() == 1) && (!CMSecurity.isDisabled(CMSecurity.DisFlag.AUTODISEASE))) { Ability A = null; if (CMLib.dice().rollPercentage() > 50) A = CMClass.getAbility("Disease_Chlamydia"); else A = CMClass.getAbility("Disease_Malaria"); if ((A != null) && (msg.source().fetchEffect(A.ID()) == null)) A.invoke(msg.source(), msg.source(), true, 0); } if (msg.amITarget(this) && (msg.targetMinor() == CMMsg.TYP_DRINK)) { final MOB mob = msg.source(); final boolean thirsty = mob.curState().getThirst() <= 0; final boolean full = !mob.curState().adjThirst(thirstQuenched(), mob.maxState().maxThirst(mob.baseWeight())); if (thirsty) mob.tell(L("You are no longer thirsty.")); else if (full) mob.tell(L("You have drunk all you can.")); if (CMLib.dice().rollPercentage() < 10) { Ability A = CMClass.getAbility("Disease_Malaria"); if ((A != null) && (msg.source().fetchEffect(A.ID()) == null)) A.invoke(msg.source(), msg.source(), true, 0); } } super.executeMsg(myHost, msg); }
@Override public void affectCharState(MOB affectedMOB, CharState affectableState) { affectableState.setHitPoints(affectableState.getHitPoints() * 4); affectableState.setHunger((Integer.MAX_VALUE / 2) + 10); affectedMOB.curState().setHunger(affectableState.getHunger()); affectableState.setThirst((Integer.MAX_VALUE / 2) + 10); affectedMOB.curState().setThirst(affectableState.getThirst()); }
@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 unInvoke() { // undo the affects of this spell if (!(affected instanceof MOB)) return; final MOB mob = (MOB) affected; super.unInvoke(); if (canBeUninvoked()) { mob.tell(L("You feel less rallied.")); mob.recoverMaxState(); if (mob.curState().getHitPoints() > mob.maxState().getHitPoints()) mob.curState().setHitPoints(mob.maxState().getHitPoints()); } }
@Override public boolean invoke(MOB mob, Vector commands, Physical givenTarget, boolean auto, int asLevel) { final MOB target = getTarget(mob, commands, givenTarget); if (target == null) return false; if (!super.invoke(mob, commands, givenTarget, auto, asLevel)) return false; final boolean success = proficiencyCheck(mob, 0, auto); if (success) { invoker = mob; final CMMsg msg = CMClass.getMsg( mob, target, this, verbalCastCode(mob, target, auto), auto ? "" : L("^S<S-NAME> incant(s) to <T-NAMESELF>.^?")); if (mob.location().okMessage(mob, msg)) { mob.location().send(mob, msg); if (msg.value() <= 0) { target .curState() .adjThirst( -150 - ((mob.phyStats().level() + (2 * getXLEVELLevel(mob))) * 100), target.maxState().maxThirst(target.baseWeight())); mob.location() .show(target, null, CMMsg.MSG_OK_VISUAL, L("<S-NAME> feel(s) incredibly thirsty!")); } } } else return maliciousFizzle( mob, target, L("<S-NAME> incant(s) to <T-NAMESELF>, but the spell fades.")); // return whether it worked return success; }
@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); if (success) { final CMMsg msg = CMClass.getMsg( mob, null, this, CMMsg.MSG_SPEAK, auto ? "" : L("^S<S-NAME> scream(s) a mighty RALLYING CRY!!^?")); if (mob.location().okMessage(mob, msg)) { mob.location().send(mob, msg); final Set<MOB> h = properTargets(mob, givenTarget, auto); if (h == null) return false; for (final Object element : h) { final MOB target = (MOB) element; target.location().show(target, null, CMMsg.MSG_OK_VISUAL, L("<S-NAME> seem(s) rallied!")); timesTicking = 0; hpUp = mob.phyStats().level() + (2 * getXLEVELLevel(mob)); beneficialAffect(mob, target, asLevel, 0); target.recoverMaxState(); if (target.fetchEffect(ID()) != null) mob.curState().adjHitPoints(hpUp, mob.maxState()); } } } else beneficialWordsFizzle(mob, null, auto ? "" : L("<S-NAME> mumble(s) a weak rally cry.")); // return whether it worked return success; }
public static boolean useTheWand(Ability A, MOB mob, int level) { int manaRequired = 5; final int q = CMLib.ableMapper().qualifyingLevel(mob, A); if (q > 0) { if (q < CMLib.ableMapper().qualifyingClassLevel(mob, A)) manaRequired = 0; else manaRequired = 5; } else manaRequired = 25; manaRequired -= (2 * level); if (manaRequired < 5) manaRequired = 5; if (manaRequired > mob.curState().getMana()) { mob.tell(CMLib.lang().L("You don't have enough mana.")); return false; } mob.curState().adjMana(-manaRequired, mob.maxState()); return true; }
@Override public boolean invoke(MOB mob, Vector commands, Physical givenTarget, boolean auto, int asLevel) { if (mob.isInCombat()) { mob.tell(L("You can't hibernate while in combat!")); return false; } if (!CMLib.flags().isSitting(mob)) { mob.tell(L("You must be in a sitting, restful position to hibernate.")); return false; } // now see if it worked final boolean success = proficiencyCheck(mob, 0, auto); if (success) { invoker = mob; final CMMsg msg = CMClass.getMsg( mob, null, this, CMMsg.MSG_SLEEP | CMMsg.MASK_MAGIC, L("<S-NAME> begin(s) to hibernate...")); if (mob.location().okMessage(mob, msg)) { mob.location().send(mob, msg); oldState = mob.curState(); beneficialAffect(mob, mob, asLevel, Ability.TICKS_FOREVER); helpProficiency(mob, 0); } } else return beneficialVisualFizzle( mob, null, L("<S-NAME> chant(s) to hibernate, but lose(s) concentration.")); // return whether it worked return success; }
@Override public boolean okMessage(final Environmental myHost, final CMMsg msg) { if (!(myHost instanceof MOB)) return super.okMessage(myHost, msg); final MOB myChar = (MOB) myHost; if (msg.tool() instanceof Ability) { if (msg.amISource(myChar) && (!myChar.isMonster()) && (msg.sourceMinor() != CMMsg.TYP_PREINVOKE)) { final WeakReference<Ability> curRef = invokable; if ((curRef != null) && (msg.tool() == curRef.get())) { curRef.clear(); final Ability A = ((Ability) msg.tool()); final int[] usageCost = A.usageCost(myChar, false); if (CMath.bset(A.usageType(), Ability.USAGE_MANA)) myChar.curState().adjMana(usageCost[Ability.USAGEINDEX_MANA] / 4, myChar.maxState()); if (CMath.bset(A.usageType(), Ability.USAGE_MOVEMENT)) myChar .curState() .adjMovement(usageCost[Ability.USAGEINDEX_MOVEMENT] / 4, myChar.maxState()); if (CMath.bset(A.usageType(), Ability.USAGE_HITPOINTS)) myChar .curState() .adjHitPoints(usageCost[Ability.USAGEINDEX_HITPOINTS] / 4, myChar.maxState()); } } else if (msg.amITarget(myChar)) { if (((((Ability) msg.tool()).classificationCode() & Ability.ALL_ACODES) == Ability.ACODE_SPELL) && ((((Ability) msg.tool()).classificationCode() & Ability.ALL_DOMAINS) == Ability.DOMAIN_DIVINATION) && (CMLib.dice().roll(1, 100, 0) < (myChar.charStats().getClassLevel(this) * 4))) { myChar .location() .show( msg.source(), myChar, CMMsg.MSG_OK_ACTION, L( "<T-NAME> fool(s) <S-NAMESELF>, causing <S-HIM-HER> to fizzle @x1.", msg.tool().name())); return false; } } } return super.okMessage(myHost, msg); }
@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; final boolean success = proficiencyCheck(mob, 0, auto); if (success) { final CMMsg msg = CMClass.getMsg( mob, target, this, CMMsg.MASK_MALICIOUS | verbalCastCode(mob, target, auto), L( auto ? "A light fatigue overcomes <T-NAME>." : "^S<S-NAME> " + prayWord(mob) + " for extreme fatigue to overcome <T-NAMESELF>!^?")); if (mob.location().okMessage(mob, msg)) { mob.location().send(mob, msg); if (msg.value() <= 0) { final int harming = CMLib.dice().roll(10, adjustedLevel(mob, asLevel), 50); if ((target.curState().getFatigue() <= CharState.FATIGUED_MILLIS) && (target.maxState().getFatigue() > Long.MIN_VALUE / 2)) target.curState().setFatigue(CharState.FATIGUED_MILLIS + 1); target.curState().adjMovement(-harming, target.maxState()); target.tell(L("You feel fatigued!")); } } } else return maliciousFizzle( mob, target, L("<S-NAME> point(s) at <T-NAMESELF> and @x1, but nothing happens.", prayWord(mob))); // return whether it worked return success; }
@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; final boolean success = proficiencyCheck(mob, 0, auto); if (success) { final CMMsg msg = CMClass.getMsg( mob, target, this, verbalCastCode(mob, target, auto), auto ? L("A bright yellow glow surrounds <T-NAME>.") : L( "^S<S-NAME> @x1, delivering a strong touch of infusion to <T-NAMESELF>.^?", prayWord(mob))); if (mob.location().okMessage(mob, msg)) { mob.location().send(mob, msg); target.curState().setMana(target.maxState().getMana()); target.curState().setHitPoints(target.maxState().getHitPoints()); target.curState().setMana(target.maxState().getMana()); target.curState().setMovement(target.maxState().getMovement()); target.curState().setFatigue(0); target.curState().setHunger(target.maxState().getHunger()); target.curState().setThirst(target.maxState().getThirst()); target.tell(L("You feel refreshed!")); lastCastHelp = System.currentTimeMillis(); } } else beneficialWordsFizzle( mob, target, auto ? "" : L("<S-NAME> @x1 for <T-NAMESELF>, but nothing happens.", prayWord(mob))); // return whether it worked return success; }
@Override public boolean invoke( MOB mob, List<String> 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; final boolean success = proficiencyCheck(mob, 0, auto); if (success) { final CMMsg msg = CMClass.getMsg( mob, target, this, somanticCastCode(mob, target, auto), L(auto ? "" : "^S<S-NAME> point(s) at <T-NAMESELF> and shout(s)!^?")); if (mob.location().okMessage(mob, msg)) { mob.location().send(mob, msg); invoker = mob; if (msg.value() > 0) { target .location() .show(target, null, CMMsg.MSG_OK_VISUAL, L("<T-NAME> become(s) exhausted!")); target.curState().setMovement(0); if (target.maxState().getFatigue() > Long.MIN_VALUE / 2) target .curState() .setFatigue(target.curState().getFatigue() + CharState.FATIGUED_MILLIS); } } } else return maliciousFizzle( mob, target, L("<S-NAME> point(s) and shout(s) at <T-NAMESELF>, but nothing more happens.")); return success; }
public void affectCharState(MOB mob, CharState state) { super.affectCharState(mob, state); if (mob.baseCharStats().getCurrentClass().ID().equals(ID())) { Ability A = null; for (int a = 0; a < mob.numLearnedAbilities(); a++) { A = mob.fetchAbility(a); if ((A != null) && ((A.classificationCode() & Ability.ALL_ACODES) == Ability.ACODE_SPELL) && (!CMLib.ableMapper().getDefaultGain(ID(), false, A.ID()))) { int[] cost = A.usageCost(mob, true); int manaCost = cost[Ability.USAGEINDEX_MANA]; if (manaCost > 0) { if (state.getMana() < manaCost) { mob.delAbility(A); a--; } else state.setMana(state.getMana() - manaCost); } } } if (mob.curState().getMana() > state.getMana()) mob.curState().setMana(state.getMana()); } }
@Override public String healthText(MOB viewer, MOB mob) { final double pct = (CMath.div(mob.curState().getHitPoints(), mob.maxState().getHitPoints())); if (pct < .10) return L("^r@x1^r is almost broken!^N", mob.name(viewer)); else if (pct < .20) return L("^r@x1^r is massively cracked and damaged.^N", mob.name(viewer)); else if (pct < .30) return L("^r@x1^r is extremely cracked and damaged.^N", mob.name(viewer)); else if (pct < .40) return L("^y@x1^y is very cracked and damaged.^N", mob.name(viewer)); else if (pct < .50) return L("^y@x1^y is cracked and damaged.^N", mob.name(viewer)); else if (pct < .60) return L("^p@x1^p is cracked and slightly damaged.^N", mob.name(viewer)); else if (pct < .70) return L("^p@x1^p is showing numerous cracks.^N", mob.name(viewer)); else if (pct < .80) return L("^g@x1^g is showing some crachs.^N", mob.name(viewer)); else if (pct < .90) return L("^g@x1^g is showing small cracks.^N", mob.name(viewer)); else if (pct < .99) return L("^g@x1^g is no longer in perfect condition.^N", mob.name(viewer)); else return L("^c@x1^c is in perfect condition.^N", mob.name(viewer)); }
@Override public String healthText(MOB viewer, MOB mob) { final double pct = (CMath.div(mob.curState().getHitPoints(), mob.maxState().getHitPoints())); if (pct < .10) return L("^r@x1^r is near destruction!^N", mob.name(viewer)); else if (pct < .20) return L("^r@x1^r is massively shredded and damaged.^N", mob.name(viewer)); else if (pct < .30) return L("^r@x1^r is extremely shredded and damaged.^N", mob.name(viewer)); else if (pct < .40) return L("^y@x1^y is very shredded and damaged.^N", mob.name(viewer)); else if (pct < .50) return L("^y@x1^y is shredded and damaged.^N", mob.name(viewer)); else if (pct < .60) return L("^p@x1^p is shredded and slightly damaged.^N", mob.name(viewer)); else if (pct < .70) return L("^p@x1^p has lost numerous leaves.^N", mob.name(viewer)); else if (pct < .80) return L("^g@x1^g has lost some leaves.^N", mob.name(viewer)); else if (pct < .90) return L("^g@x1^g has lost a few leaves.^N", mob.name(viewer)); else if (pct < .99) return L("^g@x1^g is no longer in perfect condition.^N", mob.name(viewer)); else return L("^c@x1^c is in perfect condition.^N", mob.name(viewer)); }
@Override public String healthText(MOB viewer, MOB mob) { final double pct = (CMath.div(mob.curState().getHitPoints(), mob.maxState().getHitPoints())); if (pct < .10) return L("^r@x1^r is unstable and almost disintegrated!^N", mob.name(viewer)); else if (pct < .20) return L("^r@x1^r is nearing disintegration.^N", mob.name(viewer)); else if (pct < .30) return L("^r@x1^r is noticeably disintegrating.^N", mob.name(viewer)); else if (pct < .40) return L("^y@x1^y is very damaged and slightly disintegrated.^N", mob.name(viewer)); else if (pct < .50) return L("^y@x1^y is very damaged.^N", mob.name(viewer)); else if (pct < .60) return L("^p@x1^p is starting to show major damage.^N", mob.name(viewer)); else if (pct < .70) return L("^p@x1^p is definitely damaged.^N", mob.name(viewer)); else if (pct < .80) return L("^g@x1^g is disheveled and mildly damaged.^N", mob.name(viewer)); else if (pct < .90) return L("^g@x1^g is noticeably disheveled.^N", mob.name(viewer)); else if (pct < .99) return L("^g@x1^g is slightly disheveled.^N", mob.name(viewer)); else return L("^c@x1^c is in perfect condition.^N", mob.name(viewer)); }
@Override public String healthText(MOB viewer, MOB mob) { final double pct = (CMath.div(mob.curState().getHitPoints(), mob.maxState().getHitPoints())); if (pct < .10) return L("^r@x1^r is nearly defeated.^N", mob.name(viewer)); else if (pct < .20) return L("^r@x1^r is covered in blood.^N", mob.name(viewer)); else if (pct < .30) return L("^r@x1^r is bleeding badly from lots of wounds.^N", mob.name(viewer)); else if (pct < .40) return L("^y@x1^y has numerous bloody wounds and gashes.^N", mob.name(viewer)); else if (pct < .50) return L("^y@x1^y has some bloody wounds and gashes.^N", mob.name(viewer)); else if (pct < .60) return L("^p@x1^p has a few bloody wounds.^N", mob.name(viewer)); else if (pct < .70) return L("^p@x1^p is cut and bruised.^N", mob.name(viewer)); else if (pct < .80) return L("^g@x1^g has some minor cuts and bruises.^N", mob.name(viewer)); else if (pct < .90) return L("^g@x1^g has a few bruises and scratches.^N", mob.name(viewer)); else if (pct < .99) return L("^g@x1^g has a few small bruises.^N", mob.name(viewer)); else return L("^c@x1^c is in perfect health.^N", mob.name(viewer)); }
public String healthText(MOB viewer, MOB mob) { double pct = (CMath.div(mob.curState().getHitPoints(), mob.maxState().getHitPoints())); if (pct < .10) return "^r" + mob.displayName(viewer) + "^r is hovering on deaths door!^N"; else if (pct < .20) return "^r" + mob.displayName(viewer) + "^r is covered in blood and matted hair.^N"; else if (pct < .30) return "^r" + mob.displayName(viewer) + "^r is bleeding badly from lots of wounds.^N"; else if (pct < .40) return "^y" + mob.displayName(viewer) + "^y has large patches of bloody matted fur.^N"; else if (pct < .50) return "^y" + mob.displayName(viewer) + "^y has some bloody matted fur.^N"; else if (pct < .60) return "^p" + mob.displayName(viewer) + "^p has a lot of cuts and gashes.^N"; else if (pct < .70) return "^p" + mob.displayName(viewer) + "^p has a few cut patches.^N"; else if (pct < .80) return "^g" + mob.displayName(viewer) + "^g has a cut patch of fur.^N"; else if (pct < .90) return "^g" + mob.displayName(viewer) + "^g has some disheveled fur.^N"; else if (pct < .99) return "^g" + mob.displayName(viewer) + "^g has some misplaced hairs.^N"; else return "^c" + mob.displayName(viewer) + "^c is in perfect health.^N"; }
@Override public String healthText(MOB viewer, MOB mob) { final double pct = (CMath.div(mob.curState().getHitPoints(), mob.maxState().getHitPoints())); if (pct < .10) return L("^r@x1^r is one unhappy little critter!^N", mob.name(viewer)); else if (pct < .20) return L("^r@x1^r is covered in blood and matted hair.^N", mob.name(viewer)); else if (pct < .30) return L("^r@x1^r is bleeding badly from lots of wounds.^N", mob.name(viewer)); else if (pct < .40) return L("^y@x1^y has large patches of bloody matted fur.^N", mob.name(viewer)); else if (pct < .50) return L("^y@x1^y has some bloody matted fur.^N", mob.name(viewer)); else if (pct < .60) return L("^p@x1^p has a lot of cuts and gashes.^N", mob.name(viewer)); else if (pct < .70) return L("^p@x1^p has a few cut patches.^N", mob.name(viewer)); else if (pct < .80) return L("^g@x1^g has a cut patch of fur.^N", mob.name(viewer)); else if (pct < .90) return L("^g@x1^g has some disheveled fur.^N", mob.name(viewer)); else if (pct < .99) return L("^g@x1^g has some misplaced hairs.^N", mob.name(viewer)); else return L("^c@x1^c is in perfect health.^N", mob.name(viewer)); }
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 boolean invoke(MOB mob, Vector commands, Physical givenTarget, boolean auto, int asLevel) { boolean announce = false; if (commands.size() > 0) { if (((String) commands.lastElement()).equals("!")) { commands.removeElementAt(commands.size() - 1); announce = true; } } final MOB target = getTargetAnywhere(mob, commands, givenTarget, true); if (target == null) 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, CMMsg.MASK_MOVE | CMMsg.TYP_JUSTICE | (auto ? CMMsg.MASK_ALWAYS : 0), auto ? L("<T-NAME> <T-IS-ARE> knocked out of <T-HIS-HER> shoes!!!") : L( "^F**<S-NAME> BLAST(S) <T-NAMESELF>**, knocking <T-HIM-HER> out of <T-HIS-HER> shoes!!^?")); CMLib.color().fixSourceFightColor(msg); if (target.location().okMessage(mob, msg)) { target.location().send(mob, msg); if (target.curState().getHitPoints() > 2) target.curState().setHitPoints(target.curState().getHitPoints() / 2); if (target.curState().getMana() > 2) target.curState().setMana(target.curState().getMana() / 2); if (target.curState().getMovement() > 2) target.curState().setMovement(target.curState().getMovement() / 2); final Item I = target.fetchFirstWornItem(Wearable.WORN_FEET); if (I != null) { I.unWear(); I.removeFromOwnerContainer(); target.location().addItem(I, ItemPossessor.Expire.Player_Drop); } Log.sysOut("Banish", mob.Name() + " wrathed " + target.name() + "."); if (announce) { final Command C = CMClass.getCommand("Announce"); try { C.execute( mob, new XVector( "ANNOUNCE", target.name() + " is knocked out of " + target.charStats().hisher() + " shoes!!!"), Command.METAFLAG_FORCED); } catch (final Exception e) { } } } } else return beneficialVisualFizzle( mob, target, L("<S-NAME> attempt(s) to inflict <S-HIS-HER> wrath upon <T-NAMESELF>, but fail(s).")); return success; }
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, List<String> commands, Physical givenTarget, boolean auto, int asLevel) { final MOB target = super.getTarget(mob, commands, givenTarget); if (target == null) return false; final Race R = target.charStats().getMyRace(); if (R.bodyMask()[Race.BODY_HEAD] <= 0) { mob.tell(L("@x1 has no head!", target.name(mob))); return false; } LegalBehavior B = null; if (mob.location() != null) B = CMLib.law().getLegalBehavior(mob.location()); List<LegalWarrant> warrants = new Vector<LegalWarrant>(); if (B != null) warrants = B.getWarrantsOf(CMLib.law().getLegalObject(mob.location()), target); if ((warrants.size() == 0) && (!CMSecurity.isAllowed(mob, mob.location(), CMSecurity.SecFlag.ABOVELAW))) { mob.tell(L("You are not allowed to behead @x1 at this time.", target.Name())); return false; } final Item w = mob.fetchWieldedItem(); Weapon ww = null; if ((w == null) || (!(w instanceof Weapon))) { mob.tell(L("You cannot behead without a weapon!")); return false; } ww = (Weapon) w; if ((!auto) && (!CMSecurity.isASysOp(mob))) { if (ww.weaponDamageType() != Weapon.TYPE_SLASHING) { mob.tell(L("You cannot behead with a @x1!", ww.name())); return false; } if (mob.isInCombat() && (mob.rangeToTarget() > 0)) { mob.tell(L("You are too far away to try that!")); return false; } if (!CMLib.flags().isBoundOrHeld(target)) { mob.tell(L("@x1 is not bound and would resist.", target.charStats().HeShe())); return false; } } if (!super.invoke(mob, commands, givenTarget, auto, asLevel)) return false; int levelDiff = target.phyStats().level() - (mob.phyStats().level() + (2 * getXLEVELLevel(mob))); if (levelDiff > 0) levelDiff = levelDiff * 3; else levelDiff = 0; final boolean hit = (auto) || CMLib.combat().rollToHit(mob, target); boolean success = proficiencyCheck(mob, 0, auto) && (hit); if (success) { final CMMsg msg = CMClass.getMsg( mob, target, this, CMMsg.MASK_MALICIOUS | CMMsg.MASK_MOVE | CMMsg.MASK_SOUND | CMMsg.TYP_JUSTICE | (auto ? CMMsg.MASK_ALWAYS : 0), null); if (mob.location().okMessage(mob, msg)) { mob.location().send(mob, msg); target.curState().setHitPoints(1); final Ability A2 = target.fetchEffect("Injury"); if (A2 != null) A2.setMiscText(mob.Name() + "/head"); CMLib.combat() .postDamage( mob, target, ww, Integer.MAX_VALUE / 2, CMMsg.MSG_WEAPONATTACK, ww.weaponClassification(), auto ? "" : L( "^F^<FIGHT^><S-NAME> rear(s) back and behead(s) <T-NAME>!^</FIGHT^>^?@x1", CMLib.protocol().msp("decap.wav", 30))); mob.location().recoverRoomStats(); final Item limb = CMClass.getItem("GenLimb"); limb.setName(L("@x1`s head", target.Name())); limb.basePhyStats().setAbility(1); limb.setDisplayText(L("the bloody head of @x1 is sitting here.", target.Name())); limb.setSecretIdentity(target.name() + "`s bloody head."); int material = RawMaterial.RESOURCE_MEAT; for (int r = 0; r < R.myResources().size(); r++) { final Item I = R.myResources().get(r); final int mat = I.material() & RawMaterial.MATERIAL_MASK; if (((mat == RawMaterial.MATERIAL_FLESH)) || (r == R.myResources().size() - 1)) { material = I.material(); break; } } limb.setMaterial(material); limb.basePhyStats().setLevel(1); limb.basePhyStats().setWeight(5); limb.recoverPhyStats(); mob.location().addItem(limb, ItemPossessor.Expire.Player_Drop); for (int i = 0; i < warrants.size(); i++) { final LegalWarrant W = warrants.get(i); W.setCrime("pardoned"); W.setOffenses(0); } } else success = false; if (mob.getVictim() == target) mob.makePeace(true); if (target.getVictim() == mob) target.makePeace(true); } else maliciousFizzle(mob, target, L("<S-NAME> attempt(s) a beheading and fail(s)!")); return success; }