Beispiel #1
0
 public boolean destroyIfNecessary() {
   final Physical E = affected;
   if ((affects.size() == 0) && (E != null)) {
     unInvoke();
     E.delEffect(this);
     return true;
   }
   return false;
 }
  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 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 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();
         }
       }
     }
   }
 }
Beispiel #6
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;
  }
Beispiel #7
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 #8
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;
  }
Beispiel #9
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;
           }
         }
       }
     }
   }
 }
Beispiel #10
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;
 }
  @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;
  }
Beispiel #13
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());
 }
  @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;
  }
  @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;
  }