From 2eb58eb7196c758fd21acacac2ea07a3e426a559 Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Thu, 5 Sep 2024 21:30:01 -0500 Subject: [PATCH] custom hit chance formula --- src/engine/gameManager/CombatManager.java | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/engine/gameManager/CombatManager.java b/src/engine/gameManager/CombatManager.java index 76cd9f5b..80e01442 100644 --- a/src/engine/gameManager/CombatManager.java +++ b/src/engine/gameManager/CombatManager.java @@ -1444,11 +1444,18 @@ public enum CombatManager { } public static boolean LandHit(int atr, int defense){ + int roll = ThreadLocalRandom.current().nextInt(101); 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) - hit = true; - return hit; + + int connvertedChance = (int)(chance * 100); + + if(connvertedChance < 5) + connvertedChance = 5; + + if(connvertedChance > 95) + connvertedChance = 95; + + return connvertedChance > roll; } }