Пример #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;
  }