use of main.ability.Ability in project Eidolons by IDemiurge.
the class ActiveAuraEffect method applyThis.
@Override
public boolean applyThis() {
AutoTargeting targeting = new AutoTargeting(new Conditions(new ObjTypeComparison(C_OBJ_TYPE.BF_OBJ), new DistanceCondition("" + radius.getInt(ref))));
targeting.getConditions().add(ConditionMaster.getAliveCondition(KEYS.MATCH));
if (onlyEnemiesOrAllies != null) {
if (onlyEnemiesOrAllies) {
targeting.getConditions().add(ConditionMaster.getEnemyCondition());
} else {
targeting.getConditions().add(ConditionMaster.getAllyCondition());
}
}
targeting.getConditions().add(new NotCondition(new RefCondition(KEYS.MATCH, KEYS.SOURCE)));
Ability ability = new ActiveAbility(targeting, effects);
new AddTriggerEffect(event_type, conditions, ability).apply(ref);
return true;
}
use of main.ability.Ability in project Eidolons by IDemiurge.
the class WaitEffect method getAbility.
protected Ability getAbility(Ref ref) {
Effect effect = new Effects(new RemoveBuffEffect(getBuffName()));
Ability ability = new ActiveAbility(new FixedTargeting(KEYS.SOURCE), effect);
ability.setRef(ref);
return ability;
}
use of main.ability.Ability in project Eidolons by IDemiurge.
the class StateCloner method cloneAbility.
private Ability cloneAbility(Ability abilities) {
Effects effects = new Effects();
for (Effect e : abilities.getEffects()) {
effects.add(cloneEffect(e));
}
Ability ability = (abilities instanceof ActiveAbility) ? new ActiveAbility(abilities.getTargeting(), effects) : new PassiveAbility(abilities.getTargeting(), effects);
return ability;
}
use of main.ability.Ability 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.ability.Ability in project Eidolons by IDemiurge.
the class ScriptParser method parseScript.
public static <T> ScriptTrigger parseScript(String script, DC_Game game, ScriptExecutor<T> executor, Class<T> funcClass) {
// TODO
script = ScriptMaster.getScriptByName(script);
// non-trigger scripts?
String originalText = script;
String processedPart = StringMaster.getFirstItem(script, ScriptSyntax.PART_SEPARATOR);
STANDARD_EVENT_TYPE event_type = parseEvent(processedPart);
script = StringMaster.cropFirstSegment(script, ScriptSyntax.PART_SEPARATOR);
Condition condition = null;
condition = getDefaultCondition(event_type, VariableManager.getVars(processedPart));
if (condition != null) {
condition.setXml(XML_Converter.wrap("ScriptedCondition", XML_Converter.wrap("STANDARD_EVENT_TYPE", event_type.toString()) + XML_Converter.wrap("STRING", VariableManager.getVars(processedPart))));
} else {
String conditionPart = StringMaster.getFirstItem(script, ScriptSyntax.PART_SEPARATOR);
condition = parseConditions(conditionPart);
condition.setXml(conditionPart);
}
boolean isRemove = true;
// if (contains("cyclic"))remove = false;
Ability abilities = null;
// TODO Global
Ref ref = new Ref(game);
script = StringMaster.getLastPart(script, ScriptSyntax.PART_SEPARATOR);
String funcPart = VariableManager.removeVarPart(script);
@Refactor T // TODO this won't work in generic way!!!!
func = new EnumMaster<T>().retrieveEnumConst(funcClass, funcPart);
if (func != null) {
// TODO for multiple scripts, need another SEPARATOR!
String separator = executor.getSeparator(func);
List<String> strings = StringMaster.openContainer(VariableManager.getVars(script), separator);
String[] args = strings.toArray(new String[strings.size()]);
abilities = new AbilityImpl() {
@Override
public boolean activatedOn(Ref ref) {
executor.execute(func, ref, args);
// reset after? not like normal action certainly...
return true;
}
};
} else {
abilities = AbilityConstructor.getAbilities(script, ref);
if (abilities.getEffects().getEffects().isEmpty()) {
main.system.auxiliary.log.LogMaster.log(1, "SCRIPT NOT FOUND: " + funcPart);
return null;
}
}
abilities.setRef(ref);
ScriptTrigger trigger = new ScriptTrigger(originalText, event_type, condition, abilities);
trigger.setRemoveAfterTriggers(isRemove);
return trigger;
}
Aggregations