コード例 #1
0
  @Override
  public boolean invoke(
      MOB mob, List<String> commands, Physical givenTarget, boolean auto, int asLevel) {
    if (!mob.isInCombat()) {
      mob.tell(L("You must be in combat to do this!"));
      return false;
    }
    final MOB victim = super.getTarget(mob, commands, givenTarget);
    if (victim == null) return false;
    if (((victim == mob.getVictim()) && (mob.rangeToTarget() > 0))
        || ((victim.getVictim() == mob) && (victim.rangeToTarget() > 0))) {
      mob.tell(L("You are too far away to disarm!"));
      return false;
    }
    if (mob.fetchWieldedItem() == null) {
      mob.tell(L("You need a weapon to disarm someone!"));
      return false;
    }
    Item hisWeapon = victim.fetchWieldedItem();
    if (hisWeapon == null) hisWeapon = victim.fetchHeldItem();
    if ((hisWeapon == null)
        || (!(hisWeapon instanceof Weapon))
        || ((((Weapon) hisWeapon).weaponClassification() == Weapon.CLASS_NATURAL))) {
      mob.tell(L("@x1 is not wielding a weapon!", victim.charStats().HeShe()));
      return false;
    }

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

    int levelDiff =
        victim.phyStats().level() - (mob.phyStats().level() + (2 * getXLEVELLevel(mob)));
    if (levelDiff > 0) levelDiff = levelDiff * 5;
    else levelDiff = 0;
    final boolean hit = (auto) || CMLib.combat().rollToHit(mob, victim);
    final boolean success = proficiencyCheck(mob, -levelDiff, auto) && (hit);
    if ((success)
        && ((hisWeapon.fitsOn(Wearable.WORN_WIELD))
            || hisWeapon.fitsOn(Wearable.WORN_WIELD | Wearable.WORN_HELD))) {
      if (mob.location().show(mob, victim, this, CMMsg.MSG_NOISYMOVEMENT, null)) {
        final CMMsg msg = CMClass.getMsg(victim, hisWeapon, null, CMMsg.MSG_DROP, null);
        if (mob.location().okMessage(mob, msg)) {
          mob.location().send(victim, msg);
          mob.location()
              .show(
                  mob,
                  victim,
                  CMMsg.MSG_NOISYMOVEMENT,
                  auto ? L("<T-NAME> is disarmed!") : L("<S-NAME> disarm(s) <T-NAMESELF>!"));
        }
      }
    } else
      maliciousFizzle(mob, victim, L("<S-NAME> attempt(s) to disarm <T-NAMESELF> and fail(s)!"));
    return success;
  }
コード例 #2
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;
  }
コード例 #3
0
 @Override
 public int castingQuality(MOB mob, Physical target) {
   if ((mob != null) && (target != null)) {
     final MOB victim = mob.getVictim();
     if (victim == null) return Ability.QUALITY_INDIFFERENT;
     if (mob.isInCombat() && (mob.rangeToTarget() > 0)) return Ability.QUALITY_INDIFFERENT;
     if (mob.fetchWieldedItem() == null) return Ability.QUALITY_INDIFFERENT;
     Item hisWeapon = victim.fetchWieldedItem();
     if (hisWeapon == null) hisWeapon = victim.fetchHeldItem();
     if ((hisWeapon == null)
         || (!(hisWeapon instanceof Weapon))
         || ((((Weapon) hisWeapon).weaponClassification() == Weapon.CLASS_NATURAL)))
       return Ability.QUALITY_INDIFFERENT;
   }
   return super.castingQuality(mob, target);
 }
コード例 #4
0
 @Override
 public int castingQuality(MOB mob, Physical target) {
   if ((mob != null) && (target != null) && (target instanceof MOB)) {
     final Race R = ((MOB) target).charStats().getMyRace();
     if (R.bodyMask()[Race.BODY_HEAD] <= 0) return Ability.QUALITY_INDIFFERENT;
     LegalBehavior B = null;
     if (mob.location() != null) B = CMLib.law().getLegalBehavior(mob.location());
     List<LegalWarrant> warrants = new Vector<LegalWarrant>();
     if (B != null)
       warrants = B.getWarrantsOf(CMLib.law().getLegalObject(mob.location()), (MOB) target);
     if (warrants.size() == 0) return Ability.QUALITY_INDIFFERENT;
     final Item w = mob.fetchWieldedItem();
     Weapon ww = null;
     if ((w == null) || (!(w instanceof Weapon))) return Ability.QUALITY_INDIFFERENT;
     ww = (Weapon) w;
     if (ww.weaponDamageType() != Weapon.TYPE_SLASHING) return Ability.QUALITY_INDIFFERENT;
     if (mob.isInCombat() && (mob.rangeToTarget() > 0)) return Ability.QUALITY_INDIFFERENT;
     if (!CMLib.flags().isBoundOrHeld(target)) return Ability.QUALITY_INDIFFERENT;
   }
   return super.castingQuality(mob, target);
 }
コード例 #5
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;
  }
コード例 #6
0
  @Override
  public boolean okMessage(final Environmental myHost, final CMMsg msg) {
    if (!super.okMessage(myHost, msg)) return false;

    if ((msg.target() == affected)
        && msg.isTarget(CMMsg.MASK_MALICIOUS)
        && CMLib.flags().isAPlant(msg.source())
        && (affected instanceof MOB)
        && (pointsRemaining >= 0)) {
      final MOB mob = (MOB) affected;
      final MOB plantMOB = msg.source();
      final Room R = plantMOB.location();
      if ((R != null) && (R == mob.location())) {
        if ((msg.isSource(CMMsg.TYP_ADVANCE)) && (--pointsRemaining >= 0)) {
          R.show(
              plantMOB,
              affected,
              CMMsg.MSG_OK_ACTION,
              L("<S-NAME> struggle(s) against <T-YOUPOSS> anti-plant shell."));
          return false;
        } else if (plantMOB.getVictim() == null) {
          plantMOB.setVictim(mob);
          if (mob.getVictim() == plantMOB) {
            if (mob.rangeToTarget() > 0) plantMOB.setRangeToTarget(mob.rangeToTarget());
            else {
              plantMOB.setRangeToTarget(R.maxRange());
              mob.setRangeToTarget(R.maxRange());
            }
          } else plantMOB.setRangeToTarget(R.maxRange());
          if ((--pointsRemaining) < 0) {
            unInvoke();
            return true;
          }
          R.show(
              plantMOB,
              affected,
              CMMsg.MSG_OK_ACTION,
              L("<S-NAME> <S-IS-ARE> repelled by <T-YOUPOSS> anti-plant shell."));
          return false;
        } else if ((plantMOB.getVictim() == affected) && (plantMOB.rangeToTarget() <= 0)) {
          plantMOB.setRangeToTarget(R.maxRange());
          if (mob.getVictim() == plantMOB) mob.setRangeToTarget(R.maxRange());
          if ((--pointsRemaining) < 0) {
            unInvoke();
            return true;
          }
          R.show(
              plantMOB,
              affected,
              CMMsg.MSG_OK_ACTION,
              L("<S-NAME> <S-IS-ARE> repelled by <T-YOUPOSS> anti-plant shell."));
          return false;
        } else if ((mob.getVictim() == plantMOB) && (mob.rangeToTarget() <= 0)) {
          mob.setRangeToTarget(R.maxRange());
          if ((--pointsRemaining) < 0) {
            unInvoke();
            return true;
          }
          R.show(
              plantMOB,
              affected,
              CMMsg.MSG_OK_ACTION,
              L("<S-NAME> <S-IS-ARE> repelled by <T-YOUPOSS> anti-plant shell."));
          return false;
        }
      }
    } else if (msg.isSource(CMMsg.TYP_ADVANCE)
        && (msg.source() == affected)
        && (msg.source().getVictim() == msg.target())
        && (CMLib.flags().isAPlant((MOB) msg.target()))
        && (pointsRemaining >= 0)
        && (msg.source().rangeToTarget() == 1)) {
      final MOB plantM = msg.source().getVictim();
      if (plantM != null) {
        final Room R = plantM.location();
        if (R != null) {
          final CMMsg msg2 =
              CMClass.getMsg(
                  plantM,
                  msg.source(),
                  CMMsg.MSG_RETREAT,
                  L("<S-NAME> <S-IS-ARE> pushed back by <T-YOUPOSS> anti-plant shell."));
          if (R.okMessage(plantM, msg2)) R.send(plantM, msg2);
        }
      }
    }
    if (pointsRemaining < 0) {
      unInvoke();
      return true;
    }
    return true;
  }
コード例 #7
0
  @Override
  public boolean invoke(
      MOB mob, List<String> commands, Physical givenTarget, boolean auto, int asLevel) {
    final MOB target = super.getTarget(mob, commands, givenTarget);
    if (target == null) return false;
    final Race R = target.charStats().getMyRace();
    if (R.bodyMask()[Race.BODY_HEAD] <= 0) {
      mob.tell(L("@x1 has no head!", target.name(mob)));
      return false;
    }

    LegalBehavior B = null;
    if (mob.location() != null) B = CMLib.law().getLegalBehavior(mob.location());
    List<LegalWarrant> warrants = new Vector<LegalWarrant>();
    if (B != null) warrants = B.getWarrantsOf(CMLib.law().getLegalObject(mob.location()), target);
    if ((warrants.size() == 0)
        && (!CMSecurity.isAllowed(mob, mob.location(), CMSecurity.SecFlag.ABOVELAW))) {
      mob.tell(L("You are not allowed to behead @x1 at this time.", target.Name()));
      return false;
    }

    final Item w = mob.fetchWieldedItem();
    Weapon ww = null;
    if ((w == null) || (!(w instanceof Weapon))) {
      mob.tell(L("You cannot behead without a weapon!"));
      return false;
    }
    ww = (Weapon) w;
    if ((!auto) && (!CMSecurity.isASysOp(mob))) {
      if (ww.weaponDamageType() != Weapon.TYPE_SLASHING) {
        mob.tell(L("You cannot behead with a @x1!", ww.name()));
        return false;
      }
      if (mob.isInCombat() && (mob.rangeToTarget() > 0)) {
        mob.tell(L("You are too far away to try that!"));
        return false;
      }
      if (!CMLib.flags().isBoundOrHeld(target)) {
        mob.tell(L("@x1 is not bound and would resist.", target.charStats().HeShe()));
        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 = levelDiff * 3;
    else levelDiff = 0;
    final boolean hit = (auto) || CMLib.combat().rollToHit(mob, target);
    boolean success = proficiencyCheck(mob, 0, auto) && (hit);
    if (success) {
      final CMMsg msg =
          CMClass.getMsg(
              mob,
              target,
              this,
              CMMsg.MASK_MALICIOUS
                  | CMMsg.MASK_MOVE
                  | CMMsg.MASK_SOUND
                  | CMMsg.TYP_JUSTICE
                  | (auto ? CMMsg.MASK_ALWAYS : 0),
              null);
      if (mob.location().okMessage(mob, msg)) {
        mob.location().send(mob, msg);
        target.curState().setHitPoints(1);
        final Ability A2 = target.fetchEffect("Injury");
        if (A2 != null) A2.setMiscText(mob.Name() + "/head");
        CMLib.combat()
            .postDamage(
                mob,
                target,
                ww,
                Integer.MAX_VALUE / 2,
                CMMsg.MSG_WEAPONATTACK,
                ww.weaponClassification(),
                auto
                    ? ""
                    : L(
                        "^F^<FIGHT^><S-NAME> rear(s) back and behead(s) <T-NAME>!^</FIGHT^>^?@x1",
                        CMLib.protocol().msp("decap.wav", 30)));
        mob.location().recoverRoomStats();
        final Item limb = CMClass.getItem("GenLimb");
        limb.setName(L("@x1`s head", target.Name()));
        limb.basePhyStats().setAbility(1);
        limb.setDisplayText(L("the bloody head of @x1 is sitting here.", target.Name()));
        limb.setSecretIdentity(target.name() + "`s bloody head.");
        int material = RawMaterial.RESOURCE_MEAT;
        for (int r = 0; r < R.myResources().size(); r++) {
          final Item I = R.myResources().get(r);
          final int mat = I.material() & RawMaterial.MATERIAL_MASK;
          if (((mat == RawMaterial.MATERIAL_FLESH)) || (r == R.myResources().size() - 1)) {
            material = I.material();
            break;
          }
        }
        limb.setMaterial(material);
        limb.basePhyStats().setLevel(1);
        limb.basePhyStats().setWeight(5);
        limb.recoverPhyStats();
        mob.location().addItem(limb, ItemPossessor.Expire.Player_Drop);
        for (int i = 0; i < warrants.size(); i++) {
          final LegalWarrant W = warrants.get(i);
          W.setCrime("pardoned");
          W.setOffenses(0);
        }
      } else success = false;
      if (mob.getVictim() == target) mob.makePeace(true);
      if (target.getVictim() == mob) target.makePeace(true);
    } else maliciousFizzle(mob, target, L("<S-NAME> attempt(s) a beheading and fail(s)!"));
    return success;
  }