use of main.elements.targeting.AutoTargeting in project Eidolons by IDemiurge.
the class ShapeEffect method initTargeting.
@Override
public void initTargeting() {
// init unit group
Coordinates baseCoordinate = getBaseCoordinate();
int base_width = radius.getInt(ref);
int distance = this.distance.getInt(ref);
coordinates = DC_PositionMaster.getShapedCoordinates(baseCoordinate, getFacing(), base_width, distance, getShape());
DequeImpl<Obj> objects = new DequeImpl<>();
objects.addAllCast(getGame().getMaster().getUnitsForCoordinates(coordinates));
Filter.filter(objects, targetType);
if (allyOrEnemyOnly != null) {
if (allyOrEnemyOnly) {
FilterMaster.applyFilter(objects, FILTERS.ALLY, ref, false);
} else {
FilterMaster.applyFilter(objects, FILTERS.ENEMY, ref, false);
}
}
if (notSelf) {
FilterMaster.applyFilter(objects, FILTERS.NOT_SELF, ref, false);
}
if (targetType.equals(DC_TYPE.TERRAIN)) {
// C_TYPE equals if contains() !
objects.addAll(game.getCellsForCoordinates(coordinates));
}
targeting = new AutoTargeting(new GroupImpl(objects));
setFilteringConditions(new Conditions());
targeting.setConditions(getFilteringConditions());
}
use of main.elements.targeting.AutoTargeting 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.elements.targeting.AutoTargeting in project Eidolons by IDemiurge.
the class AbilityImpl method activatedOn.
@Override
public boolean activatedOn(Ref ref) {
setRef(ref);
// preCheck if targeting is overridden
if (!(targeting instanceof AutoTargeting)) {
if (!(targeting instanceof FixedTargeting)) {
if (isForcePresetTargeting() || targeting == null) {
if (ref.getTarget() != null || ref.getGroup() != null) {
// without targeting.select()
return resolve();
} else {
// inconsistent data
return false;
}
}
}
}
boolean selectResult = targeting.select(ref);
ActiveObj a = ref.getActive();
if (selectResult) {
if (a != null) {
a.setCancelled(null);
}
return resolve();
} else {
if (a != null) {
if (a.isCancelled() != null) {
a.setCancelled(true);
}
}
return false;
}
}
use of main.elements.targeting.AutoTargeting in project Eidolons by IDemiurge.
the class BindingDamageEffect method applyThis.
@Override
public boolean applyThis() {
// Can be initialized() just once
GroupImpl group = ref.getGroup();
Effects effects = new Effects();
STANDARD_EVENT_TYPE event_type;
if (shareOrRedirect) {
// TODO splitMode!
event_type = STANDARD_EVENT_TYPE.UNIT_IS_DEALT_TOUGHNESS_DAMAGE;
if (spellDmgOnly != null) {
if (spellDmgOnly) {
event_type = STANDARD_EVENT_TYPE.UNIT_HAS_BEEN_DEALT_SPELL_DAMAGE;
}
}
if (physicalDmgOnly != null) {
if (physicalDmgOnly) {
event_type = STANDARD_EVENT_TYPE.UNIT_HAS_BEEN_DEALT_PHYSICAL_DAMAGE;
}
}
} else {
effects.add(new AlteringEffect(false, formula.getNegative().toString()));
event_type = Event.STANDARD_EVENT_TYPE.UNIT_IS_BEING_DEALT_DAMAGE;
if (spellDmgOnly != null) {
if (spellDmgOnly) {
event_type = STANDARD_EVENT_TYPE.UNIT_IS_BEING_DEALT_SPELL_DAMAGE;
}
}
if (physicalDmgOnly != null) {
if (physicalDmgOnly) {
event_type = STANDARD_EVENT_TYPE.UNIT_IS_BEING_DEALT_PHYSICAL_DAMAGE;
}
}
}
Targeting targeting_other_units = new AutoTargeting(new Conditions(new GroupCondition(Ref.KEYS.MATCH.name(), group), // negative
new RefCondition(KEYS.EVENT_TARGET, KEYS.MATCH, true)));
effects.add(new CustomTargetEffect(targeting_other_units, new DealDamageEffect(getDamageFormula(), GenericEnums.DAMAGE_TYPE.PURE)));
/*
* ensure there is no deadlock
*/
conditions = new Conditions();
conditions.add(new NonTriggeredEventCondition());
KEYS OBJ_REF = Ref.KEYS.EVENT_TARGET;
conditions.add(new GroupCondition(OBJ_REF, group));
// has the group...
Ref REF = Ref.getCopy(ref);
// REF.setTarget(null); // ???
new AddTriggerEffect(event_type, conditions, OBJ_REF, effects).apply(REF);
return true;
}
use of main.elements.targeting.AutoTargeting in project Eidolons by IDemiurge.
the class RayEffect method initTargeting.
public void initTargeting() {
Conditions conditions = new Conditions();
if (distance != null) {
conditions.add(ConditionMaster.getDistanceFilterCondition(KEYS.SOURCE.toString(), distance));
}
if (PositionMaster.inLine(ref.getTargetObj().getCoordinates(), ref.getSourceObj().getCoordinates())) {
conditions.add(ConditionMaster.getLineCondition(ref.getSourceObj(), ref.getTargetObj(), false));
} else {
conditions.add(ConditionMaster.getDiagonalLineCondition(ref.getSourceObj(), ref.getTargetObj(), false));
}
// conditions.add(ConditionMaster.getUnitTypeCondition());
conditions.add(ConditionMaster.getNotDeadCondition());
if (allyOrEnemyOnly != null) {
if (allyOrEnemyOnly) {
conditions.add(ConditionMaster.getAllyCondition());
} else {
conditions.add(ConditionMaster.getEnemyCondition());
}
}
if (ref.getObj(KEYS.ACTIVE).checkBool(GenericEnums.STD_BOOLS.BLOCKED)) {
conditions.add(DC_ConditionMaster.getClearShotFilterCondition());
}
this.targeting = new AutoTargeting(conditions, DataManager.BF_TYPES);
setFilteringConditions(conditions);
}
Aggregations