Ejemplo n.º 1
0
  @Override
  public void executeMsg(Environmental affecting, CMMsg msg) {
    super.executeMsg(affecting, msg);
    final MOB source = msg.source();
    if (!canFreelyBehaveNormal(affecting)) return;
    final MOB observer = (MOB) affecting;

    if ((source != observer)
        && (msg.amITarget(observer))
        && (msg.targetMinor() == CMMsg.TYP_GIVE)
        && (msg.tool() instanceof Coins)) {
      if ((CMLib.flags().canBeSeenBy(source, observer))
          && (CMLib.flags().canBeSeenBy(observer, source))) {
        double value = ((Coins) msg.tool()).getTotalValue();
        final String currency = ((Coins) msg.tool()).getCurrency().toUpperCase();
        double takeCut = getMyCut(affecting, currency);
        double amountToTake = CMLib.beanCounter().abbreviatedRePrice(observer, value * takeCut);
        if ((amountToTake > 0.0)
            && (amountToTake
                < CMLib.beanCounter()
                    .getLowestDenomination(CMLib.beanCounter().getCurrency(observer))))
          amountToTake =
              CMLib.beanCounter().getLowestDenomination(CMLib.beanCounter().getCurrency(observer));
        value -= amountToTake;
        observer.recoverPhyStats();
        final Coins C = CMLib.beanCounter().makeBestCurrency(observer, value);
        if ((value > 0.0) && (C != null)) {
          // this message will actually end up triggering the hand-over.
          final CMMsg newMsg =
              CMClass.getMsg(
                  observer,
                  source,
                  C,
                  CMMsg.MSG_SPEAK,
                  L("^T<S-NAME> say(s) 'Thank you for your business' to <T-NAMESELF>.^?"));
          C.setOwner(observer);
          final long num = C.getNumberOfCoins();
          final String curr = C.getCurrency();
          final double denom = C.getDenomination();
          C.destroy();
          C.setNumberOfCoins(num);
          C.setCurrency(curr);
          C.setDenomination(denom);
          msg.addTrailerMsg(newMsg);
        } else CMLib.commands().postSay(observer, source, L("Gee, thanks. :)"), true, false);
        ((Coins) msg.tool()).destroy();
      } else if (!CMLib.flags().canBeSeenBy(source, observer))
        CMLib.commands()
            .postSay(observer, null, L("Wha?  Where did this come from?  Cool!"), true, false);
    } else if ((msg.source() == observer)
        && (msg.target() instanceof MOB)
        && (msg.targetMinor() == CMMsg.TYP_SPEAK)
        && (msg.tool() instanceof Coins)
        && (((Coins) msg.tool()).amDestroyed())
        && (!msg.source().isMine(msg.tool()))
        && (!((MOB) msg.target()).isMine(msg.tool())))
      CMLib.beanCounter()
          .giveSomeoneMoney(msg.source(), (MOB) msg.target(), ((Coins) msg.tool()).getTotalValue());
  }
Ejemplo n.º 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;
  }
Ejemplo n.º 3
0
  @Override
  public boolean tick(Tickable ticking, int tickID) {
    if (!super.tick(ticking, tickID)) return false;
    if (affected == null) return false;
    if (!(affected instanceof MOB)) return true;

    final MOB mob = (MOB) affected;
    if (mob.amDead()) return true;

    if (!changed) {
      if (mob.location() == null) return true;
      final Area A = mob.location().getArea();
      if (((A.getTimeObj().getTODCode() == TimeClock.TimeOfDay.DUSK)
              || (A.getTimeObj().getTODCode() == TimeClock.TimeOfDay.NIGHT))
          && (A.getTimeObj().getMoonPhase() == TimeClock.MoonPhase.FULL)) {
        changed = true;
        mob.location()
            .show(
                mob,
                null,
                CMMsg.MSG_OK_VISUAL,
                L("<S-NAME> turn(s) into a @x1!", lycanRace().name()));
        mob.recoverCharStats();
        mob.recoverPhyStats();
        mob.recoverMaxState();
        mob.location().recoverRoomStats();
      }
    } else {
      if (mob.location() == null) return true;
      final Area A = mob.location().getArea();
      if (((A.getTimeObj().getTODCode() != TimeClock.TimeOfDay.DUSK)
              && (A.getTimeObj().getTODCode() != TimeClock.TimeOfDay.NIGHT))
          || (A.getTimeObj().getMoonPhase() != TimeClock.MoonPhase.FULL)) {
        changed = false;
        mob.location().show(mob, null, CMMsg.MSG_OK_VISUAL, L("<S-NAME> revert(s) to normal."));
        mob.recoverCharStats();
        mob.recoverPhyStats();
        mob.recoverMaxState();
        mob.location().recoverRoomStats();
        return true;
      }
      tickLycanthropically(mob);
    }
    return true;
  }
