コード例 #1
0
  @Override
  public boolean okMessage(final Environmental myHost, final CMMsg msg) {
    if ((affected instanceof MOB)
        && (msg.amISource((MOB) affected))
        && (msg.targetMinor() == CMMsg.TYP_DAMAGE)
        && (msg.tool() instanceof Weapon)
        && (msg.value() > 0)
        && (msg.target() instanceof MOB)
        && (((Weapon) msg.tool()).weaponClassification() == Weapon.CLASS_THROWN)) {
      if (CMLib.dice().rollPercentage() < 25) helpProficiency((MOB) affected, 0);
      final CMMsg msg2 =
          CMClass.getMsg(
              (MOB) msg.target(),
              msg.tool(),
              this,
              CMMsg.MSG_OK_VISUAL,
              L("^F^<FIGHT^><T-NAME> fragment(s) in <S-NAME>!^</FIGHT^>^?"));
      CMLib.color().fixSourceFightColor(msg2);
      msg.addTrailerMsg(msg2);
      msg.setValue(
          msg.value()
              + (int)
                  Math.round(
                      CMath.mul(
                          3.0 * msg.value(),
                          CMath.div(proficiency(), 100.0 - (10.0 * getXLEVELLevel(invoker()))))));
    }

    return super.okMessage(myHost, msg);
  }
コード例 #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;
  }
コード例 #3
0
ファイル: Spell_IceLance.java プロジェクト: kingdavid127/MUD
  @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;
  }
コード例 #4
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;
    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;
  }
コード例 #5
0
ファイル: Spell_AcidSpray.java プロジェクト: kingdavid127/MUD
  @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;
  }
コード例 #6
0
ファイル: Prayer_Drain.java プロジェクト: renokun/CoffeeMud
  @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;
  }
コード例 #7
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;
  }
コード例 #8
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) {
      invoker = mob;
      final CMMsg msg =
          CMClass.getMsg(
              mob,
              target,
              this,
              verbalCastCode(mob, target, auto),
              auto ? "" : L("^S<S-NAME> incant(s) to <T-NAMESELF>.^?"));
      if (mob.location().okMessage(mob, msg)) {
        mob.location().send(mob, msg);
        if (msg.value() <= 0) {
          target
              .curState()
              .adjThirst(
                  -150 - ((mob.phyStats().level() + (2 * getXLEVELLevel(mob))) * 100),
                  target.maxState().maxThirst(target.baseWeight()));
          mob.location()
              .show(target, null, CMMsg.MSG_OK_VISUAL, L("<S-NAME> feel(s) incredibly thirsty!"));
        }
      }
    } else
      return maliciousFizzle(
          mob, target, L("<S-NAME> incant(s) to <T-NAMESELF>, but the spell fades."));
    // return whether it worked
    return success;
  }
コード例 #9
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;
  }
コード例 #10
0
  @Override
  public boolean invoke(
      MOB mob, List<String> commands, Physical givenTarget, boolean auto, int asLevel) {
    MOB target = null;
    Ability reAffect = null;
    if (mob.isInCombat()) {
      if (mob.rangeToTarget() > 0) {
        mob.tell(L("You are too far away to touch!"));
        return false;
      }
      final MOB victim = mob.getVictim();
      reAffect = victim.fetchEffect("Undead_WeakEnergyDrain");
      if (reAffect == null) reAffect = victim.fetchEffect("Undead_EnergyDrain");
      if (reAffect != null) target = victim;
    }
    if (target == null) 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);

    String str = null;
    if (success) {
      str = auto ? "" : L("^S<S-NAME> extend(s) an energy draining hand to <T-NAMESELF>!^?");
      final CMMsg msg =
          CMClass.getMsg(
              mob,
              target,
              this,
              CMMsg.MSK_MALICIOUS_MOVE | CMMsg.TYP_UNDEAD | (auto ? CMMsg.MASK_ALWAYS : 0),
              str);
      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> <S-IS-ARE> drained!"));
          if (reAffect != null) {
            if (reAffect instanceof Undead_EnergyDrain)
              ((Undead_EnergyDrain) reAffect).levelsDown++;
            ((StdAbility) reAffect)
                .setTickDownRemaining(
                    ((StdAbility) reAffect).getTickDownRemaining() + mob.phyStats().level());
            mob.recoverPhyStats();
            mob.recoverCharStats();
            mob.recoverMaxState();
          } else {
            direction = 1;
            if (target.charStats().getMyRace().racialCategory().equalsIgnoreCase("Undead"))
              direction = -1;
            success = maliciousAffect(mob, target, asLevel, 0, -1) != null;
          }
        }
      }
    } else
      return maliciousFizzle(
          mob, target, L("<S-NAME> attempt(s) to drain <T-NAMESELF>, but fail(s)."));

    return success;
  }
コード例 #11
0
 @Override
 public void executeMsg(final Environmental myHost, final CMMsg msg) {
   super.executeMsg(myHost, msg);
   if ((msg.source().location() != null)
       && (msg.targetMinor() == CMMsg.TYP_DAMAGE)
       && ((msg.value()) > 0)
       && (msg.tool() == this)
       && (msg.target() instanceof MOB)
       && (!((MOB) msg.target()).amDead())
       && (CMLib.flags().isEvil((MOB) msg.target()))) {
     final CMMsg msg2 =
         CMClass.getMsg(
             msg.source(),
             msg.target(),
             new HolyAvenger(),
             CMMsg.MSG_OK_ACTION,
             CMMsg.MSK_MALICIOUS_MOVE | CMMsg.TYP_UNDEAD,
             CMMsg.MSG_NOISYMOVEMENT,
             null);
     if (msg.source().location().okMessage(msg.source(), msg2)) {
       msg.source().location().send(msg.source(), msg2);
       int damage = CMLib.dice().roll(1, 15, 0);
       if (msg.value() > 0) damage = damage / 2;
       msg.addTrailerMsg(
           CMClass.getMsg(
               msg.source(),
               msg.target(),
               CMMsg.MSG_OK_ACTION,
               L(
                   "@x1 dispels evil within <T-NAME> and @x2 <T-HIM-HER>>!",
                   name(),
                   CMLib.combat().standardHitWord(Weapon.TYPE_BURSTING, damage))));
       final CMMsg msg3 =
           CMClass.getMsg(
               msg.source(),
               msg.target(),
               null,
               CMMsg.MSG_OK_VISUAL,
               CMMsg.MSG_DAMAGE,
               CMMsg.NO_EFFECT,
               null);
       msg3.setValue(damage);
       msg.addTrailerMsg(msg3);
     }
   }
 }
コード例 #12
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 (target.charStats().getBodyPart(Race.BODY_FOOT) == 0) {
      mob.tell(L("@x1 has no feet!", target.name(mob)));
      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) | CMMsg.MASK_MALICIOUS,
              auto ? "" : L("^S<S-NAME> chant(s) at <T-YOUPOSS> feet!^?"));
      final CMMsg msg2 =
          CMClass.getMsg(
              mob, target, this, verbalCastMask(mob, target, auto) | CMMsg.TYP_DISEASE, null);
      if ((mob.location().okMessage(mob, msg)) && (mob.location().okMessage(mob, msg2))) {
        mob.location().send(mob, msg);
        mob.location().send(mob, msg2);
        if ((msg.value() <= 0) && (msg2.value() <= 0)) {
          invoker = mob;
          maliciousAffect(mob, target, asLevel, Ability.TICKS_ALMOST_FOREVER, -1);
          mob.location()
              .show(
                  target,
                  null,
                  CMMsg.MSG_OK_VISUAL,
                  L("A fungus sprouts up between <S-YOUPOSS> toes!"));
        } else spreadImmunity(target);
      }
    } else
      return maliciousFizzle(
          mob, target, L("<S-NAME> chant(s) at <T-YOUPOSS> feet, but nothing happens."));

    // return whether it worked
    return success;
  }
コード例 #13
0
ファイル: Shaman.java プロジェクト: bbailey/ewok
  public boolean okMessage(Environmental myHost, CMMsg msg) {
    if (!(myHost instanceof MOB)) return super.okMessage(myHost, msg);
    MOB myChar = (MOB) myHost;
    if (!super.okMessage(myChar, msg)) return false;

    if ((msg.amITarget(myChar))
        && (msg.targetMinor() == CMMsg.TYP_DAMAGE)
        && (msg.sourceMinor() == CMMsg.TYP_ACID)) {
      int recovery = myChar.charStats().getClassLevel(this);
      msg.setValue(msg.value() - recovery);
    } else if ((msg.amITarget(myChar))
        && (msg.targetMinor() == CMMsg.TYP_DAMAGE)
        && (msg.sourceMinor() == CMMsg.TYP_ELECTRIC)) {
      int recovery = msg.value();
      msg.setValue(msg.value() + recovery);
    }
    return true;
  }
コード例 #14
0
  @Override
  public boolean invoke(MOB mob, Vector commands, Physical givenTarget, boolean auto, int asLevel) {
    if (!super.invoke(mob, commands, givenTarget, auto, asLevel)) return false;

    final boolean success = proficiencyCheck(mob, 0, auto);
    final String str =
        auto
            ? L("The unholy word is spoken.")
            : L("^S<S-NAME> speak(s) the unholy word@x1 to <T-NAMESELF>.^?", ofDiety(mob));

    final Room room = mob.location();
    if (room != null)
      for (int i = 0; i < room.numInhabitants(); i++) {
        final MOB target = room.fetchInhabitant(i);
        if (target == null) break;
        int affectType = CMMsg.MSG_CAST_VERBAL_SPELL;
        if (auto) affectType = affectType | CMMsg.MASK_ALWAYS;
        if (CMLib.flags().isGood(target)) affectType = affectType | CMMsg.MASK_MALICIOUS;

        if (success) {
          final CMMsg msg = CMClass.getMsg(mob, target, this, affectType, str);
          if (room.okMessage(mob, msg)) {
            room.send(mob, msg);
            if (msg.value() <= 0) {
              if (CMLib.flags().canBeHeardSpeakingBy(mob, target)) {
                final Item I = Prayer_Curse.getSomething(mob, true);
                if (I != null) {
                  Prayer_Curse.endLowerBlessings(I, CMLib.ableMapper().lowestQualifyingLevel(ID()));
                  I.recoverPhyStats();
                }
                Prayer_Curse.endLowerBlessings(
                    target, CMLib.ableMapper().lowestQualifyingLevel(ID()));
                beneficialAffect(mob, target, asLevel, 0);
                target.recoverPhyStats();
              } else if (CMath.bset(affectType, CMMsg.MASK_MALICIOUS))
                maliciousFizzle(mob, target, L("<T-NAME> did not hear the unholy word!"));
              else beneficialWordsFizzle(mob, target, L("<T-NAME> did not hear the unholy word!"));
            }
          }
        } else {
          if (CMath.bset(affectType, CMMsg.MASK_MALICIOUS))
            maliciousFizzle(
                mob,
                target,
                L("<S-NAME> attempt(s) to speak the unholy word to <T-NAMESELF>, but flub(s) it."));
          else
            beneficialWordsFizzle(
                mob,
                target,
                L("<S-NAME> attempt(s) to speak the unholy word to <T-NAMESELF>, but flub(s) it."));
          return false;
        }
      }

    // return whether it worked
    return success;
  }
コード例 #15
0
ファイル: StdLasso.java プロジェクト: carriercomm/CoffeeMud
 @Override
 public boolean okMessage(final Environmental myHost, final CMMsg msg) {
   if (!super.okMessage(myHost, msg)) return false;
   if ((msg.tool() == this)
       && (msg.targetMinor() == CMMsg.TYP_DAMAGE)
       && (msg.value() > 0)
       && (msg.target() != null)
       && (msg.target() instanceof MOB)
       && (weaponClassification() == Weapon.CLASS_THROWN)) {
     msg.setValue(0);
   }
   return true;
 }
コード例 #16
0
 @Override
 public boolean okMessage(Environmental host, CMMsg msg) {
   if (msg.amITarget(this)) {
     switch (msg.targetMinor()) {
       case CMMsg.TYP_ACTIVATE:
         if (!isInstalled()) {
           if (!CMath.bset(msg.targetMajor(), CMMsg.MASK_CNTRLMSG))
             msg.source().tell(L("@x1 is not installed or connected.", name()));
           return false;
         } else if (!isAllWiringHot(this)) {
           if (!CMath.bset(msg.targetMajor(), CMMsg.MASK_CNTRLMSG))
             msg.source()
                 .tell(L("The panel containing @x1 is not activated or connected.", name()));
           return false;
         }
         break;
       case CMMsg.TYP_DEACTIVATE:
         break;
       case CMMsg.TYP_LOOK:
         break;
       case CMMsg.TYP_POWERCURRENT:
         if ((!(this instanceof FuelConsumer))
             && (!(this instanceof PowerGenerator))
             && activated()
             && (powerNeeds() > 0)
             && (msg.value() > 0)) {
           double amtToTake = Math.min((double) powerNeeds(), (double) msg.value());
           msg.setValue(msg.value() - (int) Math.round(amtToTake));
           amtToTake *= getFinalManufacturer().getEfficiencyPct();
           if (subjectToWearAndTear() && (usesRemaining() <= 200))
             amtToTake *= CMath.div(usesRemaining(), 100.0);
           setPowerRemaining(Math.min(powerCapacity(), Math.round(amtToTake) + powerRemaining()));
         }
         break;
     }
   }
   return super.okMessage(host, msg);
 }
コード例 #17
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) {

      final CMMsg msg =
          CMClass.getMsg(
              mob,
              target,
              this,
              verbalCastCode(mob, target, auto) | CMMsg.MASK_MALICIOUS,
              auto
                  ? L("<T-NAME> become(s) contagious!")
                  : L("^S<S-NAME> @x1 for a contagion to inflict <T-NAMESELF>.^?", prayWord(mob)));
      final CMMsg msg2 =
          CMClass.getMsg(mob, target, this, CMMsg.TYP_DISEASE | CMMsg.MASK_MALICIOUS, null);
      if ((mob.location().okMessage(mob, msg)) && (mob.location().okMessage(mob, msg2))) {
        mob.location().send(mob, msg);
        mob.location().send(mob, msg2);
        if ((msg.value() <= 0) && (msg2.value() <= 0))
          success = maliciousAffect(mob, target, asLevel, 0, -1) != null;
        else spreadImmunity(target);
      }
    } 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;
  }
コード例 #18
0
  @Override
  public boolean invoke(MOB mob, Vector commands, Physical givenTarget, boolean auto, int asLevel) {
    final Room target = mob.location();
    if (target == null) return false;
    if ((target.getArea().getTimeObj().getTODCode() != TimeClock.TimeOfDay.DUSK)
        && (target.getArea().getTimeObj().getTODCode() != TimeClock.TimeOfDay.NIGHT)) {
      mob.tell(L("You can only start this chant at night."));
      return false;
    }
    if ((target.domainType() & Room.INDOORS) > 0) {
      mob.tell(L("This chant only works outdoors."));
      return false;
    }

    if (target.fetchEffect(ID()) != null) {
      mob.tell(L("This place is already under the piercing moon."));
      return false;
    }

    if (!super.invoke(mob, commands, givenTarget, auto, asLevel)) return false;
    final 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> chant(s) to the sky.^?"));
      if (mob.location().okMessage(mob, msg)) {
        mob.location().send(mob, msg);
        if (msg.value() <= 0) {
          if (!mob.location().getArea().getClimateObj().canSeeTheStars(mob.location()))
            mob.location()
                .showHappens(CMMsg.MSG_OK_VISUAL, L("The Moon pierces through the clouds!"));
          else mob.location().showHappens(CMMsg.MSG_OK_VISUAL, L("The Moon brightens!"));
          beneficialAffect(mob, target, asLevel, 0);
        }
      }
    } else
      return maliciousFizzle(mob, target, L("<S-NAME> chant(s) to the sky, but the magic fades."));
    // return whether it worked
    return success;
  }
コード例 #19
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.MASK_MALICIOUS | verbalCastCode(mob, target, auto),
              L(
                  auto
                      ? "A light fatigue overcomes <T-NAME>."
                      : "^S<S-NAME> "
                          + prayWord(mob)
                          + " for extreme fatigue to overcome <T-NAMESELF>!^?"));
      if (mob.location().okMessage(mob, msg)) {
        mob.location().send(mob, msg);
        if (msg.value() <= 0) {
          final int harming = CMLib.dice().roll(10, adjustedLevel(mob, asLevel), 50);
          if ((target.curState().getFatigue() <= CharState.FATIGUED_MILLIS)
              && (target.maxState().getFatigue() > Long.MIN_VALUE / 2))
            target.curState().setFatigue(CharState.FATIGUED_MILLIS + 1);
          target.curState().adjMovement(-harming, target.maxState());
          target.tell(L("You feel fatigued!"));
        }
      }
    } 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;
  }
コード例 #20
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 ((!target.charStats().getMyRace().racialCategory().equals("Earth Elemental"))
        && (!target.charStats().getMyRace().racialCategory().equals("Stone Golem"))
        && (!target.charStats().getMyRace().racialCategory().equals("Metal Golem"))) {
      mob.tell(L("@x1 is not an stone/metal golem or earth elemental!", target.name(mob)));
      return false;
    }

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

    // now see if it worked
    boolean success = proficiencyCheck(mob, 0, auto);
    if (success) {
      final String str = auto ? "" : L("^S<S-NAME> chant(s) at <T-NAMESELF>.^?");
      final CMMsg msg = CMClass.getMsg(mob, target, this, verbalCastCode(mob, target, auto), str);
      if (mob.location().okMessage(mob, msg)) {
        mob.location().send(mob, msg);
        if (msg.value() <= 0) {
          success = maliciousAffect(mob, target, asLevel, 0, -1) != null;
          if (success) {
            if (target.isInCombat()) target.makePeace();
            CMLib.commands().postFollow(target, mob, false);
            CMLib.combat().makePeaceInGroup(mob);
            if (target.amFollowing() != mob)
              mob.tell(L("@x1 seems unwilling to follow you.", target.name(mob)));
          }
        }
      }
    }
    if (!success)
      return maliciousFizzle(
          mob, target, L("<S-NAME> chant(s) at <T-NAMESELF>, but nothing happens."));

    // return whether it worked
    return success;
  }
コード例 #21
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,
              somanticCastCode(mob, target, auto),
              L(auto ? "" : "^S<S-NAME> point(s) at <T-NAMESELF> and shout(s)!^?"));
      if (mob.location().okMessage(mob, msg)) {
        mob.location().send(mob, msg);
        invoker = mob;
        if (msg.value() > 0) {
          target
              .location()
              .show(target, null, CMMsg.MSG_OK_VISUAL, L("<T-NAME> become(s) exhausted!"));
          target.curState().setMovement(0);
          if (target.maxState().getFatigue() > Long.MIN_VALUE / 2)
            target
                .curState()
                .setFatigue(target.curState().getFatigue() + CharState.FATIGUED_MILLIS);
        }
      }
    } else
      return maliciousFizzle(
          mob,
          target,
          L("<S-NAME> point(s) and shout(s) at <T-NAMESELF>, but nothing more happens."));

    return success;
  }
コード例 #22
0
  @Override
  public boolean okMessage(final Environmental myHost, final CMMsg msg) {
    if (!super.okMessage(myHost, msg)) return false;

    if (!(affected instanceof MOB)) return true;

    final MOB mob = (MOB) affected;
    if ((msg.amITarget(mob))
        && (msg.sourceMinor() == CMMsg.TYP_FIRE)
        && (msg.targetMinor() == CMMsg.TYP_DAMAGE)) {
      final int recovery = (int) Math.round(CMath.div((msg.value()), 2.0));
      mob.location()
          .show(
              mob,
              null,
              CMMsg.MSG_OK_VISUAL,
              L("The flame attack heals <S-NAME> @x1 points.", "" + recovery));
      CMLib.combat()
          .postHealing(mob, mob, this, recovery, CMMsg.MASK_ALWAYS | CMMsg.TYP_CAST_SPELL, null);
      return false;
    }
    return true;
  }
