예제 #1
0
 public void makePuddle(Room R, int oldWeather, int newWeather) {
   for (int i = 0; i < R.numItems(); i++) {
     final Item I = R.getItem(i);
     if ((I instanceof Drink)
         && (!CMLib.flags().isGettable(I))
         && ((I.name().toLowerCase().indexOf("puddle") >= 0)
             || (I.name().toLowerCase().indexOf("snow") >= 0))) return;
   }
   final Item I = CMClass.getItem("GenLiquidResource");
   CMLib.flags().setGettable(I, false);
   ((Drink) I).setLiquidHeld(100);
   ((Drink) I).setLiquidRemaining(100);
   ((Drink) I).setLiquidType(RawMaterial.RESOURCE_FRESHWATER);
   I.setMaterial(RawMaterial.RESOURCE_FRESHWATER);
   I.basePhyStats().setDisposition(I.basePhyStats().disposition() | PhyStats.IS_UNSAVABLE);
   CMLib.materials().addEffectsToResource(I);
   I.recoverPhyStats();
   if (coldWetWeather(oldWeather)) {
     I.setName(L("some snow"));
     I.setDisplayText(L("some snow rests on the ground here."));
     I.setDescription(L("the snow is white and still quite cold!"));
   } else {
     I.setName(L("a puddle of water"));
     I.setDisplayText(L("a puddle of water has formed here."));
     I.setDescription(L("It looks drinkable."));
   }
   R.addItem(I, ItemPossessor.Expire.Monster_EQ);
   R.recoverRoomStats();
 }
예제 #2
0
 public Set<MOB> getDeadMOBsFrom(Environmental whoE) {
   if (whoE instanceof MOB) {
     final MOB mob = (MOB) whoE;
     final Room room = mob.location();
     if (room != null) return getEveryoneHere(mob, room);
   } else if (whoE instanceof Item) {
     final Item item = (Item) whoE;
     final Environmental E = item.owner();
     if (E != null) {
       final Room room = getTickersRoom(whoE);
       if (room != null) {
         if ((E instanceof MOB) && ((mask == null) || (CMLib.masking().maskCheck(mask, E, false))))
           return new XHashSet<MOB>((MOB) E);
         else if (E instanceof Room) return getEveryoneHere(null, (Room) E);
         room.recoverRoomStats();
       }
     }
   } else if (whoE instanceof Room) return getEveryoneHere(null, (Room) whoE);
   else if (whoE instanceof Area) {
     final Set<MOB> allMobs = new HashSet<MOB>();
     for (final Enumeration r = ((Area) whoE).getMetroMap(); r.hasMoreElements(); ) {
       final Room R = (Room) r.nextElement();
       allMobs.addAll(getEveryoneHere(null, R));
     }
   }
   return new HashSet<MOB>();
 }
예제 #3
0
  @Override
  public boolean invoke(
      MOB mob, List<String> commands, Physical givenTarget, boolean auto, int asLevel) {
    final MOB target = getTarget(mob, commands, givenTarget);
    if (target == null) return false;
    final Room targetRoom = target.location();
    if (targetRoom == null) return false;

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

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

    if (success) {
      beneficialAffect(mob, target, asLevel, 0);
      target.recoverPhyStats();
      targetRoom.recoverRoomStats();
    }
    // return whether it worked
    return success;
  }
예제 #4
0
  @Override
  public boolean invoke(MOB mob, Vector commands, Physical givenTarget, boolean auto, int asLevel) {
    final Vector areas = new Vector();
    if (commands.size() == 0) areas.addElement(mob.location().getArea());
    else if (((String) commands.lastElement()).equalsIgnoreCase("far")) {
      commands.removeElementAt(commands.size() - 1);
      for (final Enumeration e = CMLib.map().areas(); e.hasMoreElements(); )
        areas.addElement(e.nextElement());
    } else if (((String) commands.lastElement()).equalsIgnoreCase("near")) {
      commands.removeElementAt(commands.size() - 1);
      areas.addElement(mob.location().getArea());
    } else areas.addElement(mob.location().getArea());
    final MOB mobTarget = getTarget(mob, commands, givenTarget, true, false);
    Item target = null;
    if (mobTarget != null) {
      target = getItem(mobTarget);
      if (target == null)
        return maliciousFizzle(
            mob,
            mobTarget,
            L("<S-NAME> attempt(s) a scattering spell at <T-NAMESELF>, but nothing happens."));
    }

    List<Item> targets = new Vector();
    if (givenTarget instanceof Item) targets.add((Item) givenTarget);
    else if (target != null) targets.add(target);
    else {
      targets = CMLib.english().fetchItemList(mob, mob, null, commands, Wearable.FILTER_ANY, true);
      if (targets.size() == 0) mob.tell(L("You don't seem to be carrying that."));
    }

    if (targets.size() == 0) return false;

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

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

    if (success) {
      String str = null;
      if (mobTarget == null)
        str =
            auto
                ? L("<S-NAME> <S-IS-ARE> enveloped in a scattering field!")
                : L("^S<S-NAME> utter(s) a scattering spell!^?");
      else
        str =
            auto
                ? L("<T-NAME> <T-IS-ARE> enveloped in a scattering field!")
                : L("^S<S-NAME> utter(s) a scattering spell, causing <T-NAMESELF> to resonate.^?");
      CMMsg msg = CMClass.getMsg(mob, mobTarget, this, verbalCastCode(mob, target, auto), str);
      if (mob.location().okMessage(mob, msg)) {
        mob.location().send(mob, msg);
        if (msg.value() <= 0) {
          for (int i = 0; i < targets.size(); i++) {
            target = targets.get(i);
            msg = CMClass.getMsg(mob, target, this, verbalCastCode(mob, target, auto), null);
            Room room = null;
            for (int x = 0; (x < 10) && (room == null); x++)
              room =
                  ((Area) areas.elementAt(CMLib.dice().roll(1, areas.size(), -1)))
                      .getRandomMetroRoom();
            if (mob.location().okMessage(mob, msg) && (room != null)) {
              mob.location().send(mob, msg);
              if (msg.value() <= 0) {
                target.unWear();
                if (target.owner() instanceof MOB) {
                  final MOB owner = (MOB) target.owner();
                  mob.location()
                      .show(
                          owner,
                          room,
                          target,
                          CMMsg.MASK_ALWAYS | CMMsg.MSG_THROW,
                          L("<O-NAME> vanishes from <S-YOUPOSS> inventory!"));
                  room.showOthers(
                      owner,
                      room,
                      target,
                      CMMsg.MASK_ALWAYS | CMMsg.MSG_THROW,
                      L("<O-NAME> appears from out of nowhere!"));
                } else {
                  mob.location()
                      .show(
                          mob,
                          room,
                          target,
                          CMMsg.MASK_ALWAYS | CMMsg.MSG_THROW,
                          L("<O-NAME> vanishes!"));
                  room.showOthers(
                      mob,
                      room,
                      target,
                      CMMsg.MASK_ALWAYS | CMMsg.MSG_THROW,
                      L("<O-NAME> appears from out of nowhere!"));
                }
                if (!room.isContent(target))
                  room.moveItemTo(
                      target, ItemPossessor.Expire.Player_Drop, ItemPossessor.Move.Followers);
                room.recoverRoomStats();
              }
            }
          }
        }
      }
    } else
      return maliciousFizzle(
          mob, mobTarget, L("<S-NAME> attempt(s) a scattering spell, but nothing happens."));

    // return whether it worked
    return success;
  }