Exemplo n.º 1
0
 @Override
 public void destroy() {
   try {
     CharStats savedCStats = charStats;
     if (charStats == baseCharStats)
       savedCStats = (CharStats) CMClass.getCommon("DefaultCharStats");
     PhyStats savedPStats = phyStats;
     if (phyStats == basePhyStats) savedPStats = (PhyStats) CMClass.getCommon("DefaultPhyStats");
     final CharState savedCState = curState;
     if ((curState == baseState) || (curState == maxState))
       curState = (CharState) CMClass.getCommon("DefaultCharState");
     super.destroy();
     removeFromGame = false;
     charStats = savedCStats;
     phyStats = savedPStats;
     curState = savedCState;
     baseCharStats.reset();
     basePhyStats.reset();
     baseState.reset();
     maxState.reset();
     curState.reset();
     phyStats.reset();
     charStats.reset();
     finalize();
   } catch (final Throwable t) {
     Log.errOut(ID(), t);
   }
 }
Exemplo n.º 2
0
  public boolean invoke(
      MOB mob, Vector commands, Environmental givenTarget, boolean auto, int asLevel) {
    if (!super.invoke(mob, commands, givenTarget, auto, asLevel)) return false;

    HashSet h = properTargets(mob, givenTarget, auto);
    if (h == null) return false;

    boolean success = proficiencyCheck(mob, 0, auto);
    boolean nothingDone = true;
    if (success) {
      for (Iterator e = h.iterator(); e.hasNext(); ) {
        MOB target = (MOB) e.next();
        // 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) | CMMsg.MASK_MALICIOUS,
                auto
                    ? ""
                    : "^S<S-NAME> "
                        + prayForWord(mob)
                        + " an unholy paralysis upon <T-NAMESELF>.^?");
        CMMsg msg2 =
            CMClass.getMsg(
                mob,
                target,
                this,
                CMMsg.MASK_MALICIOUS | CMMsg.TYP_PARALYZE | (auto ? CMMsg.MASK_ALWAYS : 0),
                null);
        if ((target != mob)
            && (mob.location().okMessage(mob, msg))
            && (mob.location().okMessage(mob, msg2))) {
          int levelDiff =
              target.envStats().level()
                  - (mob.envStats().level() + (2 * super.getXLEVELLevel(mob)));
          if (levelDiff < 0) levelDiff = 0;
          if (levelDiff > 6) levelDiff = 6;
          mob.location().send(mob, msg);
          mob.location().send(mob, msg2);
          if ((msg.value() <= 0) && (msg2.value() <= 0)) {
            success = maliciousAffect(mob, target, asLevel, 8 - levelDiff, -1);
            mob.location().show(target, null, CMMsg.MSG_OK_VISUAL, "<S-NAME> can't move!");
          }
          nothingDone = false;
        }
      }
    }

    if (nothingDone)
      return maliciousFizzle(
          mob, null, "<S-NAME> attempt(s) to paralyze everyone, but flub(s) it.");

    // return whether it worked
    return success;
  }
Exemplo n.º 3
0
 @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);
 }
Exemplo n.º 4
0
 @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();
     }
   }
 }
Exemplo n.º 5
0
 @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);
 }
Exemplo n.º 6
0
  @Override
  public boolean invoke(MOB mob, Vector commands, Physical givenTarget, boolean auto, int asLevel) {
    final MOB target = this.getTarget(mob, commands, givenTarget);
    if (target == null) return false;

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

    // now see if it worked
    final boolean success = proficiencyCheck(mob, 0, auto);

    if (success) {
      final CMMsg msg =
          CMClass.getMsg(
              mob,
              target,
              this,
              somanticCastCode(mob, target, auto),
              L(
                      (auto ? "A " : "^S<S-NAME> incant(s) and point(s) at <T-NAMESELF>. A ")
                          + "long shard of ice streaks through the air!^?")
                  + CMLib.protocol().msp("spelldam2.wav", 40));
      final CMMsg msg2 =
          CMClass.getMsg(
              mob,
              target,
              this,
              CMMsg.MSK_CAST_MALICIOUS_VERBAL | CMMsg.TYP_COLD | (auto ? CMMsg.MASK_ALWAYS : 0),
              null);
      if ((mob.location().okMessage(mob, msg)) && (mob.location().okMessage(mob, msg2))) {
        mob.location().send(mob, msg);
        invoker = mob;

        int damage = 0;
        final int maxDie = (adjustedLevel(mob, asLevel) + (2 * super.getX1Level(mob))) / 2;
        damage += CMLib.dice().roll(maxDie, 6, 15);
        mob.location().send(mob, msg2);
        if ((msg2.value() > 0) || (msg.value() > 0))
          damage = (int) Math.round(CMath.div(damage, 2.0));

        if (target.location() == mob.location())
          CMLib.combat()
              .postDamage(
                  mob,
                  target,
                  this,
                  damage,
                  CMMsg.MASK_ALWAYS | CMMsg.TYP_COLD,
                  Weapon.TYPE_FROSTING,
                  L("The lance <DAMAGE> <T-NAME>!"));
      }
    } else
      return maliciousFizzle(
          mob,
          target,
          L("<S-NAME> incant(s) and point(s) at <T-NAMESELF>, but flub(s) the spell."));

    // return whether it worked
    return success;
  }
