@Override public boolean invoke( MOB mob, List<String> commands, Physical givenTarget, boolean auto, int asLevel) { final Item target = getTarget(mob, null, givenTarget, commands, Wearable.FILTER_UNWORNONLY); if (target == null) return false; if (!(target instanceof Armor)) { mob.tell(L("@x1 cannot be refitted.", target.name(mob))); return false; } if (!super.invoke(mob, commands, givenTarget, auto, asLevel)) return false; final boolean success = proficiencyCheck( mob, (((mob.phyStats().level() + (2 * getXLEVELLevel(mob))) - target.phyStats().level()) * 5), auto); if (success) { final CMMsg msg = CMClass.getMsg( mob, target, this, verbalCastCode(mob, target, auto), (auto ? "<T-NAME> begins to shimmer!" : "^S<S-NAME> incant(s) at <T-NAMESELF>!^?")); if (mob.location().okMessage(mob, msg)) { mob.location().send(mob, msg); if (target.phyStats().height() == 0) mob.tell(L("Nothing happens to @x1.", target.name(mob))); else { mob.location() .show( mob, target, CMMsg.MSG_OK_VISUAL, L("<T-NAME> begin(s) to magically resize itself!")); target.basePhyStats().setHeight(0); } target.recoverPhyStats(); mob.location().recoverRoomStats(); } } else beneficialWordsFizzle( mob, target, L("<S-NAME> incant(s) at <T-NAMESELF>, but nothing happens.")); // return whether it worked return success; }
@Override public boolean invoke(MOB mob, Vector commands, Physical givenTarget, boolean auto, int asLevel) { Item target = null; if ((commands.size() == 0) && (!auto) && (givenTarget == null)) target = Prayer_Sacrifice.getBody(mob.location()); if (target == null) target = getTarget(mob, mob.location(), givenTarget, commands, Wearable.FILTER_UNWORNONLY); if (target == null) return false; if ((!(target instanceof DeadBody)) || (target.rawSecretIdentity().toUpperCase().indexOf("FAKE") >= 0)) { mob.tell(L("You may only desecrate the dead.")); return false; } if ((((DeadBody) target).isPlayerCorpse()) && (!((DeadBody) target).getMobName().equals(mob.Name())) && (((DeadBody) target).hasContent())) { mob.tell(L("You are not allowed to desecrate a players corpse.")); return false; } if (!super.invoke(mob, commands, givenTarget, auto, asLevel)) return false; final boolean success = proficiencyCheck(mob, 0, auto); if (success) { final CMMsg msg = CMClass.getMsg( mob, target, this, verbalCastCode(mob, target, auto), auto ? L("<T-NAME> feel(s) desecrated!") : L("^S<S-NAME> desecrate(s) <T-NAMESELF> before @x1.^?", hisHerDiety(mob))); if (mob.location().okMessage(mob, msg)) { mob.location().send(mob, msg); if (CMLib.flags().isEvil(mob)) { double exp = 5.0; final int levelLimit = CMProps.getIntVar(CMProps.Int.EXPRATE); final int levelDiff = (mob.phyStats().level()) - target.phyStats().level(); if (levelDiff > levelLimit) exp = 0.0; if (exp > 0.0) CMLib.leveler() .postExperience( mob, null, null, (int) Math.round(exp) + super.getXPCOSTLevel(mob), false); } target.destroy(); mob.location().recoverRoomStats(); } } else beneficialWordsFizzle( mob, target, L("<S-NAME> attempt(s) to desecrate <T-NAMESELF>, but fail(s).")); // return whether it worked return success; }
@Override public boolean invoke(MOB mob, Vector commands, Physical givenTarget, boolean auto, int asLevel) { final Item target = getTarget(mob, null, givenTarget, commands, Wearable.FILTER_ANY); if (target == null) return false; if (!target.subjectToWearAndTear()) { mob.tell(L("@x1 cannot be mended.", target.name(mob))); return false; } if (!super.invoke(mob, commands, givenTarget, auto, asLevel)) return false; final boolean success = proficiencyCheck( mob, (((mob.phyStats().level() + (2 * getXLEVELLevel(mob))) - target.phyStats().level()) * 5), auto); if (success) { final CMMsg msg = CMClass.getMsg( mob, target, this, verbalCastCode(mob, target, auto), (auto ? "<T-NAME> begins to shimmer!" : "^S<S-NAME> incant(s) at <T-NAMESELF>!^?")); if (mob.location().okMessage(mob, msg)) { mob.location().send(mob, msg); if (target.usesRemaining() >= 100) mob.tell(L("Nothing happens to @x1.", target.name(mob))); else { mob.location() .show(mob, target, CMMsg.MSG_OK_VISUAL, L("<T-NAME> begin(s) to glow and mend!")); target.setUsesRemaining(100); } target.recoverPhyStats(); mob.location().recoverRoomStats(); } } else beneficialWordsFizzle( mob, target, L("<S-NAME> incant(s) at <T-NAMESELF>, but nothing happens.")); // return whether it worked return success; }
@Override public boolean invoke(MOB mob, Vector commands, Physical givenTarget, boolean auto, int asLevel) { final MOB mobTarget = getTarget(mob, commands, givenTarget, true, false); Item target = getPossibility(mobTarget); if (target == null) target = getTarget(mob, mob.location(), givenTarget, commands, Wearable.FILTER_ANY); if (target == null) return false; if (((target.material() & RawMaterial.MATERIAL_MASK) != RawMaterial.MATERIAL_WOODEN) || (!target.subjectToWearAndTear())) { mob.tell(L("That can't be warped.")); 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> starts warping!") : L("^S<S-NAME> chant(s) at <T-NAMESELF>.^?")); final CMMsg msg2 = CMClass.getMsg(mob, mobTarget, this, verbalCastCode(mob, mobTarget, auto), null); if ((mob.location().okMessage(mob, msg)) && ((mobTarget == null) || (mob.location().okMessage(mob, msg2)))) { mob.location().send(mob, msg); if (mobTarget != null) mob.location().send(mob, msg2); if (msg.value() <= 0) { int damage = 100 + (mob.phyStats().level() + (2 * super.getXLEVELLevel(mob))) - target.phyStats().level(); if (CMLib.flags().isABonusItems(target)) damage = (int) Math.round(CMath.div(damage, 2.0)); target.setUsesRemaining(target.usesRemaining() - damage); if (mobTarget == null) mob.location() .show(mob, target, CMMsg.MSG_OK_VISUAL, L("<T-NAME> begin(s) to twist and warp!")); else mob.location() .show( mobTarget, target, CMMsg.MSG_OK_VISUAL, L("<T-NAME>, possessed by <S-NAME>, twists and warps!")); if (target.usesRemaining() > 0) target.recoverPhyStats(); else { target.setUsesRemaining(100); mob.location().show(mob, target, CMMsg.MSG_OK_VISUAL, L("<T-NAME> is destroyed!")); target.unWear(); target.destroy(); mob.location().recoverRoomStats(); } } } } else return maliciousFizzle(mob, null, L("<S-NAME> chant(s), but nothing happens.")); // return whether it worked return success; }
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 StringBuffer deviations(MOB mob, String rest) { final Vector<String> V = CMParms.parse(rest); if ((V.size() == 0) || ((!V.get(0).equalsIgnoreCase("mobs")) && (!V.get(0).equalsIgnoreCase("items")) && (!V.get(0).equalsIgnoreCase("both")))) return new StringBuffer( "You must specify whether you want deviations on MOBS, ITEMS, or BOTH."); final String type = V.get(0).toLowerCase(); if (V.size() == 1) return new StringBuffer( "You must also specify a mob or item name, or the word room, or the word area."); final Room mobR = mob.location(); Faction useFaction = null; for (final Enumeration<Faction> e = CMLib.factions().factions(); e.hasMoreElements(); ) { final Faction F = e.nextElement(); if (F.showInSpecialReported()) useFaction = F; } final String where = V.get(1).toLowerCase(); final Environmental E = mobR.fetchFromMOBRoomFavorsItems(mob, null, where, Wearable.FILTER_ANY); final Vector<Environmental> check = new Vector<Environmental>(); if (where.equalsIgnoreCase("room")) fillCheckDeviations(mobR, type, check); else if (where.equalsIgnoreCase("area")) { for (final Enumeration<Room> r = mobR.getArea().getFilledCompleteMap(); r.hasMoreElements(); ) { final Room R = r.nextElement(); fillCheckDeviations(R, type, check); } } else if (where.equalsIgnoreCase("world")) { for (final Enumeration<Room> r = CMLib.map().roomsFilled(); r.hasMoreElements(); ) { final Room R = r.nextElement(); fillCheckDeviations(R, type, check); } } else if (E == null) return new StringBuffer("'" + where + "' is an unknown item or mob name."); else if (type.equals("items") && (!(E instanceof Weapon)) && (!(E instanceof Armor))) return new StringBuffer("'" + where + "' is not a weapon or armor item."); else if (type.equals("mobs") && (!(E instanceof MOB))) return new StringBuffer("'" + where + "' is not a MOB."); else if ((!(E instanceof Weapon)) && (!(E instanceof Armor)) && (!(E instanceof MOB))) return new StringBuffer("'" + where + "' is not a MOB, or Weapon, or Item."); else check.add(E); final StringBuffer str = new StringBuffer(""); str.append(L("Deviations Report:\n\r")); final StringBuffer itemResults = new StringBuffer(); final StringBuffer mobResults = new StringBuffer(); for (int c = 0; c < check.size(); c++) { if (check.get(c) instanceof Item) { final Item I = (Item) check.get(c); Weapon W = null; if (I instanceof Weapon) W = (Weapon) I; final Map<String, String> vals = CMLib.itemBuilder() .timsItemAdjustments( I, I.phyStats().level(), I.material(), I.rawLogicalAnd() ? 2 : 1, (W == null) ? 0 : W.weaponClassification(), I.maxRange(), I.rawProperLocationBitmap()); itemResults.append(CMStrings.padRight(I.name(), 20) + " "); itemResults.append(CMStrings.padRight(I.ID(), 10) + " "); itemResults.append(CMStrings.padRight("" + I.phyStats().level(), 4) + " "); itemResults.append( CMStrings.padRight( "" + getDeviation(I.basePhyStats().attackAdjustment(), vals, "ATTACK"), 5) + " "); itemResults.append( CMStrings.padRight("" + getDeviation(I.basePhyStats().damage(), vals, "DAMAGE"), 5) + " "); itemResults.append( CMStrings.padRight("" + getDeviation(I.basePhyStats().damage(), vals, "ARMOR"), 5) + " "); itemResults.append( CMStrings.padRight("" + getDeviation(I.baseGoldValue(), vals, "VALUE"), 5) + " "); itemResults.append( CMStrings.padRight( "" + ((I.phyStats().rejuv() == PhyStats.NO_REJUV) ? " MAX" : "" + I.phyStats().rejuv()), 5) + " "); if (I instanceof Weapon) itemResults.append(CMStrings.padRight("" + I.basePhyStats().weight(), 4)); else itemResults.append( CMStrings.padRight("" + getDeviation(I.basePhyStats().weight(), vals, "WEIGHT"), 4) + " "); if (I instanceof Armor) itemResults.append(CMStrings.padRight("" + ((Armor) I).phyStats().height(), 4)); else itemResults.append(CMStrings.padRight(" - ", 4) + " "); itemResults.append("\n\r"); } else { final MOB M = (MOB) check.get(c); mobResults.append(CMStrings.padRight(M.name(), 20) + " "); mobResults.append(CMStrings.padRight("" + M.phyStats().level(), 4) + " "); mobResults.append( CMStrings.padRight( "" + getDeviation( M.basePhyStats().attackAdjustment(), CMLib.leveler().getLevelAttack(M)), 5) + " "); mobResults.append( CMStrings.padRight( "" + getDeviation( M.basePhyStats().damage(), (int) Math.round( CMath.div( CMLib.leveler().getLevelMOBDamage(M), M.basePhyStats().speed()))), 5) + " "); mobResults.append( CMStrings.padRight( "" + getDeviation( M.basePhyStats().armor(), CMLib.leveler().getLevelMOBArmor(M)), 5) + " "); mobResults.append( CMStrings.padRight( "" + getDeviation( M.basePhyStats().speed(), CMLib.leveler().getLevelMOBSpeed(M)), 5) + " "); mobResults.append( CMStrings.padRight( "" + ((M.phyStats().rejuv() == PhyStats.NO_REJUV) ? " MAX" : "" + M.phyStats().rejuv()), 5) + " "); if (useFaction != null) mobResults.append( CMStrings.padRight( "" + (M.fetchFaction(useFaction.factionID()) == Integer.MAX_VALUE ? "N/A" : "" + M.fetchFaction(useFaction.factionID())), 7) + " "); double value = CMLib.beanCounter().getTotalAbsoluteNativeValue(M); double[] range = CMLib.leveler().getLevelMoneyRange(M); if (value < range[0]) mobResults.append(CMStrings.padRight("" + getDeviation(value, range[0]), 5) + " "); else if (value > range[1]) mobResults.append(CMStrings.padRight("" + getDeviation(value, range[1]), 5) + " "); else mobResults.append(CMStrings.padRight("0%", 5) + " "); int reallyWornCount = 0; for (int j = 0; j < M.numItems(); j++) { final Item Iw = M.getItem(j); if (!(Iw.amWearingAt(Wearable.IN_INVENTORY))) reallyWornCount++; } mobResults.append(CMStrings.padRight("" + reallyWornCount, 5) + " "); mobResults.append("\n\r"); } } if (itemResults.length() > 0) str.append(itemHeader() + itemResults.toString()); if (mobResults.length() > 0) str.append(mobHeader(useFaction) + mobResults.toString()); return str; }