Esempio n. 1
0
 protected void clearWarrants(
     final MOB officer, final MOB invoker, final Room R, final Area A, final LegalBehavior B) {
   final List<LegalWarrant> warrants = B.getWarrantsOf(A, invoker);
   if ((warrants != null) && (warrants.size() > 0)) {
     boolean didSomething = false;
     for (LegalWarrant W : warrants) {
       if ((W.arrestingOfficer() == officer)
           && (System.currentTimeMillis() > W.getIgnoreUntilTime())) {
         if (W.state() != Law.STATE_SEEKING) didSomething = true;
         B.release(A, W);
       }
     }
     if (didSomething && (officer.location() == invoker.location())) {
       R.show(officer, invoker, CMMsg.MSG_HANDS, L("<S-NAME> wink(s) at <T-NAME>."));
     }
   }
 }
Esempio n. 2
0
  @Override
  public boolean invoke(
      MOB mob, List<String> commands, Physical givenTarget, boolean auto, int asLevel) {
    if (commands.size() < 1) {
      mob.tell(L("Pay Off Whom?"));
      return false;
    }
    final MOB target = this.getTarget(mob, commands, givenTarget);
    if (target == null) return false;

    if ((target.charStats().getStat(CharStats.STAT_INTELLIGENCE) < 3) || (!target.isMonster())) {
      mob.tell(L("You can't pay off @x1.", target.name(mob)));
      return false;
    }

    final LegalBehavior B = CMLib.law().getLegalBehavior(mob.location());
    final Area A = (B == null) ? null : CMLib.law().getLegalObject(mob.location());
    if ((A == null) || (B == null)) {
      mob.tell(L("There's no point in paying off @x1.", target.name(mob)));
      return false;
    }

    boolean isJudge = B.isJudge(A, target);
    if ((!isJudge) && (!B.isAnyOfficer(A, target))) {
      mob.tell(L("Paying off @x1 won't help you.", target.name(mob)));
      return false;
    }

    final List<LegalWarrant> warrants = B.getWarrantsOf(A, mob);
    if ((warrants == null) || (warrants.size() == 0)) {
      mob.tell(L("Pay off @x1? Why? You aren't in any trouble.", target.name(mob)));
      return false;
    }

    if (target.fetchEffect(ID()) != null) {
      mob.tell(L("@x1 is already paid off.", target.name(mob)));
      return false;
    }

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

    double amountRequired =
        CMLib.beanCounter().getTotalAbsoluteNativeValue(target)
            + ((double)
                    ((100l
                        - ((mob.charStats().getStat(CharStats.STAT_CHARISMA)
                                + (2l * getXLEVELLevel(mob)))
                            * 2)))
                * target.phyStats().level());
    if (isJudge) amountRequired *= 2;

    final String currency = CMLib.beanCounter().getCurrency(target);
    boolean success = proficiencyCheck(mob, 0, auto);

    if ((!success) || (CMLib.beanCounter().getTotalAbsoluteValue(mob, currency) < amountRequired)) {
      final CMMsg msg =
          CMClass.getMsg(
              mob,
              target,
              this,
              CMMsg.MSG_SPEAK,
              L(
                  "^T<S-NAME> attempt(s) to pay off <T-NAMESELF> to '@x1', but no deal is reached.^?",
                  CMParms.combine(commands, 0)));
      if (mob.location().okMessage(mob, msg)) mob.location().send(mob, msg);
      if (CMLib.beanCounter().getTotalAbsoluteValue(mob, currency) < amountRequired) {
        final String costWords = CMLib.beanCounter().nameCurrencyShort(currency, amountRequired);
        mob.tell(L("@x1 requires @x2 to do this.", target.charStats().HeShe(), costWords));
      }
      success = false;
    } else {
      final String costWords = CMLib.beanCounter().nameCurrencyShort(target, amountRequired);
      final CMMsg msg =
          CMClass.getMsg(
              mob,
              target,
              this,
              CMMsg.MSG_THIEF_ACT,
              L("^T<S-NAME> pay(s) off <T-NAMESELF>.^?", CMParms.combine(commands, 0), costWords));
      if (mob.location().okMessage(mob, msg)) {
        mob.location().send(mob, msg);
        CMLib.beanCounter().subtractMoney(mob, currency, amountRequired);
        CMLib.beanCounter().addMoney(mob, currency, amountRequired);
        if (isJudge) {
          for (LegalWarrant W : warrants) {
            if (W.punishment() > 0) W.setPunishment(W.punishment() - 1);
          }
        } else {
          clearWarrants(target, mob, mob.location(), A, B);
          super.beneficialAffect(mob, target, asLevel, 0);
        }
      }
      target.recoverPhyStats();
    }
    return success;
  }
Esempio n. 3
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;
  }