Search in sources :

Example 1 with Ref

use of main.entity.Ref 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 Ref

use of main.entity.Ref in project Eidolons by IDemiurge.

the class ActionSequenceConstructor method getSequences.

private List<ActionSequence> getSequences(Task task, DC_ActiveObj active) {
    List<ActionSequence> sequences = new ArrayList<>();
    Ref ref = task.getUnit().getRef().getCopy();
    Integer arg = TaskManager.checkTaskArgReplacement(task, active);
    // if (arg == null) {
    // if (isArgNeeded(active))     return;
    // }
    ref.setTarget(arg);
    List<ActionSequence> newSequences = null;
    Action action = AiActionFactory.newAction(active, ref);
    action.setTask(task);
    try {
        newSequences = getSequencesWithPathsForAction(action, task.getArg(), task);
    } catch (Exception e) {
        main.system.ExceptionMaster.printStackTrace(e);
    }
    if (ListMaster.isNotEmpty(newSequences)) {
        sequences.addAll(newSequences);
    } else {
        // if no pathing is required/available [QUICK FIX]
        if (!action.canBeTargetedOnAny()) {
            return sequences;
        }
        ActionSequence sequence = constructSingleActionSequence(action, task);
        if (sequence != null) {
            if (active.isRanged()) {
                sequences.addAll(AiUnitActionMaster.splitRangedSequence(sequence));
            } else {
                sequences.add(sequence);
            }
        } else {
        // if (unit.getUnitAI().getLogLevel() > UnitAI.LOG_LEVEL_NONE)
        // TODO smarter logging?
        // main.system.auxiliary.LogMaster.log(1, "***" +
        // action.toString()
        // + " could not be constructed into an action sequence!");
        // return;
        }
    }
    return sequences;
}
Also used : Ref(main.entity.Ref) AiQuickItemAction(eidolons.game.battlecraft.ai.elements.actions.AiQuickItemAction) Action(eidolons.game.battlecraft.ai.elements.actions.Action) ArrayList(java.util.ArrayList)

Example 3 with Ref

use of main.entity.Ref in project Eidolons by IDemiurge.

the class DC_Masteries method boostParameter.

private void boostParameter(int i, PARAMS p, MOD modval) {
    Ref ref = new Ref(hero.getGame(), hero.getId());
    ref.setTarget(hero.getId());
    ref.setBase(true);
    ref.setQuiet(true);
    new ModifyValueEffect(p, modval, i + "").apply(ref);
}
Also used : Ref(main.entity.Ref) ModifyValueEffect(eidolons.ability.effects.common.ModifyValueEffect)

Example 4 with Ref

use of main.entity.Ref in project Eidolons by IDemiurge.

the class BehaviorMaster method getAction.

private Action getAction(GOAL_TYPE type, UnitAI ai) {
    String action = null;
    Integer target = null;
    // doesn't the group have standing orders as a whole?..
    Unit unit = ai.getUnit();
    Ref ref = new Ref(unit);
    GroupAI group = ai.getGroup();
    // checkBehaviorChange(group); where does that happen?
    switch(type) {
        case AMBUSH:
            break;
        case STALK:
            break;
        case STAND_GUARD:
        case PATROL:
            PatrolMaster.getPatrolAction(ai);
        // having already turned on the Mode
        case SEARCH:
        case WANDER:
            if (ai.isLeader()) {
                Boolean change = WanderAi.checkWanderDirectionChange(group, type);
                if (change == null) {
                    action = getIdleAction(ai, type);
                    change = true;
                }
                // maybe go meet leader if blocked... or something like it
                if (change) {
                    group.getWanderStepCoordinateStack().push(group.getLeader().getCoordinates());
                    WanderAi.changeGroupMoveDirection(group, type);
                }
            }
            boolean wait = false;
            // ActionSequenceConstructor.getSequence(targetAction, task)
            Coordinates targetCoordinates = WanderAi.getCoordinates(type, ai);
            if (targetCoordinates == null) {
                wait = true;
            // if (!recursion)
            // return null;
            // recursion = true;
            // return getAction(type, ai);
            } else {
                action = STD_ACTIONS.Move.name();
                // if (!unit.getAction(action).canBeActivated()) {
                // }
                ActionPath path = getPathBuilder().init(new ListMaster<DC_ActiveObj>().getList(unit.getAction(action)), new Action(unit.getAction(action), new Ref(unit))).getPathByPriority(new ListMaster<Coordinates>().getList(targetCoordinates));
                if (path == null) {
                    // TODO preCheck if path
                    ai.setPathBlocked(true);
                // appropriate
                } else {
                    ai.setPathBlocked(false);
                    return path.getActions().get(0);
                }
            }
            if (wait) {
                action = getIdleAction(ai, type);
            } else {
            // if (change) {
            // targetCoordinates = WanderMaster.getCoordinates(type,
            // ai);
            // }
            // return path.getActions().getOrCreate(0);
            }
    }
    DC_ActiveObj active = unit.getAction(action);
    ref.setTarget(target);
    recursion = false;
    return new Action(active, ref);
}
Also used : Action(eidolons.game.battlecraft.ai.elements.actions.Action) Coordinates(main.game.bf.Coordinates) ActionPath(eidolons.game.battlecraft.ai.tools.path.ActionPath) ListMaster(main.system.auxiliary.data.ListMaster) Unit(eidolons.entity.obj.unit.Unit) Ref(main.entity.Ref) GroupAI(eidolons.game.battlecraft.ai.GroupAI) DC_ActiveObj(eidolons.entity.active.DC_ActiveObj)

Example 5 with Ref

use of main.entity.Ref in project Eidolons by IDemiurge.

the class DC_HeroSlotItem method applySpecialEffects.

public void applySpecialEffects(SPECIAL_EFFECTS_CASE case_type, DC_UnitModel target, Ref REF) {
    if (specialEffects == null) {
        return;
    }
    if (specialEffects.get(case_type) == null) {
        return;
    }
    Ref ref = Ref.getCopy(REF);
    ref.setTarget(target.getId());
    ref.setSource(getOwnerObj().getId());
    Effect effect = specialEffects.get(case_type);
    effect.apply(ref);
}
Also used : Ref(main.entity.Ref) Effect(main.ability.effects.Effect)

Aggregations

Ref (main.entity.Ref)155 Unit (eidolons.entity.obj.unit.Unit)28 ObjType (main.entity.type.ObjType)23 Event (main.game.logic.event.Event)16 ArrayList (java.util.ArrayList)15 Obj (main.entity.obj.Obj)15 DC_ActiveObj (eidolons.entity.active.DC_ActiveObj)13 Coordinates (main.game.bf.Coordinates)13 Conditions (main.elements.conditions.Conditions)12 Formula (main.system.math.Formula)11 BattleFieldObject (eidolons.entity.obj.BattleFieldObject)10 ModifyValueEffect (eidolons.ability.effects.common.ModifyValueEffect)9 PARAMETER (main.content.values.parameters.PARAMETER)9 DC_SpellObj (eidolons.entity.active.DC_SpellObj)8 Effects (main.ability.effects.Effects)8 AddBuffEffect (eidolons.ability.effects.attachment.AddBuffEffect)7 Wave (eidolons.game.battlecraft.logic.battle.arena.Wave)7 Effect (main.ability.effects.Effect)7 DC_HeroItemObj (eidolons.entity.item.DC_HeroItemObj)5 DC_QuickItemObj (eidolons.entity.item.DC_QuickItemObj)5