@Override public void spring(MOB target) { if ((target != invoker()) && (target.location() != null)) { if ((doesSaveVsTraps(target)) || (invoker().getGroupMembers(new HashSet<MOB>()).contains(target))) target .location() .show( target, null, null, CMMsg.MASK_ALWAYS | CMMsg.MSG_NOISE, L("<S-NAME> avoid(s) setting off a gas trap!")); else if (target .location() .show( target, target, this, CMMsg.MASK_ALWAYS | CMMsg.MSG_NOISE, L("<S-NAME> set(s) off a trap! The room fills with gas!"))) { super.spring(target); Ability A = CMClass.getAbility(text()); if (A == null) A = CMClass.getAbility("Poison"); for (int i = 0; i < target.location().numInhabitants(); i++) { final MOB M = target.location().fetchInhabitant(i); if ((M != null) && (M != invoker()) && (A != null)) if (invoker().mayIFight(M)) A.invoke(invoker(), M, true, 0); } if ((canBeUninvoked()) && (affected instanceof Item)) disable(); } } }
@Override public void spring(MOB target) { if (target.location() != null) { if ((!invoker().mayIFight(target)) || (isLocalExempt(target)) || (invoker().getGroupMembers(new HashSet<MOB>()).contains(target)) || (target == invoker()) || (doesSaveVsTraps(target))) target .location() .show( target, null, null, CMMsg.MASK_ALWAYS | CMMsg.MSG_NOISE, L("<S-NAME> avoid(s) the water bomb!")); else if (target .location() .show( invoker(), target, this, CMMsg.MASK_ALWAYS | CMMsg.MSG_NOISE, L("@x1 explodes water all over <T-NAME>!", affected.name()))) { super.spring(target); final Ability A = CMClass.getAbility("Spell_Irritation"); if (A != null) A.invoke(target, target, true, invoker().phyStats().level() + abilityCode()); } } }
@Override public void executeMsg(final Environmental myHost, final CMMsg msg) { if ((msg.tool() == this) && (msg.targetMinor() == CMMsg.TYP_WEAPONATTACK) && (weaponClassification() == Weapon.CLASS_THROWN)) return; // msg.addTrailerMsg(CMClass.getMsg(msg.source(),this,CMMsg.MSG_DROP,null)); else if ((msg.tool() == this) && (msg.targetMinor() == CMMsg.TYP_DAMAGE) && (msg.target() != null) && (msg.target() instanceof MOB) && (weaponClassification() == Weapon.CLASS_THROWN)) { unWear(); msg.addTrailerMsg( CMClass.getMsg(msg.source(), this, CMMsg.MASK_ALWAYS | CMMsg.MSG_DROP, null)); msg.addTrailerMsg( CMClass.getMsg((MOB) msg.target(), this, CMMsg.MASK_ALWAYS | CMMsg.MSG_GET, null)); msg.addTrailerMsg( CMClass.getMsg( msg.source(), msg.target(), this, CMMsg.MASK_ALWAYS | CMMsg.TYP_GENERAL, null)); } else if ((msg.tool() == this) && (msg.target() instanceof MOB) && (msg.targetMinor() == CMMsg.TYP_GENERAL) && (((MOB) msg.target()).isMine(this)) && (msg.sourceMessage() == null)) { final Ability A = CMClass.getAbility("Thief_Bind"); if (A != null) { A.setAffectedOne(this); A.invoke(msg.source(), (MOB) msg.target(), true, phyStats().level()); } } else super.executeMsg(myHost, msg); }
public void initializeClass() { super.initializeClass(); CMLib.ableMapper().addCharAbilityMapping(ID(), 1, "Skill_Spellcraft", 50, true); CMLib.ableMapper().addCharAbilityMapping(ID(), 1, "Skill_ScrollCopy", 100, true); CMLib.ableMapper().addCharAbilityMapping(ID(), 1, "Spell_Scribe", 75, true); CMLib.ableMapper().addCharAbilityMapping(ID(), 1, "Papermaking", 75, true); CMLib.ableMapper().addCharAbilityMapping(ID(), 1, "Spell_ReadMagic", 100, true); CMLib.ableMapper().addCharAbilityMapping(ID(), 1, "Spell_MagicMissile", false); CMLib.ableMapper().addCharAbilityMapping(ID(), 1, "Spell_ResistMagicMissiles", false); CMLib.ableMapper().addCharAbilityMapping(ID(), 1, "Spell_Shield", false); CMLib.ableMapper().addCharAbilityMapping(ID(), 1, "Spell_IronGrip", false); for (Enumeration a = CMClass.abilities(); a.hasMoreElements(); ) { Ability A = (Ability) a.nextElement(); if ((A != null) && ((A.classificationCode() & Ability.ALL_ACODES) == Ability.ACODE_SPELL)) { int level = CMLib.ableMapper().getQualifyingLevel(ID(), true, A.ID()); if (level > 0) { AbilityMapper.AbilityMapping able = CMLib.ableMapper().getAbleMap(ID(), A.ID()); if ((able != null) && (!CMLib.ableMapper().getDefaultGain(ID(), true, A.ID()))) { able.costOverrides = new Integer[] { Integer.valueOf(0), Integer.valueOf(0), Integer.valueOf(0), Integer.valueOf(0) }; able.defaultProficiency = 100; } } } } }
@Override public String secretIdentity() { String id = super.secretIdentity(); final Ability A = getSpell(); if (A != null) id = "'A wand of " + A.name() + "' Charges: " + usesRemaining() + "\n\r" + id; return id + "\n\rSay the magic word :`" + secretWord + "` to the target."; }
public void setTrapped(Environmental myThang, Trap theTrap, boolean isTrapped) { for (int a = 0; a < myThang.numEffects(); a++) { Ability A = myThang.fetchEffect(a); if ((A != null) && (A instanceof Trap)) A.unInvoke(); } if ((isTrapped) && (myThang.fetchEffect(theTrap.ID()) == null)) myThang.addEffect(theTrap); }
public static boolean isPlant(Item I) { if ((I != null) && (I.rawSecretIdentity().length() > 0)) { for (final Enumeration<Ability> a = I.effects(); a.hasMoreElements(); ) { final Ability A = a.nextElement(); if ((A != null) && (A.invoker() != null) && (A instanceof Chant_SummonPlants)) return true; } } return false; }
public List<Ability> returnOffensiveAffects(Physical fromMe) { final Vector offenders = new Vector(); for (final Enumeration<Ability> a = fromMe.effects(); a.hasMoreElements(); ) { final Ability A = a.nextElement(); if ((A != null) && ((A.classificationCode() & Ability.ALL_ACODES) == Ability.ACODE_POISON)) offenders.addElement(A); } return offenders; }
@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 false; final MOB mob = (MOB) affected; if (mob.location().numInhabitants() == 1) return true; final Vector choices = new Vector(); for (final Enumeration<Ability> a = mob.effects(); a.hasMoreElements(); ) { final Ability A = a.nextElement(); if ((A != null) && (A.canBeUninvoked()) && (!A.ID().equals(ID())) && (A.abstractQuality() == Ability.QUALITY_MALICIOUS) && (((A.classificationCode() & Ability.ALL_ACODES) == Ability.ACODE_SPELL) || ((A.classificationCode() & Ability.ALL_ACODES) == Ability.ACODE_PRAYER)) && (!A.isAutoInvoked())) choices.addElement(A); } if (choices.size() == 0) return true; final MOB target = mob.location().fetchRandomInhabitant(); final Ability thisOne = (Ability) choices.elementAt(CMLib.dice().roll(1, choices.size(), -1)); if ((target == null) || (thisOne == null) || (target.fetchEffect(ID()) != null)) return true; if (CMLib.dice().rollPercentage() > (target.charStats().getSave(CharStats.STAT_SAVE_DISEASE))) { ((Ability) this.copyOf()).invoke(target, target, true, 0); if (target.fetchEffect(ID()) != null) ((Ability) thisOne.copyOf()).invoke(target, target, true, 0); } else spreadImmunity(target); return true; }
public List<Ability> returnOffensiveAffects(Physical fromMe) { final Vector offenders = new Vector(); for (int a = 0; a < fromMe.numEffects(); a++) // personal { final Ability A = fromMe.fetchEffect(a); if ((A != null) && ((A.classificationCode() & Ability.ALL_ACODES) == Ability.ACODE_POISON)) offenders.addElement(A); } return offenders; }
public ClimbableSurface() { super(); name = "the surface"; basePhyStats.setWeight(4); climbA = CMClass.getAbility("Prop_Climbable"); if (climbA != null) { climbA.setAffectedOne(this); climbA.makeNonUninvokable(); } recoverPhyStats(); }
@Override public void endCharacter(MOB mob) { final Vector<Ability> otherChoices = new Vector<Ability>(); for (int a = 0; a < mob.numAbilities(); a++) { final Ability A2 = mob.fetchAbility(a); if ((A2 != null) && (!A2.isSavable()) && ((A2.classificationCode() & Ability.ALL_ACODES) == Ability.ACODE_SPELL)) otherChoices.addElement(A2); } for (int a = 0; a < otherChoices.size(); a++) mob.delAbility(otherChoices.elementAt(a)); }
@Override public void executeMsg(final Environmental myHost, final CMMsg msg) { super.executeMsg(myHost, msg); // the sex rules if (!(affected instanceof MOB)) return; final MOB myChar = (MOB) affected; if (msg.target() instanceof MOB) { final MOB mate = (MOB) msg.target(); if ((msg.amISource(myChar)) && (msg.tool() instanceof Social) && (msg.tool().Name().equals("MATE <T-NAME>") || msg.tool().Name().equals("SEX <T-NAME>")) && (msg.sourceMinor() != CMMsg.TYP_CHANNEL) && (myChar.charStats().getStat(CharStats.STAT_GENDER) != mate.charStats().getStat(CharStats.STAT_GENDER)) && ((mate.charStats().getStat(CharStats.STAT_GENDER) == ('M')) || (mate.charStats().getStat(CharStats.STAT_GENDER) == ('F'))) && ((myChar.charStats().getStat(CharStats.STAT_GENDER) == ('M')) || (myChar.charStats().getStat(CharStats.STAT_GENDER) == ('F'))) && (!mate.charStats().getMyRace().canBreedWith(myChar.charStats().getMyRace())) && (myChar.location() == mate.location()) && (myChar .fetchWornItems( Wearable.WORN_LEGS | Wearable.WORN_WAIST, (short) -2048, (short) 0) .size() == 0) && (mate.fetchWornItems( Wearable.WORN_LEGS | Wearable.WORN_WAIST, (short) -2048, (short) 0) .size() == 0) && ((mate.charStats().getStat(CharStats.STAT_AGE) == 0) || ((mate.charStats().ageCategory() > Race.AGE_CHILD) && (mate.charStats().ageCategory() < Race.AGE_OLD))) && ((myChar.charStats().getStat(CharStats.STAT_AGE) == 0) || ((myChar.charStats().ageCategory() > Race.AGE_CHILD) && (myChar.charStats().ageCategory() < Race.AGE_OLD)))) { MOB female = myChar; MOB male = mate; if ((mate.charStats().getStat(CharStats.STAT_GENDER) == ('F'))) { female = mate; male = myChar; } final Ability A = CMClass.getAbility("Pregnancy"); if ((A != null) && (female.fetchAbility(A.ID()) == null) && (female.fetchEffect(A.ID()) == null)) { A.invoke(male, female, true, 0); unInvoke(); } } } }
@Override public boolean okMessage(final Environmental myHost, final CMMsg msg) { if (affected == null) return super.okMessage(myHost, msg); if (affected instanceof MOB) { final MOB mob = (MOB) affected; if ((msg.amITarget(mob)) && (!msg.amISource(mob)) && (mob.location() != msg.source().location()) && (msg.tool() instanceof Ability) && (CMath.bset(((Ability) msg.tool()).flags(), Ability.FLAG_TRANSPORTING)) && (!mob.amDead())) { final Ability A = (Ability) msg.tool(); if (((A.classificationCode() & Ability.ALL_ACODES) == Ability.ACODE_CHANT) || ((A.classificationCode() & Ability.ALL_ACODES) == Ability.ACODE_SPELL) || ((A.classificationCode() & Ability.ALL_ACODES) == Ability.ACODE_PRAYER) || ((A.classificationCode() & Ability.ALL_ACODES) == Ability.ACODE_SONG)) msg.source() .location() .showHappens( CMMsg.MSG_OK_VISUAL, L("Magical energy fizzles and is absorbed into the air!")); return false; } } else if (affected instanceof Room) { final Room R = (Room) affected; if ((msg.tool() instanceof Ability) && (msg.source().location() != null) && (msg.sourceMinor() != CMMsg.TYP_LEAVE)) { final boolean summon = CMath.bset(((Ability) msg.tool()).flags(), Ability.FLAG_SUMMONING); final boolean teleport = CMath.bset(((Ability) msg.tool()).flags(), Ability.FLAG_TRANSPORTING); final boolean shere = (msg.source().location() == affected) || ((affected instanceof Area) && (((Area) affected).inMyMetroArea(msg.source().location().getArea()))); if ((!shere) && (!summon) && (teleport) && (!CMLib.law().doesHavePriviledgesHere(msg.source(), R))) { if ((msg.source().location() != null) && (msg.source().location() != R)) msg.source() .location() .showHappens( CMMsg.MSG_OK_VISUAL, L("Magical energy fizzles and is absorbed into the air!")); R.showHappens( CMMsg.MSG_OK_VISUAL, L("Magic energy fizzles and is absorbed into the air.")); return false; } } } return super.okMessage(myHost, msg); }
@Override public int classDurationModifier(MOB myChar, Ability skill, int duration) { if (myChar == null) return duration; if (((skill.classificationCode() & Ability.ALL_DOMAINS) == Ability.DOMAIN_CRAFTINGSKILL) && (myChar.charStats().getCurrentClass().ID().equals(ID())) && (!skill.ID().equals("FoodPrep")) && (!skill.ID().equals("Cooking")) && (!skill.ID().equals("Herbalism")) && (!skill.ID().equals("Weaving")) && (!skill.ID().equals("Masonry"))) return duration * 2; return duration; }
private void clearAbilityFromSpellcraftList(MOB mob, Ability A) { final Ability enabledA = mob.fetchAbility("Skill_Spellcraft"); if (enabledA != null) { final List<String> ables = CMParms.parseCommas(enabledA.text(), true); if (ables.contains(A.ID())) { if (!CMSecurity.isAllowed(mob, mob.location(), CMSecurity.SecFlag.ALLSKILLS)) { ables.remove(A.ID()); enabledA.setMiscText(CMParms.toListString(ables)); mob.delAbility(A); } } } }
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(); } }
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 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 void unInvoke() { // undo the affects of this spell if (!(affected instanceof MOB)) return; final MOB mob = (MOB) affected; final List<Ability> poisonAffects = this.poisonAffects; super.unInvoke(); if (canBeUninvoked() && (poisonAffects != null)) { mob.tell(L("The poisons in your system are reviving.")); for (Ability A : poisonAffects) { mob.addEffect(A); A.setAffectedOne(mob); } this.poisonAffects = null; } }
@Override public boolean invoke(MOB mob, Vector commands, Physical givenTarget, boolean auto, int asLevel) { final Item target = getTarget(mob, mob.location(), givenTarget, commands, Wearable.FILTER_ANY); if (target == null) return false; final Room room = CMLib.map().roomLocation(mob); if ((room == null) || (room.getArea() == null)) return false; final String roomID = CMLib.map().getExtendedRoomID(room); if ((CMath.bset(room.getArea().flags(), Area.FLAG_INSTANCE_CHILD)) || (roomID.length() == 0)) { mob.tell(L("The magic in this place will not permit it to become a refuge.")); 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> point(s) at <T-NAMESELF> and @x1.^?", prayWord(mob))); if (mob.location().okMessage(mob, msg)) { mob.location().send(mob, msg); mob.location().show(mob, target, CMMsg.MSG_OK_VISUAL, L("<T-NAME> glows slightly!")); mob.tell( L( "@x1 will now await someone to 'SAYTO \"@x1\" Refuge' to it before teleporting you back here.", target.name(mob))); final Ability A = beneficialAffect(mob, target, asLevel, Ability.TICKS_ALMOST_FOREVER); if (A != null) A.setMiscText(roomID); target.recoverPhyStats(); mob.recoverPhyStats(); } } else beneficialVisualFizzle( mob, target, L("<S-NAME> point(s) at <T-NAMESELF>, but fail(s) to properly pray.")); // return whether it worked return success; }
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 static java.util.List<Ability> returnOffensiveAffects(Physical fromMe) { final MOB newMOB = CMClass.getFactoryMOB(); newMOB.setLocation(CMLib.map().roomLocation(fromMe)); final List<Ability> offenders = new Vector<Ability>(); for (int a = 0; a < fromMe.numEffects(); a++) // personal { final Ability A = fromMe.fetchEffect(a); if ((A != null) && (A.canBeUninvoked())) { try { newMOB.recoverPhyStats(); A.affectPhyStats(newMOB, newMOB.phyStats()); if (CMLib.flags().isInvisible(newMOB) || CMLib.flags().isHidden(newMOB)) offenders.add(A); } catch (final Exception e) { } } } newMOB.destroy(); return offenders; }
@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; }
@Override public void grantAbilities(MOB mob, boolean isBorrowedClass) { super.grantAbilities(mob, isBorrowedClass); if (mob.playerStats() == null) { final List<AbilityMapper.AbilityMapping> V = CMLib.ableMapper() .getUpToLevelListings(ID(), mob.charStats().getClassLevel(ID()), false, false); for (final AbilityMapper.AbilityMapping able : V) { final Ability A = CMClass.getAbility(able.abilityID); if ((A != null) && ((A.classificationCode() & Ability.ALL_ACODES) == Ability.ACODE_SONG) && (!CMLib.ableMapper().getDefaultGain(ID(), true, A.ID()))) giveMobAbility( mob, A, CMLib.ableMapper().getDefaultProficiency(ID(), true, A.ID()), CMLib.ableMapper().getDefaultParm(ID(), true, A.ID()), isBorrowedClass); } } }
@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); }
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 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); final List<Ability> offensiveAffects = returnOffensiveAffects(target); if ((success) && (offensiveAffects.size() > 0)) { final CMMsg msg = CMClass.getMsg( mob, target, this, verbalCastCode(mob, target, auto), auto ? L("<T-NAME> feel(s) the poison slowing down.") : L("^S<S-NAME> chant(s) for the poisons in <T-NAME> to be slowed down.^?")); if (mob.location().okMessage(mob, msg)) { mob.location().send(mob, msg); Chant_DelayPoison pA = (Chant_DelayPoison) beneficialAffect(mob, target, asLevel, 0); if (pA != null) { pA.poisonAffects = offensiveAffects; for (Ability A : offensiveAffects) { target.delEffect(A); A.setAffectedOne(target); } } target.recoverPhyStats(); } } else beneficialWordsFizzle( mob, target, auto ? "" : L("<S-NAME> chant(s) for <T-NAME>, but nothing happens.")); // return whether it worked return success; }
public static void waveIfAble(MOB mob, Physical afftarget, String message, Wand me) { if ((mob.isMine(me)) && (message != null) && (!me.amWearingAt(Wearable.IN_INVENTORY))) { Physical target = null; if (mob.location() != null) target = afftarget; final int x = message.toUpperCase().indexOf(me.magicWord().toUpperCase()); if (x >= 0) { message = message.substring(x + me.magicWord().length()); final int y = message.indexOf('\''); if (y >= 0) message = message.substring(0, y); message = message.trim(); final Ability wandUse = mob.fetchAbility("Skill_WandUse"); if ((wandUse == null) || (!wandUse.proficiencyCheck(null, 0, false))) mob.tell(CMLib.lang().L("@x1 glows faintly for a moment, then fades.", me.name())); else { Ability A = me.getSpell(); if (A == null) mob.tell(CMLib.lang().L("Something seems wrong with @x1.", me.name())); else if (me.usesRemaining() <= 0) mob.tell(CMLib.lang().L("@x1 seems spent.", me.name())); else { wandUse.setInvoker(mob); A = (Ability) A.newInstance(); if (useTheWand(A, mob, wandUse.abilityCode())) { final Vector V = new Vector(); if (target != null) V.addElement(target.name()); V.addAll(CMParms.parse(message)); mob.location() .show( mob, null, CMMsg.MSG_OK_VISUAL, CMLib.lang().L("@x1 glows brightly.", me.name())); me.setUsesRemaining(me.usesRemaining() - 1); int level = me.phyStats().level(); final int lowest = CMLib.ableMapper().lowestQualifyingLevel(A.ID()); if (level < lowest) level = lowest; A.invoke(mob, V, target, true, level); wandUse.helpProficiency(mob, 0); return; } } } } } }
@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; Room R = CMLib.map().roomLocation(target); if (R == null) R = mob.location(); if (!super.invoke(mob, commands, givenTarget, auto, asLevel)) return false; 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> cast(s) a spell on <T-NAMESELF>.^?")); if (R.okMessage(mob, msg)) { R.send(mob, msg); if (msg.value() <= 0) { R.show(target, null, CMMsg.MSG_OK_VISUAL, L("<S-NAME> slow(s) down!")); final Ability A = target.fetchEffect("Spell_MassSlow"); if (A != null) A.unInvoke(); success = maliciousAffect(mob, target, asLevel, 0, -1) != null; } } } else return maliciousFizzle( mob, target, L("<S-NAME> incant(s) at <T-NAMESELF>, but the spell fizzles.")); // return whether it worked return success; }