use of main.game.logic.action.context.Context in project Eidolons by IDemiurge.
the class RadialManager method configureSelectiveTargetedNode.
protected static RadialValueContainer configureSelectiveTargetedNode(DC_ActiveObj active, DC_Obj target) {
boolean wasValid;
// if (target == null|| target.equals(active.getOwnerObj())){
// Set<Obj> objSet = CoreEngine.isActionTargetingFiltersOff() ?
// DC_Game.game.getUnits().parallelStream().distinct().collect(Collectors.toSet())
// : getFilter(active).getObjects();
// wasValid = objSet.size() > 0 &&
// active.canBeManuallyActivated();
// } else
wasValid = active.canBeManuallyActivated();
final boolean valid = wasValid;
TextureRegion textureRegion = getOrCreateR(active.getImagePath());
// valid ? now via Shader!
// getOrCreateR(active.getImagePath()) :
// getOrCreateGrayscaleR(active.getImagePath());
Runnable runnable = () -> {
if (valid) {
Context context = new Context(active.getOwnerObj().getRef());
if (target != null)
if (!target.equals(active.getOwnerObj())) {
context.setTarget(target.getId());
}
Eidolons.getGame().getGameLoop().actionInput(new ActionInput(active, context));
} else {
FloatingTextMaster.getInstance().createFloatingText(TEXT_CASES.CANNOT_ACTIVATE, "", active);
}
};
return new RadialValueContainer(textureRegion, runnable, valid, active, target);
}
use of main.game.logic.action.context.Context in project Eidolons by IDemiurge.
the class Executor method activateOn.
public void activateOn(Ref ref) {
targeter.setForcePresetTarget(true);
Eidolons.getGame().getGameLoop().actionInput(new ActionInput(getAction(), new Context(ref)));
}
use of main.game.logic.action.context.Context 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.game.logic.action.context.Context in project Eidolons by IDemiurge.
the class ExplorationAiMaster method aiMoves.
private void aiMoves(UnitAI ai) {
ActionInput input = new ActionInput(ai.getStandingOrders().getCurrentAction().getActive(), new Context(ai.getStandingOrders().getCurrentAction().getRef()));
queueAiAction(input);
ai.setExplorationTimeOfLastAction(master.getTimeMaster().getTime());
if (ai.getStandingOrders().getCurrentAction() == ai.getStandingOrders().getLastAction())
ai.setStandingOrders(null);
}
use of main.game.logic.action.context.Context in project Eidolons by IDemiurge.
the class PriorityManagerImpl method getAttackPriority.
@Override
public int getAttackPriority(DC_ActiveObj active, BattleFieldObject targetObj) {
if (getUnit().getBehaviorMode() != AiEnums.BEHAVIOR_MODE.BERSERK && getUnit().getBehaviorMode() != AiEnums.BEHAVIOR_MODE.CONFUSED) {
if (targetObj.isOwnedBy(active.getOwnerObj().getOwner())) {
return -10000;
}
}
boolean attack = !(active instanceof DC_SpellObj);
int enemy_priority = getUnitPriority(targetObj);
int priority = enemy_priority;
int damage_priority = getDamagePriority(active, targetObj, attack);
if (active.isThrow()) {
if (damage_priority < getUnitPriority(targetObj) * 2) {
// TODO
return -1;
}
}
// getActionNumberFactor
int counter_penalty = 0;
if (active.getActionGroup() != ActionEnums.ACTION_TYPE_GROUPS.ATTACK) {
// if (AttackOfOpportunityRule.checkAction(active)) {
// counter_penalty = getAttackOfOpportunityPenalty(active,
// targetObj);
// }
} else {
if (!active.isRanged() && targetObj.canCounter() && !getUnit().checkPassive(UnitEnums.STANDARD_PASSIVES.NO_RETALIATION) && !active.checkProperty(G_PROPS.STANDARD_PASSIVES, UnitEnums.STANDARD_PASSIVES.NO_RETALIATION.getName())) {
if ((damage_priority != getLethalDamagePriority() && damage_priority != getUnconsciousDamagePriority()) || targetObj.checkPassive(UnitEnums.STANDARD_PASSIVES.FIRST_STRIKE)) {
counter_penalty = getCounterPenalty(active, (Unit) targetObj);
}
}
}
// TODO spells!
if (active instanceof DC_SpellObj) {
// check mod effects too
Action action = AiActionFactory.newAction(active, new Context(getUnit(), targetObj));
damage_priority += getSpellPriority(GOAL_TYPE.DEBILITATE, action);
damage_priority += getSpellPriority(GOAL_TYPE.DEBUFF, action);
if (getUnit().getAiType().isCaster()) {
damage_priority *= 4;
}
} else {
if (active.isRanged()) {
if (getUnit().getAiType() == AiEnums.AI_TYPE.ARCHER) {
damage_priority *= 2;
}
} else if (getUnit().getAiType() == AiEnums.AI_TYPE.BRUTE) {
damage_priority *= 2;
}
}
damage_priority = Math.max(getConstInt(AiConst.DAMAGE_PERCENTAGE_MOD_MINIMUM), damage_priority - counter_penalty);
priority = priority * damage_priority / 100;
priority += getConstInt((active instanceof DC_SpellObj) ? AiConst.DEFAULT_SPELL_ATTACK_PRIORITY : AiConst.DEFAULT_ATTACK_PRIORITY);
if (active.isThrow()) {
try {
applyThrowPenalty(active);
priority = this.priority;
} catch (Exception e) {
main.system.ExceptionMaster.printStackTrace(e);
addMultiplier(-50, "throw");
}
}
if (targetObj.isNeutral()) {
addMultiplier(-90, "Neutral");
}
return priority;
}
Aggregations