Search in sources :

Example 1 with DealDamageEffect

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

the class DamageCalculator method precalculateRawDamageForDisplay.

/**
 * Calculates and creates Damage Objects of each DAMAGE_TYPE present for PhaseAnimations
 *
 * @param attack
 * @return
 */
public static List<Damage> precalculateRawDamageForDisplay(Attack attack) {
    List<Damage> list = new ArrayList<>();
    list.add(DamageFactory.getDamageFromAttack(attack));
    List<Effect> effects = new ArrayList<>();
    if (attack.getWeapon().getSpecialEffects() != null) {
        if (attack.getWeapon().getSpecialEffects().get(SPECIAL_EFFECTS_CASE.ON_ATTACK) != null) {
            effects.add(attack.getWeapon().getSpecialEffects().get(SPECIAL_EFFECTS_CASE.ON_ATTACK));
        }
    }
    if (attack.getAttacker().getSpecialEffects() != null) {
        if (attack.getAttacker().getSpecialEffects().get(SPECIAL_EFFECTS_CASE.ON_ATTACK) != null) {
            effects.add(attack.getAttacker().getSpecialEffects().get(SPECIAL_EFFECTS_CASE.ON_ATTACK));
        }
    }
    for (Effect e : effects) {
        // TODO ++ PARAM MOD
        for (Effect dmgEffect : EffectFinder.getEffectsOfClass(e, DealDamageEffect.class)) {
            int amount = dmgEffect.getFormula().getInt(attack.getRef());
            list.add(DamageFactory.getDamageFromEffect((DealDamageEffect) dmgEffect, amount));
        }
    }
    return list;
}
Also used : ArrayList(java.util.ArrayList) DealDamageEffect(eidolons.ability.effects.oneshot.DealDamageEffect) Effect(main.ability.effects.Effect) DealDamageEffect(eidolons.ability.effects.oneshot.DealDamageEffect)

Example 2 with DealDamageEffect

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

the class ForceRule method applyDamage.

public static void applyDamage(int force, DC_ActiveObj attack, BattleFieldObject source, BattleFieldObject target) {
    int damage = getDamage(force, target, target, target);
    // attack.modifyParameter(PARAMS.BASE_DAMAGE, damage);
    // if (target.getShield()!=null )
    Ref ref = attack.getRef().getCopy();
    ref.setTarget(target.getId());
    new DealDamageEffect(new Formula(damage + ""), GenericEnums.DAMAGE_TYPE.BLUDGEONING).apply(ref);
}
Also used : Formula(main.system.math.Formula) Ref(main.entity.Ref) DealDamageEffect(eidolons.ability.effects.oneshot.DealDamageEffect)

Example 3 with DealDamageEffect

use of eidolons.ability.effects.oneshot.DealDamageEffect 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 DealDamageEffect

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

the class BindingDamageEffect method applyThis.

