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; }
@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; }
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>(); }
public boolean armorCheck(MOB mob, Item I, int allowedArmorLevel) { if ((((I instanceof Armor) || (I instanceof Shield))) && (I.rawProperLocationBitmap() & CharClass.ARMOR_WEARMASK) > 0) { boolean ok = true; switch (I.material() & RawMaterial.MATERIAL_MASK) { case RawMaterial.MATERIAL_LEATHER: if ((allowedArmorLevel == CharClass.ARMOR_CLOTH) || (allowedArmorLevel == CharClass.ARMOR_VEGAN) || (allowedArmorLevel == CharClass.ARMOR_OREONLY) || (allowedArmorLevel == CharClass.ARMOR_METALONLY)) ok = false; break; case RawMaterial.MATERIAL_METAL: case RawMaterial.MATERIAL_MITHRIL: if ((allowedArmorLevel == CharClass.ARMOR_CLOTH) || (allowedArmorLevel == CharClass.ARMOR_LEATHER) || (allowedArmorLevel == CharClass.ARMOR_NONMETAL)) ok = false; break; case RawMaterial.MATERIAL_ENERGY: if ((allowedArmorLevel == CharClass.ARMOR_METALONLY) || (allowedArmorLevel == CharClass.ARMOR_OREONLY) || (allowedArmorLevel == CharClass.ARMOR_VEGAN)) return false; break; case RawMaterial.MATERIAL_CLOTH: if ((allowedArmorLevel == CharClass.ARMOR_METALONLY) || (allowedArmorLevel == CharClass.ARMOR_OREONLY) || ((allowedArmorLevel == CharClass.ARMOR_VEGAN) && ((I.material() == RawMaterial.RESOURCE_HIDE) || (I.material() == RawMaterial.RESOURCE_FUR) || (I.material() == RawMaterial.RESOURCE_FEATHERS) || (I.material() == RawMaterial.RESOURCE_WOOL)))) ok = false; break; case RawMaterial.MATERIAL_PLASTIC: case RawMaterial.MATERIAL_WOODEN: if ((allowedArmorLevel == CharClass.ARMOR_CLOTH) || (allowedArmorLevel == CharClass.ARMOR_OREONLY) || (allowedArmorLevel == CharClass.ARMOR_LEATHER) || (allowedArmorLevel == CharClass.ARMOR_METALONLY)) ok = false; break; case RawMaterial.MATERIAL_ROCK: case RawMaterial.MATERIAL_GLASS: if ((allowedArmorLevel == CharClass.ARMOR_CLOTH) || (allowedArmorLevel == CharClass.ARMOR_LEATHER) || (allowedArmorLevel == CharClass.ARMOR_METALONLY)) ok = false; break; case RawMaterial.MATERIAL_FLESH: if ((allowedArmorLevel == CharClass.ARMOR_METALONLY) || (allowedArmorLevel == CharClass.ARMOR_VEGAN) || (allowedArmorLevel == CharClass.ARMOR_CLOTH) || (allowedArmorLevel == CharClass.ARMOR_OREONLY)) ok = false; break; default: if ((allowedArmorLevel == CharClass.ARMOR_METALONLY) || (allowedArmorLevel == CharClass.ARMOR_OREONLY)) ok = false; break; } return ok; } return true; }
@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; }
@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; }
@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); }
@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; }
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; }
@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)); } }
@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; }
@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); } }
@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; }
@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); }
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; }
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; }
public boolean armorCheck(MOB mob, int allowedArmorLevel) { if (allowedArmorLevel == CharClass.ARMOR_ANY) return true; for (int i = 0; i < mob.inventorySize(); i++) { Item I = mob.fetchInventory(i); if ((I != null) && (!I.amWearingAt(Wearable.IN_INVENTORY))) { boolean ok = armorCheck(mob, I, allowedArmorLevel); if ((!ok) && ((I.rawWornCode() & CharClass.ARMOR_WEARMASK) > 0)) return false; } } return true; }
@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; }
@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; }
@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; }
@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); }
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; }
public void recursiveDropMOB(MOB mob, Room room, Item thisContainer, boolean bodyFlag) { // caller is responsible for recovering any env // stat changes! if (CMLib.flags().isHidden(thisContainer)) thisContainer .baseEnvStats() .setDisposition( thisContainer.baseEnvStats().disposition() & ((int) EnvStats.ALLMASK - EnvStats.IS_HIDDEN)); mob.delInventory(thisContainer); thisContainer.unWear(); if (!bodyFlag) bodyFlag = (thisContainer instanceof DeadBody); if (bodyFlag) { room.addItem(thisContainer); thisContainer.setExpirationDate(0); } else room.addItemRefuse(thisContainer, CMProps.getIntVar(CMProps.SYSTEMI_EXPIRE_PLAYER_DROP)); thisContainer.recoverEnvStats(); boolean nothingDone = true; do { nothingDone = true; for (int i = 0; i < mob.inventorySize(); i++) { Item thisItem = mob.fetchInventory(i); if ((thisItem != null) && (thisItem.container() == thisContainer)) { recursiveDropMOB(mob, room, thisItem, bodyFlag); nothingDone = false; break; } } } while (!nothingDone); }
@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; }
@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; }
public void outfit(MOB mob, Vector items) { if ((mob == null) || (items == null) || (items.size() == 0)) return; for (int i = 0; i < items.size(); i++) { Item I = (Item) items.elementAt(i); if (mob.fetchInventory("$" + I.name() + "$") == null) { I = (Item) I.copyOf(); I.text(); I.recoverEnvStats(); mob.addInventory(I); if (I.whereCantWear(mob) <= 0) I.wearIfPossible(mob); if (((I instanceof Armor) || (I instanceof Weapon)) && (I.amWearingAt(Wearable.IN_INVENTORY))) I.destroy(); } } }
@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(); }
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); } } }
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; }
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(); }