Starsector 0.97a is out! (02/02/24); New blog post: Simulator Enhancements (03/13/24)
protected ShipAPI findTarget(ShipAPI ship) { float range = getMaxRange(ship); boolean player = ship == Global.getCombatEngine().getPlayerShip(); ShipAPI target = ship.getShipTarget(); if (target != null) { float dist = Misc.getDistance(ship.getLocation(), target.getLocation()); float radSum = ship.getCollisionRadius() + target.getCollisionRadius(); if (dist > range + radSum) target = null; /* no ally check if have target */ } else { /* ally check only if target is null */ if (target == null || target.getOwner() == ship.getOwner()) { if (player) { target = Misc.findClosestShipEnemyOf(ship, ship.getMouseTarget(), HullSize.FIGHTER, range, true); } else { Object test = ship.getAIFlags().getCustom(AIFlags.MANEUVER_TARGET); if (test instanceof ShipAPI) { target = (ShipAPI) test; float dist = Misc.getDistance(ship.getLocation(), target.getLocation()); float radSum = ship.getCollisionRadius() + target.getCollisionRadius(); if (dist > range + radSum) target = null; } } } if (target == null) { target = Misc.findClosestShipEnemyOf(ship, ship.getLocation(), HullSize.FIGHTER, range, true); } } return target; }
boolean damaged = fleet.getMemoryWithoutUpdate().getBoolean("$damagedStation"); if ((difficulty == 7 || difficulty == 8) && damaged) { stations.add(fleet); } else if (!damaged) { stations.add(fleet); }
boolean isDamaged = fleet.getMemoryWithoutUpdate().getBoolean("$damagedStation"); boolean wantDamaged = difficulty <= 8; if (isDamaged == wantDamaged) { stations.add(fleet); }