Exemplo n.º 1
0
  public boolean invoke(MOB mob, Vector commands, Physical givenTarget, boolean auto, int asLevel) {
    String dir = CMParms.combine(commands, 0);
    if (commands.size() > 0) dir = (String) commands.lastElement();
    int dirCode = Directions.getGoodDirectionCode(dir);
    if (!preInvoke(mob, commands, givenTarget, auto, asLevel, 0, 0.0)) return false;

    MOB highestMOB = getHighestLevelMOB(mob, null);
    int levelDiff =
        mob.phyStats().level() + (2 * super.getXLEVELLevel(mob)) - getMOBLevel(highestMOB);

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

    boolean success = false;
    CMMsg msg =
        CMClass.getMsg(
            mob,
            null,
            this,
            auto ? CMMsg.MSG_OK_VISUAL : CMMsg.MSG_DELICATE_HANDS_ACT,
            "<S-NAME> walk(s) carefully " + Directions.getDirectionName(dirCode) + ".");
    if (mob.location().okMessage(mob, msg)) {
      mob.location().send(mob, msg);
      if (levelDiff < 0) levelDiff = levelDiff * 8;
      else levelDiff = levelDiff * 10;
      success = proficiencyCheck(mob, levelDiff, auto);
      int oldDex = mob.baseCharStats().getStat(CharStats.STAT_DEXTERITY);
      if (success) mob.baseCharStats().setStat(CharStats.STAT_DEXTERITY, oldDex + 100);
      mob.recoverCharStats();
      CMLib.tracking().walk(mob, dirCode, false, false);
      if (oldDex != mob.baseCharStats().getStat(CharStats.STAT_DEXTERITY))
        mob.baseCharStats().setStat(CharStats.STAT_DEXTERITY, oldDex);
      mob.recoverCharStats();
    }
    return success;
  }
Exemplo n.º 2
0
 public boolean supportsMending(Physical item) {
   if (!(item instanceof MOB)) return false;
   MOB caster = CMClass.getFactoryMOB();
   caster.basePhyStats().setLevel(CMProps.getIntVar(CMProps.SYSTEMI_LASTPLAYERLEVEL));
   caster.phyStats().setLevel(CMProps.getIntVar(CMProps.SYSTEMI_LASTPLAYERLEVEL));
   boolean canMend = returnOffensiveAffects(caster, item).size() > 0;
   caster.destroy();
   return canMend;
 }
Exemplo n.º 3
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;
  }
Exemplo n.º 4
0
  public boolean invoke(MOB mob, Vector commands, Physical givenTarget, boolean auto, int asLevel) {
    if (!super.invoke(mob, commands, givenTarget, auto, asLevel)) return false;

    int size = mob.location().getArea().numberOfProperIDedRooms();
    size = size - ((mob.phyStats().level() + (2 * super.getXLEVELLevel(mob))) * 20);
    if (size < 0) size = 0;
    boolean success = proficiencyCheck(mob, -size, auto);
    if (success) {
      CMMsg msg =
          CMClass.getMsg(
              mob,
              null,
              this,
              verbalCastCode(mob, null, auto),
              auto
                  ? "The sky changes color!"
                  : "^S<S-NAME> " + prayWord(mob) + " for a change in weather!^?");
      if (mob.location().okMessage(mob, msg)) {
        int switcher = CMLib.dice().roll(1, 3, 0);
        mob.location().send(mob, msg);
        switch (mob.location().getArea().getClimateObj().weatherType(mob.location())) {
          case Climate.WEATHER_BLIZZARD:
            if (switcher == 1)
              mob.location().getArea().getClimateObj().setNextWeatherType(Climate.WEATHER_BLIZZARD);
            else if (switcher == 2)
              mob.location().getArea().getClimateObj().setNextWeatherType(Climate.WEATHER_BLIZZARD);
            else mob.location().getArea().getClimateObj().setNextWeatherType(Climate.WEATHER_SNOW);
            break;
          case Climate.WEATHER_CLEAR:
            if (switcher == 1)
              mob.location().getArea().getClimateObj().setNextWeatherType(Climate.WEATHER_WINDY);
            else if (switcher == 2)
              mob.location().getArea().getClimateObj().setNextWeatherType(Climate.WEATHER_RAIN);
            else
              mob.location().getArea().getClimateObj().setNextWeatherType(Climate.WEATHER_CLOUDY);
            break;
          case Climate.WEATHER_CLOUDY:
            if (switcher == 1)
              mob.location().getArea().getClimateObj().setNextWeatherType(Climate.WEATHER_WINDY);
            else if (switcher == 2)
              mob.location().getArea().getClimateObj().setNextWeatherType(Climate.WEATHER_RAIN);
            else mob.location().getArea().getClimateObj().setNextWeatherType(Climate.WEATHER_CLEAR);
            break;
          case Climate.WEATHER_DROUGHT:
            if (switcher == 1)
              mob.location()
                  .getArea()
                  .getClimateObj()
                  .setNextWeatherType(Climate.WEATHER_DUSTSTORM);
            else if (switcher == 2)
              mob.location()
                  .getArea()
                  .getClimateObj()
                  .setNextWeatherType(Climate.WEATHER_HEAT_WAVE);
            else mob.location().getArea().getClimateObj().setNextWeatherType(Climate.WEATHER_CLEAR);
            break;
          case Climate.WEATHER_DUSTSTORM:
            if (switcher == 1)
              mob.location()
                  .getArea()
                  .getClimateObj()
                  .setNextWeatherType(Climate.WEATHER_DUSTSTORM);
            else if (switcher == 2)
              mob.location().getArea().getClimateObj().setNextWeatherType(Climate.WEATHER_CLOUDY);
            else mob.location().getArea().getClimateObj().setNextWeatherType(Climate.WEATHER_CLEAR);
            break;
          case Climate.WEATHER_HAIL:
            if (switcher == 1)
              mob.location().getArea().getClimateObj().setNextWeatherType(Climate.WEATHER_HAIL);
            else if (switcher == 2)
              mob.location().getArea().getClimateObj().setNextWeatherType(Climate.WEATHER_SLEET);
            else
              mob.location().getArea().getClimateObj().setNextWeatherType(Climate.WEATHER_CLOUDY);
            break;
          case Climate.WEATHER_HEAT_WAVE:
            if (switcher == 1)
              mob.location()
                  .getArea()
                  .getClimateObj()
                  .setNextWeatherType(Climate.WEATHER_DUSTSTORM);
            else if (switcher == 2)
              mob.location().getArea().getClimateObj().setNextWeatherType(Climate.WEATHER_RAIN);
            else mob.location().getArea().getClimateObj().setNextWeatherType(Climate.WEATHER_CLEAR);
            break;
          case Climate.WEATHER_RAIN:
            if (switcher == 1)
              mob.location()
                  .getArea()
                  .getClimateObj()
                  .setNextWeatherType(Climate.WEATHER_THUNDERSTORM);
            else if (switcher == 2)
              mob.location()
                  .getArea()
                  .getClimateObj()
                  .setNextWeatherType(Climate.WEATHER_THUNDERSTORM);
            else
              mob.location().getArea().getClimateObj().setNextWeatherType(Climate.WEATHER_CLOUDY);
            break;
          case Climate.WEATHER_SLEET:
            if (switcher == 1)
              mob.location().getArea().getClimateObj().setNextWeatherType(Climate.WEATHER_SLEET);
            else if (switcher == 2)
              mob.location().getArea().getClimateObj().setNextWeatherType(Climate.WEATHER_SLEET);
            else
              mob.location().getArea().getClimateObj().setNextWeatherType(Climate.WEATHER_CLOUDY);
            break;
          case Climate.WEATHER_SNOW:
            if (switcher == 1)
              mob.location().getArea().getClimateObj().setNextWeatherType(Climate.WEATHER_BLIZZARD);
            else if (switcher == 2)
              mob.location().getArea().getClimateObj().setNextWeatherType(Climate.WEATHER_SLEET);
            else
              mob.location().getArea().getClimateObj().setNextWeatherType(Climate.WEATHER_CLOUDY);
            break;
          case Climate.WEATHER_THUNDERSTORM:
            if (switcher == 1)
              mob.location()
                  .getArea()
                  .getClimateObj()
                  .setNextWeatherType(Climate.WEATHER_THUNDERSTORM);
            else if (switcher == 2)
              mob.location()
                  .getArea()
                  .getClimateObj()
                  .setNextWeatherType(Climate.WEATHER_THUNDERSTORM);
            else mob.location().getArea().getClimateObj().setNextWeatherType(Climate.WEATHER_RAIN);
            break;
          case Climate.WEATHER_WINDY:
            if (switcher == 1)
              mob.location().getArea().getClimateObj().setNextWeatherType(Climate.WEATHER_WINDY);
            else if (switcher == 2)
              mob.location()
                  .getArea()
                  .getClimateObj()
                  .setNextWeatherType(Climate.WEATHER_THUNDERSTORM);
            else mob.location().getArea().getClimateObj().setNextWeatherType(Climate.WEATHER_CLEAR);
            break;
          case Climate.WEATHER_WINTER_COLD:
            if (switcher == 1)
              mob.location().getArea().getClimateObj().setNextWeatherType(Climate.WEATHER_WINDY);
            else if (switcher == 2)
              mob.location().getArea().getClimateObj().setNextWeatherType(Climate.WEATHER_SNOW);
            else mob.location().getArea().getClimateObj().setNextWeatherType(Climate.WEATHER_CLEAR);
            break;
          default:
            break;
        }
        mob.location().getArea().getClimateObj().forceWeatherTick(mob.location().getArea());
      }
    } else
      beneficialVisualFizzle(mob, null, "<S-NAME> " + prayWord(mob) + ", but nothing happens.");

    return success;
  }
