Пример #1
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()) && ((--diseaseTick) <= 0)) {
      diseaseTick = DISEASE_DELAY();
      if (mob.maxState().getFatigue() > Long.MIN_VALUE / 2)
        mob.curState()
            .adjFatigue(mob.curState().getFatigue() + CharState.FATIGUED_MILLIS, mob.maxState());
      mob.location().show(mob, null, CMMsg.MSG_NOISE, DISEASE_AFFECT());
      if (!CMLib.flags().isSleeping(mob)) {
        final Command C = CMClass.getCommand("Sleep");
        try {
          if (C != null) C.execute(mob, CMParms.parse("Sleep"), Command.METAFLAG_FORCED);
        } catch (final Exception e) {
        }
      }
      return true;
    }
    return true;
  }
Пример #2
0
  @Override
  public boolean tick(Tickable ticking, int tickID) {
    if (!(affected instanceof MOB)) return super.tick(ticking, tickID);

    final MOB mob = (MOB) affected;

    if (tickID != Tickable.TICKID_MOB) return true;
    if (!proficiencyCheck(null, 0, false)) return true;

    if ((!mob.isInCombat()) && (CMLib.flags().isSleeping(mob))) {
      roundsHibernating++;
      final double man =
          ((mob.charStats().getStat(CharStats.STAT_INTELLIGENCE)
              + mob.charStats().getStat(CharStats.STAT_WISDOM)));
      mob.curState()
          .adjMana(
              (int)
                  Math.round(
                      (man * .1)
                          + ((mob.phyStats().level() + (2.0 * super.getXLEVELLevel(invoker())))
                              / 2.0)),
              mob.maxState());
      mob.curState().setHunger(oldState.getHunger());
      mob.curState().setThirst(oldState.getThirst());
      final double move = mob.charStats().getStat(CharStats.STAT_STRENGTH);
      mob.curState()
          .adjMovement(
              (int)
                  Math.round(
                      (move * .1)
                          + ((mob.phyStats().level() + (2.0 * super.getXLEVELLevel(invoker())))
                              / 2.0)),
              mob.maxState());
      if (!CMLib.flags().isGolem(mob)) {
        final double hp = mob.charStats().getStat(CharStats.STAT_CONSTITUTION);
        if (!CMLib.combat()
            .postHealing(
                mob,
                mob,
                this,
                CMMsg.MASK_ALWAYS | CMMsg.TYP_CAST_SPELL,
                (int)
                    Math.round(
                        (hp * .1)
                            + ((mob.phyStats().level() + (2.0 * super.getXLEVELLevel(invoker())))
                                / 2.0)),
                null)) unInvoke();
      }
    } else {
      unInvoke();
      return false;
    }
    return super.tick(ticking, tickID);
  }
Пример #3
0
  @Override
  public void unInvoke() {
    // undo the affects of this spell
    if (!(affected instanceof MOB)) return;
    final MOB mob = (MOB) affected;

    super.unInvoke();

    if (canBeUninvoked()) {
      mob.tell(L("You feel less rallied."));
      mob.recoverMaxState();
      if (mob.curState().getHitPoints() > mob.maxState().getHitPoints())
        mob.curState().setHitPoints(mob.maxState().getHitPoints());
    }
  }
Пример #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);
    if (success) {
      final CMMsg msg =
          CMClass.getMsg(
              mob,
              null,
              this,
              CMMsg.MSG_SPEAK,
              auto ? "" : L("^S<S-NAME> scream(s) a mighty RALLYING CRY!!^?"));
      if (mob.location().okMessage(mob, msg)) {
        mob.location().send(mob, msg);
        final Set<MOB> h = properTargets(mob, givenTarget, auto);
        if (h == null) return false;
        for (final Object element : h) {
          final MOB target = (MOB) element;
          target.location().show(target, null, CMMsg.MSG_OK_VISUAL, L("<S-NAME> seem(s) rallied!"));
          timesTicking = 0;
          hpUp = mob.phyStats().level() + (2 * getXLEVELLevel(mob));
          beneficialAffect(mob, target, asLevel, 0);
          target.recoverMaxState();
          if (target.fetchEffect(ID()) != null) mob.curState().adjHitPoints(hpUp, mob.maxState());
        }
      }
    } else beneficialWordsFizzle(mob, null, auto ? "" : L("<S-NAME> mumble(s) a weak rally cry."));

    // return whether it worked
    return success;
  }
