Search in sources :

Example 1 with SelectiveTargeting

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

the class AiExecutor method execute.

public boolean execute(Action action, boolean free) {
    boolean result = false;
    Ref ref = action.getRef();
    if (free) {
        action.getActive().setFree(true);
    }
    try {
        if (!action.getActive().isChanneling()) {
            if (ref.getTargetObj() == null) {
                if (!(action.getActive().getTargeting() instanceof SelectiveTargeting)) {
                    result = true;
                    action.getActive().getHandler().activateOnGameLoopThread();
                }
            }
        }
        if (!result) {
            action.getActive().getHandler().activateOn(ref);
            result = true;
        }
        // WaitMaster.waitForInput(WAIT_OPERATIONS.ACTION_COMPLETE);
        return result;
    } catch (Exception e) {
        main.system.ExceptionMaster.printStackTrace(e);
    } finally {
        action.getActive().setFree(false);
    }
    return result;
}
Also used : SelectiveTargeting(main.elements.targeting.SelectiveTargeting) Ref(main.entity.Ref)

Example 2 with SelectiveTargeting

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

the class ActivesConstructor method getDefaultSingleTargeting.

public static Targeting getDefaultSingleTargeting(DC_ActiveObj entity) {
    Conditions conditions = (DC_ConditionMaster.getSelectiveTargetingTemplateConditions(DEFAULT_TARGETING_TEMPLATE));
    Targeting targeting = new SelectiveTargeting(conditions);
    return targeting;
}
Also used : TemplateSelectiveTargeting(eidolons.ability.targeting.TemplateSelectiveTargeting) SelectiveTargeting(main.elements.targeting.SelectiveTargeting) FixedTargeting(main.elements.targeting.FixedTargeting) TemplateAutoTargeting(eidolons.ability.targeting.TemplateAutoTargeting) TemplateSelectiveTargeting(eidolons.ability.targeting.TemplateSelectiveTargeting) Targeting(main.elements.targeting.Targeting) MultiTargeting(main.elements.targeting.MultiTargeting) SelectiveTargeting(main.elements.targeting.SelectiveTargeting) Conditions(main.elements.conditions.Conditions)

Example 3 with SelectiveTargeting

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

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

the class DefaultActionHandler method leftClickCell.

public static boolean leftClickCell(boolean turn, boolean moveTo, int gridX, int gridY) {
    Unit source = null;
    try {
        source = Eidolons.getGame().getManager().getActiveObj();
    } catch (Exception e) {
        main.system.ExceptionMaster.printStackTrace(e);
    }
    if (source == null)
        return false;
    if (source.isAiControlled())
        return false;
    Coordinates c = new Coordinates(gridX, gridY);
    if (turn) {
        return turnToMotion(source, c);
    }
    if (moveTo) {
        return moveToMotion(source, c);
    }
    if (source.getGame().isDebugMode()) {
        return doDebugStuffCell(source, c);
    }
    if (c.x - source.getX() > 1) {
        return false;
    }
    if (c.y - source.getY() > 1) {
        return false;
    }
    DC_UnitAction action = getMoveToCellAction(source, c);
    if (action == null) {
        return false;
    }
    Obj target = action.getTargeting() instanceof SelectiveTargeting ? Eidolons.getGame().getCellByCoordinate(c) : null;
    Context context = new Context(source, target);
    return activate(context, action);
}
Also used : SelectiveTargeting(main.elements.targeting.SelectiveTargeting) Context(main.game.logic.action.context.Context) DungeonObj(eidolons.game.module.dungeoncrawl.objects.DungeonObj) DC_Obj(eidolons.entity.obj.DC_Obj) Obj(main.entity.obj.Obj) Coordinates(main.game.bf.Coordinates) Unit(eidolons.entity.obj.unit.Unit)

Example 5 with SelectiveTargeting

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

the class TossItemEffect method applyThis.

/*
     * size? from hand?
	 * 
	 * interrupt?
	 */
@Override
public boolean applyThis() {
    Unit source = (Unit) ref.getSourceObj();
    Ref REF = ref.getCopy();
    conditions = new OrConditions(DC_ConditionMaster.getSelectiveTargetingTemplateConditions(SELECTIVE_TARGETING_TEMPLATES.MY_ITEM), DC_ConditionMaster.getSelectiveTargetingTemplateConditions(SELECTIVE_TARGETING_TEMPLATES.MY_WEAPON));
    if (!new SelectiveTargeting(conditions).select(REF)) {
        ref.getActive().setCancelled(true);
        return false;
    }
    DC_HeroItemObj item = (DC_HeroItemObj) REF.getTargetObj();
    conditions = new Conditions(// ++ Max distance?
    new DistanceCondition(ref.getActive().getIntParam(PARAMS.RANGE, false) + ""), // new NumericCondition("{match_c_n_of_actions}", "1"),
    new CanActCondition(KEYS.MATCH), new NotCondition(ConditionMaster.getSelfFilterCondition()), DC_ConditionMaster.getSelectiveTargetingTemplateConditions(SELECTIVE_TARGETING_TEMPLATES.ANY_ALLY));
    // non-immobile, ++facing?
    if (!new SelectiveTargeting(conditions).select(REF)) {
        ref.getActive().setCancelled(true);
        return false;
    }
    Unit unit = (Unit) REF.getTargetObj();
    boolean result = roll(source, unit, item);
    if (item instanceof DC_QuickItemObj) {
        DC_QuickItemObj quickItem = (DC_QuickItemObj) item;
        source.removeQuickItem(quickItem);
        if (result) {
            unit.addQuickItem(quickItem);
        } else {
            dropped(item, unit);
        }
    } else {
        source.unequip(item, null);
        if (result) {
            // TODO equip in hand if
            unit.addItemToInventory(item);
        } else // possible? spend AP?
        {
            dropped(item, unit);
        }
    }
    // ref.getObj(KEYS.ITEM);
    unit.modifyParameter(PARAMS.C_N_OF_ACTIONS, -1);
    return true;
}
Also used : SelectiveTargeting(main.elements.targeting.SelectiveTargeting) Ref(main.entity.Ref) CanActCondition(eidolons.ability.conditions.special.CanActCondition) DC_HeroItemObj(eidolons.entity.item.DC_HeroItemObj) DC_QuickItemObj(eidolons.entity.item.DC_QuickItemObj) Unit(eidolons.entity.obj.unit.Unit)

Aggregations

SelectiveTargeting (main.elements.targeting.SelectiveTargeting)11 Unit (eidolons.entity.obj.unit.Unit)5 Conditions (main.elements.conditions.Conditions)5 Ref (main.entity.Ref)5 DC_ActiveObj (eidolons.entity.active.DC_ActiveObj)4 Targeting (main.elements.targeting.Targeting)4 DC_SpellObj (eidolons.entity.active.DC_SpellObj)3 DC_HeroItemObj (eidolons.entity.item.DC_HeroItemObj)3 DC_Obj (eidolons.entity.obj.DC_Obj)3 ActiveObj (main.entity.obj.ActiveObj)3 Obj (main.entity.obj.Obj)3 TemplateSelectiveTargeting (eidolons.ability.targeting.TemplateSelectiveTargeting)2 DC_QuickItemObj (eidolons.entity.item.DC_QuickItemObj)2 DistanceCondition (main.elements.conditions.DistanceCondition)2 FixedTargeting (main.elements.targeting.FixedTargeting)2 MultiTargeting (main.elements.targeting.MultiTargeting)2 ObjType (main.entity.type.ObjType)2 Coordinates (main.game.bf.Coordinates)2 Formula (main.system.math.Formula)2 FacingCondition (eidolons.ability.conditions.FacingCondition)1