use of eidolons.entity.active.DC_UnitAction 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_UnitAction in project Eidolons by IDemiurge.
the class TurnSequenceConstructor method getTurnSequence.
public List<Action> getTurnSequence(FACING_SINGLE template, Unit source, Coordinates target) {
FACING_DIRECTION original_facing = source.getFacing();
FACING_DIRECTION facing = original_facing;
boolean clockwise = true;
int i = 0;
List<Action> clockwise_list = new ArrayList<>();
if (template == FacingMaster.getSingleFacing(FacingMaster.rotate180(facing), source.getCoordinates(), target)) {
DC_UnitAction specAction = source.getAction("Turn About " + (RandomWizard.random() ? "anti" : "") + "clockwise");
if (specAction != null) {
clockwise_list.add(new Action(specAction));
return clockwise_list;
}
}
while (true) {
if (template == FacingMaster.getSingleFacing(facing, source.getCoordinates(), target)) {
break;
}
facing = FacingMaster.rotate(facing, clockwise);
clockwise_list.add(getTurnAction(clockwise, source));
i++;
if (i > 2) {
break;
}
}
clockwise = false;
i = 0;
List<Action> anticlockwise_list = new ArrayList<>();
facing = original_facing;
while (true) {
if (template == FacingMaster.getSingleFacing(facing, source.getCoordinates(), target)) {
break;
}
facing = FacingMaster.rotate(facing, clockwise);
anticlockwise_list.add(getTurnAction(clockwise, source));
i++;
if (i > 2) {
break;
}
}
return (anticlockwise_list.size() > clockwise_list.size()) ? clockwise_list : anticlockwise_list;
}
use of eidolons.entity.active.DC_UnitAction in project Eidolons by IDemiurge.
the class HeroObjectModifyingEffect method getIdList.
protected List<Integer> getIdList(Unit hero) {
List<Integer> list = new ArrayList<>();
if (hero == null) {
return list;
}
switch(type) {
case ACTIONS:
for (ACTION_TYPE a : ActionEnums.ACTION_TYPE.values()) {
if (hero.getActionMap().get(a) != null) {
for (DC_UnitAction action : hero.getActionMap().get(a)) {
list.add(action.getId());
}
}
}
break;
case ARMOR:
list = new ArrayList<>(new ListMaster<Integer>().getList(hero.getArmor().getId()));
break;
case ITEMS:
for (Obj i : hero.getQuickItems()) // if (i.getOBJ_TYPE_ENUM() != OBJ_TYPES.WEAPONS)
// non-weapon QI???
{
list.add(i.getId());
}
break;
case SPELLS:
for (Obj i : hero.getSpells()) {
list.add(i.getId());
}
// hero.getGame().getManager().getSpells(hero)
break;
case WEAPONS:
Integer id = null;
if (hero.getActiveWeapon(true) != null) {
id = hero.getActiveWeapon(true).getId();
}
Integer id2 = 0;
if (hero.getActiveWeapon(false) != null) {
id2 = hero.getActiveWeapon(false).getId();
}
list = new ArrayList<>(new ListMaster<Integer>().getList(id2, id));
List<? extends Obj> l = new ArrayList<>(hero.getQuickItems());
for (Obj i : l) {
if (i.getOBJ_TYPE_ENUM() == DC_TYPE.WEAPONS) {
list.add(i.getId());
}
}
break;
}
// ListMaster.removeNullElements(list);
FilterMaster.filter(list, conditions, game);
return list;
}
use of eidolons.entity.active.DC_UnitAction in project Eidolons by IDemiurge.
the class AttackOfOpportunityRule method getAttacksOfOpportunity.
private static List<DC_ActiveObj> getAttacksOfOpportunity(Unit unit) {
List<DC_ActiveObj> list = new ArrayList<>();
DequeImpl<DC_UnitAction> attacks = unit.getActionMap().get(ActionEnums.ACTION_TYPE.STANDARD_ATTACK);
if (attacks == null) {
attacks = new DequeImpl<>();
}
if (unit.getActionMap().get(ActionEnums.ACTION_TYPE.SPECIAL_ATTACK) != null) {
attacks.addAll(unit.getActionMap().get(ActionEnums.ACTION_TYPE.SPECIAL_ATTACK));
}
for (DC_UnitAction attack : attacks) {
if (// TODO same tag?!
attack.checkProperty(G_PROPS.ACTION_TAGS, ActionEnums.ACTION_TAGS.ATTACK_OF_OPPORTUNITY_ACTION.toString())) {
list.add(attack);
}
}
return list;
}
use of eidolons.entity.active.DC_UnitAction in project Eidolons by IDemiurge.
the class ExtraAttacksRule method getCounterAttacks.
public static List<DC_ActiveObj> getCounterAttacks(DC_ActiveObj triggeringAction, Unit unit) {
List<DC_ActiveObj> list = new ArrayList<>();
if (unit.getActionMap().get(ActionEnums.ACTION_TYPE.STANDARD_ATTACK) == null) {
return list;
}
for (DC_UnitAction a : unit.getActionMap().get(ActionEnums.ACTION_TYPE.STANDARD_ATTACK)) {
// offhand?
if (a.isMelee() && !a.isAttackGeneric()) // auto-atk range?
{
list.add(a);
}
}
SortMaster.sortEntitiesByExpression(list, action -> FutureBuilder.precalculateDamage((DC_ActiveObj) action, triggeringAction.getOwnerObj(), true) * (action.getIntParam(PARAMS.COUNTER_MOD) + action.getIntParam(PARAMS.COUNTER_ATTACK_MOD)));
return list;
}
Aggregations