Пример #5
0
 @Override
 public void executeMsg(final Environmental myHost, final CMMsg msg) {
   if ((msg.amITarget(this)
           || (msg.targetMinor() == CMMsg.TYP_ADVANCE)
           || (msg.targetMinor() == CMMsg.TYP_RETREAT))
       && (!msg.source().isMonster())
       && (msg.source().curState().getHitPoints() < msg.source().maxState().getHitPoints())
       && (CMLib.dice().rollPercentage() == 1)
       && (CMLib.dice().rollPercentage() == 1)
       && (!CMSecurity.isDisabled(CMSecurity.DisFlag.AUTODISEASE))) {
     Ability A = null;
     if (CMLib.dice().rollPercentage() > 50) A = CMClass.getAbility("Disease_Chlamydia");
     else A = CMClass.getAbility("Disease_Malaria");
     if ((A != null) && (msg.source().fetchEffect(A.ID()) == null))
       A.invoke(msg.source(), msg.source(), true, 0);
   }
   if (msg.amITarget(this) && (msg.targetMinor() == CMMsg.TYP_DRINK)) {
     final MOB mob = msg.source();
     final boolean thirsty = mob.curState().getThirst() <= 0;
     final boolean full =
         !mob.curState().adjThirst(thirstQuenched(), mob.maxState().maxThirst(mob.baseWeight()));
     if (thirsty) mob.tell(L("You are no longer thirsty."));
     else if (full) mob.tell(L("You have drunk all you can."));
     if (CMLib.dice().rollPercentage() < 10) {
       Ability A = CMClass.getAbility("Disease_Malaria");
       if ((A != null) && (msg.source().fetchEffect(A.ID()) == null))
         A.invoke(msg.source(), msg.source(), true, 0);
     }
   }
   super.executeMsg(myHost, msg);
 }
Пример #6
0
 @Override
 public void executeMsg(final Environmental myHost, final CMMsg msg) {
   super.executeMsg(myHost, msg);
   if (msg.amITarget(this) && (msg.targetMinor() == CMMsg.TYP_DRINK)) {
     final MOB mob = msg.source();
     final boolean thirsty = mob.curState().getThirst() <= 0;
     final boolean full =
         !mob.curState().adjThirst(thirstQuenched(), mob.maxState().maxThirst(mob.baseWeight()));
     if (thirsty) mob.tell(L("You are no longer thirsty."));
     else if (full) mob.tell(L("You have drunk all you can."));
   } else if ((msg.tool() == this)
       && (msg.targetMinor() == CMMsg.TYP_FILL)
       && (msg.target() instanceof Container)
       && (((Container) msg.target()).capacity() > 0)) {
     final Container container = (Container) msg.target();
     final Item I = CMClass.getItem("GenLiquidResource");
     I.setName(L("some milk"));
     I.setDisplayText(L("some milk has been left here."));
     I.setDescription(L("It looks like milk"));
     I.setMaterial(RawMaterial.RESOURCE_MILK);
     I.setBaseValue(RawMaterial.CODES.VALUE(RawMaterial.RESOURCE_MILK));
     I.basePhyStats().setWeight(1);
     CMLib.materials().addEffectsToResource(I);
     I.recoverPhyStats();
     I.setContainer(container);
     if (container.owner() != null)
       if (container.owner() instanceof MOB) ((MOB) container.owner()).addItem(I);
       else if (container.owner() instanceof Room)
         ((Room) container.owner()).addItem(I, ItemPossessor.Expire.Resource);
   }
 }
Пример #7
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);

    if (success) {
      invoker = mob;
      final CMMsg msg =
          CMClass.getMsg(
              mob,
              target,
              this,
              verbalCastCode(mob, target, auto),
              auto ? "" : L("^S<S-NAME> incant(s) to <T-NAMESELF>.^?"));
      if (mob.location().okMessage(mob, msg)) {
        mob.location().send(mob, msg);
        if (msg.value() <= 0) {
          target
              .curState()
              .adjThirst(
                  -150 - ((mob.phyStats().level() + (2 * getXLEVELLevel(mob))) * 100),
                  target.maxState().maxThirst(target.baseWeight()));
          mob.location()
              .show(target, null, CMMsg.MSG_OK_VISUAL, L("<S-NAME> feel(s) incredibly thirsty!"));
        }
      }
    } else
      return maliciousFizzle(
          mob, target, L("<S-NAME> incant(s) to <T-NAMESELF>, but the spell fades."));
    // return whether it worked
    return success;
  }
