Search in sources :

Example 1 with Context

use of main.game.logic.action.context.Context in project Eidolons by IDemiurge.

the class RadialManager method configureSelectiveTargetedNode.

protected static RadialValueContainer configureSelectiveTargetedNode(DC_ActiveObj active, DC_Obj target) {
    boolean wasValid;
    // if (target == null|| target.equals(active.getOwnerObj())){
    // Set<Obj> objSet = CoreEngine.isActionTargetingFiltersOff() ?
    // DC_Game.game.getUnits().parallelStream().distinct().collect(Collectors.toSet())
    // : getFilter(active).getObjects();
    // wasValid = objSet.size() > 0 &&
    // active.canBeManuallyActivated();
    // } else
    wasValid = active.canBeManuallyActivated();
    final boolean valid = wasValid;
    TextureRegion textureRegion = getOrCreateR(active.getImagePath());
    // valid ? now via Shader!
    // getOrCreateR(active.getImagePath()) :
    // getOrCreateGrayscaleR(active.getImagePath());
    Runnable runnable = () -> {
        if (valid) {
            Context context = new Context(active.getOwnerObj().getRef());
            if (target != null)
                if (!target.equals(active.getOwnerObj())) {
                    context.setTarget(target.getId());
                }
            Eidolons.getGame().getGameLoop().actionInput(new ActionInput(active, context));
        } else {
            FloatingTextMaster.getInstance().createFloatingText(TEXT_CASES.CANNOT_ACTIVATE, "", active);
        }
    };
    return new RadialValueContainer(textureRegion, runnable, valid, active, target);
}
Also used : Context(main.game.logic.action.context.Context) TextureRegion(com.badlogic.gdx.graphics.g2d.TextureRegion) ActionInput(eidolons.game.core.ActionInput)

Example 2 with Context

use of main.game.logic.action.context.Context in project Eidolons by IDemiurge.

the class Executor method activateOn.

public void activateOn(Ref ref) {
    targeter.setForcePresetTarget(true);
    Eidolons.getGame().getGameLoop().actionInput(new ActionInput(getAction(), new Context(ref)));
}
Also used : Context(main.game.logic.action.context.Context) AnimContext(eidolons.libgdx.anims.AnimContext) ActionInput(eidolons.game.core.ActionInput)

Example 3 with Context

use of main.game.logic.action.context.Context 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 4 with Context

use of main.game.logic.action.context.Context in project Eidolons by IDemiurge.

the class ExplorationAiMaster method aiMoves.

private void aiMoves(UnitAI ai) {
    ActionInput input = new ActionInput(ai.getStandingOrders().getCurrentAction().getActive(), new Context(ai.getStandingOrders().getCurrentAction().getRef()));
    queueAiAction(input);
    ai.setExplorationTimeOfLastAction(master.getTimeMaster().getTime());
    if (ai.getStandingOrders().getCurrentAction() == ai.getStandingOrders().getLastAction())
        ai.setStandingOrders(null);
}
Also used : Context(main.game.logic.action.context.Context) ActionInput(eidolons.game.core.ActionInput)

Example 5 with Context

use of main.game.logic.action.context.Context in project Eidolons by IDemiurge.

the class PriorityManagerImpl method getAttackPriority.

