Search in sources :

Example 6 with Targeting

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

the class VampirismEffect method applyThis.

@Override
public boolean applyThis() {
    if (conditions == null) {
        initConditions();
    }
    // TODO Auto-generated method stub
    // endurance damage; modify endurance only? above base?
    // if (triggerEffect!=null) triggerEffect.apply(ref); else {
    Targeting targeting = new FixedTargeting(KEYS.SOURCE);
    Effects effects = new Effects();
    if (restoreEndurance) {
        ModifyValueEffect effect = new ModifyValueEffect(PARAMS.C_ENDURANCE, code, formula.toString());
        if (!restoreEnduranceAboveBase) {
            effect.setMaxParam(PARAMS.ENDURANCE);
        }
        effects.add(effect);
    }
    if (restoreToughness) {
        ModifyValueEffect effect = new ModifyValueEffect(PARAMS.C_TOUGHNESS, code, formula.toString());
        if (!restoreToughnessAboveBase) {
            effect.setMaxParam(PARAMS.TOUGHNESS);
        }
        effects.add(effect);
    }
    if (fromEnduranceDamage) {
        ActiveAbility ability = new ActiveAbility(targeting, effects);
        new AddTriggerEffect(// TODO
        STANDARD_EVENT_TYPE.UNIT_IS_DEALT_ENDURANCE_DAMAGE, // damage?
        conditions, ability).apply(ref);
    }
    if (fromToughnessDamage) {
    }
    return true;
}
Also used : ActiveAbility(main.ability.ActiveAbility) FixedTargeting(main.elements.targeting.FixedTargeting) Targeting(main.elements.targeting.Targeting) FixedTargeting(main.elements.targeting.FixedTargeting) ModifyValueEffect(eidolons.ability.effects.common.ModifyValueEffect) Effects(main.ability.effects.Effects)

Example 7 with Targeting

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

the class PathChoiceMaster method getChoices.