Ejemplo n.º 4
0
  @Override
  public boolean invoke(MOB mob, Vector commands, Physical givenTarget, boolean auto, int asLevel) {
    if (!super.invoke(mob, commands, givenTarget, auto, asLevel)) return false;

    final boolean success = proficiencyCheck(mob, 0, auto);
    final String str =
        auto
            ? L("The unholy word is spoken.")
            : L("^S<S-NAME> speak(s) the unholy word@x1 to <T-NAMESELF>.^?", ofDiety(mob));

    final Room room = mob.location();
    if (room != null)
      for (int i = 0; i < room.numInhabitants(); i++) {
        final MOB target = room.fetchInhabitant(i);
        if (target == null) break;
        int affectType = CMMsg.MSG_CAST_VERBAL_SPELL;
        if (auto) affectType = affectType | CMMsg.MASK_ALWAYS;
        if (CMLib.flags().isGood(target)) affectType = affectType | CMMsg.MASK_MALICIOUS;

        if (success) {
          final CMMsg msg = CMClass.getMsg(mob, target, this, affectType, str);
          if (room.okMessage(mob, msg)) {
            room.send(mob, msg);
            if (msg.value() <= 0) {
              if (CMLib.flags().canBeHeardSpeakingBy(mob, target)) {
                final Item I = Prayer_Curse.getSomething(mob, true);
                if (I != null) {
                  Prayer_Curse.endLowerBlessings(I, CMLib.ableMapper().lowestQualifyingLevel(ID()));
                  I.recoverPhyStats();
                }
                Prayer_Curse.endLowerBlessings(
                    target, CMLib.ableMapper().lowestQualifyingLevel(ID()));
                beneficialAffect(mob, target, asLevel, 0);
                target.recoverPhyStats();
              } else if (CMath.bset(affectType, CMMsg.MASK_MALICIOUS))
                maliciousFizzle(mob, target, L("<T-NAME> did not hear the unholy word!"));
              else beneficialWordsFizzle(mob, target, L("<T-NAME> did not hear the unholy word!"));
            }
          }
        } else {
          if (CMath.bset(affectType, CMMsg.MASK_MALICIOUS))
            maliciousFizzle(
                mob,
                target,
                L("<S-NAME> attempt(s) to speak the unholy word to <T-NAMESELF>, but flub(s) it."));
          else
            beneficialWordsFizzle(
                mob,
                target,
                L("<S-NAME> attempt(s) to speak the unholy word to <T-NAMESELF>, but flub(s) it."));
          return false;
        }
      }

    // return whether it worked
    return success;
  }
Ejemplo n.º 5
0
  @Override
  public boolean okMessage(final Environmental myHost, final CMMsg msg) {
    if ((myHost == null) || (!(myHost instanceof MOB))) return super.okMessage(myHost, msg);

    final MOB mob = (MOB) myHost;
    if ((msg.amISource(mob)) && (mob.charStats().getClassLevel(this) > 4)) {
      if (((msg.sourceMinor() == CMMsg.TYP_BUY) || (msg.sourceMinor() == CMMsg.TYP_LIST))
          && (msg.tool() instanceof Potion)) {
        mob.basePhyStats().setDisposition(mob.basePhyStats().disposition() | PhyStats.IS_BONUS);
        mob.recoverPhyStats();
        mob.recoverCharStats();
      } else if ((mob.basePhyStats().disposition() & PhyStats.IS_BONUS) == PhyStats.IS_BONUS) {
        mob.basePhyStats().setDisposition(mob.basePhyStats().disposition() - PhyStats.IS_BONUS);
        mob.recoverPhyStats();
        mob.recoverCharStats();
      }
    }
    return super.okMessage(myHost, msg);
  }
Ejemplo n.º 6
0
 @Override
 public boolean tick(Tickable ticking, int tickID) {
   if ((ticking instanceof MOB)
       && ((((MOB) ticking).basePhyStats().disposition() & PhyStats.IS_BONUS)
           == PhyStats.IS_BONUS)) {
     ((MOB) ticking)
         .basePhyStats()
         .setDisposition(((MOB) ticking).basePhyStats().disposition() - PhyStats.IS_BONUS);
     ((MOB) ticking).recoverPhyStats();
   }
   return super.tick(ticking, tickID);
 }
Ejemplo n.º 7
0
 @Override
 public boolean okMessage(Environmental affecting, CMMsg msg) {
   if (!super.okMessage(affecting, msg)) return false;
   final MOB source = msg.source();
   if (!canFreelyBehaveNormal(affecting)) return true;
   final MOB observer = (MOB) affecting;
   if ((source != observer)
       && (msg.amITarget(observer))
       && (msg.targetMinor() == CMMsg.TYP_GIVE)
       && (!CMSecurity.isAllowed(source, source.location(), CMSecurity.SecFlag.CMDROOMS))
       && (msg.tool() != null)) {
     if (!(msg.tool() instanceof Coins)) {
       CMLib.commands()
           .postSay(observer, source, L("I'm sorry, I can only accept money."), true, false);
       return false;
     } else if (!doIExchangeThisCurrency(affecting, ((Coins) msg.tool()).getCurrency())) {
       CMLib.commands()
           .postSay(
               observer,
               source,
               L("I'm sorry, I don't accept that kind of currency."),
               true,
               false);
       return false;
     }
     double value = ((Coins) msg.tool()).getTotalValue();
     final String currency = ((Coins) msg.tool()).getCurrency().toUpperCase();
     double takeCut = getMyCut(affecting, currency);
     double amountToTake = CMLib.beanCounter().abbreviatedRePrice(observer, value * takeCut);
     if ((amountToTake > 0.0)
         && (amountToTake
             < CMLib.beanCounter()
                 .getLowestDenomination(CMLib.beanCounter().getCurrency(observer))))
       amountToTake =
           CMLib.beanCounter().getLowestDenomination(CMLib.beanCounter().getCurrency(observer));
     value -= amountToTake;
     observer.recoverPhyStats();
     final Coins C = CMLib.beanCounter().makeBestCurrency(observer, value);
     if ((value <= 0) || (C == null)) {
       CMLib.commands()
           .postSay(
               observer,
               source,
               L("I'm sorry, I can not change such a small amount."),
               true,
               false);
       return false;
     }
   }
   return true;
 }
Ejemplo n.º 8
0
  @Override
  public boolean tick(Tickable ticking, int tickID) {
    if ((!built) && (affected instanceof MOB)) {
      built = true;
      CharClass C = null;
      final Vector allowedClasses = new Vector();
      final Vector allowedExpertises = new Vector();
      final Vector<String> V = CMParms.parse(text());
      String s = null;
      for (int v = 0; v < V.size(); v++) {
        s = V.elementAt(v);
        if (s.equalsIgnoreCase("all")) continue;
        C = CMClass.getCharClass(s);
        if (C != null) {
          if ((v > 0) && (V.elementAt(v - 1).equalsIgnoreCase("ALL"))) {
            final String baseClass = C.baseClass();
            for (final Enumeration c = CMClass.charClasses(); c.hasMoreElements(); ) {
              C = (CharClass) c.nextElement();
              if ((C.baseClass().equalsIgnoreCase(baseClass)) && (!allowedClasses.contains(C)))
                allowedClasses.addElement(C);
            }
          } else allowedClasses.addElement(C);
        } else {
          final ExpertiseLibrary.ExpertiseDefinition def = CMLib.expertises().getDefinition(s);
          if (def != null) allowedExpertises.addElement(def);
        }
      }
      if (allowedClasses.size() == 0)
        for (final Enumeration c = CMClass.charClasses(); c.hasMoreElements(); )
          allowedClasses.addElement(c.nextElement());
      if (allowedExpertises.size() == 0)
        for (final Enumeration e = CMLib.expertises().definitions(); e.hasMoreElements(); )
          allowedExpertises.addElement(e.nextElement());

      final MOB mob = (MOB) affected;
      for (int c = 0; c < allowedClasses.size(); c++) {
        C = (CharClass) allowedClasses.elementAt(c);
        addCharClassIfNotFound(mob, C);
      }
      for (int e = 0; e < allowedExpertises.size(); e++)
        mob.addExpertise(
            ((ExpertiseLibrary.ExpertiseDefinition) allowedExpertises.elementAt(e)).ID);
      mob.recoverCharStats();
      mob.recoverPhyStats();
      mob.recoverMaxState();
    }
    return super.tick(ticking, tickID);
  }