コード例 #23
0
ファイル: Spell_Slow.java プロジェクト: bozimmerman/CoffeeMud
  @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;
    Room R = CMLib.map().roomLocation(target);
    if (R == null) R = mob.location();

    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> cast(s) a spell on <T-NAMESELF>.^?"));
      if (R.okMessage(mob, msg)) {
        R.send(mob, msg);
        if (msg.value() <= 0) {
          R.show(target, null, CMMsg.MSG_OK_VISUAL, L("<S-NAME> slow(s) down!"));
          final Ability A = target.fetchEffect("Spell_MassSlow");
          if (A != null) A.unInvoke();
          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;
  }
コード例 #24
0
  @Override
  public boolean invoke(MOB mob, Vector commands, Physical givenTarget, boolean auto, int asLevel) {
    if (mob.isInCombat() && (mob.rangeToTarget() > 0)) {
      mob.tell(L("You are too far away to touch!"));
      return false;
    }
    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);

    String str = null;
    if (success) {
      str = auto ? "" : L("^S<S-NAME> extend(s) a chilling hand to <T-NAMESELF>!^?");
      final CMMsg msg =
          CMClass.getMsg(
              mob,
              target,
              this,
              CMMsg.MSK_MALICIOUS_MOVE | CMMsg.TYP_UNDEAD | (auto ? CMMsg.MASK_ALWAYS : 0),
              str);
      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> turn(s) cold!"));
          success = maliciousAffect(mob, target, asLevel, 0, -1) != null;
        }
      }
    } else
      return maliciousFizzle(
          mob, target, L("<S-NAME> extend(s) a chilling hand to <T-NAMESELF>, but fail(s)."));

    return success;
  }
コード例 #25
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;

    int levelDiff =
        target.phyStats().level() - (mob.phyStats().level() + (2 * getXLEVELLevel(mob)));
    if (levelDiff < 0) levelDiff = 0;
    final boolean success = proficiencyCheck(mob, -(levelDiff * 25), auto);
    Item Bread = null;
    Item BreadContainer = null;
    for (int i = 0; i < target.numItems(); i++) {
      final Item I = target.getItem(i);
      if ((I != null) && (I instanceof Food)) {
        if (I.container() != null) {
          Bread = I;
          BreadContainer = I.container();
        } else {
          Bread = I;
          BreadContainer = null;
          break;
        }
      }
    }
    if ((Bread != null) && (BreadContainer != null))
      CMLib.commands().postGet(target, BreadContainer, Bread, false);
    if (Bread == null) {
      final ShopKeeper SK = CMLib.coffeeShops().getShopKeeper(target);
      if (SK != null) {
        for (final Iterator<Environmental> i = SK.getShop().getStoreInventory(); i.hasNext(); ) {
          final Environmental E2 = i.next();
          if ((E2 != null) && (E2 instanceof Food)) {
            Bread = (Item) E2.copyOf();
            target.addItem(Bread);
            break;
          }
        }
      }
    }
    if ((success) && (Bread != null)) {
      CMMsg msg =
          CMClass.getMsg(
              mob,
              target,
              this,
              verbalCastCode(mob, target, auto),
              L(
                  "^S<S-NAME> @x1 for <T-NAMESELF> to provide <S-HIS-HER> daily bread!^?",
                  prayWord(mob)));
      final CMMsg msg2 =
          CMClass.getMsg(
              mob,
              target,
              this,
              CMMsg.MSK_CAST_MALICIOUS_VERBAL | CMMsg.TYP_MIND | (auto ? CMMsg.MASK_ALWAYS : 0),
              null);
      if ((mob.location().okMessage(mob, msg)) && (mob.location().okMessage(mob, msg2))) {
        mob.location().send(mob, msg);
        mob.location().send(mob, msg2);
        if ((msg.value() <= 0) && (msg2.value() <= 0)) {
          msg =
              CMClass.getMsg(
                  target,
                  mob,
                  Bread,
                  CMMsg.MSG_GIVE,
                  L("<S-NAME> gladly donate(s) <O-NAME> to <T-NAMESELF>."));
          if (mob.location().okMessage(mob, msg)) mob.location().send(mob, msg);
        }
      }
    } else
      maliciousFizzle(
          mob,
          target,
          auto
              ? ""
              : L(
                  "<S-NAME> @x1 for <T-NAMESELF> to provide <S-HIS-HER> daily bread, but nothing happens.",
                  prayWord(mob)));

    // return whether it worked
    return success;
  }
