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 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 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; }
public void setDisplayText(String newDisplayText) { super.setDisplayText(newDisplayText); displayTexts = new Vector(); int x = newDisplayText.toUpperCase().indexOf("<P>"); while (x >= 0) { String s = newDisplayText.substring(0, x).trim(); if (s.length() > 0) displayTexts.addElement(s); newDisplayText = newDisplayText.substring(x + 3).trim(); x = newDisplayText.toUpperCase().indexOf("<P>"); } if (newDisplayText.length() > 0) displayTexts.addElement(newDisplayText); }
public void setDescription(String newDescription) { super.setDescription(newDescription); descriptions = new Vector(); int x = newDescription.toUpperCase().indexOf("<P>"); while (x >= 0) { String s = newDescription.substring(0, x).trim(); if (s.length() > 0) descriptions.addElement(s); newDescription = newDescription.substring(x + 3).trim(); x = newDescription.toUpperCase().indexOf("<P>"); } if (newDescription.length() > 0) descriptions.addElement(newDescription); }
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 List<RawMaterial> myResources() { synchronized (resources) { if (resources.size() == 0) { resources.addElement( makeResource(L("some @x1 hair", name().toLowerCase()), RawMaterial.RESOURCE_FUR)); resources.addElement( makeResource( L("a pair of @x1 teeth", name().toLowerCase()), RawMaterial.RESOURCE_BONE)); resources.addElement( makeResource(L("some @x1 blood", name().toLowerCase()), RawMaterial.RESOURCE_BLOOD)); } } return resources; }
@Override public List<RawMaterial> myResources() { synchronized (resources) { if (resources.size() == 0) { resources.addElement( makeResource("a " + name().toLowerCase() + " brain", RawMaterial.RESOURCE_MEAT)); resources.addElement( makeResource("some " + name().toLowerCase() + " blood", RawMaterial.RESOURCE_BLOOD)); resources.addElement( makeResource( "a pile of " + name().toLowerCase() + " bones", RawMaterial.RESOURCE_BONE)); } } return resources; }
@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); }
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; } }
@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; }
@Override public List<Item> getTrapComponents() { final Vector V = new Vector(); for (int i = 0; i < 10; i++) V.addElement(CMLib.materials().makeItemResource(RawMaterial.RESOURCE_IRON)); return V; }
@Override public List<RawMaterial> myResources() { synchronized (resources) { if (resources.size() == 0) { for (int i = 0; i < 25; i++) resources.addElement( makeResource("some " + name().toLowerCase(), RawMaterial.RESOURCE_FISH)); for (int i = 0; i < 15; i++) resources.addElement( makeResource("a " + name().toLowerCase() + " hide", RawMaterial.RESOURCE_HIDE)); resources.addElement( makeResource("some " + name().toLowerCase() + " blood", RawMaterial.RESOURCE_BLOOD)); } } return resources; }
@Override public void executeMsg(final Environmental myHost, final CMMsg msg) { super.executeMsg(myHost, msg); if (((msg.sourceMinor() == CMMsg.TYP_SHUTDOWN) || ((msg.targetMinor() == CMMsg.TYP_EXPIRE) && (msg.target() == affected)) || (msg.sourceMinor() == CMMsg.TYP_ROOMRESET)) && (affected instanceof Room)) { updateLot(null); final Vector mobs = new Vector(); Room R = (Room) affected; if (R != null) { synchronized (("SYNC" + R.roomID()).intern()) { R = CMLib.map().getRoom(R); for (int m = 0; m < R.numInhabitants(); m++) { final MOB M = R.fetchInhabitant(m); if ((M != null) && (M.isSavable()) && (M.getStartRoom() == R) && ((M.basePhyStats().rejuv() == 0) || (M.basePhyStats().rejuv() == PhyStats.NO_REJUV))) { CMLib.catalog().updateCatalogIntegrity(M); mobs.addElement(M); } } if (!CMSecurity.isSaveFlag(CMSecurity.SaveFlag.NOPROPERTYMOBS)) CMLib.database().DBUpdateTheseMOBs(R, mobs); } } } }
@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; }
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 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 boolean findVictim(MOB mob, Room room, Vector rooms, int depth) { if (depth > 5) return false; if (victimHere(room, mob) != null) { rooms.addElement(room); return true; } for (int d = Directions.NUM_DIRECTIONS() - 1; d >= 0; d--) { final Room R = room.getRoomInDir(d); final Exit E = room.getExitInDir(d); if ((R != null) && (E != null) && (E.isOpen())) { if (findVictim(mob, R, rooms, depth + 1)) { rooms.addElement(R); return true; } } } return false; }
@Override public List<RawMaterial> myResources() { synchronized (resources) { if (resources.size() == 0) { resources.addElement(makeResource(L("a stem"), RawMaterial.RESOURCE_VINE)); } } return resources; }
@Override public List<RawMaterial> myResources() { synchronized (resources) { if (resources.size() == 0) { resources.addElement(makeResource("some pebbles", RawMaterial.RESOURCE_STONE)); } } return resources; }
public List<Ability> returnOffensiveAffects(Physical fromMe) { final Vector offenders = new Vector(); for (final Enumeration<Ability> a = fromMe.effects(); a.hasMoreElements(); ) { final Ability A = a.nextElement(); if ((A != null) && ((A.classificationCode() & Ability.ALL_ACODES) == Ability.ACODE_POISON)) offenders.addElement(A); } return offenders; }
@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<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; }
public List<Ability> returnOffensiveAffects(Physical fromMe) { final Vector offenders = new Vector(); for (int a = 0; a < fromMe.numEffects(); a++) // personal { final Ability A = fromMe.fetchEffect(a); if ((A != null) && ((A.classificationCode() & Ability.ALL_ACODES) == Ability.ACODE_POISON)) offenders.addElement(A); } return offenders; }
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 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)); }
public Vector myResources() { synchronized (resources) { if (resources.size() == 0) { resources.addElement( makeResource("a " + name().toLowerCase() + " mane", RawMaterial.RESOURCE_FUR)); for (int i = 0; i < 2; i++) resources.addElement( makeResource( "a piece of " + name().toLowerCase() + " leather", RawMaterial.RESOURCE_LEATHER)); resources.addElement( makeResource( "a pound of " + name().toLowerCase() + " meat", RawMaterial.RESOURCE_BEEF)); resources.addElement( makeResource( "a pint of " + name().toLowerCase() + " blood", RawMaterial.RESOURCE_BLOOD)); resources.addElement( makeResource("a " + name().toLowerCase() + " horn", RawMaterial.RESOURCE_BONE)); } } return resources; }
@Override public List<RawMaterial> myResources() { synchronized (resources) { if (resources.size() == 0) { resources.addElement( makeResource("" + name().toLowerCase() + " mane", RawMaterial.RESOURCE_FUR)); for (int i = 0; i < 2; i++) resources.addElement( makeResource( "a strip of " + name().toLowerCase() + " fur", RawMaterial.RESOURCE_FUR)); resources.addElement( makeResource( "a pound of " + name().toLowerCase() + " meat", RawMaterial.RESOURCE_BEEF)); resources.addElement( makeResource("some " + name().toLowerCase() + " blood", RawMaterial.RESOURCE_BLOOD)); resources.addElement( makeResource( "a pile of " + name().toLowerCase() + " bones", RawMaterial.RESOURCE_BONE)); } } return resources; }
protected Vector<Long> getFreeWearingPositions(MOB target) { final Vector<Long> V = new Vector<Long>(); final Wearable.CODES codes = Wearable.CODES.instance(); final boolean[] pos = new boolean[codes.all_ordered().length]; for (int i = 0; i < pos.length; i++) if (target.freeWearPositions(codes.all_ordered()[i], (short) 0, (short) 0) > 0) pos[i] = false; else pos[i] = true; for (int i = 0; i < pos.length; i++) if (!pos[i]) V.addElement(Long.valueOf(codes.all_ordered()[i])); return V; }