Ejemplo n.º 9
0
  @Override
  public boolean invoke(MOB mob, Vector commands, Physical givenTarget, boolean auto, int asLevel) {
    final Item target = getTarget(mob, mob.location(), givenTarget, commands, Wearable.FILTER_ANY);
    if (target == null) return false;

    final Room room = CMLib.map().roomLocation(mob);
    if ((room == null) || (room.getArea() == null)) return false;
    final String roomID = CMLib.map().getExtendedRoomID(room);
    if ((CMath.bset(room.getArea().flags(), Area.FLAG_INSTANCE_CHILD)) || (roomID.length() == 0)) {
      mob.tell(L("The magic in this place will not permit it to become a refuge."));
      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("^S<S-NAME> point(s) at <T-NAMESELF> and @x1.^?", prayWord(mob)));
      if (mob.location().okMessage(mob, msg)) {
        mob.location().send(mob, msg);
        mob.location().show(mob, target, CMMsg.MSG_OK_VISUAL, L("<T-NAME> glows slightly!"));
        mob.tell(
            L(
                "@x1 will now await someone to 'SAYTO \"@x1\" Refuge' to it before teleporting you back here.",
                target.name(mob)));
        final Ability A = beneficialAffect(mob, target, asLevel, Ability.TICKS_ALMOST_FOREVER);
        if (A != null) A.setMiscText(roomID);
        target.recoverPhyStats();
        mob.recoverPhyStats();
      }

    } else
      beneficialVisualFizzle(
          mob, target, L("<S-NAME> point(s) at <T-NAMESELF>, but fail(s) to properly pray."));

    // return whether it worked
    return success;
  }
Ejemplo n.º 10
0
 public static java.util.List<Ability> returnOffensiveAffects(Physical fromMe) {
   final MOB newMOB = CMClass.getFactoryMOB();
   newMOB.setLocation(CMLib.map().roomLocation(fromMe));
   final List<Ability> offenders = new Vector<Ability>();
   for (int a = 0; a < fromMe.numEffects(); a++) // personal
   {
     final Ability A = fromMe.fetchEffect(a);
     if ((A != null) && (A.canBeUninvoked())) {
       try {
         newMOB.recoverPhyStats();
         A.affectPhyStats(newMOB, newMOB.phyStats());
         if (CMLib.flags().isInvisible(newMOB) || CMLib.flags().isHidden(newMOB)) offenders.add(A);
       } catch (final Exception e) {
       }
     }
   }
   newMOB.destroy();
   return offenders;
 }
Ejemplo n.º 11
0
  @Override
  public boolean okMessage(final Environmental myHost, final CMMsg msg) {
    if (!(affected instanceof MOB)) return true;

    final MOB mob = (MOB) affected;
    if ((msg.amITarget(mob))
        && (CMath.bset(msg.targetMajor(), CMMsg.MASK_MALICIOUS))
        && (msg.tool() instanceof Ability)
        && (!mob.amDead())) {
      final Ability A = (Ability) msg.tool();
      if (CMath.bset(A.flags(), Ability.FLAG_PARALYZING)) {
        msg.addTrailerMsg(
            CMClass.getMsg(
                mob,
                null,
                CMMsg.MSG_OK_VISUAL,
                L("The uninhibiting barrier around <S-NAME> repels the @x1.", A.name())));
        return false;
      }
      final MOB newMOB = CMClass.getFactoryMOB();
      final CMMsg msg2 = CMClass.getMsg(newMOB, null, null, CMMsg.MSG_SIT, null);
      newMOB.recoverPhyStats();
      try {
        A.affectPhyStats(newMOB, newMOB.phyStats());
        if ((!CMLib.flags().aliveAwakeMobileUnbound(newMOB, true))
            || (CMath.bset(A.flags(), Ability.FLAG_PARALYZING))
            || (!A.okMessage(newMOB, msg2))) {
          msg.addTrailerMsg(
              CMClass.getMsg(
                  mob,
                  null,
                  CMMsg.MSG_OK_VISUAL,
                  L("The uninhibiting barrier around <S-NAME> repels the @x1.", A.name())));
          newMOB.destroy();
          return false;
        }
      } catch (final Exception e) {
      }
      newMOB.destroy();
    }
    return true;
  }
