示例#1
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;

    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,
              CMMsg.MSK_MALICIOUS_MOVE | CMMsg.TYP_PARALYZE | (auto ? CMMsg.MASK_ALWAYS : 0),
              auto ? "" : "^S<S-NAME> paralyze(s) <T-NAMESELF>.^?");
      if (target.location().okMessage(target, msg)) {
        target.location().send(target, msg);
        if (msg.value() <= 0) {
          success = maliciousAffect(mob, target, asLevel, 5, -1);
          mob.location().show(target, null, CMMsg.MSG_OK_VISUAL, "<S-NAME> can't move!");
        }
      }
    } else
      return maliciousFizzle(
          mob, target, "<S-NAME> attempt(s) to paralyze <T-NAMESELF>, but fail(s)!");

    // return whether it worked
    return success;
  }
示例#2
0
 public void executeMsg(final Environmental myHost, final CMMsg msg) {
   if ((msg.amITarget(littlePlants)) && (msg.targetMinor() == CMMsg.TYP_GET))
     msg.addTrailerMsg(
         CMClass.getMsg(
             msg.source(),
             littlePlants,
             null,
             CMMsg.MSG_OK_VISUAL,
             CMMsg.MASK_ALWAYS | CMMsg.MSG_DEATH,
             CMMsg.NO_EFFECT,
             null));
 }
示例#3
0
  public boolean okMessage(Environmental host, CMMsg msg) {
    if (!super.okMessage(host, msg)) return false;

    if ((msg.target() == affected)
        && (msg.targetMinor() == CMMsg.TYP_ENTER)
        && (affected instanceof Room)
        && (isLaw(msg.source()))) {
      msg.source().tell("You don't think there's anything going on in there.");
      return false;
    }
    return true;
  }
示例#4
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;

    boolean success = proficiencyCheck(mob, 0, auto);
    CMMsg msg2 = null;
    if ((mob != target) && (!mob.getGroupMembers(new HashSet<MOB>()).contains(target)))
      msg2 =
          CMClass.getMsg(
              mob,
              target,
              this,
              verbalCastCode(mob, target, auto) | CMMsg.MASK_MALICIOUS,
              "<T-NAME> do(es) not seem to like <S-NAME> messing with <T-HIS-HER> head.");

    if (success && (CMLib.factions().getFaction(CMLib.factions().AlignID()) != 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),
              (auto
                  ? "<T-NAME> feel(s) more good."
                  : "^S<S-NAME> " + prayWord(mob) + " to atone <T-NAMESELF>!^?"));
      if ((mob.location().okMessage(mob, msg))
          && ((msg2 == null) || (mob.location().okMessage(mob, msg2)))) {
        mob.location().send(mob, msg);
        if ((msg.value() <= 0) && ((msg2 == null) || (msg2.value() <= 0))) {
          target.tell("Good, pure thoughts fill your head.");
          int evilness = CMLib.dice().roll(10, adjustedLevel(mob, asLevel), 0);
          CMLib.factions().postFactionChange(target, this, CMLib.factions().AlignID(), evilness);
        }
        if (msg2 != null) mob.location().send(mob, msg2);
      }
    } else {
      if ((msg2 != null) && (mob.location().okMessage(mob, msg2))) mob.location().send(mob, msg2);
      return beneficialWordsFizzle(
          mob,
          target,
          "<S-NAME> point(s) at <T-NAMESELF> and " + prayWord(mob) + ", but nothing happens.");
    }

    // return whether it worked
    return success;
  }
示例#5
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;
  }
示例#6
0
 public void executeMsg(Environmental host, CMMsg msg) {
   if ((affected instanceof Armor) && (msg.source() == ((Armor) affected).owner())) {
     if ((msg.targetMinor() == CMMsg.TYP_REMOVE)
         || (msg.sourceMinor() == CMMsg.TYP_WEAR)
         || (msg.sourceMinor() == CMMsg.TYP_WIELD)
         || (msg.sourceMinor() == CMMsg.TYP_HOLD)
         || (msg.sourceMinor() == CMMsg.TYP_DROP)) checked = false;
     else {
       check(msg.source(), (Armor) affected);
       super.executeMsg(host, msg);
     }
   } else super.executeMsg(host, msg);
 }
