Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public final boolean poll(boolean insideStructure, boolean deeded, long seed) {
- boolean decayed = false;
- boolean templateId = true;
- int var28 = this.getTemplateId();
- if(Feature.FREE_ITEMS.isEnabled() && this.isChallengeNewbieItem() && (this.isArmour() || this.isWeapon() || this.isShield()) && this.ownerId == -10L) {
- Items.destroyItem(this.getWurmId());
- return true;
- } else {
- if(var28 == 339 && ArtifactBehaviour.getOrbActivation() > 0L && System.currentTimeMillis() - ArtifactBehaviour.getOrbActivation() > 21000L && WurmCalendar.currentTime - this.getData() < 360000L) {
- ArtifactBehaviour.resetOrbActivation();
- Server.getInstance().broadCastMessage("A deadly field surges through the air from the location of the " + this.getName() + "!", this.getTileX(), this.getTileY(), this.isOnSurface(), 25);
- ArtifactBehaviour.markOrbRecipients((Creature)null, false, this.getPosX(), this.getPosY(), this.getPosZ());
- }
- if(this.hatching) {
- return this.pollHatching();
- } else {
- int xx;
- boolean yy;
- int tttype;
- int var31;
- int var33;
- Item var36;
- if(this.template.getDecayTime() != 9223372036854775807L) {
- long x;
- boolean var34;
- boolean var35;
- Item var38;
- if(!this.isHollow() && !this.isFood() && !this.isAlwaysPoll()) {
- if(!this.hasNoDecay() && (WurmCalendar.currentTime > this.creationDate + 1382400L || this.template.getDecayTime() < 3600L)) {
- var28 = this.getTemplateId();
- x = this.template.getDecayTime();
- if(var28 == 386) {
- try {
- x = ItemTemplateFactory.getInstance().getTemplate(this.realTemplate).getDecayTime();
- } catch (NoSuchTemplateException var22) {
- logger.log(Level.INFO, "No template for " + this.getName() + ", id=" + this.realTemplate);
- }
- }
- float var30 = 0.5F;
- if(x == 28800L) {
- if(this.damage == 0.0F) {
- x = 1382400L + (long)(28800.0F * Math.max(1.0F, this.qualityLevel / 3.0F));
- } else {
- x = (long)(28800.0F * Math.max(1.0F, this.qualityLevel / 3.0F));
- }
- var30 = 1.0F;
- }
- if(!this.isBulk()) {
- if(deeded) {
- x *= 2L;
- }
- if(insideStructure) {
- x *= 2L;
- }
- }
- x = (long)((float)x * this.getDecayMultByParents(this));
- var31 = (int)((WurmCalendar.currentTime - this.lastMaintained) / x);
- if(var31 > 0) {
- var34 = true;
- if((this.isSign() || this.isStreetLamp() || this.isFlag()) && this.isPlanted() && deeded) {
- var34 = false;
- }
- if(var34) {
- if(!insideStructure) {
- if(this.template.destroyOnDecay) {
- decayed = this.setDamage(this.damage + (float)(var31 * 10));
- } else {
- decayed = this.setDamage(this.damage + (float)var31 * Math.max(var30, this.getDamageModifier()));
- }
- } else if(this.template.destroyOnDecay) {
- decayed = this.setDamage(this.damage + (float)(var31 * 40));
- } else if(Server.rand.nextInt(deeded?12:8) == 0) {
- if(!this.template.positiveDecay) {
- decayed = this.setDamage(this.damage + (float)var31 * Math.max(var30, this.getDamageModifier()));
- } else {
- if(this.getTemplateId() == 419 || this.getTemplateId() == 420) {
- var38 = null;
- try {
- var38 = this.getParent();
- } catch (NoSuchItemException var21) {
- logger.log(Level.WARNING, "Item " + this.getWurmId() + " had no container when checking for wine barrel bonus.");
- }
- if(var38 != null && var38.getTemplateId() == 768) {
- float var41 = (float)(1 + var38.getRarity());
- if(var38.getMaterial() == 38) {
- var41 += 2.0F;
- }
- }
- }
- this.setQualityLevel(Math.min(100.0F, this.qualityLevel + (100.0F - this.qualityLevel) * (100.0F - this.qualityLevel) / 10000.0F));
- if(this.getTemplateId() == 738) {
- this.checkGnome();
- }
- }
- }
- }
- if(this.isPlantedFlowerpot() && decayed) {
- try {
- var35 = true;
- short var52;
- if(this.isPotteryFlowerPot()) {
- var52 = 813;
- } else if(this.isMarblePlanter()) {
- var52 = 1001;
- } else {
- var52 = -1;
- }
- if(var52 != -1) {
- var36 = ItemFactory.createItem(var52, this.getQualityLevel() * 0.75F, this.creator);
- var36.setPosXYZ(this.getPosX(), this.getPosY(), this.getPosZ());
- VolaTile var48 = Zones.getTileOrNull(this.getTileX(), this.getTileY(), this.isOnSurface());
- if(var48 != null) {
- var48.addItem(var36, false, false);
- }
- }
- } catch (NoSuchTemplateException var19) {
- logger.log(Level.WARNING, var19.getMessage(), var19);
- } catch (FailedException var20) {
- logger.log(Level.WARNING, var20.getMessage(), var20);
- }
- }
- if(!decayed && this.lastMaintained != WurmCalendar.currentTime) {
- this.setLastMaintained(WurmCalendar.currentTime);
- }
- }
- }
- } else {
- x = this.template.getDecayTime();
- if(var28 == 386) {
- try {
- x = ItemTemplateFactory.getInstance().getTemplate(this.realTemplate).getDecayTime();
- } catch (NoSuchTemplateException var27) {
- logger.log(Level.INFO, "No template for " + this.getName() + ", id=" + this.realTemplate);
- }
- }
- if(x == 28800L) {
- if(this.damage == 0.0F) {
- x = 1382400L + (long)(28800.0F * Math.max(1.0F, this.qualityLevel / 3.0F));
- } else {
- x = (long)(28800.0F * Math.max(1.0F, this.qualityLevel / 3.0F));
- }
- }
- x = (long)((float)x * this.getDecayMultByParents(this));
- if(deeded && this.isDecoration() && var28 != 74) {
- x *= 3L;
- }
- xx = (int)((WurmCalendar.currentTime - this.lastMaintained) / x);
- if(this.isHollow()) {
- yy = seed == 1L;
- if(this.items != null) {
- Item[] tile = (Item[])this.items.toArray(new Item[this.items.size()]);
- tttype = 0;
- boolean theTile = var28 == 670;
- long tree = 0L;
- for(int newType = 0; newType < tile.length; ++newType) {
- if(!tile[newType].deleted) {
- if(theTile) {
- if(tree > 0L && tree != tile[newType].getLastOwnerId() && tttype > 0) {
- try {
- Creature lLastOwner = Server.getInstance().getCreature(tree);
- lLastOwner.achievement(160, tttype);
- tttype = 0;
- } catch (Exception var26) {
- ;
- }
- }
- tree = tile[newType].getLastOwnerId();
- if(tile[newType].poll(this, this.getTemperature(), insideStructure, deeded, yy, this.isMagicContainer(), true)) {
- ++tttype;
- }
- } else {
- tile[newType].poll(this, this.getTemperature(), insideStructure, deeded, yy, this.isMagicContainer(), false);
- }
- }
- }
- if(tttype > 0 && tree > 0L) {
- try {
- Creature var54 = Server.getInstance().getCreature(tree);
- var54.achievement(160, tttype);
- var35 = false;
- } catch (Exception var25) {
- ;
- }
- }
- } else if(this.isCorpse()) {
- if(this.getData1() != 67 && this.getData1() != 36 && this.getData1() != 35 && this.getData1() != 34) {
- if(Servers.localServer.isChallengeServer() && this.getData1() != 1 && WurmCalendar.currentTime - this.creationDate > 28800L) {
- decayed = this.setDamage(100.0F);
- }
- } else {
- decayed = this.setDamage(100.0F);
- }
- }
- this.checkDrift();
- }
- this.attackEnemies(false);
- if(this.isSpringFilled()) {
- if(!this.isSourceSpring()) {
- if(Zone.hasSpring(this.getTileX(), this.getTileY()) || this.isAutoFilled()) {
- MethodsItems.fillContainer(this, (Creature)null);
- }
- } else if(Server.rand.nextInt(100) == 0) {
- var31 = this.getFreeVolume();
- var33 = 30 + Server.rand.nextInt(100);
- if(var31 > 0) {
- var38 = null;
- Iterator var45 = this.getItems().iterator();
- while(var45.hasNext()) {
- var36 = (Item)var45.next();
- if(var36.isLiquid()) {
- var38 = var36;
- }
- }
- if(var38 != null) {
- if(var38.getTemplateId() == 763) {
- var38.setWeight(var38.getWeightGrams() + var33, true);
- }
- } else {
- try {
- Random var39 = new Random(this.getWurmId());
- Item var46 = ItemFactory.createItem(763, 80.0F + var39.nextFloat() * 20.0F, "");
- this.insertItem(var46, true);
- } catch (NoSuchTemplateException var23) {
- logger.log(Level.INFO, var23.getMessage(), var23);
- } catch (FailedException var24) {
- logger.log(Level.INFO, var24.getMessage(), var24);
- }
- }
- }
- }
- }
- if(xx > 0 && !decayed && !this.hasNoDecay()) {
- if(var28 == 74 && this.isOnFire()) {
- for(var31 = 0; var31 < xx; ++var31) {
- this.createDaleItems();
- decayed = this.setDamage(this.damage + 1.0F * this.getDamageModifier());
- if(decayed) {
- break;
- }
- }
- if(!decayed && this.lastMaintained != WurmCalendar.currentTime) {
- this.setLastMaintained(WurmCalendar.currentTime);
- }
- return decayed;
- }
- if((var28 != 37 || this.getTemperature() <= 200) && (WurmCalendar.currentTime > this.creationDate + 1382400L || this.isAlwaysPoll() || this.template.getDecayTime() < 3600L || Servers.localServer.isChallengeOrEpicServer() && this.template.destroyOnDecay)) {
- float var32 = 0.5F;
- var34 = true;
- if((this.isSign() || this.isStreetLamp() || this.isFlag()) && this.isPlanted() && deeded) {
- var34 = false;
- }
- if(var34) {
- if(insideStructure) {
- if(this.isFood()) {
- var32 = 1.0F;
- }
- if(this.template.destroyOnDecay) {
- decayed = this.setDamage(this.damage + (float)(xx * 10));
- } else if(Server.rand.nextInt(deeded?12:8) == 0) {
- decayed = this.setDamage(this.damage + (float)xx * Math.max(var32, this.getDamageModifier()));
- }
- } else {
- if(this.isFood()) {
- var32 = 2.0F;
- }
- if(this.template.destroyOnDecay) {
- if(Servers.localServer.isChallengeServer()) {
- decayed = this.setDamage(100.0F);
- } else {
- decayed = this.setDamage(this.damage + (float)(xx * 10));
- }
- } else {
- decayed = this.setDamage(this.damage + (float)xx * Math.max(var32, this.getDamageModifier()));
- }
- }
- } else {
- this.lastMaintained = (long)(WurmCalendar.currentTime + (long)Server.rand.nextInt(10) == 0L?1:0);
- }
- if(!decayed && this.lastMaintained != WurmCalendar.currentTime) {
- this.setLastMaintained(WurmCalendar.currentTime);
- }
- }
- }
- }
- } else if(this.template.hugeAltar) {
- if(this.isHollow()) {
- boolean var37 = true;
- if(this.items != null) {
- Item[] y = (Item[])this.items.toArray(new Item[this.items.size()]);
- for(xx = 0; xx < y.length; ++xx) {
- if(!y[xx].deleted) {
- y[xx].poll(this, this.getTemperature(), insideStructure, deeded, true, true, false);
- }
- }
- }
- }
- this.pollHugeAltar();
- } else if(var28 == 521) {
- if(!this.isOnSurface()) {
- this.setDamage(this.getDamage() + 0.1F);
- logger.log(Level.INFO, this.getName() + " at " + this.getTileX() + ", " + this.getTileY() + " on cave tile. Dealing damage.");
- } else {
- VolaTile var40 = Zones.getTileOrNull(this.getTileX(), this.getTileY(), true);
- if(var40 != null) {
- if(var40.isTransition) {
- this.setDamage(this.getDamage() + 0.1F);
- logger.log(Level.INFO, this.getName() + " at " + this.getTileX() + ", " + this.getTileY() + " on surface transition tile. Dealing damage.");
- }
- } else {
- logger.log(Level.WARNING, this.getName() + " at " + this.getTileX() + ", " + this.getTileY() + " no tile on surface. Zone no. is " + this.getZoneId());
- }
- }
- } else if(var28 == 236) {
- this.checkItemSpawn();
- }
- if(var28 != 74) {
- this.coolOutSideItem(this.isAlwaysPoll(), insideStructure);
- }
- if(var28 == 445 && this.getData() > 0L) {
- try {
- Item var42 = Items.getItem(this.getData());
- if(var42.poll(insideStructure, deeded, seed)) {
- this.setData(0L);
- }
- } catch (NoSuchItemException var18) {
- ;
- }
- }
- int var29;
- int var44;
- if(this.spawnsTrees()) {
- for(var44 = 0; var44 < 10; ++var44) {
- var29 = Zones.safeTileX(this.getTileX() - 18 + Server.rand.nextInt(36));
- xx = Zones.safeTileY(this.getTileY() - 18 + Server.rand.nextInt(36));
- yy = true;
- for(var33 = var29 - 1; var33 <= var29 + 1; ++var33) {
- for(tttype = xx - 1; tttype <= xx + 1; ++tttype) {
- if(Tiles.getTile(Tiles.decodeType(Server.surfaceMesh.getTile(Zones.safeTileX(var33), Zones.safeTileY(tttype)))).isNormalTree()) {
- yy = false;
- break;
- }
- }
- }
- VolaTile var43 = Zones.getTileOrNull(var29, xx, true);
- if(var43 != null) {
- Item[] var57 = var43.getItems();
- Item[] var55 = var57;
- int newData = var57.length;
- for(int var50 = 0; var50 < newData; ++var50) {
- var36 = var55[var50];
- if(var36.isDestroyedOnDecay()) {
- Items.destroyItem(var36.getWurmId());
- }
- }
- }
- if(yy) {
- tttype = Server.surfaceMesh.getTile(var29, xx);
- if((double)Tiles.decodeHeight(tttype) > 0.3D && Tiles.canSpawnTree(Tiles.decodeType(tttype))) {
- int var47 = 8 + Server.rand.nextInt(6);
- byte var53 = (byte)Server.rand.nextInt(9);
- if(TreeType.fromInt(var53).isFruitTree()) {
- var53 = (byte)(var53 + 4);
- }
- byte var49 = (byte)(var47 << 4);
- byte var56 = Tile.TILE_TREE.id;
- if(Feature.SPLIT_TREES.isEnabled()) {
- var56 = TreeType.fromInt(var53).asNormalTree();
- var49 = (byte)(var49 + 1 & 255);
- } else {
- var49 = (byte)(var49 + var53 & 255);
- }
- Server.setSurfaceTile(var29, xx, Tiles.decodeHeight(tttype), var56, var49);
- Players.getInstance().sendChangedTile(var29, xx, true, false);
- }
- }
- }
- }
- if(this.killsTrees()) {
- var44 = Zones.safeTileX(this.getTileX() - 10);
- var29 = Zones.safeTileY(this.getTileY() - 10);
- for(xx = var44; xx <= var44 + 20; ++xx) {
- for(var31 = var29; var31 <= var29 + 20; ++var31) {
- var33 = Server.surfaceMesh.getTile(Zones.safeTileX(xx), Zones.safeTileY(var31));
- byte var58 = Tiles.decodeType(var33);
- Tile var51 = Tiles.getTile(var58);
- if(var51.isNormalTree() || var58 == Tile.TILE_GRASS.id || var58 == Tile.TILE_DIRT.id || var58 == Tile.TILE_KELP.id || var58 == Tile.TILE_REED.id) {
- Server.setSurfaceTile(xx, var31, Tiles.decodeHeight(var33), Tile.TILE_MYCELIUM.id, (byte)0);
- Players.getInstance().sendChangedTile(xx, var31, true, false);
- break;
- }
- }
- }
- }
- if(this.isWind() && !insideStructure && this.getParentId() == -10L && this.isOnSurface() && this.getRotation() != this.ladderRotate(Creature.normalizeAngle(Server.getWeather().getWindRotation() + 180.0F))) {
- this.setRotation(Creature.normalizeAngle(Server.getWeather().getWindRotation() + 180.0F));
- }
- if(!decayed && !insideStructure && this.isFlickering() && this.isOnFire() && Server.rand.nextFloat() * 10.0F < Server.getWeather().getRain()) {
- this.setTemperature((short)200);
- }
- return decayed;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement