示例#1
0
 public boolean okMessage(final Environmental myHost, final CMMsg msg) {
   if (!super.okMessage(myHost, msg)) return false;
   if (msg.amITarget(this)) {
     MOB mob = msg.source();
     switch (msg.targetMinor()) {
       case CMMsg.TYP_DRINK:
         if ((mob.isMine(this))
             || (phyStats().weight() > 1000)
             || (!CMLib.flags().isGettable(this))) {
           if (!containsDrink()) {
             mob.tell(name() + " is empty.");
             return false;
           }
           if ((liquidType() == RawMaterial.RESOURCE_SALTWATER)
               || (liquidType() == RawMaterial.RESOURCE_LAMPOIL)) {
             mob.tell(
                 "You don't want to be drinking "
                     + RawMaterial.CODES.NAME(liquidType()).toLowerCase()
                     + ".");
             return false;
           }
           return true;
         }
         mob.tell("You don't have that.");
         return false;
       case CMMsg.TYP_FILL:
         if ((liquidRemaining() >= amountOfLiquidHeld) && (liquidHeld() < 500000)) {
           mob.tell(name() + " is full.");
           return false;
         }
         if ((msg.tool() != null)
             && (msg.tool() != msg.target())
             && (msg.tool() instanceof Drink)) {
           Drink thePuddle = (Drink) msg.tool();
           if (!thePuddle.containsDrink()) {
             mob.tell(thePuddle.name() + " is empty.");
             return false;
           }
           if ((liquidRemaining() > 0) && (liquidType() != thePuddle.liquidType())) {
             mob.tell(
                 "There is still some "
                     + RawMaterial.CODES.NAME(liquidType()).toLowerCase()
                     + " left in "
                     + name()
                     + ".  You must empty it before you can fill it with "
                     + RawMaterial.CODES.NAME(thePuddle.liquidType()).toLowerCase()
                     + ".");
             return false;
           }
           return true;
         }
         mob.tell("You can't fill " + name() + " from that.");
         return false;
       default:
         break;
     }
   }
   return true;
 }
示例#2
0
  public void executeMsg(final Environmental myHost, final CMMsg msg) {
    super.executeMsg(myHost, msg);
    if ((affected != null)
        && (affected instanceof Room)
        && (invoker() != null)
        && (invoker().location() != null)
        && (sourceRoom != null)
        && (!invoker().isInCombat())
        && (invoker().location() == sourceRoom)) {
      if (invoker().location() == room) {
        if ((msg.sourceMinor() == CMMsg.TYP_SPEAK)
            && (msg.othersCode() == CMMsg.NO_EFFECT)
            && (msg.othersMessage() == null)
            && (msg.sourceMessage() != null)
            && (!msg.amISource(invoker()))
            && (!msg.amITarget(invoker()))
            && (!lastSaid.equals(msg.sourceMessage()))) {
          lastSaid = msg.sourceMessage();
          if ((invoker().phyStats().level() + (getXLEVELLevel(invoker()) * 10))
              > msg.source().phyStats().level())
            invoker().tell(msg.source(), msg.target(), msg.tool(), msg.sourceMessage());
          else
            invoker()
                .tell(
                    msg.source(),
                    null,
                    null,
                    "<S-NAME> said something, but you couldn't quite make it out.");
        }
      } else if ((msg.sourceMinor() == CMMsg.TYP_SPEAK)
          && (msg.othersMinor() == CMMsg.TYP_SPEAK)
          && (msg.othersMessage() != null)
          && (msg.sourceMessage() != null)
          && (!lastSaid.equals(msg.sourceMessage()))) {
        lastSaid = msg.sourceMessage();
        if ((invoker().phyStats().level() + (getXLEVELLevel(invoker()) * 10))
            > msg.source().phyStats().level())
          invoker().tell(msg.source(), msg.target(), msg.tool(), msg.sourceMessage());
        else
          invoker()
              .tell(
                  msg.source(),
                  null,
                  null,
                  "<S-NAME> said something, but you couldn't quite make it out.");
      }

    } else unInvoke();
  }
