public boolean invoke( MOB mob, Vector commands, Environmental givenTarget, boolean auto, int asLevel) { Item myPlant = getTarget(mob, mob.location(), givenTarget, commands, Item.WORNREQ_ANY); if (myPlant == null) return false; if (isPlant(myPlant) == null) { mob.tell("You can't control " + myPlant.name() + "."); return false; } if (myPlant.rawSecretIdentity().equals(mob.Name())) { mob.tell("You already control " + myPlant.name() + "."); return false; } if (!super.invoke(mob, commands, givenTarget, auto, asLevel)) return false; boolean success = proficiencyCheck(mob, 0, auto); if (success) { CMMsg msg = CMClass.getMsg( mob, myPlant, this, verbalCastCode(mob, myPlant, auto), auto ? "" : "^S<S-NAME> chant(s) to <T-NAMESELF>!^?"); if (mob.location().okMessage(mob, msg)) { mob.location().send(mob, msg); Ability A = isPlant(myPlant); if (A != null) A.setInvoker(mob); mob.tell( "You wrest control of " + myPlant.name() + " from " + myPlant.secretIdentity() + "."); myPlant.setSecretIdentity(mob.Name()); } } else beneficialVisualFizzle( mob, myPlant, "<S-NAME> chant(s) to <T-NAMESELF>, 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; } } } } } }