@Override
public int getAttackPriority(DC_ActiveObj active, BattleFieldObject targetObj) {
    if (getUnit().getBehaviorMode() != AiEnums.BEHAVIOR_MODE.BERSERK && getUnit().getBehaviorMode() != AiEnums.BEHAVIOR_MODE.CONFUSED) {
        if (targetObj.isOwnedBy(active.getOwnerObj().getOwner())) {
            return -10000;
        }
    }
    boolean attack = !(active instanceof DC_SpellObj);
    int enemy_priority = getUnitPriority(targetObj);
    int priority = enemy_priority;
    int damage_priority = getDamagePriority(active, targetObj, attack);
    if (active.isThrow()) {
        if (damage_priority < getUnitPriority(targetObj) * 2) {
            // TODO
            return -1;
        }
    }
    // getActionNumberFactor
    int counter_penalty = 0;
    if (active.getActionGroup() != ActionEnums.ACTION_TYPE_GROUPS.ATTACK) {
    // if (AttackOfOpportunityRule.checkAction(active)) {
    // counter_penalty = getAttackOfOpportunityPenalty(active,
    // targetObj);
    // }
    } else {
        if (!active.isRanged() && targetObj.canCounter() && !getUnit().checkPassive(UnitEnums.STANDARD_PASSIVES.NO_RETALIATION) && !active.checkProperty(G_PROPS.STANDARD_PASSIVES, UnitEnums.STANDARD_PASSIVES.NO_RETALIATION.getName())) {
            if ((damage_priority != getLethalDamagePriority() && damage_priority != getUnconsciousDamagePriority()) || targetObj.checkPassive(UnitEnums.STANDARD_PASSIVES.FIRST_STRIKE)) {
                counter_penalty = getCounterPenalty(active, (Unit) targetObj);
            }
        }
    }
    // TODO spells!
    if (active instanceof DC_SpellObj) {
        // check mod effects too
        Action action = AiActionFactory.newAction(active, new Context(getUnit(), targetObj));
        damage_priority += getSpellPriority(GOAL_TYPE.DEBILITATE, action);
        damage_priority += getSpellPriority(GOAL_TYPE.DEBUFF, action);
        if (getUnit().getAiType().isCaster()) {
            damage_priority *= 4;
        }
    } else {
        if (active.isRanged()) {
            if (getUnit().getAiType() == AiEnums.AI_TYPE.ARCHER) {
                damage_priority *= 2;
            }
        } else if (getUnit().getAiType() == AiEnums.AI_TYPE.BRUTE) {
            damage_priority *= 2;
        }
    }
    damage_priority = Math.max(getConstInt(AiConst.DAMAGE_PERCENTAGE_MOD_MINIMUM), damage_priority - counter_penalty);
    priority = priority * damage_priority / 100;
    priority += getConstInt((active instanceof DC_SpellObj) ? AiConst.DEFAULT_SPELL_ATTACK_PRIORITY : AiConst.DEFAULT_ATTACK_PRIORITY);
    if (active.isThrow()) {
        try {
            applyThrowPenalty(active);
            priority = this.priority;
        } catch (Exception e) {
            main.system.ExceptionMaster.printStackTrace(e);
            addMultiplier(-50, "throw");
        }
    }
    if (targetObj.isNeutral()) {
        addMultiplier(-90, "Neutral");
    }
    return priority;
}
Also used : Context(main.game.logic.action.context.Context) Action(eidolons.game.battlecraft.ai.elements.actions.Action) AiQuickItemAction(eidolons.game.battlecraft.ai.elements.actions.AiQuickItemAction) DC_UnitAction(eidolons.entity.active.DC_UnitAction) DC_QuickItemAction(eidolons.entity.active.DC_QuickItemAction) DC_SpellObj(eidolons.entity.active.DC_SpellObj) Unit(eidolons.entity.obj.unit.Unit)

Aggregations

Context (main.game.logic.action.context.Context)14 ActionInput (eidolons.game.core.ActionInput)9 Unit (eidolons.entity.obj.unit.Unit)4 DC_UnitAction (eidolons.entity.active.DC_UnitAction)3 InputEvent (com.badlogic.gdx.scenes.scene2d.InputEvent)2 ClickListener (com.badlogic.gdx.scenes.scene2d.utils.ClickListener)2 Action (eidolons.game.battlecraft.ai.elements.actions.Action)2 DungeonObj (eidolons.game.module.dungeoncrawl.objects.DungeonObj)2 TextureRegion (com.badlogic.gdx.graphics.g2d.TextureRegion)1 Actor (com.badlogic.gdx.scenes.scene2d.Actor)1 DC_QuickItemAction (eidolons.entity.active.DC_QuickItemAction)1 DC_SpellObj (eidolons.entity.active.DC_SpellObj)1 DC_Obj (eidolons.entity.obj.DC_Obj)1 AiQuickItemAction (eidolons.game.battlecraft.ai.elements.actions.AiQuickItemAction)1 ActionPath (eidolons.game.battlecraft.ai.tools.path.ActionPath)1 AnimContext (eidolons.libgdx.anims.AnimContext)1 GearCluster (eidolons.libgdx.gui.generic.GearCluster)1 SelectiveTargeting (main.elements.targeting.SelectiveTargeting)1 Obj (main.entity.obj.Obj)1 Coordinates (main.game.bf.Coordinates)1