use of main.elements.targeting.SelectiveTargeting in project Eidolons by IDemiurge.
the class AiExecutor method execute.
public boolean execute(Action action, boolean free) {
boolean result = false;
Ref ref = action.getRef();
if (free) {
action.getActive().setFree(true);
}
try {
if (!action.getActive().isChanneling()) {
if (ref.getTargetObj() == null) {
if (!(action.getActive().getTargeting() instanceof SelectiveTargeting)) {
result = true;
action.getActive().getHandler().activateOnGameLoopThread();
}
}
}
if (!result) {
action.getActive().getHandler().activateOn(ref);
result = true;
}
// WaitMaster.waitForInput(WAIT_OPERATIONS.ACTION_COMPLETE);
return result;
} catch (Exception e) {
main.system.ExceptionMaster.printStackTrace(e);
} finally {
action.getActive().setFree(false);
}
return result;
}
use of main.elements.targeting.SelectiveTargeting in project Eidolons by IDemiurge.
the class ActivesConstructor method getDefaultSingleTargeting.
public static Targeting getDefaultSingleTargeting(DC_ActiveObj entity) {
Conditions conditions = (DC_ConditionMaster.getSelectiveTargetingTemplateConditions(DEFAULT_TARGETING_TEMPLATE));
Targeting targeting = new SelectiveTargeting(conditions);
return targeting;
}
use of main.elements.targeting.SelectiveTargeting in project Eidolons by IDemiurge.
the class ActionExecutor method createTargeter.
@Override
protected Targeter createTargeter(DC_ActiveObj active, ActiveMaster entityMaster) {
return new Targeter(active, entityMaster) {
@Override
public Targeting getTargeting() {
initTargetingMode();
if (AI_Manager.isRunning()) {
return super.getTargeting();
}
if (getAction().isAttackGeneric()) {
Conditions conditions = new OrConditions();
int maxRange = 0;
for (DC_ActiveObj attack : getAction().getSubActions()) {
if (attack.isThrow()) {
continue;
}
if (!attack.canBeActivated()) {
continue;
}
conditions.add(attack.getTargeting().getFilter().getConditions());
if (maxRange < attack.getRange()) {
maxRange = attack.getRange();
}
}
conditions.setFastFailOnCheck(true);
conditions = ConditionMaster.getFilteredConditions(conditions, DistanceCondition.class);
conditions.add(new DistanceCondition("" + maxRange));
SelectiveTargeting selectiveTargeting = new SelectiveTargeting(SELECTIVE_TARGETING_TEMPLATES.ATTACK, conditions);
return selectiveTargeting;
}
return super.getTargeting();
}
};
}
use of main.elements.targeting.SelectiveTargeting in project Eidolons by IDemiurge.
the class DefaultActionHandler method leftClickCell.
public static boolean leftClickCell(boolean turn, boolean moveTo, int gridX, int gridY) {
Unit source = null;
try {
source = Eidolons.getGame().getManager().getActiveObj();
} catch (Exception e) {
main.system.ExceptionMaster.printStackTrace(e);
}
if (source == null)
return false;
if (source.isAiControlled())
return false;
Coordinates c = new Coordinates(gridX, gridY);
if (turn) {
return turnToMotion(source, c);
}
if (moveTo) {
return moveToMotion(source, c);
}
if (source.getGame().isDebugMode()) {
return doDebugStuffCell(source, c);
}
if (c.x - source.getX() > 1) {
return false;
}
if (c.y - source.getY() > 1) {
return false;
}
DC_UnitAction action = getMoveToCellAction(source, c);
if (action == null) {
return false;
}
Obj target = action.getTargeting() instanceof SelectiveTargeting ? Eidolons.getGame().getCellByCoordinate(c) : null;
Context context = new Context(source, target);
return activate(context, action);
}
use of main.elements.targeting.SelectiveTargeting in project Eidolons by IDemiurge.
the class TossItemEffect method applyThis.
/*
* size? from hand?
*
* interrupt?
*/
@Override
public boolean applyThis() {
Unit source = (Unit) ref.getSourceObj();
Ref REF = ref.getCopy();
conditions = new OrConditions(DC_ConditionMaster.getSelectiveTargetingTemplateConditions(SELECTIVE_TARGETING_TEMPLATES.MY_ITEM), DC_ConditionMaster.getSelectiveTargetingTemplateConditions(SELECTIVE_TARGETING_TEMPLATES.MY_WEAPON));
if (!new SelectiveTargeting(conditions).select(REF)) {
ref.getActive().setCancelled(true);
return false;
}
DC_HeroItemObj item = (DC_HeroItemObj) REF.getTargetObj();
conditions = new Conditions(// ++ Max distance?
new DistanceCondition(ref.getActive().getIntParam(PARAMS.RANGE, false) + ""), // new NumericCondition("{match_c_n_of_actions}", "1"),
new CanActCondition(KEYS.MATCH), new NotCondition(ConditionMaster.getSelfFilterCondition()), DC_ConditionMaster.getSelectiveTargetingTemplateConditions(SELECTIVE_TARGETING_TEMPLATES.ANY_ALLY));
// non-immobile, ++facing?
if (!new SelectiveTargeting(conditions).select(REF)) {
ref.getActive().setCancelled(true);
return false;
}
Unit unit = (Unit) REF.getTargetObj();
boolean result = roll(source, unit, item);
if (item instanceof DC_QuickItemObj) {
DC_QuickItemObj quickItem = (DC_QuickItemObj) item;
source.removeQuickItem(quickItem);
if (result) {
unit.addQuickItem(quickItem);
} else {
dropped(item, unit);
}
} else {
source.unequip(item, null);
if (result) {
// TODO equip in hand if
unit.addItemToInventory(item);
} else // possible? spend AP?
{
dropped(item, unit);
}
}
// ref.getObj(KEYS.ITEM);
unit.modifyParameter(PARAMS.C_N_OF_ACTIONS, -1);
return true;
}
Aggregations