@Override
public boolean applyThis() {
    // Can be initialized() just once
    GroupImpl group = ref.getGroup();
    Effects effects = new Effects();
    STANDARD_EVENT_TYPE event_type;
    if (shareOrRedirect) {
        // TODO splitMode!
        event_type = STANDARD_EVENT_TYPE.UNIT_IS_DEALT_TOUGHNESS_DAMAGE;
        if (spellDmgOnly != null) {
            if (spellDmgOnly) {
                event_type = STANDARD_EVENT_TYPE.UNIT_HAS_BEEN_DEALT_SPELL_DAMAGE;
            }
        }
        if (physicalDmgOnly != null) {
            if (physicalDmgOnly) {
                event_type = STANDARD_EVENT_TYPE.UNIT_HAS_BEEN_DEALT_PHYSICAL_DAMAGE;
            }
        }
    } else {
        effects.add(new AlteringEffect(false, formula.getNegative().toString()));
        event_type = Event.STANDARD_EVENT_TYPE.UNIT_IS_BEING_DEALT_DAMAGE;
        if (spellDmgOnly != null) {
            if (spellDmgOnly) {
                event_type = STANDARD_EVENT_TYPE.UNIT_IS_BEING_DEALT_SPELL_DAMAGE;
            }
        }
        if (physicalDmgOnly != null) {
            if (physicalDmgOnly) {
                event_type = STANDARD_EVENT_TYPE.UNIT_IS_BEING_DEALT_PHYSICAL_DAMAGE;
            }
        }
    }
    Targeting targeting_other_units = new AutoTargeting(new Conditions(new GroupCondition(Ref.KEYS.MATCH.name(), group), // negative
    new RefCondition(KEYS.EVENT_TARGET, KEYS.MATCH, true)));
    effects.add(new CustomTargetEffect(targeting_other_units, new DealDamageEffect(getDamageFormula(), GenericEnums.DAMAGE_TYPE.PURE)));
    /*
         * ensure there is no deadlock
		 */
    conditions = new Conditions();
    conditions.add(new NonTriggeredEventCondition());
    KEYS OBJ_REF = Ref.KEYS.EVENT_TARGET;
    conditions.add(new GroupCondition(OBJ_REF, group));
    // has the group...
    Ref REF = Ref.getCopy(ref);
    // REF.setTarget(null); // ???
    new AddTriggerEffect(event_type, conditions, OBJ_REF, effects).apply(REF);
    return true;
}
Also used : AutoTargeting(main.elements.targeting.AutoTargeting) Targeting(main.elements.targeting.Targeting) AutoTargeting(main.elements.targeting.AutoTargeting) NonTriggeredEventCondition(main.elements.conditions.standard.NonTriggeredEventCondition) STANDARD_EVENT_TYPE(main.game.logic.event.Event.STANDARD_EVENT_TYPE) RefCondition(main.elements.conditions.RefCondition) CustomTargetEffect(main.ability.effects.continuous.CustomTargetEffect) DealDamageEffect(eidolons.ability.effects.oneshot.DealDamageEffect) Effects(main.ability.effects.Effects) Conditions(main.elements.conditions.Conditions) AddTriggerEffect(eidolons.ability.effects.attachment.AddTriggerEffect) Ref(main.entity.Ref) GroupImpl(main.entity.group.GroupImpl) KEYS(main.entity.Ref.KEYS) AlteringEffect(eidolons.ability.effects.oneshot.misc.AlteringEffect) GroupCondition(main.elements.conditions.standard.GroupCondition)

Example 5 with DealDamageEffect

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

the class DealDamageEffectTest method dealDamageEffectTest.

@Test
public void dealDamageEffectTest() {
    assertTrue(source != null);
    assertTrue(target != null);
    int origToughness = target.getIntParam(PARAMS.C_TOUGHNESS);
    int origEndurance = target.getIntParam(PARAMS.C_ENDURANCE);
    Effect eff = new DealDamageEffect(new Formula("50"), GenericEnums.DAMAGE_TYPE.BLUDGEONING.getName(), DAMAGE_MODIFIER.UNBLOCKABLE);
    Ref ref = new Ref(source);
    ref.setTarget(target.getId());
    ref.setID(KEYS.ACTIVE, source.getAction("Attack").getId());
    eff.apply(ref);
    Integer newToughness = target.getIntParam(PARAMS.C_TOUGHNESS);
    Integer newEndurance = target.getIntParam(PARAMS.C_ENDURANCE);
    assertTrue(newToughness < origToughness);
    assertTrue(newEndurance < origEndurance);
}
Also used : Formula(main.system.math.Formula) Ref(main.entity.Ref) DealDamageEffect(eidolons.ability.effects.oneshot.DealDamageEffect) Effect(main.ability.effects.Effect) DealDamageEffect(eidolons.ability.effects.oneshot.DealDamageEffect) FastDcTest(tests.FastDcTest) Test(org.junit.Test)

Aggregations

DealDamageEffect (eidolons.ability.effects.oneshot.DealDamageEffect)7 Ref (main.entity.Ref)4 Formula (main.system.math.Formula)3 Effect (main.ability.effects.Effect)2 Test (org.junit.Test)2 FastDcTest (tests.FastDcTest)2 AddTriggerEffect (eidolons.ability.effects.attachment.AddTriggerEffect)1 AttackEffect (eidolons.ability.effects.oneshot.attack.AttackEffect)1 AlteringEffect (eidolons.ability.effects.oneshot.misc.AlteringEffect)1 Attack (eidolons.game.battlecraft.rules.combat.attack.Attack)1 Damage (eidolons.game.battlecraft.rules.combat.damage.Damage)1 ArrayList (java.util.ArrayList)1 Effects (main.ability.effects.Effects)1 CustomTargetEffect (main.ability.effects.continuous.CustomTargetEffect)1 Conditions (main.elements.conditions.Conditions)1 RefCondition (main.elements.conditions.RefCondition)1 GroupCondition (main.elements.conditions.standard.GroupCondition)1 NonTriggeredEventCondition (main.elements.conditions.standard.NonTriggeredEventCondition)1 AutoTargeting (main.elements.targeting.AutoTargeting)1 Targeting (main.elements.targeting.Targeting)1