use of main.content.enums.system.AiEnums.BEHAVIOR_MODE in project Eidolons by IDemiurge.
the class ActionManager method getForcedAction.
public Action getForcedAction(UnitAI ai) {
BEHAVIOR_MODE behaviorMode = ai.getBehaviorMode();
GOAL_TYPE goal = AiEnums.GOAL_TYPE.PREPARE;
Action action = null;
if (behaviorMode != null) {
if (behaviorMode == AiEnums.BEHAVIOR_MODE.PANIC) {
action = new Action(ai.getUnit().getAction("Cower"));
}
if (behaviorMode == AiEnums.BEHAVIOR_MODE.CONFUSED) {
action = new Action(ai.getUnit().getAction("Stumble"));
}
if (behaviorMode == AiEnums.BEHAVIOR_MODE.BERSERK) {
action = new Action(ai.getUnit().getAction("Rage"));
}
action.setTaskDescription("Forced Behavior");
}
action = getAtomicAi().getAtomicActionForced(ai);
if (action != null)
return action;
try {
action = getAtomicAi().getAtomicActionPrepare(getUnit().getAI());
} catch (Exception e) {
main.system.ExceptionMaster.printStackTrace(e);
}
if (action != null) {
return action;
}
List<ActionSequence> actions = getActionSequenceConstructor().createActionSequencesForGoal(new Goal(goal, ai, true), ai);
if (ai.checkMod(AI_MODIFIERS.TRUE_BRUTE)) {
goal = AiEnums.GOAL_TYPE.ATTACK;
actions.addAll(getActionSequenceConstructor().createActionSequencesForGoal(new Goal(goal, ai, true), ai));
}
if (behaviorMode == null) {
if (ParamAnalyzer.isFatigued(getUnit())) {
actions.add(new ActionSequence(AiEnums.GOAL_TYPE.PREPARE, getAction(getUnit(), STD_MODE_ACTIONS.Rest.name())));
}
if (ParamAnalyzer.isHazed(getUnit())) {
// when is that used?
actions.add(new ActionSequence(AiEnums.GOAL_TYPE.PREPARE, getAction(getUnit(), STD_MODE_ACTIONS.Concentrate.name())));
}
}
if (actions.isEmpty()) {
return getAction(getUnit(), STD_MODE_ACTIONS.Defend.name(), null);
}
ActionSequence sequence = getPriorityManager().chooseByPriority(actions);
LogMaster.log(1, getUnit() + " has been Forced to choose " + "" + sequence + " with priorioty of " + sequence.getPriority());
getMaster().getMessageBuilder().append("Forced Task: " + sequence.getTask().toShortString());
action = sequence.nextAction();
if (action == null) {
return getAction(getUnit(), STD_MODE_ACTIONS.Defend.name(), null);
}
return action;
}
use of main.content.enums.system.AiEnums.BEHAVIOR_MODE in project Eidolons by IDemiurge.
the class TaskManager method getTasks.
public List<Task> getTasks(GOAL_TYPE goal, UnitAI ai, boolean forced, DC_ActiveObj action) {
List<Task> list = new XList<>();
if (ai.getCurrentOrder() != null)
if (ai.getCurrentOrder().getArg() != null)
return new ArrayList<>(Arrays.asList(new Task(ai, goal, ai.getCurrentOrder().getArg())));
List<Integer> ids = new ArrayList<>();
List<? extends DC_Obj> targets = new ArrayList<>();
List<? extends DC_Obj> targets2 = new ArrayList<>();
BEHAVIOR_MODE behaviorMode = ai.getBehaviorMode();
// ai.getGroup().getKnownEnemyCoordinatesMap();
switch(goal) {
case STAND_GUARD:
case AMBUSH:
// preCheck engagement level, default prefs
case SELF:
case STEALTH:
list.add(new Task(forced, ai, goal, ai.getUnit().getId()));
break;
// SPEC MODE - KIND OF ON ALERT...
case PATROL:
targets = Analyzer.getWanderCells(ai);
break;
case // RANDOM DESTINATION MOVEMENT, BLOCK SPECIAL MOVES
WANDER:
// limit max distance from original spawning position
// TODO sometimes in chosen direction
targets = Analyzer.getWanderCells(ai);
break;
case STALK:
// ai.getGroup().getKnownEnemies
break;
case APPROACH:
targets = getCellPrioritizer().getApproachCells(ai);
break;
case SEARCH:
// or maybe the last-seen enemies?
if (!forced) {
if (ai.getUnit().getBuff("Search Mode") == null) {
list.add(new Task(forced, ai, goal, ai.getUnit().getId()));
break;
}
}
targets = Analyzer.getSearchCells(ai);
break;
case RETREAT:
if (ai.getBehaviorMode() == AiEnums.BEHAVIOR_MODE.PANIC) {
// only border cells => flee
}
targets = Analyzer.getSafeCells(ai);
break;
case MOVE:
targets = Analyzer.getMoveTargetCells(ai);
break;
case CUSTOM_HOSTILE:
targets = Analyzer.getVisibleEnemies(ai);
checkPrune(targets, goal, ai, action);
break;
case CUSTOM_SUPPORT:
targets = Analyzer.getAllies(ai);
checkPrune(targets, goal, ai, action);
break;
case ZONE_DAMAGE:
targets = Analyzer.getZoneDamageCells(ai.getUnit());
targets2 = Analyzer.getAdjacentEnemies(ai.getUnit(), false);
checkPrune(targets, goal, ai, action);
break;
case SUMMONING:
targets = Analyzer.getSummonCells(ai, action);
break;
case DEBILITATE:
case DEBUFF:
case ATTACK:
if (behaviorMode == AiEnums.BEHAVIOR_MODE.BERSERK || behaviorMode == AiEnums.BEHAVIOR_MODE.CONFUSED) {
targets = (Analyzer.getUnits(ai, true, true, true, false));
} else {
// if (forced)
// targets = (Analyzer.getUnits(ai, false, true, true,
// false, true));
// else
// TODO detected!
targets = Analyzer.getVisibleEnemies(ai);
}
checkPrune(targets, goal, ai, action);
break;
case AUTO_DAMAGE:
case AUTO_DEBUFF:
case AUTO_BUFF:
// list.add(new Task(ai, goal, null));
case RESTORE:
case BUFF:
targets = Analyzer.getAllies(ai);
checkPrune(targets, goal, ai, action);
break;
case WAIT:
if (!DC_Engine.isAtbMode())
targets = Analyzer.getWaitUnits(ai);
break;
case PROTECT:
if (RuleMaster.isRuleOn(RULE.GUARD))
if (GuardRule.on)
targets = Analyzer.getProtectCells(ai);
break;
case COATING:
Set<Obj> objects = action.getTargeting().getFilter().getObjects(action.getRef());
for (Obj q : objects) {
if (q.getRef().getSourceObj() == getUnit()) {
// q.isOwnedBy(ai.getUnit().getOwner())
ids.add(q.getId());
}
}
break;
default:
list.add(new Task(forced, ai, goal, null));
break;
}
if (targets.isEmpty()) {
return new ArrayList<>();
}
if (behaviorMode == AiEnums.BEHAVIOR_MODE.CONFUSED) {
DC_Obj target = targets.get(new RandomWizard<>().getRandomListIndex(targets));
List<Task> tasks = new ArrayList<>();
tasks.add(new Task(forced, ai, goal, target.getId()));
return tasks;
}
if (list.isEmpty()) {
for (DC_Obj obj : targets) {
list.add(new Task(forced, ai, goal, obj.getId()));
}
for (DC_Obj obj : targets2) {
list.add(new Task(forced, ai, goal, obj.getId()));
}
for (Integer id : ids) {
list.add(new Task(forced, ai, goal, id));
}
}
return list;
}
use of main.content.enums.system.AiEnums.BEHAVIOR_MODE in project Eidolons by IDemiurge.
the class DC_UnitModel method getBehaviorMode.
public BEHAVIOR_MODE getBehaviorMode() {
MODE mode = getMode();
if (!(mode instanceof ModeImpl) || mode == null) {
return null;
}
ModeImpl modeImpl = (ModeImpl) mode;
return modeImpl.getBehaviorMode();
}
use of main.content.enums.system.AiEnums.BEHAVIOR_MODE in project Eidolons by IDemiurge.
the class UnitInitializer method initMode.
public void initMode() {
String name = getProperty(G_PROPS.MODE);
MODE mode = (new EnumMaster<STD_MODES>().retrieveEnumConst(STD_MODES.class, name));
if (mode == null) {
BEHAVIOR_MODE behavior = new EnumMaster<BEHAVIOR_MODE>().retrieveEnumConst(BEHAVIOR_MODE.class, name);
if (behavior != null) {
mode = new ModeImpl(behavior);
}
}
if (mode == null) {
mode = (STD_MODES.NORMAL);
}
getEntity().setMode(mode);
LogMaster.log(LogMaster.CORE_DEBUG, getName() + " has mode: " + mode);
}
Aggregations