@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; }
public void executeMsg(Environmental myHost, CMMsg msg) { super.executeMsg(myHost, msg); if ((myHost == null) || (!(myHost instanceof MOB))) return; MOB mob = (MOB) myHost; if (msg.amISource(mob) && (msg.tool() != null)) { if (msg.tool() instanceof Ability) { Ability A = mob.fetchAbility(msg.tool().ID()); if ((A != null) && (!CMLib.ableMapper().getDefaultGain(ID(), false, A.ID())) && ((A.classificationCode() & Ability.ALL_ACODES) == Ability.ACODE_SPELL)) { mob.delAbility(A); mob.recoverMaxState(); } } else if (msg.tool().ID().equalsIgnoreCase("Skill_ScrollCopy")) { } } }
public void confirmWearability(MOB mob) { if (mob == null) return; Race R = mob.charStats().getMyRace(); DVector reWearSet = new DVector(2); Item item = null; for (int i = 0; i < mob.inventorySize(); i++) { item = mob.fetchInventory(i); if ((item != null) && (!item.amWearingAt(Wearable.IN_INVENTORY))) { Long oldCode = Long.valueOf(item.rawWornCode()); item.unWear(); if (reWearSet.size() == 0) reWearSet.addElement(item, oldCode); else { short layer = (item instanceof Armor) ? ((Armor) item).getClothingLayer() : 0; int d = 0; for (; d < reWearSet.size(); d++) if (reWearSet.elementAt(d, 1) instanceof Armor) { if (((Armor) reWearSet.elementAt(d, 1)).getClothingLayer() > layer) break; } else if (0 > layer) break; if (d >= reWearSet.size()) reWearSet.addElement(item, oldCode); else reWearSet.insertElementAt(d, item, oldCode); } } } for (int r = 0; r < reWearSet.size(); r++) { item = (Item) reWearSet.elementAt(r, 1); long oldCode = ((Long) reWearSet.elementAt(r, 2)).longValue(); int msgCode = CMMsg.MSG_WEAR; if ((oldCode & Wearable.WORN_WIELD) > 0) msgCode = CMMsg.MSG_WIELD; else if ((oldCode & Wearable.WORN_HELD) > 0) msgCode = CMMsg.MSG_HOLD; CMMsg msg = CMClass.getMsg( mob, item, null, CMMsg.NO_EFFECT, null, msgCode, null, CMMsg.NO_EFFECT, null); if ((R.okMessage(mob, msg)) && (item.okMessage(item, msg)) && ((mob.charStats().getWearableRestrictionsBitmap() & oldCode) == 0) && (item.canWear(mob, oldCode))) item.wearAt(oldCode); } // why wasn't that here before? mob.recoverEnvStats(); mob.recoverCharStats(); mob.recoverMaxState(); }
@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; }
public int processVariableEquipment(MOB mob) { int newLastTickedDateTime = 0; if (mob != null) { Room R = mob.location(); if (R != null) { for (int i = 0; i < R.numInhabitants(); i++) { MOB M = R.fetchInhabitant(i); if ((M != null) && (!M.isMonster()) && (CMSecurity.isAllowed(M, R, "CMDMOBS"))) { newLastTickedDateTime = -1; break; } } if (newLastTickedDateTime == 0) { Vector rivals = new Vector(); for (int i = 0; i < mob.inventorySize(); i++) { Item I = mob.fetchInventory(i); if ((I != null) && (I.baseEnvStats().rejuv() > 0) && (I.baseEnvStats().rejuv() < Integer.MAX_VALUE)) { Vector V = null; for (int r = 0; r < rivals.size(); r++) { Vector V2 = (Vector) rivals.elementAt(r); Item I2 = (Item) V2.firstElement(); if (I2.rawWornCode() == I.rawWornCode()) { V = V2; break; } } if (V == null) { V = new Vector(); rivals.addElement(V); } V.addElement(I); } } for (int i = 0; i < rivals.size(); i++) { Vector V = (Vector) rivals.elementAt(i); if ((V.size() == 1) || (((Item) V.firstElement()).rawWornCode() == 0)) { for (int r = 0; r < V.size(); r++) { Item I = (Item) V.elementAt(r); if (CMLib.dice().rollPercentage() < I.baseEnvStats().rejuv()) mob.delInventory(I); else { I.baseEnvStats().setRejuv(0); I.envStats().setRejuv(0); } } } else { int totalChance = 0; for (int r = 0; r < V.size(); r++) { Item I = (Item) V.elementAt(r); totalChance += I.baseEnvStats().rejuv(); } int chosenChance = CMLib.dice().roll(1, totalChance, 0); totalChance = 0; Item chosenI = null; for (int r = 0; r < V.size(); r++) { Item I = (Item) V.elementAt(r); if (chosenChance <= (totalChance + I.baseEnvStats().rejuv())) { chosenI = I; break; } totalChance += I.baseEnvStats().rejuv(); } for (int r = 0; r < V.size(); r++) { Item I = (Item) V.elementAt(r); if (chosenI != I) mob.delInventory(I); else { I.baseEnvStats().setRejuv(0); I.envStats().setRejuv(0); } } } } if (mob instanceof ShopKeeper) { rivals = new Vector(); CoffeeShop shop = ((ShopKeeper) mob).getShop(); for (int v = 0; v < shop.getBaseInventory().size(); v++) { Environmental E = (Environmental) shop.getBaseInventory().elementAt(v); if ((E.baseEnvStats().rejuv() > 0) && (E.baseEnvStats().rejuv() < Integer.MAX_VALUE)) rivals.addElement(E); } for (int r = 0; r < rivals.size(); r++) { Environmental E = (Environmental) rivals.elementAt(r); if (CMLib.dice().rollPercentage() > E.baseEnvStats().rejuv()) shop.delAllStoreInventory(E); else { E.baseEnvStats().setRejuv(0); E.envStats().setRejuv(0); } } } mob.recoverEnvStats(); mob.recoverCharStats(); mob.recoverMaxState(); } } } return newLastTickedDateTime; }
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; }