Esempio n. 1
0
 @Override
 public boolean mayICraft(final Item I) {
   if (I == null) return false;
   if (!super.mayBeCrafted(I)) return false;
   if (((I.material() & RawMaterial.MATERIAL_MASK) != RawMaterial.MATERIAL_METAL)
       && ((I.material() & RawMaterial.MATERIAL_MASK) != RawMaterial.MATERIAL_MITHRIL))
     return false;
   if (CMLib.flags().isDeadlyOrMaliciousEffect(I)) return false;
   if (isANativeItem(I.Name()) && (!(I instanceof Armor)) && (!(I instanceof Weapon))) return true;
   if (I instanceof Rideable) {
     final Rideable R = (Rideable) I;
     final int rideType = R.rideBasis();
     switch (rideType) {
       case Rideable.RIDEABLE_LADDER:
       case Rideable.RIDEABLE_SLEEP:
       case Rideable.RIDEABLE_SIT:
       case Rideable.RIDEABLE_TABLE:
         return true;
       default:
         return false;
     }
   }
   if (I instanceof DoorKey) return true;
   if (I instanceof Shield) return false;
   if (I instanceof Weapon) return false;
   if (I instanceof Light) return true;
   if (I instanceof Armor) return false;
   if (I instanceof Container) return true;
   if ((I instanceof Drink) && (!(I instanceof Potion))) return true;
   if (I instanceof FalseLimb) return true;
   if (I.rawProperLocationBitmap() == Wearable.WORN_HELD) return true;
   return (isANativeItem(I.Name()));
 }
Esempio n. 2
0
  @Override
  public boolean tick(Tickable ticking, int tickID) {
    super.tick(ticking, tickID);
    if ((canAct(ticking, tickID)) && (ticking instanceof MOB)) {
      if (DoneEquipping) return true;

      final MOB mob = (MOB) ticking;
      final Room thisRoom = mob.location();
      if (thisRoom.numItems() == 0) return true;

      DoneEquipping = true;
      final Vector<Item> stuffIHad = new Vector<Item>();
      for (int i = 0; i < mob.numItems(); i++) stuffIHad.addElement(mob.getItem(i));
      mob.enqueCommand(new XVector<String>("GET", "ALL"), MUDCmdProcessor.METAFLAG_FORCED, 0);
      Item I = null;
      final Vector<Item> dropThisStuff = new Vector<Item>();
      for (int i = 0; i < mob.numItems(); i++) {
        I = mob.getItem(i);
        if ((I != null) && (!stuffIHad.contains(I))) {
          if (I instanceof DeadBody) dropThisStuff.addElement(I);
          else if ((I.container() != null) && (I.container() instanceof DeadBody))
            I.setContainer(null);
        }
      }
      for (int d = 0; d < dropThisStuff.size(); d++)
        mob.enqueCommand(
            new XVector<String>("DROP", "$" + dropThisStuff.elementAt(d).Name() + "$"),
            MUDCmdProcessor.METAFLAG_FORCED,
            0);
      mob.enqueCommand(new XVector<String>("WEAR", "ALL"), MUDCmdProcessor.METAFLAG_FORCED, 0);
    }
    return true;
  }
Esempio n. 3
0
 public static InventoryList fetchInventory(MOB seer, MOB mob) {
   final InventoryList lst = new InventoryList();
   Vector<Coins> coinsV = null;
   int insertAt = -1;
   CMLib.beanCounter().getTotalAbsoluteNativeValue(mob);
   for (final Enumeration<Item> i = mob.items(); i.hasMoreElements(); ) {
     final Item thisItem = i.nextElement();
     if (thisItem == null) continue;
     if ((thisItem.container() == null) && (thisItem.amWearingAt(Wearable.IN_INVENTORY))) {
       if (CMLib.flags().canBeSeenBy(thisItem, seer)) lst.foundAndSeen = true;
       else lst.foundButUnseen = true;
       if ((!(thisItem instanceof Coins)) || (((Coins) thisItem).getDenomination() == 0.0))
         lst.viewItems.add(thisItem);
       else {
         coinsV = lst.moneyItems.get(((Coins) thisItem).getCurrency());
         if (coinsV == null) {
           coinsV = new Vector<Coins>();
           lst.moneyItems.put(((Coins) thisItem).getCurrency(), coinsV);
         }
         for (insertAt = 0; insertAt < coinsV.size(); insertAt++)
           if (coinsV.get(insertAt).getDenomination() > ((Coins) thisItem).getDenomination())
             break;
         if (insertAt >= coinsV.size()) coinsV.add((Coins) thisItem);
         else coinsV.insertElementAt((Coins) thisItem, insertAt);
       }
     }
   }
   return lst;
 }
