@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; }
@Override public boolean invoke( MOB mob, List<String> commands, Physical givenTarget, boolean auto, int asLevel) { MOB target = null; Ability reAffect = null; if (mob.isInCombat()) { if (mob.rangeToTarget() > 0) { mob.tell(L("You are too far away to touch!")); return false; } final MOB victim = mob.getVictim(); reAffect = victim.fetchEffect("Undead_WeakEnergyDrain"); if (reAffect == null) reAffect = victim.fetchEffect("Undead_EnergyDrain"); if (reAffect != null) target = victim; } if (target == null) target = this.getTarget(mob, commands, givenTarget); if (target == null) return false; if (!super.invoke(mob, commands, givenTarget, auto, asLevel)) return false; boolean success = proficiencyCheck(mob, 0, auto); String str = null; if (success) { str = auto ? "" : L("^S<S-NAME> extend(s) an energy draining hand to <T-NAMESELF>!^?"); final CMMsg msg = CMClass.getMsg( mob, target, this, CMMsg.MSK_MALICIOUS_MOVE | CMMsg.TYP_UNDEAD | (auto ? CMMsg.MASK_ALWAYS : 0), str); if (mob.location().okMessage(mob, msg)) { mob.location().send(mob, msg); if (msg.value() <= 0) { mob.location().show(target, null, CMMsg.MSG_OK_VISUAL, L("<S-NAME> <S-IS-ARE> drained!")); if (reAffect != null) { if (reAffect instanceof Undead_EnergyDrain) ((Undead_EnergyDrain) reAffect).levelsDown++; ((StdAbility) reAffect) .setTickDownRemaining( ((StdAbility) reAffect).getTickDownRemaining() + mob.phyStats().level()); mob.recoverPhyStats(); mob.recoverCharStats(); mob.recoverMaxState(); } else { direction = 1; if (target.charStats().getMyRace().racialCategory().equalsIgnoreCase("Undead")) direction = -1; success = maliciousAffect(mob, target, asLevel, 0, -1) != null; } } } } else return maliciousFizzle( mob, target, L("<S-NAME> attempt(s) to drain <T-NAMESELF>, but fail(s).")); return success; }
@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()) return true; if (!changed) { if (mob.location() == null) return true; final Area A = mob.location().getArea(); if (((A.getTimeObj().getTODCode() == TimeClock.TimeOfDay.DUSK) || (A.getTimeObj().getTODCode() == TimeClock.TimeOfDay.NIGHT)) && (A.getTimeObj().getMoonPhase() == TimeClock.MoonPhase.FULL)) { changed = true; mob.location() .show( mob, null, CMMsg.MSG_OK_VISUAL, L("<S-NAME> turn(s) into a @x1!", lycanRace().name())); mob.recoverCharStats(); mob.recoverPhyStats(); mob.recoverMaxState(); mob.location().recoverRoomStats(); } } else { if (mob.location() == null) return true; final Area A = mob.location().getArea(); if (((A.getTimeObj().getTODCode() != TimeClock.TimeOfDay.DUSK) && (A.getTimeObj().getTODCode() != TimeClock.TimeOfDay.NIGHT)) || (A.getTimeObj().getMoonPhase() != TimeClock.MoonPhase.FULL)) { changed = false; mob.location().show(mob, null, CMMsg.MSG_OK_VISUAL, L("<S-NAME> revert(s) to normal.")); mob.recoverCharStats(); mob.recoverPhyStats(); mob.recoverMaxState(); mob.location().recoverRoomStats(); return true; } tickLycanthropically(mob); } return true; }
public void unAffectAffected(Object[] Os) { final CMObject O = (CMObject) Os[0]; final Physical P = affected; if (O instanceof Ability) { ((Ability) O).unInvoke(); ((Ability) O).destroy(); } affects.remove(Os); if (P != null) P.recoverPhyStats(); if (P instanceof MOB) { ((MOB) P).recoverCharStats(); ((MOB) P).recoverMaxState(); } }
@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 tick(Tickable ticking, int tickID) { if ((!built) && (affected instanceof MOB)) { built = true; CharClass C = null; final Vector allowedClasses = new Vector(); final Vector allowedExpertises = new Vector(); final Vector<String> V = CMParms.parse(text()); String s = null; for (int v = 0; v < V.size(); v++) { s = V.elementAt(v); if (s.equalsIgnoreCase("all")) continue; C = CMClass.getCharClass(s); if (C != null) { if ((v > 0) && (V.elementAt(v - 1).equalsIgnoreCase("ALL"))) { final String baseClass = C.baseClass(); for (final Enumeration c = CMClass.charClasses(); c.hasMoreElements(); ) { C = (CharClass) c.nextElement(); if ((C.baseClass().equalsIgnoreCase(baseClass)) && (!allowedClasses.contains(C))) allowedClasses.addElement(C); } } else allowedClasses.addElement(C); } else { final ExpertiseLibrary.ExpertiseDefinition def = CMLib.expertises().getDefinition(s); if (def != null) allowedExpertises.addElement(def); } } if (allowedClasses.size() == 0) for (final Enumeration c = CMClass.charClasses(); c.hasMoreElements(); ) allowedClasses.addElement(c.nextElement()); if (allowedExpertises.size() == 0) for (final Enumeration e = CMLib.expertises().definitions(); e.hasMoreElements(); ) allowedExpertises.addElement(e.nextElement()); final MOB mob = (MOB) affected; for (int c = 0; c < allowedClasses.size(); c++) { C = (CharClass) allowedClasses.elementAt(c); addCharClassIfNotFound(mob, C); } for (int e = 0; e < allowedExpertises.size(); e++) mob.addExpertise( ((ExpertiseLibrary.ExpertiseDefinition) allowedExpertises.elementAt(e)).ID); mob.recoverCharStats(); mob.recoverPhyStats(); mob.recoverMaxState(); } return super.tick(ticking, tickID); }
public void finishInit(CMObject A) { if (affected == null) return; if (A instanceof Ability) { ((Ability) A).makeNonUninvokable(); ((Ability) A).makeLongLasting(); ((Ability) A).setAffectedOne(affected); } if ((A instanceof Behavior) && (affected instanceof PhysicalAgent)) ((Behavior) A).startBehavior((PhysicalAgent) affected); if (affected != null) affected.recoverPhyStats(); if (affected instanceof MOB) { ((MOB) affected).recoverCharStats(); ((MOB) affected).recoverMaxState(); } initialized = true; }
@Override public boolean tick(Tickable ticking, int tickID) { if (!(affected instanceof MOB)) return super.tick(ticking, tickID); if (!super.tick(ticking, tickID)) return false; if ((--plagueDown) <= 0) { final MOB mob = (MOB) affected; plagueDown = 10; if (invoker == null) invoker = mob; drawups += .1; if (drawups >= 3.1) { if ((mob.location() != null) && (CMLib.flags().isInTheGame(mob, false))) { mob.location().show(mob, null, CMMsg.MSG_OK_VISUAL, L("<S-YOU-POSS> feet rot off!")); final Ability A = CMClass.getAbility("Amputation"); if (A != null) { int x = 100; while (((--x) > 0) && A.invoke(mob, CMParms.parse("foot"), mob, true, 0)) { /*do nothing */ } mob.recoverCharStats(); mob.recoverPhyStats(); mob.recoverMaxState(); } unInvoke(); } } else { final MOB invoker = (invoker() != null) ? invoker() : mob; CMLib.combat() .postDamage( invoker, mob, this, 1, CMMsg.TYP_DISEASE, -1, L( "<T-NAME> feel(s) the fungus between <T-HIS-HER> toes eating <T-HIS-HER> feet away!")); } } return true; }
protected static boolean tryMerge( MOB mob, Room room, Environmental E, List things, List<String> changes, List<String> onfields, List<String> ignore, boolean noisy) { boolean didAnything = false; final List<String> efields = new Vector(); List<String> allMyFields = new Vector(); final String[] EFIELDS = E.getStatCodes(); for (int i = 0; i < EFIELDS.length; i++) if (!efields.contains(EFIELDS[i])) efields.add(EFIELDS[i]); efields.add("REJUV"); allMyFields = new XVector<String>(efields); for (int v = 0; v < ignore.size(); v++) if (efields.contains(ignore.get(v))) efields.remove(ignore.get(v)); for (int v = 0; v < changes.size(); v++) if (efields.contains(changes.get(v))) efields.remove(changes.get(v)); if (noisy) mergedebugtell(mob, "AllMy-" + CMParms.toStringList(allMyFields)); if (noisy) mergedebugtell(mob, "efields-" + CMParms.toStringList(efields)); for (int t = 0; t < things.size(); t++) { final Environmental E2 = (Environmental) things.get(t); if (noisy) mergedebugtell( mob, E.name() + "/" + E2.name() + "/" + CMClass.classID(E) + "/" + CMClass.classID(E2)); if (CMClass.classID(E).equals(CMClass.classID(E2))) { Vector fieldsToCheck = null; if (onfields.size() > 0) { fieldsToCheck = new Vector(); for (int v = 0; v < onfields.size(); v++) if (efields.contains(onfields.get(v))) fieldsToCheck.add(onfields.get(v)); } else fieldsToCheck = new XVector<String>(efields); boolean checkedOut = fieldsToCheck.size() > 0; if (noisy) mergedebugtell(mob, "fieldsToCheck-" + CMParms.toStringList(fieldsToCheck)); if (checkedOut) for (int i = 0; i < fieldsToCheck.size(); i++) { final String field = (String) fieldsToCheck.get(i); if (noisy) mergedebugtell( mob, field + "/" + getStat(E, field) + "/" + getStat(E2, field) + "/" + getStat(E, field).equals(getStat(E2, field))); if (!getStat(E, field).equals(getStat(E2, field))) { checkedOut = false; break; } } if (checkedOut) { List<String> fieldsToChange = null; if (changes.size() == 0) fieldsToChange = new XVector<String>(allMyFields); else { fieldsToChange = new Vector(); for (int v = 0; v < changes.size(); v++) if (allMyFields.contains(changes.get(v))) fieldsToChange.add(changes.get(v)); } if (noisy) mergedebugtell(mob, "fieldsToChange-" + CMParms.toStringList(fieldsToChange)); for (int i = 0; i < fieldsToChange.size(); i++) { final String field = fieldsToChange.get(i); if (noisy) mergedebugtell( mob, E.name() + " wants to change " + field + " value " + getStat(E, field) + " to " + getStat(E2, field) + "/" + (!getStat(E, field).equals(getStat(E2, field)))); if (!getStat(E, field).equals(getStat(E2, field))) { setStat(E, field, getStat(E2, field)); Log.sysOut( "Merge", "The " + CMStrings.capitalizeAndLower(field) + " field on " + E.Name() + " in " + room.roomID() + " was changed to " + getStat(E2, field) + "."); didAnything = true; } } } } } if (didAnything) { if (E instanceof Physical) ((Physical) E).recoverPhyStats(); if (E instanceof MOB) { ((MOB) E).recoverCharStats(); ((MOB) E).recoverMaxState(); } E.text(); } return didAnything; }
@Override public boolean invoke( MOB mob, List<String> commands, Physical givenTarget, boolean auto, int asLevel) { final Physical target = getAnyTarget(mob, commands, givenTarget, Wearable.FILTER_UNWORNONLY); if (target == null) return false; if (target == mob) { mob.tell(L("@x1 doesn't look dead yet.", target.name(mob))); return false; } if (!(target instanceof DeadBody)) { mob.tell(L("You can't animate that.")); return false; } final DeadBody body = (DeadBody) target; if (body.isPlayerCorpse() || (body.getMobName().length() == 0) || ((body.charStats() != null) && (body.charStats().getMyRace() != null) && (body.charStats().getMyRace().racialCategory().equalsIgnoreCase("Undead")))) { mob.tell(L("You can't animate that.")); return false; } String race = "a"; if ((body.charStats() != null) && (body.charStats().getMyRace() != null)) race = CMLib.english().startWithAorAn(body.charStats().getMyRace().name()).toLowerCase(); String description = body.getMobDescription(); if (description.trim().length() == 0) description = "It looks dead."; else description += "\n\rIt also looks dead."; if (body.basePhyStats().level() < 7) { mob.tell(L("This creature is too weak to create a ghast from.")); 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("^S<S-NAME> @x1 to animate <T-NAMESELF> as a ghast.^?", prayForWord(mob))); if (mob.location().okMessage(mob, msg)) { mob.location().send(mob, msg); int undeadLevel = this.getUndeadLevel(mob, 6, body.phyStats().level()); final MOB newMOB = CMClass.getMOB("GenUndead"); newMOB.setName(L("@x1 ghast", race)); newMOB.setDescription(description); newMOB.setDisplayText(L("@x1 ghast is here", race)); newMOB.basePhyStats().setLevel(undeadLevel); newMOB .baseCharStats() .setStat(CharStats.STAT_GENDER, body.charStats().getStat(CharStats.STAT_GENDER)); newMOB.baseCharStats().setMyRace(CMClass.getRace("Undead")); newMOB .baseCharStats() .setBodyPartsFromStringAfterRace(body.charStats().getBodyPartsAsString()); final Ability P = CMClass.getAbility("Prop_StatTrainer"); if (P != null) { P.setMiscText("NOTEACH STR=20 INT=10 WIS=10 CON=10 DEX=15 CHA=2"); newMOB.addNonUninvokableEffect(P); } newMOB.recoverCharStats(); newMOB.basePhyStats().setAttackAdjustment(CMLib.leveler().getLevelAttack(newMOB)); newMOB.basePhyStats().setDamage(CMLib.leveler().getLevelMOBDamage(newMOB)); newMOB.basePhyStats().setSensesMask(PhyStats.CAN_SEE_DARK); CMLib.factions().setAlignment(newMOB, Faction.Align.EVIL); newMOB.baseState().setHitPoints(25 * newMOB.basePhyStats().level()); newMOB.baseState().setMovement(CMLib.leveler().getLevelMove(newMOB)); newMOB.basePhyStats().setArmor(CMLib.leveler().getLevelMOBArmor(newMOB)); newMOB.baseState().setMana(100); newMOB.recoverCharStats(); newMOB.recoverPhyStats(); newMOB.recoverMaxState(); newMOB.resetToMaxState(); newMOB.addAbility(CMClass.getAbility("Paralysis")); Behavior B = CMClass.getBehavior("CombatAbilities"); if (B != null) newMOB.addBehavior(B); B = CMClass.getBehavior("Aggressive"); if (B != null) { B.setParms("+NAMES \"-" + mob.Name() + "\" -LEVEL +>" + newMOB.basePhyStats().level()); newMOB.addBehavior(B); } newMOB.addNonUninvokableEffect(CMClass.getAbility("Spell_CauseStink")); newMOB.addNonUninvokableEffect(CMClass.getAbility("Prop_ModExperience")); newMOB.text(); newMOB.bringToLife(mob.location(), true); CMLib.beanCounter().clearZeroMoney(newMOB, null); // newMOB.location().showOthers(newMOB,null,CMMsg.MSG_OK_ACTION,L("<S-NAME> appears!")); int it = 0; while (it < newMOB.location().numItems()) { final Item item = newMOB.location().getItem(it); if ((item != null) && (item.container() == body)) { final CMMsg msg2 = CMClass.getMsg(newMOB, body, item, CMMsg.MSG_GET, null); newMOB.location().send(newMOB, msg2); final CMMsg msg4 = CMClass.getMsg(newMOB, item, null, CMMsg.MSG_GET, null); newMOB.location().send(newMOB, msg4); final CMMsg msg3 = CMClass.getMsg(newMOB, item, null, CMMsg.MSG_WEAR, null); newMOB.location().send(newMOB, msg3); if (!newMOB.isMine(item)) it++; else it = 0; } else it++; } body.destroy(); mob.location().show(newMOB, null, CMMsg.MSG_OK_ACTION, L("<S-NAME> begin(s) to rise!")); newMOB.setStartRoom(null); beneficialAffect(mob, newMOB, 0, 0); mob.location().recoverRoomStats(); } } else return beneficialWordsFizzle( mob, target, L("<S-NAME> @x1 to animate <T-NAMESELF>, but fail(s) miserably.", prayForWord(mob))); // return whether it worked return success; }