コード例 #1
0
ファイル: Spell_Friends.java プロジェクト: Cocanuta/Marble
  public boolean invoke(MOB mob, Vector commands, Physical givenTarget, boolean auto, int asLevel) {
    MOB target = this.getTarget(mob, commands, givenTarget);
    if (target == null) return false;
    Room R = CMLib.map().roomLocation(target);
    if (R == null) R = mob.location();

    // the invoke method for spells receives as
    // parameters the invoker, and the REMAINING
    // command line parameters, divided into words,
    // and added as String objects to a vector.
    if (!super.invoke(mob, commands, givenTarget, auto, asLevel)) return false;

    if ((auto) && (givenTarget != null) && (givenTarget instanceof MOB)) target = (MOB) givenTarget;
    // now see if it worked
    boolean success = proficiencyCheck(mob, 0, auto);

    if (success) {
      // it worked, so build a copy of this ability,
      // and add it to the affects list of the
      // affected MOB.  Then tell everyone else
      // what happened.
      CMMsg msg =
          CMClass.getMsg(
              mob,
              target,
              this,
              verbalCastCode(mob, target, auto),
              auto ? "" : "^S<S-NAME> speak(s) and gesture(s) to <T-NAMESELF>.^?");
      if (R.okMessage(mob, msg)) {
        R.send(mob, msg);
        R.show(target, null, CMMsg.MSG_OK_VISUAL, "<S-NAME> seem(s) much more likeable!");
        beneficialAffect(mob, target, asLevel, 0);
      }
    } else
      return beneficialWordsFizzle(
          mob, target, "<S-NAME> incant(s) gracefully to <T-NAMESELF>, but nothing more happens.");

    // return whether it worked
    return success;
  }
コード例 #2
0
ファイル: WeatherAffects.java プロジェクト: Cocanuta/Marble
  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;
  }