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;
}
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);
}
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;
}
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);
}
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);
}
Aggregations