示例#7
0
 public void executeMsg(Environmental host, CMMsg msg) {
   if (affected instanceof MOB) {
     MOB mob = (MOB) affected;
     if ((msg.source() == mob)
         && (msg.target() == mob.location())
         && (msg.targetMinor() == CMMsg.TYP_LEAVE)) {
       failed = true;
       unInvoke();
     } else if ((CMLib.flags().isStanding(mob)) || (mob.location() != room)) {
       failed = true;
       unInvoke();
     }
   }
   super.executeMsg(host, msg);
 }
示例#8
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;
 }
示例#9
0
  public boolean okMessage(final Environmental myHost, final CMMsg msg) {
    if ((affected == null) || (!(affected instanceof MOB))) return true;

    MOB mob = (MOB) affected;

    // when this spell is on a MOBs Affected list,
    // it should consistantly prevent the mob
    // from trying to do ANYTHING except sleep
    if (msg.amISource(mob)) {
      switch (msg.sourceMinor()) {
        case CMMsg.TYP_ENTER:
        case CMMsg.TYP_ADVANCE:
        case CMMsg.TYP_LEAVE:
        case CMMsg.TYP_FLEE:
          mob.tell("You are frozen, and cant go anywhere.");
          return false;
      }
    }
    return super.okMessage(myHost, msg);
  }
示例#10
0
文件: Wear.java 项目: Cocanuta/Marble
 public boolean wear(MOB mob, Item item, int locationIndex, boolean quiet) {
   String str = "<S-NAME> put(s) on <T-NAME>.";
   int msgType = CMMsg.MSG_WEAR;
   if (item.rawProperLocationBitmap() == Wearable.WORN_HELD) {
     str = "<S-NAME> hold(s) <T-NAME>.";
     msgType = CMMsg.MSG_HOLD;
   } else if ((item.rawProperLocationBitmap() == Wearable.WORN_WIELD)
       || (item.rawProperLocationBitmap() == (Wearable.WORN_HELD | Wearable.WORN_WIELD))) {
     str = "<S-NAME> wield(s) <T-NAME>.";
     msgType = CMMsg.MSG_WIELD;
   } else if (locationIndex != 0)
     str =
         "<S-NAME> put(s) <T-NAME> on <S-HIS-HER> "
             + Wearable.CODES.NAME(locationIndex).toLowerCase()
             + ".";
   CMMsg newMsg = CMClass.getMsg(mob, item, null, msgType, quiet ? null : str);
   newMsg.setValue(locationIndex);
   if (mob.location().okMessage(mob, newMsg)) {
     mob.location().send(mob, newMsg);
     return true;
   }
   return false;
 }
示例#11
0
  public boolean okMessage(final Environmental myHost, final CMMsg msg) {
    if ((affected == null) || (!(affected instanceof MOB))) return true;

    MOB mob = (MOB) affected;

    // when this spell is on a MOBs Affected list,
    // it should consistantly prevent the mob
    // from trying to do ANYTHING except sleep
    if (msg.amISource(mob)) {
      if (msg.sourceMinor() == CMMsg.TYP_ADVANCE) {
        if (mob.location()
            .show(
                mob,
                null,
                CMMsg.MSG_OK_ACTION,
                "<S-NAME> struggle(s) against the repulsion field.")) {
          amountRemaining -= mob.charStats().getStat(CharStats.STAT_STRENGTH);
          if (amountRemaining < 0) unInvoke();
        }
        return false;
      }
    }
    return super.okMessage(myHost, msg);
  }
示例#12
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);
  }
示例#13
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;
  }
示例#14
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;
  }
示例#15
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;
  }
示例#16
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);
  }
示例#17
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;
  }
示例#18
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();
    }
  }
示例#19
0
  public boolean invoke(MOB mob, Vector commands, Physical givenTarget, boolean auto, int asLevel) {
    int autoGenerate = 0;
    if ((auto) && (commands.size() > 0) && (commands.firstElement() instanceof Integer)) {
      autoGenerate = ((Integer) commands.firstElement()).intValue();
      commands.removeElementAt(0);
      givenTarget = null;
    }
    DVector enhancedTypes = enhancedTypes(mob, commands);
    randomRecipeFix(mob, addRecipes(mob, loadRecipes()), commands, autoGenerate);
    if (commands.size() == 0) {
      commonTell(
          mob,
          "Weave what? Enter \"weave list\" for a list, \"weave refit <item>\" to resize, \"weave learn <item>\", \"weave scan\", or \"weave mend <item>\".");
      return false;
    }
    if ((!auto)
        && (commands.size() > 0)
        && (((String) commands.firstElement()).equalsIgnoreCase("bundle"))) {
      bundling = true;
      if (super.invoke(mob, commands, givenTarget, auto, asLevel))
        return super.bundle(mob, commands);
      return false;
    }
    List<List<String>> recipes = addRecipes(mob, loadRecipes());
    String str = (String) commands.elementAt(0);
    bundling = false;
    String startStr = null;
    int duration = 4;
    if (str.equalsIgnoreCase("list")) {
      String mask = CMParms.combine(commands, 1);
      StringBuffer buf = new StringBuffer("");
      int toggler = 1;
      int toggleTop = 2;
      for (int r = 0; r < toggleTop; r++)
        buf.append(
            CMStrings.padRight("Item", 22)
                + " "
                + CMStrings.padRight("Lvl", 3)
                + " "
                + CMStrings.padRight("Material", 10)
                + " ");
      buf.append("\n\r");
      for (int r = 0; r < recipes.size(); r++) {
        List<String> V = recipes.get(r);
        if (V.size() > 0) {
          String item = replacePercent((String) V.get(RCP_FINALNAME), "");
          int level = CMath.s_int((String) V.get(RCP_LEVEL));
          String wood = getComponentDescription(mob, V, RCP_WOOD);
          if (wood.length() > 5) {
            if (toggler > 1) buf.append("\n\r");
            toggler = toggleTop;
          }
          if ((level <= xlevel(mob))
              && ((mask == null)
                  || (mask.length() == 0)
                  || mask.equalsIgnoreCase("all")
                  || CMLib.english().containsString(item, mask))) {
            buf.append(
                CMStrings.padRight(item, 22)
                    + " "
                    + CMStrings.padRight("" + level, 3)
                    + " "
                    + CMStrings.padRightPreserve("" + wood, 10)
                    + ((toggler != toggleTop) ? " " : "\n\r"));
            if (++toggler > toggleTop) toggler = 1;
          }
        }
      }
      if (toggler != 1) buf.append("\n\r");
      commonTell(mob, buf.toString());
      enhanceList(mob);
      return true;
    } else if ((commands.firstElement() instanceof String)
        && (((String) commands.firstElement())).equalsIgnoreCase("learn")) {
      return doLearnRecipe(mob, commands, givenTarget, auto, asLevel);
    } else if (str.equalsIgnoreCase("scan")) return publicScan(mob, commands);
    else if (str.equalsIgnoreCase("mend")) {
      building = null;
      activity = CraftingActivity.CRAFTING;
      messedUp = false;
      key = null;
      Vector newCommands = CMParms.parse(CMParms.combine(commands, 1));
      building =
          getTarget(mob, mob.location(), givenTarget, newCommands, Wearable.FILTER_UNWORNONLY);
      if (!canMend(mob, building, false)) return false;
      activity = CraftingActivity.MENDING;
      if (!super.invoke(mob, commands, givenTarget, auto, asLevel)) return false;
      startStr = "<S-NAME> start(s) mending " + building.name() + ".";
      displayText = "You are mending " + building.name();
      verb = "mending " + building.name();
    } else if (str.equalsIgnoreCase("refit")) {
      building = null;
      activity = CraftingActivity.CRAFTING;
      key = null;
      messedUp = false;
      Vector newCommands = CMParms.parse(CMParms.combine(commands, 1));
      building =
          getTarget(mob, mob.location(), givenTarget, newCommands, Wearable.FILTER_UNWORNONLY);
      if (building == null) return false;
      if ((building.material() != RawMaterial.RESOURCE_COTTON)
          && (building.material() != RawMaterial.RESOURCE_SILK)
          && (building.material() != RawMaterial.RESOURCE_HEMP)
          && (building.material() != RawMaterial.RESOURCE_VINE)
          && (building.material() != RawMaterial.RESOURCE_WHEAT)
          && (building.material() != RawMaterial.RESOURCE_SEAWEED)) {
        commonTell(mob, "That's not made of any sort of weavable material.  It can't be refitted.");
        return false;
      }
      if (!(building instanceof Armor)) {
        commonTell(mob, "You don't know how to refit that sort of thing.");
        return false;
      }
      if (building.phyStats().height() == 0) {
        commonTell(mob, building.name() + " is already the right size.");
        return false;
      }
      activity = CraftingActivity.REFITTING;
      if (!super.invoke(mob, commands, givenTarget, auto, asLevel)) return false;
      startStr = "<S-NAME> start(s) refitting " + building.name() + ".";
      displayText = "You are refitting " + building.name();
      verb = "refitting " + building.name();
    } else {
      building = null;
      activity = CraftingActivity.CRAFTING;
      messedUp = false;
      aborted = false;
      key = null;
      int amount = -1;
      if ((commands.size() > 1) && (CMath.isNumber((String) commands.lastElement()))) {
        amount = CMath.s_int((String) commands.lastElement());
        commands.removeElementAt(commands.size() - 1);
      }
      String recipeName = CMParms.combine(commands, 0);
      List<String> foundRecipe = null;
      List<List<String>> matches = matchingRecipeNames(recipes, recipeName, true);
      for (int r = 0; r < matches.size(); r++) {
        List<String> V = matches.get(r);
        if (V.size() > 0) {
          int level = CMath.s_int((String) V.get(RCP_LEVEL));
          if (level <= xlevel(mob)) {
            foundRecipe = V;
            break;
          }
        }
      }
      if (foundRecipe == null) {
        commonTell(
            mob,
            "You don't know how to weave a '" + recipeName + "'.  Try \"weave list\" for a list.");
        return false;
      }

      final String woodRequiredStr = (String) foundRecipe.get(RCP_WOOD);
      final List<Object> componentsFoundList =
          getAbilityComponents(
              mob,
              woodRequiredStr,
              "make " + CMLib.english().startWithAorAn(recipeName),
              autoGenerate);
      if (componentsFoundList == null) return false;
      int woodRequired = CMath.s_int(woodRequiredStr);
      woodRequired = adjustWoodRequired(woodRequired, mob);

      if (amount > woodRequired) woodRequired = amount;
      int[] pm = {
        RawMaterial.RESOURCE_COTTON,
        RawMaterial.RESOURCE_SILK,
        RawMaterial.RESOURCE_HEMP,
        RawMaterial.RESOURCE_VINE,
        RawMaterial.RESOURCE_WHEAT,
        RawMaterial.RESOURCE_SEAWEED
      };
      String misctype = (String) foundRecipe.get(RCP_MISCTYPE);
      String spell =
          (foundRecipe.size() > RCP_SPELL) ? ((String) foundRecipe.get(RCP_SPELL)).trim() : "";
      bundling = spell.equalsIgnoreCase("BUNDLE") || misctype.equalsIgnoreCase("BUNDLE");
      int[][] data =
          fetchFoundResourceData(
              mob,
              woodRequired,
              "weavable material",
              pm,
              0,
              null,
              null,
              false,
              autoGenerate,
              enhancedTypes);
      if (data == null) return false;
      fixDataForComponents(data, componentsFoundList);
      woodRequired = data[0][FOUND_AMT];
      if (!super.invoke(mob, commands, givenTarget, auto, asLevel)) return false;
      int lostValue =
          autoGenerate > 0
              ? 0
              : CMLib.materials()
                      .destroyResources(mob.location(), woodRequired, data[0][FOUND_CODE], 0, null)
                  + CMLib.ableMapper().destroyAbilityComponents(componentsFoundList);
      building = CMClass.getItem((String) foundRecipe.get(RCP_CLASSTYPE));
      if (building == null) {
        commonTell(mob, "There's no such thing as a " + foundRecipe.get(RCP_CLASSTYPE) + "!!!");
        return false;
      }
      duration =
          getDuration(
              CMath.s_int((String) foundRecipe.get(RCP_TICKS)),
              mob,
              CMath.s_int((String) foundRecipe.get(RCP_LEVEL)),
              4);
      String itemName =
          replacePercent(
                  (String) foundRecipe.get(RCP_FINALNAME),
                  RawMaterial.CODES.NAME(data[0][FOUND_CODE]))
              .toLowerCase();
      if (bundling) itemName = "a " + woodRequired + "# " + itemName;
      else if (itemName.endsWith("s")) itemName = "some " + itemName;
      else itemName = CMLib.english().startWithAorAn(itemName);
      building.setName(itemName);
      startStr = "<S-NAME> start(s) weaving " + building.name() + ".";
      displayText = "You are weaving " + building.name();
      verb = "weaving " + building.name();
      building.setDisplayText(itemName + " lies here");
      building.setDescription(itemName + ". ");
      building
          .basePhyStats()
          .setWeight(
              (int) Math.round((double) woodRequired * this.getItemWeightMultiplier(bundling)));
      building.setBaseValue(CMath.s_int((String) foundRecipe.get(RCP_VALUE)));
      building.setMaterial(data[0][FOUND_CODE]);
      building.basePhyStats().setLevel(CMath.s_int((String) foundRecipe.get(RCP_LEVEL)));
      building.setSecretIdentity(getBrand(mob));
      int capacity = CMath.s_int((String) foundRecipe.get(RCP_CAPACITY));
      long canContain = getContainerType((String) foundRecipe.get(RCP_CONTAINMASK));
      int armordmg = CMath.s_int((String) foundRecipe.get(RCP_ARMORDMG));
      if (bundling) {
        building.setBaseValue(lostValue);
        building.basePhyStats().setWeight(woodRequired);
      }
      addSpells(building, spell);
      if (building instanceof Weapon) {
        ((Weapon) building).setWeaponClassification(Weapon.CLASS_FLAILED);
        for (int cl = 0; cl < Weapon.CLASS_DESCS.length; cl++) {
          if (misctype.equalsIgnoreCase(Weapon.CLASS_DESCS[cl]))
            ((Weapon) building).setWeaponClassification(cl);
        }
        building.basePhyStats().setDamage(armordmg);
        ((Weapon) building).setRawProperLocationBitmap(Wearable.WORN_WIELD | Wearable.WORN_HELD);
        ((Weapon) building).setRawLogicalAnd((capacity > 1));
      }
      key = null;
      if (building instanceof Armor) {
        if (capacity > 0) {
          ((Armor) building).setCapacity(capacity + woodRequired);
          ((Armor) building).setContainTypes(canContain);
        }
        ((Armor) building).basePhyStats().setArmor(0);
        if (armordmg != 0)
          ((Armor) building).basePhyStats().setArmor(armordmg + (abilityCode() - 1));
        setWearLocation(building, misctype, 0);
      } else if (building instanceof Container) {
        if (capacity > 0) {
          ((Container) building).setCapacity(capacity + woodRequired);
          ((Container) building).setContainTypes(canContain);
        }
        if (misctype.equalsIgnoreCase("LID"))
          ((Container) building).setLidsNLocks(true, false, false, false);
        else if (misctype.equalsIgnoreCase("LOCK")) {
          ((Container) building).setLidsNLocks(true, false, true, false);
          ((Container) building).setKeyName(Double.toString(Math.random()));
          key = CMClass.getItem("GenKey");
          ((DoorKey) key).setKey(((Container) building).keyName());
          key.setName("a key");
          key.setDisplayText("a small key sits here");
          key.setDescription("looks like a key to " + building.name());
          key.recoverPhyStats();
          key.text();
        }
      }
      if (building instanceof Rideable) {
        setRideBasis((Rideable) building, misctype);
      }
      building.recoverPhyStats();
      building.text();
      building.recoverPhyStats();
    }

    messedUp = !proficiencyCheck(mob, 0, auto);

    if (bundling) {
      messedUp = false;
      duration = 1;
      verb = "bundling " + RawMaterial.CODES.NAME(building.material()).toLowerCase();
      startStr = "<S-NAME> start(s) " + verb + ".";
      displayText = "You are " + verb;
    }

    if (autoGenerate > 0) {
      if (key != null) commands.addElement(key);
      commands.addElement(building);
      return true;
    }

    CMMsg msg = CMClass.getMsg(mob, building, this, CMMsg.MSG_NOISYMOVEMENT, startStr);
    if (mob.location().okMessage(mob, msg)) {
      mob.location().send(mob, msg);
      building = (Item) msg.target();
      beneficialAffect(mob, mob, asLevel, duration);
      enhanceItem(mob, building, enhancedTypes);
    } else if (bundling) {
      messedUp = false;
      aborted = false;
      unInvoke();
    }
    return true;
  }
示例#20
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;
  }
示例#21
0
  public boolean invoke(MOB mob, Vector commands, Physical givenTarget, boolean auto, int asLevel) {
    int autoGenerate = 0;
    if ((auto) && (commands.size() > 0) && (commands.firstElement() instanceof Integer)) {
      autoGenerate = ((Integer) commands.firstElement()).intValue();
      commands.removeElementAt(0);
      givenTarget = null;
    }
    DVector enhancedTypes = enhancedTypes(mob, commands);
    randomRecipeFix(mob, addRecipes(mob, loadRecipes()), commands, autoGenerate);
    if (commands.size() == 0) {
      commonTell(
          mob,
          "Make what? Enter \"mleatherwork list\" for a list, \"mleatherwork refit <item>\" to resize, \"mleatherwork learn <item>\", \"mleatherwork scan\", or \"mleatherwork mend <item>\".");
      return false;
    }
    if ((!auto)
        && (commands.size() > 0)
        && (((String) commands.firstElement()).equalsIgnoreCase("bundle"))) {
      bundling = true;
      if (super.invoke(mob, commands, givenTarget, auto, asLevel))
        return super.bundle(mob, commands);
      return false;
    }
    List<List<String>> recipes = addRecipes(mob, loadRecipes());
    String str = (String) commands.elementAt(0);
    playSound = "scissor.wav";
    String startStr = null;
    bundling = false;
    int multiplier = 4;
    int duration = 4;
    if (str.equalsIgnoreCase("list")) {
      String mask = CMParms.combine(commands, 1);
      StringBuffer buf = new StringBuffer("");
      int toggler = 1;
      int toggleTop = 2;
      for (int r = 0; r < toggleTop; r++)
        buf.append(
            CMStrings.padRight("Item", 30)
                + " "
                + CMStrings.padRight("Lvl", 3)
                + " "
                + CMStrings.padRight("Amt", 3)
                + " ");
      buf.append("\n\r");
      for (int r = 0; r < recipes.size(); r++) {
        List<String> V = recipes.get(r);
        if (V.size() > 0) {
          String item = replacePercent((String) V.get(RCP_FINALNAME), "");
          int level = CMath.s_int((String) V.get(RCP_LEVEL));
          String wood = getComponentDescription(mob, V, RCP_WOOD);
          if (wood.length() > 5) {
            if (toggler > 1) buf.append("\n\r");
            toggler = toggleTop;
          }
          if ((level <= xlevel(mob))
              && ((mask == null)
                  || (mask.length() == 0)
                  || mask.equalsIgnoreCase("all")
                  || CMLib.english().containsString(item, mask))) {
            buf.append(
                CMStrings.padRight(item, 30)
                    + " "
                    + CMStrings.padRight("" + (level), 3)
                    + " "
                    + CMStrings.padRightPreserve("" + wood, 3)
                    + ((toggler != toggleTop) ? " " : "\n\r"));
            if (++toggler > toggleTop) toggler = 1;
          }
        }
      }
      if (toggler != 1) buf.append("\n\r");
      commonTell(mob, buf.toString());
      enhanceList(mob);
      return true;
    } else if ((commands.firstElement() instanceof String)
        && (((String) commands.firstElement())).equalsIgnoreCase("learn")) {
      return doLearnRecipe(mob, commands, givenTarget, auto, asLevel);
    } else if (str.equalsIgnoreCase("scan")) return publicScan(mob, commands);
    else if (str.equalsIgnoreCase("mend")) {
      building = null;
      activity = CraftingActivity.CRAFTING;
      messedUp = false;
      Vector newCommands = CMParms.parse(CMParms.combine(commands, 1));
      building =
          getTarget(mob, mob.location(), givenTarget, newCommands, Wearable.FILTER_UNWORNONLY);
      if (!canMend(mob, building, false)) return false;
      activity = CraftingActivity.MENDING;
      if (!super.invoke(mob, commands, givenTarget, auto, asLevel)) return false;
      startStr = "<S-NAME> start(s) mending " + building.name() + ".";
      displayText = "You are mending " + building.name();
      verb = "mending " + building.name();
    } else if (str.equalsIgnoreCase("refit")) {
      building = null;
      activity = CraftingActivity.CRAFTING;
      messedUp = false;
      Vector newCommands = CMParms.parse(CMParms.combine(commands, 1));
      building =
          getTarget(mob, mob.location(), givenTarget, newCommands, Wearable.FILTER_UNWORNONLY);
      if (building == null) return false;
      if ((building.material() & RawMaterial.MATERIAL_MASK) != RawMaterial.MATERIAL_LEATHER) {
        commonTell(mob, "That's not made of leather.  That can't be refitted.");
        return false;
      }
      if (!(building instanceof Armor)) {
        commonTell(mob, "You don't know how to refit that sort of thing.");
        return false;
      }
      if (building.phyStats().height() == 0) {
        commonTell(mob, building.name() + " is already the right size.");
        return false;
      }
      activity = CraftingActivity.REFITTING;
      if (!super.invoke(mob, commands, givenTarget, auto, asLevel)) return false;
      startStr = "<S-NAME> start(s) refitting " + building.name() + ".";
      displayText = "You are refitting " + building.name();
      verb = "refitting " + building.name();
    } else {
      building = null;
      activity = CraftingActivity.CRAFTING;
      messedUp = false;
      aborted = false;
      int amount = -1;
      if ((commands.size() > 1) && (CMath.isNumber((String) commands.lastElement()))) {
        amount = CMath.s_int((String) commands.lastElement());
        commands.removeElementAt(commands.size() - 1);
      }
      String recipeName = CMParms.combine(commands, 0);
      List<String> foundRecipe = null;
      List<List<String>> matches = matchingRecipeNames(recipes, recipeName, true);
      for (int r = 0; r < matches.size(); r++) {
        List<String> V = matches.get(r);
        if (V.size() > 0) {
          String name = (String) V.get(RCP_FINALNAME);
          int level = CMath.s_int((String) V.get(RCP_LEVEL));
          if ((level <= xlevel(mob)) && (name.toUpperCase().indexOf("BATTLEMOULDED") >= 0)) {
            multiplier = 9;
            foundRecipe = V;
            break;
          } else if ((level <= xlevel(mob)) && (name.toUpperCase().indexOf("LAMINAR") >= 0)) {
            multiplier = 8;
            foundRecipe = V;
            break;
          } else if ((level <= (xlevel(mob))) && (name.toUpperCase().indexOf("MASTERWORK") >= 0)) {
            multiplier = 7;
            foundRecipe = V;
            break;
          } else if ((level <= xlevel(mob)) && (name.toUpperCase().indexOf("REINFORCED") >= 0)) {
            multiplier = 6;
            foundRecipe = V;
            break;
          } else if ((level <= (xlevel(mob))) && (name.toUpperCase().indexOf("CUIRBOULI") >= 0)) {
            multiplier = 5;
            foundRecipe = V;
            break;
          } else if (level <= (xlevel(mob))) {
            multiplier = 4;
            foundRecipe = V;
            break;
          }
        }
      }
      if (foundRecipe == null) {
        commonTell(
            mob,
            "You don't know how to make a '"
                + recipeName
                + "'.  Try \"mleatherwork list\" for a list.");
        return false;
      }

      final String woodRequiredStr = (String) foundRecipe.get(RCP_WOOD);
      final List<Object> componentsFoundList =
          getAbilityComponents(
              mob,
              woodRequiredStr,
              "make " + CMLib.english().startWithAorAn(recipeName),
              autoGenerate);
      if (componentsFoundList == null) return false;
      int woodRequired = CMath.s_int(woodRequiredStr);
      woodRequired = adjustWoodRequired(woodRequired, mob);

      if (amount > woodRequired) woodRequired = amount;
      int[] pm = {RawMaterial.MATERIAL_LEATHER};
      int[] pm1 = {RawMaterial.MATERIAL_METAL, RawMaterial.MATERIAL_MITHRIL};
      String misctype = (String) foundRecipe.get(RCP_MISCTYPE);
      bundling = misctype.equalsIgnoreCase("BUNDLE");
      int[][] data =
          fetchFoundResourceData(
              mob,
              woodRequired,
              "leather",
              pm,
              (multiplier == 6) ? 1 : 0,
              (multiplier == 6) ? "metal" : null,
              (multiplier == 6) ? pm1 : null,
              bundling,
              autoGenerate,
              enhancedTypes);
      if (data == null) return false;
      fixDataForComponents(data, componentsFoundList);
      woodRequired = data[0][FOUND_AMT];
      if (!super.invoke(mob, commands, givenTarget, auto, asLevel)) return false;
      int lostValue =
          autoGenerate > 0
              ? 0
              : CMLib.materials()
                      .destroyResources(
                          mob.location(),
                          woodRequired,
                          data[0][FOUND_CODE],
                          data[1][FOUND_CODE],
                          null)
                  + CMLib.ableMapper().destroyAbilityComponents(componentsFoundList);
      building = CMClass.getItem((String) foundRecipe.get(RCP_CLASSTYPE));
      if (building == null) {
        commonTell(mob, "There's no such thing as a " + foundRecipe.get(RCP_CLASSTYPE) + "!!!");
        return false;
      }
      duration =
          getDuration(multiplier * CMath.s_int((String) foundRecipe.get(RCP_TICKS)), mob, 30, 4);
      String itemName =
          (replacePercent(
                  (String) foundRecipe.get(RCP_FINALNAME),
                  RawMaterial.CODES.NAME(data[0][FOUND_CODE])))
              .toLowerCase();
      if (bundling) itemName = "a " + woodRequired + "# " + itemName;
      else if (itemName.endsWith("s")) itemName = "some " + itemName;
      else itemName = CMLib.english().startWithAorAn(itemName);
      building.setName(itemName);
      startStr = "<S-NAME> start(s) making " + building.name() + ".";
      displayText = "You are making " + building.name();
      verb = "making " + building.name();
      building.setDisplayText(itemName + " lies here");
      building.setDescription(itemName + ". ");
      building
          .basePhyStats()
          .setWeight(
              (int) Math.round((double) woodRequired * this.getItemWeightMultiplier(bundling)));
      building.setBaseValue(CMath.s_int((String) foundRecipe.get(RCP_VALUE)) * multiplier);
      building.setMaterial(data[0][FOUND_CODE]);
      building.setSecretIdentity(getBrand(mob));
      int hardness = RawMaterial.CODES.HARDNESS(data[0][FOUND_CODE]) - 2;
      building
          .basePhyStats()
          .setLevel(CMath.s_int((String) foundRecipe.get(RCP_LEVEL)) + (2 * hardness));
      int capacity = CMath.s_int((String) foundRecipe.get(RCP_CAPACITY));
      long canContain = getContainerType((String) foundRecipe.get(RCP_CONTAINMASK));
      int armordmg = CMath.s_int((String) foundRecipe.get(RCP_ARMORDMG));
      if (armordmg != 0) armordmg = armordmg + (multiplier - 1);
      if (bundling) building.setBaseValue(lostValue);
      String spell =
          (foundRecipe.size() > RCP_SPELL) ? ((String) foundRecipe.get(RCP_SPELL)).trim() : "";
      addSpells(building, spell);
      if (building instanceof Weapon) {
        ((Weapon) building)
            .basePhyStats()
            .setAttackAdjustment(abilityCode() + (hardness * 5) + (abilityCode() - 1) - 1);
        ((Weapon) building).setWeaponClassification(Weapon.CLASS_FLAILED);
        setWeaponTypeClass((Weapon) building, misctype, Weapon.TYPE_SLASHING);
        building.basePhyStats().setDamage(armordmg + hardness);
        ((Weapon) building).setRawProperLocationBitmap(Wearable.WORN_WIELD | Wearable.WORN_HELD);
        ((Weapon) building).setRawLogicalAnd((capacity > 1));
      }
      if (building instanceof Armor) {
        if (capacity > 0) {
          ((Armor) building).setCapacity(capacity + woodRequired);
          ((Armor) building).setContainTypes(canContain);
        }
        ((Armor) building).basePhyStats().setArmor(0);
        if (armordmg != 0)
          ((Armor) building).basePhyStats().setArmor(armordmg + (abilityCode() - 1) + hardness);
        setWearLocation(building, misctype, 0);
      }
      if (building instanceof Drink) {
        if (CMLib.flags().isGettable(building)) {
          ((Drink) building).setLiquidRemaining(0);
          ((Drink) building).setLiquidHeld(capacity * 50);
          ((Drink) building).setThirstQuenched(250);
          if ((capacity * 50) < 250) ((Drink) building).setThirstQuenched(capacity * 50);
        }
      }
      building.recoverPhyStats();
      building.text();
      building.recoverPhyStats();
    }

    messedUp = !proficiencyCheck(mob, 0, auto);

    if (bundling) {
      messedUp = false;
      duration = 1;
      verb = "bundling " + RawMaterial.CODES.NAME(building.material()).toLowerCase();
      startStr = "<S-NAME> start(s) " + verb + ".";
      displayText = "You are " + verb;
    }

    if (autoGenerate > 0) {
      commands.addElement(building);
      return true;
    }

    CMMsg msg = CMClass.getMsg(mob, building, this, CMMsg.MSG_NOISYMOVEMENT, startStr);
    if (mob.location().okMessage(mob, msg)) {
      mob.location().send(mob, msg);
      building = (Item) msg.target();
      beneficialAffect(mob, mob, asLevel, duration);
      enhanceItem(mob, building, enhancedTypes);
    } else if (bundling) {
      messedUp = false;
      aborted = false;
      unInvoke();
    }
    return true;
  }
示例#22
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();
  }