Search in sources :

Example 6 with FixedTargeting

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

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

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

Example 9 with FixedTargeting

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

the class WaitEffect method getAbility.

protected Ability getAbility(Ref ref) {
    Effect effect = new Effects(new RemoveBuffEffect(getBuffName()));
    Ability ability = new ActiveAbility(new FixedTargeting(KEYS.SOURCE), effect);
    ability.setRef(ref);
    return ability;
}
Also used : ActiveAbility(main.ability.ActiveAbility) Ability(main.ability.Ability) ActiveAbility(main.ability.ActiveAbility) RemoveBuffEffect(eidolons.ability.effects.oneshot.buff.RemoveBuffEffect) FixedTargeting(main.elements.targeting.FixedTargeting) AddBuffEffect(eidolons.ability.effects.attachment.AddBuffEffect) Effect(main.ability.effects.Effect) MicroEffect(main.ability.effects.MicroEffect) SetCustomModeEffect(eidolons.ability.effects.continuous.SetCustomModeEffect) RemoveBuffEffect(eidolons.ability.effects.oneshot.buff.RemoveBuffEffect) AddTriggerEffect(eidolons.ability.effects.attachment.AddTriggerEffect) OneshotEffect(main.ability.effects.OneshotEffect) Effects(main.ability.effects.Effects)

Example 10 with FixedTargeting

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

the class BindingSpellEffect method applyThis.

@Override
public boolean applyThis() {
    // TODO Auto-generated method stub
    Effects effects = null;
    if (!shareOrRedirect) {
        effects = new Effects(new CustomTargetEffect(new FixedTargeting(KEYS.TARGET2), new DuplicateEffect(true)), new CustomTargetEffect(new FixedTargeting(KEYS.TARGET), new InterruptEffect()));
    }
    Effect EFFECT = new DuplicateSpellEffect(KEYS.TARGET.name(), false, true);
    EFFECT.setTargetGroup(ref.getGroup());
    effects = new Effects(EFFECT);
    Event.STANDARD_EVENT_TYPE event_type = Event.STANDARD_EVENT_TYPE.SPELL_RESOLVED;
    conditions.add(ConditionMaster.getPropCondition("EVENT_SPELL", G_PROPS.SPELL_TAGS, SpellEnums.SPELL_TAGS.MIND_AFFECTING.name()));
    return false;
}
Also used : InterruptEffect(main.ability.effects.triggered.InterruptEffect) FixedTargeting(main.elements.targeting.FixedTargeting) CustomTargetEffect(main.ability.effects.continuous.CustomTargetEffect) DuplicateEffect(eidolons.ability.effects.continuous.triggered.DuplicateEffect) DuplicateSpellEffect(eidolons.ability.effects.continuous.triggered.DuplicateSpellEffect) Event(main.game.logic.event.Event) DC_Effect(eidolons.ability.effects.DC_Effect) DuplicateSpellEffect(eidolons.ability.effects.continuous.triggered.DuplicateSpellEffect) DuplicateEffect(eidolons.ability.effects.continuous.triggered.DuplicateEffect) Effect(main.ability.effects.Effect) InterruptEffect(main.ability.effects.triggered.InterruptEffect) CustomTargetEffect(main.ability.effects.continuous.CustomTargetEffect) Effects(main.ability.effects.Effects)

Aggregations

FixedTargeting (main.elements.targeting.FixedTargeting)14 ActiveAbility (main.ability.ActiveAbility)8 Targeting (main.elements.targeting.Targeting)8 Effects (main.ability.effects.Effects)7 AddTriggerEffect (eidolons.ability.effects.attachment.AddTriggerEffect)5 Effect (main.ability.effects.Effect)4 Ref (main.entity.Ref)4 ModifyValueEffect (eidolons.ability.effects.common.ModifyValueEffect)3 Obj (main.entity.obj.Obj)3 AddBuffEffect (eidolons.ability.effects.attachment.AddBuffEffect)2 RemoveBuffEffect (eidolons.ability.effects.oneshot.buff.RemoveBuffEffect)2 DC_ActiveObj (eidolons.entity.active.DC_ActiveObj)2 DC_WeaponObj (eidolons.entity.item.DC_WeaponObj)2 Abilities (main.ability.Abilities)2 InterruptEffect (main.ability.effects.triggered.InterruptEffect)2 Conditions (main.elements.conditions.Conditions)2 RefCondition (main.elements.conditions.RefCondition)2 AutoTargeting (main.elements.targeting.AutoTargeting)2 SelectiveTargeting (main.elements.targeting.SelectiveTargeting)2 Coordinates (main.game.bf.Coordinates)2