use of eidolons.entity.obj.DC_Obj in project Eidolons by IDemiurge.
the class SightMaster method resetUnitVision.
private void resetUnitVision(BattleFieldObject observer, Collection<? extends Obj> units) {
int maxDistance = observer.getIntParam(PARAMS.SIGHT_RANGE) * 2 + 1;
for (Obj obj : units) {
DC_Obj unit = (DC_Obj) obj;
if (PositionMaster.getDistance(observer, obj) > maxDistance) {
master.getVisionController().getUnitVisionMapper().set(observer, unit, null);
continue;
}
UNIT_VISION status = getUnitVisionStatusPrivate(unit, (Unit) observer);
master.getVisionController().getUnitVisionMapper().set(observer, unit, status);
}
}
use of eidolons.entity.obj.DC_Obj in project Eidolons by IDemiurge.
the class StealthRule method actionComplete.
public void actionComplete(ActiveObj active) {
if (!isOn())
return;
// perhaps only moves?
DC_ActiveObj action = (DC_ActiveObj) active;
Unit source = action.getOwnerObj();
List<? extends DC_Obj> list = Analyzer.getEnemies(source, false, false, false);
list.removeIf(unit -> {
double d = PositionMaster.getExactDistance(source, unit);
if ((d > getMaxDistance(source, unit))) {
return true;
}
if ((d > getMaxDistance((Unit) unit, source))) {
return true;
}
return false;
});
for (DC_Obj sub : list) {
Unit unit = (Unit) sub;
double d = PositionMaster.getExactDistance(source, unit);
if ((d <= getMaxDistance(unit, source))) {
if (isSpotRollAllowed(unit, source)) {
rollSpotted(unit, source);
}
}
if ((d <= getMaxDistance(source, unit))) {
if (isSpotRollAllowed(source, unit)) {
rollSpotted(source, unit);
}
}
}
}
use of eidolons.entity.obj.DC_Obj 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 eidolons.entity.obj.DC_Obj in project Eidolons by IDemiurge.
the class Unit method applySpecialEffects.
public void applySpecialEffects(SPECIAL_EFFECTS_CASE case_type, BattleFieldObject target, Ref REF, boolean offhand) {
DC_Obj weapon = (DC_Obj) ref.getObj(offhand ? KEYS.OFFHAND : KEYS.WEAPON);
if (weapon == null) {
weapon = getWeapon(offhand);
}
if (weapon == null) {
weapon = getNaturalWeapon(offhand);
}
if (weapon != null) {
weapon.applySpecialEffects(case_type, target, REF);
}
DC_Obj action = (DC_Obj) ref.getActive();
if (action != null) {
action.applySpecialEffects(case_type, target, REF);
}
super.applySpecialEffects(case_type, target, REF);
}
use of eidolons.entity.obj.DC_Obj in project Eidolons by IDemiurge.
the class Analyzer method getLastSeenEnemyCells.
public static List<DC_Cell> getLastSeenEnemyCells(UnitAI ai) {
List<DC_Cell> list = new ArrayList<>();
for (DC_Obj obj : ai.getUnit().getOwner().getLastSeenCache().keySet()) {
if (isEnemy(obj, ai.getUnit())) {
Coordinates coordinates = ai.getUnit().getOwner().getLastSeenCache().get(obj);
list.add(obj.getGame().getCellByCoordinate(coordinates));
}
}
return list;
}
Aggregations