Advertisement
Guest User

Untitled

a guest
Jan 22nd, 2019
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.92 KB | None | 0 0
  1. public class Hit_calc
  2. {
  3. //Attacking player
  4. static final boolean mageAtk=false; //True if using a Magic attack on a non NPC
  5. static final int atkLvl=61; //Range, Magic or Attack level
  6. static final int atkBonus=12; //Slash, Crush, Stab, Range or Magic attack bonus
  7. static final int atkStyleBonus=0; //3 for Accurate, 1 for Controlled, 0 otherwise
  8. static final double atkPrayBonus=1.00; //Offensive prayer multiplier
  9. static final double atkVoidBonus=1.10; //Void accuracy multiplier
  10.  
  11. //Defending player
  12. static final int defLvl=1; //Defense or NPC magic level
  13. static final int defBonus=0; //Slash, Crush, Stab, Range or Magic defense bonus
  14. static final int defStyleBonus=0; //3 for Defensive or Long range, 1 for Controlled, 0 otherwise
  15. static final double defPrayBonus=1.00; //Defensive prayer multiplier
  16. static final double magePrayBonus=1.00; //Magic prayer multiplier
  17. static final int mageLvl=1; //Opponents Magic level
  18.  
  19.  
  20. public static void main(String[] args)
  21. {
  22. System.out.println("Chance to hit: "+hitChance());
  23. }
  24.  
  25. public static double hitChance()
  26. {
  27. double atkRoll=getRoll(atkLvl,atkPrayBonus,atkStyleBonus,atkBonus,atkVoidBonus);
  28. double defRoll=getRoll(defLvl,defPrayBonus,defStyleBonus,defBonus,1.00);
  29. if(mageAtk)
  30. defRoll=getMageRoll();
  31. if(atkRoll>defRoll)
  32. return 1-(defRoll+2)/(2*(atkRoll+1));
  33. else
  34. return atkRoll/(2*(defRoll+1));
  35. }
  36.  
  37. private static int getRoll(int atkLvl, double prayBonus, int styleBonus, int bonus, double voidBonus)
  38. {
  39. int effectiveLvl=(int)((((int)(atkLvl*prayBonus))+styleBonus+8)*voidBonus);
  40. return effectiveLvl*(bonus+64);
  41. }
  42.  
  43. private static double getMageRoll()
  44. {
  45. int effectiveDefLvl=(int)((((int)(defLvl*defPrayBonus))+defStyleBonus+8)*0.30);
  46. int effectiveLvl=(int)(((int)(mageLvl*magePrayBonus)+8)*0.70)+effectiveDefLvl;
  47. return effectiveLvl*(defBonus+64);
  48. }
  49.  
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement