Advertisement
VANPER

rusaCis formulas

Apr 3rd, 2023
501
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.29 KB | None | 0 0
  1. public static final double calcPhysicalAttackDamage(Creature attacker, Creature target, ShieldDefense sDef, boolean crit, boolean ss)
  2. {
  3. // If the attacker can't attack, return.
  4. final Player attackerPlayer = attacker.getActingPlayer();
  5. if (attackerPlayer != null && !attackerPlayer.getAccessLevel().canGiveDamage())
  6. return 0.;
  7.  
  8. double defence = target.getStatus().getPDef(attacker);
  9. switch (sDef)
  10. {
  11. case SUCCESS:
  12. defence += target.getStatus().getShldDef();
  13. break;
  14.  
  15. case PERFECT:
  16. return 1.;
  17. }
  18.  
  19. final boolean isPvP = attacker instanceof Playable && target instanceof Playable;
  20.  
  21. final double attackPower = attacker.getStatus().getPAtk(target);
  22.  
  23. double addCritPower = 0.;
  24.  
  25. final double pvpMul = (isPvP) ? attacker.getStatus().calcStat(Stats.PVP_PHYSICAL_DMG, 1, null, null) : 1.;
  26. final double posMul = getPosMul(attacker, target, crit);
  27. final double elemMul = calcElementalPhysicalAttackModifier(attacker, target);
  28. final double rndMul = attacker.getRandomDamageMultiplier();
  29.  
  30. double raceMul = 1.;
  31. double weaponMul = 1.;
  32. double critDamMul = 1.;
  33. double critDamPosMul = 1.;
  34.  
  35. double critVuln = 1.;
  36.  
  37. // Critic multiplier.
  38. if (crit)
  39. {
  40. critDamMul = attacker.getStatus().calcStat(Stats.CRITICAL_DAMAGE, 1, target, null);
  41. critDamPosMul = attacker.getStatus().calcStat(Stats.CRITICAL_DAMAGE_POS, 1, target, null);
  42.  
  43. critVuln = target.getStatus().calcStat(Stats.CRIT_VULN, 1, target, null);
  44.  
  45. addCritPower = attacker.getStatus().calcStat(Stats.CRITICAL_DAMAGE_ADD, 0, target, null) * 77. / defence;
  46. }
  47.  
  48. // Weapon multiplier.
  49. final Weapon weapon = attacker.getActiveWeaponItem();
  50. if (weapon != null)
  51. {
  52. final Stats stat = weapon.getItemType().getVulnStat();
  53. if (stat != null)
  54. weaponMul = target.getStatus().calcStat(stat, 1, target, null);
  55. }
  56.  
  57. // Race multiplier.
  58. if (target instanceof Npc)
  59. {
  60. final NpcRace race = ((Npc) target).getTemplate().getRace();
  61. if (race.getAtkStat() != null && race.getResStat() != null)
  62. raceMul = 1 + ((attacker.getStatus().calcStat(race.getAtkStat(), 1, target, null) - target.getStatus().calcStat(race.getResStat(), 1, target, null)) / 100);
  63. }
  64.  
  65. // End calculation.
  66. double damage = 0;
  67. if (crit)
  68. damage = ((attackPower * 2. * critDamMul * critDamPosMul * critVuln * posMul * rndMul * raceMul * pvpMul * elemMul * weaponMul) + addCritPower) * 77. / defence;
  69. else
  70. damage = (attackPower * posMul * rndMul * raceMul * pvpMul * elemMul * weaponMul) * 77. / defence;
  71.  
  72. // If using ss, the damages are multiplied by 2.
  73. if (ss)
  74. damage *= 2.;
  75.  
  76. if (Config.DEVELOPER)
  77. {
  78. StringUtil.printSection("Physical attack damage");
  79. LOGGER.info("crit:{}, ss:{}, shield:{}, isPvp:{}, defence:{}", crit, ss, sDef, isPvP, defence);
  80. LOGGER.info("Basic powers: attack: {}, addCrit: {}", attackPower, addCritPower);
  81. LOGGER.info("Multipliers: critDam: {}, critPos: {}, pos: {}, rnd: {}, race: {}, pvp: {}, elem: {}, weapon: {}", critDamMul, critDamPosMul, posMul, rndMul, raceMul, pvpMul, elemMul, weaponMul);
  82. LOGGER.info("Vulnerabilities: criticalVuln: {}", critVuln);
  83. LOGGER.info("Final damage: {}", damage);
  84. }
  85.  
  86. if (damage < 0)
  87. damage = 0;
  88. else if (damage < 1)
  89. damage = 1;
  90.  
  91. return damage;
  92. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement