Advertisement
Guest User

other poll

a guest
Nov 19th, 2015
182
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 12.50 KB | None | 0 0
  1. private boolean poll(Item parent, int parentTemp, boolean insideStructure, boolean deeded, boolean saveLastMaintained, boolean inMagicContainer, boolean inTrashbin) {
  2.         boolean decayed = false;
  3.         if(this.hatching) {
  4.             return this.pollHatching();
  5.         } else if(Feature.FREE_ITEMS.isEnabled() && this.isChallengeNewbieItem() && (this.isArmour() || this.isWeapon() || this.isShield()) && this.ownerId == -10L) {
  6.             Items.destroyItem(this.getWurmId());
  7.             return true;
  8.         } else {
  9.             if(this.template.getDecayTime() == 9223372036854775807L) {
  10.                 if(saveLastMaintained && this.lastMaintained - WurmCalendar.currentTime > 1209600L) {
  11.                     this.setLastMaintained(WurmCalendar.currentTime);
  12.                 }
  13.             } else {
  14.                 boolean decaytimeql = false;
  15.                 int timesSinceLastUsed;
  16.                 int num;
  17.                 long var21;
  18.                 if(!this.isFood() && !this.isHollow() && !this.isAlwaysPoll()) {
  19.                     if(WurmCalendar.currentTime - this.creationDate > 1382400L || inTrashbin || this.template.getDecayTime() < 3600L) {
  20.                         var21 = this.template.getDecayTime();
  21.                         if(this.template.templateId == 386) {
  22.                             try {
  23.                                 var21 = ItemTemplateFactory.getInstance().getTemplate(this.realTemplate).getDecayTime();
  24.                             } catch (NoSuchTemplateException var18) {
  25.                                 logger.log(Level.INFO, "No template for " + this.getName() + ", id=" + this.realTemplate);
  26.                             }
  27.                         }
  28.  
  29.                         if(var21 == 28800L) {
  30.                             if(this.damage == 0.0F) {
  31.                                 var21 = 1382400L + (long)(28800.0F * Math.max(1.0F, this.qualityLevel / 3.0F));
  32.                             } else {
  33.                                 var21 = (long)(28800.0F * Math.max(1.0F, this.qualityLevel / 3.0F));
  34.                             }
  35.  
  36.                             decaytimeql = true;
  37.                         }
  38.  
  39.                         var21 = (long)((float)var21 * this.getDecayMultByParents(this));
  40.                         if(inTrashbin && (!this.isHollow() || !this.isLocked())) {
  41.                             var21 = Math.min(var21, 28800L);
  42.                         }
  43.  
  44.                         timesSinceLastUsed = (int)((WurmCalendar.currentTime - this.lastMaintained) / var21);
  45.                         if(timesSinceLastUsed > 0) {
  46.                             if(inTrashbin && (!this.isHollow() || !this.isLocked())) {
  47.                                 if(this.getDamage() > 0.0F) {
  48.                                     Items.destroyItem(this.getWurmId());
  49.                                     return true;
  50.                                 } else {
  51.                                     return this.setDamage(this.getDamage() + 0.1F);
  52.                                 }
  53.                             }
  54.  
  55.                             num = 2;
  56.                             if(!this.isBulk() && this.template.templateId != 74) {
  57.                                 if(insideStructure && !this.template.positiveDecay) {
  58.                                     num = 10;
  59.                                 }
  60.  
  61.                                 if(deeded) {
  62.                                     num += 4;
  63.                                 }
  64.                             }
  65.  
  66.                             if(decaytimeql || this.isBulkItem() || Server.rand.nextInt(num) == 0) {
  67.                                 if(this.template.positiveDecay && !inTrashbin) {
  68.                                     this.setQualityLevel(Math.min(100.0F, this.qualityLevel + (100.0F - this.qualityLevel) * (100.0F - this.qualityLevel) / 10000.0F));
  69.                                     if(this.getTemplateId() == 738) {
  70.                                         this.checkGnome();
  71.                                     }
  72.                                 } else if(this.isMagicContainer() || !inMagicContainer) {
  73.                                     if(this.template.destroyOnDecay) {
  74.                                         decayed = this.setDamage(this.damage + (float)(timesSinceLastUsed * 10));
  75.                                     } else if(this.isBulkItem() && this.getBulkNums() > 0) {
  76.                                         try {
  77.                                             ItemTemplate var22 = ItemTemplateFactory.getInstance().getTemplate(this.getRealTemplateId());
  78.                                             if(this.getWeightGrams() < var22.getVolume()) {
  79.                                                 Items.destroyItem(this.getWurmId());
  80.                                                 decayed = true;
  81.                                             } else {
  82.                                                 float var23 = 0.05F;
  83.                                                 decayed = this.setWeight((int)((float)this.getWeightGrams() - (float)(this.getWeightGrams() * timesSinceLastUsed) * 0.05F), true);
  84.                                             }
  85.                                         } catch (NoSuchTemplateException var17) {
  86.                                             Items.destroyItem(this.getWurmId());
  87.                                             decayed = true;
  88.                                         }
  89.                                     } else {
  90.                                         decayed = this.setDamage(this.damage + (float)timesSinceLastUsed * Math.max(1.0F, this.getDamageModifier()));
  91.                                     }
  92.                                 }
  93.                             }
  94.  
  95.                             if(!decayed && this.lastMaintained != WurmCalendar.currentTime) {
  96.                                 this.setLastMaintained(WurmCalendar.currentTime);
  97.                             }
  98.                         }
  99.                     }
  100.                 } else {
  101.                     if(this.template.templateId == 339 && ArtifactBehaviour.getOrbActivation() > 0L && System.currentTimeMillis() - ArtifactBehaviour.getOrbActivation() > 21000L && WurmCalendar.currentTime - this.getData() < 360000L) {
  102.                         ArtifactBehaviour.resetOrbActivation();
  103.                         Server.getInstance().broadCastMessage("A deadly field surges through the air from the location of the " + this.getName() + "!", this.getTileX(), this.getTileY(), this.isOnSurface(), 25);
  104.                         ArtifactBehaviour.markOrbRecipients((Creature)null, false, this.getPosX(), this.getPosY(), this.getPosZ());
  105.                     }
  106.  
  107.                     if(this.isHollow() && this.items != null) {
  108.                         Item[] decayt = (Item[])this.items.toArray(new Item[this.items.size()]);
  109.  
  110.                         for(int x = 0; x < decayt.length; ++x) {
  111.                             if(!decayt[x].deleted) {
  112.                                 decayt[x].poll(this, this.getTemperature(), insideStructure, deeded, saveLastMaintained, inMagicContainer || this.isMagicContainer(), false);
  113.                             }
  114.                         }
  115.                     }
  116.  
  117.                     if(WurmCalendar.currentTime > this.creationDate + 1382400L || inTrashbin || this.template.getDecayTime() < 3600L) {
  118.                         var21 = this.template.getDecayTime();
  119.                         if(this.template.templateId == 386) {
  120.                             try {
  121.                                 var21 = ItemTemplateFactory.getInstance().getTemplate(this.realTemplate).getDecayTime();
  122.                             } catch (NoSuchTemplateException var20) {
  123.                                 logger.log(Level.INFO, "No template for " + this.getName() + ", id=" + this.realTemplate);
  124.                             }
  125.                         }
  126.  
  127.                         if(var21 == 28800L) {
  128.                             if(this.damage == 0.0F) {
  129.                                 var21 = 1382400L + (long)(28800.0F * Math.max(1.0F, this.qualityLevel / 3.0F));
  130.                             } else {
  131.                                 var21 = (long)(28800.0F * Math.max(1.0F, this.qualityLevel / 3.0F));
  132.                             }
  133.  
  134.                             decaytimeql = true;
  135.                         }
  136.  
  137.                         var21 = (long)((float)var21 * this.getDecayMultByParents(this));
  138.                         if(inTrashbin && (!this.isHollow() || !this.isLocked())) {
  139.                             var21 = Math.min(var21, 28800L);
  140.                         }
  141.  
  142.                         timesSinceLastUsed = (int)((WurmCalendar.currentTime - this.lastMaintained) / var21);
  143.                         if(timesSinceLastUsed > 0) {
  144.                             if(inTrashbin && (!this.isHollow() || !this.isLocked())) {
  145.                                 if(this.getDamage() > 0.0F) {
  146.                                     Items.destroyItem(this.getWurmId());
  147.                                     return true;
  148.                                 }
  149.  
  150.                                 return this.setDamage(this.getDamage() + 0.1F);
  151.                             }
  152.  
  153.                             num = 2;
  154.                             float nst = 0.5F;
  155.                             if(this.isFood()) {
  156.                                 nst = 1.0F;
  157.                             }
  158.  
  159.                             if(!this.isBulk() && this.template.templateId != 74 && !this.isLight()) {
  160.                                 if(insideStructure) {
  161.                                     num = 10;
  162.                                 }
  163.  
  164.                                 if(deeded) {
  165.                                     num += 4;
  166.                                 }
  167.                             }
  168.  
  169.                             if(decaytimeql || this.isBulkItem() || Server.rand.nextInt(num) == 0) {
  170.                                 if(this.template.positiveDecay) {
  171.                                     this.setQualityLevel(Math.min(100.0F, this.qualityLevel + (100.0F - this.qualityLevel) * (100.0F - this.qualityLevel) / 10000.0F));
  172.                                     if(this.getTemplateId() == 738) {
  173.                                         this.checkGnome();
  174.                                     }
  175.                                 } else if(this.isMagicContainer() || !inMagicContainer || this.isLight() && this.isOnFire()) {
  176.                                     if(this.isLight() && this.isOnFire()) {
  177.                                         this.pollLightSource();
  178.                                     }
  179.  
  180.                                     if(this.template.destroyOnDecay) {
  181.                                         decayed = this.setDamage(this.damage + (float)(timesSinceLastUsed * 10));
  182.                                     } else if(this.isBulkItem() && this.getBulkNums() > 0) {
  183.                                         try {
  184.                                             ItemTemplate mod = ItemTemplateFactory.getInstance().getTemplate(this.getRealTemplateId());
  185.                                             if(this.getWeightGrams() < mod.getVolume()) {
  186.                                                 Items.destroyItem(this.getWurmId());
  187.                                                 decayed = true;
  188.                                             } else {
  189.                                                 float mod1 = 0.05F;
  190.                                                 decayed = this.setWeight((int)((float)this.getWeightGrams() - (float)(this.getWeightGrams() * timesSinceLastUsed) * 0.05F), true);
  191.                                             }
  192.                                         } catch (NoSuchTemplateException var19) {
  193.                                             Items.destroyItem(this.getWurmId());
  194.                                             decayed = true;
  195.                                         }
  196.                                     } else {
  197.                                         decayed = this.setDamage(this.damage + (float)timesSinceLastUsed * Math.max(nst, this.getDamageModifier()));
  198.                                     }
  199.                                 }
  200.                             }
  201.  
  202.                             if(!decayed && this.lastMaintained != WurmCalendar.currentTime) {
  203.                                 this.setLastMaintained(WurmCalendar.currentTime);
  204.                             }
  205.                         }
  206.                     }
  207.                 }
  208.             }
  209.  
  210.             if(!decayed) {
  211.                 this.modTemp(parent, parentTemp, insideStructure);
  212.             }
  213.  
  214.             return decayed;
  215.         }
  216.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement