custom hit chance formula

This commit is contained in:
2024-09-05 21:24:23 -05:00
parent dacdb2cf35
commit 3fb29f8e2b
3 changed files with 15 additions and 65 deletions
+9 -22
View File
@@ -660,32 +660,11 @@ public enum CombatManager {
//calculate hit/miss
//int roll = ThreadLocalRandom.current().nextInt(100);
DeferredPowerJob dpj = null;
int max = (int)atr;
if(max < 10)
max = 10;
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;
max = tar.defenseRating;
if(max < 1)
max = 10;
min = (int)(max * 0.5f);
if(max < min){
min = max - 1;
}
defRoll = ThreadLocalRandom.current().nextInt(min,max);
}
if (atrRoll > defRoll) {
if (LandHit((int)atr,(int)defense)) {
if (ac.getObjectType().equals(GameObjectType.PlayerCharacter))
updateAttackTimers((PlayerCharacter) ac, target, true);
@@ -1464,4 +1443,12 @@ public enum CombatManager {
((AbstractCharacter) awo).getCharItemManager().damageRandomArmor(1);
}
public static boolean LandHit(int atr, int defense){
int roll = ThreadLocalRandom.current().nextInt(100);
float chance = (float)((atr-((atr+defense)*0.315))/((defense-((atr+defense)*0.315))+(atr-((atr+defense)*0.315))));
boolean hit = false;
if(chance > roll)
hit = true;
return hit;
}
}
+1 -23
View File
@@ -2375,30 +2375,8 @@ public enum PowersManager {
//}
// calculate hit/miss
//int roll = ThreadLocalRandom.current().nextInt(100);
boolean disable = true;
int max = (int)atr;
if(max < 10)
max = 10;
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;
max = tar.defenseRating;
if(max < 10)
max = 10;
min = (int)(max * 0.5f);
if(max < min){
min = max - 1;
}
defRoll = ThreadLocalRandom.current().nextInt(min,max);
}
if (atrRoll > defRoll) {
if (CombatManager.LandHit((int)atr,(int)defense)) {
// Hit, check if dodge kicked in
if (awo instanceof AbstractCharacter) {
AbstractCharacter tarAc = (AbstractCharacter) awo;