From 1a13f3f096f7924b868a13b417c167de2d03be86 Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Fri, 30 Aug 2024 20:44:22 -0500 Subject: [PATCH] hit roll formula fixed --- src/engine/gameManager/CombatManager.java | 17 +++++++++++++---- src/engine/gameManager/PowersManager.java | 16 +++++++++++++--- 2 files changed, 26 insertions(+), 7 deletions(-) diff --git a/src/engine/gameManager/CombatManager.java b/src/engine/gameManager/CombatManager.java index 135a2f30..081e6ab4 100644 --- a/src/engine/gameManager/CombatManager.java +++ b/src/engine/gameManager/CombatManager.java @@ -663,15 +663,24 @@ public enum CombatManager { //int roll = ThreadLocalRandom.current().nextInt(100); DeferredPowerJob dpj = null; - int atrRoll = ThreadLocalRandom.current().nextInt(ac.level * 10,(int)atr); + int max = (int)atr; + int min = (int)(max * 0.5f); + if(max < min){ + min = max - 1; + } + int atrRoll = ThreadLocalRandom.current().nextInt(min,max); int defRoll = 0; if(AbstractCharacter.IsAbstractCharacter(target)){ AbstractCharacter tar = (AbstractCharacter) target; - defRoll = ThreadLocalRandom.current().nextInt(tar.level * 10,tar.defenseRating); + max = tar.defenseRating; + min = (int)(max * 0.5f); + if(max < min){ + min = max - 1; + } + defRoll = ThreadLocalRandom.current().nextInt(min,max); } - - if (atrRoll < defRoll) { + if (atrRoll > defRoll) { if (ac.getObjectType().equals(GameObjectType.PlayerCharacter)) updateAttackTimers((PlayerCharacter) ac, target, true); diff --git a/src/engine/gameManager/PowersManager.java b/src/engine/gameManager/PowersManager.java index d1c5b501..75dcc2bf 100644 --- a/src/engine/gameManager/PowersManager.java +++ b/src/engine/gameManager/PowersManager.java @@ -2329,13 +2329,23 @@ public enum PowersManager { //int roll = ThreadLocalRandom.current().nextInt(100); boolean disable = true; - int atrRoll = ThreadLocalRandom.current().nextInt(pc.level * 10,(int)atr); + int max = (int)atr; + int min = (int)(max * 0.5f); + if(max < min){ + min = max - 1; + } + int atrRoll = ThreadLocalRandom.current().nextInt(min,max); int defRoll = 0; if(AbstractCharacter.IsAbstractCharacter(awo)){ AbstractCharacter tar = (AbstractCharacter) awo; - defRoll = ThreadLocalRandom.current().nextInt(tar.level * 10,tar.defenseRating); + max = tar.defenseRating; + min = (int)(max * 0.5f); + if(max < min){ + min = max - 1; + } + defRoll = ThreadLocalRandom.current().nextInt(min,max); } - if (atrRoll < defRoll) { + if (atrRoll > defRoll) { // Hit, check if dodge kicked in if (awo instanceof AbstractCharacter) { AbstractCharacter tarAc = (AbstractCharacter) awo;