Search in sources :

Example 6 with Costs

use of main.elements.costs.Costs 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 7 with Costs

use of main.elements.costs.Costs in project Eidolons by IDemiurge.

the class PriorityModifier method getCostPenalty.

public int getCostPenalty(ActionSequence as) {
    Costs cost = ActionManager.getTotalCost(as.getActions());
    int cost_penalty = 100 - getParamAnalyzer().getCostPriorityFactor(cost, getUnit());
    String string = "cost";
    try {
        if (as.getLastAction().getActive().isChanneling()) {
            cost_penalty += cost_penalty * cost.getCost(PARAMS.C_N_OF_ACTIONS).getPayment().getAmountFormula().getInt(as.getLastAction().getRef()) / 5;
            string = "channeling cost";
        }
    } catch (Exception e) {
        main.system.ExceptionMaster.printStackTrace(e);
    }
    return (cost_penalty);
}
Also used : Costs(main.elements.costs.Costs)

Example 8 with Costs

use of main.elements.costs.Costs in project Eidolons by IDemiurge.

the class PathBuilder method getPathPriority.

private Integer getPathPriority() {
    Costs cost = getPathCosts(path);
    int result = DC_PriorityManager.getCostFactor(cost, unit);
    // try {
    // result += getAoOPenalty(); TODO instant atks preCheck !
    // } catch (Exception e) {
    // main.system.ExceptionMaster.printStackTrace(e);
    // }
    int size = path.getActions().size();
    result = result * getParamAnalyzer().getActionNumberFactor(size) / 100;
    path.setPriority(result);
    return result;
}
Also used : Costs(main.elements.costs.Costs)

Example 9 with Costs

use of main.elements.costs.Costs in project Eidolons by IDemiurge.

the class ActiveInitializer method initCosts.

public void initCosts(boolean anim) {
    Costs costs = null;
    if (getEntity().isFree()) {
        costs = new Costs(new ArrayList<>());
    } else {
        try {
            costs = DC_CostsFactory.getCostsForSpell(getEntity(), getChecker().isSpell());
        } catch (Exception e) {
            main.system.ExceptionMaster.printStackTrace(e);
        }
        Cost cp_cost = costs.getCost(PARAMS.C_N_OF_COUNTERS);
        Formula ap_cost = DC_Engine.isAtbMode() ? new Formula(getParam(PARAMS.AP_COST)) : costs.getCost(PARAMS.C_N_OF_ACTIONS).getPayment().getAmountFormula();
        boolean noCounterCost = cp_cost == null;
        if (!noCounterCost) {
            noCounterCost = cp_cost.getPayment().getAmountFormula().toString().isEmpty() || cp_cost.getPayment().getAmountFormula().toString().equals("0");
        }
        if (noCounterCost) {
            // if not specifically set...
            if (getHandler().isExtraAttackMode()) {
                cp_cost = new CostImpl(new Payment(PARAMS.C_N_OF_COUNTERS, (ap_cost)));
                cp_cost.getPayment().getAmountFormula().applyModifier(getEntity().getOwnerObj().getIntParam(PARAMS.EXTRA_ATTACKS_POINT_COST_MOD));
                cp_cost.setCostParam(PARAMS.CP_COST);
            }
        } else {
            if (!(getHandler().isExtraAttackMode())) {
                costs.getCosts().remove(cp_cost);
            }
        }
        if (!DC_Engine.isAtbMode())
            if (getHandler().isAttackOfOpportunityMode()) {
                // TODO only if watched? better
                // here perhaps!
                cp_cost.addAltCost(new CostImpl(new Payment(PARAMS.C_N_OF_ACTIONS, ap_cost)));
            }
        costs.removeCost(getHandler().isExtraAttackMode() ? PARAMS.C_N_OF_ACTIONS : PARAMS.C_N_OF_COUNTERS);
    }
    if (anim) {
    // getAnimator().  addCostAnim();
    }
    costs.setActive(getEntity());
    // TODO what for?
    // if (!getHandler().isInstantMode() || getHandler().isCounterMode()) {
    // getHandler().getActivator().setCanActivate(costs.canBePaid(getRef()));
    // }
    costs.setActiveId(getId());
    if (getEntity().isAttackAny())
        if (getEntity().isExtraAttackMode())
            applyDynamicCostMods(costs);
    getEntity().setCosts(costs);
}
Also used : Formula(main.system.math.Formula) Costs(main.elements.costs.Costs) Payment(main.elements.costs.Payment) ArrayList(java.util.ArrayList) CostImpl(main.elements.costs.CostImpl) Cost(main.elements.costs.Cost)

Example 10 with Costs

use of main.elements.costs.Costs in project Eidolons by IDemiurge.

the class SpellInitializer method initCosts.

@Override
public void initCosts() {
    Costs costs;
    costs = DC_CostsFactory.getCostsForSpell(getEntity(), // isSpell()
    true);
    costs.getRequirements().add(new Requirement(new NotCondition(new StatusCheckCondition(UnitEnums.STATUS.SILENCED)), InfoMaster.SILENCE));
    costs.setActive(getEntity());
    getEntity().getActivator().setCanActivate(costs.canBePaid(getRef()));
    getEntity().setCosts(costs);
}
Also used : Requirement(main.elements.conditions.Requirement) Costs(main.elements.costs.Costs) NotCondition(main.elements.conditions.NotCondition) StatusCheckCondition(eidolons.ability.conditions.StatusCheckCondition)

Aggregations

Costs (main.elements.costs.Costs)10 Cost (main.elements.costs.Cost)6 PARAMETER (main.content.values.parameters.PARAMETER)4 ArrayList (java.util.ArrayList)3 CostImpl (main.elements.costs.CostImpl)2 Payment (main.elements.costs.Payment)2 Formula (main.system.math.Formula)2 StatusCheckCondition (eidolons.ability.conditions.StatusCheckCondition)1 ModifyValueEffect (eidolons.ability.effects.common.ModifyValueEffect)1 ActivateEffect (eidolons.ability.effects.oneshot.activation.ActivateEffect)1 PARAMS (eidolons.content.PARAMS)1 DC_UnitAction (eidolons.entity.active.DC_UnitAction)1 Abilities (main.ability.Abilities)1 Ability (main.ability.Ability)1 ActiveAbility (main.ability.ActiveAbility)1 Effects (main.ability.effects.Effects)1 XLinkedMap (main.data.XLinkedMap)1 NotCondition (main.elements.conditions.NotCondition)1 PropCondition (main.elements.conditions.PropCondition)1 Requirement (main.elements.conditions.Requirement)1