Search in sources :

Example 1 with DistanceCondition

use of main.elements.conditions.DistanceCondition in project Eidolons by IDemiurge.

the class ActionExecutor method createTargeter.

@Override
protected Targeter createTargeter(DC_ActiveObj active, ActiveMaster entityMaster) {
    return new Targeter(active, entityMaster) {

        @Override
        public Targeting getTargeting() {
            initTargetingMode();
            if (AI_Manager.isRunning()) {
                return super.getTargeting();
            }
            if (getAction().isAttackGeneric()) {
                Conditions conditions = new OrConditions();
                int maxRange = 0;
                for (DC_ActiveObj attack : getAction().getSubActions()) {
                    if (attack.isThrow()) {
                        continue;
                    }
                    if (!attack.canBeActivated()) {
                        continue;
                    }
                    conditions.add(attack.getTargeting().getFilter().getConditions());
                    if (maxRange < attack.getRange()) {
                        maxRange = attack.getRange();
                    }
                }
                conditions.setFastFailOnCheck(true);
                conditions = ConditionMaster.getFilteredConditions(conditions, DistanceCondition.class);
                conditions.add(new DistanceCondition("" + maxRange));
                SelectiveTargeting selectiveTargeting = new SelectiveTargeting(SELECTIVE_TARGETING_TEMPLATES.ATTACK, conditions);
                return selectiveTargeting;
            }
            return super.getTargeting();
        }
    };
}
Also used : SelectiveTargeting(main.elements.targeting.SelectiveTargeting) OrConditions(main.elements.conditions.OrConditions) DistanceCondition(main.elements.conditions.DistanceCondition) Targeter(eidolons.entity.handlers.active.Targeter) DC_ActiveObj(eidolons.entity.active.DC_ActiveObj) Conditions(main.elements.conditions.Conditions) OrConditions(main.elements.conditions.OrConditions)

Example 2 with DistanceCondition

use of main.elements.conditions.DistanceCondition in project Eidolons by IDemiurge.

the class DungeonObjMaster method createAction.

public DC_UnitAction createAction(T sub, Unit unit, String typeName, DungeonObj obj) {
    // TODO CACHE
    DC_UnitAction action = unit.getGame().getActionManager().getOrCreateAction(typeName, unit);
    action.setTargeting(new SelectiveTargeting(new Conditions(new DistanceCondition("1", true), new FacingCondition(FACING_SINGLE.IN_FRONT))));
    action.setConstructed(true);
    action.getTargeter().setTargetingInitialized(true);
    action.setTargetingCachingOff(true);
    action.setActionTypeGroup(ACTION_TYPE_GROUPS.STANDARD);
    action.setAbilities(null);
    List<ActiveObj> actives = new ArrayList<>();
    actives.add(new ActiveAbilityObj((AbilityType) DataManager.getType("Dummy Ability", DC_TYPE.ABILS), unit.getRef(), unit.getOwner(), unit.getGame()) {

        @Override
        public boolean activatedOn(Ref ref) {
            return actionActivated(sub, unit, obj);
        }
    });
    action.setActives(actives);
    action.setActionTypeGroup(ACTION_TYPE_GROUPS.DUNGEON);
    return action;
}
Also used : SelectiveTargeting(main.elements.targeting.SelectiveTargeting) Ref(main.entity.Ref) ActiveObj(main.entity.obj.ActiveObj) DC_ActiveObj(eidolons.entity.active.DC_ActiveObj) AbilityType(main.ability.AbilityType) DistanceCondition(main.elements.conditions.DistanceCondition) ArrayList(java.util.ArrayList) ActiveAbilityObj(main.ability.ActiveAbilityObj) FacingCondition(eidolons.ability.conditions.FacingCondition) DC_UnitAction(eidolons.entity.active.DC_UnitAction) Conditions(main.elements.conditions.Conditions)

Aggregations

DC_ActiveObj (eidolons.entity.active.DC_ActiveObj)2 Conditions (main.elements.conditions.Conditions)2 DistanceCondition (main.elements.conditions.DistanceCondition)2 SelectiveTargeting (main.elements.targeting.SelectiveTargeting)2 FacingCondition (eidolons.ability.conditions.FacingCondition)1 DC_UnitAction (eidolons.entity.active.DC_UnitAction)1 Targeter (eidolons.entity.handlers.active.Targeter)1 ArrayList (java.util.ArrayList)1 AbilityType (main.ability.AbilityType)1 ActiveAbilityObj (main.ability.ActiveAbilityObj)1 OrConditions (main.elements.conditions.OrConditions)1 Ref (main.entity.Ref)1 ActiveObj (main.entity.obj.ActiveObj)1