Advertisement
Guest User

pollAge

a guest
Jun 26th, 2017
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.19 KB | None | 0 0
  1. final boolean pollAge(int maxAge)
  2. {
  3. boolean rebornPoll = false;
  4. if ((this.reborn) && (this.mother == -10L)) {
  5. if (WurmCalendar.currentTime - this.lastPolledAge > 604800L) {
  6. rebornPoll = true;
  7. }
  8. }
  9. if ((WurmCalendar.currentTime - this.lastPolledAge > ((Servers.localServer.PVPSERVER) && (this.age < 8) && (this.statusHolder.getTemplate().getTemplateId() == 65) ? 259200L : 2419200L)) || (rebornPoll))
  10. {
  11. if (((this.statusHolder.isGhost()) || (this.statusHolder.isKingdomGuard()) || (this.statusHolder.isUnique())) && ((!this.reborn) || (this.mother == -10L))) {
  12. this.age = Math.max(this.age, 11);
  13. }
  14. int newAge = this.age + 1;
  15. boolean updated = false;
  16. if ((!this.statusHolder.isCaredFor()) && ((newAge >= maxAge) || (
  17. (isTraitBitSet(13)) && (newAge >= Math.max(1, maxAge - Server.rand
  18. .nextInt(maxAge / 2)))))) {
  19. return true;
  20. }
  21. if (!rebornPoll)
  22. {
  23. if (newAge > (isTraitBitSet(21) ? 75 : 50)) {
  24. if ((!this.statusHolder.isGhost()) && (!this.statusHolder.isHuman()) && (!this.statusHolder.isUnique()) &&
  25. (!this.statusHolder.isCaredFor())) {
  26. return true;
  27. }
  28. }
  29. if ((newAge - 1 >= 5) && (!this.reborn)) {
  30. if ((getTemplate().getAdultMaleTemplateId() > -1) ||
  31. (getTemplate().getAdultFemaleTemplateId() > -1))
  32. {
  33. int newtemplateId = getTemplate().getAdultMaleTemplateId();
  34. if ((this.sex == 1) && (getTemplate().getAdultFemaleTemplateId() > -1)) {
  35. newtemplateId = getTemplate().getAdultFemaleTemplateId();
  36. }
  37. if (newtemplateId != getTemplate().getTemplateId())
  38. {
  39. newAge = 1;
  40. try
  41. {
  42. updateAge(newAge);
  43. updated = true;
  44. }
  45. catch (IOException iox)
  46. {
  47. logger.log(Level.WARNING, iox.getMessage(), iox);
  48. }
  49. try
  50. {
  51. setChanged(true);
  52. CreatureTemplate newTemplate = CreatureTemplateFactory.getInstance().getTemplate(newtemplateId);
  53.  
  54. this.template = newTemplate;
  55. this.statusHolder.template = this.template;
  56. if (!this.statusHolder.isNpc())
  57. {
  58. if ((this.statusHolder.getMother() == -10L) || ((!this.statusHolder.isHorse()) && (!this.reborn))) {
  59. try
  60. {
  61. if (this.statusHolder.getName().endsWith("traitor")) {
  62. this.statusHolder.setName(this.template.getName() + " traitor");
  63. } else {
  64. this.statusHolder.setName(this.template.getName());
  65. }
  66. }
  67. catch (Exception ex)
  68. {
  69. logger.log(Level.WARNING, ex.getMessage(), ex);
  70. }
  71. }
  72. if ((!this.reborn) || (this.mother == -10L)) {
  73. try
  74. {
  75. this.statusHolder.skills.delete();
  76. this.statusHolder.skills.clone(newTemplate.getSkills().getSkills());
  77. this.statusHolder.skills.save();
  78. }
  79. catch (Exception ex)
  80. {
  81. logger.log(Level.WARNING, ex.getMessage(), ex);
  82. }
  83. }
  84. }
  85. save();
  86. this.statusHolder.setVisible(false);
  87. this.statusHolder.setVisible(true);
  88. }
  89. catch (NoSuchCreatureTemplateException nsc)
  90. {
  91. logger.log(Level.WARNING, this.statusHolder
  92. .getName() + ", " + this.statusHolder.getWurmId() + ": " + nsc.getMessage(), nsc);
  93. }
  94. catch (IOException iox)
  95. {
  96. logger.log(Level.WARNING, this.statusHolder
  97. .getName() + ", " + this.statusHolder.getWurmId() + ": " + iox.getMessage(), iox);
  98. }
  99. }
  100. }
  101. }
  102. }
  103. if (!updated) {
  104. try
  105. {
  106. updateAge(newAge);
  107. if ((this.statusHolder.getHitched() != null) && (!this.statusHolder.getHitched().isAnySeatOccupied(false))) {
  108. if ((!this.statusHolder.isDomestic()) && (getBattleRatingTypeModifier() > 1.2F))
  109. {
  110. Server.getInstance().broadCastMessage(this.statusHolder.getName() + " stops dragging a " +
  111. Vehicle.getVehicleName(this.statusHolder.getHitched()) + ".", this.statusHolder
  112. .getTileX(), this.statusHolder.getTileY(), this.statusHolder.isOnSurface(), 5);
  113. if (this.statusHolder.getHitched().removeDragger(this.statusHolder)) {
  114. this.statusHolder.setHitched(null, false);
  115. }
  116. }
  117. }
  118. }
  119. catch (IOException iox)
  120. {
  121. logger.log(Level.WARNING, iox.getMessage(), iox);
  122. }
  123. }
  124. }
  125. return false;
  126. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement