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(); }
@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, 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; }
@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 protected Item buildMyPlant(MOB mob, Room room) { final int code = material & RawMaterial.RESOURCE_MASK; final Item newItem = CMClass.getBasicItem("GenItem"); final String name = CMLib.english().startWithAorAn(RawMaterial.CODES.NAME(code).toLowerCase() + " tree"); newItem.setName(name); newItem.setDisplayText(L("@x1 grows here.", newItem.name())); newItem.setDescription(""); newItem.basePhyStats().setWeight(10000); CMLib.flags().setGettable(newItem, false); newItem.setMaterial(material); newItem.setSecretIdentity(mob.Name()); newItem.setMiscText(newItem.text()); room.addItem(newItem); final Chant_SummonTree newChant = new Chant_SummonTree(); newItem.basePhyStats().setLevel(10 + newChant.getX1Level(mob)); newItem.setExpirationDate(0); room.showHappens( CMMsg.MSG_OK_ACTION, L("a tall, healthy @x1 tree sprouts up.", RawMaterial.CODES.NAME(code).toLowerCase())); room.recoverPhyStats(); newChant.plantsLocationR = room; newChant.littlePlantsI = newItem; if (CMLib.law().doesOwnThisLand(mob, room)) { newChant.setInvoker(mob); newChant.setMiscText(mob.Name()); newItem.addNonUninvokableEffect(newChant); } else newChant.beneficialAffect(mob, newItem, 0, (newChant.adjustedLevel(mob, 0) * 240) + 450); room.recoverPhyStats(); return newItem; }
@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; }
public boolean invoke( MOB mob, Vector commands, Environmental givenTarget, boolean auto, int asLevel) { Item myPlant = getTarget(mob, mob.location(), givenTarget, commands, Item.WORNREQ_ANY); if (myPlant == null) return false; if (isPlant(myPlant) == null) { mob.tell("You can't control " + myPlant.name() + "."); return false; } if (myPlant.rawSecretIdentity().equals(mob.Name())) { mob.tell("You already control " + myPlant.name() + "."); return false; } if (!super.invoke(mob, commands, givenTarget, auto, asLevel)) return false; boolean success = proficiencyCheck(mob, 0, auto); if (success) { CMMsg msg = CMClass.getMsg( mob, myPlant, this, verbalCastCode(mob, myPlant, auto), auto ? "" : "^S<S-NAME> chant(s) to <T-NAMESELF>!^?"); if (mob.location().okMessage(mob, msg)) { mob.location().send(mob, msg); Ability A = isPlant(myPlant); if (A != null) A.setInvoker(mob); mob.tell( "You wrest control of " + myPlant.name() + " from " + myPlant.secretIdentity() + "."); myPlant.setSecretIdentity(mob.Name()); } } else beneficialVisualFizzle( mob, myPlant, "<S-NAME> chant(s) to <T-NAMESELF>, but nothing happens."); // return whether it worked return success; }
public boolean invoke( MOB mob, Vector commands, Environmental givenTarget, boolean auto, int asLevel) { Item target = super.getTarget(mob, mob.location(), givenTarget, commands, Wearable.FILTER_ANY); if (target == null) return false; if ((!(target instanceof Ammunition)) || (!((Ammunition) target).ammunitionType().equalsIgnoreCase("arrows"))) { mob.tell(mob, target, null, "You can't enchant <T-NAME> ith an Enchant Arrows spell!"); return false; } if (!super.invoke(mob, commands, givenTarget, auto, asLevel)) return false; int experienceToLose = getXPCOSTAdjustment(mob, 5); CMLib.leveler().postExperience(mob, null, null, -experienceToLose, false); boolean success = proficiencyCheck(mob, 0, auto); if (success) { CMMsg msg = CMClass.getMsg( mob, target, this, verbalCastCode(mob, target, auto), auto ? "" : "^S<S-NAME> hold(s) <T-NAMESELF> and cast(s) a spell.^?"); if (mob.location().okMessage(mob, msg)) { mob.location().send(mob, msg); Ability A = target.fetchEffect(ID()); if ((A != null) && (CMath.s_int(A.text()) > 2)) mob.tell("You are not able to enchant " + target.name() + " further."); else { mob.location().show(mob, target, CMMsg.MSG_OK_VISUAL, "<T-NAME> glows!"); if (A == null) { A = (Ability) copyOf(); target.addNonUninvokableEffect(A); } A.setMiscText("" + (CMath.s_int(A.text()) + 1)); target.recoverEnvStats(); mob.recoverEnvStats(); } } } else beneficialWordsFizzle( mob, target, "<S-NAME> hold(s) <T-NAMESELF> tightly and whisper(s), but fail(s) to cast a spell."); // 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() { Item I = null; if (affected instanceof Item) I = (Item) affected; super.unInvoke(); if ((canBeUninvoked()) && (I != null) && (I.owner() instanceof MOB) && (!I.amWearingAt(Wearable.IN_INVENTORY))) { final MOB mob = (MOB) I.owner(); if ((!mob.amDead()) && (CMLib.flags().isInTheGame(mob, false))) { mob.tell(L("@x1 loosens its grip on your neck and falls off.", I.name(mob))); I.setRawWornCode(0); mob.location().moveItemTo(I, ItemPossessor.Expire.Player_Drop); } } }
@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; }
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(); }
public Item isRuinedLoot(DVector policies, Item I) { if (I == null) return null; if ((CMath.bset(I.envStats().disposition(), EnvStats.IS_UNSAVABLE)) || (CMath.bset(I.envStats().sensesMask(), EnvStats.SENSE_ITEMNORUIN)) || (I instanceof Coins)) return I; if (I.name().toLowerCase().indexOf("ruined ") >= 0) return I; for (int d = 0; d < policies.size(); d++) { if ((((Vector) policies.elementAt(d, 3)).size() > 0) && (!CMLib.masking().maskCheck((Vector) policies.elementAt(d, 3), I, true))) continue; if (CMLib.dice().rollPercentage() > ((Integer) policies.elementAt(d, 1)).intValue()) continue; int flags = ((Integer) policies.elementAt(d, 2)).intValue(); if (CMath.bset(flags, CMMiscUtils.LOOTFLAG_WORN) && I.amWearingAt(Wearable.IN_INVENTORY)) continue; else if (CMath.bset(flags, CMMiscUtils.LOOTFLAG_UNWORN) && (!I.amWearingAt(Wearable.IN_INVENTORY))) continue; if (CMath.bset(flags, CMMiscUtils.LOOTFLAG_LOSS)) return null; Item I2 = CMClass.getItem("GenItem"); I2.baseEnvStats().setWeight(I.baseEnvStats().weight()); I2.setName(I.Name()); I2.setDisplayText(I.displayText()); I2.setDescription(I2.description()); I2.recoverEnvStats(); I2.setMaterial(I.material()); String ruinDescAdder = null; switch (I2.material() & RawMaterial.MATERIAL_MASK) { case RawMaterial.MATERIAL_LEATHER: case RawMaterial.MATERIAL_CLOTH: case RawMaterial.MATERIAL_VEGETATION: case RawMaterial.MATERIAL_FLESH: case RawMaterial.MATERIAL_PAPER: ruinDescAdder = CMStrings.capitalizeFirstLetter(I2.name()) + " is torn and ruined beyond repair."; break; case RawMaterial.MATERIAL_METAL: case RawMaterial.MATERIAL_MITHRIL: case RawMaterial.MATERIAL_WOODEN: ruinDescAdder = CMStrings.capitalizeFirstLetter(I2.name()) + " is battered and ruined beyond repair."; break; case RawMaterial.MATERIAL_GLASS: ruinDescAdder = CMStrings.capitalizeFirstLetter(I2.name()) + " is shattered and ruined beyond repair."; break; case RawMaterial.MATERIAL_ROCK: case RawMaterial.MATERIAL_PRECIOUS: case RawMaterial.MATERIAL_PLASTIC: ruinDescAdder = CMStrings.capitalizeFirstLetter(I2.name()) + " is cracked and ruined beyond repair."; break; case RawMaterial.MATERIAL_UNKNOWN: case RawMaterial.MATERIAL_ENERGY: case RawMaterial.MATERIAL_LIQUID: default: ruinDescAdder = CMStrings.capitalizeFirstLetter(I2.name()) + " is ruined beyond repair."; break; } I2.setDescription(CMStrings.endWithAPeriod(I2.description()) + " " + ruinDescAdder); String oldName = I2.Name(); I2.setName(CMLib.english().insertUnColoredAdjective(I2.Name(), "ruined")); int x = I2.displayText().toUpperCase().indexOf(oldName.toUpperCase()); I2.setBaseValue(0); if (x >= 0) I2.setDisplayText( I2.displayText().substring(0, x) + I2.Name() + I2.displayText().substring(x + oldName.length())); return I2; } return I; }
@Override public boolean invoke( MOB mob, List<String> commands, Physical givenTarget, boolean auto, int asLevel) { if (commands.size() < 2) { if (mob.isMonster() && (commands.size() == 1)) { final String parm = correctItem(mob); if (parm != null) commands.add(parm); } if (commands.size() < 2) { mob.tell(L("You must specify a target, and what item to swap on the target!")); return false; } } final Item I = mob.findItem(null, commands.get(commands.size() - 1)); if ((I == null) || (!CMLib.flags().canBeSeenBy(I, mob))) { mob.tell(L("You don't seem to have '@x1'.", (commands.get(commands.size() - 1)))); return false; } if (((I instanceof Armor) && (I.basePhyStats().armor() > 1)) || ((I instanceof Weapon) && (I.basePhyStats().damage() > 1))) { mob.tell(L("@x1 is not buffoonish enough!", I.name(mob))); return false; } commands.remove(commands.size() - 1); final MOB target = getTarget(mob, commands, givenTarget); if (target == null) return false; final Item targetItem = targetItem(target); if (targetItem == null) { if (!freePosition(target)) { mob.tell(L("@x1 has no free wearing positions!", target.name(mob))); return false; } } if (!super.invoke(mob, commands, givenTarget, auto, asLevel)) return false; int levelDiff = target.phyStats().level() - mob.phyStats().level(); final boolean success = proficiencyCheck(mob, 0, auto); if (levelDiff > 0) levelDiff = -(levelDiff * ((!CMLib.flags().canBeSeenBy(mob, target)) ? 5 : 15)); else levelDiff = -(levelDiff * ((!CMLib.flags().canBeSeenBy(mob, target)) ? 1 : 2)); if (success) { final CMMsg msg = CMClass.getMsg( mob, target, this, (CMMsg.MSG_NOISYMOVEMENT | CMMsg.MASK_DELICATE | CMMsg.MASK_MALICIOUS) | (auto ? CMMsg.MASK_ALWAYS : 0), auto ? "" : L("<S-NAME> do(es) buffoonery to <T-NAMESELF>.")); if (mob.location().okMessage(mob, msg)) { mob.location().send(mob, msg); long position = -1; if (targetItem != null) { position = targetItem.rawWornCode(); targetItem.unWear(); } else { final Vector<Long> free = getFreeWearingPositions(target); if (free.size() < 1) { mob.tell(L("@x1 has no free wearing positions!", target.name(mob))); return false; } if ((free.contains(Long.valueOf(Wearable.WORN_WIELD))) && ((I instanceof Weapon) || (!(I instanceof Armor)))) position = Wearable.WORN_WIELD; else position = free.elementAt(CMLib.dice().roll(1, free.size(), -1)).longValue(); } if (position >= 0) { I.unWear(); target.moveItemTo(I); I.wearAt(position); } } } else return beneficialVisualFizzle( mob, target, L("<S-NAME> attempt(s) buffoonery on <T-NAMESELF>, but fail(s).")); return success; }
public boolean invoke( MOB mob, Vector commands, Environmental givenTarget, boolean auto, int asLevel) { if (commands.size() < 1) { mob.tell("Create overgrowth where?"); return false; } String areaName = CMParms.combine(commands, 0).trim().toUpperCase(); Room anyRoom = null; Room newRoom = null; try { Vector rooms = CMLib.map().findRooms(CMLib.map().rooms(), mob, areaName, true, 10); for (Enumeration r = rooms.elements(); r.hasMoreElements(); ) { Room R = (Room) r.nextElement(); anyRoom = R; if ((R.domainType() & Room.INDOORS) == 0) { newRoom = R; break; } } } catch (NoSuchElementException e) { } if (newRoom == null) { if (anyRoom == null) mob.tell("You don't know of an place called '" + CMParms.combine(commands, 0) + "'."); else mob.tell("There IS such a place, but its not outdoors, so your magic would fail."); return false; } if (!super.invoke(mob, commands, givenTarget, auto, asLevel)) return false; boolean success = proficiencyCheck(mob, 0, auto); if (success) { CMMsg msg = CMClass.getMsg( mob, null, this, verbalCastCode(mob, null, auto), "^S<S-NAME> chant(s) about a far away place.^?"); if (mob.location().okMessage(mob, msg)) { mob.location().send(mob, msg); Item newItem = null; if (newRoom.domainType() == Room.DOMAIN_INDOORS_CAVE) newItem = Chant_SummonFungus.buildFungus(mob, newRoom); else if ((newRoom.domainType() == Room.DOMAIN_OUTDOORS_UNDERWATER) || (newRoom.domainType() == Room.DOMAIN_OUTDOORS_WATERSURFACE)) newItem = Chant_SummonSeaweed.buildSeaweed(mob, newRoom); else if ((newRoom.domainType() == Room.DOMAIN_INDOORS_STONE) || (newRoom.domainType() == Room.DOMAIN_INDOORS_WOOD)) newItem = Chant_SummonHouseplant.buildHouseplant(mob, newRoom); else newItem = Chant_SummonPlants.buildPlant(mob, newRoom); mob.tell("You feel a distant connection with " + newItem.name()); } } else beneficialWordsFizzle( mob, null, "<S-NAME> chant(s) about a far away place, but the magic fades."); // return whether it worked return success; }
public static String getBasic(MOB M, int i) { StringBuffer str = new StringBuffer(""); switch (i) { case 0: str.append(M.Name() + ", "); break; case 1: str.append(M.description() + ", "); break; case 2: if (M.playerStats() != null) str.append(CMLib.time().date2String(M.playerStats().lastDateTime()) + ", "); break; case 3: if (M.playerStats() != null) str.append(M.playerStats().getEmail() + ", "); break; case 4: str.append(M.baseCharStats().getMyRace().name() + ", "); break; case 5: str.append( M.baseCharStats().getCurrentClass().name(M.baseCharStats().getCurrentClassLevel()) + ", "); break; case 6: str.append(M.baseEnvStats().level() + ", "); break; case 7: str.append(M.baseCharStats().displayClassLevel(M, true) + ", "); break; case 8: str.append(M.baseCharStats().getClassLevel(M.baseCharStats().getCurrentClass()) + ", "); break; case 9: { for (int c = M.charStats().numClasses() - 1; c >= 0; c--) { CharClass C = M.charStats().getMyClass(c); str.append( C.name(M.baseCharStats().getCurrentClassLevel()) + " (" + M.charStats().getClassLevel(C) + ") "); } str.append(", "); break; } case 10: if (M.maxCarry() > (Integer.MAX_VALUE / 3)) str.append("NA, "); else str.append(M.maxCarry() + ", "); break; case 11: str.append(CMStrings.capitalizeAndLower(CMLib.combat().fightingProwessStr(M)) + ", "); break; case 12: str.append(CMStrings.capitalizeAndLower(CMLib.combat().armorStr(M)) + ", "); break; case 13: str.append(CMLib.combat().adjustedDamage(M, null, null) + ", "); break; case 14: str.append(Math.round(CMath.div(M.getAgeHours(), 60.0)) + ", "); break; case 15: str.append(M.getPractices() + ", "); break; case 16: str.append(M.getExperience() + ", "); break; case 17: if (M.getExpNeededLevel() == Integer.MAX_VALUE) str.append("N/A, "); else str.append(M.getExpNextLevel() + ", "); break; case 18: str.append(M.getTrains() + ", "); break; case 19: str.append(CMLib.beanCounter().getMoney(M) + ", "); break; case 20: str.append(M.getWorshipCharID() + ", "); break; case 21: str.append(M.getLiegeID() + ", "); break; case 22: str.append(M.getClanID() + ", "); break; case 23: if (M.getClanID().length() > 0) { Clan C = CMLib.clans().getClan(M.getClanID()); if (C != null) str.append( CMLib.clans().getRoleName(C.getGovernment(), M.getClanRole(), true, false) + ", "); } break; case 24: str.append(M.fetchFaction(CMLib.factions().AlignID()) + ", "); break; case 25: { Faction.FactionRange FR = CMLib.factions() .getRange(CMLib.factions().AlignID(), M.fetchFaction(CMLib.factions().AlignID())); if (FR != null) str.append(FR.name() + ", "); else str.append(M.fetchFaction(CMLib.factions().AlignID())); break; } case 26: str.append(M.getWimpHitPoint() + ", "); break; case 27: if (M.getStartRoom() != null) str.append(M.getStartRoom().displayText() + ", "); break; case 28: if (M.location() != null) str.append(M.location().displayText() + ", "); break; case 29: if (M.getStartRoom() != null) str.append(M.getStartRoom().roomID() + ", "); break; case 30: if (M.location() != null) str.append(M.location().roomID() + ", "); break; case 31: { for (int inv = 0; inv < M.inventorySize(); inv++) { Item I = M.fetchInventory(inv); if ((I != null) && (I.container() == null)) str.append(I.name() + ", "); } break; } case 32: str.append(M.baseEnvStats().weight() + ", "); break; case 33: str.append(M.envStats().weight() + ", "); break; case 34: str.append(CMStrings.capitalizeAndLower(M.baseCharStats().genderName()) + ", "); break; case 35: if (M.playerStats() != null) str.append(M.playerStats().lastDateTime() + ", "); break; case 36: str.append(M.curState().getHitPoints() + ", "); break; case 37: str.append(M.curState().getMana() + ", "); break; case 38: str.append(M.curState().getMovement() + ", "); break; case 39: if (M.riding() != null) str.append(M.riding().name() + ", "); break; case 40: str.append(M.baseEnvStats().height() + ", "); break; case 41: if (!M.isMonster()) str.append(M.session().getAddress() + ", "); else if (M.playerStats() != null) str.append(M.playerStats().lastIP() + ", "); break; case 42: str.append(M.getQuestPoint() + ", "); break; case 43: str.append(M.maxState().getHitPoints() + ", "); break; case 44: str.append(M.maxState().getMana() + ", "); break; case 45: str.append(M.maxState().getMovement() + ", "); break; case 46: str.append(M.rawImage() + ", "); break; case 47: str.append(M.maxItems() + ", "); break; case 48: { String[] paths = CMProps.mxpImagePath(M.image()); if (paths[0].length() > 0) str.append(paths[0] + paths[1] + ", "); break; } case 49: if (CMProps.mxpImagePath(M.image())[0].length() > 0) str.append("true, "); else str.append("false, "); break; case 50: if (M.playerStats() != null) str.append(M.playerStats().notes() + ", "); break; case 51: if (M.playerStats() != null) { long lastDateTime = -1; for (int level = 0; level <= M.envStats().level(); level++) { long dateTime = M.playerStats().leveledDateTime(level); if ((dateTime > 1529122205) && (dateTime != lastDateTime)) { str.append("<TR>"); if (level == 0) str.append("<TD><FONT COLOR=WHITE>Created</FONT></TD>"); else str.append("<TD><FONT COLOR=WHITE>" + level + "</FONT></TD>"); str.append( "<TD><FONT COLOR=WHITE>" + CMLib.time().date2String(dateTime) + "</FONT></TD></TR>"); } } str.append(", "); } break; case 52: str.append(M.baseEnvStats().attackAdjustment() + ", "); break; case 53: str.append(M.baseEnvStats().damage() + ", "); break; case 54: str.append(M.baseEnvStats().armor() + ", "); break; case 55: str.append(M.envStats().speed() + ", "); break; case 56: str.append(M.baseEnvStats().speed() + ", "); break; case 57: { for (int e = 0; e < M.numExpertises(); e++) { String E = M.fetchExpertise(e); ExpertiseLibrary.ExpertiseDefinition X = CMLib.expertises().getDefinition(E); if (X == null) str.append(E + ", "); else str.append(X.name + ", "); } break; } case 58: { for (int t = 0; t < M.numTattoos(); t++) { String E = M.fetchTattoo(t); str.append(E + ", "); } break; } case 59: { if (M.playerStats() != null) for (int b = 0; b < M.playerStats().getSecurityGroups().size(); b++) { String B = (String) M.playerStats().getSecurityGroups().elementAt(b); if (B != null) str.append(B + ", "); } break; } case 60: { if (M.playerStats() != null) for (int b = 0; b < M.playerStats().getTitles().size(); b++) { String B = (String) M.playerStats().getTitles().elementAt(b); if (B != null) str.append(B + ", "); } break; } case 61: { for (Enumeration e = M.fetchFactions(); e.hasMoreElements(); ) { String FID = (String) e.nextElement(); Faction F = CMLib.factions().getFaction(FID); int value = M.fetchFaction(FID); if (F != null) str.append(F.name() + " (" + value + "), "); } break; } case 62: str.append(CMProps.getBoolVar(CMProps.SYSTEMB_ACCOUNTEXPIRATION) ? "true" : "false"); break; case 63: if (M.playerStats() != null) str.append(CMLib.time().date2String(M.playerStats().getAccountExpiration())); break; case 64: { for (int f = 0; f < M.numFollowers(); f++) str.append(M.fetchFollower(f).name()).append(", "); // Vector V=CMLib.database().DBScanFollowers(M); // for(int v=0;v<V.size();v++) // str.append(((MOB)V.elementAt(v)).name()).append(", "); break; } case 65: if ((M.playerStats() != null) && (M.playerStats().getAccount() != null)) str.append(M.playerStats().getAccount().accountName()); break; } return str.toString(); }
public String builtPrompt(MOB mob) { StringBuffer buf = new StringBuffer("\n\r"); String prompt = mob.playerStats().getPrompt(); String promptUp = null; int c = 0; while (c < prompt.length()) if ((prompt.charAt(c) == '%') && (c < (prompt.length() - 1))) { switch (prompt.charAt(++c)) { case '-': if (c < (prompt.length() - 2)) { if (promptUp == null) promptUp = prompt.toUpperCase(); String promptSub = promptUp.substring(c + 1); Wearable.CODES wcodes = Wearable.CODES.instance(); boolean isFound = false; for (long code : wcodes.all()) if (promptSub.startsWith(wcodes.nameup(code))) { c += 1 + wcodes.nameup(code).length(); Item I = mob.fetchFirstWornItem(code); if (I != null) buf.append(I.name()); isFound = true; break; } if (!isFound) { CharStats.CODES ccodes = CharStats.CODES.instance(); for (int code : ccodes.all()) if (promptSub.startsWith(ccodes.name(code))) { c += 1 + ccodes.name(code).length(); buf.append(mob.charStats().getStat(code)); isFound = true; break; } if (!isFound) for (int code : ccodes.all()) if (promptSub.startsWith("BASE " + ccodes.name(code))) { buf.append(mob.baseCharStats().getStat(code)); c += 6 + ccodes.name(code).length(); isFound = true; break; } } if (!isFound) { for (String s : mob.envStats().getStatCodes()) if (promptSub.startsWith(s)) { c += 1 + s.length(); buf.append(mob.envStats().getStat(s)); isFound = true; break; } if (!isFound) for (String s : mob.baseEnvStats().getStatCodes()) if (promptSub.startsWith("BASE " + s)) { c += 6 + s.length(); buf.append(mob.baseEnvStats().getStat(s)); isFound = true; break; } } if (!isFound) { for (String s : mob.curState().getStatCodes()) if (promptSub.startsWith(s)) { c += 1 + s.length(); buf.append(mob.curState().getStat(s)); isFound = true; break; } if (!isFound) for (String s : mob.maxState().getStatCodes()) if (promptSub.startsWith("MAX " + s)) { c += 5 + s.length(); buf.append(mob.maxState().getStat(s)); isFound = true; break; } if (!isFound) for (String s : mob.baseState().getStatCodes()) if (promptSub.startsWith("BASE " + s)) { c += 6 + s.length(); buf.append(mob.baseState().getStat(s)); isFound = true; break; } } } break; case 'a': { buf.append( CMLib.factions() .getRangePercent( CMLib.factions().AlignID(), mob.fetchFaction(CMLib.factions().AlignID())) + "%"); c++; break; } case 'A': { Faction.FactionRange FR = CMLib.factions() .getRange( CMLib.factions().AlignID(), mob.fetchFaction(CMLib.factions().AlignID())); buf.append( (FR != null) ? FR.name() : "" + mob.fetchFaction(CMLib.factions().AlignID())); c++; break; } case 'B': { buf.append("\n\r"); c++; break; } case 'c': { buf.append(mob.inventorySize()); c++; break; } case 'C': { buf.append(mob.maxItems()); c++; break; } case 'd': { MOB victim = mob.getVictim(); if ((mob.isInCombat()) && (victim != null)) buf.append("" + mob.rangeToTarget()); c++; break; } case 'e': { MOB victim = mob.getVictim(); if ((mob.isInCombat()) && (victim != null) && (CMLib.flags().canBeSeenBy(victim, mob))) buf.append(victim.displayName(mob)); c++; break; } case 'E': { MOB victim = mob.getVictim(); if ((mob.isInCombat()) && (victim != null) && (!victim.amDead()) && (CMLib.flags().canBeSeenBy(victim, mob))) buf.append(victim.healthText(mob) + "\n\r"); c++; break; } case 'g': { buf.append( (int) Math.round( Math.floor( CMLib.beanCounter().getTotalAbsoluteNativeValue(mob) / CMLib.beanCounter() .getLowestDenomination( CMLib.beanCounter().getCurrency(mob))))); c++; break; } case 'G': { buf.append( CMLib.beanCounter() .nameCurrencyShort( mob, CMLib.beanCounter().getTotalAbsoluteNativeValue(mob))); c++; break; } case 'h': { buf.append("^<Hp^>" + mob.curState().getHitPoints() + "^</Hp^>"); c++; break; } case 'H': { buf.append("^<MaxHp^>" + mob.maxState().getHitPoints() + "^</MaxHp^>"); c++; break; } case 'I': { if ((CMLib.flags().isCloaked(mob)) && (((mob.envStats().disposition() & EnvStats.IS_NOT_SEEN) != 0))) buf.append("Wizinvisible"); else if (CMLib.flags().isCloaked(mob)) buf.append("Cloaked"); else if (!CMLib.flags().isSeen(mob)) buf.append("Undetectable"); else if (CMLib.flags().isInvisible(mob) && CMLib.flags().isHidden(mob)) buf.append("Hidden/Invisible"); else if (CMLib.flags().isInvisible(mob)) buf.append("Invisible"); else if (CMLib.flags().isHidden(mob)) buf.append("Hidden"); c++; break; } case 'K': case 'k': { MOB tank = mob; if ((tank.getVictim() != null) && (tank.getVictim().getVictim() != null) && (tank.getVictim().getVictim() != mob)) tank = tank.getVictim().getVictim(); if (((c + 1) < prompt.length()) && (tank != null)) switch (prompt.charAt(c + 1)) { case 'h': { buf.append(tank.curState().getHitPoints()); c++; break; } case 'H': { buf.append(tank.maxState().getHitPoints()); c++; break; } case 'm': { buf.append(tank.curState().getMana()); c++; break; } case 'M': { buf.append(tank.maxState().getMana()); c++; break; } case 'v': { buf.append(tank.curState().getMovement()); c++; break; } case 'V': { buf.append(tank.maxState().getMovement()); c++; break; } case 'e': { buf.append(tank.displayName(mob)); c++; break; } case 'E': { if ((mob.isInCombat()) && (CMLib.flags().canBeSeenBy(tank, mob))) buf.append(tank.healthText(mob) + "\n\r"); c++; break; } } c++; break; } case 'm': { buf.append("^<Mana^>" + mob.curState().getMana() + "^</Mana^>"); c++; break; } case 'M': { buf.append("^<MaxMana^>" + mob.maxState().getMana() + "^</MaxMana^>"); c++; break; } case 'r': { if (mob.location() != null) buf.append(mob.location().displayText()); c++; break; } case 'R': { if ((mob.location() != null) && CMSecurity.isAllowed(mob, mob.location(), "SYSMSGS")) buf.append(mob.location().roomID()); c++; break; } case 'v': { buf.append("^<Move^>" + mob.curState().getMovement() + "^</Move^>"); c++; break; } case 'V': { buf.append("^<MaxMove^>" + mob.maxState().getMovement() + "^</MaxMove^>"); c++; break; } case 'w': { buf.append(mob.envStats().weight()); c++; break; } case 'W': { buf.append(mob.maxCarry()); c++; break; } case 'x': { buf.append(mob.getExperience()); c++; break; } case 'X': { if (mob.getExpNeededLevel() == Integer.MAX_VALUE) buf.append("N/A"); else buf.append(mob.getExpNeededLevel()); c++; break; } case 'z': { if (mob.location() != null) buf.append(mob.location().getArea().name()); c++; break; } case 't': { if (mob.location() != null) buf.append( CMStrings.capitalizeAndLower( TimeClock.TOD_DESC[mob.location().getArea().getTimeObj().getTODCode()] .toLowerCase())); c++; break; } case 'T': { if (mob.location() != null) buf.append(mob.location().getArea().getTimeObj().getTimeOfDay()); c++; break; } case '@': { if (mob.location() != null) buf.append( mob.location().getArea().getClimateObj().weatherDescription(mob.location())); c++; break; } default: { buf.append("%" + prompt.charAt(c)); c++; break; } } } else buf.append(prompt.charAt(c++)); return buf.toString(); }
public StringBuffer deviations(MOB mob, String rest) { final Vector<String> V = CMParms.parse(rest); if ((V.size() == 0) || ((!V.get(0).equalsIgnoreCase("mobs")) && (!V.get(0).equalsIgnoreCase("items")) && (!V.get(0).equalsIgnoreCase("both")))) return new StringBuffer( "You must specify whether you want deviations on MOBS, ITEMS, or BOTH."); final String type = V.get(0).toLowerCase(); if (V.size() == 1) return new StringBuffer( "You must also specify a mob or item name, or the word room, or the word area."); final Room mobR = mob.location(); Faction useFaction = null; for (final Enumeration<Faction> e = CMLib.factions().factions(); e.hasMoreElements(); ) { final Faction F = e.nextElement(); if (F.showInSpecialReported()) useFaction = F; } final String where = V.get(1).toLowerCase(); final Environmental E = mobR.fetchFromMOBRoomFavorsItems(mob, null, where, Wearable.FILTER_ANY); final Vector<Environmental> check = new Vector<Environmental>(); if (where.equalsIgnoreCase("room")) fillCheckDeviations(mobR, type, check); else if (where.equalsIgnoreCase("area")) { for (final Enumeration<Room> r = mobR.getArea().getFilledCompleteMap(); r.hasMoreElements(); ) { final Room R = r.nextElement(); fillCheckDeviations(R, type, check); } } else if (where.equalsIgnoreCase("world")) { for (final Enumeration<Room> r = CMLib.map().roomsFilled(); r.hasMoreElements(); ) { final Room R = r.nextElement(); fillCheckDeviations(R, type, check); } } else if (E == null) return new StringBuffer("'" + where + "' is an unknown item or mob name."); else if (type.equals("items") && (!(E instanceof Weapon)) && (!(E instanceof Armor))) return new StringBuffer("'" + where + "' is not a weapon or armor item."); else if (type.equals("mobs") && (!(E instanceof MOB))) return new StringBuffer("'" + where + "' is not a MOB."); else if ((!(E instanceof Weapon)) && (!(E instanceof Armor)) && (!(E instanceof MOB))) return new StringBuffer("'" + where + "' is not a MOB, or Weapon, or Item."); else check.add(E); final StringBuffer str = new StringBuffer(""); str.append(L("Deviations Report:\n\r")); final StringBuffer itemResults = new StringBuffer(); final StringBuffer mobResults = new StringBuffer(); for (int c = 0; c < check.size(); c++) { if (check.get(c) instanceof Item) { final Item I = (Item) check.get(c); Weapon W = null; if (I instanceof Weapon) W = (Weapon) I; final Map<String, String> vals = CMLib.itemBuilder() .timsItemAdjustments( I, I.phyStats().level(), I.material(), I.rawLogicalAnd() ? 2 : 1, (W == null) ? 0 : W.weaponClassification(), I.maxRange(), I.rawProperLocationBitmap()); itemResults.append(CMStrings.padRight(I.name(), 20) + " "); itemResults.append(CMStrings.padRight(I.ID(), 10) + " "); itemResults.append(CMStrings.padRight("" + I.phyStats().level(), 4) + " "); itemResults.append( CMStrings.padRight( "" + getDeviation(I.basePhyStats().attackAdjustment(), vals, "ATTACK"), 5) + " "); itemResults.append( CMStrings.padRight("" + getDeviation(I.basePhyStats().damage(), vals, "DAMAGE"), 5) + " "); itemResults.append( CMStrings.padRight("" + getDeviation(I.basePhyStats().damage(), vals, "ARMOR"), 5) + " "); itemResults.append( CMStrings.padRight("" + getDeviation(I.baseGoldValue(), vals, "VALUE"), 5) + " "); itemResults.append( CMStrings.padRight( "" + ((I.phyStats().rejuv() == PhyStats.NO_REJUV) ? " MAX" : "" + I.phyStats().rejuv()), 5) + " "); if (I instanceof Weapon) itemResults.append(CMStrings.padRight("" + I.basePhyStats().weight(), 4)); else itemResults.append( CMStrings.padRight("" + getDeviation(I.basePhyStats().weight(), vals, "WEIGHT"), 4) + " "); if (I instanceof Armor) itemResults.append(CMStrings.padRight("" + ((Armor) I).phyStats().height(), 4)); else itemResults.append(CMStrings.padRight(" - ", 4) + " "); itemResults.append("\n\r"); } else { final MOB M = (MOB) check.get(c); mobResults.append(CMStrings.padRight(M.name(), 20) + " "); mobResults.append(CMStrings.padRight("" + M.phyStats().level(), 4) + " "); mobResults.append( CMStrings.padRight( "" + getDeviation( M.basePhyStats().attackAdjustment(), CMLib.leveler().getLevelAttack(M)), 5) + " "); mobResults.append( CMStrings.padRight( "" + getDeviation( M.basePhyStats().damage(), (int) Math.round( CMath.div( CMLib.leveler().getLevelMOBDamage(M), M.basePhyStats().speed()))), 5) + " "); mobResults.append( CMStrings.padRight( "" + getDeviation( M.basePhyStats().armor(), CMLib.leveler().getLevelMOBArmor(M)), 5) + " "); mobResults.append( CMStrings.padRight( "" + getDeviation( M.basePhyStats().speed(), CMLib.leveler().getLevelMOBSpeed(M)), 5) + " "); mobResults.append( CMStrings.padRight( "" + ((M.phyStats().rejuv() == PhyStats.NO_REJUV) ? " MAX" : "" + M.phyStats().rejuv()), 5) + " "); if (useFaction != null) mobResults.append( CMStrings.padRight( "" + (M.fetchFaction(useFaction.factionID()) == Integer.MAX_VALUE ? "N/A" : "" + M.fetchFaction(useFaction.factionID())), 7) + " "); double value = CMLib.beanCounter().getTotalAbsoluteNativeValue(M); double[] range = CMLib.leveler().getLevelMoneyRange(M); if (value < range[0]) mobResults.append(CMStrings.padRight("" + getDeviation(value, range[0]), 5) + " "); else if (value > range[1]) mobResults.append(CMStrings.padRight("" + getDeviation(value, range[1]), 5) + " "); else mobResults.append(CMStrings.padRight("0%", 5) + " "); int reallyWornCount = 0; for (int j = 0; j < M.numItems(); j++) { final Item Iw = M.getItem(j); if (!(Iw.amWearingAt(Wearable.IN_INVENTORY))) reallyWornCount++; } mobResults.append(CMStrings.padRight("" + reallyWornCount, 5) + " "); mobResults.append("\n\r"); } } if (itemResults.length() > 0) str.append(itemHeader() + itemResults.toString()); if (mobResults.length() > 0) str.append(mobHeader(useFaction) + mobResults.toString()); return str; }