use of eidolons.game.battlecraft.rules.RuleMaster.RULE in project Eidolons by IDemiurge.
the class DefenseVsAttackRule method getChance.
private static int getChance(DC_ActiveObj action, Unit attacker, BattleFieldObject attacked, int attack, int defense, boolean critOrDodge) {
int diff = defense - attack;
// first preCheck ARITHMETIC difference...
diff = Math.abs(diff) - ((critOrDodge) ? DC_Formulas.ATTACK_DMG_INCREASE_LIMIT : DC_Formulas.DEFENSE_DMG_DECREASE_LIMIT);
if (diff <= 0) {
diff = 0;
}
// add PROPORTION BASED
diff += getProportionBasedChance(attack, defense, critOrDodge);
float mod = (critOrDodge) ? DC_Formulas.ATTACK_CRIT_CHANCE : DC_Formulas.DEFENSE_DODGE_CHANCE;
int chance = Math.round(diff * mod);
if (critOrDodge) {
chance += action.getFinalBonusParam(PARAMS.AUTO_CRIT_CHANCE);
// TODO chance modifiers?
} else {
if (attacker.checkPassive(UnitEnums.STANDARD_PASSIVES.TRUE_STRIKE)) {
chance = 0;
}
if (attacked != null) {
chance += attacked.getIntParam(PARAMS.EVASION);
}
chance += -action.getFinalBonusParam(PARAMS.ACCURACY);
}
chance = Math.min(100, chance);
if (action.getGame().getCombatMaster().isChancesOff()) {
RULE rule = (critOrDodge) ? RULE.CRITICAL_ATTACK : RULE.DODGE;
if (RuleMaster.isRuleTestOn(rule) || chance > 50)
chance = 100;
else
chance = 0;
}
return chance;
}
Aggregations