From a155bc03088e59ec5f88e5b3cdaf209e44a48442 Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Mon, 6 Jan 2025 07:14:40 -0600 Subject: [PATCH] modified ht chance --- src/engine/gameManager/CombatManager.java | 33 +++++-------------- .../mobileAI/utilities/CombatUtilities.java | 2 +- 2 files changed, 9 insertions(+), 26 deletions(-) diff --git a/src/engine/gameManager/CombatManager.java b/src/engine/gameManager/CombatManager.java index 0b6416a3..9262ada2 100644 --- a/src/engine/gameManager/CombatManager.java +++ b/src/engine/gameManager/CombatManager.java @@ -1453,34 +1453,17 @@ public enum CombatManager { ((AbstractCharacter) awo).getCharItemManager().damageRandomArmor(1); } - public static boolean LandHit(int atr, int defense){ + public static boolean LandHit(int C5, int D5){ - //int roll = ThreadLocalRandom.current().nextInt(101); - //float chance = (float)((atr-((atr+defense)*0.315))/((defense-((atr+defense)*0.315))+(atr-((atr+defense)*0.315)))); - - //int connvertedChance = (int)(chance * 100); - - //if(connvertedChance < 5) - // connvertedChance = 5; - - //if(connvertedChance > 95) - // connvertedChance = 95; - - //return connvertedChance > roll; - - // Calculate raw chance to hit - float adjustedAtr = (float) atr - (atr + defense) * 0.315f; - float adjustedDefense = (float) defense - (atr + defense) * 0.315f; - - // Prevent division by zero - float chance = adjustedAtr / (adjustedDefense + adjustedAtr); - - // Convert to percentage and clamp between 5% and 95% + float chance = (C5-((C5+D5)*.315f)) / ((D5-((C5+D5)*.315f)) + (C5-((C5+D5)*.315f))); int convertedChance = Math.round(chance * 100); - convertedChance = Math.max(5, Math.min(95, convertedChance)); + //convertedChance = Math.max(5, Math.min(95, convertedChance)); - // Generate random roll (0–100) and determine hit int roll = ThreadLocalRandom.current().nextInt(101); - return convertedChance > roll; + + if(roll < 5)//always 5% chance ot miss + return false; + + return roll <= convertedChance; } } diff --git a/src/engine/mobileAI/utilities/CombatUtilities.java b/src/engine/mobileAI/utilities/CombatUtilities.java index 7b1c2d29..550819c6 100644 --- a/src/engine/mobileAI/utilities/CombatUtilities.java +++ b/src/engine/mobileAI/utilities/CombatUtilities.java @@ -154,7 +154,7 @@ public class CombatUtilities { case Building: return false; } - return CombatManager.LandHit(atr,defense); + return !CombatManager.LandHit(atr,defense); } public static boolean triggerBlock(Mob agent, AbstractWorldObject ac) {