コード例 #1
0
  @Override
  public boolean invoke(MOB mob, Vector commands, Physical givenTarget, boolean auto, int asLevel) {
    final Item I =
        getTarget(mob, mob.location(), givenTarget, commands, Wearable.FILTER_UNWORNONLY);
    if (I == null) return false;
    if (((I.material() & RawMaterial.MATERIAL_MASK) != RawMaterial.MATERIAL_VEGETATION)
        && ((I.material() & RawMaterial.MATERIAL_MASK) != RawMaterial.MATERIAL_WOODEN)) {
      mob.tell(L("Your plant knowledge can tell you nothing about @x1.", I.name(mob)));
      return false;
    }

    if (!super.invoke(mob, commands, givenTarget, auto, asLevel)) return false;
    final boolean success = proficiencyCheck(mob, 0, auto);

    if (!success) mob.tell(L("Your plant senses fail you."));
    else {
      final CMMsg msg =
          CMClass.getMsg(mob, I, null, CMMsg.MSG_DELICATE_SMALL_HANDS_ACT | CMMsg.MASK_MAGIC, null);
      if (mob.location().okMessage(mob, msg)) {
        mob.location().send(mob, msg);
        final StringBuffer str = new StringBuffer("");
        str.append(
            L(
                "@x1 is a kind of @x2.  ",
                I.name(mob),
                RawMaterial.CODES.NAME(I.material()).toLowerCase()));
        if (isPlant(I)) str.append(L("It was summoned by @x1.", I.rawSecretIdentity()));
        else str.append(L("It is either processed by hand, or grown wild."));
        mob.tell(str.toString());
      }
    }
    return success;
  }
コード例 #2
0
 public static Ability isPlant(Item I) {
   if ((I != null) && (I.rawSecretIdentity().length() > 0)) {
     for (int a = 0; a < I.numEffects(); a++) {
       Ability A = I.fetchEffect(a);
       if ((A != null) && (A.invoker() != null) && (A instanceof Chant_SummonPlants)) return A;
     }
   }
   return null;
 }
コード例 #3
0
  @Override
  public boolean invoke(MOB mob, Vector commands, Physical givenTarget, boolean auto, int asLevel) {
    Item target = null;
    if ((commands.size() == 0) && (!auto) && (givenTarget == null))
      target = Prayer_Sacrifice.getBody(mob.location());
    if (target == null)
      target = getTarget(mob, mob.location(), givenTarget, commands, Wearable.FILTER_UNWORNONLY);
    if (target == null) return false;

    if ((!(target instanceof DeadBody))
        || (target.rawSecretIdentity().toUpperCase().indexOf("FAKE") >= 0)) {
      mob.tell(L("You may only desecrate the dead."));
      return false;
    }
    if ((((DeadBody) target).isPlayerCorpse())
        && (!((DeadBody) target).getMobName().equals(mob.Name()))
        && (((DeadBody) target).hasContent())) {
      mob.tell(L("You are not allowed to desecrate a players corpse."));
      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> feel(s) desecrated!")
                  : L("^S<S-NAME> desecrate(s) <T-NAMESELF> before @x1.^?", hisHerDiety(mob)));
      if (mob.location().okMessage(mob, msg)) {
        mob.location().send(mob, msg);
        if (CMLib.flags().isEvil(mob)) {
          double exp = 5.0;
          final int levelLimit = CMProps.getIntVar(CMProps.Int.EXPRATE);
          final int levelDiff = (mob.phyStats().level()) - target.phyStats().level();
          if (levelDiff > levelLimit) exp = 0.0;
          if (exp > 0.0)
            CMLib.leveler()
                .postExperience(
                    mob, null, null, (int) Math.round(exp) + super.getXPCOSTLevel(mob), false);
        }
        target.destroy();
        mob.location().recoverRoomStats();
      }
    } else
      beneficialWordsFizzle(
          mob, target, L("<S-NAME> attempt(s) to desecrate <T-NAMESELF>, but fail(s)."));

    // return whether it worked
    return success;
  }
コード例 #4
0
 public static boolean isPlant(Item I) {
   if ((I != null) && (I.rawSecretIdentity().length() > 0)) {
     for (final Enumeration<Ability> a = I.effects(); a.hasMoreElements(); ) {
       final Ability A = a.nextElement();
       if ((A != null) && (A.invoker() != null) && (A instanceof Chant_SummonPlants)) return true;
     }
   }
   return false;
 }
コード例 #5
0
  public boolean invoke(
      MOB mob, Vector commands, Environmental givenTarget, boolean auto, int asLevel) {
    Item myPlant = getTarget(mob, mob.location(), givenTarget, commands, Item.WORNREQ_ANY);
    if (myPlant == null) return false;

    if (isPlant(myPlant) == null) {
      mob.tell("You can't control " + myPlant.name() + ".");
      return false;
    }

    if (myPlant.rawSecretIdentity().equals(mob.Name())) {
      mob.tell("You already control " + myPlant.name() + ".");
      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,
              myPlant,
              this,
              verbalCastCode(mob, myPlant, auto),
              auto ? "" : "^S<S-NAME> chant(s) to <T-NAMESELF>!^?");
      if (mob.location().okMessage(mob, msg)) {
        mob.location().send(mob, msg);
        Ability A = isPlant(myPlant);
        if (A != null) A.setInvoker(mob);
        mob.tell(
            "You wrest control of " + myPlant.name() + " from " + myPlant.secretIdentity() + ".");
        myPlant.setSecretIdentity(mob.Name());
      }

    } else
      beneficialVisualFizzle(
          mob, myPlant, "<S-NAME> chant(s) to <T-NAMESELF>, but nothing happens.");

    // return whether it worked
    return success;
  }