Exemplo n.º 7
0
  @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_CHANT)
            && (!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);
      }
      return;
    }

    final Vector grantable = new Vector();

    final int level = mob.charStats().getClassLevel(this);
    int numChants = 2;
    for (final Enumeration<Ability> a = CMClass.abilities(); a.hasMoreElements(); ) {
      final Ability A = a.nextElement();
      if ((CMLib.ableMapper().getQualifyingLevel(ID(), true, A.ID()) == level)
          && ((CMLib.ableMapper().getQualifyingLevel(ID(), true, A.ID()) <= 25)
              && (!CMLib.ableMapper().getSecretSkill(ID(), true, A.ID()))
              && (!CMLib.ableMapper().getDefaultGain(ID(), true, A.ID()))
              && ((A.classificationCode() & Ability.ALL_ACODES) == Ability.ACODE_CHANT))) {
        if (!grantable.contains(A.ID())) grantable.addElement(A.ID());
      }
    }
    for (int a = 0; a < mob.numAbilities(); a++) {
      final Ability A = mob.fetchAbility(a);
      if (grantable.contains(A.ID())) {
        grantable.remove(A.ID());
        numChants--;
      }
    }
    for (int i = 0; i < numChants; i++) {
      if (grantable.size() == 0) break;
      final String AID = (String) grantable.elementAt(CMLib.dice().roll(1, grantable.size(), -1));
      if (AID != null) {
        grantable.removeElement(AID);
        giveMobAbility(
            mob,
            CMClass.getAbility(AID),
            CMLib.ableMapper().getDefaultProficiency(ID(), true, AID),
            CMLib.ableMapper().getDefaultParm(ID(), true, AID),
            isBorrowedClass);
      }
    }
  }
  @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;
    final boolean undead = CMLib.flags().isUndead(target);

    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,
              (undead ? 0 : CMMsg.MASK_MALICIOUS) | verbalCastCode(mob, target, auto),
              L(
                      auto
                          ? "A seriously painful burst assaults <T-NAME>."
                          : "^S<S-NAME> "
                              + prayWord(mob)
                              + " for a serious burst of pain at <T-NAMESELF>!^?")
                  + CMLib.protocol().msp("spelldam1.wav", 40));
      final CMMsg msg2 =
          CMClass.getMsg(
              mob,
              target,
              this,
              CMMsg.MSK_CAST_MALICIOUS_VERBAL | CMMsg.TYP_UNDEAD | (auto ? CMMsg.MASK_ALWAYS : 0),
              null);
      final Room R = target.location();
      if ((R != null) && (R.okMessage(mob, msg)) && ((R.okMessage(mob, msg2)))) {
        R.send(mob, msg);
        R.send(mob, msg2);
        if ((msg.value() <= 0) && (msg2.value() <= 0)) {
          final int harming = CMLib.dice().roll(1, adjustedLevel(mob, asLevel) + 6, 4);
          CMLib.combat()
              .postDamage(
                  mob,
                  target,
                  this,
                  harming,
                  CMMsg.MASK_ALWAYS | CMMsg.TYP_UNDEAD,
                  Weapon.TYPE_BURSTING,
                  L("The unholy spell <DAMAGE> <T-NAME>!"));
        }
      }
    } else
      return maliciousFizzle(
          mob,
          target,
          L("<S-NAME> point(s) at <T-NAMESELF> and @x1, but nothing happens.", prayWord(mob)));

    // return whether it worked
    return success;
  }
