use of eidolons.entity.obj.unit.Unit in project Eidolons by IDemiurge.
the class GoalManager method getGoalsForUnit.
public static List<GOAL_TYPE> getGoalsForUnit(UnitAI ai) {
Unit unit = ai.getUnit();
List<GOAL_TYPE> list = getBehaviorGoals(unit);
if (list != null) {
return list;
}
if (ai.getCurrentOrder() != null)
if (ai.getCurrentOrder().getStrictPriority() != null)
return new ArrayList<>(Arrays.asList(ai.getCurrentOrder().getStrictPriority().getGoalTypes()));
list = new ArrayList<>();
if (unit.getAiType() == AiEnums.AI_TYPE.SNEAK) {
list.add(AiEnums.GOAL_TYPE.STEALTH);
}
if (Analyzer.getVisibleEnemies(unit.getUnitAI()).isEmpty()) {
list = new ListMaster<GOAL_TYPE>().getList(AiEnums.GOAL_TYPE.SEARCH);
addNonEnemyGoals(list);
return list;
}
if (unit.checkAiMod(AI_MODIFIERS.TRUE_BRUTE)) {
return new ListMaster<GOAL_TYPE>().getList(AiEnums.GOAL_TYPE.ATTACK);
}
list.addAll(getDefaultGoals());
if (unit.getAiType() == AiEnums.AI_TYPE.CASTER || unit.getAiType() == AiEnums.AI_TYPE.ARCHER) {
if (!unit.checkPassive(UnitEnums.STANDARD_PASSIVES.FEARLESS)) {
if (DC_PriorityManager.getMeleeDangerFactor(unit) > 0) {
list.add(AiEnums.GOAL_TYPE.RETREAT);
}
}
}
if (Analyzer.hasAnySpecialActions(unit)) {
addNonEnemyGoals(list);
addEnemyGoals(list);
}
list.sort(getSorter(ai));
// FLEE
return list;
}
use of eidolons.entity.obj.unit.Unit in project Eidolons by IDemiurge.
the class AI_Manager method resetGroups.
private void resetGroups() {
// }
if (groups == null)
groups = new ArrayList<>();
for (Object sub : game.getBattleMaster().getPlayerManager().getPlayers()) {
DC_Player player = (DC_Player) sub;
for (Unit unit : player.getControlledUnits_()) {
GroupAI group = unit.getAI().getGroup();
if (group == null)
group = new GroupAI(unit);
for (Unit unit1 : player.getControlledUnits_()) {
if (unit1.getAI().getGroup() != null)
continue;
if (unit1.equals(unit))
continue;
double max_distance = 2.5;
if (PositionMaster.getExactDistance(unit1.getCoordinates(), unit.getCoordinates()) >= max_distance)
continue;
if (!game.getVisionMaster().getSightMaster().getClearShotCondition().check(unit, unit1))
continue;
group.add(unit1);
}
if (!groups.contains(group))
groups.add(group);
}
}
if (!groups.isEmpty())
return;
else
return;
}
use of eidolons.entity.obj.unit.Unit in project Eidolons by IDemiurge.
the class AI_Manager method chooseEnemyToEngage.
public static Unit chooseEnemyToEngage(Unit obj, List<Unit> units) {
if (obj.getAiType() == AiEnums.AI_TYPE.CASTER) {
return null;
}
if (obj.getAiType() == AiEnums.AI_TYPE.ARCHER) {
return null;
}
if (obj.getAiType() == AiEnums.AI_TYPE.SNEAK) {
return null;
}
Unit topPriorityUnit = null;
int topPriority = -1;
for (Unit u : units) {
int priority = DC_PriorityManager.getUnitPriority(u, true);
if (priority > topPriority) {
topPriority = priority;
topPriorityUnit = u;
}
}
return topPriorityUnit;
}
use of eidolons.entity.obj.unit.Unit in project Eidolons by IDemiurge.
the class BehaviorMaster method getAction.
private Action getAction(GOAL_TYPE type, UnitAI ai) {
String action = null;
Integer target = null;
// doesn't the group have standing orders as a whole?..
Unit unit = ai.getUnit();
Ref ref = new Ref(unit);
GroupAI group = ai.getGroup();
// checkBehaviorChange(group); where does that happen?
switch(type) {
case AMBUSH:
break;
case STALK:
break;
case STAND_GUARD:
case PATROL:
PatrolMaster.getPatrolAction(ai);
// having already turned on the Mode
case SEARCH:
case WANDER:
if (ai.isLeader()) {
Boolean change = WanderAi.checkWanderDirectionChange(group, type);
if (change == null) {
action = getIdleAction(ai, type);
change = true;
}
// maybe go meet leader if blocked... or something like it
if (change) {
group.getWanderStepCoordinateStack().push(group.getLeader().getCoordinates());
WanderAi.changeGroupMoveDirection(group, type);
}
}
boolean wait = false;
// ActionSequenceConstructor.getSequence(targetAction, task)
Coordinates targetCoordinates = WanderAi.getCoordinates(type, ai);
if (targetCoordinates == null) {
wait = true;
// if (!recursion)
// return null;
// recursion = true;
// return getAction(type, ai);
} else {
action = STD_ACTIONS.Move.name();
// if (!unit.getAction(action).canBeActivated()) {
// }
ActionPath path = getPathBuilder().init(new ListMaster<DC_ActiveObj>().getList(unit.getAction(action)), new Action(unit.getAction(action), new Ref(unit))).getPathByPriority(new ListMaster<Coordinates>().getList(targetCoordinates));
if (path == null) {
// TODO preCheck if path
ai.setPathBlocked(true);
// appropriate
} else {
ai.setPathBlocked(false);
return path.getActions().get(0);
}
}
if (wait) {
action = getIdleAction(ai, type);
} else {
// if (change) {
// targetCoordinates = WanderMaster.getCoordinates(type,
// ai);
// }
// return path.getActions().getOrCreate(0);
}
}
DC_ActiveObj active = unit.getAction(action);
ref.setTarget(target);
recursion = false;
return new Action(active, ref);
}
use of eidolons.entity.obj.unit.Unit in project Eidolons by IDemiurge.
the class ActionManager method checkWaitForBlockingAlly.
private Integer checkWaitForBlockingAlly() {
Coordinates c = getUnit().getCoordinates().getAdjacentCoordinate(getUnit().getFacing().getDirection());
Obj obj = getUnit().getGame().getObjectVisibleByCoordinate(c);
if (obj instanceof Unit) {
if (((Unit) obj).canActNow()) // if (!((DC_HeroObj) obj).checkStatus(STATUS.WAITING))
{
return obj.getId();
}
}
return null;
}
Aggregations