Search in sources :

Example 16 with DC_UnitAction

use of eidolons.entity.active.DC_UnitAction in project Eidolons by IDemiurge.

the class DualAttackMaster method createDual.

private static DC_UnitAction createDual(DC_UnitAction main, DC_UnitAction offhand) {
    Costs costs = getDualCosts(main, offhand);
    // cooldown!
    ActiveAbility activateAttacks = new ActiveAbility(main.getTargeting(), new Effects(new ActivateEffect(main.getName(), true), new ActivateEffect(offhand.getName(), true)));
    Ability setCooldown = new ActiveAbility(new AutoTargeting(new PropCondition(G_PROPS.ACTION_TAGS, "Dual", false)), new ModifyValueEffect(PARAMS.C_COOLDOWN, MOD.SET, getCooldown(main.getOwnerObj())));
    Abilities abilities = new Abilities();
    abilities.add(activateAttacks);
    abilities.add(setCooldown);
    ObjType newType = new ObjType("Dual: " + main.getName() + " and " + offhand.getName(), DataManager.getType("Dual Attack", DC_TYPE.ACTIONS));
    for (Cost cost : costs.getCosts()) {
        PARAMETER p = cost.getCostParam();
        if (p == null)
            continue;
        newType.setParam(p, cost.getPayment().getAmountFormula().toString());
    }
    DC_UnitAction dual = new DC_UnitAction(newType, main.getOwner(), main.getGame(), new Ref(main.getOwnerObj()));
    dual.setAbilities(abilities);
    dual.setCosts(costs);
    dual.setTargeting(main.getTargeting());
    dual.getTargeter().setTargetingInitialized(true);
    dual.setConstructed(true);
    return dual;
}
Also used : ActiveAbility(main.ability.ActiveAbility) ActiveAbility(main.ability.ActiveAbility) Ability(main.ability.Ability) AutoTargeting(main.elements.targeting.AutoTargeting) Costs(main.elements.costs.Costs) Abilities(main.ability.Abilities) ModifyValueEffect(eidolons.ability.effects.common.ModifyValueEffect) Effects(main.ability.effects.Effects) PropCondition(main.elements.conditions.PropCondition) Cost(main.elements.costs.Cost) DC_UnitAction(eidolons.entity.active.DC_UnitAction) Ref(main.entity.Ref) ObjType(main.entity.type.ObjType) ActivateEffect(eidolons.ability.effects.oneshot.activation.ActivateEffect) PARAMETER(main.content.values.parameters.PARAMETER)

Example 17 with DC_UnitAction

use of eidolons.entity.active.DC_UnitAction in project Eidolons by IDemiurge.

the class ToolTipMaster method getActionTargetingTooltip.

public static String getActionTargetingTooltip(DC_Obj target, DC_ActiveObj active) {
    if (active == null) {
        return "";
    }
    String tooltip = "";
    ACTION_TOOL_TIP_CASE _case = null;
    AI_LOGIC spellLogic = AI_SpellMaster.getSpellLogic(active);
    if (spellLogic == null) {
        if (active instanceof DC_UnitAction) {
            if (active.getActionGroup() == ActionEnums.ACTION_TYPE_GROUPS.ATTACK) {
                _case = ACTION_TOOL_TIP_CASE.DAMAGE;
            }
        }
    }
    if (spellLogic != null) {
        switch(spellLogic) {
            case BUFF_NEGATIVE:
            case BUFF_POSITIVE:
                _case = ACTION_TOOL_TIP_CASE.BUFF;
                break;
            case CUSTOM_HOSTILE:
            case CUSTOM_SUPPORT:
                _case = ACTION_TOOL_TIP_CASE.SPECIAL;
                break;
            case AUTO_DAMAGE:
            case DAMAGE:
            case DAMAGE_ZONE:
                _case = ACTION_TOOL_TIP_CASE.DAMAGE;
                break;
            case RESTORE:
                break;
        }
    }
    if (_case == null) {
        return "";
    }
    switch(_case) {
        case BUFF:
            break;
        case DAMAGE:
            boolean attack = !(active instanceof DC_SpellObj);
            int damage = FutureBuilder.precalculateDamage(active, target, attack);
            // ++ damage type
            // MIN-MAX is really in
            tooltip += "avrg. damage: " + damage;
            // order
            if (DamageCalculator.isLethal(damage, target)) {
                // TODO possibly lethal
                tooltip += "(lethal)";
            } else {
                if (attack) {
                    if (((Unit) target).canCounter(active)) {
                        // TODO precalc dmg?
                        tooltip += "(will retaliate)";
                    }
                }
            }
            break;
        case SPECIAL:
            break;
    }
    return tooltip;
}
Also used : AI_LOGIC(main.content.enums.system.AiEnums.AI_LOGIC) DC_SpellObj(eidolons.entity.active.DC_SpellObj) Unit(eidolons.entity.obj.unit.Unit) DC_UnitAction(eidolons.entity.active.DC_UnitAction)

