Search in sources :

Example 1 with AttackEffect

use of eidolons.ability.effects.oneshot.attack.AttackEffect in project Eidolons by IDemiurge.

the class DC_AttackMaster method attack.

private Boolean attack(Attack attack, Ref ref, boolean free, boolean canCounter, Effect onHit, Effect onKill, boolean offhand, boolean counter) {
    ENTRY_TYPE type = ENTRY_TYPE.ATTACK;
    boolean extraAttack = true;
    if (attack.getAction().isCounterMode()) {
        type = ENTRY_TYPE.COUNTER_ATTACK;
    } else if (attack.getAction().isInstantMode()) {
        type = ENTRY_TYPE.INSTANT_ATTACK;
    } else if (attack.getAction().isAttackOfOpportunityMode()) {
        type = ENTRY_TYPE.ATTACK_OF_OPPORTUNITY;
    } else {
        extraAttack = false;
    }
    // LogEntryNode entry = game.getLogManager().newLogEntryNode(type,
    // attack.getAttacker().getName(), attack.getAttackedUnit().getName(), attack.getAction());
    Boolean result = null;
    if (!extraAttack) {
        Unit guard = (Unit) GuardRule.checkTargetChanged(attack.getAction());
        if (guard != null) {
            game.getLogManager().log(guard.getNameIfKnown() + " intercepts " + attack.toLogString());
            ref.setTarget(guard.getId());
            attack.setRef(ref);
            attack.setAttacked(guard);
        }
    }
    attack.setSneak(SneakRule.checkSneak(ref));
    try {
        main.system.auxiliary.log.LogMaster.log(1, attack.getAttacker() + " attacks " + attack.getAttacked() + " with " + attack.getAction());
        result = attackNow(attack, ref, free, canCounter, onHit, onKill, offhand, counter);
        boolean countered = false;
        if (result == null) {
            // first strike
            main.system.auxiliary.log.LogMaster.log(1, "Counter attack with first strike against " + attack.getAction());
            ActiveObj action = counterRule.tryCounter(attack, false);
            if (action != null) {
                AttackEffect effect = EffectMaster.getAttackEffect(action);
                waitForAttackAnimation(effect.getAttack());
            }
            attackNow(attack, ref, free, false, onHit, onKill, offhand, counter);
            countered = true;
            result = true;
        }
        if ((!countered) || attack.getAttacker().hasDoubleCounter()) {
            if (canCounter) {
                if (!counter) {
                    counterRule.tryCounter(attack);
                }
            }
        }
    } catch (Exception e) {
        result = false;
        main.system.ExceptionMaster.printStackTrace(e);
    } finally {
        if (!extraAttack) {
            game.getLogManager().doneLogEntryNode(ENTRY_TYPE.ACTION);
        }
        game.getLogManager().doneLogEntryNode(type);
    }
    return result;
}
Also used : ActiveObj(main.entity.obj.ActiveObj) DC_ActiveObj(eidolons.entity.active.DC_ActiveObj) AttackEffect(eidolons.ability.effects.oneshot.attack.AttackEffect) Unit(eidolons.entity.obj.unit.Unit) ENTRY_TYPE(main.system.text.EntryNodeMaster.ENTRY_TYPE)

Example 2 with AttackEffect

use of eidolons.ability.effects.oneshot.attack.AttackEffect in project Eidolons by IDemiurge.

the class EffectFinder method getAttackFromAction.

public static Attack getAttackFromAction(DC_ActiveObj t) {
    List<Effect> eff = getEffectsOfClass(t, AttackEffect.class);
    AttackEffect e = (AttackEffect) eff.get(0);
    return e.getAttack();
}
Also used : AttackEffect(eidolons.ability.effects.oneshot.attack.AttackEffect) AddBuffEffect(eidolons.ability.effects.attachment.AddBuffEffect) ContainerEffect(main.ability.effects.ContainerEffect) AttackEffect(eidolons.ability.effects.oneshot.attack.AttackEffect) ModifyValueEffect(eidolons.ability.effects.common.ModifyValueEffect) ModifyPropertyEffect(eidolons.ability.effects.common.ModifyPropertyEffect) RollEffect(eidolons.ability.effects.oneshot.mechanic.RollEffect) Effect(main.ability.effects.Effect)

Example 3 with AttackEffect

use of eidolons.ability.effects.oneshot.attack.AttackEffect in project Eidolons by IDemiurge.

the class FutureBuilder method getDamage.

public static int getDamage(DC_ActiveObj active, Obj targetObj, Effect e, Boolean min_max_normal) {
    Integer damage;
    Ref ref = active.getOwnerObj().getRef().getCopy();
    ref.setTarget(targetObj.getId());
    ref.setID(KEYS.ACTIVE, active.getId());
    e.setRef(ref);
    if (e instanceof DealDamageEffect) {
        ref.setAmount(e.getFormula().getInt(ref));
        if (((DealDamageEffect) e).getDamageType() != null) {
            ref.setValue(KEYS.DAMAGE_TYPE, ((DealDamageEffect) e).getDamageType().toString());
        }
        damage = DamageCalculator.precalculateDamage(ref);
    } else {
        Attack attack = ((AttackEffect) e).initAttack();
        // attack.setAttacked((DC_HeroObj) targetObj);
        Map<String, Integer> _cache = getCache(min_max_normal);
        damage = _cache.get(getCacheKey(active, targetObj));
        if (damage == null) {
            damage = DamageCalculator.precalculateDamage(attack, min_max_normal);
            _cache.put(getCacheKey(active, targetObj), damage);
        }
    }
    // active.toBase();
    LogMaster.log(1, active.getName() + " on " + targetObj.getName() + " - damage precalculated: " + damage);
    return damage;
}
Also used : Ref(main.entity.Ref) AttackEffect(eidolons.ability.effects.oneshot.attack.AttackEffect) DealDamageEffect(eidolons.ability.effects.oneshot.DealDamageEffect) Attack(eidolons.game.battlecraft.rules.combat.attack.Attack)

Example 4 with AttackEffect

use of eidolons.ability.effects.oneshot.attack.AttackEffect in project Eidolons by IDemiurge.

the class AttackCondition method check.

@Override
public boolean check(Ref ref) {
    AttackEffect attackEffect = null;
    if (ref.getEffect() instanceof AttackEffect) {
        attackEffect = (AttackEffect) ref.getEffect();
    } else {
        try {
            attackEffect = (AttackEffect) EffectFinder.getEffectsOfClass(ref.getActive().getAbilities(), AttackEffect.class).get(0);
        } catch (Exception e) {
            main.system.ExceptionMaster.printStackTrace(e);
        }
    }
    if (attackEffect == null) {
        return false;
    }
    boolean result = false;
    if (counter != null) {
        result = attackEffect.getAttack().isCounter();
        if (!counter) {
            result = !result;
        }
    }
    return result;
}
Also used : AttackEffect(eidolons.ability.effects.oneshot.attack.AttackEffect)

Aggregations

AttackEffect (eidolons.ability.effects.oneshot.attack.AttackEffect)4 AddBuffEffect (eidolons.ability.effects.attachment.AddBuffEffect)1 ModifyPropertyEffect (eidolons.ability.effects.common.ModifyPropertyEffect)1 ModifyValueEffect (eidolons.ability.effects.common.ModifyValueEffect)1 DealDamageEffect (eidolons.ability.effects.oneshot.DealDamageEffect)1 RollEffect (eidolons.ability.effects.oneshot.mechanic.RollEffect)1 DC_ActiveObj (eidolons.entity.active.DC_ActiveObj)1 Unit (eidolons.entity.obj.unit.Unit)1 Attack (eidolons.game.battlecraft.rules.combat.attack.Attack)1 ContainerEffect (main.ability.effects.ContainerEffect)1 Effect (main.ability.effects.Effect)1 Ref (main.entity.Ref)1 ActiveObj (main.entity.obj.ActiveObj)1 ENTRY_TYPE (main.system.text.EntryNodeMaster.ENTRY_TYPE)1