Advertisement
VANPER

350 Formulas

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