Exemplo n.º 5
0
  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;

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

    int levelDiff =
        target.phyStats().level() - (mob.phyStats().level() + (2 * getXLEVELLevel(mob)));
    if (levelDiff < 0) levelDiff = 0;
    boolean success = proficiencyCheck(mob, -(levelDiff * 25), auto);
    Item Bread = null;
    Item BreadContainer = null;
    for (int i = 0; i < target.numItems(); i++) {
      Item I = target.getItem(i);
      if ((I != null) && (I instanceof Food)) {
        if (I.container() != null) {
          Bread = I;
          BreadContainer = I.container();
        } else {
          Bread = I;
          BreadContainer = null;
          break;
        }
      }
    }
    if ((Bread != null) && (BreadContainer != null))
      CMLib.commands().postGet(target, BreadContainer, Bread, false);
    if (Bread == null) {
      ShopKeeper SK = CMLib.coffeeShops().getShopKeeper(target);
      if (SK != null) {
        for (Iterator<Environmental> i = SK.getShop().getStoreInventory(); i.hasNext(); ) {
          Environmental E2 = (Environmental) i.next();
          if ((E2 != null) && (E2 instanceof Food)) {
            Bread = (Item) E2.copyOf();
            target.addItem(Bread);
            break;
          }
        }
      }
    }
    if ((success) && (Bread != null)) {
      // 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),
              "^S<S-NAME> "
                  + prayWord(mob)
                  + " for <T-NAMESELF> to provide <S-HIS-HER> daily bread!^?");
      CMMsg msg2 =
          CMClass.getMsg(
              mob,
              target,
              this,
              CMMsg.MSK_CAST_MALICIOUS_VERBAL | CMMsg.TYP_MIND | (auto ? CMMsg.MASK_ALWAYS : 0),
              null);
      if ((mob.location().okMessage(mob, msg)) && (mob.location().okMessage(mob, msg2))) {
        mob.location().send(mob, msg);
        mob.location().send(mob, msg2);
        if ((msg.value() <= 0) && (msg2.value() <= 0)) {
          msg =
              CMClass.getMsg(
                  target,
                  mob,
                  Bread,
                  CMMsg.MSG_GIVE,
                  "<S-NAME> gladly donate(s) <O-NAME> to <T-NAMESELF>.");
          if (mob.location().okMessage(mob, msg)) mob.location().send(mob, msg);
        }
      }
    } else
      maliciousFizzle(
          mob,
          target,
          auto
              ? ""
              : "<S-NAME> "
                  + prayWord(mob)
                  + " for <T-NAMESELF> to provide <S-HIS-HER> daily bread, but nothing happens.");

    // return whether it worked
    return success;
  }
Exemplo n.º 6
0
  public boolean invoke(MOB mob, Vector commands, Physical givenTarget, boolean auto, int asLevel) {
    if (((mob.location().domainType() & Room.INDOORS) > 0) && (!auto)) {
      mob.tell("You must be outdoors for this chant to work.");
      return false;
    }
    if (!super.invoke(mob, commands, givenTarget, auto, asLevel)) return false;

    int size = mob.location().getArea().numberOfProperIDedRooms();
    size = size / (mob.phyStats().level() + (2 * super.getXLEVELLevel(mob)));
    if (size < 0) size = 0;
    boolean success = proficiencyCheck(mob, -size, auto);
    if (success) {
      Climate C = mob.location().getArea().getClimateObj();
      Climate oldC = (Climate) C.copyOf();
      CMMsg msg =
          CMClass.getMsg(
              mob,
              null,
              this,
              verbalCastCode(mob, null, auto),
              auto
                  ? "^JThe sky changes color!^?"
                  : "^S<S-NAME> chant(s) into the sky for water!^?");
      if (mob.location().okMessage(mob, msg)) {
        mob.location().send(mob, msg);
        switch (C.weatherType(mob.location())) {
          case Climate.WEATHER_BLIZZARD:
            C.setNextWeatherType(Climate.WEATHER_BLIZZARD);
            break;
          case Climate.WEATHER_CLEAR:
            C.setNextWeatherType(Climate.WEATHER_RAIN);
            break;
          case Climate.WEATHER_CLOUDY:
            C.setNextWeatherType(Climate.WEATHER_RAIN);
            break;
          case Climate.WEATHER_DROUGHT:
            C.setNextWeatherType(Climate.WEATHER_CLEAR);
            break;
          case Climate.WEATHER_DUSTSTORM:
            C.setNextWeatherType(Climate.WEATHER_CLOUDY);
            break;
          case Climate.WEATHER_HAIL:
            C.setNextWeatherType(Climate.WEATHER_SLEET);
            break;
          case Climate.WEATHER_HEAT_WAVE:
            C.setNextWeatherType(Climate.WEATHER_RAIN);
            break;
          case Climate.WEATHER_RAIN:
            C.setNextWeatherType(Climate.WEATHER_THUNDERSTORM);
            break;
          case Climate.WEATHER_SLEET:
            C.setNextWeatherType(Climate.WEATHER_SLEET);
            break;
          case Climate.WEATHER_SNOW:
            C.setNextWeatherType(Climate.WEATHER_SLEET);
            break;
          case Climate.WEATHER_THUNDERSTORM:
            C.setNextWeatherType(Climate.WEATHER_THUNDERSTORM);
            break;
          case Climate.WEATHER_WINDY:
            C.setNextWeatherType(Climate.WEATHER_THUNDERSTORM);
            break;
          case Climate.WEATHER_WINTER_COLD:
            C.setNextWeatherType(Climate.WEATHER_SNOW);
            break;
          default:
            break;
        }
        C.forceWeatherTick(mob.location().getArea());
        Chant_CalmWeather.xpWorthyChange(mob, mob.location().getArea(), oldC, C);
      }
    } else
      beneficialVisualFizzle(
          mob, null, "<S-NAME> chant(s) into the sky for water, but the magic fizzles.");

    return success;
  }
Exemplo n.º 7
0
  public boolean tick(Tickable ticking, int tickID) {
    int realLastWeather = super.lastWeather;
    if (!super.tick(ticking, tickID)) return false;
    Area A = CMLib.map().areaLocation(ticking);
    if (A == null) return false;
    Climate C = A.getClimateObj();
    if (C == null) return false;
    lastWeather = realLastWeather;

    // handle freeze overs
    if ((coldWeather(lastWeather))
        && (coldWeather(C.weatherType(null)))
        && (lastWeather != C.weatherType(null))
        && (A.getTimeObj().getSeasonCode() == TimeClock.SEASON_WINTER)
        && (CMLib.dice().rollPercentage() < freezeOverChance)) {
      if (ticking instanceof Room) {
        Room R = (Room) ticking;
        if ((R.domainType() == Room.DOMAIN_OUTDOORS_WATERSURFACE)
            && (CMLib.dice().rollPercentage() < freezeOverChance)
            && (R instanceof Drink)
            && (((Drink) R).liquidType() == RawMaterial.RESOURCE_FRESHWATER)) {
          Ability A2 = CMClass.getAbility("Spell_IceSheet");
          if (A2 != null) {
            MOB mob = CMLib.map().getFactoryMOB(R);
            A2.invoke(mob, R, true, 0);
            mob.destroy();
          }
        }
      } else
        for (Enumeration<Room> e = A.getProperMap(); e.hasMoreElements(); ) {
          Room R = (Room) e.nextElement();
          if ((R.domainType() == Room.DOMAIN_OUTDOORS_WATERSURFACE)
              && (CMLib.dice().rollPercentage() < freezeOverChance)) {
            Ability A2 = CMClass.getAbility("Spell_IceSheet");
            if (A2 != null) {
              MOB mob = CMLib.map().getFactoryMOB(R);
              A2.invoke(mob, R, true, 0);
              mob.destroy();
            }
          }
        }
    }
    if ((botherDown--) == 1) {
      resetBotherTicks();
      switch (C.weatherType(null)) {
        case Climate.WEATHER_BLIZZARD:
        case Climate.WEATHER_SLEET:
        case Climate.WEATHER_SNOW:
        case Climate.WEATHER_HAIL:
        case Climate.WEATHER_THUNDERSTORM:
        case Climate.WEATHER_RAIN:
          for (Enumeration<Room> r = A.getProperMap(); r.hasMoreElements(); ) {
            Room R = (Room) r.nextElement();
            if (CMLib.map().hasASky(R))
              for (int i = 0; i < R.numInhabitants(); i++) {
                MOB mob = R.fetchInhabitant(i);
                if ((mob != null)
                    && (!mob.isMonster())
                    && (CMLib.flags().aliveAwakeMobile(mob, true))
                    && (CMath.bset(mob.getBitmap(), MOB.ATT_AUTOWEATHER)))
                  mob.tell(C.getWeatherDescription(A));
              }
          }
          break;
      }
    }
    if ((diseaseDown--) == 1) {
      resetDiseaseTicks();
      int coldChance = 0;
      int fluChance = 0;
      int frostBiteChance = 0;
      int heatExhaustionChance = 0;
      switch (C.weatherType(null)) {
        case Climate.WEATHER_BLIZZARD:
        case Climate.WEATHER_SLEET:
        case Climate.WEATHER_SNOW:
          coldChance = 99;
          fluChance = 25;
          frostBiteChance = 15;
          break;
        case Climate.WEATHER_HAIL:
          coldChance = 50;
          frostBiteChance = 10;
          break;
        case Climate.WEATHER_THUNDERSTORM:
        case Climate.WEATHER_RAIN:
          coldChance = 25;
          break;
        case Climate.WEATHER_WINTER_COLD:
          coldChance = 75;
          fluChance = 10;
          frostBiteChance = 5;
          break;
        case Climate.WEATHER_HEAT_WAVE:
          heatExhaustionChance = 15;
          break;
        case Climate.WEATHER_DROUGHT:
          heatExhaustionChance = 20;
          break;
      }

      for (Session S : CMLib.sessions().localOnlineIterable()) {
        if ((S.mob() == null)
            || (S.mob().location() == null)
            || (S.mob().location().getArea() != A)
            || (S.mob().isMonster())) continue;

        MOB M = S.mob();
        Room R = M.location();

        if ((R.domainConditions() & Room.CONDITION_COLD) > 0) {
          if (coldChance > 0) coldChance += 10;
          if (coldChance > 0) fluChance += 5; // yes, cold is related this way to flu
          if (frostBiteChance > 0)
            frostBiteChance = frostBiteChance + (int) Math.round(CMath.mul(frostBiteChance, 0.5));
        }
        if ((R.domainConditions() & Room.CONDITION_HOT) > 0) {
          if (heatExhaustionChance > 0) heatExhaustionChance += 10;
        }
        if ((R.domainConditions() & Room.CONDITION_WET) > 0) {
          if (coldChance > 0) coldChance += 5;
          if (heatExhaustionChance > 5) heatExhaustionChance -= 5;
          if (frostBiteChance > 0)
            frostBiteChance = frostBiteChance + (int) Math.round(CMath.mul(frostBiteChance, 0.25));
        }
        int save =
            (M.charStats().getSave(CharStats.STAT_SAVE_COLD)
                    + M.charStats().getSave(CharStats.STAT_SAVE_WATER))
                / 2;
        if ((CMLib.dice().rollPercentage() < (coldChance - save))
            && ((C.weatherType(M.location()) != Climate.WEATHER_CLEAR))) {
          long coveredPlaces = 0;
          for (int l = 0; l < ALL_COVERED_SPOTS.length; l++)
            if (M.getWearPositions(ALL_COVERED_SPOTS[l]) == 0)
              coveredPlaces = coveredPlaces | ALL_COVERED_SPOTS[l];
          Item I = null;
          for (int i = 0; i < M.numItems(); i++) {
            I = M.getItem(i);
            if ((I == null) || (I.amWearingAt(Wearable.IN_INVENTORY))) continue;
            if (I.amWearingAt(Wearable.WORN_ABOUT_BODY))
              coveredPlaces = coveredPlaces | Wearable.WORN_TORSO | Wearable.WORN_LEGS;
            for (int l = 0; l < ALL_COVERED_SPOTS.length; l++)
              if (I.amWearingAt(ALL_COVERED_SPOTS[l]))
                coveredPlaces = coveredPlaces | ALL_COVERED_SPOTS[l];
          }
          if ((coveredPlaces != ALL_COVERED_CODE)
              && (!CMSecurity.isDisabled(CMSecurity.DisFlag.AUTODISEASE))) {
            Ability COLD = CMClass.getAbility("Disease_Cold");
            if (CMLib.dice().rollPercentage()
                < (fluChance
                    + (((M.location().domainConditions() & Room.CONDITION_WET) > 0) ? 10 : 0)))
              COLD = CMClass.getAbility("Disease_Flu");
            if ((COLD != null) && (M.fetchEffect(COLD.ID()) == null)) COLD.invoke(M, M, true, 0);
          }
        }
        if ((CMLib.dice().rollPercentage() < (frostBiteChance - save))
            && ((C.weatherType(M.location()) != Climate.WEATHER_CLEAR))) {
          long unfrostedPlaces = 0;
          for (int l = 0; l < ALL_FROST_SPOTS.length; l++)
            if (M.getWearPositions(ALL_FROST_SPOTS[l]) == 0)
              unfrostedPlaces = unfrostedPlaces | ALL_FROST_SPOTS[l];
          Item I = null;
          for (int i = 0; i < M.numItems(); i++) {
            I = M.getItem(i);
            if ((I == null) || (I.amWearingAt(Wearable.IN_INVENTORY))) continue;
            for (int l = 0; l < ALL_FROST_SPOTS.length; l++)
              if (I.amWearingAt(ALL_FROST_SPOTS[l]))
                unfrostedPlaces = unfrostedPlaces | ALL_FROST_SPOTS[l];
          }
          if ((unfrostedPlaces != ALL_FROST_CODE)
              && (!CMSecurity.isDisabled(CMSecurity.DisFlag.AUTODISEASE))) {
            Ability COLD = CMClass.getAbility("Disease_FrostBite");
            if ((COLD != null) && (M.fetchEffect(COLD.ID()) == null)) COLD.invoke(M, M, true, 0);
          }
        }
        if ((heatExhaustionChance > 0)
            && (CMLib.dice().rollPercentage()
                < (heatExhaustionChance - M.charStats().getSave(CharStats.STAT_SAVE_FIRE)))
            && (C.weatherType(M.location()) != Climate.WEATHER_CLEAR)
            && (!CMSecurity.isDisabled(CMSecurity.DisFlag.AUTODISEASE))) {
          Ability COLD = CMClass.getAbility("Disease_HeatExhaustion");
          if ((COLD != null) && (M.fetchEffect(COLD.ID()) == null)) COLD.invoke(M, M, true, 0);
        }
      }
    }
    if ((rumbleDown--) == 1) {
      resetRumbleTicks();
      for (Session S : CMLib.sessions().localOnlineIterable()) {
        if ((S.mob() == null)
            || (S.mob().location() == null)
            || (S.mob().location().getArea() != A)
            || (S.mob().isMonster())
            || (!CMath.bset(S.mob().getBitmap(), MOB.ATT_AUTOWEATHER))) continue;
        Room R = S.mob().location();
        if (R != null) {
          switch (C.weatherType(null)) {
            case Climate.WEATHER_THUNDERSTORM:
              {
                if (C.weatherType(R) != Climate.WEATHER_THUNDERSTORM) {
                  if ((R.domainType() & Room.INDOORS) > 0) {
                    if ((R.getArea() != null)
                        && CMath.div(
                                R.getArea().getAreaIStats()[Area.Stats.INDOOR_ROOMS.ordinal()],
                                R.getArea().properSize())
                            < 0.90)
                      S.mob()
                          .tell(
                              "^JA thunderous rumble and CRACK of lightning can be heard outside.^?"
                                  + CMProps.msp("thunder.wav", 40));
                  } else
                    S.mob()
                        .tell(
                            "^JA thunderous rumble and CRACK of lightning can be heard.^?"
                                + CMProps.msp("thunder.wav", 40));
                } else if (R.getArea().getTimeObj().getTODCode() == TimeClock.TIME_DAY)
                  S.mob()
                      .tell(
                          "^JA thunderous rumble and CRACK of lightning can be heard as the pounding rain soaks you.^?"
                              + CMProps.msp("thunderandrain.wav", 40));
                else
                  S.mob()
                      .tell(
                          "^JA bolt of lightning streaks across the sky as the pounding rain soaks you!^?"
                              + CMProps.msp("thunderandrain.wav", 40));
                break;
              }
            case Climate.WEATHER_BLIZZARD:
              if (C.weatherType(R) == Climate.WEATHER_BLIZZARD)
                S.mob()
                    .tell(
                        "^JSwirling clouds of snow buffet you.^?"
                            + CMProps.msp("blizzard.wav", 40));
              break;
            case Climate.WEATHER_SNOW:
              if (C.weatherType(R) == Climate.WEATHER_SNOW)
                S.mob().tell("^JSnowflakes fall lightly on you.^?");
              break;
            case Climate.WEATHER_DUSTSTORM:
              if (C.weatherType(R) == Climate.WEATHER_DUSTSTORM)
                S.mob()
                    .tell(
                        "^JSwirling clouds of dust assault you.^?" + CMProps.msp("windy.wav", 40));
              break;
            case Climate.WEATHER_HAIL:
              if (C.weatherType(R) == Climate.WEATHER_HAIL)
                S.mob()
                    .tell(
                        "^JYou are being pelleted by hail! Ouch!^?" + CMProps.msp("hail.wav", 40));
              break;
            case Climate.WEATHER_RAIN:
              if (C.weatherType(R) == Climate.WEATHER_RAIN)
                S.mob().tell("^JThe rain is soaking you!^?" + CMProps.msp("rainlong.wav", 40));
              break;
            case Climate.WEATHER_SLEET:
              if (C.weatherType(R) == Climate.WEATHER_SLEET)
                S.mob()
                    .tell(
                        "^JCold and blistering sleet is soaking you numb!^?"
                            + CMProps.msp("rain.wav", 40));
              break;
            case Climate.WEATHER_WINDY:
              if (C.weatherType(R) == Climate.WEATHER_WINDY)
                S.mob().tell("^JThe wind gusts around you.^?" + CMProps.msp("wind.wav", 40));
              break;
          }
        }
      }
    }
    if ((lightningDown--) == 1) {
      resetLightningTicks();
      if (C.weatherType(null) == Climate.WEATHER_THUNDERSTORM) {
        boolean playerAround = false;
        for (Session S : CMLib.sessions().localOnlineIterable()) {
          if ((S.mob() == null)
              || (S.mob().location() == null)
              || (S.mob().location().getArea() != A)
              || (S.mob().isMonster())
              || (C.weatherType(S.mob().location()) != Climate.WEATHER_THUNDERSTORM)) continue;
          playerAround = true;
        }
        if (playerAround) {
          Room R = A.getRandomProperRoom();
          MOB M = R.fetchRandomInhabitant();
          if (M != null) {
            Ability A2 = CMClass.getAbility("Chant_SummonLightning");
            if (A2 != null) {
              A2.setMiscText("RENDER MUNDANE");
              A2.invoke(M, M, true, M.phyStats().level());
            }
          } else R = null;
          Room R2 = null;
          for (Enumeration<Room> e = A.getProperMap(); e.hasMoreElements(); ) {
            R2 = (Room) e.nextElement();
            if ((R2 != R) && (R2.numInhabitants() > 0))
              if ((A.getTimeObj().getTODCode() == TimeClock.TIME_DAY)
                  || (C.weatherType(R2) != Climate.WEATHER_THUNDERSTORM)) {
                if ((R2.domainType() & Room.INDOORS) > 0)
                  R2.showHappens(
                      CMMsg.MSG_OK_ACTION,
                      "^JA thunderous rumble and crack of lightning can be heard outside.^?"
                          + CMProps.msp("thunder2.wav", 40));
                else
                  R2.showHappens(
                      CMMsg.MSG_OK_ACTION,
                      "^JA thunderous rumble and crack of lightning can be heard.^?"
                          + CMProps.msp("thunder2.wav", 40));
              } else
                R2.showHappens(
                    CMMsg.MSG_OK_ACTION,
                    "^JYou hear a thunderous rumble as a bolt of lightning streaks across the sky!^?"
                        + CMProps.msp("thunder3.wav", 40));
          }
        }
      }
    }
    if ((tornadoDown--) == 1) {
      resetTornadoTicks();
      if ((C.weatherType(null) == Climate.WEATHER_THUNDERSTORM)
          || (C.weatherType(null) == Climate.WEATHER_WINDY)) {
        boolean playerAround = false;
        for (Session S : CMLib.sessions().localOnlineIterable()) {
          if ((S.mob() == null)
              || (S.mob().location() == null)
              || (S.mob().location().getArea() != A)
              || (S.mob().isMonster())
              || (C.weatherType(S.mob().location()) != Climate.WEATHER_THUNDERSTORM)) continue;
          playerAround = true;
        }
        if (playerAround) {
          Room R = A.getRandomProperRoom();
          MOB M = R.fetchRandomInhabitant();
          if (M != null) {
            Ability A2 = CMClass.getAbility("Chant_SummonTornado");
            if (A2 != null) {
              A2.setMiscText("RENDER MUNDANE");
              MOB mob = CMLib.map().getFactoryMOB(R);
              A2.invoke(mob, null, true, 0);
              mob.destroy();
            }
          } else R = null;
          Room R2 = null;
          for (Enumeration<Room> e = A.getProperMap(); e.hasMoreElements(); ) {
            R2 = (Room) e.nextElement();
            if ((R2 != R) && (R2.numInhabitants() > 0))
              if ((A.getTimeObj().getTODCode() == TimeClock.TIME_DAY)
                  || (C.weatherType(R2) != Climate.WEATHER_THUNDERSTORM)) {
                if ((R2.domainType() & Room.INDOORS) > 0)
                  R2.showHappens(
                      CMMsg.MSG_OK_ACTION,
                      "^JThe terrible rumble of a tornado can be heard outside.^?"
                          + CMProps.msp("tornado.wav", 40));
                else
                  R2.showHappens(
                      CMMsg.MSG_OK_ACTION,
                      "^JThe terrible rumble of a tornado can be heard.^?"
                          + CMProps.msp("tornado.wav", 40));
              } else
                R2.showHappens(
                    CMMsg.MSG_OK_ACTION,
                    "^JA huge and terrible tornado touches down somewhere near by.^?"
                        + CMProps.msp("tornado.wav", 40));
          }
        }
      }
    }
    if ((dustDown--) == 1) {
      resetDustTicks();
      if (C.weatherType(null) == Climate.WEATHER_DUSTSTORM) {
        Vector choices = new Vector();
        Room R = null;
        for (Session S : CMLib.sessions().localOnlineIterable()) {
          if ((S.mob() == null)
              || (S.mob().location() == null)
              || (S.mob().location().getArea() != A)
              || (S.mob().isMonster())
              || (C.weatherType(S.mob().location()) != Climate.WEATHER_DUSTSTORM)) continue;
          R = S.mob().location();
          if ((R != null) && (!choices.contains(R))) choices.addElement(R);
        }
        if (choices.size() > 0) {
          R = (Room) choices.elementAt(CMLib.dice().roll(1, choices.size(), -1));
          MOB M = R.fetchRandomInhabitant();
          if ((M != null)
              && (C.weatherType(R) == Climate.WEATHER_DUSTSTORM)
              && (!CMLib.flags().isSleeping(M))) {
            Ability A2 = CMClass.getAbility("Skill_Dirt");
            if (A2 != null) A2.invoke(M, M, true, 0);
          }
        }
      }
    }
    if ((hailDown--) == 1) {
      resetHailTicks();
      if (C.weatherType(null) == Climate.WEATHER_HAIL) {
        Vector choices = new Vector();
        Room R = null;
        for (Session S : CMLib.sessions().localOnlineIterable()) {
          if ((S.mob() == null)
              || (S.mob().location() == null)
              || (S.mob().location().getArea() != A)
              || (S.mob().isMonster())
              || (C.weatherType(S.mob().location()) != Climate.WEATHER_HAIL)) continue;
          R = S.mob().location();
          if ((R != null) && (!choices.contains(R))) choices.addElement(R);
        }
        if (choices.size() > 0) {
          R = (Room) choices.elementAt(CMLib.dice().roll(1, choices.size(), -1));
          MOB M = R.fetchRandomInhabitant();
          Ability A2 = CMClass.getAbility("Chant_SummonHail");
          if ((A2 != null) && (C.weatherType(R) == Climate.WEATHER_HAIL)) {
            A2.setMiscText("RENDER MUNDANE");
            A2.invoke(M, M, true, M.phyStats().level());
          }
        }
      }
    }
    if ((C.weatherType(null) == Climate.WEATHER_DROUGHT)
        && (CMLib.dice().rollPercentage() < droughtFireChance)) {
      Room R = CMLib.map().roomLocation((Environmental) ticking);
      if ((R == null) && (ticking instanceof Area)) R = ((Area) ticking).getRandomProperRoom();
      if ((R != null)
          && ((R.domainType() & Room.INDOORS) == 0)
          && (R.domainType() != Room.DOMAIN_OUTDOORS_SWAMP)
          && (R.domainType() != Room.DOMAIN_OUTDOORS_UNDERWATER)
          && (R.domainType() != Room.DOMAIN_OUTDOORS_WATERSURFACE)
          && ((R.domainConditions() & Room.CONDITION_WET) == 0)) {
        Item I = R.getRandomItem();
        if ((I != null) && (CMLib.flags().isGettable(I)))
          switch (I.material() & RawMaterial.MATERIAL_MASK) {
            case RawMaterial.MATERIAL_CLOTH:
            case RawMaterial.MATERIAL_LEATHER:
            case RawMaterial.MATERIAL_PAPER:
            case RawMaterial.MATERIAL_VEGETATION:
            case RawMaterial.MATERIAL_WOODEN:
              {
                Ability A2 = CMClass.getAbility("Burning");
                MOB mob = CMLib.map().getFactoryMOB(R);
                R.showHappens(
                    CMMsg.MSG_OK_VISUAL,
                    I.Name()
                        + " spontaneously combusts in the seering heat!"
                        + CMProps.msp("fire.wav", 40));
                A2.invoke(mob, I, true, 0);
                mob.destroy();
              }
              break;
          }
      }
    }
    if ((gustDown--) == 1) {
      resetGustTicks();
      if ((C.weatherType(null) == Climate.WEATHER_WINDY)
          || (C.weatherType(null) == Climate.WEATHER_BLIZZARD)
          || (C.weatherType(null) == Climate.WEATHER_DUSTSTORM)) {
        Vector choices = new Vector();
        Room R = null;
        for (Session S : CMLib.sessions().localOnlineIterable()) {
          if ((S.mob() == null)
              || (S.mob().location() == null)
              || (S.mob().location().getArea() != A)
              || (S.mob().isMonster())
              || ((C.weatherType(S.mob().location()) != Climate.WEATHER_WINDY)
                  && (C.weatherType(S.mob().location()) != Climate.WEATHER_BLIZZARD)
                  && (C.weatherType(S.mob().location()) != Climate.WEATHER_DUSTSTORM))) continue;
          R = S.mob().location();
          if ((R != null) && (!choices.contains(R))) choices.addElement(R);
        }
        if (choices.size() > 0) {
          R = (Room) choices.elementAt(CMLib.dice().roll(1, choices.size(), -1));
          MOB M = CMLib.map().getFactoryMOB(R);
          Ability A2 = CMClass.getAbility("Chant_WindGust");
          if (A2 != null) {
            A2.setMiscText("RENDER MUNDANE");
            A2.invoke(M, M, true, M.phyStats().level());
          }
          M.destroy();
        }
      }
    }
    if ((rustDown--) == 1) {
      resetRustTicks();
      for (Session S : CMLib.sessions().localOnlineIterable()) {
        if ((S.mob() == null)
            || (S.mob().location() == null)
            || (S.mob().location().getArea() != A)
            || (S.mob().isMonster())) continue;
        int rustChance = 0;
        switch (C.weatherType(S.mob().location())) {
          case Climate.WEATHER_BLIZZARD:
          case Climate.WEATHER_SLEET:
          case Climate.WEATHER_SNOW:
            rustChance = 5;
            break;
          case Climate.WEATHER_HAIL:
            rustChance = 5;
            break;
          case Climate.WEATHER_THUNDERSTORM:
          case Climate.WEATHER_RAIN:
            rustChance = 5;
            break;
        }

        MOB M = S.mob();
        Room R = M.location();

        switch (R.domainType()) {
          case Room.DOMAIN_INDOORS_UNDERWATER:
          case Room.DOMAIN_INDOORS_WATERSURFACE:
          case Room.DOMAIN_OUTDOORS_WATERSURFACE:
          case Room.DOMAIN_OUTDOORS_UNDERWATER:
            rustChance += 5;
            break;
          default:
            break;
        }
        if ((R.domainConditions() & Room.CONDITION_WET) > 0) rustChance += 2;
        if (CMLib.dice().rollPercentage() < rustChance) {
          int weatherType = C.weatherType(R);
          Vector rustThese = new Vector();
          for (int i = 0; i < M.numItems(); i++) {
            Item I = M.getItem(i);
            if (I == null) continue;
            if ((!I.amWearingAt(Wearable.IN_INVENTORY))
                && (((I.material() & RawMaterial.MATERIAL_MASK) == RawMaterial.MATERIAL_METAL))
                && (I.subjectToWearAndTear())
                && ((CMLib.dice().rollPercentage() > I.phyStats().ability() * 25)))
              rustThese.addElement(I);
            else if (I.amWearingAt(Wearable.WORN_ABOUT_BODY)
                && (((I.material() & RawMaterial.MATERIAL_MASK) != RawMaterial.MATERIAL_METAL))) {
              rustThese.clear();
              break;
            }
          }
          if (R != null)
            for (int i = 0; i < rustThese.size(); i++) {
              Item I = (Item) rustThese.elementAt(i);
              CMMsg msg =
                  CMClass.getMsg(
                      M,
                      I,
                      null,
                      CMMsg.MASK_ALWAYS | CMMsg.TYP_WATER,
                      (weatherType != 0) ? "<T-NAME> rusts." : "<T-NAME> rusts in the water.",
                      CMMsg.TYP_WATER,
                      null,
                      CMMsg.NO_EFFECT,
                      null);
              if (R.okMessage(M, msg)) {
                R.send(M, msg);
                if (msg.value() <= 0) {
                  I.setUsesRemaining(I.usesRemaining() - 1);
                  if (I.usesRemaining() <= 0) {
                    msg =
                        CMClass.getMsg(
                            M,
                            null,
                            null,
                            CMMsg.MSG_OK_VISUAL,
                            I.name() + " is destroyed!",
                            null,
                            I.name() + " carried by " + M.name() + " is destroyed!");
                    if (R.okMessage(M, msg)) R.send(M, msg);
                    I.destroy();
                  }
                }
              }
            }
        }
      }
    }
    if (ticking instanceof Room) lastWeather = C.weatherType((Room) ticking);
    else lastWeather = C.weatherType(null);
    return true;
  }
Exemplo n.º 8
0
  public boolean invoke(MOB mob, Vector commands, Physical givenTarget, boolean auto, int asLevel) {
    Set<MOB> h = properTargets(mob, givenTarget, auto);
    if ((h == null) || (h.size() == 0)) {
      mob.tell("There doesn't appear to be anyone here worth repelling.");
      return false;
    }

    // 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;

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

    if (success) {
      if (mob.location()
          .show(
              mob,
              null,
              this,
              somanticCastCode(mob, null, auto),
              auto ? "" : "^S<S-NAME> wave(s) <S-HIS-HER> arms and cast(s) a spell.^?"))
        for (Iterator f = h.iterator(); f.hasNext(); ) {
          MOB target = (MOB) f.next();

          // 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), null);
          if ((mob.location().okMessage(mob, msg)) && (target.fetchEffect(this.ID()) == null)) {
            mob.location().send(mob, msg);
            if (msg.value() <= 0) {
              amountRemaining = 130;
              if (target.location() == mob.location()) {
                success =
                    maliciousAffect(
                        mob,
                        target,
                        asLevel,
                        ((mob.phyStats().level() + (2 * getXLEVELLevel(mob))) * 10),
                        -1);
                int level = 2;
                if ((CMLib.ableMapper().qualifyingClassLevel(mob, this) > 0)
                    && ((adjustedLevel(mob, asLevel)
                            - CMLib.ableMapper().qualifyingClassLevel(mob, this))
                        > 10))
                  level +=
                      ((adjustedLevel(mob, asLevel)
                                  - CMLib.ableMapper().qualifyingClassLevel(mob, this))
                              - 10)
                          / 10;
                if (level < 2) level = 2;
                target
                    .location()
                    .show(target, null, CMMsg.MSG_OK_ACTION, "<S-NAME> become(s) repelled!");
                if ((target.getVictim() != null) && (target.rangeToTarget() > 0))
                  target.setAtRange(target.rangeToTarget());
                else if (target.location().maxRange() < level)
                  target.setAtRange(target.location().maxRange());
                else target.setAtRange(level);
                if (target.getVictim() != null)
                  target.getVictim().setAtRange(target.rangeToTarget());
                if (mob.getVictim() == null) mob.setVictim(null); // correct range
                if (target.getVictim() == null) target.setVictim(null); // correct range
              }
            }
          }
        }
    } else
      return maliciousFizzle(
          mob, null, "<S-NAME> wave(s) <S-HIS-HER> arms, but the spell fizzles.");

    // return whether it worked
    return success;
  }
Exemplo n.º 9
0
  public boolean invoke(MOB mob, Vector commands, Physical givenTarget, boolean auto, int asLevel) {
    boolean saveTheTrap = false;
    if ((commands.size() > 0) && (commands.lastElement() instanceof Boolean)) {
      saveTheTrap = ((Boolean) commands.lastElement()).booleanValue();
      commands.removeElementAt(commands.size() - 1);
    }
    String whatTounlock = CMParms.combine(commands, 0);
    Physical unlockThis = null;
    int dirCode = Directions.getGoodDirectionCode(whatTounlock);
    Room R = mob.location();
    Room nextRoom = null;
    if (dirCode >= 0) {
      nextRoom = R.getRoomInDir(dirCode);
      unlockThis = R.getExitInDir(dirCode);
    }
    if ((unlockThis == null)
        && (whatTounlock.equalsIgnoreCase("room") || whatTounlock.equalsIgnoreCase("here")))
      unlockThis = R;
    if (unlockThis == null)
      unlockThis = getAnyTarget(mob, commands, givenTarget, Wearable.FILTER_UNWORNONLY);
    if (unlockThis == null) return false;
    int oldProficiency = proficiency();

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

    boolean success =
        proficiencyCheck(
            mob,
            +(((mob.phyStats().level() + (getXLEVELLevel(mob) * 2)) - unlockThis.phyStats().level())
                * 3),
            auto);
    Vector<Physical> permSetV = new Vector<Physical>();
    Trap theTrap = CMLib.utensils().fetchMyTrap(unlockThis);
    if (theTrap != null) permSetV.addElement(unlockThis);
    Trap opTrap = null;
    boolean permanent = false;
    if ((unlockThis instanceof Room) && (CMLib.law().doesOwnThisProperty(mob, ((Room) unlockThis))))
      permanent = true;
    else if (unlockThis instanceof Exit) {
      Room R2 = null;
      if (dirCode < 0)
        for (int d = Directions.NUM_DIRECTIONS() - 1; d >= 0; d--)
          if (R.getExitInDir(d) == unlockThis) {
            dirCode = d;
            R2 = R.getRoomInDir(d);
            break;
          }
      if ((CMLib.law().doesOwnThisProperty(mob, R))
          || ((R2 != null) && (CMLib.law().doesOwnThisProperty(mob, R2)))) permanent = true;
      if (dirCode >= 0) {
        Exit exit = R.getReverseExit(dirCode);
        if (exit != null) opTrap = CMLib.utensils().fetchMyTrap(exit);
        if (opTrap != null) permSetV.addElement(exit);
        Trap roomTrap = null;
        if (nextRoom != null) roomTrap = CMLib.utensils().fetchMyTrap(nextRoom);
        if (roomTrap != null) permSetV.addElement(nextRoom);
        if ((theTrap != null) && (theTrap.disabled()) && (roomTrap != null)) {
          opTrap = null;
          unlockThis = nextRoom;
          theTrap = roomTrap;
        }
      }
    }
    if (unlockThis == null) {
      mob.tell("You can't seem to remember how this works.");
      return false;
    }
    CMMsg msg =
        CMClass.getMsg(
            mob,
            unlockThis,
            this,
            auto ? CMMsg.MSG_OK_ACTION : CMMsg.MSG_DELICATE_HANDS_ACT,
            CMMsg.MSG_DELICATE_HANDS_ACT,
            CMMsg.MSG_OK_ACTION,
            auto
                ? unlockThis.name() + " begins to glow."
                : "<S-NAME> attempt(s) to safely deactivate a trap on " + unlockThis.name() + ".");
    if ((success) && (!lastDone.contains("" + unlockThis))) {
      while (lastDone.size() > 40) lastDone.removeElementAt(0);
      lastDone.addElement("" + unlockThis);
      msg.setValue(1);
    } else msg.setValue(0);
    if (R.okMessage(mob, msg)) {
      R.send(mob, msg);
      if ((unlockThis == lastChecked) && ((theTrap == null) || (theTrap.disabled())))
        setProficiency(oldProficiency);
      if (success) {
        if (theTrap != null) {
          theTrap.disable();
          if (saveTheTrap) commands.addElement(theTrap);
        }
        if (opTrap != null) {
          opTrap.disable();
          if (saveTheTrap) commands.addElement(opTrap);
        }
        if (permanent) {
          for (int i = 0; i < permSetV.size(); i++) {
            if (theTrap != null) {
              theTrap.unInvoke();
              ((Physical) permSetV.elementAt(i)).delEffect(theTrap);
            }
            if (opTrap != null) {
              opTrap.unInvoke();
              ((Physical) permSetV.elementAt(i)).delEffect(opTrap);
            }
          }
          CMLib.database().DBUpdateRoom(R);
          CMLib.database().DBUpdateExits(R);
        }
      }
      if ((!auto) && (!saveTheTrap)) mob.tell("You have completed your attempt.");
      lastChecked = unlockThis;
    }

    return success;
  }
Exemplo n.º 10
0
  public boolean invoke(MOB mob, Vector commands, Physical givenTarget, boolean auto, int asLevel) {
    String whom = CMParms.combine(commands, 0);
    int dirCode = Directions.getGoodDirectionCode(whom);
    if (!CMLib.flags().canHear(mob)) {
      mob.tell("You don't hear anything.");
      return false;
    }

    if (room != null)
      for (final Enumeration<Ability> a = room.effects(); a.hasMoreElements(); ) {
        final Ability A = a.nextElement();
        if ((A.ID().equals(ID())) && (invoker() == mob)) A.unInvoke();
      }
    room = null;
    if (dirCode < 0) room = mob.location();
    else {
      if ((mob.location().getRoomInDir(dirCode) == null)
          || (mob.location().getExitInDir(dirCode) == null)) {
        mob.tell("Listen which direction?");
        return false;
      }
      room = mob.location().getRoomInDir(dirCode);
      if ((room.domainType() & Room.INDOORS) == 0) {
        mob.tell("You can only listen indoors.");
        return false;
      }
    }

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

    boolean success = false;
    CMMsg msg =
        CMClass.getMsg(
            mob,
            null,
            this,
            auto ? CMMsg.MSG_OK_ACTION : (CMMsg.MSG_DELICATE_SMALL_HANDS_ACT),
            CMMsg.MSG_OK_VISUAL,
            CMMsg.MSG_OK_VISUAL,
            "<S-NAME> listen(s)"
                + ((dirCode < 0) ? "" : " " + Directions.getDirectionName(dirCode))
                + ".");
    if (mob.location().okMessage(mob, msg)) {
      mob.location().send(mob, msg);
      success = proficiencyCheck(mob, 0, auto);
      int numberHeard = 0;
      int levelsHeard = 0;
      for (int i = 0; i < room.numInhabitants(); i++) {
        MOB inhab = room.fetchInhabitant(i);
        if ((inhab != null)
            && (!CMLib.flags().isSneaking(inhab))
            && (!CMLib.flags().isHidden(inhab))
            && (inhab != mob)) {
          numberHeard++;
          if (inhab.phyStats().level() > (mob.phyStats().level() + (2 * super.getXLEVELLevel(mob))))
            levelsHeard +=
                (inhab.phyStats().level()
                    - (mob.phyStats().level() + (2 * super.getXLEVELLevel(mob))));
        }
      }
      if ((success) && (numberHeard > 0)) {
        if (((proficiency() + (getXLEVELLevel(mob) * 10)) > (50 + levelsHeard))
            || (room == mob.location())) {
          mob.tell("You definitely hear " + numberHeard + " creature(s).");
          if (proficiency() > ((room == mob.location()) ? 50 : 75)) {
            sourceRoom = mob.location();
            beneficialAffect(mob, room, asLevel, ((room == mob.location()) ? 0 : 10));
          }
        } else mob.tell("You definitely hear something.");
      } else mob.tell("You don't hear anything.");
    }
    return success;
  }