Search in sources :

Example 1 with AutoTargeting

use of main.elements.targeting.AutoTargeting in project Eidolons by IDemiurge.

the class ShapeEffect method initTargeting.

@Override
public void initTargeting() {
    // init unit group
    Coordinates baseCoordinate = getBaseCoordinate();
    int base_width = radius.getInt(ref);
    int distance = this.distance.getInt(ref);
    coordinates = DC_PositionMaster.getShapedCoordinates(baseCoordinate, getFacing(), base_width, distance, getShape());
    DequeImpl<Obj> objects = new DequeImpl<>();
    objects.addAllCast(getGame().getMaster().getUnitsForCoordinates(coordinates));
    Filter.filter(objects, targetType);
    if (allyOrEnemyOnly != null) {
        if (allyOrEnemyOnly) {
            FilterMaster.applyFilter(objects, FILTERS.ALLY, ref, false);
        } else {
            FilterMaster.applyFilter(objects, FILTERS.ENEMY, ref, false);
        }
    }
    if (notSelf) {
        FilterMaster.applyFilter(objects, FILTERS.NOT_SELF, ref, false);
    }
    if (targetType.equals(DC_TYPE.TERRAIN)) {
        // C_TYPE equals if contains() !
        objects.addAll(game.getCellsForCoordinates(coordinates));
    }
    targeting = new AutoTargeting(new GroupImpl(objects));
    setFilteringConditions(new Conditions());
    targeting.setConditions(getFilteringConditions());
}
Also used : AutoTargeting(main.elements.targeting.AutoTargeting) Obj(main.entity.obj.Obj) Coordinates(main.game.bf.Coordinates) GroupImpl(main.entity.group.GroupImpl) DequeImpl(main.system.datatypes.DequeImpl) Conditions(main.elements.conditions.Conditions)

Example 2 with AutoTargeting

use of main.elements.targeting.AutoTargeting in project Eidolons by IDemiurge.

the class ActiveAuraEffect method applyThis.

@Override
public boolean applyThis() {
    AutoTargeting targeting = new AutoTargeting(new Conditions(new ObjTypeComparison(C_OBJ_TYPE.BF_OBJ), new DistanceCondition("" + radius.getInt(ref))));
    targeting.getConditions().add(ConditionMaster.getAliveCondition(KEYS.MATCH));
    if (onlyEnemiesOrAllies != null) {
        if (onlyEnemiesOrAllies) {
            targeting.getConditions().add(ConditionMaster.getEnemyCondition());
        } else {
            targeting.getConditions().add(ConditionMaster.getAllyCondition());
        }
    }
    targeting.getConditions().add(new NotCondition(new RefCondition(KEYS.MATCH, KEYS.SOURCE)));
    Ability ability = new ActiveAbility(targeting, effects);
    new AddTriggerEffect(event_type, conditions, ability).apply(ref);
    return true;
}
Also used : ActiveAbility(main.ability.ActiveAbility) Ability(main.ability.Ability) ActiveAbility(main.ability.ActiveAbility) AutoTargeting(main.elements.targeting.AutoTargeting) AddTriggerEffect(eidolons.ability.effects.attachment.AddTriggerEffect)

Example 3 with AutoTargeting

use of main.elements.targeting.AutoTargeting in project Eidolons by IDemiurge.

the class AbilityImpl method activatedOn.

@Override
public boolean activatedOn(Ref ref) {
    setRef(ref);
    // preCheck if targeting is overridden
    if (!(targeting instanceof AutoTargeting)) {
        if (!(targeting instanceof FixedTargeting)) {
            if (isForcePresetTargeting() || targeting == null) {
                if (ref.getTarget() != null || ref.getGroup() != null) {
                    // without targeting.select()
                    return resolve();
                } else {
                    // inconsistent data
                    return false;
                }
            }
        }
    }
    boolean selectResult = targeting.select(ref);
    ActiveObj a = ref.getActive();
    if (selectResult) {
        if (a != null) {
            a.setCancelled(null);
        }
        return resolve();
    } else {
        if (a != null) {
            if (a.isCancelled() != null) {
                a.setCancelled(true);
            }
        }
        return false;
    }
}
Also used : AutoTargeting(main.elements.targeting.AutoTargeting) ActiveObj(main.entity.obj.ActiveObj) FixedTargeting(main.elements.targeting.FixedTargeting)

Example 4 with AutoTargeting

use of main.elements.targeting.AutoTargeting 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 AutoTargeting

use of main.elements.targeting.AutoTargeting in project Eidolons by IDemiurge.

the class RayEffect method initTargeting.

public void initTargeting() {
    Conditions conditions = new Conditions();
    if (distance != null) {
        conditions.add(ConditionMaster.getDistanceFilterCondition(KEYS.SOURCE.toString(), distance));
    }
    if (PositionMaster.inLine(ref.getTargetObj().getCoordinates(), ref.getSourceObj().getCoordinates())) {
        conditions.add(ConditionMaster.getLineCondition(ref.getSourceObj(), ref.getTargetObj(), false));
    } else {
        conditions.add(ConditionMaster.getDiagonalLineCondition(ref.getSourceObj(), ref.getTargetObj(), false));
    }
    // conditions.add(ConditionMaster.getUnitTypeCondition());
    conditions.add(ConditionMaster.getNotDeadCondition());
    if (allyOrEnemyOnly != null) {
        if (allyOrEnemyOnly) {
            conditions.add(ConditionMaster.getAllyCondition());
        } else {
            conditions.add(ConditionMaster.getEnemyCondition());
        }
    }
    if (ref.getObj(KEYS.ACTIVE).checkBool(GenericEnums.STD_BOOLS.BLOCKED)) {
        conditions.add(DC_ConditionMaster.getClearShotFilterCondition());
    }
    this.targeting = new AutoTargeting(conditions, DataManager.BF_TYPES);
    setFilteringConditions(conditions);
}
Also used : AutoTargeting(main.elements.targeting.AutoTargeting) Conditions(main.elements.conditions.Conditions)

Aggregations

AutoTargeting (main.elements.targeting.AutoTargeting)9 Conditions (main.elements.conditions.Conditions)4 AddTriggerEffect (eidolons.ability.effects.attachment.AddTriggerEffect)3 Effects (main.ability.effects.Effects)3 Ref (main.entity.Ref)3 Ability (main.ability.Ability)2 ActiveAbility (main.ability.ActiveAbility)2 CustomTargetEffect (main.ability.effects.continuous.CustomTargetEffect)2 GroupImpl (main.entity.group.GroupImpl)2 Obj (main.entity.obj.Obj)2 AddBuffEffect (eidolons.ability.effects.attachment.AddBuffEffect)1 ModifyValueEffect (eidolons.ability.effects.common.ModifyValueEffect)1 ZoneEffect (eidolons.ability.effects.containers.customtarget.ZoneEffect)1 DealDamageEffect (eidolons.ability.effects.oneshot.DealDamageEffect)1 ActivateEffect (eidolons.ability.effects.oneshot.activation.ActivateEffect)1 AlteringEffect (eidolons.ability.effects.oneshot.misc.AlteringEffect)1 DC_UnitAction (eidolons.entity.active.DC_UnitAction)1 Unit (eidolons.entity.obj.unit.Unit)1 ArrayList (java.util.ArrayList)1 Abilities (main.ability.Abilities)1