public DVector parseLootPolicyFor(MOB mob) { if (mob == null) return new DVector(3); Vector lootPolicy = (!mob.isMonster()) ? new Vector() : CMParms.parseCommas(CMProps.getVar(CMProps.SYSTEM_ITEMLOOTPOLICY), true); DVector policies = new DVector(3); for (int p = 0; p < lootPolicy.size(); p++) { String s = ((String) lootPolicy.elementAt(p)).toUpperCase().trim(); if (s.length() == 0) continue; Vector compiledMask = null; int maskDex = s.indexOf("MASK="); if (maskDex >= 0) { s = s.substring(0, maskDex).trim(); compiledMask = CMLib.masking() .maskCompile(((String) lootPolicy.elementAt(p)).substring(maskDex + 5).trim()); } else compiledMask = new Vector(); Vector parsed = CMParms.parse(s); int pct = 100; for (int x = 0; x < parsed.size(); x++) if (CMath.isInteger((String) parsed.elementAt(x))) pct = CMath.s_int((String) parsed.elementAt(x)); else if (CMath.isPct((String) parsed.elementAt(x))) pct = (int) Math.round(CMath.s_pct((String) parsed.elementAt(x)) * 100.0); int flags = 0; if (parsed.contains("RUIN")) flags |= CMMiscUtils.LOOTFLAG_RUIN; else if (parsed.contains("LOSS")) flags |= CMMiscUtils.LOOTFLAG_LOSS; if (flags == 0) flags |= CMMiscUtils.LOOTFLAG_LOSS; if (parsed.contains("WORN")) flags |= CMMiscUtils.LOOTFLAG_WORN; else if (parsed.contains("UNWORN")) flags |= CMMiscUtils.LOOTFLAG_UNWORN; policies.addElement(Integer.valueOf(pct), Integer.valueOf(flags), compiledMask); } return policies; }
@Override public boolean tick(Tickable ticking, int tickID) { if (!super.tick(ticking, tickID)) return false; if (affected == null) return false; if (!(affected instanceof MOB)) return false; final MOB mob = (MOB) affected; if (mob.location().numInhabitants() == 1) return true; final Vector choices = new Vector(); for (final Enumeration<Ability> a = mob.effects(); a.hasMoreElements(); ) { final Ability A = a.nextElement(); if ((A != null) && (A.canBeUninvoked()) && (!A.ID().equals(ID())) && (A.abstractQuality() == Ability.QUALITY_MALICIOUS) && (((A.classificationCode() & Ability.ALL_ACODES) == Ability.ACODE_SPELL) || ((A.classificationCode() & Ability.ALL_ACODES) == Ability.ACODE_PRAYER)) && (!A.isAutoInvoked())) choices.addElement(A); } if (choices.size() == 0) return true; final MOB target = mob.location().fetchRandomInhabitant(); final Ability thisOne = (Ability) choices.elementAt(CMLib.dice().roll(1, choices.size(), -1)); if ((target == null) || (thisOne == null) || (target.fetchEffect(ID()) != null)) return true; if (CMLib.dice().rollPercentage() > (target.charStats().getSave(CharStats.STAT_SAVE_DISEASE))) { ((Ability) this.copyOf()).invoke(target, target, true, 0); if (target.fetchEffect(ID()) != null) ((Ability) thisOne.copyOf()).invoke(target, target, true, 0); } else spreadImmunity(target); return true; }
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; }
public void removeMyAffectsFrom(Physical P) { if (P == null) return; int x = 0; final Vector<Ability> eff = new Vector<Ability>(); Ability thisAffect = null; for (x = 0; x < P.numEffects(); x++) // personal { thisAffect = P.fetchEffect(x); if (thisAffect != null) eff.addElement(thisAffect); } if (eff.size() > 0) { final Map<String, String> h = makeMySpellsH(getMySpellsV()); if (unrevocableSpells != null) { for (int v = unrevocableSpells.size() - 1; v >= 0; v--) { thisAffect = unrevocableSpells.get(v); if (h.containsKey(thisAffect.ID())) P.delEffect(thisAffect); } } else for (x = 0; x < eff.size(); x++) { thisAffect = eff.elementAt(x); final String ID = h.get(thisAffect.ID()); if ((ID != null) && (thisAffect.invoker() == getInvokerMOB(P, P))) { thisAffect.unInvoke(); if ((!uninvocable) && (!thisAffect.canBeUninvoked())) P.delEffect(thisAffect); } } unrevocableSpells = null; } }
protected Vector loadRecipes() { String filename = parametersFile(); Vector recipes = (Vector) Resources.getResource("PARSED: " + filename); if (recipes == null) { StringBuffer str = new CMFile(Resources.buildResourcePath("skills") + filename, null, true).text(); recipes = loadList(str); if (recipes.size() == 0) Log.errOut("LeatherWorking", "Recipes not found!"); else { Vector pleaseAdd1 = new Vector(); Vector pleaseAdd2 = new Vector(); for (int r = 0; r < recipes.size(); r++) { Vector V = (Vector) recipes.elementAt(r); if (V.size() > 0) { Vector V1 = (Vector) V.clone(); Vector V2 = (Vector) V.clone(); String name = (String) V.elementAt(RCP_FINALNAME); V1.setElementAt("Hard " + name, RCP_FINALNAME); V1.setElementAt("" + (CMath.s_int((String) V.elementAt(RCP_LEVEL)) + 5), RCP_LEVEL); V2.setElementAt("Studded " + name, RCP_FINALNAME); V2.setElementAt("" + (CMath.s_int((String) V.elementAt(RCP_LEVEL)) + 11), RCP_LEVEL); pleaseAdd1.addElement(V1); pleaseAdd2.addElement(V2); } } for (int i = 0; i < pleaseAdd1.size(); i++) recipes.addElement(pleaseAdd1.elementAt(i)); for (int i = 0; i < pleaseAdd2.size(); i++) recipes.addElement(pleaseAdd2.elementAt(i)); } Resources.submitResource("PARSED: " + filename, recipes); } return recipes; }
@Override public void grantAbilities(MOB mob, boolean isBorrowedClass) { super.grantAbilities(mob, isBorrowedClass); if (mob.playerStats() == null) { final List<AbilityMapper.AbilityMapping> V = CMLib.ableMapper() .getUpToLevelListings(ID(), mob.charStats().getClassLevel(ID()), false, false); for (final AbilityMapper.AbilityMapping able : V) { final Ability A = CMClass.getAbility(able.abilityID); if ((A != null) && ((A.classificationCode() & Ability.ALL_ACODES) == Ability.ACODE_CHANT) && (!CMLib.ableMapper().getDefaultGain(ID(), true, A.ID()))) giveMobAbility( mob, A, CMLib.ableMapper().getDefaultProficiency(ID(), true, A.ID()), CMLib.ableMapper().getDefaultParm(ID(), true, A.ID()), isBorrowedClass); } return; } final Vector grantable = new Vector(); final int level = mob.charStats().getClassLevel(this); int numChants = 2; for (final Enumeration<Ability> a = CMClass.abilities(); a.hasMoreElements(); ) { final Ability A = a.nextElement(); if ((CMLib.ableMapper().getQualifyingLevel(ID(), true, A.ID()) == level) && ((CMLib.ableMapper().getQualifyingLevel(ID(), true, A.ID()) <= 25) && (!CMLib.ableMapper().getSecretSkill(ID(), true, A.ID())) && (!CMLib.ableMapper().getDefaultGain(ID(), true, A.ID())) && ((A.classificationCode() & Ability.ALL_ACODES) == Ability.ACODE_CHANT))) { if (!grantable.contains(A.ID())) grantable.addElement(A.ID()); } } for (int a = 0; a < mob.numAbilities(); a++) { final Ability A = mob.fetchAbility(a); if (grantable.contains(A.ID())) { grantable.remove(A.ID()); numChants--; } } for (int i = 0; i < numChants; i++) { if (grantable.size() == 0) break; final String AID = (String) grantable.elementAt(CMLib.dice().roll(1, grantable.size(), -1)); if (AID != null) { grantable.removeElement(AID); giveMobAbility( mob, CMClass.getAbility(AID), CMLib.ableMapper().getDefaultProficiency(ID(), true, AID), CMLib.ableMapper().getDefaultParm(ID(), true, AID), isBorrowedClass); } } }
protected int parseOutLevel(Vector commands) { if ((commands.size() > 1) && (commands.lastElement() instanceof String) && (CMath.isNumber((String) commands.lastElement()))) { final int x = CMath.s_int((String) commands.lastElement()); commands.remove(commands.size() - 1); return x; } return -1; }
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 String niceCommaList(Vector V, boolean andTOrF) { String id = ""; for (int v = 0; v < V.size(); v++) { String s = null; if (V.elementAt(v) instanceof Environmental) s = ((Environmental) V.elementAt(v)).name(); else if (V.elementAt(v) instanceof String) s = (String) V.elementAt(v); else continue; if (V.size() == 1) id += s; else if (v == (V.size() - 1)) id += ((andTOrF) ? "and " : "or ") + s; else id += s + ", "; } return id; }
public String composition() { String comp = ""; if (trail != null) { String t = trail.toString(); final int[] counts = new int[stuff.length]; int x = t.indexOf(';'); while (x >= 0) { final int q = CMath.s_int(t.substring(0, x)); t = t.substring(x + 1); if (q >= 0) { for (int i = 0; i < stuff.length; i++) { if (CMath.s_int(stuff[i][0]) == q) counts[i]++; } } x = t.indexOf(';'); } int wa = -1; for (int i = 0; i < stuff.length; i++) if (CMath.s_int(stuff[i][0]) == CMMsg.TYP_WEAPONATTACK) { wa = i; break; } if (wa >= 0) counts[wa] = counts[wa] / 25; final Vector<Integer> V = new Vector<Integer>(); while (V.size() < counts.length) { int high = -1; int which = -1; for (int i = 0; i < counts.length; i++) { if ((counts[i] > high) && (!V.contains(Integer.valueOf(i)))) { high = counts[i]; which = i; } } if (which >= 0) V.addElement(Integer.valueOf(which)); } final Vector<Integer> V2 = new Vector<Integer>(); for (int i = 0; i < 3; i++) { final Integer ref = V.elementAt(i); Integer which = null; while ((which == null) || (V2.contains(which))) { final Integer w = V.elementAt(CMLib.dice().roll(1, V.size(), -1)); if (counts[w.intValue()] == counts[ref.intValue()]) which = w; } V2.addElement(which); comp += which.intValue() + ";" + counts[which.intValue()] + ";"; } } return comp; }
@Override public boolean invoke(MOB mob, Vector commands, Physical givenTarget, boolean auto, int asLevel) { String cmd = ""; if (commands.size() > 0) cmd = ((String) commands.firstElement()).toUpperCase(); if ((commands.size() < 2) || ((!cmd.equals("BUY") && (!cmd.equals("SELL"))))) { mob.tell( L( "You must specify BUY, SELL, an item, and possibly a ShopKeeper (unless it is implied).")); return false; } final Environmental shopkeeper = CMLib.english() .parseShopkeeper(mob, commands, CMStrings.capitalizeAndLower(cmd) + " what to whom?"); if (shopkeeper == null) return false; if (commands.size() == 0) { mob.tell(L("@x1 what?", CMStrings.capitalizeAndLower(cmd))); 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> haggle(s) with <T-NAMESELF>.")); if (mob.location().okMessage(mob, msg)) { mob.location().send(mob, msg); invoker = mob; mob.addEffect(this); mob.recoverCharStats(); commands.insertElementAt(CMStrings.capitalizeAndLower(cmd), 0); mob.doCommand(commands, Command.METAFLAG_FORCED); commands.addElement(shopkeeper.name()); mob.delEffect(this); mob.recoverCharStats(); } } else beneficialWordsFizzle( mob, shopkeeper, L("<S-NAME> haggle(s) with <T-NAMESELF>, but <S-IS-ARE> unconvincing.")); // 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 boolean tick(Tickable ticking, int tickID) { if ((!built) && (affected instanceof MOB)) { built = true; CharClass C = null; final Vector allowedClasses = new Vector(); final Vector allowedExpertises = new Vector(); final Vector<String> V = CMParms.parse(text()); String s = null; for (int v = 0; v < V.size(); v++) { s = V.elementAt(v); if (s.equalsIgnoreCase("all")) continue; C = CMClass.getCharClass(s); if (C != null) { if ((v > 0) && (V.elementAt(v - 1).equalsIgnoreCase("ALL"))) { final String baseClass = C.baseClass(); for (final Enumeration c = CMClass.charClasses(); c.hasMoreElements(); ) { C = (CharClass) c.nextElement(); if ((C.baseClass().equalsIgnoreCase(baseClass)) && (!allowedClasses.contains(C))) allowedClasses.addElement(C); } } else allowedClasses.addElement(C); } else { final ExpertiseLibrary.ExpertiseDefinition def = CMLib.expertises().getDefinition(s); if (def != null) allowedExpertises.addElement(def); } } if (allowedClasses.size() == 0) for (final Enumeration c = CMClass.charClasses(); c.hasMoreElements(); ) allowedClasses.addElement(c.nextElement()); if (allowedExpertises.size() == 0) for (final Enumeration e = CMLib.expertises().definitions(); e.hasMoreElements(); ) allowedExpertises.addElement(e.nextElement()); final MOB mob = (MOB) affected; for (int c = 0; c < allowedClasses.size(); c++) { C = (CharClass) allowedClasses.elementAt(c); addCharClassIfNotFound(mob, C); } for (int e = 0; e < allowedExpertises.size(); e++) mob.addExpertise( ((ExpertiseLibrary.ExpertiseDefinition) allowedExpertises.elementAt(e)).ID); mob.recoverCharStats(); mob.recoverPhyStats(); mob.recoverMaxState(); } return super.tick(ticking, tickID); }
@Override public boolean execute(MOB mob, Vector commands, int metaFlags) throws java.io.IOException { if (!(CMLib.intermud().imc2online())) { mob.tell(L("IMC2 is unavailable.")); return false; } commands.remove(0); if (commands.size() < 1) { IMC2Error(mob); return false; } final String str = (String) commands.get(0); if (!(CMLib.intermud().imc2online())) mob.tell(L("IMC2 is unavailable.")); else if (str.equalsIgnoreCase("list")) CMLib.intermud().giveIMC2MudList(mob); else if (str.equalsIgnoreCase("locate")) CMLib.intermud().i3locate(mob, CMParms.combine(commands, 1)); else if (str.equalsIgnoreCase("channels") && CMSecurity.isAllowed(mob, mob.location(), CMSecurity.SecFlag.IMC2)) CMLib.intermud().giveIMC2ChannelsList(mob); else if (str.equalsIgnoreCase("info")) CMLib.intermud().imc2mudInfo(mob, CMParms.combine(commands, 1)); else if (str.equalsIgnoreCase("restart") && CMSecurity.isAllowed(mob, mob.location(), CMSecurity.SecFlag.IMC2)) { try { mob.tell(CMLib.hosts().get(0).executeCommand("START IMC2")); } catch (final Exception e) { Log.errOut("IMC2Cmd", e); } } else IMC2Error(mob); return false; }
public boolean execute(MOB mob, Vector commands, int metaFlags) throws java.io.IOException { if ((mob == null) || (mob.playerStats() == null)) return false; if (commands.size() < 2) { String pageBreak = (mob.playerStats().getPageBreak() != 0) ? ("" + mob.playerStats().getPageBreak()) : "Disabled"; mob.tell( "Change your page break to what? Your current page break setting is: " + pageBreak + ". Enter a number larger than 0 or 'disable'."); return false; } String newBreak = CMParms.combine(commands, 1); int newVal = mob.playerStats().getWrap(); if ((CMath.isInteger(newBreak)) && (CMath.s_int(newBreak) > 0)) newVal = CMath.s_int(newBreak); else if ("DISABLED".startsWith(newBreak.toUpperCase())) newVal = 0; else { mob.tell( "'" + newBreak + "' is not a valid setting. Enter a number larger than 0 or 'disable'."); return false; } mob.playerStats().setPageBreak(newVal); String pageBreak = (mob.playerStats().getPageBreak() != 0) ? ("" + mob.playerStats().getPageBreak()) : "Disabled"; mob.tell("Your new page break setting is: " + pageBreak + "."); return false; }
@Override public boolean execute(MOB mob, Vector commands, int metaFlags) throws java.io.IOException { final StringBuilder msg = new StringBuilder(""); final Vector V = new Vector(); V.add(Integer.valueOf(Ability.ACODE_THIEF_SKILL)); V.add(Integer.valueOf(Ability.ACODE_SKILL)); V.add(Integer.valueOf(Ability.ACODE_COMMON_SKILL)); final String qual = CMParms.combine(commands, 1).toUpperCase(); if (parsedOutIndividualSkill(mob, qual, V)) return true; final int[] level = new int[1]; final int[] domain = new int[1]; final String[] domainName = new String[1]; domainName[0] = ""; level[0] = -1; parseDomainInfo(mob, commands, V, level, domain, domainName); int mask = Ability.ALL_ACODES; if (domain[0] >= 0) { mask = mask | Ability.ALL_DOMAINS; for (int v = 0; v < V.size(); v++) V.setElementAt(Integer.valueOf(((Integer) V.get(v)).intValue() + domain[0]), v); } if ((domain[0] >= 0) || (qual.length() == 0)) msg.append( L( "\n\r^HYour @x1skills:^? @x2", domainName[0].replace('_', ' '), getAbilities(mob, mob, V, mask, true, level[0]).toString())); if (!mob.isMonster()) mob.session().wraplessPrintln(msg.toString()); return false; }
@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; }
@Override public boolean tick(Tickable ticking, int tickID) { final MOB mob = (MOB) affected; if (mob == null) return false; if (song == null) { if ((whom == null) || (commonRoomSet == null) || (!commonRoomSet.contains(whom.location())) || (CMLib.flags().isSleeping(invoker)) || (!CMLib.flags().canBeSeenBy(whom, invoker))) return unsingMe(mob, null); } if ((whom != null) && (song != null) && (affected == invoker()) && (CMLib.dice().rollPercentage() < 10)) { final Hashtable<Integer, Integer> H = getSongBenefits(song); final Vector<Integer> V = new Vector<Integer>(); for (final Enumeration<Integer> e = H.keys(); e.hasMoreElements(); ) V.addElement(e.nextElement()); final Integer I = V.elementAt(CMLib.dice().roll(1, V.size(), -1)); final String[] chk = stuff[I.intValue()]; invoker() .location() .show(invoker(), this, whom, CMMsg.MSG_SPEAK, L("<S-NAME> sing(s) '@x1'.", chk[3])); } if (!super.tick(ticking, tickID)) return false; return true; }
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; }
@Override public List<RawMaterial> myResources() { synchronized (resources) { if (resources.size() == 0) { resources.addElement(makeResource("some pebbles", RawMaterial.RESOURCE_STONE)); } } return resources; }
@Override public List<RawMaterial> myResources() { synchronized (resources) { if (resources.size() == 0) { resources.addElement(makeResource(L("a stem"), RawMaterial.RESOURCE_VINE)); } } return resources; }
@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; }
public Vector getDeadBodies(Environmental E) { if (E instanceof DeadBody) return CMParms.makeVector(E); if (E instanceof Container) { Vector Bs = new Vector(); Vector V = ((Container) E).getContents(); for (int v = 0; v < V.size(); v++) Bs.addAll(getDeadBodies((Environmental) V.elementAt(v))); return Bs; } return new Vector(); }
@Override public List<RawMaterial> myResources() { synchronized (resources) { if (resources.size() == 0) { resources.addElement( makeResource(L("some @x1 pincers", name().toLowerCase()), RawMaterial.RESOURCE_BONE)); } } return resources; }
@Override public List<RawMaterial> myResources() { synchronized (resources) { if (resources.size() == 0) { resources.addElement(makeResource("a pound of clay", RawMaterial.RESOURCE_CLAY)); resources.addElement(makeResource("essence of golem", RawMaterial.RESOURCE_BLOOD)); } } return resources; }
@Override public boolean invoke(MOB mob, Vector commands, Physical givenTarget, boolean auto, int asLevel) { material = RawMaterial.RESOURCE_OAK; if ((mob.location().myResource() & RawMaterial.MATERIAL_MASK) == RawMaterial.MATERIAL_WOODEN) material = mob.location().myResource(); else { final List<Integer> V = mob.location().resourceChoices(); final Vector V2 = new Vector(); if (V != null) for (int v = 0; v < V.size(); v++) { if (((V.get(v).intValue() & RawMaterial.MATERIAL_MASK) == RawMaterial.MATERIAL_WOODEN) && ((V.get(v).intValue()) != RawMaterial.RESOURCE_WOOD)) V2.addElement(V.get(v)); } if (V2.size() > 0) material = ((Integer) V2.elementAt(CMLib.dice().roll(1, V2.size(), -1))).intValue(); } return super.invoke(mob, commands, givenTarget, auto, asLevel); }
@Override public boolean execute(MOB mob, Vector commands, int metaFlags) throws java.io.IOException { if ((commands.size() == 1) && (commands.get(0) instanceof MOB)) { commands.add(getInventory((MOB) commands.get(0), mob, null)); return true; } final StringBuilder msg = getInventory(mob, mob, CMParms.combine(commands, 1)); if (msg.length() == 0) mob.tell(L("^HYou are carrying:\n\r^!Nothing!^?\n\r")); else if (!mob.isMonster()) mob.session().wraplessPrintln(L("^HYou are carrying:^?\n\r@x1", msg.toString())); return false; }
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; }
@Override public void endCharacter(MOB mob) { final Vector<Ability> otherChoices = new Vector<Ability>(); for (int a = 0; a < mob.numAbilities(); a++) { final Ability A2 = mob.fetchAbility(a); if ((A2 != null) && (!A2.isSavable()) && ((A2.classificationCode() & Ability.ALL_ACODES) == Ability.ACODE_SPELL)) otherChoices.addElement(A2); } for (int a = 0; a < otherChoices.size(); a++) mob.delAbility(otherChoices.elementAt(a)); }
@Override public boolean invoke(MOB mob, Vector commands, Physical givenTarget, boolean auto, int asLevel) { if (super.checkStop(mob, commands)) return true; if (commands.size() == 0) { commonTell( mob, L( "Build what? Enter \"buildcage list\" for a list, \"buildcage learn <item>\" to gain recipes, or \"buildcage stop\" to cancel.")); return false; } return super.invoke(mob, commands, givenTarget, auto, asLevel); }