Esempio n. 4
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>();
 }
Esempio n. 5
0
  @Override
  public boolean invoke(
      MOB mob, List<String> commands, Physical givenTarget, boolean auto, int asLevel) {
    if (commands.size() < 1) {
      mob.tell(
          L(
              "You must specify an item to fence, and possibly a ShopKeeper (unless it is implied)."));
      return false;
    }

    commands.add(0, "SELL"); // will be instantly deleted by parseshopkeeper
    final Environmental shopkeeper =
        CMLib.english().parseShopkeeper(mob, commands, L("Fence what to whom?"));
    if (shopkeeper == null) return false;
    if (commands.size() == 0) {
      mob.tell(L("Fence what?"));
      return false;
    }

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

    final boolean success = proficiencyCheck(mob, 0, auto);
    if (success) {
      final CMMsg msg =
          CMClass.getMsg(
              mob,
              shopkeeper,
              this,
              CMMsg.MSG_SPEAK,
              auto ? "" : L("<S-NAME> fence(s) stolen loot to <T-NAMESELF>."));
      if (mob.location().okMessage(mob, msg)) {
        mob.location().send(mob, msg);
        invoker = mob;
        addBackMap.clear();
        mob.addEffect(this);
        mob.recoverCharStats();
        commands.add(0, CMStrings.capitalizeAndLower("SELL"));
        mob.doCommand(commands, MUDCmdProcessor.METAFLAG_FORCED);
        commands.add(shopkeeper.name());
        mob.delEffect(this);
        for (Item I : addBackMap.keySet()) {
          if (mob.isMine(I)) {
            I.addEffect(addBackMap.get(I));
          }
        }
        addBackMap.clear();
        mob.recoverCharStats();
      }
    } else
      beneficialWordsFizzle(
          mob,
          shopkeeper,
          L(
              "<S-NAME> attempt(s) to fence stolen loot to <T-NAMESELF>, but make(s) <T-HIM-HER> too nervous."));

    // return whether it worked
    return success;
  }
Esempio n. 6
0
 @Override
 public Trap setTrap(MOB mob, Physical P, int trapBonus, int qualifyingClassLevel, boolean perm) {
   if (P == null) return null;
   if (mob != null) {
     final Item I = findMostOfMaterial(mob.location(), RawMaterial.MATERIAL_METAL);
     if (I != null) super.destroyResources(mob.location(), I.material(), 10);
   }
   return super.setTrap(mob, P, trapBonus, qualifyingClassLevel, perm);
 }
Esempio n. 7
0
 public static boolean isPlant(Item I) {
   if ((I != null) && (I.rawSecretIdentity().length() > 0)) {
     for (final Enumeration<Ability> a = I.effects(); a.hasMoreElements(); ) {
       final Ability A = a.nextElement();
       if ((A != null) && (A.invoker() != null) && (A instanceof Chant_SummonPlants)) return true;
     }
   }
   return false;
 }
Esempio n. 8
0
  @Override
  public boolean invoke(MOB mob, Vector commands, Physical givenTarget, boolean auto, int asLevel) {
    Item target = null;
    if ((commands.size() == 0) && (!auto) && (givenTarget == null))
      target = Prayer_Sacrifice.getBody(mob.location());
    if (target == null)
      target = getTarget(mob, mob.location(), givenTarget, commands, Wearable.FILTER_UNWORNONLY);
    if (target == null) return false;

    if ((!(target instanceof DeadBody))
        || (target.rawSecretIdentity().toUpperCase().indexOf("FAKE") >= 0)) {
      mob.tell(L("You may only desecrate the dead."));
      return false;
    }
    if ((((DeadBody) target).isPlayerCorpse())
        && (!((DeadBody) target).getMobName().equals(mob.Name()))
        && (((DeadBody) target).hasContent())) {
      mob.tell(L("You are not allowed to desecrate a players corpse."));
      return false;
    }

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

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

    if (success) {
      final CMMsg msg =
          CMClass.getMsg(
              mob,
              target,
              this,
              verbalCastCode(mob, target, auto),
              auto
                  ? L("<T-NAME> feel(s) desecrated!")
                  : L("^S<S-NAME> desecrate(s) <T-NAMESELF> before @x1.^?", hisHerDiety(mob)));
      if (mob.location().okMessage(mob, msg)) {
        mob.location().send(mob, msg);
        if (CMLib.flags().isEvil(mob)) {
          double exp = 5.0;
          final int levelLimit = CMProps.getIntVar(CMProps.Int.EXPRATE);
          final int levelDiff = (mob.phyStats().level()) - target.phyStats().level();
          if (levelDiff > levelLimit) exp = 0.0;
          if (exp > 0.0)
            CMLib.leveler()
                .postExperience(
                    mob, null, null, (int) Math.round(exp) + super.getXPCOSTLevel(mob), false);
        }
        target.destroy();
        mob.location().recoverRoomStats();
      }
    } else
      beneficialWordsFizzle(
          mob, target, L("<S-NAME> attempt(s) to desecrate <T-NAMESELF>, but fail(s)."));

    // return whether it worked
    return success;
  }
Esempio n. 9
0
  @Override
  public boolean invoke(MOB mob, Vector commands, Physical givenTarget, boolean auto, int asLevel) {
    if (!super.invoke(mob, commands, givenTarget, auto, asLevel)) return false;

    final boolean success = proficiencyCheck(mob, 0, auto);
    final String str =
        auto
            ? L("The unholy word is spoken.")
            : L("^S<S-NAME> speak(s) the unholy word@x1 to <T-NAMESELF>.^?", ofDiety(mob));

    final Room room = mob.location();
    if (room != null)
      for (int i = 0; i < room.numInhabitants(); i++) {
        final MOB target = room.fetchInhabitant(i);
        if (target == null) break;
        int affectType = CMMsg.MSG_CAST_VERBAL_SPELL;
        if (auto) affectType = affectType | CMMsg.MASK_ALWAYS;
        if (CMLib.flags().isGood(target)) affectType = affectType | CMMsg.MASK_MALICIOUS;

        if (success) {
          final CMMsg msg = CMClass.getMsg(mob, target, this, affectType, str);
          if (room.okMessage(mob, msg)) {
            room.send(mob, msg);
            if (msg.value() <= 0) {
              if (CMLib.flags().canBeHeardSpeakingBy(mob, target)) {
                final Item I = Prayer_Curse.getSomething(mob, true);
                if (I != null) {
                  Prayer_Curse.endLowerBlessings(I, CMLib.ableMapper().lowestQualifyingLevel(ID()));
                  I.recoverPhyStats();
                }
                Prayer_Curse.endLowerBlessings(
                    target, CMLib.ableMapper().lowestQualifyingLevel(ID()));
                beneficialAffect(mob, target, asLevel, 0);
                target.recoverPhyStats();
              } else if (CMath.bset(affectType, CMMsg.MASK_MALICIOUS))
                maliciousFizzle(mob, target, L("<T-NAME> did not hear the unholy word!"));
              else beneficialWordsFizzle(mob, target, L("<T-NAME> did not hear the unholy word!"));
            }
          }
        } else {
          if (CMath.bset(affectType, CMMsg.MASK_MALICIOUS))
            maliciousFizzle(
                mob,
                target,
                L("<S-NAME> attempt(s) to speak the unholy word to <T-NAMESELF>, but flub(s) it."));
          else
            beneficialWordsFizzle(
                mob,
                target,
                L("<S-NAME> attempt(s) to speak the unholy word to <T-NAMESELF>, but flub(s) it."));
          return false;
        }
      }

    // return whether it worked
    return success;
  }
Esempio n. 10
0
 @Override
 public void affectCharState(MOB affected, CharState affectableState) {
   super.affectCharState(affected, affectableState);
   if (affected.location() != null)
     for (int i = 0; i < affected.location().numItems(); i++) {
       final Item I = affected.location().getItem(i);
       if ((I != null) && (I.ID().equals("DruidicMonument")))
         affectableState.setMana(affectableState.getMana() + (affectableState.getMana() / 2));
     }
 }
Esempio n. 11
0
 @Override
 public List<Item> getTrapComponents() {
   final Vector V = new Vector();
   final Item I = CMLib.materials().makeItemResource(RawMaterial.RESOURCE_POISON);
   Ability A = CMClass.getAbility(text());
   if (A == null) A = CMClass.getAbility("Poison");
   I.addNonUninvokableEffect(A);
   V.addElement(I);
   return V;
 }
Esempio n. 12
0
 @Override
 public void executeMsg(final Environmental myHost, final CMMsg msg) {
   super.executeMsg(myHost, msg);
   if (msg.amITarget(this) && (msg.targetMinor() == CMMsg.TYP_DRINK)) {
     final MOB mob = msg.source();
     final boolean thirsty = mob.curState().getThirst() <= 0;
     final boolean full =
         !mob.curState().adjThirst(thirstQuenched(), mob.maxState().maxThirst(mob.baseWeight()));
     if (thirsty) mob.tell(L("You are no longer thirsty."));
     else if (full) mob.tell(L("You have drunk all you can."));
   } else if ((msg.tool() == this)
       && (msg.targetMinor() == CMMsg.TYP_FILL)
       && (msg.target() instanceof Container)
       && (((Container) msg.target()).capacity() > 0)) {
     final Container container = (Container) msg.target();
     final Item I = CMClass.getItem("GenLiquidResource");
     I.setName(L("some milk"));
     I.setDisplayText(L("some milk has been left here."));
     I.setDescription(L("It looks like milk"));
     I.setMaterial(RawMaterial.RESOURCE_MILK);
     I.setBaseValue(RawMaterial.CODES.VALUE(RawMaterial.RESOURCE_MILK));
     I.basePhyStats().setWeight(1);
     CMLib.materials().addEffectsToResource(I);
     I.recoverPhyStats();
     I.setContainer(container);
     if (container.owner() != null)
       if (container.owner() instanceof MOB) ((MOB) container.owner()).addItem(I);
       else if (container.owner() instanceof Room)
         ((Room) container.owner()).addItem(I, ItemPossessor.Expire.Resource);
   }
 }
Esempio n. 13
0
 public String correctItem(MOB mob) {
   for (int i = 0; i < mob.numItems(); i++) {
     final Item I = mob.getItem(i);
     if ((I != null)
         && (CMLib.flags().canBeSeenBy(I, mob))
         && (I.amWearingAt(Wearable.IN_INVENTORY))
         && (!((((I instanceof Armor) && (I.basePhyStats().armor() > 1))
             || ((I instanceof Weapon) && (I.basePhyStats().damage() > 1)))))) return I.Name();
   }
   return null;
 }
Esempio n. 14
0
 @Override
 public Trap setTrap(MOB mob, Physical P, int trapBonus, int qualifyingClassLevel, boolean perm) {
   if (P == null) return null;
   final Item I = getPoison(mob);
   if (I != null) {
     final List<Ability> V = returnOffensiveAffects(I);
     if (V.size() > 0) setMiscText(V.get(0).ID());
     I.destroy();
   }
   return super.setTrap(mob, P, trapBonus, qualifyingClassLevel, perm);
 }
Esempio n. 15
0
  @Override
  public boolean invoke(
      MOB mob, List<String> commands, Physical givenTarget, boolean auto, int asLevel) {
    if (!mob.isInCombat()) {
      mob.tell(L("You must be in combat to do this!"));
      return false;
    }
    final MOB victim = super.getTarget(mob, commands, givenTarget);
    if (victim == null) return false;
    if (((victim == mob.getVictim()) && (mob.rangeToTarget() > 0))
        || ((victim.getVictim() == mob) && (victim.rangeToTarget() > 0))) {
      mob.tell(L("You are too far away to disarm!"));
      return false;
    }
    if (mob.fetchWieldedItem() == null) {
      mob.tell(L("You need a weapon to disarm someone!"));
      return false;
    }
    Item hisWeapon = victim.fetchWieldedItem();
    if (hisWeapon == null) hisWeapon = victim.fetchHeldItem();
    if ((hisWeapon == null)
        || (!(hisWeapon instanceof Weapon))
        || ((((Weapon) hisWeapon).weaponClassification() == Weapon.CLASS_NATURAL))) {
      mob.tell(L("@x1 is not wielding a weapon!", victim.charStats().HeShe()));
      return false;
    }

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

    int levelDiff =
        victim.phyStats().level() - (mob.phyStats().level() + (2 * getXLEVELLevel(mob)));
    if (levelDiff > 0) levelDiff = levelDiff * 5;
    else levelDiff = 0;
    final boolean hit = (auto) || CMLib.combat().rollToHit(mob, victim);
    final boolean success = proficiencyCheck(mob, -levelDiff, auto) && (hit);
    if ((success)
        && ((hisWeapon.fitsOn(Wearable.WORN_WIELD))
            || hisWeapon.fitsOn(Wearable.WORN_WIELD | Wearable.WORN_HELD))) {
      if (mob.location().show(mob, victim, this, CMMsg.MSG_NOISYMOVEMENT, null)) {
        final CMMsg msg = CMClass.getMsg(victim, hisWeapon, null, CMMsg.MSG_DROP, null);
        if (mob.location().okMessage(mob, msg)) {
          mob.location().send(victim, msg);
          mob.location()
              .show(
                  mob,
                  victim,
                  CMMsg.MSG_NOISYMOVEMENT,
                  auto ? L("<T-NAME> is disarmed!") : L("<S-NAME> disarm(s) <T-NAMESELF>!"));
        }
      }
    } else
      maliciousFizzle(mob, victim, L("<S-NAME> attempt(s) to disarm <T-NAMESELF> and fail(s)!"));
    return success;
  }
Esempio n. 16
0
 @Override
 public boolean canSetTrapOn(MOB mob, Physical P) {
   if (!super.canSetTrapOn(mob, P)) return false;
   if (mob != null) {
     final Item I = findMostOfMaterial(mob.location(), RawMaterial.MATERIAL_METAL);
     if ((I == null) || (super.findNumberOfResource(mob.location(), I.material()) < 10)) {
       mob.tell(L("You'll need to set down at least 10 pounds of metal first."));
       return false;
     }
   }
   return true;
 }
Esempio n. 17
0
 public Item targetItem(MOB target) {
   final Vector<Item> V = new Vector<Item>();
   for (int i = 0; i < target.numItems(); i++) {
     final Item I2 = target.getItem(i);
     if ((!I2.amWearingAt(Wearable.IN_INVENTORY))
         && (((I2 instanceof Weapon) && (I2.basePhyStats().damage() > 1))
             || ((I2 instanceof Armor) && (I2.basePhyStats().armor() > 1)))
         && (I2.container() == null)) V.addElement(I2);
   }
   if (V.size() > 0) return V.elementAt(CMLib.dice().roll(1, V.size(), -1));
   return null;
 }
Esempio n. 18
0
 @Override
 public boolean mayICraft(final Item I) {
   if (I == null) return false;
   if (!super.mayBeCrafted(I)) return false;
   if ((I.material() & RawMaterial.MATERIAL_MASK) != RawMaterial.MATERIAL_WOODEN) return false;
   if (CMLib.flags().isDeadlyOrMaliciousEffect(I)) return false;
   if (!(I instanceof Container)) return false;
   final Container C = (Container) I;
   if ((C.containTypes() == Container.CONTAIN_CAGED)
       || (C.containTypes() == (Container.CONTAIN_BODIES | Container.CONTAIN_CAGED))) return true;
   if (isANativeItem(I.Name())) return true;
   return false;
 }
Esempio n. 19
0
  @Override
  public boolean invoke(MOB mob, Vector commands, Physical givenTarget, boolean auto, int asLevel) {
    final MOB target = getTarget(mob, commands, givenTarget);
    if (target == null) return false;
    Item myPlant = Druid_MyPlants.myPlant(mob.location(), mob, 0);
    if (myPlant == null) {
      if (auto) myPlant = new Chant_SummonPlants().buildPlant(mob, mob.location());
      else {
        mob.tell(L("There doesn't appear to be any of your plants here to choke with."));
        return false;
      }
    }

    if (target.getWearPositions(Wearable.WORN_NECK) == 0) {
      if (!auto) mob.tell(L("Ummm, @x1 doesn't HAVE a neck...", target.name(mob)));
      return false;
    }

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

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

      final CMMsg msg =
          CMClass.getMsg(
              mob,
              target,
              this,
              verbalCastCode(mob, target, auto),
              auto
                  ? ""
                  : L("^S<S-NAME> chant(s) at <T-NAME> while pointing at @x1!^?", myPlant.name()));
      if (mob.location().okMessage(mob, msg)) {
        mob.location().send(mob, msg);
        target.moveItemTo(myPlant);
        myPlant.setRawWornCode(Wearable.WORN_NECK);
        mob.location()
            .show(
                target,
                null,
                CMMsg.MSG_OK_VISUAL,
                L("@x1 jumps up and wraps itself around <S-YOUPOSS> neck!", myPlant.name()));
        beneficialAffect(mob, myPlant, asLevel, 5);
      }
    } else
      return maliciousFizzle(
          mob, target, L("<S-NAME> chant(s) at <T-NAME>, but the magic fizzles."));

    // return whether it worked
    return success;
  }
Esempio n. 20
0
 @Override
 public boolean tick(Tickable ticking, int tickID) {
   Item I = null;
   if (affected instanceof Item) I = (Item) affected;
   if ((canBeUninvoked())
       && (I != null)
       && (I.owner() instanceof MOB)
       && (I.amWearingAt(Wearable.WORN_NECK))) {
     final MOB mob = (MOB) I.owner();
     if ((!mob.amDead()) && (mob.isMonster()) && (CMLib.flags().isInTheGame(mob, false)))
       CMLib.commands().postRemove(mob, I, false);
   }
   return super.tick(ticking, tickID);
 }
Esempio n. 21
0
 private Item getItem(MOB mobTarget) {
   final Vector goodPossibilities = new Vector();
   final Vector possibilities = new Vector();
   for (int i = 0; i < mobTarget.numItems(); i++) {
     final Item item = mobTarget.getItem(i);
     if (item != null) {
       if (item.amWearingAt(Wearable.IN_INVENTORY)) possibilities.addElement(item);
       else goodPossibilities.addElement(item);
     }
   }
   if (goodPossibilities.size() > 0)
     return (Item) goodPossibilities.elementAt(CMLib.dice().roll(1, goodPossibilities.size(), -1));
   else if (possibilities.size() > 0)
     return (Item) possibilities.elementAt(CMLib.dice().roll(1, possibilities.size(), -1));
   return null;
 }
Esempio n. 22
0
  @Override
  public boolean invoke(MOB mob, Vector commands, Physical givenTarget, boolean auto, int asLevel) {
    final Item I =
        getTarget(mob, mob.location(), givenTarget, commands, Wearable.FILTER_UNWORNONLY);
    if (I == null) return false;
    if (((I.material() & RawMaterial.MATERIAL_MASK) != RawMaterial.MATERIAL_VEGETATION)
        && ((I.material() & RawMaterial.MATERIAL_MASK) != RawMaterial.MATERIAL_WOODEN)) {
      mob.tell(L("Your plant knowledge can tell you nothing about @x1.", I.name(mob)));
      return false;
    }

    if (!super.invoke(mob, commands, givenTarget, auto, asLevel)) return false;
    final boolean success = proficiencyCheck(mob, 0, auto);

    if (!success) mob.tell(L("Your plant senses fail you."));
    else {
      final CMMsg msg =
          CMClass.getMsg(mob, I, null, CMMsg.MSG_DELICATE_SMALL_HANDS_ACT | CMMsg.MASK_MAGIC, null);
      if (mob.location().okMessage(mob, msg)) {
        mob.location().send(mob, msg);
        final StringBuffer str = new StringBuffer("");
        str.append(
            L(
                "@x1 is a kind of @x2.  ",
                I.name(mob),
                RawMaterial.CODES.NAME(I.material()).toLowerCase()));
        if (isPlant(I)) str.append(L("It was summoned by @x1.", I.rawSecretIdentity()));
        else str.append(L("It is either processed by hand, or grown wild."));
        mob.tell(str.toString());
      }
    }
    return success;
  }
Esempio n. 23
0
  @Override
  public boolean invoke(MOB mob, Vector commands, Physical givenTarget, boolean auto, int asLevel) {
    final Item target = getTarget(mob, mob.location(), givenTarget, commands, Wearable.FILTER_ANY);
    if (target == null) return false;

    final Room room = CMLib.map().roomLocation(mob);
    if ((room == null) || (room.getArea() == null)) return false;
    final String roomID = CMLib.map().getExtendedRoomID(room);
    if ((CMath.bset(room.getArea().flags(), Area.FLAG_INSTANCE_CHILD)) || (roomID.length() == 0)) {
      mob.tell(L("The magic in this place will not permit it to become a refuge."));
      return false;
    }

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

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

    if (success) {
      final CMMsg msg =
          CMClass.getMsg(
              mob,
              target,
              this,
              verbalCastCode(mob, target, auto),
              auto ? "" : L("^S<S-NAME> point(s) at <T-NAMESELF> and @x1.^?", prayWord(mob)));
      if (mob.location().okMessage(mob, msg)) {
        mob.location().send(mob, msg);
        mob.location().show(mob, target, CMMsg.MSG_OK_VISUAL, L("<T-NAME> glows slightly!"));
        mob.tell(
            L(
                "@x1 will now await someone to 'SAYTO \"@x1\" Refuge' to it before teleporting you back here.",
                target.name(mob)));
        final Ability A = beneficialAffect(mob, target, asLevel, Ability.TICKS_ALMOST_FOREVER);
        if (A != null) A.setMiscText(roomID);
        target.recoverPhyStats();
        mob.recoverPhyStats();
      }

    } else
      beneficialVisualFizzle(
          mob, target, L("<S-NAME> point(s) at <T-NAMESELF>, but fail(s) to properly pray."));

    // return whether it worked
    return success;
  }
Esempio n. 24
0
 @Override
 public void unInvoke() {
   if ((affected != null)
       && (affected instanceof Item)
       && (((Item) affected).owner() != null)
       && (((Item) affected).owner() instanceof Room))
     ((Room) ((Item) affected).owner())
         .showHappens(CMMsg.MSG_OK_ACTION, L("@x1 stops moving.", affected.name()));
   super.unInvoke();
 }
Esempio n. 25
0
 public static void colorForSale(Room R, boolean rental, boolean reset) {
   synchronized (("SYNC" + R.roomID()).intern()) {
     R = CMLib.map().getRoom(R);
     final String theStr = rental ? RENTSTR : SALESTR;
     final String otherStr = rental ? SALESTR : RENTSTR;
     int x = R.description().indexOf(otherStr);
     while (x >= 0) {
       R.setDescription(R.description().substring(0, x));
       CMLib.database().DBUpdateRoom(R);
       x = R.description().indexOf(otherStr);
     }
     final String oldDescription = R.description();
     x = R.description().indexOf(theStr.trim());
     if ((x < 0)
         || (reset
             && (!R.displayText()
                 .equals(CMath.bset(R.domainType(), Room.INDOORS) ? INDOORSTR : OUTDOORSTR)))) {
       if (reset) {
         R.setDescription("");
         R.setDisplayText(CMath.bset(R.domainType(), Room.INDOORS) ? INDOORSTR : OUTDOORSTR);
         x = -1;
       }
       if (x < 0) R.setDescription(R.description() + theStr);
       else if (!reset) R.setDescription(R.description().substring(0, x + theStr.trim().length()));
       if (!R.description().equals(oldDescription)) CMLib.database().DBUpdateRoom(R);
     } else {
       R.setDescription(R.description().substring(0, x + theStr.trim().length()));
       if (!R.description().equals(oldDescription)) CMLib.database().DBUpdateRoom(R);
     }
     Item I = R.findItem(null, "$id$");
     if ((I == null) || (!I.ID().equals("GenWallpaper"))) {
       I = CMClass.getItem("GenWallpaper");
       CMLib.flags().setReadable(I, true);
       I.setName(("id"));
       I.setReadableText(CMLib.lang().L("This room is " + CMLib.map().getExtendedRoomID(R)));
       I.setDescription(CMLib.lang().L("This room is @x1", CMLib.map().getExtendedRoomID(R)));
       R.addItem(I);
       CMLib.database().DBUpdateItems(R);
     }
   }
 }
Esempio n. 26
0
 public Item getPossibility(MOB mobTarget) {
   if (mobTarget != null) {
     final Vector goodPossibilities = new Vector();
     final Vector possibilities = new Vector();
     for (int i = 0; i < mobTarget.numItems(); i++) {
       final Item item = mobTarget.getItem(i);
       if ((item != null)
           && ((item.material() & RawMaterial.MATERIAL_MASK) == RawMaterial.MATERIAL_WOODEN)
           && (item.subjectToWearAndTear())) {
         if (item.amWearingAt(Wearable.IN_INVENTORY)) possibilities.addElement(item);
         else goodPossibilities.addElement(item);
       }
       if (goodPossibilities.size() > 0)
         return (Item)
             goodPossibilities.elementAt(CMLib.dice().roll(1, goodPossibilities.size(), -1));
       else if (possibilities.size() > 0)
         return (Item) possibilities.elementAt(CMLib.dice().roll(1, possibilities.size(), -1));
     }
   }
   return null;
 }
Esempio n. 27
0
 protected String getShowableMoney(InventoryList list) {
   final StringBuilder msg = new StringBuilder("");
   if (list.moneyItems.size() > 0) {
     msg.append(L("\n\r^HMoney:^N\n\r"));
     Item I = null;
     for (final Enumeration e = list.moneyItems.keys(); e.hasMoreElements(); ) {
       final String key = (String) e.nextElement();
       final Vector<Coins> V = list.moneyItems.get(key);
       double totalValue = 0.0;
       for (int v = 0; v < V.size(); v++) {
         I = V.get(v);
         if (I != null) {
           if (v > 0) msg.append(", ");
           if (I instanceof Coins) totalValue += ((Coins) I).getTotalValue();
           msg.append(I.name());
         }
       }
       msg.append(" ^N(" + CMLib.beanCounter().abbreviatedPrice(key, totalValue) + ")");
       if (e.hasMoreElements()) msg.append("\n\r");
     }
   }
   return msg.toString();
 }
Esempio n. 28
0
  @Override
  public boolean invoke(
      MOB mob, List<String> commands, Physical givenTarget, boolean auto, int asLevel) {
    final Item target = getTarget(mob, null, givenTarget, commands, Wearable.FILTER_UNWORNONLY);
    if (target == null) return false;
    if (!(target instanceof Armor)) {
      mob.tell(L("@x1 cannot be refitted.", target.name(mob)));
      return false;
    }

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

    final boolean success =
        proficiencyCheck(
            mob,
            (((mob.phyStats().level() + (2 * getXLEVELLevel(mob))) - target.phyStats().level())
                * 5),
            auto);

    if (success) {
      final CMMsg msg =
          CMClass.getMsg(
              mob,
              target,
              this,
              verbalCastCode(mob, target, auto),
              (auto ? "<T-NAME> begins to shimmer!" : "^S<S-NAME> incant(s) at <T-NAMESELF>!^?"));
      if (mob.location().okMessage(mob, msg)) {
        mob.location().send(mob, msg);

        if (target.phyStats().height() == 0)
          mob.tell(L("Nothing happens to @x1.", target.name(mob)));
        else {
          mob.location()
              .show(
                  mob,
                  target,
                  CMMsg.MSG_OK_VISUAL,
                  L("<T-NAME> begin(s) to magically resize itself!"));
          target.basePhyStats().setHeight(0);
        }
        target.recoverPhyStats();
        mob.location().recoverRoomStats();
      }

    } else
      beneficialWordsFizzle(
          mob, target, L("<S-NAME> incant(s) at <T-NAMESELF>, but nothing happens."));

    // return whether it worked
    return success;
  }
Esempio n. 29
0
  @Override
  public boolean invoke(MOB mob, Vector commands, Physical givenTarget, boolean auto, int asLevel) {
    final Item target = getTarget(mob, mob.location(), givenTarget, commands, Wearable.FILTER_ANY);
    if (target == null) return false;
    if (!(target instanceof Weapon)) {
      mob.tell(L("That's not a weapon!"));
      return false;
    }

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

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

    if (success) {
      final CMMsg msg = CMClass.getMsg(mob, target, this, verbalCastCode(mob, target, auto), null);
      if (mob.location().okMessage(mob, msg)) {
        mob.location().send(mob, msg);
        target.unWear();
        if (mob.isMine(target))
          mob.location()
              .show(mob, target, CMMsg.MSG_DROP, L("<T-NAME> flies out of <S-YOUPOSS> hands!"));
        else
          mob.location()
              .show(mob, target, CMMsg.MSG_OK_ACTION, L("<T-NAME> starts flying around!"));
        if (mob.location().isContent(target)) beneficialAffect(mob, target, asLevel, 0);
      }
    } else
      mob.location()
          .show(
              mob,
              target,
              CMMsg.MSG_OK_ACTION,
              L("<T-NAME> twitch(es) oddly, but does nothing more."));

    // return whether it worked
    return success;
  }
Esempio n. 30
0
  @Override
  public boolean invoke(MOB mob, Vector commands, Physical givenTarget, boolean auto, int asLevel) {
    final Item target = getTarget(mob, null, givenTarget, commands, Wearable.FILTER_ANY);
    if (target == null) return false;
    if (!target.subjectToWearAndTear()) {
      mob.tell(L("@x1 cannot be mended.", target.name(mob)));
      return false;
    }

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

    final boolean success =
        proficiencyCheck(
            mob,
            (((mob.phyStats().level() + (2 * getXLEVELLevel(mob))) - target.phyStats().level())
                * 5),
            auto);

    if (success) {
      final CMMsg msg =
          CMClass.getMsg(
              mob,
              target,
              this,
              verbalCastCode(mob, target, auto),
              (auto ? "<T-NAME> begins to shimmer!" : "^S<S-NAME> incant(s) at <T-NAMESELF>!^?"));
      if (mob.location().okMessage(mob, msg)) {
        mob.location().send(mob, msg);
        if (target.usesRemaining() >= 100) mob.tell(L("Nothing happens to @x1.", target.name(mob)));
        else {
          mob.location()
              .show(mob, target, CMMsg.MSG_OK_VISUAL, L("<T-NAME> begin(s) to glow and mend!"));
          target.setUsesRemaining(100);
        }
        target.recoverPhyStats();
        mob.location().recoverRoomStats();
      }

    } else
      beneficialWordsFizzle(
          mob, target, L("<S-NAME> incant(s) at <T-NAMESELF>, but nothing happens."));

    // return whether it worked
    return success;
  }