use of eidolons.entity.active.DC_ActiveObj in project Eidolons by IDemiurge.
the class AiUnitActionMaster method getFullActionList.
// returns all of unit's active that we want to preCheck for execution
public static List<DC_ActiveObj> getFullActionList(GOAL_TYPE type, Unit unit) {
// cache
List<DC_ActiveObj> actions = new XList<>();
switch(type) {
case PROTECT:
actions.add(AiActionFactory.getUnitAction(unit, "Guard Mode"));
break;
case PATROL:
case WANDER:
case RETREAT:
case MOVE:
case APPROACH:
// dummy action!
actions.add(AiActionFactory.getUnitAction(unit, "Move"));
break;
case ATTACK:
if (unit.getActionMap().get(ActionEnums.ACTION_TYPE.SPECIAL_ATTACK) != null) {
actions.addAll(unit.getActionMap().get(ActionEnums.ACTION_TYPE.STANDARD_ATTACK));
}
if (unit.getActionMap().get(ActionEnums.ACTION_TYPE.SPECIAL_ATTACK) != null) {
actions.addAll(unit.getActionMap().get(ActionEnums.ACTION_TYPE.SPECIAL_ATTACK));
}
actions.remove(AiActionFactory.getUnitAction(unit, DC_ActionManager.OFFHAND_ATTACK));
DC_UnitAction action = unit.getAction("Throw", false);
actions.remove(action);
action = unit.getAction("Throw", false);
actions.remove(action);
break;
case DEFEND:
actions.add(AiActionFactory.getUnitAction(unit, STD_MODE_ACTIONS.Defend.name()));
actions.add(AiActionFactory.getUnitAction(unit, STD_MODE_ACTIONS.On_Alert.name()));
break;
case COWER:
actions.add(AiActionFactory.getUnitAction(unit, "Cower"));
break;
case AMBUSH:
if (!checkAddStealth(true, unit, actions)) {
actions.add(AiActionFactory.getUnitAction(unit, STD_MODE_ACTIONS.On_Alert.name()));
}
break;
case STALK:
if (!checkAddStealth(false, unit, actions)) {
actions.add(AiActionFactory.getUnitAction(unit, "Move"));
}
break;
case STEALTH:
checkAddStealth(false, unit, actions);
break;
case // can it be MOVE?
SEARCH:
if (unit.getBuff("Search Mode") == null) {
actions.add(AiActionFactory.getUnitAction(unit, "Search Mode"));
} else {
actions.add(AiActionFactory.getUnitAction(unit, "Move"));
}
break;
case WAIT:
actions.add(AiActionFactory.getUnitAction(unit, "Wait"));
break;
case PREPARE:
actions.addAll(unit.getActionMap().get(ActionEnums.ACTION_TYPE.MODE));
if (!unit.isLiving()) {
actions.remove(AiActionFactory.getUnitAction(unit, STD_MODE_ACTIONS.Defend.name()));
}
actions.remove(AiActionFactory.getUnitAction(unit, STD_MODE_ACTIONS.Defend.name()));
actions.remove(AiActionFactory.getUnitAction(unit, STD_MODE_ACTIONS.On_Alert.name()));
break;
}
actions.addAll(ActionFilter.filterActives(type, (unit.getSpells())));
actions.addAll(ActionFilter.filterActives(type, (unit.getQuickItemActives())));
if (type.isFilterByCanActivate()) {
actions = ActionFilter.filterByCanActivate(unit, actions);
}
return actions;
}
use of eidolons.entity.active.DC_ActiveObj 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.active.DC_ActiveObj in project Eidolons by IDemiurge.
the class AutoAttackEffect method pickAutomatically.
private DC_ActiveObj pickAutomatically(List<DC_ActiveObj> subActions) {
DC_ActiveObj pick = null;
int max = 0;
for (DC_ActiveObj attack : subActions) {
int priority = calculatePriority(attack, getTarget());
if (priority > max) {
pick = attack;
max = priority;
}
}
return pick;
}
use of eidolons.entity.active.DC_ActiveObj in project Eidolons by IDemiurge.
the class AutoAttackEffect method applyThis.
// boolean offhand; auto!
@Override
public boolean applyThis() {
// auto-select action
// getUnit().getAction(action)
DC_ActiveObj attack = pickAttack();
if (attack == null) {
return false;
}
boolean result = attack.activatedOn(ref);
if (result) {
if (getActiveObj().getParentAction() != null) {
getActiveObj().getParentAction().setLastSubaction(attack);
getActiveObj().getParentAction().getRef().setTarget(ref.getTarget());
}
} else {
return false;
}
// getRef().getActive()
return true;
}
use of eidolons.entity.active.DC_ActiveObj in project Eidolons by IDemiurge.
the class ChangeRefEffect method applyThis.
@Override
public boolean applyThis() {
// so I need the active to have ref with the ammo as AMMO, not weapon?
Ref REF = this.ref;
if (keyWhoseRefToModify != null) {
REF = REF.getObj(keyWhoseRefToModify).getRef();
} else {
// for (KEYS key :
// add_remove ? autoCheckedKeysAdd : autoCheckedKeysRemove)
// {
// if (REF.getObj(key)!=null )
// if (REF.getObj(key).getRef().getId(this.keyToAddOrRemoveForRef) != null) {
// REF = ref.getObj(key).getRef();
// break;
// }
// }
}
Integer id = REF.getId(keyToAddOrRemoveForRef);
if (id == null) {
if (ref.getActive() instanceof DC_ActiveObj) {
DC_ActiveObj activeObj = (DC_ActiveObj) ref.getActive();
if (activeObj.getParentAction() != null) {
id = activeObj.getParentAction().getRef().getId(keyToAddOrRemoveForRef);
}
}
}
if (add_remove) {
REF.getTargetObj().getRef().setID(keyToAddOrRemoveForRef, id);
} else {
REF.removeValue(keyToAddOrRemoveForRef);
}
return true;
}
Aggregations