Example 18 with DC_UnitAction

use of eidolons.entity.active.DC_UnitAction in project Eidolons by IDemiurge.

the class CellPrioritizer method getPriorityForCell.

/*
     * Perhaps one could feed an action to this method!.. Or actions...
     */
public int getPriorityForCell(Unit unit, Obj cell, DC_ActiveObj targetAcsdftion) {
    /*
         * getOrCreate attack priority for each adjacent enemy...
		 */
    /*
         * I could exclude paths for zone spells, let the range be the limit for
		 * now
		 */
    int priority = 0;
    List<ActionPath> paths = pathMap.get(cell.getCoordinates());
    if (paths == null) {
        paths = getPathBuilder().init(moves, targetAction).build(new ListMaster<Coordinates>().getList(cell.getCoordinates()));
        pathMap.put(cell.getCoordinates(), paths);
    }
    if (!ListMaster.isNotEmpty(paths)) {
        return 0;
    }
    int path_priority = paths.get(0).getPriority();
    for (Coordinates c : cell.getCoordinates().getAdjacentCoordinates()) {
        Obj targetObj = unit.getGame().getObjectByCoordinate(c, false);
        if (targetObj != null) {
            if (targetObj.getOBJ_TYPE_ENUM() != DC_TYPE.BF_OBJ) {
                if (Analyzer.isEnemy(targetObj, unit)) {
                    Integer cell_priority = enemyPriorityMap.get(targetObj);
                    if (cell_priority != null) {
                        priority += cell_priority;
                        continue;
                    }
                    Unit enemy = (Unit) targetObj;
                    cell_priority = DC_PriorityManager.getUnitPriority(targetObj);
                    // "now"?
                    cell_priority -= DC_PriorityManager.getMeleeThreat(enemy);
                    // should all AI-units *be afraid*? :) Maybe memory map
                    // will do nicely here?
                    // if ()
                    Action action = new Action(unit.getAction("attack"), enemy);
                    // if (melee )
                    // PriorityManager.getDamagePriority(action, targetObj,
                    // false);
                    priority += DC_PriorityManager.getAttackPriority(new ActionSequence(action));
                    DC_UnitAction offhand_attack = unit.getAction("offhand attack");
                    // use its priority?
                    if (offhand_attack != null) {
                        action = new Action(offhand_attack, enemy);
                        priority += DC_PriorityManager.getAttackPriority(new ActionSequence(action));
                    }
                    // do we calculate move costs before or after?
                    enemyPriorityMap.put(targetObj, cell_priority);
                    priority += cell_priority;
                }
            }
        }
    }
    priority += priority * path_priority / 100;
    return priority;
}
Also used : Action(eidolons.game.battlecraft.ai.elements.actions.Action) DC_UnitAction(eidolons.entity.active.DC_UnitAction) ActionSequence(eidolons.game.battlecraft.ai.elements.actions.sequence.ActionSequence) DC_Obj(eidolons.entity.obj.DC_Obj) DC_ActiveObj(eidolons.entity.active.DC_ActiveObj) Obj(main.entity.obj.Obj) Coordinates(main.game.bf.Coordinates) Unit(eidolons.entity.obj.unit.Unit) DC_UnitAction(eidolons.entity.active.DC_UnitAction)

Example 19 with DC_UnitAction

use of eidolons.entity.active.DC_UnitAction in project Eidolons by IDemiurge.

the class AtomicAi method getAtomicActionDoor.

public Action getAtomicActionDoor(UnitAI ai) {
    Coordinates c = getDoorCoordinates(ai);
    if (c == null)
        return null;
    Door door = (Door) game.getObjectByCoordinate(c);
    DC_UnitAction action = game.getDungeonMaster().getDungeonObjMaster(DUNGEON_OBJ_TYPE.DOOR).createAction(DOOR_ACTION.OPEN, ai.getUnit(), door);
    return AiActionFactory.newAction(action, ai.getUnit().getRef().getTargetingRef(door));
}
Also used : Coordinates(main.game.bf.Coordinates) DC_UnitAction(eidolons.entity.active.DC_UnitAction) Door(eidolons.game.module.dungeoncrawl.objects.Door)

Example 20 with DC_UnitAction

use of eidolons.entity.active.DC_UnitAction in project Eidolons by IDemiurge.

the class DoorMaster method getActions.

public List<DC_ActiveObj> getActions(DungeonObj door, Unit unit) {
    if (!(door instanceof Door))
        return new ArrayList<>();
    if (!checkUnitCanHandleActions(unit)) {
        return new ArrayList<>();
    }
    // check intelligence, mastery
    List<DC_ActiveObj> list = new ArrayList<>();
    DC_UnitAction action = null;
    for (DOOR_ACTION sub : DOOR_ACTION.values()) {
        if (checkAction(unit, (Door) door, sub)) {
            action = createAction(sub, unit, door);
            if (action != null) {
                list.add(action);
            }
        }
    }
    return list;
}
Also used : ArrayList(java.util.ArrayList) DC_ActiveObj(eidolons.entity.active.DC_ActiveObj) DC_UnitAction(eidolons.entity.active.DC_UnitAction) DOOR_ACTION(eidolons.game.module.dungeoncrawl.objects.DoorMaster.DOOR_ACTION)

Aggregations

DC_UnitAction (eidolons.entity.active.DC_UnitAction)22 DC_ActiveObj (eidolons.entity.active.DC_ActiveObj)10 ArrayList (java.util.ArrayList)10 Unit (eidolons.entity.obj.unit.Unit)4 Obj (main.entity.obj.Obj)3 PARAMS (eidolons.content.PARAMS)2 DC_SpellObj (eidolons.entity.active.DC_SpellObj)2 DC_Obj (eidolons.entity.obj.DC_Obj)2 Action (eidolons.game.battlecraft.ai.elements.actions.Action)2 ValueContainer (eidolons.libgdx.gui.generic.ValueContainer)2 Ref (main.entity.Ref)2 ObjType (main.entity.type.ObjType)2 Coordinates (main.game.bf.Coordinates)2 Context (main.game.logic.action.context.Context)2 TextureRegion (com.badlogic.gdx.graphics.g2d.TextureRegion)1 FacingCondition (eidolons.ability.conditions.FacingCondition)1 ModifyValueEffect (eidolons.ability.effects.common.ModifyValueEffect)1 ActivateEffect (eidolons.ability.effects.oneshot.activation.ActivateEffect)1 UNIT_INFO_PARAMS (eidolons.content.UNIT_INFO_PARAMS)1 DC_ActionManager (eidolons.entity.active.DC_ActionManager)1