Search in sources :

Example 1 with AttackCalculator

use of eidolons.game.battlecraft.rules.combat.attack.AttackCalculator in project Eidolons by IDemiurge.

the class DamageCalculator method precalculateDamage.

/**
 * Calculates damage for AI's FutureBuilder (AttackEffect)
 *
 * @param attack
 * @return
 */
public static int precalculateDamage(Attack attack, Boolean min_max_normal) {
    BattleFieldObject attacked = attack.getAttacked();
    Unit attacker = attack.getAttacker();
    if (!attacked.checkPassive(UnitEnums.STANDARD_PASSIVES.SNEAK_IMMUNE)) {
        attack.setSneak(SneakRule.checkSneak(attack.getRef()));
    }
    // TODO ref.setFuture(true) -> average dice, auto-reset action etc
    AttackCalculator calculator = new AttackCalculator(attack, true);
    if (min_max_normal != null)
        if (min_max_normal) {
            calculator.setMin(true);
        } else {
            calculator.setMax(true);
        }
    int amount = calculator.calculateFinalDamage();
    DAMAGE_TYPE dmg_type = attack.getDamageType();
    if (dmg_type == DAMAGE_TYPE.PURE || dmg_type == DAMAGE_TYPE.POISON) {
        return amount;
    }
    if (!(attacked instanceof Unit)) {
        return amount;
    }
    int blocked = attacked.getGame().getArmorSimulator().getShieldDamageBlocked(amount, (Unit) attacked, attacker, attack.getAction(), attack.getWeapon(), attack.getDamageType());
    blocked += attacked.getGame().getArmorSimulator().getArmorBlockDamage(amount, (Unit) attacked, attacker, attack.getAction());
    amount = calculateDamage(true, attacked, attacker, amount, null, blocked, attack.getDamageType());
    if (attack.getAction().isAttackGeneric()) {
        return amount;
    }
    return amount;
}
Also used : AttackCalculator(eidolons.game.battlecraft.rules.combat.attack.AttackCalculator) BattleFieldObject(eidolons.entity.obj.BattleFieldObject) DAMAGE_TYPE(main.content.enums.GenericEnums.DAMAGE_TYPE) Unit(eidolons.entity.obj.unit.Unit)

Example 2 with AttackCalculator

use of eidolons.game.battlecraft.rules.combat.attack.AttackCalculator in project Eidolons by IDemiurge.

the class AttackAnimation method start.

@Override
public void start() {
    if (isRecalc()) {
        int damage = new AttackCalculator(attack, true).calculateFinalDamage();
        super.start();
        return;
    }
    super.start();
}
Also used : AttackCalculator(eidolons.game.battlecraft.rules.combat.attack.AttackCalculator)

Aggregations

AttackCalculator (eidolons.game.battlecraft.rules.combat.attack.AttackCalculator)2 BattleFieldObject (eidolons.entity.obj.BattleFieldObject)1 Unit (eidolons.entity.obj.unit.Unit)1 DAMAGE_TYPE (main.content.enums.GenericEnums.DAMAGE_TYPE)1