Advertisement
Guest User

Untitled

a guest
Jan 20th, 2020
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.46 KB | None | 0 0
  1. public void refreshBonuses() {
  2. bonuses = new int[15];
  3. int mainHandType = player.getEquipment().getWeaponId() == -1 ? Combat.MELEE_TYPE : getType(Equipment.SLOT_WEAPON);
  4. int offHandType = getType(Equipment.SLOT_SHIELD);
  5. int meleeGearArmor = 0;
  6. int rangeGearArmor = 0;
  7. int mageGearArmor = 0;
  8. int allGearArmor = 0;
  9. Item shield = player.getEquipment().getItem(Equipment.SLOT_SHIELD);
  10. boolean hasShield = player.getEquipment().hasShield() && shield.getDefinitions().isShield();
  11. int spellId = getSpellId();
  12. if (spellId < 1 && hasPolyporeStaff(player))
  13. spellId = 65535;
  14. if (spellId > 0) {
  15. mainHandType = Combat.MAGIC_TYPE;
  16. offHandType = Combat.MAGIC_TYPE;
  17. }
  18. val items = player.getEquipment().getItems().getItems();
  19. for (int i = items.length - 1; i >= 0; i--) {
  20. val item = items[i];
  21. if (item == null)
  22. continue;
  23. ItemDefinitions defs = item.getDefinitions();
  24. if (item.getId() == 9705)
  25. defs = ItemDefinitions.getItemDefinitions(857);
  26. if (item.getId() == 9703)
  27. defs = ItemDefinitions.getItemDefinitions(1303);
  28. if (item.getName().equalsIgnoreCase("christmas scythe"))
  29. defs = ItemDefinitions.getItemDefinitions(36333);
  30. if (item.getName().equalsIgnoreCase("soul reaper's blade"))
  31. defs = ItemDefinitions.getItemDefinitions(4587);
  32. if ((item.getName().equalsIgnoreCase("Dominion sword") ||
  33. item.getName().equalsIgnoreCase("Dominion crossbow") || item.getName().equalsIgnoreCase("Dominion staff")) && !DTController.isInsideDominionTower(player))
  34. continue;
  35. if (item.getName().toLowerCase().contains("goliath gloves"))
  36. continue;
  37. if(item.getName().toLowerCase().contains("primal") || item.getName().toLowerCase().contains("sagittarian")
  38. || item.getName().toLowerCase().contains("celestial"))
  39. continue;
  40. int defenderType = defs.getName().toLowerCase().contains(" defender") ? Combat.MELEE_TYPE : defs.getName().toLowerCase().contains(" repriser") ? Combat.RANGE_TYPE :
  41. defs.getName().toLowerCase().contains(" rebounder") || defs.getName().toLowerCase().contains("ancient lantern") ? Combat.MAGIC_TYPE : -1;
  42. int type = getType(i);
  43. if (i != Equipment.SLOT_SHIELD && !(i == Equipment.SLOT_ARROWS && mainHandType == Combat.RANGE_TYPE && player.getEquipment().getItem(Equipment.SLOT_WEAPON).getDefinitions().getCSOpcode(2940) != 0)) {
  44. int damage = (int) (defs.getDamage(mainHandType));
  45. if (i == Equipment.SLOT_ARROWS && item.getId() == 29617 && !Combat.hasDarkbow(player))
  46. damage /= 2;
  47. else if (i == Equipment.SLOT_ARROWS && item.getId() == 28465 && !Combat.hasAscensionCrossbow(player, true))
  48. damage /= 2;
  49. if (i == Equipment.SLOT_ARROWS) { // cap arrows
  50. Item weapon = player.getEquipment().getItem(Equipment.SLOT_WEAPON);
  51. int maxDamage = weapon == null ? 0 : (int) (weapon.getDefinitions().getRangedLevel() * 96);
  52. if (damage > maxDamage)
  53. damage = maxDamage;
  54. }
  55. if (defenderType != -1) {
  56. damage = (int) (damage + (Math.ceil(damage * 0.25)));
  57. }
  58. int accuracy = defs.getAccuracy(mainHandType);
  59. Perk blunted = player.getInventionManager().hasPerk(Perks.BLUNTED);
  60. if (blunted != null)
  61. damage -= (int) ((double) damage * ((double) blunted.getRank() * 0.01));
  62. Perk inaccurate = player.getInventionManager().hasPerk(Perks.INACCURATE);
  63. if (inaccurate != null)
  64. accuracy -= (int) ((double) accuracy * ((double) inaccurate.getRank() * 0.01));
  65.  
  66. bonuses[MAINHAND_DAMAGE] += damage;
  67. bonuses[MAINHAND_ACCURACY] += accuracy;
  68. }
  69. if (!hasShield && i != Equipment.SLOT_WEAPON && !(i == Equipment.SLOT_ARROWS && offHandType == Combat.RANGE_TYPE && player.getEquipment().getItem(Equipment.SLOT_SHIELD).getDefinitions().getCSOpcode(2940) != 0)) {
  70. int damage = (int) (defs.getDamage(offHandType) / 2);
  71. if (i == Equipment.SLOT_ARROWS && item.getId() == 29617 && !Combat.hasDarkbow(player))
  72. damage /= 2;
  73. else if (i == Equipment.SLOT_ARROWS && item.getId() == 28465 && !Combat.hasAscensionCrossbow(player, false))
  74. damage /= 2;
  75. if (i == Equipment.SLOT_ARROWS) { // cap arrows
  76. Item weapon = player.getEquipment().getItem(Equipment.SLOT_SHIELD);
  77. int maxDamage = weapon == null ? 0 : (int) (weapon.getDefinitions().getRangedLevel() * 96);
  78. if (damage > maxDamage)
  79. damage = maxDamage;
  80. }
  81.  
  82. if (defenderType != -1) {
  83. damage = (int) (damage + (Math.ceil(damage * 0.25)));
  84. }
  85. int accuracy = defs.getAccuracy(offHandType);
  86. Perk blunted = player.getInventionManager().hasPerk(Perks.BLUNTED);
  87. if (blunted != null)
  88. damage -= (int) ((double) damage * ((double) blunted.getRank() * 0.01));
  89. Perk inaccurate = player.getInventionManager().hasPerk(Perks.INACCURATE);
  90. if (inaccurate != null)
  91. accuracy -= (int) ((double) accuracy * ((double) inaccurate.getRank() * 0.01));
  92. if ((!Settings.DUAL_COMBAT && i == Equipment.SLOT_SHIELD) || (Settings.DUAL_COMBAT)) {
  93. bonuses[OFFHAND_DAMAGE] += damage;
  94. bonuses[OFFHAND_ACCURACY] += accuracy;
  95. }
  96. }
  97. bonuses[LIFE_B] += defs.getHealth() / 10;
  98. bonuses[PRAYER_B] += defs.getPrayerBonus();
  99. int armor = defs.getArmor();
  100. if (armor > 0) {
  101. bonuses[WORN_ARMOUR] += armor;
  102.  
  103. if (type != Combat.ALL_TYPE && (i == Equipment.SLOT_CHEST || i == Equipment.SLOT_LEGS || i == Equipment.SLOT_FEET || i == Equipment.SLOT_HANDS || i == Equipment.SLOT_HAT || (i == Equipment.SLOT_SHIELD && !hasShield)) && player.getEquipment().getWeaponId() != -1 && type != mainHandType) {
  104. if (mainHandType == Combat.MELEE_TYPE)
  105. bonuses[MELEE_ACCURACY_PENALTY] += armor * (mainHandType == Combat.RANGE_TYPE ? 1.5 : 0.8);
  106. else if (mainHandType == Combat.RANGE_TYPE)
  107. bonuses[RANGE_ACCURACY_PENALTY] += armor * (mainHandType == Combat.MAGIC_TYPE ? 1.5 : 0.8);
  108. else if (mainHandType == Combat.MAGIC_TYPE)
  109. bonuses[MAGE_ACCURACY_PENALTY] += armor * (mainHandType == Combat.MELEE_TYPE ? 1.5 : 0.8);
  110. }
  111. if (type == Combat.ALL_TYPE) {
  112. allGearArmor += armor;
  113. } else if (type == Combat.MELEE_TYPE) {
  114. meleeGearArmor += armor;
  115. } else if (type == Combat.RANGE_TYPE) {
  116. rangeGearArmor += armor;
  117. } else if (type == Combat.MAGIC_TYPE) {
  118. mageGearArmor += armor;
  119. }
  120. }
  121. }
  122. if (player.getEquipment().getWeaponId() == -1 && !player.getEquipment().hasOffHand()) {
  123. Item gloves = player.getEquipment().getItem(Equipment.SLOT_HANDS);
  124. if (gloves != null && gloves.getDefinitions().getName().toLowerCase().contains("goliath gloves")) {
  125. bonuses[MAINHAND_DAMAGE] += 10800;
  126. bonuses[MAINHAND_ACCURACY] += 1694;
  127. }
  128. }
  129. if (!Settings.DUAL_COMBAT) {
  130. bonuses[MAINHAND_DAMAGE] += bonuses[OFFHAND_DAMAGE];
  131. bonuses[MAINHAND_ACCURACY] = Math.max(bonuses[MAINHAND_ACCURACY], bonuses[OFFHAND_ACCURACY]);
  132. }
  133. bonuses[MELEE_AFF] = (int) Combat.getArmourAffinity(bonuses[WORN_ARMOUR], mageGearArmor, meleeGearArmor + allGearArmor, rangeGearArmor);
  134. bonuses[RANGE_AFF] = (int) Combat.getArmourAffinity(bonuses[WORN_ARMOUR], meleeGearArmor, rangeGearArmor + allGearArmor, mageGearArmor);
  135. bonuses[MAGIC_AFF] = (int) Combat.getArmourAffinity(bonuses[WORN_ARMOUR], rangeGearArmor, mageGearArmor + allGearArmor, meleeGearArmor);
  136. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement