custom hit chance formula
This commit is contained in:
@@ -660,32 +660,11 @@ public enum CombatManager {
|
|||||||
|
|
||||||
//calculate hit/miss
|
//calculate hit/miss
|
||||||
|
|
||||||
//int roll = ThreadLocalRandom.current().nextInt(100);
|
|
||||||
DeferredPowerJob dpj = null;
|
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))
|
if (ac.getObjectType().equals(GameObjectType.PlayerCharacter))
|
||||||
updateAttackTimers((PlayerCharacter) ac, target, true);
|
updateAttackTimers((PlayerCharacter) ac, target, true);
|
||||||
@@ -1464,4 +1443,12 @@ public enum CombatManager {
|
|||||||
((AbstractCharacter) awo).getCharItemManager().damageRandomArmor(1);
|
((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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2375,30 +2375,8 @@ public enum PowersManager {
|
|||||||
//}
|
//}
|
||||||
|
|
||||||
// calculate hit/miss
|
// calculate hit/miss
|
||||||
//int roll = ThreadLocalRandom.current().nextInt(100);
|
|
||||||
|
|
||||||
boolean disable = true;
|
if (CombatManager.LandHit((int)atr,(int)defense)) {
|
||||||
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) {
|
|
||||||
// Hit, check if dodge kicked in
|
// Hit, check if dodge kicked in
|
||||||
if (awo instanceof AbstractCharacter) {
|
if (awo instanceof AbstractCharacter) {
|
||||||
AbstractCharacter tarAc = (AbstractCharacter) awo;
|
AbstractCharacter tarAc = (AbstractCharacter) awo;
|
||||||
|
|||||||
@@ -139,37 +139,22 @@ public class CombatUtilities {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static boolean triggerDefense(Mob agent, AbstractWorldObject target) {
|
public static boolean triggerDefense(Mob agent, AbstractWorldObject target) {
|
||||||
int defenseScore = 0;
|
int defense = 0;
|
||||||
int attackScore = agent.getAtrHandOne();
|
int atr = agent.getAtrHandOne();
|
||||||
switch (target.getObjectType()) {
|
switch (target.getObjectType()) {
|
||||||
case PlayerCharacter:
|
case PlayerCharacter:
|
||||||
defenseScore = ((AbstractCharacter) target).getDefenseRating();
|
defense = ((AbstractCharacter) target).getDefenseRating();
|
||||||
break;
|
break;
|
||||||
case Mob:
|
case Mob:
|
||||||
|
|
||||||
Mob mob = (Mob) target;
|
Mob mob = (Mob) target;
|
||||||
if (mob.isSiege())
|
if (mob.isSiege())
|
||||||
defenseScore = attackScore;
|
defense = atr;
|
||||||
break;
|
break;
|
||||||
case Building:
|
case Building:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
return CombatManager.LandHit(atr,defense);
|
||||||
int hitChance;
|
|
||||||
if (attackScore > defenseScore || defenseScore == 0)
|
|
||||||
hitChance = 94;
|
|
||||||
else if (attackScore == defenseScore && target.getObjectType() == GameObjectType.Mob)
|
|
||||||
hitChance = 10;
|
|
||||||
else {
|
|
||||||
float dif = attackScore / defenseScore;
|
|
||||||
if (dif <= 0.8f)
|
|
||||||
hitChance = 4;
|
|
||||||
else
|
|
||||||
hitChance = ((int) (450 * (dif - 0.8f)) + 4);
|
|
||||||
if (target.getObjectType() == GameObjectType.Building)
|
|
||||||
hitChance = 100;
|
|
||||||
}
|
|
||||||
return ThreadLocalRandom.current().nextInt(100) > hitChance;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean triggerBlock(Mob agent, AbstractWorldObject ac) {
|
public static boolean triggerBlock(Mob agent, AbstractWorldObject ac) {
|
||||||
|
|||||||
Reference in New Issue
Block a user