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;
    }
  }
Example #2
0
 public boolean destroyIfNecessary() {
   final Physical E = affected;
   if ((affects.size() == 0) && (E != null)) {
     unInvoke();
     E.delEffect(this);
     return true;
   }
   return false;
 }
 @Override
 public void affectPhyStats(Physical affected, PhyStats affectableStats) {
   super.affectPhyStats(affected, affectableStats);
   if (!(affected instanceof MOB)) return;
   if (lycanRace() != null) {
     if (affected.name().indexOf(' ') > 0)
       affectableStats.setName(L("a @x1 called @x2", lycanRace().name(), affected.name()));
     else affectableStats.setName(L("@x1 the @x2", affected.name(), lycanRace().name()));
     lycanRace().setHeightWeight(affectableStats, 'M');
   }
 }
Example #4
0
  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;
  }
Example #5
0
 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();
   }
 }
Example #6
0
 public static void setStat(Environmental E, String stat, String value) {
   if ((stat != null)
       && (stat.length() > 0)
       && (stat.equalsIgnoreCase("REJUV"))
       && (E instanceof Physical)) ((Physical) E).basePhyStats().setRejuv(CMath.s_int(value));
   else E.setStat(stat, value);
 }
 public List<Object> convertToV2(List<Ability> spellsV, Physical target) {
   final List<Object> VTOO = new Vector<Object>();
   for (int v = 0; v < spellsV.size(); v++) {
     Ability A = spellsV.get(v);
     final Ability EA = (target != null) ? target.fetchEffect(A.ID()) : null;
     if ((EA == null) && (didHappen())) {
       final String t = A.text();
       A = (Ability) A.copyOf();
       Vector<String> V2 = new Vector<String>();
       if (t.length() > 0) {
         final int x = t.indexOf('/');
         if (x < 0) {
           V2 = CMParms.parse(t);
           A.setMiscText("");
         } else {
           V2 = CMParms.parse(t.substring(0, x));
           A.setMiscText(t.substring(x + 1));
         }
       }
       VTOO.add(A);
       VTOO.add(V2);
     }
   }
   return VTOO;
 }
  @Override
  public boolean invoke(
      MOB mob, List<String> commands, Physical givenTarget, boolean auto, int asLevel) {
    Physical target = null;
    if (commands.size() > 0) {
      final String s = CMParms.combine(commands, 0);
      if (s.equalsIgnoreCase("room")) target = mob.location();
      else if (s.equalsIgnoreCase("here")) target = mob.location();
      else if (CMLib.english().containsString(mob.location().ID(), s)
          || CMLib.english().containsString(mob.location().name(), s)
          || CMLib.english().containsString(mob.location().displayText(), s))
        target = mob.location();
    }
    if (target == null) target = getTarget(mob, commands, givenTarget);
    if (target == null) return false;
    if ((target instanceof Room) && (target.fetchEffect(ID()) != null)) {
      mob.tell(L("This place is already under a teleportation ward."));
      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("<T-NAME> seem(s) magically protected.")
                  : L("^S<S-NAME> invoke(s) a teleportation ward upon <T-NAMESELF>.^?"));
      if (mob.location().okMessage(mob, msg)) {
        mob.location().send(mob, msg);
        if ((target instanceof Room) && (CMLib.law().doesOwnThisLand(mob, ((Room) target)))) {
          target.addNonUninvokableEffect((Ability) this.copyOf());
          CMLib.database().DBUpdateRoom((Room) target);
        } else beneficialAffect(mob, target, asLevel, 0);
      }
    } else
      beneficialWordsFizzle(
          mob, target, L("<S-NAME> attempt(s) to invoke a teleportation ward, but fail(s)."));

    return success;
  }
 @Override
 public void unInvoke() {
   final Physical P = affected;
   super.unInvoke();
   if ((P instanceof MOB) && (this.canBeUninvoked) && (this.unInvoked)) {
     if ((!P.amDestroyed()) && (((MOB) P).amFollowing() == null)) {
       final Room R = CMLib.map().roomLocation(P);
       if (CMLib.law().getLandOwnerName(R).length() == 0) {
         if (!CMLib.law().doesHavePriviledgesHere(invoker(), R)) {
           if ((R != null) && (!((MOB) P).amDead()))
             R.showHappens(CMMsg.MSG_OK_ACTION, P, L("<S-NAME> wander(s) off."));
           P.destroy();
         }
       }
     }
   }
 }
Example #10
0
  public void affectPhyStats(Physical affected, PhyStats affectableStats) {
    super.affectPhyStats(affected, affectableStats);
    if (affected == null) return;
    if (!(affected instanceof MOB)) return;
    MOB mob = (MOB) affected;
    int xlvl = super.getXLEVELLevel(invoker());
    affectableStats.setAttackAdjustment(
        affectableStats.attackAdjustment() + ((affected.phyStats().level() + (2 * xlvl)) / 5) + 1);
    affectableStats.setDamage(
        affectableStats.damage() + ((affected.phyStats().level() + (2 * xlvl)) / 5) + 1);

    if (mob.isInCombat()) {
      MOB victim = mob.getVictim();
      if (CMLib.flags().isEvil(victim))
        affectableStats.setArmor(affectableStats.armor() - 5 - xlvl);
    }
  }
Example #11
0
  public boolean invoke(MOB mob, Vector commands, Physical givenTarget, boolean auto, int asLevel) {
    Physical target = getAnyTarget(mob, commands, givenTarget, Wearable.FILTER_UNWORNONLY);
    if (target == null) return false;

    if (!super.invoke(mob, commands, givenTarget, auto, asLevel)) return false;

    boolean success = proficiencyCheck(mob, 0, auto);
    if ((success) && ((target instanceof MOB) || (target instanceof Item))) {
      CMMsg msg =
          CMClass.getMsg(
              mob,
              target,
              this,
              verbalCastCode(mob, target, auto),
              auto
                  ? "<T-NAME> feel(s) somewhat smaller."
                  : "^S<S-NAME> cast(s) a small spell on <T-NAMESELF>.^?");
      if (mob.location().okMessage(mob, msg)) {
        mob.location().send(mob, msg);
        boolean isJustUnInvoking = false;
        if (target instanceof Item) {
          Ability A = target.fetchEffect("Spell_Shrink");
          if ((A != null) && (A.canBeUninvoked())) {
            A.unInvoke();
            isJustUnInvoking = true;
          }
        } else if (target instanceof MOB) {
          Ability A = target.fetchEffect("Spell_Grow");
          if ((A != null) && (A.canBeUninvoked())) {
            A.unInvoke();
            isJustUnInvoking = true;
          }
        }

        if ((!isJustUnInvoking) && (msg.value() <= 0)) {
          beneficialAffect(mob, target, asLevel, 0);
          if (target instanceof MOB) CMLib.utensils().confirmWearability((MOB) target);
        }
      }
    } else
      beneficialWordsFizzle(mob, target, "<S-NAME> attempt(s) to cast a small spell, but fail(s).");

    return success;
  }
Example #12
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;
 }
Example #13
0
  @Override
  public boolean invoke(MOB mob, Vector commands, Physical givenTarget, boolean auto, int asLevel) {
    if (commands.size() < 3) {
      mob.tell(
          L("Specify a target, a property, number of ticks, and (optionally) some misc text!"));
      return false;
    }
    final Vector V = new XVector(commands.firstElement());
    final Physical target = getAnyTarget(mob, V, givenTarget, Wearable.FILTER_ANY);
    if (target == null) return false;
    commands.removeElementAt(0);

    final String abilityStr = (String) commands.firstElement();
    CMObject A = CMClass.getAbility(abilityStr);
    if (A == null) A = CMClass.getBehavior(abilityStr);
    if (A == null) A = CMClass.findAbility(abilityStr);
    if (A == null) A = CMClass.findBehavior(abilityStr);
    if (A == null) {
      mob.tell(L("No such ability or behavior as @x1!", abilityStr));
      return false;
    }
    final String numTicks = ((String) commands.elementAt(1)).trim();
    if ((!CMath.isInteger(numTicks)) || (CMath.s_int(numTicks) <= 0)) {
      mob.tell(L("'@x1' is not a number of ticks!", numTicks));
      return false;
    }
    final String parms = CMParms.combine(commands, 2);

    if (!super.invoke(mob, commands, givenTarget, auto, asLevel)) return false;

    TemporaryAffects T = (TemporaryAffects) target.fetchEffect(ID());
    if (T == null) {
      T = (TemporaryAffects) this.newInstance();
      T.affects = new SVector<Object[]>();
      T.startTickDown(mob, target, 10);
      T = (TemporaryAffects) target.fetchEffect(ID());
    }
    if (T != null) {
      T.setMiscText("+" + A.ID() + " " + numTicks.trim() + " " + parms.trim());
      T.makeLongLasting();
    }
    return true;
  }
Example #14
0
 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;
           }
         }
       }
     }
   }
 }
Example #15
0
  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;
  }
Example #16
0
 @Override
 public boolean invoke(
     MOB mob, List<String> commands, Physical target, boolean auto, int asLevel) {
   if (!auto) return false;
   final Physical P = target;
   if (P == null) return false;
   if ((P instanceof Item) && (room == null)) return false;
   if (P.fetchEffect("Falling") == null) {
     final Falling F = new Falling();
     F.setProficiency(proficiency());
     F.invoker = null;
     if (P instanceof MOB) F.invoker = (MOB) P;
     else F.invoker = CMClass.getMOB("StdMOB");
     F.setSavable(false);
     F.makeLongLasting();
     P.addEffect(F);
     if (!(P instanceof MOB)) CMLib.threads().startTickDown(F, Tickable.TICKID_MOB, 1);
     P.recoverPhyStats();
   }
   return true;
 }
 @Override
 public Trap setTrap(MOB mob, Physical P, int trapBonus, int qualifyingClassLevel, boolean perm) {
   if (P == null) return null;
   final Trap T = (Trap) copyOf();
   T.setInvoker(mob);
   P.addEffect(T);
   CMLib.threads()
       .startTickDown(
           T,
           Tickable.TICKID_TRAP_DESTRUCTION,
           CMProps.getIntVar(CMProps.Int.TICKSPERMUDDAY) + (2 * getXLEVELLevel(mob)));
   return T;
 }
Example #18
0
  public boolean invoke(MOB mob, Vector commands, Physical givenTarget, boolean auto, int asLevel) {
    Physical target = mob;
    if ((auto) && (givenTarget != null)) target = givenTarget;
    if (target.fetchEffect(this.ID()) != null) {
      mob.tell(mob, target, null, "<T-NAME> <T-IS-ARE> already affected by " + name() + ".");
      return false;
    }

    if (!super.invoke(mob, commands, givenTarget, auto, asLevel)) return false;

    boolean success = proficiencyCheck(mob, 0, auto);

    if (success) {
      // it worked, so build a copy of this ability,
      // and add it to the affects list of the
      // affected MOB. Then tell everyone else
      // what happened.
      CMMsg msg =
          CMClass.getMsg(
              mob,
              target,
              this,
              verbalCastCode(mob, target, auto),
              auto
                  ? "<T-NAME> become(s) divinely lucky."
                  : "^S<S-NAME> " + prayWord(mob) + " for divine luck.^?");
      if (mob.location().okMessage(mob, msg)) {
        mob.location().send(mob, msg);
        beneficialAffect(mob, target, asLevel, 0);
      }
    } else
      return beneficialWordsFizzle(
          mob,
          null,
          "<S-NAME> " + prayWord(mob) + ", but as luck would have it, there's no answer.");

    // return whether it worked
    return success;
  }
  @Override
  public boolean invoke(MOB mob, Vector commands, Physical givenTarget, boolean auto, int asLevel) {
    final Physical target = mob.location();
    if (target == null) return false;
    if (target.fetchEffect(ID()) != null) {
      mob.tell(L("This place is already consecrated."));
      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 consecrate this place.^?", prayForWord(mob)));
      if (mob.location().okMessage(mob, msg)) {
        mob.location().send(mob, msg);
        setMiscText(mob.Name());
        if ((target instanceof Room) && (CMLib.law().doesOwnThisLand(mob, ((Room) target)))) {
          target.addNonUninvokableEffect((Ability) this.copyOf());
          CMLib.database().DBUpdateRoom((Room) target);
        } else beneficialAffect(mob, target, asLevel, 0);
      }
    } else
      beneficialWordsFizzle(
          mob,
          target,
          L(
              "<S-NAME> @x1 to consecrate this place, but <S-IS-ARE> not answered.",
              prayForWord(mob)));

    return success;
  }
 public boolean addMeIfNeccessary(
     PhysicalAgent source, Physical target, boolean makeLongLasting, int asLevel, short maxTicks) {
   final List<Ability> V = getMySpellsV();
   if ((target == null)
       || (V.size() == 0)
       || ((compiledMask != null) && (!CMLib.masking().maskCheck(compiledMask, target, true))))
     return false;
   final List VTOO = convertToV2(V, target);
   if (VTOO.size() == 0) return false;
   final MOB qualMOB = getInvokerMOB(source, target);
   for (int v = 0; v < VTOO.size(); v += 2) {
     final Ability A = (Ability) VTOO.get(v);
     final Vector V2 = (Vector) VTOO.get(v + 1);
     if (level >= 0) asLevel = level;
     else if (asLevel <= 0) asLevel = (affected != null) ? affected.phyStats().level() : 0;
     A.invoke(qualMOB, V2, target, true, asLevel);
     final Ability EA = target.fetchEffect(A.ID());
     lastMOB = target;
     // this needs to go here because otherwise it makes non-item-invoked spells long lasting,
     // which means they dont go away when item is removed.
     if (EA != null) {
       if ((maxTicks > 0)
           && (maxTicks < Short.MAX_VALUE)
           && (CMath.s_int(EA.getStat("TICKDOWN")) > maxTicks))
         EA.setStat("TICKDOWN", Short.toString(maxTicks));
       else if (makeLongLasting) {
         EA.makeLongLasting();
         if (!uninvocable) {
           EA.makeNonUninvokable();
           if (unrevocableSpells == null) unrevocableSpells = new Vector<Ability>();
           unrevocableSpells.add(EA);
         }
       }
     }
   }
   return true;
 }
  public boolean invoke(MOB mob, Vector commands, Physical givenTarget, boolean auto, int asLevel) {
    Physical target = mob;
    if ((auto) && (givenTarget != null)) target = givenTarget;
    if (target.fetchEffect(this.ID()) != null) {
      mob.tell(mob, target, null, "<T-NAME> <T-IS-ARE> already affected by " + name() + ".");
      return false;
    }
    clan1 = CMLib.clans().findRivalrousClan(mob);
    if (clan1 == null) {
      mob.tell("You must belong to a clan to use this prayer.");
      return false;
    }
    if (commands.size() < 1) {
      mob.tell("You must specify the clan you wish to see peace with.");
      return false;
    }
    String clan2Name = CMParms.combine(commands, 0);
    clan2 = CMLib.clans().findClan(clan2Name);
    if ((clan2 == null)
        || ((clan1.getClanRelations(clan2.clanID()) != Clan.REL_WAR)
            && (clan2.getClanRelations(clan1.clanID()) != Clan.REL_WAR))) {
      mob.tell("Your " + clan1.getGovernmentName() + " is not at war with " + clan2 + "!");
      return false;
    }
    boolean found = false;
    for (Enumeration e = CMLib.players().players(); e.hasMoreElements(); ) {
      MOB M = (MOB) e.nextElement();
      if (M.getClanRole(clan2.clanID()) != null) {
        found = true;
        break;
      }
    }
    if (!found) {
      mob.tell(
          "You must wait until a member of " + clan2 + " is online before beginning the ritual.");
      return false;
    }

    if (!super.invoke(mob, commands, givenTarget, auto, asLevel)) return false;

    boolean success = proficiencyCheck(mob, 0, auto);

    if (success) {
      // it worked, so build a copy of this ability,
      // and add it to the affects list of the
      // affected MOB. Then tell everyone else
      // what happened.
      CMMsg msg =
          CMClass.getMsg(
              mob,
              target,
              this,
              verbalCastCode(mob, target, auto),
              auto
                  ? "<T-NAME> begin(s) a peace ritual."
                  : "^S<S-NAME> "
                      + prayWord(mob)
                      + " for peace between "
                      + clan1.name()
                      + " and "
                      + clan2.name()
                      + ".^?");
      if (mob.location().okMessage(mob, msg)) {
        mob.location().send(mob, msg);
        beneficialAffect(mob, target, asLevel, (int) CMProps.getTicksPerMinute() * 5);
      }
    } else
      return beneficialWordsFizzle(
          mob,
          null,
          "<S-NAME> "
              + prayWord(mob)
              + " for peace between "
              + clan1.name()
              + " and "
              + clan2.name()
              + ", but there is no answer.");

    // return whether it worked
    return success;
  }
