Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Hit_calc
- {
- //Attacking player
- static final boolean mageAtk=false; //True if using a Magic attack on a non NPC
- static final int atkLvl=61; //Range, Magic or Attack level
- static final int atkBonus=12; //Slash, Crush, Stab, Range or Magic attack bonus
- static final int atkStyleBonus=0; //3 for Accurate, 1 for Controlled, 0 otherwise
- static final double atkPrayBonus=1.00; //Offensive prayer multiplier
- static final double atkVoidBonus=1.10; //Void accuracy multiplier
- //Defending player
- static final int defLvl=1; //Defense or NPC magic level
- static final int defBonus=0; //Slash, Crush, Stab, Range or Magic defense bonus
- static final int defStyleBonus=0; //3 for Defensive or Long range, 1 for Controlled, 0 otherwise
- static final double defPrayBonus=1.00; //Defensive prayer multiplier
- static final double magePrayBonus=1.00; //Magic prayer multiplier
- static final int mageLvl=1; //Opponents Magic level
- public static void main(String[] args)
- {
- System.out.println("Chance to hit: "+hitChance());
- }
- public static double hitChance()
- {
- double atkRoll=getRoll(atkLvl,atkPrayBonus,atkStyleBonus,atkBonus,atkVoidBonus);
- double defRoll=getRoll(defLvl,defPrayBonus,defStyleBonus,defBonus,1.00);
- if(mageAtk)
- defRoll=getMageRoll();
- if(atkRoll>defRoll)
- return 1-(defRoll+2)/(2*(atkRoll+1));
- else
- return atkRoll/(2*(defRoll+1));
- }
- private static int getRoll(int atkLvl, double prayBonus, int styleBonus, int bonus, double voidBonus)
- {
- int effectiveLvl=(int)((((int)(atkLvl*prayBonus))+styleBonus+8)*voidBonus);
- return effectiveLvl*(bonus+64);
- }
- private static double getMageRoll()
- {
- int effectiveDefLvl=(int)((((int)(defLvl*defPrayBonus))+defStyleBonus+8)*0.30);
- int effectiveLvl=(int)(((int)(mageLvl*magePrayBonus)+8)*0.70)+effectiveDefLvl;
- return effectiveLvl*(defBonus+64);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement