public void makePuddle(Room R, int oldWeather, int newWeather) { for (int i = 0; i < R.numItems(); i++) { final Item I = R.getItem(i); if ((I instanceof Drink) && (!CMLib.flags().isGettable(I)) && ((I.name().toLowerCase().indexOf("puddle") >= 0) || (I.name().toLowerCase().indexOf("snow") >= 0))) return; } final Item I = CMClass.getItem("GenLiquidResource"); CMLib.flags().setGettable(I, false); ((Drink) I).setLiquidHeld(100); ((Drink) I).setLiquidRemaining(100); ((Drink) I).setLiquidType(RawMaterial.RESOURCE_FRESHWATER); I.setMaterial(RawMaterial.RESOURCE_FRESHWATER); I.basePhyStats().setDisposition(I.basePhyStats().disposition() | PhyStats.IS_UNSAVABLE); CMLib.materials().addEffectsToResource(I); I.recoverPhyStats(); if (coldWetWeather(oldWeather)) { I.setName(L("some snow")); I.setDisplayText(L("some snow rests on the ground here.")); I.setDescription(L("the snow is white and still quite cold!")); } else { I.setName(L("a puddle of water")); I.setDisplayText(L("a puddle of water has formed here.")); I.setDescription(L("It looks drinkable.")); } R.addItem(I, ItemPossessor.Expire.Monster_EQ); R.recoverRoomStats(); }
@Override public boolean 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; }
private void fillCheckDeviations(Room R, String type, Vector<Environmental> check) { if (type.equalsIgnoreCase("mobs") || type.equalsIgnoreCase("both")) { for (int m = 0; m < R.numInhabitants(); m++) { final MOB M = R.fetchInhabitant(m); if ((M != null) && (M.isSavable()) && (!alreadyDone(M, check))) check.add(M); } } if (type.equalsIgnoreCase("items") || type.equalsIgnoreCase("both")) { for (int i = 0; i < R.numItems(); i++) { final Item I = R.getItem(i); if ((I != null) && ((I instanceof Armor) || (I instanceof Weapon)) && (!alreadyDone(I, check))) check.add(I); } for (int m = 0; m < R.numInhabitants(); m++) { final MOB M = R.fetchInhabitant(m); if (M != null) { for (int i = 0; i < M.numItems(); i++) { final Item I = M.getItem(i); if ((I != null) && ((I instanceof Armor) || (I instanceof Weapon)) && (!alreadyDone(I, check))) check.add(I); } final ShopKeeper SK = CMLib.coffeeShops().getShopKeeper(M); if (SK != null) { for (final Iterator<Environmental> i = SK.getShop().getStoreInventory(); i.hasNext(); ) { final Environmental E2 = i.next(); if (E2 instanceof Item) { final Item I = (Item) E2; if (((I instanceof Armor) || (I instanceof Weapon)) && (!alreadyDone(I, check))) check.add(I); } } } } } } }
public void extinguish(MOB source, Environmental target, boolean mundane) { if (target instanceof Room) { Room R = (Room) target; for (int m = 0; m < R.numInhabitants(); m++) { MOB M = R.fetchInhabitant(m); if (M != null) extinguish(source, M, mundane); } for (int i = 0; i < R.numItems(); i++) { Item I = R.fetchItem(i); if (I != null) extinguish(source, I, mundane); } return; } for (int a = target.numEffects() - 1; a >= 0; a--) { Ability A = target.fetchEffect(a); if ((A != null) && ((!mundane) || ((A.classificationCode() & Ability.ALL_ACODES) == Ability.ACODE_PROPERTY))) { if ((CMath.bset(A.flags(), Ability.FLAG_HEATING) && (!mundane)) || (CMath.bset(A.flags(), Ability.FLAG_FIREBASED)) || ((A.ID().equalsIgnoreCase("Spell_SummonElemental") && A.text().toUpperCase().indexOf("FIRE") >= 0))) A.unInvoke(); } } if ((target instanceof MOB) && (!mundane)) { MOB tmob = (MOB) target; if (tmob.charStats().getMyRace().ID().equals("FireElemental")) CMLib.combat().postDeath(source, (MOB) target, null); for (int i = 0; i < tmob.inventorySize(); i++) { Item I = tmob.fetchInventory(i); if (I != null) extinguish(tmob, I, mundane); } } if ((target instanceof Light) && (((Light) target).isLit())) { ((Light) target).tick(target, Tickable.TICKID_LIGHT_FLICKERS); ((Light) target).light(false); } }
@Override public boolean tick(Tickable ticking, int tickID) { if (!super.tick(ticking, tickID)) return false; if (tickID != Tickable.TICKID_MOB) return true; if (affected == null) return false; if (--fallTickDown > 0) return true; fallTickDown = 1; int direction = Directions.DOWN; String addStr = L("down"); if (reversed()) { direction = Directions.UP; addStr = L("upwards"); } if (affected instanceof MOB) { final MOB mob = (MOB) affected; if (mob == null) return false; if (mob.location() == null) return false; if (CMLib.flags().isInFlight(mob)) { damageToTake = 0; unInvoke(); return false; } else if (!canFallFrom(mob.location(), direction)) return stopFalling(mob); else { if (mob.phyStats().weight() < 1) { mob.tell(L("\n\r\n\rYou are floating gently @x1.\n\r\n\r", addStr)); } else { mob.tell(L("\n\r\n\rYOU ARE FALLING @x1!!\n\r\n\r", addStr.toUpperCase())); int damage = CMLib.dice() .roll( 1, (int) Math.round( CMath.mul( CMath.mul(mob.maxState().getHitPoints(), 0.1), CMath.div(mob.baseWeight(), 150.0))), 0); if (damage > (mob.maxState().getHitPoints() / 3)) damage = (mob.maxState().getHitPoints() / 3); damageToTake = reversed() ? damage : (damageToTake + damage); } temporarilyDisable = true; CMLib.tracking().walk(mob, direction, false, false); temporarilyDisable = false; if (!canFallFrom(mob.location(), direction)) return stopFalling(mob); return true; } } else if (affected instanceof Item) { final Item item = (Item) affected; if ((room == null) && (item.owner() != null) && (item.owner() instanceof Room)) room = (Room) item.owner(); if ((room == null) || ((room != null) && (!room.isContent(item))) || (!CMLib.flags().isGettable(item)) || (item.container() != null) || (CMLib.flags().isInFlight(item.ultimateContainer(null))) || (room.getRoomInDir(direction) == null)) { unInvoke(); return false; } if (room.numItems() > 100) { fallTickDown = CMLib.dice().roll(1, room.numItems() / 50, 0); if ((--fallTickDown) > 0) return true; } final Room nextRoom = room.getRoomInDir(direction); if (canFallFrom(room, direction)) { room.show(invoker, null, item, CMMsg.MSG_OK_ACTION, L("<O-NAME> falls @x1.", addStr)); nextRoom.moveItemTo(item, ItemPossessor.Expire.Player_Drop); room = nextRoom; nextRoom.show( invoker, null, item, CMMsg.MSG_OK_ACTION, L("<O-NAME> falls in from @x1.", (reversed() ? "below" : "above"))); return true; } if (reversed()) return true; unInvoke(); return false; } return false; }
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; }