Esempio n. 1
0
  public void executeMsg(final Environmental myHost, final CMMsg msg) {
    try {
      super.executeMsg(myHost, msg);
      if (spy == null) return;
      if (invoker == null) return;

      if ((msg.amISource(spy))
          && ((msg.sourceMinor() == CMMsg.TYP_LOOK) || (msg.sourceMinor() == CMMsg.TYP_EXAMINE))
          && (msg.target() != null)
          && ((invoker.location() != spy.location()) || (!(msg.target() instanceof Room)))) {
        disable = true;
        CMMsg newAffect = CMClass.getMsg(invoker, msg.target(), msg.sourceMinor(), null);
        msg.target().executeMsg(invoker, newAffect);
      } else if ((!msg.amISource(invoker))
          && (invoker.location() != spy.location())
          && (msg.source().location() == spy.location())
          && (msg.othersCode() != CMMsg.NO_EFFECT)
          && (msg.othersMessage() != null)
          && (!disable)) {
        disable = true;
        invoker.executeMsg(invoker, msg);
      } else if (msg.amISource(invoker)
          && (!disable)
          && (msg.sourceMinor() == CMMsg.TYP_SPEAK)
          && (msg.sourceMessage() != null)
          && ((msg.sourceMajor() & CMMsg.MASK_MAGIC) == 0)) {
        int start = msg.sourceMessage().indexOf("\'");
        int end = msg.sourceMessage().lastIndexOf("\'");
        if ((start > 0) && (end > start)) {
          String msg2 = msg.sourceMessage().substring(start + 1, end).trim();
          if (msg2.length() > 0)
            spy.enqueCommand(CMParms.parse(msg2.trim()), Command.METAFLAG_FORCED, 0);
        }
      }
    } finally {
      disable = false;
      if ((spy != null)
          && ((spy.amFollowing() != invoker)
              || (spy.amDead())
              || (!CMLib.flags().isInTheGame(spy, false))
              || (!CMLib.flags().isInTheGame(invoker, true)))) unInvoke();
    }
  }
Esempio n. 2
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;
  }