Пример #8
0
  @Override
  public boolean okMessage(final Environmental myHost, final CMMsg msg) {
    if (!(myHost instanceof MOB)) return super.okMessage(myHost, msg);

    final MOB myChar = (MOB) myHost;
    if (msg.tool() instanceof Ability) {
      if (msg.amISource(myChar)
          && (!myChar.isMonster())
          && (msg.sourceMinor() != CMMsg.TYP_PREINVOKE)) {
        final WeakReference<Ability> curRef = invokable;
        if ((curRef != null) && (msg.tool() == curRef.get())) {
          curRef.clear();
          final Ability A = ((Ability) msg.tool());
          final int[] usageCost = A.usageCost(myChar, false);
          if (CMath.bset(A.usageType(), Ability.USAGE_MANA))
            myChar.curState().adjMana(usageCost[Ability.USAGEINDEX_MANA] / 4, myChar.maxState());
          if (CMath.bset(A.usageType(), Ability.USAGE_MOVEMENT))
            myChar
                .curState()
                .adjMovement(usageCost[Ability.USAGEINDEX_MOVEMENT] / 4, myChar.maxState());
          if (CMath.bset(A.usageType(), Ability.USAGE_HITPOINTS))
            myChar
                .curState()
                .adjHitPoints(usageCost[Ability.USAGEINDEX_HITPOINTS] / 4, myChar.maxState());
        }
      } else if (msg.amITarget(myChar)) {
        if (((((Ability) msg.tool()).classificationCode() & Ability.ALL_ACODES)
                == Ability.ACODE_SPELL)
            && ((((Ability) msg.tool()).classificationCode() & Ability.ALL_DOMAINS)
                == Ability.DOMAIN_DIVINATION)
            && (CMLib.dice().roll(1, 100, 0) < (myChar.charStats().getClassLevel(this) * 4))) {
          myChar
              .location()
              .show(
                  msg.source(),
                  myChar,
                  CMMsg.MSG_OK_ACTION,
                  L(
                      "<T-NAME> fool(s) <S-NAMESELF>, causing <S-HIM-HER> to fizzle @x1.",
                      msg.tool().name()));
          return false;
        }
      }
    }
    return super.okMessage(myHost, msg);
  }
Пример #9
0
  @Override
  public boolean invoke(MOB mob, Vector commands, Physical givenTarget, boolean auto, int asLevel) {
    final MOB target = this.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);

    if (success) {
      final CMMsg msg =
          CMClass.getMsg(
              mob,
              target,
              this,
              CMMsg.MASK_MALICIOUS | verbalCastCode(mob, target, auto),
              L(
                  auto
                      ? "A light fatigue overcomes <T-NAME>."
                      : "^S<S-NAME> "
                          + prayWord(mob)
                          + " for extreme fatigue to overcome <T-NAMESELF>!^?"));
      if (mob.location().okMessage(mob, msg)) {
        mob.location().send(mob, msg);
        if (msg.value() <= 0) {
          final int harming = CMLib.dice().roll(10, adjustedLevel(mob, asLevel), 50);
          if ((target.curState().getFatigue() <= CharState.FATIGUED_MILLIS)
              && (target.maxState().getFatigue() > Long.MIN_VALUE / 2))
            target.curState().setFatigue(CharState.FATIGUED_MILLIS + 1);
          target.curState().adjMovement(-harming, target.maxState());
          target.tell(L("You feel fatigued!"));
        }
      }
    } else
      return maliciousFizzle(
          mob,
          target,
          L("<S-NAME> point(s) at <T-NAMESELF> and @x1, but nothing happens.", prayWord(mob)));

    // return whether it worked
    return success;
  }
Пример #10
0
  @Override
  public boolean invoke(MOB mob, Vector commands, Physical givenTarget, boolean auto, int asLevel) {
    final MOB target = this.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);

    if (success) {
      final CMMsg msg =
          CMClass.getMsg(
              mob,
              target,
              this,
              verbalCastCode(mob, target, auto),
              auto
                  ? L("A bright yellow glow surrounds <T-NAME>.")
                  : L(
                      "^S<S-NAME> @x1, delivering a strong touch of infusion to <T-NAMESELF>.^?",
                      prayWord(mob)));
      if (mob.location().okMessage(mob, msg)) {
        mob.location().send(mob, msg);
        target.curState().setMana(target.maxState().getMana());
        target.curState().setHitPoints(target.maxState().getHitPoints());
        target.curState().setMana(target.maxState().getMana());
        target.curState().setMovement(target.maxState().getMovement());
        target.curState().setFatigue(0);
        target.curState().setHunger(target.maxState().getHunger());
        target.curState().setThirst(target.maxState().getThirst());
        target.tell(L("You feel refreshed!"));
        lastCastHelp = System.currentTimeMillis();
      }
    } else
      beneficialWordsFizzle(
          mob,
          target,
          auto ? "" : L("<S-NAME> @x1 for <T-NAMESELF>, but nothing happens.", prayWord(mob)));
    // return whether it worked
    return success;
  }
Пример #11
0
  @Override
  public String healthText(MOB viewer, MOB mob) {
    final double pct = (CMath.div(mob.curState().getHitPoints(), mob.maxState().getHitPoints()));

    if (pct < .10) return L("^r@x1^r is almost broken!^N", mob.name(viewer));
    else if (pct < .20) return L("^r@x1^r is massively cracked and damaged.^N", mob.name(viewer));
    else if (pct < .30) return L("^r@x1^r is extremely cracked and damaged.^N", mob.name(viewer));
    else if (pct < .40) return L("^y@x1^y is very cracked and damaged.^N", mob.name(viewer));
    else if (pct < .50) return L("^y@x1^y is cracked and damaged.^N", mob.name(viewer));
    else if (pct < .60) return L("^p@x1^p is cracked and slightly damaged.^N", mob.name(viewer));
    else if (pct < .70) return L("^p@x1^p is showing numerous cracks.^N", mob.name(viewer));
    else if (pct < .80) return L("^g@x1^g is showing some crachs.^N", mob.name(viewer));
    else if (pct < .90) return L("^g@x1^g is showing small cracks.^N", mob.name(viewer));
    else if (pct < .99) return L("^g@x1^g is no longer in perfect condition.^N", mob.name(viewer));
    else return L("^c@x1^c is in perfect condition.^N", mob.name(viewer));
  }
Пример #12
0
 public static boolean useTheWand(Ability A, MOB mob, int level) {
   int manaRequired = 5;
   final int q = CMLib.ableMapper().qualifyingLevel(mob, A);
   if (q > 0) {
     if (q < CMLib.ableMapper().qualifyingClassLevel(mob, A)) manaRequired = 0;
     else manaRequired = 5;
   } else manaRequired = 25;
   manaRequired -= (2 * level);
   if (manaRequired < 5) manaRequired = 5;
   if (manaRequired > mob.curState().getMana()) {
     mob.tell(CMLib.lang().L("You don't have enough mana."));
     return false;
   }
   mob.curState().adjMana(-manaRequired, mob.maxState());
   return true;
 }
Пример #13
0
  @Override
  public String healthText(MOB viewer, MOB mob) {
    final double pct = (CMath.div(mob.curState().getHitPoints(), mob.maxState().getHitPoints()));

    if (pct < .10) return L("^r@x1^r is near destruction!^N", mob.name(viewer));
    else if (pct < .20) return L("^r@x1^r is massively shredded and damaged.^N", mob.name(viewer));
    else if (pct < .30) return L("^r@x1^r is extremely shredded and damaged.^N", mob.name(viewer));
    else if (pct < .40) return L("^y@x1^y is very shredded and damaged.^N", mob.name(viewer));
    else if (pct < .50) return L("^y@x1^y is shredded and damaged.^N", mob.name(viewer));
    else if (pct < .60) return L("^p@x1^p is shredded and slightly damaged.^N", mob.name(viewer));
    else if (pct < .70) return L("^p@x1^p has lost numerous leaves.^N", mob.name(viewer));
    else if (pct < .80) return L("^g@x1^g has lost some leaves.^N", mob.name(viewer));
    else if (pct < .90) return L("^g@x1^g has lost a few leaves.^N", mob.name(viewer));
    else if (pct < .99) return L("^g@x1^g is no longer in perfect condition.^N", mob.name(viewer));
    else return L("^c@x1^c is in perfect condition.^N", mob.name(viewer));
  }
Пример #14
0
  @Override
  public String healthText(MOB viewer, MOB mob) {
    final double pct = (CMath.div(mob.curState().getHitPoints(), mob.maxState().getHitPoints()));

    if (pct < .10) return L("^r@x1^r is unstable and almost disintegrated!^N", mob.name(viewer));
    else if (pct < .20) return L("^r@x1^r is nearing disintegration.^N", mob.name(viewer));
    else if (pct < .30) return L("^r@x1^r is noticeably disintegrating.^N", mob.name(viewer));
    else if (pct < .40)
      return L("^y@x1^y is very damaged and slightly disintegrated.^N", mob.name(viewer));
    else if (pct < .50) return L("^y@x1^y is very damaged.^N", mob.name(viewer));
    else if (pct < .60) return L("^p@x1^p is starting to show major damage.^N", mob.name(viewer));
    else if (pct < .70) return L("^p@x1^p is definitely damaged.^N", mob.name(viewer));
    else if (pct < .80) return L("^g@x1^g is disheveled and mildly damaged.^N", mob.name(viewer));
    else if (pct < .90) return L("^g@x1^g is noticeably disheveled.^N", mob.name(viewer));
    else if (pct < .99) return L("^g@x1^g is slightly disheveled.^N", mob.name(viewer));
    else return L("^c@x1^c is in perfect condition.^N", mob.name(viewer));
  }
Пример #15
0
  @Override
  public String healthText(MOB viewer, MOB mob) {
    final double pct = (CMath.div(mob.curState().getHitPoints(), mob.maxState().getHitPoints()));

    if (pct < .10) return L("^r@x1^r is nearly defeated.^N", mob.name(viewer));
    else if (pct < .20) return L("^r@x1^r is covered in blood.^N", mob.name(viewer));
    else if (pct < .30)
      return L("^r@x1^r is bleeding badly from lots of wounds.^N", mob.name(viewer));
    else if (pct < .40)
      return L("^y@x1^y has numerous bloody wounds and gashes.^N", mob.name(viewer));
    else if (pct < .50) return L("^y@x1^y has some bloody wounds and gashes.^N", mob.name(viewer));
    else if (pct < .60) return L("^p@x1^p has a few bloody wounds.^N", mob.name(viewer));
    else if (pct < .70) return L("^p@x1^p is cut and bruised.^N", mob.name(viewer));
    else if (pct < .80) return L("^g@x1^g has some minor cuts and bruises.^N", mob.name(viewer));
    else if (pct < .90) return L("^g@x1^g has a few bruises and scratches.^N", mob.name(viewer));
    else if (pct < .99) return L("^g@x1^g has a few small bruises.^N", mob.name(viewer));
    else return L("^c@x1^c is in perfect health.^N", mob.name(viewer));
  }
Пример #16
0
  @Override
  public String healthText(MOB viewer, MOB mob) {
    final double pct = (CMath.div(mob.curState().getHitPoints(), mob.maxState().getHitPoints()));

    if (pct < .10) return L("^r@x1^r is one unhappy little critter!^N", mob.name(viewer));
    else if (pct < .20)
      return L("^r@x1^r is covered in blood and matted hair.^N", mob.name(viewer));
    else if (pct < .30)
      return L("^r@x1^r is bleeding badly from lots of wounds.^N", mob.name(viewer));
    else if (pct < .40)
      return L("^y@x1^y has large patches of bloody matted fur.^N", mob.name(viewer));
    else if (pct < .50) return L("^y@x1^y has some bloody matted fur.^N", mob.name(viewer));
    else if (pct < .60) return L("^p@x1^p has a lot of cuts and gashes.^N", mob.name(viewer));
    else if (pct < .70) return L("^p@x1^p has a few cut patches.^N", mob.name(viewer));
    else if (pct < .80) return L("^g@x1^g has a cut patch of fur.^N", mob.name(viewer));
    else if (pct < .90) return L("^g@x1^g has some disheveled fur.^N", mob.name(viewer));
    else if (pct < .99) return L("^g@x1^g has some misplaced hairs.^N", mob.name(viewer));
    else return L("^c@x1^c is in perfect health.^N", mob.name(viewer));
  }
Пример #17
0
  public String healthText(MOB viewer, MOB mob) {
    double pct = (CMath.div(mob.curState().getHitPoints(), mob.maxState().getHitPoints()));

    if (pct < .10) return "^r" + mob.displayName(viewer) + "^r is hovering on deaths door!^N";
    else if (pct < .20)
      return "^r" + mob.displayName(viewer) + "^r is covered in blood and matted hair.^N";
    else if (pct < .30)
      return "^r" + mob.displayName(viewer) + "^r is bleeding badly from lots of wounds.^N";
    else if (pct < .40)
      return "^y" + mob.displayName(viewer) + "^y has large patches of bloody matted fur.^N";
    else if (pct < .50) return "^y" + mob.displayName(viewer) + "^y has some bloody matted fur.^N";
    else if (pct < .60)
      return "^p" + mob.displayName(viewer) + "^p has a lot of cuts and gashes.^N";
    else if (pct < .70) return "^p" + mob.displayName(viewer) + "^p has a few cut patches.^N";
    else if (pct < .80) return "^g" + mob.displayName(viewer) + "^g has a cut patch of fur.^N";
    else if (pct < .90) return "^g" + mob.displayName(viewer) + "^g has some disheveled fur.^N";
    else if (pct < .99) return "^g" + mob.displayName(viewer) + "^g has some misplaced hairs.^N";
    else return "^c" + mob.displayName(viewer) + "^c is in perfect health.^N";
  }
Пример #18
0
  @Override
  public boolean invoke(
      MOB mob, List<String> commands, Physical givenTarget, boolean auto, int asLevel) {
    final MOB target = this.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);

    if (success) {
      final CMMsg msg =
          CMClass.getMsg(
              mob,
              target,
              this,
              somanticCastCode(mob, target, auto),
              L(auto ? "" : "^S<S-NAME> point(s) at <T-NAMESELF> and shout(s)!^?"));
      if (mob.location().okMessage(mob, msg)) {
        mob.location().send(mob, msg);
        invoker = mob;
        if (msg.value() > 0) {
          target
              .location()
              .show(target, null, CMMsg.MSG_OK_VISUAL, L("<T-NAME> become(s) exhausted!"));
          target.curState().setMovement(0);
          if (target.maxState().getFatigue() > Long.MIN_VALUE / 2)
            target
                .curState()
                .setFatigue(target.curState().getFatigue() + CharState.FATIGUED_MILLIS);
        }
      }
    } else
      return maliciousFizzle(
          mob,
          target,
          L("<S-NAME> point(s) and shout(s) at <T-NAMESELF>, but nothing more happens."));

    return success;
  }
Пример #19
0
 protected boolean stopFalling(MOB mob) {
   final Room R = mob.location();
   if (reversed()) {
     if (!hitTheCeiling) {
       hitTheCeiling = true;
       if (R != null)
         R.show(
             mob,
             null,
             CMMsg.MSG_OK_ACTION,
             L("<S-NAME> hit(s) the ceiling.@x1", CMLib.protocol().msp("splat.wav", 50)));
       CMLib.combat()
           .postDamage(
               mob, mob, this, damageToTake, CMMsg.MASK_ALWAYS | CMMsg.TYP_JUSTICE, -1, null);
     }
     return true;
   }
   hitTheCeiling = false;
   unInvoke();
   if (R != null) {
     if (isAirRoom(R))
       R.show(
           mob,
           null,
           CMMsg.MSG_OK_ACTION,
           L("<S-NAME> stop(s) falling.@x1", CMLib.protocol().msp("splat.wav", 50)));
     else if (CMLib.flags().isWaterySurfaceRoom(R) || CMLib.flags().isUnderWateryRoom(R))
       R.show(
           mob,
           null,
           CMMsg.MSG_OK_ACTION,
           L("<S-NAME> hit(s) the water.@x1", CMLib.protocol().msp("splat.wav", 50)));
     else {
       R.show(
           mob,
           null,
           CMMsg.MSG_OK_ACTION,
           L("<S-NAME> hit(s) the ground.@x1", CMLib.protocol().msp("splat.wav", 50)));
       if (CMath.div(damageToTake, mob.maxState().getHitPoints()) > 0.05) {
         LimbDamage damage = (LimbDamage) mob.fetchEffect("BrokenLimbs");
         if (damage == null) {
           damage = (LimbDamage) CMClass.getAbility("BrokenLimbs");
           damage.setAffectedOne(mob);
         }
         List<String> limbs = damage.unaffectedLimbSet();
         if (limbs.size() > 0) {
           if (mob.fetchEffect(damage.ID()) == null) {
             mob.addEffect(damage);
             damage.makeLongLasting();
           }
           damage.damageLimb(limbs.get(CMLib.dice().roll(1, limbs.size(), -1)));
         }
       }
     }
     CMLib.combat()
         .postDamage(
             mob, mob, this, damageToTake, CMMsg.MASK_ALWAYS | CMMsg.TYP_JUSTICE, -1, null);
   }
   mob.delEffect(this);
   return false;
 }
Пример #20
0
 public String builtPrompt(MOB mob) {
   StringBuffer buf = new StringBuffer("\n\r");
   String prompt = mob.playerStats().getPrompt();
   String promptUp = null;
   int c = 0;
   while (c < prompt.length())
     if ((prompt.charAt(c) == '%') && (c < (prompt.length() - 1))) {
       switch (prompt.charAt(++c)) {
         case '-':
           if (c < (prompt.length() - 2)) {
             if (promptUp == null) promptUp = prompt.toUpperCase();
             String promptSub = promptUp.substring(c + 1);
             Wearable.CODES wcodes = Wearable.CODES.instance();
             boolean isFound = false;
             for (long code : wcodes.all())
               if (promptSub.startsWith(wcodes.nameup(code))) {
                 c += 1 + wcodes.nameup(code).length();
                 Item I = mob.fetchFirstWornItem(code);
                 if (I != null) buf.append(I.name());
                 isFound = true;
                 break;
               }
             if (!isFound) {
               CharStats.CODES ccodes = CharStats.CODES.instance();
               for (int code : ccodes.all())
                 if (promptSub.startsWith(ccodes.name(code))) {
                   c += 1 + ccodes.name(code).length();
                   buf.append(mob.charStats().getStat(code));
                   isFound = true;
                   break;
                 }
               if (!isFound)
                 for (int code : ccodes.all())
                   if (promptSub.startsWith("BASE " + ccodes.name(code))) {
                     buf.append(mob.baseCharStats().getStat(code));
                     c += 6 + ccodes.name(code).length();
                     isFound = true;
                     break;
                   }
             }
             if (!isFound) {
               for (String s : mob.envStats().getStatCodes())
                 if (promptSub.startsWith(s)) {
                   c += 1 + s.length();
                   buf.append(mob.envStats().getStat(s));
                   isFound = true;
                   break;
                 }
               if (!isFound)
                 for (String s : mob.baseEnvStats().getStatCodes())
                   if (promptSub.startsWith("BASE " + s)) {
                     c += 6 + s.length();
                     buf.append(mob.baseEnvStats().getStat(s));
                     isFound = true;
                     break;
                   }
             }
             if (!isFound) {
               for (String s : mob.curState().getStatCodes())
                 if (promptSub.startsWith(s)) {
                   c += 1 + s.length();
                   buf.append(mob.curState().getStat(s));
                   isFound = true;
                   break;
                 }
               if (!isFound)
                 for (String s : mob.maxState().getStatCodes())
                   if (promptSub.startsWith("MAX " + s)) {
                     c += 5 + s.length();
                     buf.append(mob.maxState().getStat(s));
                     isFound = true;
                     break;
                   }
               if (!isFound)
                 for (String s : mob.baseState().getStatCodes())
                   if (promptSub.startsWith("BASE " + s)) {
                     c += 6 + s.length();
                     buf.append(mob.baseState().getStat(s));
                     isFound = true;
                     break;
                   }
             }
           }
           break;
         case 'a':
           {
             buf.append(
                 CMLib.factions()
                         .getRangePercent(
                             CMLib.factions().AlignID(),
                             mob.fetchFaction(CMLib.factions().AlignID()))
                     + "%");
             c++;
             break;
           }
         case 'A':
           {
             Faction.FactionRange FR =
                 CMLib.factions()
                     .getRange(
                         CMLib.factions().AlignID(), mob.fetchFaction(CMLib.factions().AlignID()));
             buf.append(
                 (FR != null) ? FR.name() : "" + mob.fetchFaction(CMLib.factions().AlignID()));
             c++;
             break;
           }
         case 'B':
           {
             buf.append("\n\r");
             c++;
             break;
           }
         case 'c':
           {
             buf.append(mob.inventorySize());
             c++;
             break;
           }
         case 'C':
           {
             buf.append(mob.maxItems());
             c++;
             break;
           }
         case 'd':
           {
             MOB victim = mob.getVictim();
             if ((mob.isInCombat()) && (victim != null)) buf.append("" + mob.rangeToTarget());
             c++;
             break;
           }
         case 'e':
           {
             MOB victim = mob.getVictim();
             if ((mob.isInCombat())
                 && (victim != null)
                 && (CMLib.flags().canBeSeenBy(victim, mob))) buf.append(victim.displayName(mob));
             c++;
             break;
           }
         case 'E':
           {
             MOB victim = mob.getVictim();
             if ((mob.isInCombat())
                 && (victim != null)
                 && (!victim.amDead())
                 && (CMLib.flags().canBeSeenBy(victim, mob)))
               buf.append(victim.healthText(mob) + "\n\r");
             c++;
             break;
           }
         case 'g':
           {
             buf.append(
                 (int)
                     Math.round(
                         Math.floor(
                             CMLib.beanCounter().getTotalAbsoluteNativeValue(mob)
                                 / CMLib.beanCounter()
                                     .getLowestDenomination(
                                         CMLib.beanCounter().getCurrency(mob)))));
             c++;
             break;
           }
         case 'G':
           {
             buf.append(
                 CMLib.beanCounter()
                     .nameCurrencyShort(
                         mob, CMLib.beanCounter().getTotalAbsoluteNativeValue(mob)));
             c++;
             break;
           }
         case 'h':
           {
             buf.append("^<Hp^>" + mob.curState().getHitPoints() + "^</Hp^>");
             c++;
             break;
           }
         case 'H':
           {
             buf.append("^<MaxHp^>" + mob.maxState().getHitPoints() + "^</MaxHp^>");
             c++;
             break;
           }
         case 'I':
           {
             if ((CMLib.flags().isCloaked(mob))
                 && (((mob.envStats().disposition() & EnvStats.IS_NOT_SEEN) != 0)))
               buf.append("Wizinvisible");
             else if (CMLib.flags().isCloaked(mob)) buf.append("Cloaked");
             else if (!CMLib.flags().isSeen(mob)) buf.append("Undetectable");
             else if (CMLib.flags().isInvisible(mob) && CMLib.flags().isHidden(mob))
               buf.append("Hidden/Invisible");
             else if (CMLib.flags().isInvisible(mob)) buf.append("Invisible");
             else if (CMLib.flags().isHidden(mob)) buf.append("Hidden");
             c++;
             break;
           }
         case 'K':
         case 'k':
           {
             MOB tank = mob;
             if ((tank.getVictim() != null)
                 && (tank.getVictim().getVictim() != null)
                 && (tank.getVictim().getVictim() != mob)) tank = tank.getVictim().getVictim();
             if (((c + 1) < prompt.length()) && (tank != null))
               switch (prompt.charAt(c + 1)) {
                 case 'h':
                   {
                     buf.append(tank.curState().getHitPoints());
                     c++;
                     break;
                   }
                 case 'H':
                   {
                     buf.append(tank.maxState().getHitPoints());
                     c++;
                     break;
                   }
                 case 'm':
                   {
                     buf.append(tank.curState().getMana());
                     c++;
                     break;
                   }
                 case 'M':
                   {
                     buf.append(tank.maxState().getMana());
                     c++;
                     break;
                   }
                 case 'v':
                   {
                     buf.append(tank.curState().getMovement());
                     c++;
                     break;
                   }
                 case 'V':
                   {
                     buf.append(tank.maxState().getMovement());
                     c++;
                     break;
                   }
                 case 'e':
                   {
                     buf.append(tank.displayName(mob));
                     c++;
                     break;
                   }
                 case 'E':
                   {
                     if ((mob.isInCombat()) && (CMLib.flags().canBeSeenBy(tank, mob)))
                       buf.append(tank.healthText(mob) + "\n\r");
                     c++;
                     break;
                   }
               }
             c++;
             break;
           }
         case 'm':
           {
             buf.append("^<Mana^>" + mob.curState().getMana() + "^</Mana^>");
             c++;
             break;
           }
         case 'M':
           {
             buf.append("^<MaxMana^>" + mob.maxState().getMana() + "^</MaxMana^>");
             c++;
             break;
           }
         case 'r':
           {
             if (mob.location() != null) buf.append(mob.location().displayText());
             c++;
             break;
           }
         case 'R':
           {
             if ((mob.location() != null) && CMSecurity.isAllowed(mob, mob.location(), "SYSMSGS"))
               buf.append(mob.location().roomID());
             c++;
             break;
           }
         case 'v':
           {
             buf.append("^<Move^>" + mob.curState().getMovement() + "^</Move^>");
             c++;
             break;
           }
         case 'V':
           {
             buf.append("^<MaxMove^>" + mob.maxState().getMovement() + "^</MaxMove^>");
             c++;
             break;
           }
         case 'w':
           {
             buf.append(mob.envStats().weight());
             c++;
             break;
           }
         case 'W':
           {
             buf.append(mob.maxCarry());
             c++;
             break;
           }
         case 'x':
           {
             buf.append(mob.getExperience());
             c++;
             break;
           }
         case 'X':
           {
             if (mob.getExpNeededLevel() == Integer.MAX_VALUE) buf.append("N/A");
             else buf.append(mob.getExpNeededLevel());
             c++;
             break;
           }
         case 'z':
           {
             if (mob.location() != null) buf.append(mob.location().getArea().name());
             c++;
             break;
           }
         case 't':
           {
             if (mob.location() != null)
               buf.append(
                   CMStrings.capitalizeAndLower(
                       TimeClock.TOD_DESC[mob.location().getArea().getTimeObj().getTODCode()]
                           .toLowerCase()));
             c++;
             break;
           }
         case 'T':
           {
             if (mob.location() != null)
               buf.append(mob.location().getArea().getTimeObj().getTimeOfDay());
             c++;
             break;
           }
         case '@':
           {
             if (mob.location() != null)
               buf.append(
                   mob.location().getArea().getClimateObj().weatherDescription(mob.location()));
             c++;
             break;
           }
         default:
           {
             buf.append("%" + prompt.charAt(c));
             c++;
             break;
           }
       }
     } else buf.append(prompt.charAt(c++));
   return buf.toString();
 }