Exemplo n.º 9
0
  public boolean open(
      MOB mob, Environmental openThis, String openableWord, int dirCode, boolean quietly) {
    final String openWord = (!(openThis instanceof Exit)) ? "open" : ((Exit) openThis).openWord();
    final String openMsg =
        quietly
            ? null
            : ("<S-NAME> " + openWord + "(s) <T-NAMESELF>.")
                + CMLib.protocol().msp("dooropen.wav", 10);
    final CMMsg msg =
        CMClass.getMsg(mob, openThis, null, CMMsg.MSG_OPEN, openMsg, openableWord, openMsg);
    if (openThis instanceof Exit) {
      final boolean open = ((Exit) openThis).isOpen();
      if ((mob.location().okMessage(msg.source(), msg)) && (!open)) {
        mob.location().send(msg.source(), msg);

        if (dirCode < 0)
          for (int d = Directions.NUM_DIRECTIONS() - 1; d >= 0; d--)
            if (mob.location().getExitInDir(d) == openThis) {
              dirCode = d;
              break;
            }
        if ((dirCode >= 0) && (mob.location().getRoomInDir(dirCode) != null)) {
          final Room opR = mob.location().getRoomInDir(dirCode);
          final Exit opE = mob.location().getPairedExit(dirCode);
          if (opE != null) {
            final CMMsg altMsg =
                CMClass.getMsg(
                    msg.source(),
                    opE,
                    msg.tool(),
                    msg.sourceCode(),
                    null,
                    msg.targetCode(),
                    null,
                    msg.othersCode(),
                    null);
            opE.executeMsg(msg.source(), altMsg);
          }
          final int opCode = Directions.getOpDirectionCode(dirCode);
          if ((opE != null) && (opE.isOpen()) && (((Exit) openThis).isOpen())) {
            final boolean useShipDirs =
                (opR instanceof BoardableShip) || (opR.getArea() instanceof BoardableShip);
            final String inDirName =
                useShipDirs
                    ? Directions.getShipInDirectionName(opCode)
                    : Directions.getInDirectionName(opCode);
            opR.showHappens(CMMsg.MSG_OK_ACTION, L("@x1 @x2 opens.", opE.name(), inDirName));
          }
          return true;
        }
      }
    } else if (mob.location().okMessage(mob, msg)) {
      mob.location().send(mob, msg);
      return true;
    }
    return false;
  }
Exemplo n.º 10
0
 @Override
 public List<Item> getTrapComponents() {
   final Vector V = new Vector();
   final Item I = CMLib.materials().makeItemResource(RawMaterial.RESOURCE_POISON);
   Ability A = CMClass.getAbility(text());
   if (A == null) A = CMClass.getAbility("Poison");
   I.addNonUninvokableEffect(A);
   V.addElement(I);
   return V;
 }
Exemplo n.º 11
0
  @Override
  public boolean invoke(MOB mob, Vector commands, Physical givenTarget, boolean auto, int asLevel) {
    final MOB target = this.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);

    if (success) {
      final CMMsg msg =
          CMClass.getMsg(
              mob,
              target,
              this,
              CMMsg.MSK_CAST_MALICIOUS_VERBAL | CMMsg.TYP_UNDEAD | (auto ? CMMsg.MASK_ALWAYS : 0),
              null);
      final CMMsg msg2 =
          CMClass.getMsg(
              mob,
              target,
              this,
              verbalCastCode(mob, target, auto),
              auto ? "" : L("^S<S-NAME> reach(es) at <T-NAMESELF>, @x1!^?", prayingWord(mob)));
      if ((mob.location().okMessage(mob, msg)) && (mob.location().okMessage(mob, msg2))) {
        mob.location().send(mob, msg2);
        mob.location().send(mob, msg);
        if ((msg.value() <= 0) && (msg2.value() <= 0)) {
          final int damage = CMLib.dice().roll(1, adjustedLevel(mob, asLevel), 0);
          CMLib.combat()
              .postDamage(
                  mob,
                  target,
                  this,
                  damage,
                  CMMsg.MASK_ALWAYS | CMMsg.TYP_UNDEAD,
                  Weapon.TYPE_BURSTING,
                  auto
                      ? L("<T-NAME> shudder(s) in a draining magical wake.")
                      : L("The draining grasp <DAMAGE> <T-NAME>."));
          if (mob != target)
            CMLib.combat()
                .postHealing(
                    mob, mob, this, CMMsg.MASK_ALWAYS | CMMsg.TYP_CAST_SPELL, damage, null);
        }
      }
    } else
      return maliciousFizzle(
          mob,
          target,
          L("<S-NAME> reach(es) for <T-NAMESELF>, @x1, but the spell fades.", prayingWord(mob)));

    // return whether it worked
    return success;
  }
Exemplo n.º 12
0
  @Override
  public boolean invoke(MOB mob, Vector 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;

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

    if (success) {
      final CMMsg msg =
          CMClass.getMsg(
              mob,
              target,
              this,
              somanticCastCode(mob, target, auto),
              L(
                      auto
                          ? "<T-NAME> <T-IS-ARE> sprayed with acid."
                          : "^S<S-NAME> reach(es) for <T-NAMESELF>, spraying acid all over <T-HIM-HER>!^?")
                  + CMLib.protocol().msp("spelldam1.wav", 40));
      final CMMsg msg2 =
          CMClass.getMsg(
              mob,
              target,
              this,
              CMMsg.MSK_CAST_MALICIOUS_VERBAL | CMMsg.TYP_ACID | (auto ? CMMsg.MASK_ALWAYS : 0),
              null);
      if ((R.okMessage(mob, msg)) && ((R.okMessage(mob, msg2)))) {
        R.send(mob, msg);
        R.send(mob, msg2);
        invoker = mob;
        final int numDice = (adjustedLevel(mob, asLevel) + (2 * super.getX1Level(invoker()))) / 2;
        int damage = CMLib.dice().roll(2, numDice, 1);
        if ((msg2.value() > 0) || (msg.value() > 0))
          damage = (int) Math.round(CMath.div(damage, 2.0));
        CMLib.combat()
            .postDamage(
                mob,
                target,
                this,
                damage,
                CMMsg.MASK_ALWAYS | CMMsg.TYP_ACID,
                Weapon.TYPE_MELTING,
                L("The acid <DAMAGE> <T-NAME>!"));
        maliciousAffect(mob, target, asLevel, 3, -1);
      }
    } else
      return maliciousFizzle(
          mob, target, L("<S-NAME> reach(es) for <T-NAMESELF>, but nothing more happens."));

    return success;
  }
Exemplo n.º 13
0
  @Override
  public boolean invoke(
      MOB mob, List<String> commands, Physical givenTarget, boolean auto, int asLevel) {
    MOB target = CMLib.players().getLoadPlayer(CMParms.combine(commands, 0));
    if (target == null) target = getTargetAnywhere(mob, commands, givenTarget, false, true, false);
    if (target == null) return false;

    final Archon_Record A = (Archon_Record) target.fetchEffect(ID());
    if (A != null) {
      target.delEffect(A);
      if (target.playerStats() != null) target.playerStats().setLastUpdated(0);
      mob.tell(L("@x1 will no longer be recorded.", target.Name()));
      return true;
    }

    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,
              CMMsg.MASK_MOVE | CMMsg.TYP_JUSTICE | (auto ? CMMsg.MASK_ALWAYS : 0),
              L("^F<S-NAME> begin(s) recording <T-NAMESELF>.^?"));
      CMLib.color().fixSourceFightColor(msg);
      if (mob.location().okMessage(mob, msg)) {
        mob.location().send(mob, msg);
        final String filename = "/" + target.Name() + System.currentTimeMillis() + ".log";
        final CMFile file = new CMFile(filename, null, CMFile.FLAG_LOGERRORS);
        if (!file.canWrite()) {
          if (!CMSecurity.isASysOp(mob) || (CMSecurity.isASysOp(target)))
            Log.sysOut("Record", mob.Name() + " failed to start recording " + target.name() + ".");
        } else {
          if (!CMSecurity.isASysOp(mob) || (CMSecurity.isASysOp(target)))
            Log.sysOut(
                "Record",
                mob.Name() + " started recording " + target.name() + " to /" + filename + ".");
          final Archon_Record A2 = (Archon_Record) copyOf();
          final Session F = (Session) CMClass.getCommon("FakeSession");
          F.initializeSession(null, Thread.currentThread().getThreadGroup().getName(), filename);
          if (target.session() == null) target.setSession(F);
          A2.sess = F;
          target.addNonUninvokableEffect(A2);
          mob.tell(L("Enter RECORD @x1 again to stop recording.", target.Name()));
        }
      }
    } else
      return beneficialVisualFizzle(
          mob, target, L("<S-NAME> attempt(s) to hush <T-NAMESELF>, but fail(s)."));
    return success;
  }
Exemplo n.º 14
0
  @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;

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

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

    final Room R = target.location();
    if (success) {
      final Prayer_Thunderbolt newOne = (Prayer_Thunderbolt) this.copyOf();
      final CMMsg msg =
          CMClass.getMsg(
              mob,
              target,
              newOne,
              verbalCastCode(mob, target, auto),
              L(
                      auto
                          ? "<T-NAME> is filled with a holy charge!"
                          : "^S<S-NAME> " + prayForWord(mob) + " to strike down <T-NAMESELF>!^?")
                  + CMLib.protocol().msp("lightning.wav", 40));
      final CMMsg msg2 =
          CMClass.getMsg(
              mob,
              target,
              this,
              CMMsg.MSK_CAST_MALICIOUS_VERBAL | CMMsg.TYP_ELECTRIC | (auto ? CMMsg.MASK_ALWAYS : 0),
              null);
      if ((R.okMessage(mob, msg)) && ((R.okMessage(mob, msg2)))) {
        R.send(mob, msg);
        R.send(mob, msg2);
        if ((msg.value() <= 0) && (msg2.value() <= 0)) {
          final int harming =
              CMLib.dice().roll(1, adjustedLevel(mob, asLevel), adjustedLevel(mob, asLevel));
          CMLib.combat()
              .postDamage(
                  mob,
                  target,
                  this,
                  harming,
                  CMMsg.MASK_ALWAYS | CMMsg.TYP_ELECTRIC,
                  Weapon.TYPE_STRIKING,
                  L("^SThe STRIKE of @x1 <DAMAGES> <T-NAME>!^?", hisHerDiety(mob)));
        }
      }
    } else
      return maliciousFizzle(mob, target, L("<S-NAME> @x1, but nothing happens.", prayWord(mob)));

    // return whether it worked
    return success;
  }
Exemplo n.º 15
0
  @Override
  public void setMiscText(String txt) {
    super.setMiscText("");
    if (txt.startsWith("-")) {
      txt = txt.substring(1).toLowerCase().trim();
      for (final Object[] A : affects)
        if (((CMObject) A[0]).ID().toLowerCase().equals(txt)) {
          unAffectAffected(A);
          return;
        }
      for (final Object[] A : affects)
        if ((A[0] instanceof Ability)
            && (((Environmental) A[0]).name().toLowerCase().startsWith(txt))) {
          unAffectAffected(A);
          return;
        }
      for (final Object[] A : affects)
        if ((A[0] instanceof Behavior)
            && (((Behavior) A[0]).name().toLowerCase().startsWith(txt))) {
          unAffectAffected(A);
          return;
        }
    } else if (txt.trim().length() > 0) {
      if (txt.startsWith("+")) txt = txt.substring(1);
      else for (final Object[] A : affects) unAffectAffected(A);

      int x = txt.indexOf(' ');
      if (x < 0) return;
      final String abilityStr = txt.substring(0, x).trim();
      String numTicksStr = txt.substring(x + 1).trim();
      String parms = "";
      x = numTicksStr.indexOf(' ');
      if (x > 0) {
        parms = numTicksStr.substring(x + 1).trim();
        numTicksStr = numTicksStr.substring(0, x);
      }
      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) {
        affects.addElement(new Object[] {A, new int[] {CMath.s_int(numTicksStr)}});
        if (A instanceof Ability) ((Ability) A).setMiscText(parms);
        if ((A instanceof Behavior) && (affected instanceof PhysicalAgent))
          ((Behavior) A).setParms(parms);
        finishInit(A);
      }
    }
  }
