66 if (total <= 0)
return;
70 float perChain = 1 + avg1 + (avg1 * avg2);
72 float num = total / perChain;
76 if (num > 1 && num < 2) {
79 num = Math.round(num);
82 List<AddedEntity> mothershipsSoFar =
new ArrayList<AddedEntity>();
84 for (
int i = 0; i < num; i++) {
92 OUTER:
for (StarSystemAPI system :
Global.
getSector().getStarSystems()) {
94 if (system.hasTag(Tags.THEME_DERELICT_PROBES)) {
96 }
else if (system.hasTag(Tags.THEME_DERELICT_SURVEY_SHIP)) {
98 }
else if (system.hasTag(Tags.THEME_DERELICT_MOTHERSHIP)) {
100 }
else if (system.hasTag(Tags.THEME_DERELICT)) {
107 boolean hasHab =
false;
108 for (PlanetAPI planet : system.getPlanets()) {
109 if (planet.isStar())
continue;
110 if (planet.getSpec().isPulsar())
continue OUTER;
111 hasHab |= planet.getMarket() !=
null && planet.getMarket().hasCondition(Conditions.HABITABLE);
115 WeightedRandomPicker<StarSystemAPI> use = cryoSystems;
116 if (!hasHab || numPlanets < 3) {
130 if (cryoSystems.isEmpty() || cryoSystems.getItems().size() < numCryo + 1) {
131 cryoSystems.addAll(backup);
135 WeightedRandomPicker<String> cryosleeperNames =
new WeightedRandomPicker<String>(
random);
136 cryosleeperNames.add(
"Calypso");
137 cryosleeperNames.add(
"Tantalus");
138 while (added < numCryo && !cryoSystems.isEmpty()) {
139 StarSystemAPI pick = cryoSystems.pickAndRemove();
140 String name = cryosleeperNames.pickAndRemove();
150 List<AddedEntity> all =
new ArrayList<AddedEntity>();
153 Vector2f center =
new Vector2f();
154 for (AddedEntity e : mothershipsSoFar) {
155 Vector2f.add(center, e.entity.getLocationInHyperspace(), center);
157 center.scale(1f / (
float)(mothershipsSoFar.size() + 1f));
161 for (
int i = 0; i < constellations.size() / 3; i++) {
162 picker.add(constellations.get(i));
166 if (main ==
null)
return;
172 constellations.remove(main);
177 if (mainSystem ==
null)
return;
180 for (StarSystemAPI system : main.
getSystems()) {
181 system.addTag(Tags.THEME_DERELICT);
189 if (mothership ==
null)
return;
194 System.out.println(
" Added mothership to [" + mainSystem.getNameWithLowercaseType() +
"]");
202 List<AddedEntity> added =
addToSystem(mainSystem, Entities.DERELICT_SURVEY_PROBE, probesNearMothership);
208 SpecialType.LOCATION_MOTHERSHIP);
212 if (surveyShipsNearMothership > main.
getSystems().size()) surveyShipsNearMothership = main.
getSystems().size();
214 System.out.println(String.format(
"Adding %d survey ships near mothership", surveyShipsNearMothership));
216 List<AddedEntity> addedShips =
addToConstellation(main, Entities.DERELICT_SURVEY_SHIP, surveyShipsNearMothership,
false);
217 all.addAll(addedShips);
220 for (AddedEntity e : addedShips) {
223 added =
addProbes((StarSystemAPI) e.entity.getContainingLocation(), probesNearSurveyShip);
228 SpecialType.LOCATION_SURVEY_SHIP);
233 SpecialType.LOCATION_MOTHERSHIP);
239 for (
int i = constellations.size() - 7; i < constellations.size(); i++) {
241 picker.add(constellations.get(i));
246 System.out.println(String.format(
"Adding up to %d survey ships", numSurveyShipsInNearConstellations));
248 List<Constellation> constellationsForSurveyShips =
new ArrayList<Constellation>();
249 for (
int i = 0; i < numSurveyShipsInNearConstellations && !picker.isEmpty(); i++) {
250 constellationsForSurveyShips.add(picker.pickAndRemove());
252 List<AddedEntity> outerShips =
new ArrayList<AddedEntity>();
259 System.out.println(
" Picked for survey ship: [" + c.getNameWithType() +
"]");
263 if (addedShips.isEmpty())
continue;
265 all.addAll(addedShips);
267 AddedEntity ship = addedShips.get(0);
268 outerShips.addAll(addedShips);
272 added =
addProbes((StarSystemAPI) ship.entity.getContainingLocation(), probesNearSurveyShip);
277 SpecialType.LOCATION_SURVEY_SHIP);
280 int max = c.getSystems().size() + 2;
281 if (probesInSameConstellation > max) probesInSameConstellation = max;
283 added =
addToConstellation(c, Entities.DERELICT_SURVEY_PROBE, probesInSameConstellation,
false);
288 SpecialType.LOCATION_SURVEY_SHIP);
295 for (
int i = c2.size() - 3; i < c2.size(); i++) {
297 p2.add(constellations.get(i));
303 System.out.println(String.format(
"Adding probes to %d constellations near survey ship", probeSystemsNearShip));
305 List<AddedEntity> probes3 =
new ArrayList<AddedEntity>();
306 while (k < probeSystemsNearShip && !p2.isEmpty()) {
311 probes3.addAll(
addToConstellation(pick, Entities.DERELICT_SURVEY_PROBE, probesInConstellation,
false));
317 SpecialType.LOCATION_MOTHERSHIP);
322 SpecialType.LOCATION_MOTHERSHIP);
356 Set<PlanetAPI> usedPlanets =
new HashSet<PlanetAPI>();
357 Set<StarSystemAPI> usedSystems =
new HashSet<StarSystemAPI>();
359 for (AddedEntity e : entities) {
362 SurveyDataSpecialType type =
null;
367 if (Entities.DERELICT_SURVEY_PROBE.equals(e.entityType)) {
368 min = HTPoints.LOW_MIN;
369 max = HTPoints.LOW_MAX;
370 }
else if (Entities.DERELICT_SURVEY_SHIP.equals(e.entityType)) {
371 min = HTPoints.MEDIUM_MIN;
372 max = HTPoints.MEDIUM_MAX;
373 }
else if (Entities.DERELICT_MOTHERSHIP.equals(e.entityType)) {
374 min = HTPoints.HIGH_MIN;
375 max = HTPoints.HIGH_MAX;
379 TopographicDataSpecialData data =
new TopographicDataSpecialData(points);
380 Misc.setSalvageSpecial(e.entity, data);
385 float p1 = 0.33f, p2 = 0.67f;
386 if (Entities.DERELICT_SURVEY_PROBE.equals(e.entityType)) {
389 }
else if (Entities.DERELICT_SURVEY_SHIP.equals(e.entityType)) {
392 }
else if (Entities.DERELICT_MOTHERSHIP.equals(e.entityType)) {
399 type = SurveyDataSpecialType.PLANET_INTERESTING_PROPERTY;
401 type = SurveyDataSpecialType.PLANET_SURVEY_DATA;
403 type = SurveyDataSpecialType.SYSTEM_PRELIMINARY_SURVEY;
409 if (type == SurveyDataSpecialType.PLANET_INTERESTING_PROPERTY) {
411 if (planet !=
null) {
413 if (conditionId !=
null) {
414 SurveyDataSpecialData data =
new SurveyDataSpecialData(SurveyDataSpecialType.PLANET_INTERESTING_PROPERTY);
415 data.entityId = planet.getId();
416 data.secondaryId = conditionId;
417 data.includeRuins =
false;
418 Misc.setSalvageSpecial(e.entity, data);
419 usedPlanets.add(planet);
432 }
else if (type == SurveyDataSpecialType.PLANET_SURVEY_DATA) {
434 if (planet !=
null) {
435 SurveyDataSpecialData data =
new SurveyDataSpecialData(SurveyDataSpecialType.PLANET_SURVEY_DATA);
436 data.entityId = planet.getId();
437 data.includeRuins =
false;
438 Misc.setSalvageSpecial(e.entity, data);
439 usedPlanets.add(planet);
446 }
else if (type == SurveyDataSpecialType.SYSTEM_PRELIMINARY_SURVEY) {
448 if (system !=
null) {
449 SurveyDataSpecialData data =
new SurveyDataSpecialData(SurveyDataSpecialType.SYSTEM_PRELIMINARY_SURVEY);
450 data.entityId = system.getId();
451 Misc.setSalvageSpecial(e.entity, data);
503 public static PlanetAPI
findInterestingPlanet(List<StarSystemAPI> systems, Set<PlanetAPI> exclude,
boolean includeKnown,
boolean includeRuins, Random
random) {
506 WeightedRandomPicker<PlanetAPI> planets =
new WeightedRandomPicker<PlanetAPI>(
random);
511 for (StarSystemAPI system : systems) {
512 for (PlanetAPI planet : system.getPlanets()) {
513 if (planet.isStar())
continue;
514 if (exclude !=
null && exclude.contains(planet))
continue;
515 if (planet.getMarket() ==
null || !planet.getMarket().isPlanetConditionMarketOnly())
continue;
516 if (!includeKnown && planet.getMarket() !=
null && planet.getMarket().getSurveyLevel() == SurveyLevel.FULL) {
520 for (MarketConditionAPI mc : planet.getMarket().getConditions()) {
521 if (conditions.contains(mc.getId())) {
522 if (mc.getId().equals(Conditions.HABITABLE) && planet.getMarket().getHazardValue() > 1.25f) {
531 return planets.pick();
641 LinkedHashMap<LocationType, Float> weights =
new LinkedHashMap<LocationType, Float>();
642 weights.put(LocationType.PLANET_ORBIT, 10f);
643 weights.put(LocationType.JUMP_ORBIT, 1f);
644 weights.put(LocationType.NEAR_STAR, 1f);
645 weights.put(LocationType.OUTER_SYSTEM, 5f);
646 weights.put(LocationType.IN_ASTEROID_BELT, 10f);
647 weights.put(LocationType.IN_RING, 10f);
648 weights.put(LocationType.IN_ASTEROID_FIELD, 10f);
649 weights.put(LocationType.STAR_ORBIT, 1f);
650 weights.put(LocationType.IN_SMALL_NEBULA, 1f);
651 weights.put(LocationType.L_POINT, 1f);
652 WeightedRandomPicker<EntityLocation> locs =
getLocations(
random, system, 100f, weights);
665 AddedEntity entity =
addEntity(
random, system, locs, Entities.DERELICT_MOTHERSHIP, Factions.DERELICT);
666 if (entity !=
null) {
667 system.addTag(Tags.THEME_INTERESTING);
668 system.addTag(Tags.THEME_DERELICT);
669 system.addTag(Tags.THEME_DERELICT_MOTHERSHIP);
673 if (entity !=
null) {
674 System.out.println(String.format(
" Added mothership to %s", system.getNameWithLowercaseType()));
676 System.out.println(String.format(
" Failed to add mothership to %s", system.getNameWithLowercaseType()));
684 LinkedHashMap<LocationType, Float> weights =
new LinkedHashMap<LocationType, Float>();
685 weights.put(LocationType.PLANET_ORBIT, 10f);
686 weights.put(LocationType.JUMP_ORBIT, 1f);
687 weights.put(LocationType.NEAR_STAR, 1f);
688 weights.put(LocationType.OUTER_SYSTEM, 5f);
689 weights.put(LocationType.IN_ASTEROID_BELT, 5f);
690 weights.put(LocationType.IN_RING, 5f);
691 weights.put(LocationType.IN_ASTEROID_FIELD, 5f);
692 weights.put(LocationType.STAR_ORBIT, 5f);
693 weights.put(LocationType.IN_SMALL_NEBULA, 5f);
694 weights.put(LocationType.L_POINT, 10f);
695 WeightedRandomPicker<EntityLocation> locs =
getLocations(
random, system, 100f, weights);
698 AddedEntity entity =
addEntity(
random, system, locs, Entities.DERELICT_CRYOSLEEPER, Factions.DERELICT);
699 if (entity !=
null) {
700 system.addTag(Tags.THEME_INTERESTING);
701 system.addTag(Tags.THEME_DERELICT);
702 system.addTag(Tags.THEME_DERELICT_CRYOSLEEPER);
705 entity.entity.setName(entity.entity.getName() +
" \"" + name +
"\"");
711 if (entity !=
null) {
712 System.out.println(String.format(
" Added cryosleeper to %s", system.getNameWithLowercaseType()));
714 System.out.println(String.format(
" Failed to add cryosleeper to %s", system.getNameWithLowercaseType()));
721 LinkedHashMap<LocationType, Float> weights =
new LinkedHashMap<LocationType, Float>();
722 weights.put(LocationType.PLANET_ORBIT, 10f);
723 weights.put(LocationType.JUMP_ORBIT, 1f);
724 weights.put(LocationType.NEAR_STAR, 1f);
725 weights.put(LocationType.OUTER_SYSTEM, 5f);
726 weights.put(LocationType.IN_ASTEROID_BELT, 10f);
727 weights.put(LocationType.IN_RING, 10f);
728 weights.put(LocationType.IN_ASTEROID_FIELD, 10f);
729 weights.put(LocationType.STAR_ORBIT, 1f);
730 weights.put(LocationType.IN_SMALL_NEBULA, 1f);
731 weights.put(LocationType.L_POINT, 1f);
732 WeightedRandomPicker<EntityLocation> locs =
getLocations(
random, system, 100f, weights);
734 AddedEntity entity =
addEntity(
random, system, locs, Entities.DERELICT_SURVEY_SHIP, Factions.DERELICT);
736 if (entity !=
null) {
737 system.addTag(Tags.THEME_INTERESTING);
738 system.addTag(Tags.THEME_DERELICT);
739 system.addTag(Tags.THEME_DERELICT_SURVEY_SHIP);
743 if (entity !=
null) {
744 System.out.println(String.format(
" Added survey ship to %s", system.getNameWithLowercaseType()));
746 System.out.println(String.format(
" Failed to add survey ship to %s", system.getNameWithLowercaseType()));
752 protected List<AddedEntity>
addProbes(StarSystemAPI system,
int num) {
753 LinkedHashMap<LocationType, Float> weights =
new LinkedHashMap<LocationType, Float>();
754 weights.put(LocationType.PLANET_ORBIT, 20f);
755 weights.put(LocationType.JUMP_ORBIT, 10f);
756 weights.put(LocationType.NEAR_STAR, 10f);
757 weights.put(LocationType.OUTER_SYSTEM, 5f);
758 weights.put(LocationType.IN_ASTEROID_BELT, 5f);
759 weights.put(LocationType.IN_RING, 5f);
760 weights.put(LocationType.IN_ASTEROID_FIELD, 5f);
761 weights.put(LocationType.STAR_ORBIT, 1f);
762 weights.put(LocationType.IN_SMALL_NEBULA, 1f);
763 weights.put(LocationType.L_POINT, 1f);
764 WeightedRandomPicker<EntityLocation> locs =
getLocations(
random, system, 100f, weights);
766 List<AddedEntity> result =
new ArrayList<AddedEntity>();
767 for (
int i = 0; i < num; i++) {
768 AddedEntity probe =
addEntity(
random, system, locs, Entities.DERELICT_SURVEY_PROBE, Factions.DERELICT);
772 system.addTag(Tags.THEME_INTERESTING_MINOR);
773 system.addTag(Tags.THEME_DERELICT);
774 system.addTag(Tags.THEME_DERELICT_PROBES);
779 System.out.println(String.format(
" Added probe to %s", system.getNameWithLowercaseType()));
781 System.out.println(String.format(
" Failed to add probe to %s", system.getNameWithLowercaseType()));