Пример #1
0
 public int castingQuality(MOB mob, Physical target) {
   if (mob != null) {
     if (mob.isInCombat()) return Ability.QUALITY_INDIFFERENT;
     if (CMLib.flags().isSitting(mob)) return Ability.QUALITY_INDIFFERENT;
     if (!CMLib.flags().aliveAwakeMobileUnbound(mob, false)) return Ability.QUALITY_INDIFFERENT;
     if (target instanceof MOB) {
       if (CMLib.flags().canBeSeenBy(mob, (MOB) target)) return Ability.QUALITY_INDIFFERENT;
       Item w = mob.fetchWieldedItem();
       if ((w == null) || (w.minRange() > 0) || (w.maxRange() > 0))
         return Ability.QUALITY_INDIFFERENT;
       return Ability.QUALITY_MALICIOUS;
     }
   }
   return super.castingQuality(mob, target);
 }
Пример #2
0
  public boolean invoke(MOB mob, Vector commands, Physical givenTarget, boolean auto, int asLevel) {
    if (mob.isInCombat()) {
      mob.tell("Not while in combat!");
      return false;
    }
    MOB target = getTarget(mob, commands, givenTarget);
    if (target == null) return false;

    if (CMLib.flags().isSitting(mob)) {
      mob.tell("You need to stand up!");
      return false;
    }
    if (!CMLib.flags().aliveAwakeMobileUnbound(mob, false)) return false;
    if (CMLib.flags().canBeSeenBy(mob, target)) {
      mob.tell(target.name(mob) + " is watching you too closely.");
      return false;
    }
    Item w = mob.fetchWieldedItem();
    if ((w == null) || (w.minRange() > 0) || (w.maxRange() > 0)) {
      mob.tell("You need a close melee weapon to shadowstrike.");
      return false;
    }

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

    boolean success = proficiencyCheck(mob, 0, auto);
    int code = CMMsg.MASK_MALICIOUS | CMMsg.MSG_THIEF_ACT;
    String str = auto ? "" : "<S-NAME> strike(s) <T-NAMESELF> from the shadows!";
    int otherCode = success ? code : CMMsg.NO_EFFECT;
    String otherStr = success ? str : null;
    CMMsg msg =
        CMClass.getMsg(mob, target, this, code, str, otherCode, otherStr, otherCode, otherStr);
    if (mob.location().okMessage(mob, msg)) {
      boolean alwaysInvis = CMath.bset(mob.basePhyStats().disposition(), PhyStats.IS_INVISIBLE);
      if (!alwaysInvis)
        mob.basePhyStats().setDisposition(mob.basePhyStats().disposition() | PhyStats.IS_INVISIBLE);
      mob.recoverPhyStats();
      mob.location().send(mob, msg);
      CMLib.combat().postAttack(mob, target, w);
      if (!alwaysInvis)
        mob.basePhyStats().setDisposition(mob.basePhyStats().disposition() - PhyStats.IS_INVISIBLE);
      mob.recoverPhyStats();
      if (success) {
        MOB oldVictim = target.getVictim();
        MOB oldVictim2 = mob.getVictim();
        if (oldVictim == mob) target.makePeace();
        if (oldVictim2 == target) mob.makePeace();
        if (mob.fetchEffect("Thief_Hide") == null) {
          Ability hide = mob.fetchAbility("Thief_Hide");
          if (hide != null) hide.invoke(mob, null, false, asLevel);

          mob.location().recoverRoomStats();
          if (CMLib.flags().canBeSeenBy(mob, target)) {
            target.setVictim(oldVictim);
            mob.setVictim(oldVictim2);
          }
        }
      }
    }
    return success;
  }