示例#3
0
  public void executeMsg(final Environmental myHost, final CMMsg msg) {
    if (msg.source().riding() == this) {
      CMLib.commands().handleHygenicMessage(msg, 0, PlayerStats.HYGIENE_WATERCLEAN);
    }

    if (msg.amITarget(this)) {
      MOB mob = msg.source();
      switch (msg.targetMinor()) {
        case CMMsg.TYP_DRINK:
          amountOfLiquidRemaining -= amountOfThirstQuenched;
          boolean thirsty = mob.curState().getThirst() <= 0;
          boolean full =
              !mob.curState()
                  .adjThirst(amountOfThirstQuenched, mob.maxState().maxThirst(mob.baseWeight()));
          if (thirsty) mob.tell("You are no longer thirsty.");
          else if (full) mob.tell("You have drunk all you can.");
          if (disappearsAfterDrinking) {
            destroy();
            return;
          }
          break;
        case CMMsg.TYP_FILL:
          if ((msg.tool() != null) && (msg.tool() instanceof Drink)) {
            Drink thePuddle = (Drink) msg.tool();
            int amountToTake = amountTakenToFillMe(thePuddle);
            thePuddle.setLiquidRemaining(thePuddle.liquidRemaining() - amountToTake);
            if (amountOfLiquidRemaining <= 0) setLiquidType(thePuddle.liquidType());
            if (((long) amountOfLiquidRemaining + (long) amountToTake) <= (long) Integer.MAX_VALUE)
              amountOfLiquidRemaining += amountToTake;
            if (amountOfLiquidRemaining > amountOfLiquidHeld)
              amountOfLiquidRemaining = amountOfLiquidHeld;
            if ((amountOfLiquidRemaining <= 0) && (disappearsAfterDrinking)) {
              destroy();
              return;
            }
          }
          break;
        default:
          break;
      }
    }
    super.executeMsg(myHost, msg);
  }
示例#4
0
  public boolean okMessage(final Environmental myHost, final CMMsg msg) {
    if (!super.okMessage(myHost, msg)) return false;

    if ((affected == null) || (!(affected instanceof MOB))) return true;

    MOB mob = (MOB) affected;
    if (msg.amISource(mob)
        && (msg.targetMinor() == CMMsg.TYP_DAMAGE)
        && (msg.tool() instanceof Weapon)
        && (msg.tool() == naturalWeapon))
      msg.setValue(msg.value() + naturalWeapon.basePhyStats().damage() + super.getXLEVELLevel(mob));
    return true;
  }
示例#5
0
  public boolean okMessage(final Environmental myHost, final CMMsg msg) {
    if (affected == null) return super.okMessage(myHost, msg);

    if (affected instanceof MOB) {
      MOB mob = (MOB) affected;
      if ((msg.amITarget(mob))
          && (!msg.amISource(mob))
          && (mob.location() != msg.source().location())
          && (msg.tool() != null)
          && (msg.tool() instanceof Ability)
          && (CMath.bset(((Ability) msg.tool()).flags(), Ability.FLAG_SUMMONING))
          && (!mob.amDead())) {
        msg.source()
            .location()
            .showHappens(
                CMMsg.MSG_OK_VISUAL, "Magical energy fizzles and is absorbed into the air!");
        return false;
      }
    } else if (affected instanceof Room) {
      Room R = (Room) affected;
      if ((msg.tool() != null)
          && (msg.tool() instanceof Ability)
          && (CMath.bset(((Ability) msg.tool()).flags(), Ability.FLAG_SUMMONING))) {
        Ability A = (Ability) msg.tool();
        if (((A.classificationCode() & Ability.ALL_ACODES) == Ability.ACODE_CHANT)
            || ((A.classificationCode() & Ability.ALL_ACODES) == Ability.ACODE_SPELL)
            || ((A.classificationCode() & Ability.ALL_ACODES) == Ability.ACODE_PRAYER)
            || ((A.classificationCode() & Ability.ALL_ACODES) == Ability.ACODE_SONG)) {
          if ((msg.source().location() != null) && (msg.source().location() != R))
            msg.source()
                .location()
                .showHappens(
                    CMMsg.MSG_OK_VISUAL, "Magical energy fizzles and is absorbed into the air!");
          R.showHappens(
              CMMsg.MSG_OK_VISUAL, "Magical energy fizzles and is absorbed into the air!");
        }
        return false;
      }
    }
    return super.okMessage(myHost, msg);
  }
示例#6
0
  public boolean okMessage(Environmental host, CMMsg msg) {
    if (!super.okMessage(host, msg)) return false;

    Room R = msg.source().location();
    if ((host instanceof Area) && (R != null) && (R.getArea() != host)) return true;
    int weather = weather(host, R);
    // first handle the effect of storms on ranged
    // weapons

    if ((msg.targetMinor() == CMMsg.TYP_WEAPONATTACK)
        && (msg.source().rangeToTarget() != 0)
        && (msg.tool() instanceof Item)
        && (!(msg.tool() instanceof Electronics))
        && ((msg.sourceMinor() == CMMsg.TYP_THROW)
            || ((msg.tool() instanceof Weapon)
                && ((((Weapon) msg.tool()).weaponClassification() == Weapon.CLASS_RANGED)
                    || (((Weapon) msg.tool()).weaponClassification() == Weapon.CLASS_THROWN))))) {
      switch (weather) {
        case Climate.WEATHER_WINDY:
        case Climate.WEATHER_THUNDERSTORM:
        case Climate.WEATHER_BLIZZARD:
        case Climate.WEATHER_DUSTSTORM:
          {
            if ((CMLib.dice().rollPercentage() < windsheer) && (R != null)) {
              R.show(
                  msg.source(),
                  msg.target(),
                  msg.tool(),
                  CMMsg.MSG_OK_ACTION,
                  "^WThe strong wind blows <S-YOUPOSS> attack against <T-NAMESELF> with <O-NAME> off target.^?");
              return false;
            }
            break;
          }
      }
    }
    // then try to handle slippage in wet weather
    if (((msg.sourceMajor(CMMsg.MASK_MOVE))) && (R != null)) {
      String what = null;
      switch (weather) {
        case Climate.WEATHER_BLIZZARD:
        case Climate.WEATHER_SNOW:
          if (CMLib.dice().rollPercentage() < snowSlipChance) what = "cold wet";
          break;
        case Climate.WEATHER_RAIN:
        case Climate.WEATHER_THUNDERSTORM:
          if (CMLib.dice().rollPercentage() < rainSlipChance) what = "slippery wet";
          break;
        case Climate.WEATHER_SLEET:
          if (CMLib.dice().rollPercentage() < sleetSlipChance) what = "icy";
          break;
      }
      if ((what != null)
          && (!CMLib.flags().isInFlight(msg.source()))
          && (R.domainType() != Room.DOMAIN_OUTDOORS_AIR)
          && (R.domainType() != Room.DOMAIN_OUTDOORS_WATERSURFACE)
          && (R.domainType() != Room.DOMAIN_OUTDOORS_UNDERWATER)
          && (CMLib.dice().rollPercentage()
              > ((msg.source().charStats().getStat(CharStats.STAT_DEXTERITY) * 3) + 25))) {
        int oldDisposition = msg.source().basePhyStats().disposition();
        oldDisposition =
            oldDisposition & (~(PhyStats.IS_SLEEPING | PhyStats.IS_SNEAKING | PhyStats.IS_SITTING));
        msg.source().basePhyStats().setDisposition(oldDisposition | PhyStats.IS_SITTING);
        msg.source().recoverPhyStats();
        R.show(
            msg.source(),
            null,
            CMMsg.MSG_OK_ACTION,
            "^W<S-NAME> slip(s) on the " + what + " ground.^?");
        return false;
      }
    }
    if ((R != null) && (weather == Climate.WEATHER_BLIZZARD)) {
      Ability A = CMClass.getAbility("Spell_ObscureSelf");
      if (A != null) {
        A.setAffectedOne(msg.source());
        if (!A.okMessage(msg.source(), msg)) return false;
      }
    }
    return true;
  }