Browse Source

custom hit chance formula

lakebane-strongholds
FatBoy-DOTC 2 months ago
parent
commit
2eb58eb719
  1. 15
      src/engine/gameManager/CombatManager.java

15
src/engine/gameManager/CombatManager.java

@ -1444,11 +1444,18 @@ public enum CombatManager {
} }
public static boolean LandHit(int atr, int defense){ public static boolean LandHit(int atr, int defense){
int roll = ThreadLocalRandom.current().nextInt(101); int roll = ThreadLocalRandom.current().nextInt(101);
float chance = (float)((atr-((atr+defense)*0.315))/((defense-((atr+defense)*0.315))+(atr-((atr+defense)*0.315)))); float chance = (float)((atr-((atr+defense)*0.315))/((defense-((atr+defense)*0.315))+(atr-((atr+defense)*0.315))));
boolean hit = false;
if((chance * 100) > roll) int connvertedChance = (int)(chance * 100);
hit = true;
return hit; if(connvertedChance < 5)
connvertedChance = 5;
if(connvertedChance > 95)
connvertedChance = 95;
return connvertedChance > roll;
} }
} }

Loading…
Cancel
Save