use of main.content.enums.system.AiEnums.GOAL_TYPE in project Eidolons by IDemiurge.
the class AiScriptExecutor method executeCommand.
private void executeCommand(Unit unit, COMBAT_SCRIPT_FUNCTION function, String arg, boolean free, boolean immediate, String... args) {
ActionSequence sequence = null;
GOAL_TYPE goal = getGoalType(function);
Task task = new Task(true, unit.getAI(), goal, arg);
UnitAI ai = unit.getAI();
switch(function) {
case MOVE_TO:
// via a path!
ActionPath path = getPathSequenceConstructor().getOptimalPathSequence(unit.getAI(), new Coordinates(arg.toString()));
sequence = new ActionSequence(path.getActions(), task, unit.getAI());
break;
case TURN_TO:
// cell id
sequence = new ActionSequence(getTurnSequenceConstructor().getTurnSequence(FACING_SINGLE.IN_FRONT, unit, new Coordinates(arg.toString())), task, unit.getAI());
break;
case ACTION:
Action action = AiActionFactory.newAction(arg.toString(), ai);
// new ActionSequence();
sequence = getActionSequenceConstructor().constructSingleActionSequence(action, new Task(ai, goal, args[0]));
break;
case ATTACK:
break;
case FREEZE:
break;
case UNFREEZE:
break;
case ORDER:
// OrderFactory.getOrder();
Order a = new Order(arg.toString());
unit.getAI().setCurrentOrder(a);
return;
}
if (immediate) {
unit.getAI().setStandingOrders(sequence);
unit.getAI().setFree(free);
} else
sequence.getActions().forEach(// TODO wait?
action -> getExecutor().execute(action, free));
}
use of main.content.enums.system.AiEnums.GOAL_TYPE 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 main.content.enums.system.AiEnums.GOAL_TYPE 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.GOAL_TYPE in project Eidolons by IDemiurge.
the class PriorityManagerImpl method getPriorityForActionSequence.
@Override
public int getPriorityForActionSequence(ActionSequence as) {
priority = 0;
modifier = 0;
// compare damage or default priority on non-damage actions (formula?)
//
setUnit(as.getAi().getUnit());
GOAL_TYPE goal = as.getType();
initLogChannel(goal);
Action action = as.getLastAction();
try {
action.getActive().getGame().getEffectManager().setEffectRefs(action.getActive().getAbilities(), action.getRef());
} catch (Exception e) {
main.system.ExceptionMaster.printStackTrace(e);
}
if (!action.getActive().getProperty(PROPS.AI_PRIORITY_FORMULA).isEmpty()) {
setBasePriority(evaluatePriorityFormula(action, action.getActive().getProperty(PROPS.AI_PRIORITY_FORMULA)));
if (EffectFinder.check(action.getActive(), RollEffect.class)) {
try {
applyRollPriorityMod((RollEffect) EffectFinder.getEffectsOfClass(action.getActive(), RollEffect.class).get(0));
} catch (Exception e) {
main.system.ExceptionMaster.printStackTrace(e);
}
}
applyResistPenalty(action);
} else {
switch(goal) {
case PROTECT:
setBasePriority(getGuardPriority(action));
break;
case ATTACK:
setBasePriority(getAttackPriority(as));
break;
case WAIT:
setBasePriority(getWaitPriority(action));
break;
case DEFEND:
case PREPARE:
setBasePriority(getModePriority(action));
break;
case SUMMONING:
setBasePriority(getSummonPriority(action));
break;
case AUTO_DAMAGE:
case ZONE_DAMAGE:
case AUTO_DEBUFF:
case AUTO_BUFF:
case SELF:
case BUFF:
case DEBUFF:
case RESTORE:
case DEBILITATE:
case CUSTOM_HOSTILE:
case CUSTOM_SUPPORT:
setBasePriority(getSpellPriority(goal, action));
break;
case STEALTH:
setBasePriority(getStealthPriority(action));
break;
case SEARCH:
// TODO sight range/detection factors,
setBasePriority(getSearchPriority(as));
break;
case COWER:
setBasePriority(getCowerPriority(getUnit()));
break;
case RETREAT:
setBasePriority(getRetreatPriority(as));
break;
case COATING:
setBasePriority(getCoatingPriority(action.getActive(), action.getTarget()));
break;
case AGGRO:
case AMBUSH:
case APPROACH:
case STAND_GUARD:
case MOVE:
case OTHER:
case PATROL:
case STALK:
case WANDER:
priority = 100;
break;
case ZONE_SPECIAL:
default:
setBasePriority(getSpellPriority(goal, action));
break;
}
}
if (priority <= 0) {
if (goal == GOAL_TYPE.ATTACK)
LogMaster.log(1, "ATK FAILED" + priority + " priority for " + as);
else
LogMaster.log(1, priority + " priority for " + as);
return priority;
}
// Integer bonus = unit_ai.getActionPriorityBonuses().get(action.getActive().getName());
// if (bonus != null) {
// priority += bonus;
// }
as.setPriority(priority);
Integer mod = as.getPriorityMultiplier();
mod += (int) (modifier);
if (mod != null) {
priority = MathMaster.applyMod(priority, mod);
}
LogMaster.log(1, "AI: " + priority + " priority for " + as);
return priority;
}
use of main.content.enums.system.AiEnums.GOAL_TYPE in project Eidolons by IDemiurge.
the class TargetingMaster method selectTargetForAction.
public static Integer selectTargetForAction(DC_ActiveObj a) {
/*
* getOrCreate possible targets init goal type prioritize
*/
GOAL_TYPE type = GoalManager.getGoalFromAction(a);
Obj target = null;
int max_priority = Integer.MIN_VALUE;
Set<Obj> objects = null;
a.getTargeting().getFilter().setRef(a.getRef());
try {
objects = a.getTargeting().getFilter().getObjects();
} catch (Exception e) {
main.system.ExceptionMaster.printStackTrace(e);
}
for (Obj obj : objects) {
ActionSequence sequence = new ActionSequence(type, new Action(a, obj));
sequence.setAi(a.getOwnerObj().getUnitAI());
sequence.setType(type);
int priority = DC_PriorityManager.getPriority(sequence);
if (priority > max_priority) {
target = obj;
max_priority = priority;
}
}
if (target == null) {
return null;
}
return target.getId();
}
Aggregations