List<Choice> getChoices(ActionPath path, Coordinates c_coordinate, Coordinates targetCoordinate, FACING_DIRECTION c_facing) {
    Chronos.mark("Finding choices for " + path);
    pathBuilder.adjustUnit();
    List<Choice> choices = new ArrayList<>();
    for (Coordinates c : getDefaultCoordinateTargets(path, c_coordinate)) {
        Choice stdMoveChoice = constructStdMoveChoice(c, c_coordinate, c_facing);
        if (stdMoveChoice != null) {
            choices.add(stdMoveChoice);
        }
    }
    Chronos.mark("Finding custom choices for " + path);
    List<Choice> specialChoices = new ArrayList<>();
    if (ListMaster.isNotEmpty(moveActions)) {
        for (DC_ActiveObj a : moveActions) {
            if (!a.canBeActivated()) {
                if (firstStep) {
                    if (!ReasonMaster.checkReasonCannotActivate(a, PARAMS.C_N_OF_ACTIONS.getName())) {
                        // exception for AP TODO
                        continue;
                    }
                }
            }
            if (path.hasAction(a)) {
                if (a.getIntParam(PARAMS.COOLDOWN) >= 0) {
                    continue;
                }
            }
            Targeting targeting = a.getTargeting();
            Collection<Obj> objects = null;
            if (targeting instanceof FixedTargeting) {
                Targeting t = a.getAbilities().getTargeting();
                if (t != null) {
                    objects = t.getFilter().getObjects(a.getRef());
                }
                Effect e = a.getAbilities().getEffects().getEffects().get(0);
                e.setRef(unit.getRef());
                if (e instanceof SelfMoveEffect) {
                    try {
                        Coordinates coordinates = ((SelfMoveEffect) e).getCoordinates();
                        if (coordinates != null) {
                            objects = new ArrayList<>(Arrays.asList(unit.getGame().getCellByCoordinate(coordinates)));
                        }
                    } catch (Exception ex) {
                        main.system.ExceptionMaster.printStackTrace(ex);
                    }
                }
            } else {
                pathBuilder.adjustUnit();
                objects = targeting.getFilter().getObjects(a.getRef());
            }
            if (objects != null) {
                List<Choice> choicesForAction = new ArrayList<>();
                for (Object obj : objects) {
                    if (obj instanceof DC_Cell) {
                        Coordinates coordinates = ((DC_Cell) obj).getCoordinates();
                        // if (a.getName().equals("Clumsy Leap"))
                        if (PositionMaster.getDistance(coordinates, c_coordinate) > Math.max(1, a.getIntParam(PARAMS.RANGE))) {
                            continue;
                        }
                        if (PositionMaster.getDistance(coordinates, targetCoordinate) > PositionMaster.getDistance(c_coordinate, targetCoordinate)) {
                            // TODO will this not eliminate good
                            continue;
                        }
                        // choices?
                        Ref ref = unit.getRef().getCopy();
                        ref.setTarget(((DC_Cell) obj).getId());
                        Choice choice = new Choice(coordinates, c_coordinate, new Action(a, ref));
                        choicesForAction.add(choice);
                    }
                }
                Chronos.mark("Filter custom choices for " + a);
                specialChoices.addAll(filterSpecialMoveChoices(choicesForAction, a, c_coordinate, path));
                Chronos.logTimeElapsedForMark("Filter custom choices for " + a);
            }
        // if (choices.size() > 1)
        }
    }
    Chronos.logTimeElapsedForMark("Finding custom choices for " + path);
    choices.addAll(specialChoices);
    Chronos.mark("Sort choices");
    sortChoices(choices);
    Chronos.logTimeElapsedForMark("Sort choices");
    // resetUnit();// TODO is that right?
    Chronos.logTimeElapsedForMark("Finding choices for " + path);
    // Chronos.logTimeElapsedForMark("Sorting choices for " + path);
    return choices;
}
Also used : Action(eidolons.game.battlecraft.ai.elements.actions.Action) DC_UnitAction(eidolons.entity.active.DC_UnitAction) FixedTargeting(main.elements.targeting.FixedTargeting) Targeting(main.elements.targeting.Targeting) Coordinates(main.game.bf.Coordinates) Ref(main.entity.Ref) FixedTargeting(main.elements.targeting.FixedTargeting) DC_Cell(eidolons.entity.obj.DC_Cell) DC_ActiveObj(eidolons.entity.active.DC_ActiveObj) Obj(main.entity.obj.Obj) SelfMoveEffect(eidolons.ability.effects.oneshot.move.SelfMoveEffect) SelfMoveEffect(eidolons.ability.effects.oneshot.move.SelfMoveEffect) Effect(main.ability.effects.Effect) DC_ActiveObj(eidolons.entity.active.DC_ActiveObj)

Example 8 with Targeting

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

the class ReasonMaster method getReasonsCannotTarget.

public static List<FILTER_REASON> getReasonsCannotTarget(Action action, boolean useConditionResultCache, Boolean checkMiscOrOnly, FILTER_REASON searchedReason) {
    Ref REF = action.getRef().getCopy();
    REF.setMatch(action.getRef().getTarget());
    Targeting targeting = action.getActive().getTargeting();
    if (targeting == null) {
        targeting = TargetingMaster.findTargeting(action.getActive());
    }
    if (targeting == null) {
        return new ArrayList<>();
    }
    Conditions conditions = targeting.getFilter().getConditions();
    // conditions.preCheck(REF);
    List<FILTER_REASON> reasons = new ArrayList<>();
    for (Condition c : conditions) {
        FILTER_REASON reason = getReason(c);
        if (searchedReason != null) {
            if (reason != searchedReason) {
                continue;
            }
        }
        if (checkMiscOrOnly == null) {
            if (reason != FILTER_REASON.OTHER) {
                continue;
            }
        } else if (!checkMiscOrOnly) {
            if (reason == FILTER_REASON.OTHER) {
                continue;
            }
        }
        boolean result = c.isTrue();
        if (!useConditionResultCache) {
            result = c.preCheck(REF);
        } else {
        // LogMaster.log(0, c + " uses cached result " + result);
        }
        if (!result) {
            if (reason != null) {
                reasons.add(reason);
            }
        }
    }
    return reasons;
}
Also used : DistanceCondition(main.elements.conditions.DistanceCondition) VisibilityCondition(eidolons.ability.conditions.VisibilityCondition) FacingCondition(eidolons.ability.conditions.FacingCondition) Condition(main.elements.conditions.Condition) Ref(main.entity.Ref) Targeting(main.elements.targeting.Targeting) ArrayList(java.util.ArrayList) Conditions(main.elements.conditions.Conditions)