コード例 #26
0
  @Override
  public boolean invoke(MOB mob, Vector commands, Physical givenTarget, boolean auto, int asLevel) {
    if ((!auto) && (!(CMLib.flags().isGood(mob)))) {
      mob.tell(L("Your alignment has alienated you from your god."));
      return false;
    }
    final List<String> V = new Vector<String>();
    if (commands.size() > 0) {
      V.add((String) commands.elementAt(0));
      commands.removeElementAt(0);
    }

    final MOB target = getTarget(mob, V, givenTarget);
    if (target == null) return false;

    if (commands.size() == 0) {
      if (mob.isMonster()) commands.addElement("FLEE");
      else {
        if (V.size() > 0) mob.tell(L("Command @x1 to do what?", V.get(0)));
        return false;
      }
    }

    if (!target.charStats().getMyRace().racialCategory().equals("Equine")) {
      mob.tell(L("@x1 is not a horse!", target.name(mob)));
      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,
              verbalSpeakCode(mob, target, auto),
              auto
                  ? ""
                  : L(
                      "^S<S-NAME> command(s) <T-NAMESELF> to '@x1'.^?",
                      CMParms.combine(commands, 0)));
      final CMMsg msg2 =
          CMClass.getMsg(
              mob,
              target,
              this,
              CMMsg.MASK_MALICIOUS
                  | CMMsg.MASK_SOUND
                  | CMMsg.TYP_MIND
                  | (auto ? CMMsg.MASK_ALWAYS : 0),
              null);
      final CMMsg omsg = CMClass.getMsg(mob, target, null, CMMsg.MSG_ORDER, null);
      if ((mob.location().okMessage(mob, msg))
          && ((mob.location().okMessage(mob, msg2)))
          && (mob.location().okMessage(mob, omsg))) {
        mob.location().send(mob, msg);
        if (msg.value() <= 0) {
          mob.location().send(mob, msg2);
          mob.location().send(mob, omsg);
          if ((msg2.value() <= 0) && (omsg.sourceMinor() == CMMsg.TYP_ORDER)) {
            invoker = mob;
            target.makePeace();
            target.enqueCommand(commands, Command.METAFLAG_FORCED | Command.METAFLAG_ORDER, 0);
          }
        }
      }
    } else
      return maliciousFizzle(
          mob,
          target,
          L("<S-NAME> attempt(s) to command <T-NAMESELF>, but it definitely didn't work."));

    // return whether it worked
    return success;
  }
コード例 #27
0
ファイル: Chant_WarpWood.java プロジェクト: kingdavid127/MUD
  @Override
  public boolean invoke(MOB mob, Vector commands, Physical givenTarget, boolean auto, int asLevel) {
    final MOB mobTarget = getTarget(mob, commands, givenTarget, true, false);
    Item target = getPossibility(mobTarget);
    if (target == null)
      target = getTarget(mob, mob.location(), givenTarget, commands, Wearable.FILTER_ANY);
    if (target == null) return false;
    if (((target.material() & RawMaterial.MATERIAL_MASK) != RawMaterial.MATERIAL_WOODEN)
        || (!target.subjectToWearAndTear())) {
      mob.tell(L("That can't be warped."));
      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> starts warping!") : L("^S<S-NAME> chant(s) at <T-NAMESELF>.^?"));
      final CMMsg msg2 =
          CMClass.getMsg(mob, mobTarget, this, verbalCastCode(mob, mobTarget, auto), null);
      if ((mob.location().okMessage(mob, msg))
          && ((mobTarget == null) || (mob.location().okMessage(mob, msg2)))) {
        mob.location().send(mob, msg);
        if (mobTarget != null) mob.location().send(mob, msg2);
        if (msg.value() <= 0) {
          int damage =
              100
                  + (mob.phyStats().level() + (2 * super.getXLEVELLevel(mob)))
                  - target.phyStats().level();
          if (CMLib.flags().isABonusItems(target))
            damage = (int) Math.round(CMath.div(damage, 2.0));
          target.setUsesRemaining(target.usesRemaining() - damage);
          if (mobTarget == null)
            mob.location()
                .show(mob, target, CMMsg.MSG_OK_VISUAL, L("<T-NAME> begin(s) to twist and warp!"));
          else
            mob.location()
                .show(
                    mobTarget,
                    target,
                    CMMsg.MSG_OK_VISUAL,
                    L("<T-NAME>, possessed by <S-NAME>, twists and warps!"));
          if (target.usesRemaining() > 0) target.recoverPhyStats();
          else {
            target.setUsesRemaining(100);
            mob.location().show(mob, target, CMMsg.MSG_OK_VISUAL, L("<T-NAME> is destroyed!"));
            target.unWear();
            target.destroy();
            mob.location().recoverRoomStats();
          }
        }
      }
    } else return maliciousFizzle(mob, null, L("<S-NAME> chant(s), but nothing happens."));

    // return whether it worked
    return success;
  }
