Exemple #1
0
  @Override
  public boolean invoke(MOB mob, Vector commands, Physical givenTarget, boolean auto, int asLevel) {
    final Item target = getTarget(mob, null, givenTarget, commands, Wearable.FILTER_ANY);
    if (target == null) return false;
    if (!target.subjectToWearAndTear()) {
      mob.tell(L("@x1 cannot be mended.", target.name(mob)));
      return false;
    }

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

    final boolean success =
        proficiencyCheck(
            mob,
            (((mob.phyStats().level() + (2 * getXLEVELLevel(mob))) - target.phyStats().level())
                * 5),
            auto);

    if (success) {
      final CMMsg msg =
          CMClass.getMsg(
              mob,
              target,
              this,
              verbalCastCode(mob, target, auto),
              (auto ? "<T-NAME> begins to shimmer!" : "^S<S-NAME> incant(s) at <T-NAMESELF>!^?"));
      if (mob.location().okMessage(mob, msg)) {
        mob.location().send(mob, msg);
        if (target.usesRemaining() >= 100) mob.tell(L("Nothing happens to @x1.", target.name(mob)));
        else {
          mob.location()
              .show(mob, target, CMMsg.MSG_OK_VISUAL, L("<T-NAME> begin(s) to glow and mend!"));
          target.setUsesRemaining(100);
        }
        target.recoverPhyStats();
        mob.location().recoverRoomStats();
      }

    } else
      beneficialWordsFizzle(
          mob, target, L("<S-NAME> incant(s) at <T-NAMESELF>, but nothing happens."));

    // return whether it worked
    return success;
  }
Exemple #2
0
  @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;
  }