use of eidolons.entity.obj.DC_Obj in project Eidolons by IDemiurge.
the class MiniObjComp method clicked.
public void clicked(Point point) {
if (getObjects().size() < 2) {
obj.getGame().getManager().objClicked(obj);
return;
}
if (point.x < getWidth() / 3) {
if (point.y < getHeight() / 3) {
// CYCLE THRU OBJs
Obj choice = DialogMaster.objChoice("Which object?", getObjects().toArray(new Obj[getObjects().size()]));
if (choice != null) {
obj = (DC_Obj) choice;
obj.getGame().getManager().objClicked(obj);
}
return;
}
}
obj.getGame().getManager().objClicked(obj);
}
use of eidolons.entity.obj.DC_Obj in project Eidolons by IDemiurge.
the class WanderAi method getWanderCells.
public static List<? extends DC_Obj> getWanderCells(UnitAI ai) {
DIRECTION d = ai.getGroup().getWanderDirection();
// permittedCells = ai.getGroup().getWanderBlocks();
List<DC_Obj> list = new ArrayList<>();
for (DC_Cell cell : Analyzer.getCells(ai, false, false, true)) {
if (d != null) {
if (DirectionMaster.getRelativeDirection(cell, ai.getUnit()) != d) {
continue;
}
}
if (PositionMaster.getDistance(cell, ai.getUnit()) <= ai.getMaxWanderDistance()) {
list.add(cell);
}
}
if (list.isEmpty()) {
// change direction?
}
return list;
}
use of eidolons.entity.obj.DC_Obj in project Eidolons by IDemiurge.
the class ParamPriorityAnalyzer method getResistanceFactor.
public static int getResistanceFactor(Action action) {
DC_ActiveObj active = action.getActive();
DC_Obj target = action.getTarget();
Integer resistance = target.getIntParam(PARAMS.RESISTANCE);
resistance -= action.getSource().getIntParam(PARAMS.RESISTANCE_PENETRATION);
Integer mod = active.getIntParam(PARAMS.RESISTANCE_MODIFIER);
if (mod > 0) {
resistance = resistance * mod / 100;
}
return Math.min(0, -resistance);
}
use of eidolons.entity.obj.DC_Obj in project Eidolons by IDemiurge.
the class PruneMaster method pruneTargetsForAction.
public void pruneTargetsForAction(List<? extends DC_Obj> targets, GOAL_TYPE goal, UnitAI ai, DC_ActiveObj action) {
/*
* cache for each goal?
*
* the 'pruneSize' must be a minimum of targets to prune... and beyond
* that, there should be some default prune logic
*/
for (DC_Obj e : targets) {
if (!(e instanceof Unit)) {
// another method?
return;
}
}
int size = targets.size();
// getPruneSize(goal);
int toPrune = size - 1;
if (// this is only the max size, how to ensure pruning of
toPrune <= 0) // 'valid' targets too?
{
if (action.isRanged() || action instanceof DC_SpellObj) {
// TODO sometimes it's not the size, but the distance!
return;
}
}
// for melee...
Boolean byCapacity = true;
Boolean byHealth = true;
Boolean byDistance = true;
Boolean byDanger = false;
Boolean byPower = true;
Boolean byType = false;
switch(goal) {
case RESTORE:
byHealth = false;
break;
case ATTACK:
byHealth = false;
byDanger = true;
break;
case BUFF:
// TODO ignore near-dead and 'surrounded'
byDanger = true;
// enemies ready to fall
break;
case CUSTOM_HOSTILE:
case CUSTOM_SUPPORT:
}
Boolean enemy = GoalManager.isGoalVsEnemies(goal);
int minDistance = // TODO for ALLIES?
getAnalyzer().getClosestEnemyDistance(ai.getUnit());
List<DC_Obj> pruneList = new ArrayList<>();
// TODO sort() first? to be sure to cut off the tail...
int maxPower = ParamAnalyzer.getMaxParam(PARAMS.POWER, new ArrayList<>(targets));
int limit = 0;
boolean first = true;
pruneLoop: while ((first || pruneList.size() < toPrune) && limit < 5) {
first = false;
for (DC_Obj t : targets) {
if (pruneList.contains(t)) {
continue;
}
boolean result = false;
while (true) {
if (byDistance) {
int distance = PositionMaster.getDistance(t, ai.getUnit());
// if (distance < minDistance) {
// minDistance = distance;
// } else {
result = (getDistancePruneFactor(limit, t, ai, action)) < distance - minDistance;
// }
if (result) {
break;
}
}
if (byCapacity) {
float capacity = DC_PriorityManager.getCapacity((Unit) t);
if (result) {
break;
}
}
if (byHealth) {
// ?
int health = DC_PriorityManager.getHealthFactor(t, byHealth);
result = (health < getHeathPruneFactor(limit, t, ai, action));
if (result) {
break;
}
}
if (byPower) {
result = t.getIntParam(PARAMS.POWER) * 100 / maxPower < getPowerFactor(limit, ai, action);
if (result) {
break;
}
}
// by danger
break;
}
if (result) {
pruneList.add(t);
continue pruneLoop;
}
}
// if nobody was pruned, increase limits
limit++;
}
main.system.auxiliary.log.LogMaster.log(LOG_CHANNEL.AI_DEBUG, "PRUNING FOR " + action + " : " + pruneList);
for (DC_Obj t : pruneList) {
targets.remove(t);
}
}
use of eidolons.entity.obj.DC_Obj in project Eidolons by IDemiurge.
the class DC_BattleFieldManager method resetVisibleWallMap.
private void resetVisibleWallMap() {
visibleWallMap = new MapMaster().cloneHashMap(wallMap);
visibleWallMap.keySet().removeIf((sub) -> {
DC_Obj obj = (DC_Obj) game.getObjectByCoordinate(sub);
if (obj == null) {
return false;
}
// return !VisionManager.checkVisible(obj, false);
return !VisionManager.getMaster().getDetectionMaster().checkKnownForPlayer(obj);
});
visibleDiagonalJoints = new MapMaster().cloneHashMap(diagonalJoints);
visibleDiagonalJoints.keySet().removeIf((sub) -> !visibleWallMap.containsKey(sub));
// for (Coordinates sub: wallMap.keySet()){
// DC_Obj obj = (DC_Obj) game.getObjectByCoordinate(sub);
// if (VisionManager.checkVisible(obj, false)){
// visibleWallMap.put(sub, wallMap.get(sub));
// }
// }
}
Aggregations