Пример #3
0
  public StringBuffer deviations(MOB mob, String rest) {
    final Vector<String> V = CMParms.parse(rest);
    if ((V.size() == 0)
        || ((!V.get(0).equalsIgnoreCase("mobs"))
            && (!V.get(0).equalsIgnoreCase("items"))
            && (!V.get(0).equalsIgnoreCase("both"))))
      return new StringBuffer(
          "You must specify whether you want deviations on MOBS, ITEMS, or BOTH.");

    final String type = V.get(0).toLowerCase();
    if (V.size() == 1)
      return new StringBuffer(
          "You must also specify a mob or item name, or the word room, or the word area.");

    final Room mobR = mob.location();
    Faction useFaction = null;
    for (final Enumeration<Faction> e = CMLib.factions().factions(); e.hasMoreElements(); ) {
      final Faction F = e.nextElement();
      if (F.showInSpecialReported()) useFaction = F;
    }
    final String where = V.get(1).toLowerCase();
    final Environmental E = mobR.fetchFromMOBRoomFavorsItems(mob, null, where, Wearable.FILTER_ANY);
    final Vector<Environmental> check = new Vector<Environmental>();
    if (where.equalsIgnoreCase("room")) fillCheckDeviations(mobR, type, check);
    else if (where.equalsIgnoreCase("area")) {
      for (final Enumeration<Room> r = mobR.getArea().getFilledCompleteMap();
          r.hasMoreElements(); ) {
        final Room R = r.nextElement();
        fillCheckDeviations(R, type, check);
      }
    } else if (where.equalsIgnoreCase("world")) {
      for (final Enumeration<Room> r = CMLib.map().roomsFilled(); r.hasMoreElements(); ) {
        final Room R = r.nextElement();
        fillCheckDeviations(R, type, check);
      }
    } else if (E == null)
      return new StringBuffer("'" + where + "' is an unknown item or mob name.");
    else if (type.equals("items") && (!(E instanceof Weapon)) && (!(E instanceof Armor)))
      return new StringBuffer("'" + where + "' is not a weapon or armor item.");
    else if (type.equals("mobs") && (!(E instanceof MOB)))
      return new StringBuffer("'" + where + "' is not a MOB.");
    else if ((!(E instanceof Weapon)) && (!(E instanceof Armor)) && (!(E instanceof MOB)))
      return new StringBuffer("'" + where + "' is not a MOB, or Weapon, or Item.");
    else check.add(E);
    final StringBuffer str = new StringBuffer("");
    str.append(L("Deviations Report:\n\r"));
    final StringBuffer itemResults = new StringBuffer();
    final StringBuffer mobResults = new StringBuffer();
    for (int c = 0; c < check.size(); c++) {
      if (check.get(c) instanceof Item) {
        final Item I = (Item) check.get(c);
        Weapon W = null;
        if (I instanceof Weapon) W = (Weapon) I;
        final Map<String, String> vals =
            CMLib.itemBuilder()
                .timsItemAdjustments(
                    I,
                    I.phyStats().level(),
                    I.material(),
                    I.rawLogicalAnd() ? 2 : 1,
                    (W == null) ? 0 : W.weaponClassification(),
                    I.maxRange(),
                    I.rawProperLocationBitmap());
        itemResults.append(CMStrings.padRight(I.name(), 20) + " ");
        itemResults.append(CMStrings.padRight(I.ID(), 10) + " ");
        itemResults.append(CMStrings.padRight("" + I.phyStats().level(), 4) + " ");
        itemResults.append(
            CMStrings.padRight(
                    "" + getDeviation(I.basePhyStats().attackAdjustment(), vals, "ATTACK"), 5)
                + " ");
        itemResults.append(
            CMStrings.padRight("" + getDeviation(I.basePhyStats().damage(), vals, "DAMAGE"), 5)
                + " ");
        itemResults.append(
            CMStrings.padRight("" + getDeviation(I.basePhyStats().damage(), vals, "ARMOR"), 5)
                + " ");
        itemResults.append(
            CMStrings.padRight("" + getDeviation(I.baseGoldValue(), vals, "VALUE"), 5) + " ");
        itemResults.append(
            CMStrings.padRight(
                    ""
                        + ((I.phyStats().rejuv() == PhyStats.NO_REJUV)
                            ? " MAX"
                            : "" + I.phyStats().rejuv()),
                    5)
                + " ");
        if (I instanceof Weapon)
          itemResults.append(CMStrings.padRight("" + I.basePhyStats().weight(), 4));
        else
          itemResults.append(
              CMStrings.padRight("" + getDeviation(I.basePhyStats().weight(), vals, "WEIGHT"), 4)
                  + " ");
        if (I instanceof Armor)
          itemResults.append(CMStrings.padRight("" + ((Armor) I).phyStats().height(), 4));
        else itemResults.append(CMStrings.padRight(" - ", 4) + " ");
        itemResults.append("\n\r");
      } else {
        final MOB M = (MOB) check.get(c);
        mobResults.append(CMStrings.padRight(M.name(), 20) + " ");
        mobResults.append(CMStrings.padRight("" + M.phyStats().level(), 4) + " ");
        mobResults.append(
            CMStrings.padRight(
                    ""
                        + getDeviation(
                            M.basePhyStats().attackAdjustment(), CMLib.leveler().getLevelAttack(M)),
                    5)
                + " ");
        mobResults.append(
            CMStrings.padRight(
                    ""
                        + getDeviation(
                            M.basePhyStats().damage(),
                            (int)
                                Math.round(
                                    CMath.div(
                                        CMLib.leveler().getLevelMOBDamage(M),
                                        M.basePhyStats().speed()))),
                    5)
                + " ");
        mobResults.append(
            CMStrings.padRight(
                    ""
                        + getDeviation(
                            M.basePhyStats().armor(), CMLib.leveler().getLevelMOBArmor(M)),
                    5)
                + " ");
        mobResults.append(
            CMStrings.padRight(
                    ""
                        + getDeviation(
                            M.basePhyStats().speed(), CMLib.leveler().getLevelMOBSpeed(M)),
                    5)
                + " ");
        mobResults.append(
            CMStrings.padRight(
                    ""
                        + ((M.phyStats().rejuv() == PhyStats.NO_REJUV)
                            ? " MAX"
                            : "" + M.phyStats().rejuv()),
                    5)
                + " ");
        if (useFaction != null)
          mobResults.append(
              CMStrings.padRight(
                      ""
                          + (M.fetchFaction(useFaction.factionID()) == Integer.MAX_VALUE
                              ? "N/A"
                              : "" + M.fetchFaction(useFaction.factionID())),
                      7)
                  + " ");
        double value = CMLib.beanCounter().getTotalAbsoluteNativeValue(M);
        double[] range = CMLib.leveler().getLevelMoneyRange(M);
        if (value < range[0])
          mobResults.append(CMStrings.padRight("" + getDeviation(value, range[0]), 5) + " ");
        else if (value > range[1])
          mobResults.append(CMStrings.padRight("" + getDeviation(value, range[1]), 5) + " ");
        else mobResults.append(CMStrings.padRight("0%", 5) + " ");
        int reallyWornCount = 0;
        for (int j = 0; j < M.numItems(); j++) {
          final Item Iw = M.getItem(j);
          if (!(Iw.amWearingAt(Wearable.IN_INVENTORY))) reallyWornCount++;
        }
        mobResults.append(CMStrings.padRight("" + reallyWornCount, 5) + " ");
        mobResults.append("\n\r");
      }
    }
    if (itemResults.length() > 0) str.append(itemHeader() + itemResults.toString());
    if (mobResults.length() > 0) str.append(mobHeader(useFaction) + mobResults.toString());
    return str;
  }