Advertisement
Guest User

poll

a guest
Nov 17th, 2015
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 25.42 KB | None | 0 0
  1. public final boolean poll(boolean insideStructure, boolean deeded, long seed) {
  2. boolean decayed = false;
  3. boolean templateId = true;
  4. int var28 = this.getTemplateId();
  5. 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(var28 == 339 && ArtifactBehaviour.getOrbActivation() > 0L && System.currentTimeMillis() - ArtifactBehaviour.getOrbActivation() > 21000L && WurmCalendar.currentTime - this.getData() < 360000L) {
  10. ArtifactBehaviour.resetOrbActivation();
  11. Server.getInstance().broadCastMessage("A deadly field surges through the air from the location of the " + this.getName() + "!", this.getTileX(), this.getTileY(), this.isOnSurface(), 25);
  12. ArtifactBehaviour.markOrbRecipients((Creature)null, false, this.getPosX(), this.getPosY(), this.getPosZ());
  13. }
  14.  
  15. if(this.hatching) {
  16. return this.pollHatching();
  17. } else {
  18. int xx;
  19. boolean yy;
  20. int tttype;
  21. int var31;
  22. int var33;
  23. Item var36;
  24. if(this.template.getDecayTime() != 9223372036854775807L) {
  25. long x;
  26. boolean var34;
  27. boolean var35;
  28. Item var38;
  29. if(!this.isHollow() && !this.isFood() && !this.isAlwaysPoll()) {
  30. if(!this.hasNoDecay() && (WurmCalendar.currentTime > this.creationDate + 1382400L || this.template.getDecayTime() < 3600L)) {
  31. var28 = this.getTemplateId();
  32. x = this.template.getDecayTime();
  33. if(var28 == 386) {
  34. try {
  35. x = ItemTemplateFactory.getInstance().getTemplate(this.realTemplate).getDecayTime();
  36. } catch (NoSuchTemplateException var22) {
  37. logger.log(Level.INFO, "No template for " + this.getName() + ", id=" + this.realTemplate);
  38. }
  39. }
  40.  
  41. float var30 = 0.5F;
  42. if(x == 28800L) {
  43. if(this.damage == 0.0F) {
  44. x = 1382400L + (long)(28800.0F * Math.max(1.0F, this.qualityLevel / 3.0F));
  45. } else {
  46. x = (long)(28800.0F * Math.max(1.0F, this.qualityLevel / 3.0F));
  47. }
  48.  
  49. var30 = 1.0F;
  50. }
  51.  
  52. if(!this.isBulk()) {
  53. if(deeded) {
  54. x *= 2L;
  55. }
  56.  
  57. if(insideStructure) {
  58. x *= 2L;
  59. }
  60. }
  61.  
  62. x = (long)((float)x * this.getDecayMultByParents(this));
  63. var31 = (int)((WurmCalendar.currentTime - this.lastMaintained) / x);
  64. if(var31 > 0) {
  65. var34 = true;
  66. if((this.isSign() || this.isStreetLamp() || this.isFlag()) && this.isPlanted() && deeded) {
  67. var34 = false;
  68. }
  69.  
  70. if(var34) {
  71. if(!insideStructure) {
  72. if(this.template.destroyOnDecay) {
  73. decayed = this.setDamage(this.damage + (float)(var31 * 10));
  74. } else {
  75. decayed = this.setDamage(this.damage + (float)var31 * Math.max(var30, this.getDamageModifier()));
  76. }
  77. } else if(this.template.destroyOnDecay) {
  78. decayed = this.setDamage(this.damage + (float)(var31 * 40));
  79. } else if(Server.rand.nextInt(deeded?12:8) == 0) {
  80. if(!this.template.positiveDecay) {
  81. decayed = this.setDamage(this.damage + (float)var31 * Math.max(var30, this.getDamageModifier()));
  82. } else {
  83. if(this.getTemplateId() == 419 || this.getTemplateId() == 420) {
  84. var38 = null;
  85.  
  86. try {
  87. var38 = this.getParent();
  88. } catch (NoSuchItemException var21) {
  89. logger.log(Level.WARNING, "Item " + this.getWurmId() + " had no container when checking for wine barrel bonus.");
  90. }
  91.  
  92. if(var38 != null && var38.getTemplateId() == 768) {
  93. float var41 = (float)(1 + var38.getRarity());
  94. if(var38.getMaterial() == 38) {
  95. var41 += 2.0F;
  96. }
  97. }
  98. }
  99.  
  100. this.setQualityLevel(Math.min(100.0F, this.qualityLevel + (100.0F - this.qualityLevel) * (100.0F - this.qualityLevel) / 10000.0F));
  101. if(this.getTemplateId() == 738) {
  102. this.checkGnome();
  103. }
  104. }
  105. }
  106. }
  107.  
  108. if(this.isPlantedFlowerpot() && decayed) {
  109. try {
  110. var35 = true;
  111. short var52;
  112. if(this.isPotteryFlowerPot()) {
  113. var52 = 813;
  114. } else if(this.isMarblePlanter()) {
  115. var52 = 1001;
  116. } else {
  117. var52 = -1;
  118. }
  119.  
  120. if(var52 != -1) {
  121. var36 = ItemFactory.createItem(var52, this.getQualityLevel() * 0.75F, this.creator);
  122. var36.setPosXYZ(this.getPosX(), this.getPosY(), this.getPosZ());
  123. VolaTile var48 = Zones.getTileOrNull(this.getTileX(), this.getTileY(), this.isOnSurface());
  124. if(var48 != null) {
  125. var48.addItem(var36, false, false);
  126. }
  127. }
  128. } catch (NoSuchTemplateException var19) {
  129. logger.log(Level.WARNING, var19.getMessage(), var19);
  130. } catch (FailedException var20) {
  131. logger.log(Level.WARNING, var20.getMessage(), var20);
  132. }
  133. }
  134.  
  135. if(!decayed && this.lastMaintained != WurmCalendar.currentTime) {
  136. this.setLastMaintained(WurmCalendar.currentTime);
  137. }
  138. }
  139. }
  140. } else {
  141. x = this.template.getDecayTime();
  142. if(var28 == 386) {
  143. try {
  144. x = ItemTemplateFactory.getInstance().getTemplate(this.realTemplate).getDecayTime();
  145. } catch (NoSuchTemplateException var27) {
  146. logger.log(Level.INFO, "No template for " + this.getName() + ", id=" + this.realTemplate);
  147. }
  148. }
  149.  
  150. if(x == 28800L) {
  151. if(this.damage == 0.0F) {
  152. x = 1382400L + (long)(28800.0F * Math.max(1.0F, this.qualityLevel / 3.0F));
  153. } else {
  154. x = (long)(28800.0F * Math.max(1.0F, this.qualityLevel / 3.0F));
  155. }
  156. }
  157.  
  158. x = (long)((float)x * this.getDecayMultByParents(this));
  159. if(deeded && this.isDecoration() && var28 != 74) {
  160. x *= 3L;
  161. }
  162.  
  163. xx = (int)((WurmCalendar.currentTime - this.lastMaintained) / x);
  164. if(this.isHollow()) {
  165. yy = seed == 1L;
  166. if(this.items != null) {
  167. Item[] tile = (Item[])this.items.toArray(new Item[this.items.size()]);
  168. tttype = 0;
  169. boolean theTile = var28 == 670;
  170. long tree = 0L;
  171.  
  172. for(int newType = 0; newType < tile.length; ++newType) {
  173. if(!tile[newType].deleted) {
  174. if(theTile) {
  175. if(tree > 0L && tree != tile[newType].getLastOwnerId() && tttype > 0) {
  176. try {
  177. Creature lLastOwner = Server.getInstance().getCreature(tree);
  178. lLastOwner.achievement(160, tttype);
  179. tttype = 0;
  180. } catch (Exception var26) {
  181. ;
  182. }
  183. }
  184.  
  185. tree = tile[newType].getLastOwnerId();
  186. if(tile[newType].poll(this, this.getTemperature(), insideStructure, deeded, yy, this.isMagicContainer(), true)) {
  187. ++tttype;
  188. }
  189. } else {
  190. tile[newType].poll(this, this.getTemperature(), insideStructure, deeded, yy, this.isMagicContainer(), false);
  191. }
  192. }
  193. }
  194.  
  195. if(tttype > 0 && tree > 0L) {
  196. try {
  197. Creature var54 = Server.getInstance().getCreature(tree);
  198. var54.achievement(160, tttype);
  199. var35 = false;
  200. } catch (Exception var25) {
  201. ;
  202. }
  203. }
  204. } else if(this.isCorpse()) {
  205. if(this.getData1() != 67 && this.getData1() != 36 && this.getData1() != 35 && this.getData1() != 34) {
  206. if(Servers.localServer.isChallengeServer() && this.getData1() != 1 && WurmCalendar.currentTime - this.creationDate > 28800L) {
  207. decayed = this.setDamage(100.0F);
  208. }
  209. } else {
  210. decayed = this.setDamage(100.0F);
  211. }
  212. }
  213.  
  214. this.checkDrift();
  215. }
  216.  
  217. this.attackEnemies(false);
  218. if(this.isSpringFilled()) {
  219. if(!this.isSourceSpring()) {
  220. if(Zone.hasSpring(this.getTileX(), this.getTileY()) || this.isAutoFilled()) {
  221. MethodsItems.fillContainer(this, (Creature)null);
  222. }
  223. } else if(Server.rand.nextInt(100) == 0) {
  224. var31 = this.getFreeVolume();
  225. var33 = 30 + Server.rand.nextInt(100);
  226. if(var31 > 0) {
  227. var38 = null;
  228. Iterator var45 = this.getItems().iterator();
  229.  
  230. while(var45.hasNext()) {
  231. var36 = (Item)var45.next();
  232. if(var36.isLiquid()) {
  233. var38 = var36;
  234. }
  235. }
  236.  
  237. if(var38 != null) {
  238. if(var38.getTemplateId() == 763) {
  239. var38.setWeight(var38.getWeightGrams() + var33, true);
  240. }
  241. } else {
  242. try {
  243. Random var39 = new Random(this.getWurmId());
  244. Item var46 = ItemFactory.createItem(763, 80.0F + var39.nextFloat() * 20.0F, "");
  245. this.insertItem(var46, true);
  246. } catch (NoSuchTemplateException var23) {
  247. logger.log(Level.INFO, var23.getMessage(), var23);
  248. } catch (FailedException var24) {
  249. logger.log(Level.INFO, var24.getMessage(), var24);
  250. }
  251. }
  252. }
  253. }
  254. }
  255.  
  256. if(xx > 0 && !decayed && !this.hasNoDecay()) {
  257. if(var28 == 74 && this.isOnFire()) {
  258. for(var31 = 0; var31 < xx; ++var31) {
  259. this.createDaleItems();
  260. decayed = this.setDamage(this.damage + 1.0F * this.getDamageModifier());
  261. if(decayed) {
  262. break;
  263. }
  264. }
  265.  
  266. if(!decayed && this.lastMaintained != WurmCalendar.currentTime) {
  267. this.setLastMaintained(WurmCalendar.currentTime);
  268. }
  269.  
  270. return decayed;
  271. }
  272.  
  273. if((var28 != 37 || this.getTemperature() <= 200) && (WurmCalendar.currentTime > this.creationDate + 1382400L || this.isAlwaysPoll() || this.template.getDecayTime() < 3600L || Servers.localServer.isChallengeOrEpicServer() && this.template.destroyOnDecay)) {
  274. float var32 = 0.5F;
  275. var34 = true;
  276. if((this.isSign() || this.isStreetLamp() || this.isFlag()) && this.isPlanted() && deeded) {
  277. var34 = false;
  278. }
  279.  
  280. if(var34) {
  281. if(insideStructure) {
  282. if(this.isFood()) {
  283. var32 = 1.0F;
  284. }
  285.  
  286. if(this.template.destroyOnDecay) {
  287. decayed = this.setDamage(this.damage + (float)(xx * 10));
  288. } else if(Server.rand.nextInt(deeded?12:8) == 0) {
  289. decayed = this.setDamage(this.damage + (float)xx * Math.max(var32, this.getDamageModifier()));
  290. }
  291. } else {
  292. if(this.isFood()) {
  293. var32 = 2.0F;
  294. }
  295.  
  296. if(this.template.destroyOnDecay) {
  297. if(Servers.localServer.isChallengeServer()) {
  298. decayed = this.setDamage(100.0F);
  299. } else {
  300. decayed = this.setDamage(this.damage + (float)(xx * 10));
  301. }
  302. } else {
  303. decayed = this.setDamage(this.damage + (float)xx * Math.max(var32, this.getDamageModifier()));
  304. }
  305. }
  306. } else {
  307. this.lastMaintained = (long)(WurmCalendar.currentTime + (long)Server.rand.nextInt(10) == 0L?1:0);
  308. }
  309.  
  310. if(!decayed && this.lastMaintained != WurmCalendar.currentTime) {
  311. this.setLastMaintained(WurmCalendar.currentTime);
  312. }
  313. }
  314. }
  315. }
  316. } else if(this.template.hugeAltar) {
  317. if(this.isHollow()) {
  318. boolean var37 = true;
  319. if(this.items != null) {
  320. Item[] y = (Item[])this.items.toArray(new Item[this.items.size()]);
  321.  
  322. for(xx = 0; xx < y.length; ++xx) {
  323. if(!y[xx].deleted) {
  324. y[xx].poll(this, this.getTemperature(), insideStructure, deeded, true, true, false);
  325. }
  326. }
  327. }
  328. }
  329.  
  330. this.pollHugeAltar();
  331. } else if(var28 == 521) {
  332. if(!this.isOnSurface()) {
  333. this.setDamage(this.getDamage() + 0.1F);
  334. logger.log(Level.INFO, this.getName() + " at " + this.getTileX() + ", " + this.getTileY() + " on cave tile. Dealing damage.");
  335. } else {
  336. VolaTile var40 = Zones.getTileOrNull(this.getTileX(), this.getTileY(), true);
  337. if(var40 != null) {
  338. if(var40.isTransition) {
  339. this.setDamage(this.getDamage() + 0.1F);
  340. logger.log(Level.INFO, this.getName() + " at " + this.getTileX() + ", " + this.getTileY() + " on surface transition tile. Dealing damage.");
  341. }
  342. } else {
  343. logger.log(Level.WARNING, this.getName() + " at " + this.getTileX() + ", " + this.getTileY() + " no tile on surface. Zone no. is " + this.getZoneId());
  344. }
  345. }
  346. } else if(var28 == 236) {
  347. this.checkItemSpawn();
  348. }
  349.  
  350. if(var28 != 74) {
  351. this.coolOutSideItem(this.isAlwaysPoll(), insideStructure);
  352. }
  353.  
  354. if(var28 == 445 && this.getData() > 0L) {
  355. try {
  356. Item var42 = Items.getItem(this.getData());
  357. if(var42.poll(insideStructure, deeded, seed)) {
  358. this.setData(0L);
  359. }
  360. } catch (NoSuchItemException var18) {
  361. ;
  362. }
  363. }
  364.  
  365. int var29;
  366. int var44;
  367. if(this.spawnsTrees()) {
  368. for(var44 = 0; var44 < 10; ++var44) {
  369. var29 = Zones.safeTileX(this.getTileX() - 18 + Server.rand.nextInt(36));
  370. xx = Zones.safeTileY(this.getTileY() - 18 + Server.rand.nextInt(36));
  371. yy = true;
  372.  
  373. for(var33 = var29 - 1; var33 <= var29 + 1; ++var33) {
  374. for(tttype = xx - 1; tttype <= xx + 1; ++tttype) {
  375. if(Tiles.getTile(Tiles.decodeType(Server.surfaceMesh.getTile(Zones.safeTileX(var33), Zones.safeTileY(tttype)))).isNormalTree()) {
  376. yy = false;
  377. break;
  378. }
  379. }
  380. }
  381.  
  382. VolaTile var43 = Zones.getTileOrNull(var29, xx, true);
  383. if(var43 != null) {
  384. Item[] var57 = var43.getItems();
  385. Item[] var55 = var57;
  386. int newData = var57.length;
  387.  
  388. for(int var50 = 0; var50 < newData; ++var50) {
  389. var36 = var55[var50];
  390. if(var36.isDestroyedOnDecay()) {
  391. Items.destroyItem(var36.getWurmId());
  392. }
  393. }
  394. }
  395.  
  396. if(yy) {
  397. tttype = Server.surfaceMesh.getTile(var29, xx);
  398. if((double)Tiles.decodeHeight(tttype) > 0.3D && Tiles.canSpawnTree(Tiles.decodeType(tttype))) {
  399. int var47 = 8 + Server.rand.nextInt(6);
  400. byte var53 = (byte)Server.rand.nextInt(9);
  401. if(TreeType.fromInt(var53).isFruitTree()) {
  402. var53 = (byte)(var53 + 4);
  403. }
  404.  
  405. byte var49 = (byte)(var47 << 4);
  406. byte var56 = Tile.TILE_TREE.id;
  407. if(Feature.SPLIT_TREES.isEnabled()) {
  408. var56 = TreeType.fromInt(var53).asNormalTree();
  409. var49 = (byte)(var49 + 1 & 255);
  410. } else {
  411. var49 = (byte)(var49 + var53 & 255);
  412. }
  413.  
  414. Server.setSurfaceTile(var29, xx, Tiles.decodeHeight(tttype), var56, var49);
  415. Players.getInstance().sendChangedTile(var29, xx, true, false);
  416. }
  417. }
  418. }
  419. }
  420.  
  421. if(this.killsTrees()) {
  422. var44 = Zones.safeTileX(this.getTileX() - 10);
  423. var29 = Zones.safeTileY(this.getTileY() - 10);
  424.  
  425. for(xx = var44; xx <= var44 + 20; ++xx) {
  426. for(var31 = var29; var31 <= var29 + 20; ++var31) {
  427. var33 = Server.surfaceMesh.getTile(Zones.safeTileX(xx), Zones.safeTileY(var31));
  428. byte var58 = Tiles.decodeType(var33);
  429. Tile var51 = Tiles.getTile(var58);
  430. if(var51.isNormalTree() || var58 == Tile.TILE_GRASS.id || var58 == Tile.TILE_DIRT.id || var58 == Tile.TILE_KELP.id || var58 == Tile.TILE_REED.id) {
  431. Server.setSurfaceTile(xx, var31, Tiles.decodeHeight(var33), Tile.TILE_MYCELIUM.id, (byte)0);
  432. Players.getInstance().sendChangedTile(xx, var31, true, false);
  433. break;
  434. }
  435. }
  436. }
  437. }
  438.  
  439. if(this.isWind() && !insideStructure && this.getParentId() == -10L && this.isOnSurface() && this.getRotation() != this.ladderRotate(Creature.normalizeAngle(Server.getWeather().getWindRotation() + 180.0F))) {
  440. this.setRotation(Creature.normalizeAngle(Server.getWeather().getWindRotation() + 180.0F));
  441. }
  442.  
  443. if(!decayed && !insideStructure && this.isFlickering() && this.isOnFire() && Server.rand.nextFloat() * 10.0F < Server.getWeather().getRain()) {
  444. this.setTemperature((short)200);
  445. }
  446.  
  447. return decayed;
  448. }
  449. }
  450. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement