public void removeMyAffectsFrom(Physical P) {
    if (P == null) return;

    int x = 0;
    final Vector<Ability> eff = new Vector<Ability>();
    Ability thisAffect = null;
    for (x = 0; x < P.numEffects(); x++) // personal
    {
      thisAffect = P.fetchEffect(x);
      if (thisAffect != null) eff.addElement(thisAffect);
    }
    if (eff.size() > 0) {
      final Map<String, String> h = makeMySpellsH(getMySpellsV());
      if (unrevocableSpells != null) {
        for (int v = unrevocableSpells.size() - 1; v >= 0; v--) {
          thisAffect = unrevocableSpells.get(v);
          if (h.containsKey(thisAffect.ID())) P.delEffect(thisAffect);
        }
      } else
        for (x = 0; x < eff.size(); x++) {
          thisAffect = eff.elementAt(x);
          final String ID = h.get(thisAffect.ID());
          if ((ID != null) && (thisAffect.invoker() == getInvokerMOB(P, P))) {
            thisAffect.unInvoke();
            if ((!uninvocable) && (!thisAffect.canBeUninvoked())) P.delEffect(thisAffect);
          }
        }
      unrevocableSpells = null;
    }
  }
  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;
  }
Beispiel #3
0
 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;
 }
Beispiel #4
0
  public boolean invoke(MOB mob, Vector commands, Physical givenTarget, boolean auto, int asLevel) {

    String whatToRevoke = CMParms.combine(commands, 0);

    Physical target = null;
    if ((whatToRevoke.length() == 0) && (mob.location().numEffects() > 0)) target = mob.location();
    else if (whatToRevoke.equalsIgnoreCase("room")) target = mob.location();
    else if (whatToRevoke.equalsIgnoreCase("self")) target = mob;
    else {
      int dir = Directions.getGoodDirectionCode(whatToRevoke);
      if (dir >= 0) target = mob.location().getExitInDir(dir);
      else {
        target = mob.location().fetchFromRoomFavorMOBs(null, whatToRevoke);
        if (target == null) target = mob.findItem(null, whatToRevoke);
      }
    }

    if ((target == null) || (!CMLib.flags().canBeSeenBy(target, mob))) {
      mob.tell("Revoke from what?  You don't see '" + whatToRevoke + "' here.");
      return false;
    }

    Ability revokeThis = null;
    for (int a = 0; a < target.numEffects(); a++) {
      Ability A = target.fetchEffect(a);
      if ((A != null)
          && (A.invoker() == mob)
          && (((A.classificationCode() & Ability.ALL_ACODES) == Ability.ACODE_SPELL)
              || ((A.classificationCode() & Ability.ALL_ACODES) == Ability.ACODE_SONG)
              || ((A.classificationCode() & Ability.ALL_ACODES) == Ability.ACODE_PRAYER)
              || ((A.classificationCode() & Ability.ALL_ACODES) == Ability.ACODE_CHANT))
          && (A.canBeUninvoked())) revokeThis = A;
    }

    if (revokeThis == null) {
      if (target instanceof Room) mob.tell("Revoke your magic from what?");
      else
        mob.tell(
            mob,
            target,
            null,
            "<T-NAME> do(es) not appear to be affected by anything you can revoke.");
      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,
              null,
              this,
              CMMsg.MSG_HANDS,
              "<S-NAME> revoke(s) " + revokeThis.name() + " from " + target.name());
      if (mob.location().okMessage(mob, msg)) {
        mob.location().send(mob, msg);
        revokeThis.unInvoke();
      }
    } else
      beneficialVisualFizzle(
          mob,
          target,
          "<S-NAME> attempt(s) to revoke "
              + revokeThis.name()
              + " from "
              + target.name()
              + ", but flub(s) it.");
    return success;
  }