Пример #21
0
  @Override
  public boolean tick(Tickable ticking, int tickID) {
    if (!super.tick(ticking, tickID)) return false;

    if (tickID != Tickable.TICKID_MOB) return true;

    if (affected == null) return false;
    if (--fallTickDown > 0) return true;
    fallTickDown = 1;

    int direction = Directions.DOWN;
    String addStr = L("down");
    if (reversed()) {
      direction = Directions.UP;
      addStr = L("upwards");
    }
    if (affected instanceof MOB) {
      final MOB mob = (MOB) affected;
      if (mob == null) return false;
      if (mob.location() == null) return false;

      if (CMLib.flags().isInFlight(mob)) {
        damageToTake = 0;
        unInvoke();
        return false;
      } else if (!canFallFrom(mob.location(), direction)) return stopFalling(mob);
      else {
        if (mob.phyStats().weight() < 1) {
          mob.tell(L("\n\r\n\rYou are floating gently @x1.\n\r\n\r", addStr));
        } else {
          mob.tell(L("\n\r\n\rYOU ARE FALLING @x1!!\n\r\n\r", addStr.toUpperCase()));
          int damage =
              CMLib.dice()
                  .roll(
                      1,
                      (int)
                          Math.round(
                              CMath.mul(
                                  CMath.mul(mob.maxState().getHitPoints(), 0.1),
                                  CMath.div(mob.baseWeight(), 150.0))),
                      0);
          if (damage > (mob.maxState().getHitPoints() / 3))
            damage = (mob.maxState().getHitPoints() / 3);
          damageToTake = reversed() ? damage : (damageToTake + damage);
        }
        temporarilyDisable = true;
        CMLib.tracking().walk(mob, direction, false, false);
        temporarilyDisable = false;
        if (!canFallFrom(mob.location(), direction)) return stopFalling(mob);
        return true;
      }
    } else if (affected instanceof Item) {
      final Item item = (Item) affected;
      if ((room == null) && (item.owner() != null) && (item.owner() instanceof Room))
        room = (Room) item.owner();

      if ((room == null)
          || ((room != null) && (!room.isContent(item)))
          || (!CMLib.flags().isGettable(item))
          || (item.container() != null)
          || (CMLib.flags().isInFlight(item.ultimateContainer(null)))
          || (room.getRoomInDir(direction) == null)) {
        unInvoke();
        return false;
      }
      if (room.numItems() > 100) {
        fallTickDown = CMLib.dice().roll(1, room.numItems() / 50, 0);
        if ((--fallTickDown) > 0) return true;
      }
      final Room nextRoom = room.getRoomInDir(direction);
      if (canFallFrom(room, direction)) {
        room.show(invoker, null, item, CMMsg.MSG_OK_ACTION, L("<O-NAME> falls @x1.", addStr));
        nextRoom.moveItemTo(item, ItemPossessor.Expire.Player_Drop);
        room = nextRoom;
        nextRoom.show(
            invoker,
            null,
            item,
            CMMsg.MSG_OK_ACTION,
            L("<O-NAME> falls in from @x1.", (reversed() ? "below" : "above")));
        return true;
      }
      if (reversed()) return true;
      unInvoke();
      return false;
    }

    return false;
  }