Search in sources :

Example 6 with DealDamageEffect

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

the class CollisionRule method collision.

public static Coordinates collision(Ref ref, DC_ActiveObj activeObj, Unit moveObj, Unit collideObj, boolean summon, int force) {
    // ++ AoO!
    // permit auto-retreat ? maybe some skill will make hidden unit
    // *passable* ;)
    Coordinates dest = collideObj.getCoordinates();
    Coordinates final_coordinate = dest;
    if (!canBeOn(moveObj, collideObj.getCoordinates())) {
        // dest.getAdjacentCoordinate(direction);
        Boolean above = PositionMaster.isAboveOr(moveObj, collideObj);
        Boolean left = PositionMaster.isToTheLeftOr(moveObj, collideObj);
        // TODO adjust in a loop in case there are multiple obstacles
        // around!
        int x = 0;
        if (left != null) {
            x = (left ? -1 : 1);
        }
        int y = 0;
        if (above != null) {
            y = (above ? -1 : 1);
        }
        final_coordinate = new Coordinates(dest.x + x, dest.y + y);
        if (!canBeOn(moveObj, final_coordinate)) {
            final_coordinate = adjustCoordinateRandomly(dest, moveObj);
        }
    // TODO ++ spare Action Points? Percentage or so...
    // saved_ap =
    // activeObj.getIntParam(PARAMS.AP_COST)*distance_factor*save_factor;
    }
    if (!moveObj.getOwner().equals(collideObj.getOwner())) {
        // any action
        Boolean incomerAlive = AttackOfOpportunityRule.collisionAoO(moveObj.getDummyAction(), collideObj);
        if (!BooleanMaster.isFalse(incomerAlive)) {
            InstantAttackRule.checkCollisionAttack(moveObj, activeObj, collideObj);
        }
    // if (incomerAlive == null) {
    // if (!summon)
    // AttackOfOpportunityRule.checkAttack(moveObj,
    // collideObj.getAction("Move"));
    // } else if (incomerAlive)
    // if (!summon)
    // AttackOfOpportunityRule.checkAttack(moveObj,
    // collideObj.getAction("Move"));
    }
    // return false; TODO
    if (moveObj.isDead()) {
        return null;
    }
    if (collideObj.isDead()) {
        return final_coordinate;
    }
    if (force != 0) {
        new DealDamageEffect(ForceRule.getCollisionDamageFormula(moveObj, collideObj, force, true), GenericEnums.DAMAGE_TYPE.BLUDGEONING).apply(Ref.getSelfTargetingRefCopy(collideObj));
        new DealDamageEffect(ForceRule.getCollisionDamageFormula(moveObj, collideObj, force, false), GenericEnums.DAMAGE_TYPE.BLUDGEONING).apply(Ref.getSelfTargetingRefCopy(moveObj));
    }
    if (!VisionManager.checkVisible(collideObj)) // if (moveObj.canAct())
    {
        // ROLL?
        StealthRule.applySpotted(collideObj);
    }
    return final_coordinate;
}
Also used : Coordinates(main.game.bf.Coordinates) DealDamageEffect(eidolons.ability.effects.oneshot.DealDamageEffect)

Example 7 with DealDamageEffect

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

the class DealDamageEffectTest method dealDamageObjectTest.

@Test
public void dealDamageObjectTest() {
    assertTrue(source != null);
    assertTrue(target != null);
    int origToughness = target.getIntParam(PARAMS.C_TOUGHNESS);
    int origEndurance = target.getIntParam(PARAMS.C_ENDURANCE);
    DealDamageEffect eff = new DealDamageEffect(new Formula("50"), GenericEnums.DAMAGE_TYPE.BLUDGEONING.getName(), DAMAGE_MODIFIER.UNBLOCKABLE);
    Damage dmg = DamageFactory.getDamageFromEffect(eff, 25);
    dmg.getRef().setTarget(target.getId());
    DamageDealer.dealDamage(dmg);
    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) DealDamageEffect(eidolons.ability.effects.oneshot.DealDamageEffect) Damage(eidolons.game.battlecraft.rules.combat.damage.Damage) 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