コード例 #28
0
ファイル: Spell_Scatter.java プロジェクト: kingdavid127/MUD
  @Override
  public boolean invoke(MOB mob, Vector commands, Physical givenTarget, boolean auto, int asLevel) {
    final Vector areas = new Vector();
    if (commands.size() == 0) areas.addElement(mob.location().getArea());
    else if (((String) commands.lastElement()).equalsIgnoreCase("far")) {
      commands.removeElementAt(commands.size() - 1);
      for (final Enumeration e = CMLib.map().areas(); e.hasMoreElements(); )
        areas.addElement(e.nextElement());
    } else if (((String) commands.lastElement()).equalsIgnoreCase("near")) {
      commands.removeElementAt(commands.size() - 1);
      areas.addElement(mob.location().getArea());
    } else areas.addElement(mob.location().getArea());
    final MOB mobTarget = getTarget(mob, commands, givenTarget, true, false);
    Item target = null;
    if (mobTarget != null) {
      target = getItem(mobTarget);
      if (target == null)
        return maliciousFizzle(
            mob,
            mobTarget,
            L("<S-NAME> attempt(s) a scattering spell at <T-NAMESELF>, but nothing happens."));
    }

    List<Item> targets = new Vector();
    if (givenTarget instanceof Item) targets.add((Item) givenTarget);
    else if (target != null) targets.add(target);
    else {
      targets = CMLib.english().fetchItemList(mob, mob, null, commands, Wearable.FILTER_ANY, true);
      if (targets.size() == 0) mob.tell(L("You don't seem to be carrying that."));
    }

    if (targets.size() == 0) return false;

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

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

    if (success) {
      String str = null;
      if (mobTarget == null)
        str =
            auto
                ? L("<S-NAME> <S-IS-ARE> enveloped in a scattering field!")
                : L("^S<S-NAME> utter(s) a scattering spell!^?");
      else
        str =
            auto
                ? L("<T-NAME> <T-IS-ARE> enveloped in a scattering field!")
                : L("^S<S-NAME> utter(s) a scattering spell, causing <T-NAMESELF> to resonate.^?");
      CMMsg msg = CMClass.getMsg(mob, mobTarget, this, verbalCastCode(mob, target, auto), str);
      if (mob.location().okMessage(mob, msg)) {
        mob.location().send(mob, msg);
        if (msg.value() <= 0) {
          for (int i = 0; i < targets.size(); i++) {
            target = targets.get(i);
            msg = CMClass.getMsg(mob, target, this, verbalCastCode(mob, target, auto), null);
            Room room = null;
            for (int x = 0; (x < 10) && (room == null); x++)
              room =
                  ((Area) areas.elementAt(CMLib.dice().roll(1, areas.size(), -1)))
                      .getRandomMetroRoom();
            if (mob.location().okMessage(mob, msg) && (room != null)) {
              mob.location().send(mob, msg);
              if (msg.value() <= 0) {
                target.unWear();
                if (target.owner() instanceof MOB) {
                  final MOB owner = (MOB) target.owner();
                  mob.location()
                      .show(
                          owner,
                          room,
                          target,
                          CMMsg.MASK_ALWAYS | CMMsg.MSG_THROW,
                          L("<O-NAME> vanishes from <S-YOUPOSS> inventory!"));
                  room.showOthers(
                      owner,
                      room,
                      target,
                      CMMsg.MASK_ALWAYS | CMMsg.MSG_THROW,
                      L("<O-NAME> appears from out of nowhere!"));
                } else {
                  mob.location()
                      .show(
                          mob,
                          room,
                          target,
                          CMMsg.MASK_ALWAYS | CMMsg.MSG_THROW,
                          L("<O-NAME> vanishes!"));
                  room.showOthers(
                      mob,
                      room,
                      target,
                      CMMsg.MASK_ALWAYS | CMMsg.MSG_THROW,
                      L("<O-NAME> appears from out of nowhere!"));
                }
                if (!room.isContent(target))
                  room.moveItemTo(
                      target, ItemPossessor.Expire.Player_Drop, ItemPossessor.Move.Followers);
                room.recoverRoomStats();
              }
            }
          }
        }
      }
    } else
      return maliciousFizzle(
          mob, mobTarget, L("<S-NAME> attempt(s) a scattering spell, but nothing happens."));

    // return whether it worked
    return success;
  }
コード例 #29
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 ((mob.getWorshipCharID().length() == 0)
        || (CMLib.map().getDeity(mob.getWorshipCharID()) == null)) {
      if (!auto) mob.tell(L("You must worship a god to use this prayer."));
      return false;
    }
    final Deity D = CMLib.map().getDeity(mob.getWorshipCharID());
    if ((target.getWorshipCharID().length() > 0)
        && (CMLib.map().getDeity(target.getWorshipCharID()) != null)) {
      if (!auto)
        mob.tell(
            L(
                "@x1 worships @x2, and may not be converted with this prayer.",
                target.name(mob),
                target.getWorshipCharID()));
      return false;
    }
    if ((CMLib.flags().isAnimalIntelligence(target)
        || CMLib.flags().isGolem(target)
        || (D == null))) {
      if (!auto) mob.tell(L("@x1 can not be converted with this prayer.", target.name(mob)));
      return false;
    }
    if (!auto) {
      if (convertStack.contains(target)) {
        final Long L = (Long) convertStack.elementAt(convertStack.indexOf(target), 2);
        if ((System.currentTimeMillis() - L.longValue()) > CMProps.getMillisPerMudHour() * 5)
          convertStack.removeElement(target);
      }
      if (convertStack.contains(target)) {
        mob.tell(L("@x1 must wait to be undeniably faithful again.", target.name(mob)));
        return false;
      }
    }

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

    int levelDiff =
        target.phyStats().level() - (mob.phyStats().level() + (2 * getXLEVELLevel(mob)));
    if (levelDiff < 0) levelDiff = 0;
    final boolean success = proficiencyCheck(mob, -(levelDiff * 25), auto);
    int type = verbalCastCode(mob, target, auto);
    int mal = CMMsg.MASK_MALICIOUS;
    if (auto) {
      type = CMath.unsetb(type, CMMsg.MASK_MALICIOUS);
      mal = 0;
    }
    if (success) {
      final CMMsg msg =
          CMClass.getMsg(
              mob,
              target,
              this,
              type,
              auto ? "" : L("^S<S-NAME> @x1 for <T-NAMESELF> to BELIEVE!^?", prayWord(mob)));
      final CMMsg msg2 =
          CMClass.getMsg(target, D, this, CMMsg.MSG_SERVE, L("<S-NAME> BELIEVE(S) !!!"));
      final CMMsg msg3 =
          CMClass.getMsg(
              mob,
              target,
              this,
              CMMsg.MSK_CAST_VERBAL | mal | CMMsg.TYP_MIND | (auto ? CMMsg.MASK_ALWAYS : 0),
              null);
      if ((mob.location().okMessage(mob, msg))
          && (mob.location().okMessage(mob, msg3))
          && (mob.location().okMessage(mob, msg2))) {
        mob.location().send(mob, msg);
        mob.location().send(mob, msg3);
        if ((msg.value() <= 0) && (msg3.value() <= 0)) {
          target.location().send(target, msg2);
          target.setWorshipCharID(godName);
          if (mob != target) CMLib.leveler().postExperience(mob, target, null, 25, false);
          godName = mob.getWorshipCharID();
          beneficialAffect(mob, target, asLevel, CMProps.getIntVar(CMProps.Int.TICKSPERMUDMONTH));
          convertStack.addElement(target, Long.valueOf(System.currentTimeMillis()));
        }
      }
    } else
      beneficialWordsFizzle(
          mob,
          target,
          auto ? "" : L("<S-NAME> @x1 for <T-NAMESELF>, but nothing happens.", prayWord(mob)));

    // return whether it worked
    return success;
  }
コード例 #30
0
 @Override
 public void executeMsg(Environmental host, CMMsg msg) {
   if (msg.amITarget(this)) {
     switch (msg.targetMinor()) {
       case CMMsg.TYP_ACTIVATE:
         if ((msg.source().location() != null)
             && (!CMath.bset(msg.targetMajor(), CMMsg.MASK_CNTRLMSG)))
           msg.source()
               .location()
               .show(msg.source(), this, CMMsg.MSG_OK_VISUAL, L("<S-NAME> activate(s) <T-NAME>."));
         this.activate(true);
         break;
       case CMMsg.TYP_DEACTIVATE:
         if ((msg.source().location() != null)
             && (!CMath.bset(msg.targetMajor(), CMMsg.MASK_CNTRLMSG)))
           msg.source()
               .location()
               .show(
                   msg.source(), this, CMMsg.MSG_OK_VISUAL, L("<S-NAME> deactivate(s) <T-NAME>."));
         this.activate(false);
         break;
       case CMMsg.TYP_LOOK:
         super.executeMsg(host, msg);
         if (CMLib.flags().canBeSeenBy(this, msg.source()))
           msg.source()
               .tell(
                   L(
                       "@x1 is currently @x2",
                       name(),
                       (activated() ? "connected.\n\r" : "deactivated/disconnected.\n\r")));
         return;
       case CMMsg.TYP_REPAIR:
         if (CMLib.dice().rollPercentage() < msg.value()) {
           setUsesRemaining(usesRemaining() < 100 ? 100 : usesRemaining());
           msg.source().tell(L("@x1 is now repaired.\n\r", name()));
         } else {
           final int repairRequired = 100 - usesRemaining();
           if (repairRequired > 0) {
             int repairApplied =
                 (int) Math.round(CMath.mul(repairRequired, CMath.div(msg.value(), 100)));
             if (repairApplied < 0) repairApplied = 1;
             setUsesRemaining(usesRemaining() + repairApplied);
             msg.source().tell(L("@x1 is now @x2% repaired.\n\r", name(), "" + usesRemaining()));
           }
         }
         break;
       case CMMsg.TYP_ENHANCE:
         if ((CMLib.dice().rollPercentage() < msg.value())
             && (CMLib.dice().rollPercentage() < 50)) {
           float addAmt = 0.01f;
           if (getInstalledFactor() < 1.0) {
             addAmt = (float) (CMath.div(100.0, msg.value()) * 0.1);
             if (addAmt < 0.1f) addAmt = 0.1f;
           }
           setInstalledFactor(this.getInstalledFactor() + addAmt);
           msg.source().tell(msg.source(), this, null, L("<T-NAME> is now enhanced.\n\r"));
         } else {
           msg.source()
               .tell(
                   msg.source(),
                   this,
                   null,
                   L("Your attempt to enhance <T-NAME> has failed.\n\r"));
         }
         break;
     }
   }
   super.executeMsg(host, msg);
 }