Example 9 with Targeting

use of main.elements.targeting.Targeting 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 10 with Targeting

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

the class AbilityConstructor method constructAbility.

private static Ability constructAbility(Node node) {
    Effect effects = null;
    Targeting targeting = null;
    for (Node NODE : XML_Converter.getNodeList(node)) {
        if (NODE.getNodeName().equals(EFFECTS) || NODE.getNodeName().contains(EFFECTS)) {
            effects = constructEffects(NODE);
        }
        if (NODE.getNodeName().equals(TARGETING) || NODE.getNodeName().contains(TARGETING)) {
            targeting = constructTargeting(NODE);
        }
    }
    if (effects == null) {
        LogMaster.log(1, "null abil effects!");
        effects = new Effects();
    }
    if (targeting == null) {
        LogMaster.log(1, "null abil targeting!");
        targeting = new FixedTargeting();
    }
    Ability abil = null;
    if (node.getNodeName().equals(ACTIVE_ABILITY)) {
        abil = new ActiveAbility(targeting, effects);
    } else if (node.getNodeName().equals(ONESHOT_ABILITY)) {
        abil = new OneshotAbility(targeting, effects);
    } else if (node.getNodeName().equals(PASSIVE_ABILITY)) {
        abil = new PassiveAbility(targeting, effects);
    }
    abil.setXml(XML_Converter.getStringFromXML(node));
    return abil;
}
Also used : FixedTargeting(main.elements.targeting.FixedTargeting) Targeting(main.elements.targeting.Targeting) FixedTargeting(main.elements.targeting.FixedTargeting) Node(org.w3c.dom.Node) Effect(main.ability.effects.Effect) Effects(main.ability.effects.Effects)

Aggregations

Targeting (main.elements.targeting.Targeting)18 FixedTargeting (main.elements.targeting.FixedTargeting)12 SelectiveTargeting (main.elements.targeting.SelectiveTargeting)9 TemplateSelectiveTargeting (eidolons.ability.targeting.TemplateSelectiveTargeting)7 Effects (main.ability.effects.Effects)6 MultiTargeting (main.elements.targeting.MultiTargeting)6 TemplateAutoTargeting (eidolons.ability.targeting.TemplateAutoTargeting)5 DC_ActiveObj (eidolons.entity.active.DC_ActiveObj)5 AutoTargeting (main.elements.targeting.AutoTargeting)5 Ref (main.entity.Ref)5 Effect (main.ability.effects.Effect)4 AddTriggerEffect (eidolons.ability.effects.attachment.AddTriggerEffect)3 ModifyValueEffect (eidolons.ability.effects.common.ModifyValueEffect)3 ActiveAbility (main.ability.ActiveAbility)3 Conditions (main.elements.conditions.Conditions)3 ActiveObj (main.entity.obj.ActiveObj)3 AddBuffEffect (eidolons.ability.effects.attachment.AddBuffEffect)2 WaveEffect (eidolons.ability.effects.containers.customtarget.WaveEffect)2 ZoneEffect (eidolons.ability.effects.containers.customtarget.ZoneEffect)2 DealDamageEffect (eidolons.ability.effects.oneshot.DealDamageEffect)2