Advertisement
VANPER

acis 243 Formulas

Apr 3rd, 2023
364
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.38 KB | None | 0 0
  1. public static final double calcPhysDam(L2Character attacker, L2Character target, L2Skill skill, byte shld, boolean crit, boolean dual, boolean ss)
  2. {
  3. if (attacker instanceof L2PcInstance)
  4. {
  5. L2PcInstance pcInst = (L2PcInstance) attacker;
  6. if (pcInst.isGM() && !pcInst.getAccessLevel().canGiveDamage())
  7. return 0;
  8. }
  9.  
  10. final boolean isPvP = (attacker instanceof L2Playable) && (target instanceof L2Playable);
  11. double damage = attacker.getPAtk(target);
  12. double defence = target.getPDef(attacker);
  13. damage += calcValakasAttribute(attacker, target, skill);
  14.  
  15. switch (shld)
  16. {
  17. case SHIELD_DEFENSE_SUCCEED:
  18. if (!Config.ALT_GAME_SHIELD_BLOCKS)
  19. defence += target.getShldDef();
  20. break;
  21. case SHIELD_DEFENSE_PERFECT_BLOCK: // perfect block
  22. return 1.;
  23. }
  24.  
  25. if (ss)
  26. damage *= 2;
  27.  
  28. if (skill != null)
  29. {
  30. double skillpower = skill.getPower(attacker, target);
  31. float ssboost = skill.getSSBoost();
  32. if (ssboost <= 0)
  33. damage += skillpower;
  34. else if (ssboost > 0)
  35. {
  36. if (ss)
  37. {
  38. skillpower *= ssboost;
  39. damage += skillpower;
  40. }
  41. else
  42. damage += skillpower;
  43. }
  44. }
  45.  
  46. // defence modifier depending of the attacker weapon
  47. L2Weapon weapon = attacker.getActiveWeaponItem();
  48. Stats stat = null;
  49. if (weapon != null)
  50. {
  51. switch (weapon.getItemType())
  52. {
  53. case BOW:
  54. stat = Stats.BOW_WPN_VULN;
  55. break;
  56. case BLUNT:
  57. stat = Stats.BLUNT_WPN_VULN;
  58. break;
  59. case BIGSWORD:
  60. stat = Stats.BIGSWORD_WPN_VULN;
  61. break;
  62. case BIGBLUNT:
  63. stat = Stats.BIGBLUNT_WPN_VULN;
  64. break;
  65. case DAGGER:
  66. stat = Stats.DAGGER_WPN_VULN;
  67. break;
  68. case DUAL:
  69. stat = Stats.DUAL_WPN_VULN;
  70. break;
  71. case DUALFIST:
  72. stat = Stats.DUALFIST_WPN_VULN;
  73. break;
  74. case ETC:
  75. stat = Stats.ETC_WPN_VULN;
  76. break;
  77. case FIST:
  78. stat = Stats.FIST_WPN_VULN;
  79. break;
  80. case POLE:
  81. stat = Stats.POLE_WPN_VULN;
  82. break;
  83. case SWORD:
  84. stat = Stats.SWORD_WPN_VULN;
  85. break;
  86. }
  87. }
  88.  
  89. if (crit)
  90. {
  91. // Finally retail like formula
  92. damage = 2 * attacker.calcStat(Stats.CRITICAL_DAMAGE, 1, target, skill) * target.calcStat(Stats.CRIT_VULN, 1, target, null) * (70 * damage / defence);
  93. // Crit dmg add is almost useless in normal hits...
  94. damage += (attacker.calcStat(Stats.CRITICAL_DAMAGE_ADD, 0, target, skill) * 70 / defence);
  95. }
  96. else
  97. damage = 70 * damage / defence;
  98.  
  99. if (stat != null)
  100. damage = target.calcStat(stat, damage, target, null);
  101.  
  102. // Weapon random damage
  103. damage *= attacker.getRandomDamageMultiplier();
  104.  
  105. if (shld > 0 && Config.ALT_GAME_SHIELD_BLOCKS)
  106. {
  107. damage -= target.getShldDef();
  108. if (damage < 0)
  109. damage = 0;
  110. }
  111.  
  112. if (target instanceof L2Npc)
  113. {
  114. double multiplier;
  115. switch (((L2Npc) target).getTemplate().getRace())
  116. {
  117. case BEAST:
  118. multiplier = 1 + ((attacker.getPAtkMonsters(target) - target.getPDefMonsters(target)) / 100);
  119. damage *= multiplier;
  120. break;
  121. case ANIMAL:
  122. multiplier = 1 + ((attacker.getPAtkAnimals(target) - target.getPDefAnimals(target)) / 100);
  123. damage *= multiplier;
  124. break;
  125. case PLANT:
  126. multiplier = 1 + ((attacker.getPAtkPlants(target) - target.getPDefPlants(target)) / 100);
  127. damage *= multiplier;
  128. break;
  129. case DRAGON:
  130. multiplier = 1 + ((attacker.getPAtkDragons(target) - target.getPDefDragons(target)) / 100);
  131. damage *= multiplier;
  132. break;
  133. case BUG:
  134. multiplier = 1 + ((attacker.getPAtkInsects(target) - target.getPDefInsects(target)) / 100);
  135. damage *= multiplier;
  136. break;
  137. case GIANT:
  138. multiplier = 1 + ((attacker.getPAtkGiants(target) - target.getPDefGiants(target)) / 100);
  139. damage *= multiplier;
  140. break;
  141. case MAGICCREATURE:
  142. multiplier = 1 + ((attacker.getPAtkMagicCreatures(target) - target.getPDefMagicCreatures(target)) / 100);
  143. damage *= multiplier;
  144. break;
  145. default:
  146. // nothing
  147. break;
  148. }
  149. }
  150.  
  151. if (damage > 0 && damage < 1)
  152. damage = 1;
  153. else if (damage < 0)
  154. damage = 0;
  155.  
  156. // Dmg bonuses in PvP fight
  157. if (isPvP)
  158. {
  159. if (skill == null)
  160. damage *= attacker.calcStat(Stats.PVP_PHYSICAL_DMG, 1, null, null);
  161. else
  162. damage *= attacker.calcStat(Stats.PVP_PHYS_SKILL_DMG, 1, null, null);
  163. }
  164.  
  165. return damage;
  166. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement