Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private boolean poll(Item parent, int parentTemp, boolean insideStructure, boolean deeded, boolean saveLastMaintained, boolean inMagicContainer, boolean inTrashbin) {
- boolean decayed = false;
- if(this.hatching) {
- return this.pollHatching();
- } else if(Feature.FREE_ITEMS.isEnabled() && this.isChallengeNewbieItem() && (this.isArmour() || this.isWeapon() || this.isShield()) && this.ownerId == -10L) {
- Items.destroyItem(this.getWurmId());
- return true;
- } else {
- if(this.template.getDecayTime() == 9223372036854775807L) {
- if(saveLastMaintained && this.lastMaintained - WurmCalendar.currentTime > 1209600L) {
- this.setLastMaintained(WurmCalendar.currentTime);
- }
- } else {
- boolean decaytimeql = false;
- int timesSinceLastUsed;
- int num;
- long var21;
- if(!this.isFood() && !this.isHollow() && !this.isAlwaysPoll()) {
- if(WurmCalendar.currentTime - this.creationDate > 1382400L || inTrashbin || this.template.getDecayTime() < 3600L) {
- var21 = this.template.getDecayTime();
- if(this.template.templateId == 386) {
- try {
- var21 = ItemTemplateFactory.getInstance().getTemplate(this.realTemplate).getDecayTime();
- } catch (NoSuchTemplateException var18) {
- logger.log(Level.INFO, "No template for " + this.getName() + ", id=" + this.realTemplate);
- }
- }
- if(var21 == 28800L) {
- if(this.damage == 0.0F) {
- var21 = 1382400L + (long)(28800.0F * Math.max(1.0F, this.qualityLevel / 3.0F));
- } else {
- var21 = (long)(28800.0F * Math.max(1.0F, this.qualityLevel / 3.0F));
- }
- decaytimeql = true;
- }
- var21 = (long)((float)var21 * this.getDecayMultByParents(this));
- if(inTrashbin && (!this.isHollow() || !this.isLocked())) {
- var21 = Math.min(var21, 28800L);
- }
- timesSinceLastUsed = (int)((WurmCalendar.currentTime - this.lastMaintained) / var21);
- if(timesSinceLastUsed > 0) {
- if(inTrashbin && (!this.isHollow() || !this.isLocked())) {
- if(this.getDamage() > 0.0F) {
- Items.destroyItem(this.getWurmId());
- return true;
- } else {
- return this.setDamage(this.getDamage() + 0.1F);
- }
- }
- num = 2;
- if(!this.isBulk() && this.template.templateId != 74) {
- if(insideStructure && !this.template.positiveDecay) {
- num = 10;
- }
- if(deeded) {
- num += 4;
- }
- }
- if(decaytimeql || this.isBulkItem() || Server.rand.nextInt(num) == 0) {
- if(this.template.positiveDecay && !inTrashbin) {
- this.setQualityLevel(Math.min(100.0F, this.qualityLevel + (100.0F - this.qualityLevel) * (100.0F - this.qualityLevel) / 10000.0F));
- if(this.getTemplateId() == 738) {
- this.checkGnome();
- }
- } else if(this.isMagicContainer() || !inMagicContainer) {
- if(this.template.destroyOnDecay) {
- decayed = this.setDamage(this.damage + (float)(timesSinceLastUsed * 10));
- } else if(this.isBulkItem() && this.getBulkNums() > 0) {
- try {
- ItemTemplate var22 = ItemTemplateFactory.getInstance().getTemplate(this.getRealTemplateId());
- if(this.getWeightGrams() < var22.getVolume()) {
- Items.destroyItem(this.getWurmId());
- decayed = true;
- } else {
- float var23 = 0.05F;
- decayed = this.setWeight((int)((float)this.getWeightGrams() - (float)(this.getWeightGrams() * timesSinceLastUsed) * 0.05F), true);
- }
- } catch (NoSuchTemplateException var17) {
- Items.destroyItem(this.getWurmId());
- decayed = true;
- }
- } else {
- decayed = this.setDamage(this.damage + (float)timesSinceLastUsed * Math.max(1.0F, this.getDamageModifier()));
- }
- }
- }
- if(!decayed && this.lastMaintained != WurmCalendar.currentTime) {
- this.setLastMaintained(WurmCalendar.currentTime);
- }
- }
- }
- } else {
- if(this.template.templateId == 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.isHollow() && this.items != null) {
- Item[] decayt = (Item[])this.items.toArray(new Item[this.items.size()]);
- for(int x = 0; x < decayt.length; ++x) {
- if(!decayt[x].deleted) {
- decayt[x].poll(this, this.getTemperature(), insideStructure, deeded, saveLastMaintained, inMagicContainer || this.isMagicContainer(), false);
- }
- }
- }
- if(WurmCalendar.currentTime > this.creationDate + 1382400L || inTrashbin || this.template.getDecayTime() < 3600L) {
- var21 = this.template.getDecayTime();
- if(this.template.templateId == 386) {
- try {
- var21 = ItemTemplateFactory.getInstance().getTemplate(this.realTemplate).getDecayTime();
- } catch (NoSuchTemplateException var20) {
- logger.log(Level.INFO, "No template for " + this.getName() + ", id=" + this.realTemplate);
- }
- }
- if(var21 == 28800L) {
- if(this.damage == 0.0F) {
- var21 = 1382400L + (long)(28800.0F * Math.max(1.0F, this.qualityLevel / 3.0F));
- } else {
- var21 = (long)(28800.0F * Math.max(1.0F, this.qualityLevel / 3.0F));
- }
- decaytimeql = true;
- }
- var21 = (long)((float)var21 * this.getDecayMultByParents(this));
- if(inTrashbin && (!this.isHollow() || !this.isLocked())) {
- var21 = Math.min(var21, 28800L);
- }
- timesSinceLastUsed = (int)((WurmCalendar.currentTime - this.lastMaintained) / var21);
- if(timesSinceLastUsed > 0) {
- if(inTrashbin && (!this.isHollow() || !this.isLocked())) {
- if(this.getDamage() > 0.0F) {
- Items.destroyItem(this.getWurmId());
- return true;
- }
- return this.setDamage(this.getDamage() + 0.1F);
- }
- num = 2;
- float nst = 0.5F;
- if(this.isFood()) {
- nst = 1.0F;
- }
- if(!this.isBulk() && this.template.templateId != 74 && !this.isLight()) {
- if(insideStructure) {
- num = 10;
- }
- if(deeded) {
- num += 4;
- }
- }
- if(decaytimeql || this.isBulkItem() || Server.rand.nextInt(num) == 0) {
- if(this.template.positiveDecay) {
- this.setQualityLevel(Math.min(100.0F, this.qualityLevel + (100.0F - this.qualityLevel) * (100.0F - this.qualityLevel) / 10000.0F));
- if(this.getTemplateId() == 738) {
- this.checkGnome();
- }
- } else if(this.isMagicContainer() || !inMagicContainer || this.isLight() && this.isOnFire()) {
- if(this.isLight() && this.isOnFire()) {
- this.pollLightSource();
- }
- if(this.template.destroyOnDecay) {
- decayed = this.setDamage(this.damage + (float)(timesSinceLastUsed * 10));
- } else if(this.isBulkItem() && this.getBulkNums() > 0) {
- try {
- ItemTemplate mod = ItemTemplateFactory.getInstance().getTemplate(this.getRealTemplateId());
- if(this.getWeightGrams() < mod.getVolume()) {
- Items.destroyItem(this.getWurmId());
- decayed = true;
- } else {
- float mod1 = 0.05F;
- decayed = this.setWeight((int)((float)this.getWeightGrams() - (float)(this.getWeightGrams() * timesSinceLastUsed) * 0.05F), true);
- }
- } catch (NoSuchTemplateException var19) {
- Items.destroyItem(this.getWurmId());
- decayed = true;
- }
- } else {
- decayed = this.setDamage(this.damage + (float)timesSinceLastUsed * Math.max(nst, this.getDamageModifier()));
- }
- }
- }
- if(!decayed && this.lastMaintained != WurmCalendar.currentTime) {
- this.setLastMaintained(WurmCalendar.currentTime);
- }
- }
- }
- }
- }
- if(!decayed) {
- this.modTemp(parent, parentTemp, insideStructure);
- }
- return decayed;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement