@Override public boolean tick(Tickable ticking, int tickID) { super.tick(ticking, tickID); if (anyWetWeather(lastWeather)) { if (ticking instanceof Room) { final Room R = (Room) ticking; final Area A = R.getArea(); if ((!anyWetWeather(A.getClimateObj().weatherType(R))) && (!dryWeather(A.getClimateObj().weatherType(R))) && (CMLib.dice().rollPercentage() < pct())) makePuddle(R, lastWeather, A.getClimateObj().weatherType(R)); } else if (ticking instanceof Area) { final Area A = (Area) ticking; if ((!anyWetWeather(A.getClimateObj().weatherType(null))) && (!dryWeather(A.getClimateObj().weatherType(null)))) { for (final Enumeration<Room> e = A.getProperMap(); e.hasMoreElements(); ) { final Room R = e.nextElement(); if (((R.domainType() & Room.INDOORS) == 0) && (R.domainType() != Room.DOMAIN_OUTDOORS_AIR) && (!CMLib.flags().isWateryRoom(R)) && (CMLib.dice().rollPercentage() < pct())) makePuddle(R, lastWeather, A.getClimateObj().weatherType(null)); } } } } if (ticking instanceof Room) lastWeather = ((Room) ticking).getArea().getClimateObj().weatherType((Room) ticking); else if (ticking instanceof Area) lastWeather = ((Area) ticking).getClimateObj().weatherType(null); return true; }
public void initializeClass() { super.initializeClass(); CMLib.ableMapper().addCharAbilityMapping(ID(), 1, "Skill_Spellcraft", 50, true); CMLib.ableMapper().addCharAbilityMapping(ID(), 1, "Skill_ScrollCopy", 100, true); CMLib.ableMapper().addCharAbilityMapping(ID(), 1, "Spell_Scribe", 75, true); CMLib.ableMapper().addCharAbilityMapping(ID(), 1, "Papermaking", 75, true); CMLib.ableMapper().addCharAbilityMapping(ID(), 1, "Spell_ReadMagic", 100, true); CMLib.ableMapper().addCharAbilityMapping(ID(), 1, "Spell_MagicMissile", false); CMLib.ableMapper().addCharAbilityMapping(ID(), 1, "Spell_ResistMagicMissiles", false); CMLib.ableMapper().addCharAbilityMapping(ID(), 1, "Spell_Shield", false); CMLib.ableMapper().addCharAbilityMapping(ID(), 1, "Spell_IronGrip", false); for (Enumeration a = CMClass.abilities(); a.hasMoreElements(); ) { Ability A = (Ability) a.nextElement(); if ((A != null) && ((A.classificationCode() & Ability.ALL_ACODES) == Ability.ACODE_SPELL)) { int level = CMLib.ableMapper().getQualifyingLevel(ID(), true, A.ID()); if (level > 0) { AbilityMapper.AbilityMapping able = CMLib.ableMapper().getAbleMap(ID(), A.ID()); if ((able != null) && (!CMLib.ableMapper().getDefaultGain(ID(), true, A.ID()))) { able.costOverrides = new Integer[] { Integer.valueOf(0), Integer.valueOf(0), Integer.valueOf(0), Integer.valueOf(0) }; able.defaultProficiency = 100; } } } } }
@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; }
public void reloadCharClasses(CharClass oldC) { for (Enumeration e = CMLib.map().rooms(); e.hasMoreElements(); ) { Room room = (Room) e.nextElement(); for (int i = 0; i < room.numInhabitants(); i++) { MOB M = room.fetchInhabitant(i); if (M == null) continue; for (int c = 0; c < M.baseCharStats().numClasses(); c++) if (M.baseCharStats().getMyClass(c) == oldC) { M.baseCharStats().setMyClasses(M.baseCharStats().getMyClassesStr()); break; } for (int c = 0; c < M.charStats().numClasses(); c++) if (M.charStats().getMyClass(c) == oldC) { M.charStats().setMyClasses(M.charStats().getMyClassesStr()); break; } } for (e = CMLib.players().players(); e.hasMoreElements(); ) { MOB M = (MOB) e.nextElement(); for (int c = 0; c < M.baseCharStats().numClasses(); c++) if (M.baseCharStats().getMyClass(c) == oldC) { M.baseCharStats().setMyClasses(M.baseCharStats().getMyClassesStr()); break; } for (int c = 0; c < M.charStats().numClasses(); c++) if (M.charStats().getMyClass(c) == oldC) { M.charStats().setMyClasses(M.charStats().getMyClassesStr()); break; } } } }
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 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) { 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; }
@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); } } }
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; }
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 String text() { final StringBuffer x = new StringBuffer(""); for (final Enumeration<String> e = getSongs().keys(); e.hasMoreElements(); ) { final String key = e.nextElement(); final String notkey = getSongs().get(key); x.append(key + "|~|" + notkey + "[|]"); } miscText = x.toString(); return x.toString(); }
@Override public void setMiscText(String txt) { noFollow = false; noSneak = false; final Vector<String> parms = CMParms.parse(txt.toUpperCase()); String s; for (final Enumeration<String> p = parms.elements(); p.hasMoreElements(); ) { s = p.nextElement(); if ("NOFOLLOW".startsWith(s)) noFollow = true; else if (s.startsWith("NOSNEAK")) noSneak = true; } super.setMiscText(txt); }
public void swapRaces(Race newR, Race oldR) { for (Enumeration e = CMLib.map().rooms(); e.hasMoreElements(); ) { Room room = (Room) e.nextElement(); for (int i = 0; i < room.numInhabitants(); i++) { MOB M = room.fetchInhabitant(i); if (M == null) continue; if (M.baseCharStats().getMyRace() == oldR) M.baseCharStats().setMyRace(newR); if (M.charStats().getMyRace() == oldR) M.charStats().setMyRace(newR); } for (e = CMLib.players().players(); e.hasMoreElements(); ) { MOB M = (MOB) e.nextElement(); if (M.baseCharStats().getMyRace() == oldR) M.baseCharStats().setMyRace(newR); if (M.charStats().getMyRace() == oldR) M.charStats().setMyRace(newR); } } }
protected final Map<String, Double> getRatesFor(final Environmental affecting, String currency) { if (spaceMaxCut <= 0.0) return rates; currency = currency.toUpperCase(); if (rates.containsKey(currency)) return rates; String myCurrency = CMLib.beanCounter().getCurrency(affecting); if (myCurrency.equalsIgnoreCase(currency)) { rates.put(currency, Double.valueOf(cut)); return rates; } SpaceObject homeO = CMLib.map().getSpaceObject(affecting, false); if (homeO != null) { myCurrency = CMLib.beanCounter().getCurrency(homeO); if (myCurrency.equalsIgnoreCase(currency)) { rates.put(currency, Double.valueOf(cut)); return rates; } } else { // no space object, wtf? this SHOULD fail if (!complainedAboutSpaceError) { complainedAboutSpaceError = true; Log.errOut( "MoneyChanger", affecting.Name() + " is not on a planet, so space rates cannot apply!"); } return rates; } for (Enumeration<Area> a = CMLib.map().spaceAreas(); a.hasMoreElements(); ) { Area A = a.nextElement(); if ((A != null) && (A != homeO)) { myCurrency = CMLib.beanCounter().getCurrency(A); if (myCurrency.equalsIgnoreCase(currency)) { SpaceObject oA = (SpaceObject) A; long distance = CMLib.map().getDistanceFrom(homeO, oA); if ((distance < 0) || (distance > spaceMaxDistance)) { rates.put(currency, Double.valueOf(spaceMaxCut)); } else { double pct = CMath.div(distance, spaceMaxDistance); double amt = spaceMaxCut * pct; if (amt < cut) amt = cut; rates.put(currency, Double.valueOf(cut)); } return rates; } } } return rates; }
@Override public void affectCharStats(MOB affected, CharStats affectableStats) { if ((whom != null) && (song != null)) { final Hashtable<Integer, Integer> H = getSongBenefits(song); for (final Enumeration<Integer> e = H.keys(); e.hasMoreElements(); ) { final Integer I = e.nextElement(); final String[] chk = stuff[I.intValue()]; if ((chk != null) && (chk[1].startsWith("c"))) { int ticks = H.get(I).intValue(); if (ticks > 50) ticks = 50; if (ticks <= 0) ticks = 1; final int stat = CMath.s_int(chk[2]); if (CharStats.CODES.isBASE(stat)) if (ticks > 5) ticks = 5; affectableStats.setStat( stat, affectableStats.getStat(stat) + ticks + getXLEVELLevel(invoker())); } } } }
@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 void spring(MOB mob) { final Room room = mob.location(); if (room != null) { final Set<MOB> friendlySet = new HashSet<MOB>(); if (invoker() != null) invoker().getGroupMembers(friendlySet); room.show( mob, affected, CMMsg.MSG_OK_ACTION, L("<T-NAME> explodes, spraying clumps of stomach acid everywhere!")); for (final Enumeration<MOB> m = room.inhabitants(); m.hasMoreElements(); ) { MOB M = m.nextElement(); if ((M != null) && (!friendlySet.contains(M))) { final MOB invoker = (invoker() != null) ? invoker() : M; final int damage = CMLib.dice().roll(4, 5 + invoker.phyStats().level(), 0); CMLib.combat() .postDamage( invoker, M, this, damage, CMMsg.MASK_MALICIOUS | CMMsg.MASK_ALWAYS | CMMsg.TYP_ACID, Weapon.TYPE_MELTING, L("The acid clumps <DAMAGE> <T-NAME>!")); if ((!M.isInCombat()) && (M.isMonster()) && (M != invoker) && (M.location() == invoker.location()) && (M.location().isInhabitant(invoker)) && (CMLib.flags().canBeSeenBy(invoker, M))) CMLib.combat().postAttack(M, invoker, M.fetchWieldedItem()); } } } Physical affected = this.affected; unInvoke(); if (affected instanceof Item) ((Item) affected).destroy(); }
@Override public boolean invoke(MOB mob, Vector commands, Physical givenTarget, boolean auto, int asLevel) { final MOB target = this.getTarget(mob, commands, givenTarget); if (target == null) return false; if (!super.invoke(mob, commands, givenTarget, auto, asLevel)) return false; final boolean success = proficiencyCheck(mob, 0, auto); if (success && (target.phyStats().level() < ((mob.phyStats().level() + super.getXLEVELLevel(mob)) / 2))) { final CMMsg msg = CMClass.getMsg( mob, target, this, verbalCastCode(mob, target, auto) | CMMsg.MASK_MALICIOUS, L("^S<S-NAME> @x1 for <T-NAME> to die.^?", prayForWord(mob))); if (mob.location().okMessage(mob, msg)) { mob.location().send(mob, msg); CMLib.combat().postDeath(target, target, null); DeadBody body = null; for (Enumeration<Item> i = mob.location().items(); i.hasMoreElements(); ) { final Item I = i.nextElement(); if ((I instanceof DeadBody) && (((DeadBody) I).getMobName().equals(target.Name()))) body = (DeadBody) I; } if (body == null) mob.tell(L("The death did not appear to create a body!")); else beneficialAffect(mob, body, asLevel, 0); } } else return maliciousFizzle( mob, target, L("^S<S-NAME> @x1 <T-NAME> to die, but nothing happens.^?", prayForWord(mob))); // return whether it worked return success; }
public boolean shutdown() { // int numTicks=tickGroup.size(); int which = 0; while (ticks.size() > 0) { // Log.sysOut("ServiceEngine","Shutting down all tick "+which+"/"+numTicks+"..."); Tick tock = ticks.getFirst(); if (tock != null) { CMProps.setUpAllLowVar( CMProps.SYSTEM_MUDSTATUS, "Shutting down...shutting down Service Engine: killing Tick#" + tock.getCounter() + ": " + tock.getStatus()); tock.shutdown(); } try { Thread.sleep(100); } catch (Exception e) { } which++; } CMProps.setUpAllLowVar( CMProps.SYSTEM_MUDSTATUS, "Shutting down...shutting down Service Engine: " + ID() + ": thread shutdown"); thread.shutdown(); // force final time tick! Vector timeObjects = new Vector(); for (Enumeration e = CMLib.map().areas(); e.hasMoreElements(); ) { Area A = ((Area) e.nextElement()); if (!timeObjects.contains(A.getTimeObj())) timeObjects.addElement(A.getTimeObj()); } CMProps.setUpAllLowVar( CMProps.SYSTEM_MUDSTATUS, "Shutting down...shutting down Service Engine: " + ID() + ": saving time objects"); for (int t = 0; t < timeObjects.size(); t++) ((TimeClock) timeObjects.elementAt(t)).save(); Log.sysOut("ServiceEngine", "Shutdown complete."); return true; }
public boolean tick(Tickable ticking, int tickID) { if (!super.tick(ticking, tickID)) return false; if (CMath.bset(flags(), Area.FLAG_INSTANCE_CHILD)) return true; if ((--childCheckDown) <= 0) { childCheckDown = CHILD_CHECK_INTERVAL; synchronized (children) { for (int i = children.size() - 1; i >= 0; i--) { StdThinInstance childA = (StdThinInstance) children.elementAt(i, 2); if (childA.getAreaState() > Area.STATE_ACTIVE) { Vector V = (Vector) children.elementAt(i, 3); boolean anyInside = false; for (int v = 0; v < V.size(); v++) { MOB M = (MOB) V.elementAt(v); if (CMLib.flags().isInTheGame(M, true) && (M.location() != null) && (M.location().getArea() == childA)) anyInside = true; } if (!anyInside) { children.removeElementsAt(i); for (int v = 0; v < V.size(); v++) { MOB M = (MOB) V.elementAt(v); if ((M.location() != null) && (M.location().getArea() == this)) M.setLocation(M.getStartRoom()); } MOB mob = CMClass.sampleMOB(); for (Enumeration e = childA.getProperMap(); e.hasMoreElements(); ) { Room R = (Room) e.nextElement(); R.executeMsg(mob, CMClass.getMsg(mob, R, null, CMMsg.MSG_EXPIRE, null)); } CMLib.map().delArea(childA); childA.destroy(); } } } } } return true; }
@Override public void affectPhyStats(Physical affected, PhyStats affectableStats) { if ((whom != null) && (song != null)) { final Hashtable<Integer, Integer> H = getSongBenefits(song); for (final Enumeration<Integer> e = H.keys(); e.hasMoreElements(); ) { final Integer I = e.nextElement(); final String[] chk = stuff[I.intValue()]; if ((chk != null) && (chk[1].startsWith("e"))) { int ticks = H.get(I).intValue(); if (ticks <= 0) ticks = 1; switch (chk[2].charAt(0)) { case 'a': if (ticks > 25) ticks = 25; affectableStats.setAttackAdjustment( affectableStats.attackAdjustment() + ticks + getXLEVELLevel(invoker())); break; default: break; } } } } }
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(); }
@Override public void affectCharState(MOB affected, CharState affectableStats) { if ((whom != null) && (song != null)) { final Hashtable<Integer, Integer> H = getSongBenefits(song); for (final Enumeration<Integer> e = H.keys(); e.hasMoreElements(); ) { final Integer I = e.nextElement(); final String[] chk = stuff[I.intValue()]; if ((chk != null) && (chk[1].startsWith("s"))) { int ticks = H.get(I).intValue(); if (ticks > 50) ticks = 50; if (ticks <= 0) ticks = 1; switch (chk[2].charAt(0)) { case 'h': affectableStats.setHunger( affectableStats.getHunger() + ticks + getXLEVELLevel(invoker())); break; case 't': affectableStats.setThirst( affectableStats.getThirst() + ticks + getXLEVELLevel(invoker())); break; case 'v': affectableStats.setMovement( affectableStats.getMovement() + ticks + getXLEVELLevel(invoker())); break; case 'm': affectableStats.setMana( affectableStats.getMana() + ticks + getXLEVELLevel(invoker())); break; case 'i': affectableStats.setHitPoints( affectableStats.getHitPoints() + ticks + getXLEVELLevel(invoker())); break; } } } } }
public static int updateLotWithThisData( Room R, LandTitle T, boolean resetRoomName, boolean clearAllItems, List optPlayerList, int lastNumItems) { boolean updateItems = false; boolean updateExits = false; boolean updateRoom = false; synchronized (("SYNC" + R.roomID()).intern()) { R = CMLib.map().getRoom(R); if (T.getOwnerName().length() == 0) { Item I = null; for (int i = R.numItems() - 1; i >= 0; i--) { I = R.getItem(i); if ((I == null) || (I.Name().equalsIgnoreCase("id"))) continue; CMLib.catalog().updateCatalogIntegrity(I); if (clearAllItems) { I.destroy(); updateItems = true; } else { if (I.expirationDate() == 0) { long now = System.currentTimeMillis(); now += (TimeManager.MILI_MINUTE * CMProps.getIntVar(CMProps.Int.EXPIRE_PLAYER_DROP)); I.setExpirationDate(now); } if ((I.phyStats().rejuv() != PhyStats.NO_REJUV) && (I.phyStats().rejuv() != 0)) { I.basePhyStats().setRejuv(PhyStats.NO_REJUV); I.recoverPhyStats(); } } } Ability A = null; if (clearAllItems) for (final Enumeration<Ability> a = R.effects(); a.hasMoreElements(); ) { A = a.nextElement(); if (((A != null) && ((A.classificationCode() & Ability.ALL_ACODES) != Ability.ACODE_PROPERTY))) { A.unInvoke(); R.delEffect(A); updateRoom = true; } } for (int d = Directions.NUM_DIRECTIONS() - 1; d >= 0; d--) { final Room R2 = R.rawDoors()[d]; Exit E = R.getRawExit(d); if ((E != null) && (E.hasALock()) && (E.isGeneric())) { E.setKeyName(""); E.setDoorsNLocks(E.hasADoor(), E.isOpen(), E.defaultsClosed(), false, false, false); updateExits = true; if (R2 != null) { E = R2.getRawExit(Directions.getOpDirectionCode(d)); if ((E != null) && (E.hasALock()) && (E.isGeneric())) { E.setKeyName(""); E.setDoorsNLocks(E.hasADoor(), E.isOpen(), E.defaultsClosed(), false, false, false); CMLib.database().DBUpdateExits(R2); R2.getArea().fillInAreaRoom(R2); } } } } if (updateExits) { CMLib.database().DBUpdateExits(R); R.getArea().fillInAreaRoom(R); } if (updateItems) CMLib.database().DBUpdateItems(R); if (updateRoom) CMLib.database().DBUpdateRoom(R); colorForSale(R, T.rentalProperty(), resetRoomName); return -1; } if ((lastNumItems < 0) && (!CMSecurity.isDisabled(CMSecurity.DisFlag.PROPERTYOWNERCHECKS)) && (optPlayerList != null)) { boolean playerExists = (CMLib.players().getPlayer(T.getOwnerName()) != null); if (!playerExists) playerExists = (CMLib.clans().getClan(T.getOwnerName()) != null); if (!playerExists) playerExists = optPlayerList.contains(T.getOwnerName()); if (!playerExists) for (int i = 0; i < optPlayerList.size(); i++) if (((String) optPlayerList.get(i)).equalsIgnoreCase(T.getOwnerName())) { playerExists = true; break; } if (!playerExists) { T.setOwnerName(""); T.updateLot(null); return -1; } } int x = R.description().indexOf(SALESTR); if (x >= 0) { R.setDescription(R.description().substring(0, x)); CMLib.database().DBUpdateRoom(R); } x = R.description().indexOf(RENTSTR); if (x >= 0) { R.setDescription(R.description().substring(0, x)); CMLib.database().DBUpdateRoom(R); } // this works on the priciple that // 1. if an item has ONLY been removed, the lastNumItems will be != current # items // 2. if an item has ONLY been added, the dispossessiontime will be != null // 3. if an item has been added AND removed, the dispossession time will be != null on the // added if ((lastNumItems >= 0) && (R.numItems() != lastNumItems)) updateItems = true; for (int i = 0; i < R.numItems(); i++) { final Item I = R.getItem(i); if ((I.expirationDate() != 0) && ((I.isSavable()) || (I.Name().equalsIgnoreCase("id"))) && ((!(I instanceof DeadBody)) || (((DeadBody) I).isPlayerCorpse()))) { I.setExpirationDate(0); updateItems = true; } if ((I.phyStats().rejuv() != Integer.MAX_VALUE) && (I.phyStats().rejuv() != 0)) { I.basePhyStats().setRejuv(PhyStats.NO_REJUV); I.recoverPhyStats(); updateItems = true; } } lastNumItems = R.numItems(); if ((!CMSecurity.isSaveFlag(CMSecurity.SaveFlag.NOPROPERTYITEMS)) && (updateItems)) CMLib.database().DBUpdateItems(R); } return lastNumItems; }
public String systemReport(String itemCode) { long totalMOBMillis = 0; long totalMOBTicks = 0; long topMOBMillis = 0; long topMOBTicks = 0; MOB topMOBClient = null; for (int s = 0; s < CMLib.sessions().size(); s++) { Session S = CMLib.sessions().elementAt(s); totalMOBMillis += S.getTotalMillis(); totalMOBTicks += S.getTotalTicks(); if (S.getTotalMillis() > topMOBMillis) { topMOBMillis = S.getTotalMillis(); topMOBTicks = S.getTotalTicks(); topMOBClient = S.mob(); } } if (itemCode.equalsIgnoreCase("totalMOBMillis")) return "" + totalMOBMillis; else if (itemCode.equalsIgnoreCase("totalMOBMillisTime")) return CMLib.english().returnTime(totalMOBMillis, 0); else if (itemCode.equalsIgnoreCase("totalMOBMillisTimePlusAverage")) return CMLib.english().returnTime(totalMOBMillis, totalMOBTicks); else if (itemCode.equalsIgnoreCase("totalMOBTicks")) return "" + totalMOBTicks; else if (itemCode.equalsIgnoreCase("topMOBMillis")) return "" + topMOBMillis; else if (itemCode.equalsIgnoreCase("topMOBMillisTime")) return CMLib.english().returnTime(topMOBMillis, 0); else if (itemCode.equalsIgnoreCase("topMOBMillisTimePlusAverage")) return CMLib.english().returnTime(topMOBMillis, topMOBTicks); else if (itemCode.equalsIgnoreCase("topMOBTicks")) return "" + topMOBTicks; else if (itemCode.equalsIgnoreCase("topMOBClient")) { if (topMOBClient != null) return topMOBClient.Name(); return ""; } int totalTickers = 0; long totalMillis = 0; long totalTicks = 0; int topGroupNumber = -1; long topGroupMillis = -1; long topGroupTicks = 0; long topObjectMillis = -1; long topObjectTicks = 0; int topObjectGroup = 0; Tickable topObjectClient = null; int num = 0; Tick almostTock = null; for (Iterator<Tick> e = tickGroups(); e.hasNext(); ) { almostTock = e.next(); totalTickers += almostTock.numTickers(); totalMillis += almostTock.milliTotal; totalTicks += almostTock.tickTotal; if (almostTock.milliTotal > topGroupMillis) { topGroupMillis = almostTock.milliTotal; topGroupTicks = almostTock.tickTotal; topGroupNumber = num; } try { for (Iterator et = almostTock.tickers(); et.hasNext(); ) { TockClient C = (TockClient) et.next(); if (C.milliTotal > topObjectMillis) { topObjectMillis = C.milliTotal; topObjectTicks = C.tickTotal; topObjectClient = C.clientObject; topObjectGroup = num; } } } catch (NoSuchElementException ex) { } num++; } if (itemCode.equalsIgnoreCase("freeMemory")) return "" + (Runtime.getRuntime().freeMemory() / 1000); else if (itemCode.equalsIgnoreCase("totalMemory")) return "" + (Runtime.getRuntime().totalMemory() / 1000); else if (itemCode.equalsIgnoreCase("totalTime")) return "" + CMLib.english().returnTime(System.currentTimeMillis() - CMSecurity.getStartTime(), 0); else if (itemCode.equalsIgnoreCase("startTime")) return CMLib.time().date2String(CMSecurity.getStartTime()); else if (itemCode.equalsIgnoreCase("currentTime")) return CMLib.time().date2String(System.currentTimeMillis()); else if (itemCode.equalsIgnoreCase("totalTickers")) return "" + totalTickers; else if (itemCode.equalsIgnoreCase("totalMillis")) return "" + totalMillis; else if (itemCode.equalsIgnoreCase("totalMillisTime")) return CMLib.english().returnTime(totalMillis, 0); else if (itemCode.equalsIgnoreCase("totalMillisTimePlusAverage")) return CMLib.english().returnTime(totalMillis, totalTicks); else if (itemCode.equalsIgnoreCase("totalTicks")) return "" + totalTicks; else if (itemCode.equalsIgnoreCase("tickgroupsize")) return "" + ticks.size(); else if (itemCode.equalsIgnoreCase("topGroupNumber")) return "" + topGroupNumber; else if (itemCode.equalsIgnoreCase("topGroupMillis")) return "" + topGroupMillis; else if (itemCode.equalsIgnoreCase("topGroupMillisTime")) return CMLib.english().returnTime(topGroupMillis, 0); else if (itemCode.equalsIgnoreCase("topGroupMillisTimePlusAverage")) return CMLib.english().returnTime(topGroupMillis, topGroupTicks); else if (itemCode.equalsIgnoreCase("topGroupTicks")) return "" + topGroupTicks; else if (itemCode.equalsIgnoreCase("topObjectMillis")) return "" + topObjectMillis; else if (itemCode.equalsIgnoreCase("topObjectMillisTime")) return CMLib.english().returnTime(topObjectMillis, 0); else if (itemCode.equalsIgnoreCase("topObjectMillisTimePlusAverage")) return CMLib.english().returnTime(topObjectMillis, topObjectTicks); else if (itemCode.equalsIgnoreCase("topObjectTicks")) return "" + topObjectTicks; else if (itemCode.equalsIgnoreCase("topObjectGroup")) return "" + topObjectGroup; else if (itemCode.toLowerCase().startsWith("thread")) { int xstart = "thread".length(); int xend = xstart; while ((xend < itemCode.length()) && (Character.isDigit(itemCode.charAt(xend)))) xend++; int threadNum = CMath.s_int(itemCode.substring(xstart, xend)); int curThreadNum = 0; for (Enumeration e = CMLib.libraries(); e.hasMoreElements(); ) { CMLibrary lib = (CMLibrary) e.nextElement(); ThreadEngine.SupportThread thread = lib.getSupportThread(); if (thread != null) { if (curThreadNum == threadNum) { String instrCode = itemCode.substring(xend); if (instrCode.equalsIgnoreCase("miliTotal")) return "" + thread.milliTotal; if (instrCode.equalsIgnoreCase("milliTotal")) return "" + thread.milliTotal; if (instrCode.equalsIgnoreCase("status")) return "" + thread.status; if (instrCode.equalsIgnoreCase("name")) return "" + thread.getName(); if (instrCode.equalsIgnoreCase("MilliTotalTime")) return CMLib.english().returnTime(thread.milliTotal, 0); if (instrCode.equalsIgnoreCase("MiliTotalTime")) return CMLib.english().returnTime(thread.milliTotal, 0); if (instrCode.equalsIgnoreCase("MilliTotalTimePlusAverage")) return CMLib.english().returnTime(thread.milliTotal, thread.tickTotal); if (instrCode.equalsIgnoreCase("MiliTotalTimePlusAverage")) return CMLib.english().returnTime(thread.milliTotal, thread.tickTotal); if (instrCode.equalsIgnoreCase("TickTotal")) return "" + thread.tickTotal; break; } curThreadNum++; } } } if (itemCode.equalsIgnoreCase("topObjectClient")) { if (topObjectClient != null) return topObjectClient.name(); return ""; } return ""; }
@Override public boolean invoke(MOB mob, Vector commands, Physical givenTarget, boolean auto, int asLevel) { final Vector areas = new Vector(); if (commands.size() == 0) areas.addElement(mob.location().getArea()); else if (((String) commands.lastElement()).equalsIgnoreCase("far")) { commands.removeElementAt(commands.size() - 1); for (final Enumeration e = CMLib.map().areas(); e.hasMoreElements(); ) areas.addElement(e.nextElement()); } else if (((String) commands.lastElement()).equalsIgnoreCase("near")) { commands.removeElementAt(commands.size() - 1); areas.addElement(mob.location().getArea()); } else areas.addElement(mob.location().getArea()); final MOB mobTarget = getTarget(mob, commands, givenTarget, true, false); Item target = null; if (mobTarget != null) { target = getItem(mobTarget); if (target == null) return maliciousFizzle( mob, mobTarget, L("<S-NAME> attempt(s) a scattering spell at <T-NAMESELF>, but nothing happens.")); } List<Item> targets = new Vector(); if (givenTarget instanceof Item) targets.add((Item) givenTarget); else if (target != null) targets.add(target); else { targets = CMLib.english().fetchItemList(mob, mob, null, commands, Wearable.FILTER_ANY, true); if (targets.size() == 0) mob.tell(L("You don't seem to be carrying that.")); } if (targets.size() == 0) return false; if (!super.invoke(mob, commands, givenTarget, auto, asLevel)) return false; final boolean success = proficiencyCheck(mob, 0, auto); if (success) { String str = null; if (mobTarget == null) str = auto ? L("<S-NAME> <S-IS-ARE> enveloped in a scattering field!") : L("^S<S-NAME> utter(s) a scattering spell!^?"); else str = auto ? L("<T-NAME> <T-IS-ARE> enveloped in a scattering field!") : L("^S<S-NAME> utter(s) a scattering spell, causing <T-NAMESELF> to resonate.^?"); CMMsg msg = CMClass.getMsg(mob, mobTarget, this, verbalCastCode(mob, target, auto), str); if (mob.location().okMessage(mob, msg)) { mob.location().send(mob, msg); if (msg.value() <= 0) { for (int i = 0; i < targets.size(); i++) { target = targets.get(i); msg = CMClass.getMsg(mob, target, this, verbalCastCode(mob, target, auto), null); Room room = null; for (int x = 0; (x < 10) && (room == null); x++) room = ((Area) areas.elementAt(CMLib.dice().roll(1, areas.size(), -1))) .getRandomMetroRoom(); if (mob.location().okMessage(mob, msg) && (room != null)) { mob.location().send(mob, msg); if (msg.value() <= 0) { target.unWear(); if (target.owner() instanceof MOB) { final MOB owner = (MOB) target.owner(); mob.location() .show( owner, room, target, CMMsg.MASK_ALWAYS | CMMsg.MSG_THROW, L("<O-NAME> vanishes from <S-YOUPOSS> inventory!")); room.showOthers( owner, room, target, CMMsg.MASK_ALWAYS | CMMsg.MSG_THROW, L("<O-NAME> appears from out of nowhere!")); } else { mob.location() .show( mob, room, target, CMMsg.MASK_ALWAYS | CMMsg.MSG_THROW, L("<O-NAME> vanishes!")); room.showOthers( mob, room, target, CMMsg.MASK_ALWAYS | CMMsg.MSG_THROW, L("<O-NAME> appears from out of nowhere!")); } if (!room.isContent(target)) room.moveItemTo( target, ItemPossessor.Expire.Player_Drop, ItemPossessor.Move.Followers); room.recoverRoomStats(); } } } } } } else return maliciousFizzle( mob, mobTarget, L("<S-NAME> attempt(s) a scattering spell, but nothing happens.")); // return whether it worked return success; }
@Override public void grantAbilities(MOB mob, boolean isBorrowedClass) { super.grantAbilities(mob, isBorrowedClass); // if he already has one, don't give another! if (mob.playerStats() != null) { final int classLevel = mob.baseCharStats().getClassLevel(this); if (classLevel < 2) return; if ((classLevel % 2) != 0) return; int maxSkills = classLevel / 2; // now only give one, for current level, respecting alignment! // first, get a list of all skills you don't qualify for that you MIGHT have gained or will // gain final List<Ability> choices = new Vector<Ability>(); for (final Enumeration<Ability> a = CMClass.abilities(); a.hasMoreElements(); ) { final Ability A = a.nextElement(); final int lql = CMLib.ableMapper().lowestQualifyingLevel(A.ID()); if ((CMLib.ableMapper().qualifyingLevel(mob, A) <= 0) && (lql < 25) && (lql > 0) && (!CMLib.ableMapper().getSecretSkill(A.ID())) && (CMLib.ableMapper().qualifiesByAnyCharClass(A.ID())) && (CMLib.ableMapper().availableToTheme(A.ID(), Area.THEME_FANTASY, true)) && (!CMLib.ableMapper().qualifiesOnlyByClan(mob, A)) && (!CMLib.ableMapper().qualifiesOnlyByRace(mob, A)) && (A.isAutoInvoked() || ((A.triggerStrings() != null) && (A.triggerStrings().length > 0)))) choices.add(A); } // now count those you already have for (int a = choices.size() - 1; a >= 0; a--) { final Ability A = choices.get(a); if (mob.fetchAbility(A.ID()) != null) maxSkills--; } if (maxSkills < 1) // if that reduced you to 0, you are done. return; // now eliminate those you already have, and those that are // above your level, if you are <25 for (int a = choices.size() - 1; a >= 0; a--) { final Ability A = choices.get(a); final int lql = CMLib.ableMapper().lowestQualifyingLevel(A.ID()); if ((mob.fetchAbility(ID()) != null) || ((lql != classLevel) && (lql != classLevel - 1) && (classLevel < 25))) choices.remove(a); } if (choices.size() == 0) return; final Ability A = choices.get(CMLib.dice().roll(1, choices.size(), -1)); if (A != null) giveMobAbility(mob, A, 0, "", isBorrowedClass); } else { 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) && (!CMLib.ableMapper().getAllQualified(ID(), true, A.ID())) && (!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); } } }
@Override public boolean invoke(MOB mob, Vector commands, Physical givenTarget, boolean auto, int asLevel) { if (CMParms.combine(commands, 0).equalsIgnoreCase("auto")) { DATA.clear(); IPS.clear(); final Hashtable<String, List<MOB>> ipes = new Hashtable<String, List<MOB>>(); for (final Session S : CMLib.sessions().localOnlineIterable()) { if ((S.getAddress().length() > 0) && (S.mob() != null)) { List V = ipes.get(S.getAddress()); if (V == null) { V = new Vector(); ipes.put(S.getAddress(), V); } if (!V.contains(S.mob())) V.add(S.mob()); } } final StringBuffer rpt = new StringBuffer(""); for (final Enumeration e = ipes.keys(); e.hasMoreElements(); ) { final String addr = (String) e.nextElement(); final List<MOB> names = ipes.get(addr); if (names.size() > 1) { IPS.put(addr, names); rpt.append("Watch #" + (IPS.size()) + " added: "); for (int n = 0; n < names.size(); n++) { final MOB MN = names.get(n); if (MN.fetchEffect(ID()) == null) { final Ability A = (Ability) copyOf(); MN.addNonUninvokableEffect(A); A.setSavable(false); } rpt.append(MN.Name() + " "); } rpt.append("\n\r"); } } if (rpt.length() == 0) rpt.append("No users with duplicate IDs found. Try MULTIWATCH ADD name1 name2 ... "); mob.tell(rpt.toString()); return true; } else if (CMParms.combine(commands, 0).equalsIgnoreCase("stop")) { boolean foundLegacy = false; for (final Session S : CMLib.sessions().localOnlineIterable()) { if ((S != null) && (S.mob() != null) && (S.mob().fetchEffect(ID()) != null)) { foundLegacy = true; break; } } if ((DATA.size() == 0) && (IPS.size() == 0) && (!foundLegacy)) { mob.tell(L("Multiwatch is already off.")); return false; } for (final Enumeration<List<MOB>> e = IPS.elements(); e.hasMoreElements(); ) { final List<MOB> V = e.nextElement(); for (int v = 0; v < V.size(); v++) { final MOB M = V.get(v); final Ability A = M.fetchEffect(ID()); if (A != null) M.delEffect(A); } } for (final Session S : CMLib.sessions().localOnlineIterable()) { if ((S != null) && (S.mob() != null)) { final MOB M = S.mob(); final Ability A = M.fetchEffect(ID()); if (A != null) M.delEffect(A); } } mob.tell(L("Multiplay watcher is now turned off.")); DATA.clear(); IPS.clear(); return true; } else if ((commands.size() > 1) && ((String) commands.firstElement()).equalsIgnoreCase("add")) { final Vector V = new Vector(); for (int i = 1; i < commands.size(); i++) { final String name = (String) commands.elementAt(i); final MOB M = CMLib.players().getPlayer(name); if ((M.session() != null) && (CMLib.flags().isInTheGame(M, true))) V.addElement(M); else mob.tell(L("'@x1' is not online.", name)); } if (V.size() > 1) { for (int n = 0; n < V.size(); n++) { final MOB MN = (MOB) V.elementAt(n); if (MN.fetchEffect(ID()) == null) { final Ability A = (Ability) copyOf(); MN.addNonUninvokableEffect(A); A.setSavable(false); } } IPS.put("MANUAL" + (IPS.size() + 1), V); mob.tell(L("Manual Watch #@x1 added.", "" + IPS.size())); } return true; } else if ((commands.size() == 0) && (DATA.size() > 0) && (IPS.size() > 0)) { final StringBuffer report = new StringBuffer(""); for (final Enumeration<String> e = IPS.keys(); e.hasMoreElements(); ) { final String key = e.nextElement(); int sync = 0; final List<MOB> V = IPS.get(key); for (int v = 0; v < V.size(); v++) { final MOB M = V.get(v); final int data[] = DATA.get(M); if (data != null) sync += data[DATA_SYNCHROFOUND]; } report.append("^x" + key + "^?^., Syncs: " + sync + "\n\r"); report.append( CMStrings.padRight(L("Name"), 25) + CMStrings.padRight(L("Speech"), 15) + CMStrings.padRight(L("Socials"), 15) + CMStrings.padRight(L("CMD"), 10) + CMStrings.padRight(L("ORDERS"), 10) + "\n\r"); for (int v = 0; v < V.size(); v++) { final MOB M = V.get(v); int data[] = DATA.get(M); if (data == null) data = new int[DATA_TOTAL]; report.append(CMStrings.padRight(M.Name(), 25)); report.append( CMStrings.padRight( data[DATA_GOODSPEECH] + "/" + data[DATA_DIRSPEECH] + "/" + data[DATA_ANYSPEECH], 15)); report.append( CMStrings.padRight( data[DATA_GOODSOCIAL] + "/" + data[DATA_DIRSOCIAL] + "/" + data[DATA_ANYSOCIAL], 15)); report.append(CMStrings.padRight(data[DATA_TYPEDCOMMAND] + "", 10)); report.append(CMStrings.padRight(data[DATA_ORDER] + "", 10)); report.append("\n\r"); } report.append("\n\r"); } mob.tell(report.toString()); return true; } else { mob.tell(L("Try MULTIWATCH AUTO, MULTIWATCH STOP, or MULTIWATCH ADD name1 name2..")); return false; } }
public String runMacro(ExternalHTTPRequests httpReq, String parm) { if (!CMProps.getBoolVar(CMProps.SYSTEMB_MUDSTARTED)) return CMProps.getVar(CMProps.SYSTEM_MUDSTATUS); Hashtable parms = parseParms(parm); String last = httpReq.getRequestParameter("PLAYER"); if (last == null) return " @break@"; if (last.length() > 0) { MOB M = CMLib.players().getLoadPlayer(last); if (M == null) { MOB authM = Authenticate.getAuthenticatedMob(httpReq); if ((authM != null) && (authM.Name().equalsIgnoreCase(last))) M = authM; else return " @break@"; } boolean firstTime = (!httpReq.isRequestParameter("ACTION")) || (httpReq.getRequestParameter("ACTION")).equals("FIRSTTIME"); StringBuffer str = new StringBuffer(""); for (int i = 0; i < MOB.AUTODESC.length; i++) { if (parms.containsKey(MOB.AUTODESC[i])) { boolean set = CMath.isSet(M.getBitmap(), i); if (MOB.AUTOREV[i]) set = !set; str.append((set ? "ON" : "OFF") + ","); } } for (int i : CharStats.CODES.ALL()) { String stat = CharStats.CODES.NAME(i); if (!stat.equalsIgnoreCase("GENDER")) { CharStats C = M.charStats(); if (parms.containsKey(stat)) { String old = httpReq.getRequestParameter(stat); if ((firstTime) || (old.length() == 0)) { if ((!CharStats.CODES.isBASE(i)) && (i != CharStats.STAT_GENDER)) old = "" + C.getSave(i); else old = "" + C.getStat(i); } str.append(old + ", "); } } } for (int i : CharStats.CODES.ALL()) { String stat = CharStats.CODES.NAME(i); if (!stat.equalsIgnoreCase("GENDER")) { CharStats C = M.baseCharStats(); if (parms.containsKey("BASE" + stat)) { String old = httpReq.getRequestParameter("BASE" + stat); if ((firstTime) || (old.length() == 0)) old = "" + C.getStat(i); str.append(old + ", "); } } } for (int i = 0; i < BASICS.length; i++) { if (parms.containsKey(BASICS[i])) { if (httpReq.isRequestParameter(BASICS[i])) str.append(httpReq.getRequestParameter(BASICS[i]) + ", "); else str.append(getBasic(M, i)); } } if (parms.containsKey("RACE")) { String old = httpReq.getRequestParameter("RACE"); if ((firstTime) || (old.length() == 0)) old = "" + M.baseCharStats().getMyRace().ID(); for (Enumeration r = CMClass.races(); r.hasMoreElements(); ) { Race R2 = (Race) r.nextElement(); str.append("<OPTION VALUE=\"" + R2.ID() + "\""); if (R2.ID().equals(old)) str.append(" SELECTED"); str.append(">" + R2.name()); } } if (parms.containsKey("DEITY")) { String old = httpReq.getRequestParameter("DEITY"); if (firstTime) old = M.getWorshipCharID(); str.append("<OPTION " + ((old.length() == 0) ? "SELECTED" : "") + " VALUE=\"\">Godless"); for (Enumeration e = CMLib.map().deities(); e.hasMoreElements(); ) { Deity E = (Deity) e.nextElement(); str.append("<OPTION VALUE=\"" + E.Name() + "\""); if (E.Name().equalsIgnoreCase(old)) str.append(" SELECTED"); str.append(">" + E.Name()); } } if (parms.containsKey("TITLELIST")) { if (M.playerStats() != null) { int b = 0; Vector titles = new Vector(); if (firstTime) CMParms.addToVector(M.playerStats().getTitles(), titles); else while (httpReq.isRequestParameter("TITLE" + b)) { String B = httpReq.getRequestParameter("TITLE" + b); if ((B != null) && (B.trim().length() > 0)) titles.addElement(B); b++; } for (b = 0; b < titles.size(); b++) { String B = (String) titles.elementAt(b); if (B != null) str.append( "<INPUT TYPE=TEXT NAME=TITLE" + b + " SIZE=" + B.length() + " VALUE=\"" + CMStrings.replaceAll(B, "\"", """) + "\"><BR>"); } str.append("<INPUT TYPE=TEXT NAME=TITLE" + titles.size() + " SIZE=60 VALUE=\"\">"); } } if (parms.containsKey("CLAN")) { String old = httpReq.getRequestParameter("CLAN"); if (firstTime) old = M.getClanID(); str.append("<OPTION " + ((old.length() == 0) ? "SELECTED" : "") + " VALUE=\"\">Clanless"); for (Enumeration e = CMLib.clans().allClans(); e.hasMoreElements(); ) { Clan C = (Clan) e.nextElement(); str.append("<OPTION VALUE=\"" + C.clanID() + "\""); if (C.clanID().equalsIgnoreCase(old)) str.append(" SELECTED"); str.append(">" + C.getName()); } } if (parms.containsKey("ALIGNMENT")) { String old = httpReq.getRequestParameter("ALIGNMENT"); if ((firstTime) || (old.length() == 0)) old = "" + M.fetchFaction(CMLib.factions().AlignID()); if (CMLib.factions().getFaction(CMLib.factions().AlignID()) != null) { for (int v = 1; v < Faction.ALIGN_NAMES.length; v++) { str.append("<OPTION VALUE=" + Faction.ALIGN_NAMES[v]); if (old.equalsIgnoreCase(Faction.ALIGN_NAMES[v])) str.append(" SELECTED"); str.append(">" + CMStrings.capitalizeAndLower(Faction.ALIGN_NAMES[v].toLowerCase())); } } } if (parms.containsKey("BASEGENDER")) { String old = httpReq.getRequestParameter("BASEGENDER"); if (firstTime) old = "" + M.baseCharStats().getStat(CharStats.STAT_GENDER); str.append("<OPTION VALUE=M " + ((old.equalsIgnoreCase("M")) ? "SELECTED" : "") + ">M"); str.append("<OPTION VALUE=F " + ((old.equalsIgnoreCase("F")) ? "SELECTED" : "") + ">F"); str.append("<OPTION VALUE=N " + ((old.equalsIgnoreCase("N")) ? "SELECTED" : "") + ">N"); } str.append(MobData.expertiseList(M, httpReq, parms)); str.append(MobData.classList(M, httpReq, parms)); str.append(MobData.itemList(M, M, httpReq, parms, 0)); str.append(MobData.abilities(M, httpReq, parms, 0)); str.append(MobData.factions(M, httpReq, parms, 0)); str.append(AreaData.affectsNBehaves(M, httpReq, parms, 0)); str.append(ExitData.dispositions(M, firstTime, httpReq, parms)); str.append(MobData.senses(M, firstTime, httpReq, parms)); String strstr = str.toString(); if (strstr.endsWith(", ")) strstr = strstr.substring(0, strstr.length() - 2); return clearWebMacros(strstr); } return ""; }
@Override public boolean invoke( MOB mob, List<String> commands, Physical givenTarget, boolean auto, int asLevel) { timeOut = 0; if (auto) return false; final Hashtable<String, String> H = getSongs(); if (commands.size() == 0) { final Song_Ode A = (Song_Ode) mob.fetchEffect(ID()); if ((A != null) && (A.whom != null) && (A.song == null)) { final String str = L("^S<S-NAME> finish(es) composing the @x1.^?", A.songOf()); final CMMsg msg = CMClass.getMsg( mob, null, this, (auto ? CMMsg.MASK_ALWAYS : 0) | CMMsg.MSG_DELICATE_SMALL_HANDS_ACT, str); if (mob.location().okMessage(mob, msg)) { mob.location().send(mob, msg); mob.delEffect(A); getSongs().put(A.whom.name(), A.composition()); whom = null; return true; } return false; } final StringBuffer str = new StringBuffer(""); for (final Enumeration<String> e = H.keys(); e.hasMoreElements(); ) str.append(e.nextElement() + " "); mob.tell(L("Compose or sing an ode about whom?")); if (str.length() > 0) mob.tell(L("You presently have odes written about: @x1.", str.toString().trim())); return false; } String name = CMParms.combine(commands, 0); for (final Enumeration<String> e = H.keys(); e.hasMoreElements(); ) { final String key = e.nextElement(); if (CMLib.english().containsString(key, name)) { invoker = mob; originRoom = mob.location(); commonRoomSet = getInvokerScopeRoomSet(null); name = key; song = H.get(name); benefits = null; whom = mob.location().fetchInhabitant(name); if ((whom == null) || (!whom.name().equals(name))) whom = CMLib.players().getPlayer(name); if ((whom == null) || (!whom.name().equals(name))) { whom = CMClass.getMOB("StdMOB"); whom.setName(name); whom.setLocation(mob.location()); } return super.invoke(mob, commands, givenTarget, auto, asLevel); } } final MOB target = getTarget(mob, commands, givenTarget); if (target == null) return false; if (target == mob) { mob.tell(L("You may not compose an ode about yourself!")); return false; } final boolean success = proficiencyCheck(mob, 0, auto); if (success) { unsingAll(mob, mob); invoker = mob; originRoom = mob.location(); commonRoomSet = getInvokerScopeRoomSet(null); whom = target; final String str = L("^S<S-NAME> begin(s) to compose an @x1.^?", songOf()); final CMMsg msg = CMClass.getMsg( mob, null, this, (auto ? CMMsg.MASK_ALWAYS : 0) | CMMsg.MSG_DELICATE_SMALL_HANDS_ACT, str); if (mob.location().okMessage(mob, msg)) { mob.location().send(mob, msg); invoker = mob; final Song_Ode newOne = (Song_Ode) copyOf(); newOne.whom = target; newOne.trail = new StringBuffer(""); newOne.song = null; mob.addEffect(newOne); } } else mob.location() .show(mob, null, CMMsg.MSG_NOISE, L("<S-NAME> lose(s) <S-HIS-HER> inspiration.")); return success; }