Exemplo n.º 16
0
  @Override
  public boolean tick(Tickable ticking, int tickID) {
    if ((!built) && (affected instanceof MOB)) {
      built = true;
      CharClass C = null;
      final Vector allowedClasses = new Vector();
      final Vector allowedExpertises = new Vector();
      final Vector<String> V = CMParms.parse(text());
      String s = null;
      for (int v = 0; v < V.size(); v++) {
        s = V.elementAt(v);
        if (s.equalsIgnoreCase("all")) continue;
        C = CMClass.getCharClass(s);
        if (C != null) {
          if ((v > 0) && (V.elementAt(v - 1).equalsIgnoreCase("ALL"))) {
            final String baseClass = C.baseClass();
            for (final Enumeration c = CMClass.charClasses(); c.hasMoreElements(); ) {
              C = (CharClass) c.nextElement();
              if ((C.baseClass().equalsIgnoreCase(baseClass)) && (!allowedClasses.contains(C)))
                allowedClasses.addElement(C);
            }
          } else allowedClasses.addElement(C);
        } else {
          final ExpertiseLibrary.ExpertiseDefinition def = CMLib.expertises().getDefinition(s);
          if (def != null) allowedExpertises.addElement(def);
        }
      }
      if (allowedClasses.size() == 0)
        for (final Enumeration c = CMClass.charClasses(); c.hasMoreElements(); )
          allowedClasses.addElement(c.nextElement());
      if (allowedExpertises.size() == 0)
        for (final Enumeration e = CMLib.expertises().definitions(); e.hasMoreElements(); )
          allowedExpertises.addElement(e.nextElement());

      final MOB mob = (MOB) affected;
      for (int c = 0; c < allowedClasses.size(); c++) {
        C = (CharClass) allowedClasses.elementAt(c);
        addCharClassIfNotFound(mob, C);
      }
      for (int e = 0; e < allowedExpertises.size(); e++)
        mob.addExpertise(
            ((ExpertiseLibrary.ExpertiseDefinition) allowedExpertises.elementAt(e)).ID);
      mob.recoverCharStats();
      mob.recoverPhyStats();
      mob.recoverMaxState();
    }
    return super.tick(ticking, tickID);
  }
Exemplo n.º 17
0
 @Override
 protected Ability getSpell() {
   if (theSpell != null) return theSpell;
   if (mimicSpell().length() == 0) return null;
   theSpell = CMClass.getAbility(mimicSpell());
   return theSpell;
 }
Exemplo n.º 18
0
  public Python() {
    super();
    username = "******";
    setDescription("A humungous snake that is known for squeezing you to DEATH.");
    setDisplayText("A python wants to give you a hug.");
    CMLib.factions().setAlignment(this, Faction.Align.NEUTRAL);
    setMoney(0);

    basePhyStats().setDamage(7);

    baseCharStats().setStat(CharStats.STAT_INTELLIGENCE, 1);

    basePhyStats().setAbility(0);
    basePhyStats().setLevel(1);
    basePhyStats().setArmor(90);

    baseCharStats().setMyRace(CMClass.getRace("Snake"));
    baseCharStats().getMyRace().startRacing(this, false);
    baseState.setHitPoints(CMLib.dice().roll(basePhyStats().level(), 20, basePhyStats().level()));

    recoverMaxState();
    resetToMaxState();
    recoverPhyStats();
    recoverCharStats();
  }
Exemplo n.º 19
0
  public Rabbit() {
    super();
    final Random randomizer = new Random(System.currentTimeMillis());

    username = "******";
    setDescription("It\\`s small, cute, and fluffy with a cute cotton-ball tail.");
    setDisplayText("A rabbit hops by.");
    CMLib.factions().setAlignment(this, Faction.Align.NEUTRAL);
    setMoney(0);
    basePhyStats.setWeight(5 + Math.abs(randomizer.nextInt() % 5));
    setWimpHitPoint(2);

    basePhyStats().setDamage(2);

    baseCharStats().setStat(CharStats.STAT_INTELLIGENCE, 1);
    baseCharStats().setMyRace(CMClass.getRace("Rabbit"));
    baseCharStats().getMyRace().startRacing(this, false);

    basePhyStats().setAbility(0);
    basePhyStats().setLevel(1);
    basePhyStats().setArmor(90);

    baseState.setHitPoints(CMLib.dice().roll(basePhyStats().level(), 20, basePhyStats().level()));

    recoverMaxState();
    resetToMaxState();
    recoverPhyStats();
    recoverCharStats();
  }
Exemplo n.º 20
0
 @Override
 protected Item buildMyPlant(MOB mob, Room room) {
   final int code = material & RawMaterial.RESOURCE_MASK;
   final Item newItem = CMClass.getBasicItem("GenItem");
   final String name =
       CMLib.english().startWithAorAn(RawMaterial.CODES.NAME(code).toLowerCase() + " tree");
   newItem.setName(name);
   newItem.setDisplayText(L("@x1 grows here.", newItem.name()));
   newItem.setDescription("");
   newItem.basePhyStats().setWeight(10000);
   CMLib.flags().setGettable(newItem, false);
   newItem.setMaterial(material);
   newItem.setSecretIdentity(mob.Name());
   newItem.setMiscText(newItem.text());
   room.addItem(newItem);
   final Chant_SummonTree newChant = new Chant_SummonTree();
   newItem.basePhyStats().setLevel(10 + newChant.getX1Level(mob));
   newItem.setExpirationDate(0);
   room.showHappens(
       CMMsg.MSG_OK_ACTION,
       L("a tall, healthy @x1 tree sprouts up.", RawMaterial.CODES.NAME(code).toLowerCase()));
   room.recoverPhyStats();
   newChant.plantsLocationR = room;
   newChant.littlePlantsI = newItem;
   if (CMLib.law().doesOwnThisLand(mob, room)) {
     newChant.setInvoker(mob);
     newChant.setMiscText(mob.Name());
     newItem.addNonUninvokableEffect(newChant);
   } else newChant.beneficialAffect(mob, newItem, 0, (newChant.adjustedLevel(mob, 0) * 240) + 450);
   room.recoverPhyStats();
   return newItem;
 }
Exemplo n.º 21
0
 @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());
     }
   }
 }
Exemplo n.º 22
0
  @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);

    if (success) {

      final CMMsg msg =
          CMClass.getMsg(
              mob,
              target,
              this,
              verbalCastCode(mob, target, auto),
              auto
                  ? L("An anti-plant shell surrounds <T-NAME>!")
                  : L("^S<S-NAME> cast(s) the anti-plant shell around <T-NAMESELF>!^?"));
      if (mob.location().okMessage(mob, msg)) {
        mob.location().send(mob, msg);
        beneficialAffect(mob, target, asLevel, 0);
      }
    } else
      return beneficialWordsFizzle(
          mob, target, L("<S-NAME> cast(s) a shell at <T-NAMESELF>, but the magic fizzles."));

    // return whether it worked
    return success;
  }
Exemplo n.º 23
0
  @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);
    if (success) {
      final CMMsg msg =
          CMClass.getMsg(
              mob,
              target,
              this,
              verbalCastCode(mob, target, auto),
              auto ? "" : L("^S<S-NAME> whistle(s) to <T-NAMESELF>.^?"));
      if (mob.location().okMessage(mob, msg)) {
        mob.location().send(mob, msg);
        mob.location()
            .show(target, null, CMMsg.MSG_OK_VISUAL, L("<S-NAME> attain(s) an aquatic aura!"));
        beneficialAffect(mob, target, asLevel, 0);
      }
    } else
      beneficialWordsFizzle(
          mob, target, L("<S-NAME> whistle(s) to <T-NAMESELF>, but nothing happens."));

    return success;
  }
Exemplo n.º 24
0
  @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 true;

    final MOB mob = (MOB) affected;
    if ((!mob.amDead()) && ((--diseaseTick) <= 0)) {
      diseaseTick = DISEASE_DELAY();
      if (mob.maxState().getFatigue() > Long.MIN_VALUE / 2)
        mob.curState()
            .adjFatigue(mob.curState().getFatigue() + CharState.FATIGUED_MILLIS, mob.maxState());
      mob.location().show(mob, null, CMMsg.MSG_NOISE, DISEASE_AFFECT());
      if (!CMLib.flags().isSleeping(mob)) {
        final Command C = CMClass.getCommand("Sleep");
        try {
          if (C != null) C.execute(mob, CMParms.parse("Sleep"), Command.METAFLAG_FORCED);
        } catch (final Exception e) {
        }
      }
      return true;
    }
    return true;
  }
Exemplo n.º 25
0
  public Panther() {
    super();
    final Random randomizer = new Random(System.currentTimeMillis());

    username = "******";
    setDescription(
        "A powerful cat with a deep chest and muscular limbs, covered in midnight black fur.");
    setDisplayText("A panther slowly stalks prey.");
    CMLib.factions().setAlignment(this, Faction.Align.NEUTRAL);
    setMoney(0);
    basePhyStats.setWeight(20 + Math.abs(randomizer.nextInt() % 45));
    setWimpHitPoint(2);

    basePhyStats.setWeight(200 + Math.abs(randomizer.nextInt() % 55));

    baseCharStats().setStat(CharStats.STAT_INTELLIGENCE, 1);
    baseCharStats().setStat(CharStats.STAT_STRENGTH, 12);
    baseCharStats().setStat(CharStats.STAT_DEXTERITY, 17);
    baseCharStats().setMyRace(CMClass.getRace("GreatCat"));
    baseCharStats().getMyRace().startRacing(this, false);

    basePhyStats().setDamage(8);
    basePhyStats().setSpeed(2.0);
    basePhyStats().setAbility(0);
    basePhyStats().setLevel(4);
    basePhyStats().setArmor(80);

    baseState.setHitPoints(CMLib.dice().roll(basePhyStats().level(), 20, basePhyStats().level()));

    recoverMaxState();
    resetToMaxState();
    recoverPhyStats();
    recoverCharStats();
  }
Exemplo n.º 26
0
  public boolean invoke(
      MOB mob, Vector commands, Environmental givenTarget, boolean auto, int asLevel) {
    MOB target = getTarget(mob, commands, givenTarget);
    if (target == null) 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,
              target,
              this,
              verbalCastCode(mob, target, auto),
              auto
                  ? "<T-NAME> feel(s) magically protected."
                  : "^S<S-NAME> invoke(s) an absorbing barrier of protection around <T-NAMESELF>.^?");
      if (mob.location().okMessage(mob, msg)) {
        mob.location().send(mob, msg);
        beneficialAffect(mob, target, asLevel, 0);
      }
    } else
      beneficialWordsFizzle(
          mob, target, "<S-NAME> attempt(s) to invoke an absorbing barrier, but fail(s).");

    return success;
  }
Exemplo n.º 27
0
  @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;

    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> chant(s) to <T-NAMESELF>.^?"));
      if (mob.location().okMessage(mob, msg)) {
        mob.location().send(mob, msg);
        mob.location()
            .show(target, null, CMMsg.MSG_OK_VISUAL, L("<S-NAME> seem(s) strangely fertile!"));
        beneficialAffect(mob, target, asLevel, Ability.TICKS_ALMOST_FOREVER);
      }
    } else
      return beneficialWordsFizzle(
          mob, target, L("<S-NAME> chant(s) to <T-NAMESELF>, but the magic fades."));

    // return whether it worked
    return success;
  }
Exemplo n.º 28
0
  @Override
  public boolean invoke(MOB mob, Vector commands, Physical givenTarget, boolean auto, int asLevel) {
    final MOB target = this.getTarget(mob, commands, givenTarget);
    if (target == null) return false;

    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> incant(s) at <T-NAMESELF>.^?"));
      if (mob.location().okMessage(mob, msg)) {
        mob.location().send(mob, msg);
        if (msg.value() <= 0) {
          mob.location().show(target, null, CMMsg.MSG_OK_VISUAL, L("<S-NAME> get(s) sick!"));
          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;
  }
Exemplo n.º 29
0
  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;
          }
        }
      }
    }
  }
Exemplo n.º 30
0
 public void makePuddle(Room R, int oldWeather, int newWeather) {
   for (int i = 0; i < R.numItems(); i++) {
     final Item I = R.getItem(i);
     if ((I instanceof Drink)
         && (!CMLib.flags().isGettable(I))
         && ((I.name().toLowerCase().indexOf("puddle") >= 0)
             || (I.name().toLowerCase().indexOf("snow") >= 0))) return;
   }
   final Item I = CMClass.getItem("GenLiquidResource");
   CMLib.flags().setGettable(I, false);
   ((Drink) I).setLiquidHeld(100);
   ((Drink) I).setLiquidRemaining(100);
   ((Drink) I).setLiquidType(RawMaterial.RESOURCE_FRESHWATER);
   I.setMaterial(RawMaterial.RESOURCE_FRESHWATER);
   I.basePhyStats().setDisposition(I.basePhyStats().disposition() | PhyStats.IS_UNSAVABLE);
   CMLib.materials().addEffectsToResource(I);
   I.recoverPhyStats();
   if (coldWetWeather(oldWeather)) {
     I.setName(L("some snow"));
     I.setDisplayText(L("some snow rests on the ground here."));
     I.setDescription(L("the snow is white and still quite cold!"));
   } else {
     I.setName(L("a puddle of water"));
     I.setDisplayText(L("a puddle of water has formed here."));
     I.setDescription(L("It looks drinkable."));
   }
   R.addItem(I, ItemPossessor.Expire.Monster_EQ);
   R.recoverRoomStats();
 }