Example #22
0
 @Override
 public Trap setTrap(MOB mob, Physical P, int trapBonus, int qualifyingClassLevel, boolean perm) {
   beneficialAffect(mob, P, qualifyingClassLevel + trapBonus, 0);
   return (Trap) P.fetchEffect(ID());
 }
Example #23
0
  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;
  }
Example #25
0
  public boolean dbMerge(MOB mob, String name, Modifiable dbM, Modifiable M, Set<String> ignores)
      throws java.io.IOException, CMException {
    if ((M instanceof Physical) && (dbM instanceof Physical)) {
      final Physical PM = (Physical) M;
      final Physical dbPM = (Physical) dbM;
      if (CMLib.flags().isCataloged(PM)) {
        mob.tell(L("^H**Warning: Changes will remove this object from the catalog."));
        PM.basePhyStats()
            .setDisposition(CMath.unsetb(PM.basePhyStats().disposition(), PhyStats.IS_CATALOGED));
      }
      if (CMLib.flags().isCataloged(dbPM))
        dbPM.basePhyStats()
            .setDisposition(CMath.unsetb(dbPM.basePhyStats().disposition(), PhyStats.IS_CATALOGED));
      PM.image();
      dbPM.image();
    }

    final String[] statCodes = dbM.getStatCodes();
    int showFlag = -1;
    if (CMProps.getIntVar(CMProps.Int.EDITORTYPE) > 0) showFlag = -999;
    boolean ok = false;
    boolean didSomething = false;
    while (!ok) {
      int showNumber = 0;
      mob.tell(name);
      for (int i = 0; i < statCodes.length; i++) {
        final String statCode = M.getStatCodes()[i];
        if (ignores.contains(statCode)
            || ((M instanceof MOB) && statCode.equalsIgnoreCase("INVENTORY"))) continue;
        final String promptStr = CMStrings.capitalizeAndLower(M.getStatCodes()[i]);
        final String dbVal = dbM.getStat(statCode);
        final String loVal = M.getStat(statCode);
        if (dbVal.equals(loVal)) continue;
        ++showNumber;
        if ((showFlag > 0) && (showFlag != showNumber)) continue;
        mob.tell(
            L(
                "^H@x1. @x2\n\rValue: ^W'@x3'\n\r^HDBVal: ^N'@x4'",
                "" + showNumber,
                promptStr,
                loVal,
                dbVal));
        if ((showFlag != showNumber) && (showFlag > -999)) continue;
        final String res =
            mob.session()
                .choose(
                    L("D)atabase Value, E)dit Value, or N)o Change, or Q)uit All: "),
                    L("DENQ"),
                    L("N"));
        if (res.trim().equalsIgnoreCase("N")) continue;
        if (res.trim().equalsIgnoreCase("Q")) throw new CMException("Cancelled by user.");
        didSomething = true;
        if (res.trim().equalsIgnoreCase("D")) {
          M.setStat(statCode, dbVal);
          continue;
        }
        M.setStat(
            statCode,
            CMLib.genEd().prompt(mob, M.getStat(statCode), ++showNumber, showFlag, promptStr));
      }
      if (showNumber == 0) return didSomething;
      if (showFlag < -900) {
        ok = true;
        break;
      }
      if (showFlag > 0) {
        showFlag = -1;
        continue;
      }
      showFlag = CMath.s_int(mob.session().prompt(L("Edit which? "), ""));
      if (showFlag <= 0) {
        showFlag = -1;
        ok = true;
      }
    }
    return didSomething;
  }
  public boolean invoke(MOB mob, Vector commands, Physical givenTarget, boolean auto, int asLevel) {
    Physical target = getAnyTarget(mob, commands, givenTarget, Wearable.FILTER_ANY);
    if (target == null) return false;

    if (!super.invoke(mob, commands, givenTarget, auto, asLevel)) return false;

    boolean success = false;
    int affectType = CMMsg.MSG_CAST_VERBAL_SPELL;
    if (!(target instanceof Item)) {
      if (!auto) affectType = affectType | CMMsg.MASK_MALICIOUS;
    }
    int levelDiff =
        target.phyStats().level() - (mob.phyStats().level() + (getXLEVELLevel(mob) / 2));
    if (target instanceof MOB) levelDiff += 6;
    if (levelDiff < 0) levelDiff = 0;
    success = proficiencyCheck(mob, -(levelDiff * 15), auto);

    if (auto) affectType = affectType | CMMsg.MASK_ALWAYS;

    Room R = mob.location();
    if (success && (R != null)) {
      CMMsg msg =
          CMClass.getMsg(
              mob,
              target,
              this,
              affectType,
              auto
                  ? ""
                  : "^S<S-NAME> point(s) at <T-NAMESELF> and "
                      + prayWord(mob)
                      + " treacherously!^?");
      if (R.okMessage(mob, msg)) {
        R.send(mob, msg);
        if (msg.value() <= 0) {
          HashSet<DeadBody> oldBodies = new HashSet<DeadBody>();
          for (int i = 0; i < R.numItems(); i++) {
            Item I = R.getItem(i);
            if ((I != null) && (I instanceof DeadBody) && (I.container() == null))
              oldBodies.add((DeadBody) I);
          }

          if (target instanceof MOB) {
            if (((MOB) target).curState().getHitPoints() > 0)
              CMLib.combat()
                  .postDamage(
                      mob,
                      (MOB) target,
                      this,
                      (((MOB) target).curState().getHitPoints() * 100),
                      CMMsg.MASK_ALWAYS | CMMsg.TYP_UNDEAD,
                      Weapon.TYPE_BURSTING,
                      "^SThe evil <DAMAGE> <T-NAME>!^?");
            if (((MOB) target).amDead())
              R.show(mob, target, CMMsg.MSG_OK_ACTION, "<T-NAME> <T-IS-ARE> consumed!");
            else return false;
          } else R.show(mob, target, CMMsg.MSG_OK_ACTION, "<T-NAME> is consumed!");

          if (target instanceof Item) ((Item) target).destroy();
          else // destroy any newly created bodies
          {
            for (int i = 0; i < R.numItems(); i++) {
              Item I = R.getItem(i);
              if ((I != null)
                  && (I instanceof DeadBody)
                  && (I.container() == null)
                  && (!oldBodies.contains(I))
                  && (!((DeadBody) I).playerCorpse())) {
                I.destroy();
                break;
              }
            }
          }
          R.recoverRoomStats();
        }
      }

    } else
      maliciousFizzle(
          mob,
          target,
          "<S-NAME> point(s) at <T-NAMESELF> and "
              + prayWord(mob)
              + " treacherously, but fizzle(s) the magic!");

    // return whether it worked
    return success;
  }
  @Override
  public boolean invoke(
      MOB mob, List<String> commands, Physical givenTarget, boolean auto, int asLevel) {
    final Physical target = getAnyTarget(mob, commands, givenTarget, Wearable.FILTER_ANY, true);
    if (target == null) return false;

    if (!super.invoke(mob, commands, givenTarget, auto, asLevel)) return false;

    int type = verbalCastCode(mob, target, auto);
    if ((target instanceof MOB)
        && (CMath.bset(type, CMMsg.MASK_MALICIOUS))
        && (((MOB) target).charStats().getStat(CharStats.STAT_AGE) > 0)) {
      final MOB mobt = (MOB) target;
      if (mobt.charStats().ageCategory() <= Race.AGE_CHILD)
        type = CMath.unsetb(type, CMMsg.MASK_MALICIOUS);
      else if ((mobt.getLiegeID().equals(mob.Name())) || (mobt.amFollowing() == mob))
        type = CMath.unsetb(type, CMMsg.MASK_MALICIOUS);
      else if ((mobt.charStats().ageCategory() <= Race.AGE_MATURE)
          && (mobt.getLiegeID().length() > 0)) type = CMath.unsetb(type, CMMsg.MASK_MALICIOUS);
    }

    if ((target instanceof Item)
        || ((target instanceof MOB)
            && (((MOB) target).isMonster())
            && (CMLib.flags().isAnimalIntelligence((MOB) target))
            && (CMLib.law().doesHavePriviledgesHere(mob, mob.location())))) {
      type = CMath.unsetb(type, CMMsg.MASK_MALICIOUS);
    }

    boolean success = proficiencyCheck(mob, 0, auto);
    if (success) {
      final CMMsg msg =
          CMClass.getMsg(
              mob, target, this, type, auto ? "" : L("^S<S-NAME> chant(s) to <T-NAMESELF>.^?"));
      if (mob.location().okMessage(mob, msg)) {
        mob.location().send(mob, msg);
        final Ability A = target.fetchEffect("Age");
        if ((!(target instanceof MOB)) && (!(target instanceof CagedAnimal)) && (A == null)) {
          if (target instanceof Food) {
            mob.tell(L("@x1 rots away!", target.name(mob)));
            ((Item) target).destroy();
          } else if (target instanceof Item) {
            switch (((Item) target).material() & RawMaterial.MATERIAL_MASK) {
              case RawMaterial.MATERIAL_CLOTH:
              case RawMaterial.MATERIAL_FLESH:
              case RawMaterial.MATERIAL_LEATHER:
              case RawMaterial.MATERIAL_PAPER:
              case RawMaterial.MATERIAL_VEGETATION:
              case RawMaterial.MATERIAL_WOODEN:
                {
                  mob.location()
                      .showHappens(CMMsg.MSG_OK_VISUAL, L("@x1 rots away!", target.name()));
                  if (target instanceof Container) ((Container) target).emptyPlease(false);
                  ((Item) target).destroy();
                  break;
                }
              default:
                mob.location()
                    .showHappens(
                        CMMsg.MSG_OK_VISUAL,
                        L("@x1 ages, but nothing happens to it.", target.name()));
                break;
            }
          } else
            mob.location()
                .showHappens(
                    CMMsg.MSG_OK_VISUAL, L("@x1 ages, but nothing happens to it.", target.name()));
          success = false;
        } else if ((target instanceof MOB) && ((A == null) || (A.displayText().length() == 0))) {
          final MOB M = (MOB) target;
          mob.location().show(M, null, CMMsg.MSG_OK_VISUAL, L("<S-NAME> age(s) a bit."));
          if (M.baseCharStats().getStat(CharStats.STAT_AGE) <= 0)
            M.setAgeMinutes(M.getAgeMinutes() + (M.getAgeMinutes() / 10));
          else if ((M.playerStats() != null) && (M.playerStats().getBirthday() != null)) {
            final TimeClock C = CMLib.time().localClock(M.getStartRoom());
            final double aging = CMath.mul(M.baseCharStats().getStat(CharStats.STAT_AGE), .10);
            int years = (int) Math.round(Math.floor(aging));
            final int monthsInYear = C.getMonthsInYear();
            int months = (int) Math.round(CMath.mul(aging - Math.floor(aging), monthsInYear));
            if ((years <= 0) && (months == 0)) months++;
            M.playerStats().getBirthday()[PlayerStats.BIRTHDEX_YEAR] -= years;
            M.playerStats().getBirthday()[PlayerStats.BIRTHDEX_MONTH] -= months;
            if (M.playerStats().getBirthday()[PlayerStats.BIRTHDEX_MONTH] < 1) {
              M.playerStats().getBirthday()[PlayerStats.BIRTHDEX_YEAR]--;
              years++;
              M.playerStats().getBirthday()[PlayerStats.BIRTHDEX_MONTH] =
                  monthsInYear + M.playerStats().getBirthday()[PlayerStats.BIRTHDEX_MONTH];
            }
            M.baseCharStats()
                .setStat(CharStats.STAT_AGE, M.baseCharStats().getStat(CharStats.STAT_AGE) + years);
          }
          M.recoverPhyStats();
          M.recoverCharStats();
        } else if (A != null) {
          final long start = CMath.s_long(A.text());
          long age = System.currentTimeMillis() - start;
          final long millisPerMudday =
              CMProps.getIntVar(CMProps.Int.TICKSPERMUDDAY) * CMProps.getTickMillis();
          if (age < millisPerMudday) age = millisPerMudday;
          final long millisPerMonth = CMLib.time().globalClock().getDaysInMonth() * millisPerMudday;
          final long millisPerYear = CMLib.time().globalClock().getMonthsInYear() * millisPerMonth;
          long ageBy = age / 10;
          if (ageBy < millisPerMonth) ageBy = millisPerMonth + 1;
          else if (ageBy < millisPerYear) ageBy = millisPerYear + 1;
          A.setMiscText("" + (start - ageBy));
          if (target instanceof MOB)
            mob.location()
                .show((MOB) target, null, CMMsg.MSG_OK_VISUAL, L("<S-NAME> age(s) a bit."));
          else mob.location().showHappens(CMMsg.MSG_OK_VISUAL, L("@x1 ages a bit.", target.name()));
          target.recoverPhyStats();
        } else
          return beneficialWordsFizzle(
              mob, target, L("<S-NAME> chant(s) to <T-NAMESELF>, but the magic fades."));
      }
    } else if (CMath.bset(type, CMMsg.MASK_MALICIOUS))
      return maliciousFizzle(
          mob, target, L("<S-NAME> chant(s) to <T-NAMESELF>, but the magic fades."));
    else
      return beneficialWordsFizzle(
          mob, target, L("<S-NAME> chant(s) to <T-NAMESELF>, but the magic fades."));

    // return whether it worked
    return success;
  }
Example #28
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;
  }