Ejemplo n.º 12
0
  @Override
  public boolean invoke(
      MOB mob, List<String> commands, Physical givenTarget, boolean auto, int asLevel) {
    final MOB target = getTarget(mob, commands, givenTarget);
    if (target == null) return false;
    final Room targetRoom = target.location();
    if (targetRoom == null) return false;

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

    final boolean success = proficiencyCheck(mob, 0, auto);

    if (success) {
      beneficialAffect(mob, target, asLevel, 0);
      target.recoverPhyStats();
      targetRoom.recoverRoomStats();
    }
    // return whether it worked
    return success;
  }
Ejemplo n.º 13
0
  @Override
  public boolean tick(Tickable ticking, int tickID) {
    if (!(affected instanceof MOB)) return super.tick(ticking, tickID);

    if (!super.tick(ticking, tickID)) return false;
    if ((--plagueDown) <= 0) {
      final MOB mob = (MOB) affected;
      plagueDown = 10;
      if (invoker == null) invoker = mob;
      drawups += .1;
      if (drawups >= 3.1) {
        if ((mob.location() != null) && (CMLib.flags().isInTheGame(mob, false))) {
          mob.location().show(mob, null, CMMsg.MSG_OK_VISUAL, L("<S-YOU-POSS> feet rot off!"));
          final Ability A = CMClass.getAbility("Amputation");
          if (A != null) {
            int x = 100;
            while (((--x) > 0) && A.invoke(mob, CMParms.parse("foot"), mob, true, 0)) {
              /*do nothing */
            }
            mob.recoverCharStats();
            mob.recoverPhyStats();
            mob.recoverMaxState();
          }
          unInvoke();
        }
      } else {
        final MOB invoker = (invoker() != null) ? invoker() : mob;
        CMLib.combat()
            .postDamage(
                invoker,
                mob,
                this,
                1,
                CMMsg.TYP_DISEASE,
                -1,
                L(
                    "<T-NAME> feel(s) the fungus between <T-HIS-HER> toes eating <T-HIS-HER> feet away!"));
      }
    }
    return true;
  }
Ejemplo n.º 14
0
  @Override
  public boolean invoke(MOB mob, Vector commands, Physical givenTarget, boolean auto, int asLevel) {
    final MOB target = getTarget(mob, commands, givenTarget);
    if (target == null) return false;

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

    final boolean success = proficiencyCheck(mob, 0, auto);
    final List<Ability> offensiveAffects = returnOffensiveAffects(target);

    if ((success) && (offensiveAffects.size() > 0)) {
      final CMMsg msg =
          CMClass.getMsg(
              mob,
              target,
              this,
              verbalCastCode(mob, target, auto),
              auto
                  ? L("<T-NAME> feel(s) the poison slowing down.")
                  : L("^S<S-NAME> chant(s) for the poisons in <T-NAME> to be slowed down.^?"));
      if (mob.location().okMessage(mob, msg)) {
        mob.location().send(mob, msg);
        Chant_DelayPoison pA = (Chant_DelayPoison) beneficialAffect(mob, target, asLevel, 0);
        if (pA != null) {
          pA.poisonAffects = offensiveAffects;
          for (Ability A : offensiveAffects) {
            target.delEffect(A);
            A.setAffectedOne(target);
          }
        }
        target.recoverPhyStats();
      }
    } else
      beneficialWordsFizzle(
          mob, target, auto ? "" : L("<S-NAME> chant(s) for <T-NAME>, but nothing happens."));

    // return whether it worked
    return success;
  }
Ejemplo n.º 15
0
  public List<Ability> returnOffensiveAffects(MOB caster, Physical fromMe) {
    MOB newMOB = CMClass.getFactoryMOB();
    MOB newerMOB = CMClass.getFactoryMOB();
    Vector offenders = new Vector(1);

    CMMsg msg = CMClass.getMsg(newMOB, newerMOB, null, CMMsg.MSG_LOOK, null);
    for (int a = 0; a < fromMe.numEffects(); a++) // personal
    {
      Ability A = fromMe.fetchEffect(a);
      if (A != null) {
        newMOB.recoverPhyStats();
        A.affectPhyStats(newMOB, newMOB.phyStats());
        if ((!CMLib.flags().canSee(newMOB)) || (!A.okMessage(newMOB, msg)))
          if ((A.invoker() == null)
              || ((A.invoker() != null)
                  && (A.invoker().phyStats().level())
                      <= (caster.phyStats().level() + 1 + (2 * getXLEVELLevel(caster)))))
            offenders.addElement(A);
      }
    }
    newMOB.destroy();
    newerMOB.destroy();
    return offenders;
  }
Ejemplo n.º 16
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;
  }
Ejemplo n.º 17
0
  @Override
  public boolean invoke(
      MOB mob, List<String> commands, Physical givenTarget, boolean auto, int asLevel) {
    final Physical target = getAnyTarget(mob, commands, givenTarget, Wearable.FILTER_ANY, true);
    if (target == null) return false;

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

    int type = verbalCastCode(mob, target, auto);
    if ((target instanceof MOB)
        && (CMath.bset(type, CMMsg.MASK_MALICIOUS))
        && (((MOB) target).charStats().getStat(CharStats.STAT_AGE) > 0)) {
      final MOB mobt = (MOB) target;
      if (mobt.charStats().ageCategory() <= Race.AGE_CHILD)
        type = CMath.unsetb(type, CMMsg.MASK_MALICIOUS);
      else if ((mobt.getLiegeID().equals(mob.Name())) || (mobt.amFollowing() == mob))
        type = CMath.unsetb(type, CMMsg.MASK_MALICIOUS);
      else if ((mobt.charStats().ageCategory() <= Race.AGE_MATURE)
          && (mobt.getLiegeID().length() > 0)) type = CMath.unsetb(type, CMMsg.MASK_MALICIOUS);
    }

    if ((target instanceof Item)
        || ((target instanceof MOB)
            && (((MOB) target).isMonster())
            && (CMLib.flags().isAnimalIntelligence((MOB) target))
            && (CMLib.law().doesHavePriviledgesHere(mob, mob.location())))) {
      type = CMath.unsetb(type, CMMsg.MASK_MALICIOUS);
    }

    boolean success = proficiencyCheck(mob, 0, auto);
    if (success) {
      final CMMsg msg =
          CMClass.getMsg(
              mob, target, this, type, auto ? "" : L("^S<S-NAME> chant(s) to <T-NAMESELF>.^?"));
      if (mob.location().okMessage(mob, msg)) {
        mob.location().send(mob, msg);
        final Ability A = target.fetchEffect("Age");
        if ((!(target instanceof MOB)) && (!(target instanceof CagedAnimal)) && (A == null)) {
          if (target instanceof Food) {
            mob.tell(L("@x1 rots away!", target.name(mob)));
            ((Item) target).destroy();
          } else if (target instanceof Item) {
            switch (((Item) target).material() & RawMaterial.MATERIAL_MASK) {
              case RawMaterial.MATERIAL_CLOTH:
              case RawMaterial.MATERIAL_FLESH:
              case RawMaterial.MATERIAL_LEATHER:
              case RawMaterial.MATERIAL_PAPER:
              case RawMaterial.MATERIAL_VEGETATION:
              case RawMaterial.MATERIAL_WOODEN:
                {
                  mob.location()
                      .showHappens(CMMsg.MSG_OK_VISUAL, L("@x1 rots away!", target.name()));
                  if (target instanceof Container) ((Container) target).emptyPlease(false);
                  ((Item) target).destroy();
                  break;
                }
              default:
                mob.location()
                    .showHappens(
                        CMMsg.MSG_OK_VISUAL,
                        L("@x1 ages, but nothing happens to it.", target.name()));
                break;
            }
          } else
            mob.location()
                .showHappens(
                    CMMsg.MSG_OK_VISUAL, L("@x1 ages, but nothing happens to it.", target.name()));
          success = false;
        } else if ((target instanceof MOB) && ((A == null) || (A.displayText().length() == 0))) {
          final MOB M = (MOB) target;
          mob.location().show(M, null, CMMsg.MSG_OK_VISUAL, L("<S-NAME> age(s) a bit."));
          if (M.baseCharStats().getStat(CharStats.STAT_AGE) <= 0)
            M.setAgeMinutes(M.getAgeMinutes() + (M.getAgeMinutes() / 10));
          else if ((M.playerStats() != null) && (M.playerStats().getBirthday() != null)) {
            final TimeClock C = CMLib.time().localClock(M.getStartRoom());
            final double aging = CMath.mul(M.baseCharStats().getStat(CharStats.STAT_AGE), .10);
            int years = (int) Math.round(Math.floor(aging));
            final int monthsInYear = C.getMonthsInYear();
            int months = (int) Math.round(CMath.mul(aging - Math.floor(aging), monthsInYear));
            if ((years <= 0) && (months == 0)) months++;
            M.playerStats().getBirthday()[PlayerStats.BIRTHDEX_YEAR] -= years;
            M.playerStats().getBirthday()[PlayerStats.BIRTHDEX_MONTH] -= months;
            if (M.playerStats().getBirthday()[PlayerStats.BIRTHDEX_MONTH] < 1) {
              M.playerStats().getBirthday()[PlayerStats.BIRTHDEX_YEAR]--;
              years++;
              M.playerStats().getBirthday()[PlayerStats.BIRTHDEX_MONTH] =
                  monthsInYear + M.playerStats().getBirthday()[PlayerStats.BIRTHDEX_MONTH];
            }
            M.baseCharStats()
                .setStat(CharStats.STAT_AGE, M.baseCharStats().getStat(CharStats.STAT_AGE) + years);
          }
          M.recoverPhyStats();
          M.recoverCharStats();
        } else if (A != null) {
          final long start = CMath.s_long(A.text());
          long age = System.currentTimeMillis() - start;
          final long millisPerMudday =
              CMProps.getIntVar(CMProps.Int.TICKSPERMUDDAY) * CMProps.getTickMillis();
          if (age < millisPerMudday) age = millisPerMudday;
          final long millisPerMonth = CMLib.time().globalClock().getDaysInMonth() * millisPerMudday;
          final long millisPerYear = CMLib.time().globalClock().getMonthsInYear() * millisPerMonth;
          long ageBy = age / 10;
          if (ageBy < millisPerMonth) ageBy = millisPerMonth + 1;
          else if (ageBy < millisPerYear) ageBy = millisPerYear + 1;
          A.setMiscText("" + (start - ageBy));
          if (target instanceof MOB)
            mob.location()
                .show((MOB) target, null, CMMsg.MSG_OK_VISUAL, L("<S-NAME> age(s) a bit."));
          else mob.location().showHappens(CMMsg.MSG_OK_VISUAL, L("@x1 ages a bit.", target.name()));
          target.recoverPhyStats();
        } else
          return beneficialWordsFizzle(
              mob, target, L("<S-NAME> chant(s) to <T-NAMESELF>, but the magic fades."));
      }
    } else if (CMath.bset(type, CMMsg.MASK_MALICIOUS))
      return maliciousFizzle(
          mob, target, L("<S-NAME> chant(s) to <T-NAMESELF>, but the magic fades."));
    else
      return beneficialWordsFizzle(
          mob, target, L("<S-NAME> chant(s) to <T-NAMESELF>, but the magic fades."));

    // return whether it worked
    return success;
  }
Ejemplo n.º 18
0
  @Override
  public boolean invoke(
      MOB mob, List<String> commands, Physical givenTarget, boolean auto, int asLevel) {
    final Physical target = getAnyTarget(mob, commands, givenTarget, Wearable.FILTER_UNWORNONLY);
    if (target == null) return false;

    if (target == mob) {
      mob.tell(L("@x1 doesn't look dead yet.", target.name(mob)));
      return false;
    }
    if (!(target instanceof DeadBody)) {
      mob.tell(L("You can't animate that."));
      return false;
    }

    final DeadBody body = (DeadBody) target;
    if (body.isPlayerCorpse()
        || (body.getMobName().length() == 0)
        || ((body.charStats() != null)
            && (body.charStats().getMyRace() != null)
            && (body.charStats().getMyRace().racialCategory().equalsIgnoreCase("Undead")))) {
      mob.tell(L("You can't animate that."));
      return false;
    }
    String race = "a";
    if ((body.charStats() != null) && (body.charStats().getMyRace() != null))
      race = CMLib.english().startWithAorAn(body.charStats().getMyRace().name()).toLowerCase();

    String description = body.getMobDescription();
    if (description.trim().length() == 0) description = "It looks dead.";
    else description += "\n\rIt also looks dead.";

    if (body.basePhyStats().level() < 7) {
      mob.tell(L("This creature is too weak to create a ghast from."));
      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("^S<S-NAME> @x1 to animate <T-NAMESELF> as a ghast.^?", prayForWord(mob)));
      if (mob.location().okMessage(mob, msg)) {
        mob.location().send(mob, msg);
        int undeadLevel = this.getUndeadLevel(mob, 6, body.phyStats().level());
        final MOB newMOB = CMClass.getMOB("GenUndead");
        newMOB.setName(L("@x1 ghast", race));
        newMOB.setDescription(description);
        newMOB.setDisplayText(L("@x1 ghast is here", race));
        newMOB.basePhyStats().setLevel(undeadLevel);
        newMOB
            .baseCharStats()
            .setStat(CharStats.STAT_GENDER, body.charStats().getStat(CharStats.STAT_GENDER));
        newMOB.baseCharStats().setMyRace(CMClass.getRace("Undead"));
        newMOB
            .baseCharStats()
            .setBodyPartsFromStringAfterRace(body.charStats().getBodyPartsAsString());
        final Ability P = CMClass.getAbility("Prop_StatTrainer");
        if (P != null) {
          P.setMiscText("NOTEACH STR=20 INT=10 WIS=10 CON=10 DEX=15 CHA=2");
          newMOB.addNonUninvokableEffect(P);
        }
        newMOB.recoverCharStats();
        newMOB.basePhyStats().setAttackAdjustment(CMLib.leveler().getLevelAttack(newMOB));
        newMOB.basePhyStats().setDamage(CMLib.leveler().getLevelMOBDamage(newMOB));
        newMOB.basePhyStats().setSensesMask(PhyStats.CAN_SEE_DARK);
        CMLib.factions().setAlignment(newMOB, Faction.Align.EVIL);
        newMOB.baseState().setHitPoints(25 * newMOB.basePhyStats().level());
        newMOB.baseState().setMovement(CMLib.leveler().getLevelMove(newMOB));
        newMOB.basePhyStats().setArmor(CMLib.leveler().getLevelMOBArmor(newMOB));
        newMOB.baseState().setMana(100);
        newMOB.recoverCharStats();
        newMOB.recoverPhyStats();
        newMOB.recoverMaxState();
        newMOB.resetToMaxState();
        newMOB.addAbility(CMClass.getAbility("Paralysis"));
        Behavior B = CMClass.getBehavior("CombatAbilities");
        if (B != null) newMOB.addBehavior(B);
        B = CMClass.getBehavior("Aggressive");
        if (B != null) {
          B.setParms("+NAMES \"-" + mob.Name() + "\" -LEVEL +>" + newMOB.basePhyStats().level());
          newMOB.addBehavior(B);
        }
        newMOB.addNonUninvokableEffect(CMClass.getAbility("Spell_CauseStink"));
        newMOB.addNonUninvokableEffect(CMClass.getAbility("Prop_ModExperience"));
        newMOB.text();
        newMOB.bringToLife(mob.location(), true);
        CMLib.beanCounter().clearZeroMoney(newMOB, null);
        // newMOB.location().showOthers(newMOB,null,CMMsg.MSG_OK_ACTION,L("<S-NAME> appears!"));
        int it = 0;
        while (it < newMOB.location().numItems()) {
          final Item item = newMOB.location().getItem(it);
          if ((item != null) && (item.container() == body)) {
            final CMMsg msg2 = CMClass.getMsg(newMOB, body, item, CMMsg.MSG_GET, null);
            newMOB.location().send(newMOB, msg2);
            final CMMsg msg4 = CMClass.getMsg(newMOB, item, null, CMMsg.MSG_GET, null);
            newMOB.location().send(newMOB, msg4);
            final CMMsg msg3 = CMClass.getMsg(newMOB, item, null, CMMsg.MSG_WEAR, null);
            newMOB.location().send(newMOB, msg3);
            if (!newMOB.isMine(item)) it++;
            else it = 0;
          } else it++;
        }
        body.destroy();
        mob.location().show(newMOB, null, CMMsg.MSG_OK_ACTION, L("<S-NAME> begin(s) to rise!"));
        newMOB.setStartRoom(null);
        beneficialAffect(mob, newMOB, 0, 0);
        mob.location().recoverRoomStats();
      }
    } else
      return beneficialWordsFizzle(
          mob,
          target,
          L("<S-NAME> @x1 to animate <T-NAMESELF>, but fail(s) miserably.", prayForWord(mob)));

    // return whether it worked
    return success;
  }