320 int num = 2 +
random.nextInt(3);
324 if (
DEBUG) System.out.println(
"Adding up to " + num +
" solar shades and mirrors");
325 List<Constellation> list =
new ArrayList<Constellation>(context.
constellations);
326 WeightedRandomPicker<PlanetAPI> picker =
new WeightedRandomPicker<PlanetAPI>(
random);
328 for (StarSystemAPI system : c.getSystems()) {
329 if (system.hasTag(Tags.THEME_CORE))
continue;
330 if (system.isNebula())
continue;
332 for (PlanetAPI planet : system.getPlanets()) {
333 if (planet.isStar())
continue;
335 SectorEntityToken focus = planet.getOrbitFocus();
336 if (!(focus instanceof PlanetAPI))
continue;
337 if (!((PlanetAPI) focus).isNormalStar())
continue;
342 if (spec ==
null)
continue;
345 if (cat ==
null)
continue;
348 if (Planets.CAT_HAB1.equals(cat)) {
350 }
else if (Planets.CAT_HAB2.equals(cat)) {
352 }
else if (Planets.CAT_HAB3.equals(cat)) {
356 if (weight <= 0)
continue;
360 if (planet.hasCondition(Conditions.HOT)) {
363 if (planet.hasCondition(Conditions.POOR_LIGHT)) {
366 if (planet.hasCondition(Conditions.WATER_SURFACE)) {
369 if (Misc.hasFarmland(planet.getMarket())) {
373 if (weight <= 0)
continue;
376 boolean enoughRoom =
true;
377 for (PlanetAPI other : system.getPlanets()) {
378 if (other.getOrbitFocus() == planet) {
379 if (other.getCircularOrbitRadius() < planet.getRadius() + other.getRadius() + 320) {
385 if (!enoughRoom)
continue;
388 picker.add(planet, weight);
393 if (
DEBUG) System.out.println(
"Found " + picker.getItems().size() +
" candidates");
394 for (
int i = 0; i < num && !picker.isEmpty(); i++) {
395 PlanetAPI planet = picker.pickAndRemove();
396 if (
DEBUG) System.out.println(
"Adding solar shades and mirrors to [" + planet.getName() +
"] in [" +
397 planet.getStarSystem() +
" located at " + planet.getLocationInHyperspace());
399 planet.getMarket().addCondition(Conditions.SOLAR_ARRAY);
401 StarSystemAPI system = planet.getStarSystem();
402 PlanetAPI star = (PlanetAPI) planet.getOrbitFocus();
404 boolean shade = planet.hasCondition(Conditions.HOT) ||
405 planet.getTypeId().equals(Planets.DESERT) ||
406 planet.getTypeId().equals(Planets.DESERT1) ||
407 planet.getTypeId().equals(Planets.ARID) ||
408 star.getTypeId().equals(StarTypes.BLUE_GIANT) ||
409 star.getTypeId().equals(StarTypes.BLUE_SUPERGIANT);
410 boolean mirror = planet.hasCondition(Conditions.POOR_LIGHT) ||
411 planet.getTypeId().equals(Planets.PLANET_TERRAN_ECCENTRIC) ||
414 star.getTypeId().equals(StarTypes.RED_DWARF) ||
415 star.getTypeId().equals(StarTypes.BROWN_DWARF);
417 boolean forceFew =
false;
418 if (!shade && !mirror) {
424 String faction = Factions.NEUTRAL;
425 float period = planet.getCircularOrbitPeriod();
426 float angle = planet.getCircularOrbitAngle();
427 float radius = 270f + planet.getRadius();
431 float profile = 2000f;
434 boolean manyMirrors =
random.nextBoolean();
436 SectorEntityToken mirror2 = system.addCustomEntity(
null,
"Stellar Mirror Beta", Entities.STELLAR_MIRROR, faction);
437 SectorEntityToken mirror3 = system.addCustomEntity(
null,
"Stellar Mirror Gamma", Entities.STELLAR_MIRROR, faction);
438 SectorEntityToken mirror4 = system.addCustomEntity(
null,
"Stellar Mirror Delta", Entities.STELLAR_MIRROR, faction);
439 mirror2.setCircularOrbitPointingDown(planet, angle - 30, radius, period);
440 mirror3.setCircularOrbitPointingDown(planet, angle + 0, radius, period);
441 mirror4.setCircularOrbitPointingDown(planet, angle + 30, radius, period);
446 if (manyMirrors && !forceFew) {
447 SectorEntityToken mirror1 = system.addCustomEntity(
null,
"Stellar Mirror Alpha", Entities.STELLAR_MIRROR, faction);
448 SectorEntityToken mirror5 = system.addCustomEntity(
null,
"Stellar Mirror Epsilon", Entities.STELLAR_MIRROR, faction);
449 mirror1.setCircularOrbitPointingDown(planet, angle - 60, radius, period);
450 mirror5.setCircularOrbitPointingDown(planet, angle + 60, radius, period);
457 boolean manyShades =
random.nextBoolean();
458 SectorEntityToken shade2 = system.addCustomEntity(
null,
"Stellar Shade Psi", Entities.STELLAR_SHADE, faction);
459 shade2.setCircularOrbitPointingDown(planet, angle + 180 + 0, radius + 25, period);
462 if (manyShades && !forceFew) {
463 SectorEntityToken shade1 = system.addCustomEntity(
null,
"Stellar Shade Omega", Entities.STELLAR_SHADE, faction);
464 SectorEntityToken shade3 = system.addCustomEntity(
null,
"Stellar Shade Chi", Entities.STELLAR_SHADE, faction);
465 shade1.setCircularOrbitPointingDown(planet, angle + 180 - 26, radius - 10, period);
466 shade3.setCircularOrbitPointingDown(planet, angle + 180 + 26, radius - 10, period);
474 if (
DEBUG) System.out.println(
"Done adding solar shades and mirrors");
485 if (
DEBUG) System.out.println(
" Generating misc derelicts in system " + data.system.getName());
486 boolean special = data.isBlackHole() || data.isNebula() || data.isPulsar();
491 if (
random.nextFloat() < 0.5f)
return;
503 Entities.WEAPONS_CACHE, 4f,
504 Entities.WEAPONS_CACHE_SMALL, 10f,
505 Entities.WEAPONS_CACHE_HIGH, 4f,
506 Entities.WEAPONS_CACHE_SMALL_HIGH, 10f,
507 Entities.WEAPONS_CACHE_LOW, 4f,
508 Entities.WEAPONS_CACHE_SMALL_LOW, 10f,
509 Entities.SUPPLY_CACHE, 4f,
510 Entities.SUPPLY_CACHE_SMALL, 10f,
511 Entities.EQUIPMENT_CACHE, 4f,
512 Entities.EQUIPMENT_CACHE_SMALL, 10f
696 if (
DEBUG) System.out.println(
"Adding coronal tap to [" + system.getNameWithLowercaseType() +
", " + system.getLocation());
698 String factionId = Factions.NEUTRAL;
700 AddedEntity entity =
null;
701 if (system.getType() == StarSystemType.TRINARY_2CLOSE) {
702 EntityLocation loc =
new EntityLocation();
703 loc.location =
new Vector2f();
704 entity =
addEntity(
random, system, loc, Entities.CORONAL_TAP, factionId);
705 if (entity !=
null) {
706 system.addScript(
new MakeCoronalTapFaceNearestStar(entity.entity));
709 WeightedRandomPicker<PlanetAPI> picker =
new WeightedRandomPicker<PlanetAPI>();
710 WeightedRandomPicker<PlanetAPI> fallback =
new WeightedRandomPicker<PlanetAPI>();
711 for (PlanetAPI planet : system.getPlanets()) {
712 if (!planet.isNormalStar())
continue;
713 if (planet.getTypeId().equals(StarTypes.BLUE_GIANT) ||
714 planet.getTypeId().equals(StarTypes.BLUE_SUPERGIANT)) {
717 fallback.add(planet);
720 if (picker.isEmpty()) {
721 picker.addAll(fallback);
724 PlanetAPI star = picker.pick();
727 EntityLocation loc =
new EntityLocation();
728 float orbitRadius = star.getRadius() + spec.getDefaultRadius() + 100f;
729 float orbitDays = orbitRadius / 20f;
731 entity =
addEntity(
random, system, loc, Entities.CORONAL_TAP, factionId);
736 if (entity !=
null) {
746 system.addTag(Tags.HAS_CORONAL_TAP);
750 if (entity !=
null) {
751 System.out.println(String.format(
" Added coronal tap to %s", system.getNameWithLowercaseType()));
753 System.out.println(String.format(
" Failed to add coronal tap to %s", system.getNameWithLowercaseType()));
761 if (
DEBUG) System.out.println(
"Looking for system to hide PK in");
763 List<StarSystemAPI> preferred =
new ArrayList<StarSystemAPI>();
764 List<StarSystemAPI> other =
new ArrayList<StarSystemAPI>();
767 for (StarSystemAPI system : c.getSystems()) {
768 if (system.hasTag(Tags.THEME_SPECIAL))
continue;
770 if (system.isNebula())
continue;
771 if (system.hasPulsar())
continue;
772 if (system.hasBlackHole())
continue;
774 boolean misc = system.hasTag(Tags.THEME_MISC_SKIP) || system.hasTag(Tags.THEME_MISC);
775 if (system.hasTag(Tags.THEME_DERELICT)) misc =
false;
777 boolean nonLargeDerelict = system.hasTag(Tags.THEME_DERELICT) &&
778 !system.hasTag(Tags.THEME_DERELICT_MOTHERSHIP) &&
779 !system.hasTag(Tags.THEME_DERELICT_CRYOSLEEPER) &&
780 !system.hasTag(Tags.THEME_DERELICT_SURVEY_SHIP);
782 boolean secondaryRuins = system.hasTag(Tags.THEME_RUINS_SECONDARY);
783 boolean remnantNoFleets = system.hasTag(Tags.THEME_REMNANT_NO_FLEETS);
784 boolean unsafe = system.hasTag(Tags.THEME_UNSAFE);
786 if (unsafe || !(misc || nonLargeDerelict || secondaryRuins || remnantNoFleets)) {
791 for (PlanetAPI curr : system.getPlanets()) {
792 if (curr.isStar())
continue;
793 if (curr.isMoon())
continue;
794 if (curr.isGasGiant())
continue;
795 if (!curr.getMarket().isPlanetConditionMarketOnly())
continue;
796 if (curr.getCircularOrbitRadius() < 6000)
continue;
797 if (curr.hasTag(Tags.NOT_RANDOM_MISSION_TARGET))
continue;
802 preferred.add(system);
809 Comparator<StarSystemAPI> comp =
new Comparator<StarSystemAPI>() {
810 public int compare(StarSystemAPI o1, StarSystemAPI o2) {
811 return (
int) Math.signum(o2.getLocation().length() - o1.getLocation().length());
815 List<StarSystemAPI> sorted =
new ArrayList<StarSystemAPI>();
816 if (!preferred.isEmpty()) {
817 sorted.addAll(preferred);
819 sorted.addAll(other);
821 if (sorted.isEmpty()) {
822 if (
DEBUG) System.out.println(
"FAILED TO FIND SUITABLE SYSTEM FOR PK");
825 Collections.sort(sorted, comp);
829 WeightedRandomPicker<StarSystemAPI> picker =
new WeightedRandomPicker<StarSystemAPI>(
random);
830 for (
int i = 0; i < 20 && i < sorted.size(); i++) {
832 picker.add(sorted.get(i), 1f);
835 StarSystemAPI system = picker.pick();
837 if (
DEBUG) System.out.println(
"Adding PK to [" + system.getName() +
"] at [" + system.getLocation() +
"]");
841 if (
DEBUG) System.out.println(
"Finished adding PK system\n\n\n\n\n");
845 system.addTag(Tags.THEME_SPECIAL);
846 system.addTag(Tags.PK_SYSTEM);
854 PlanetAPI tundra =
null;
855 for (PlanetAPI curr : system.getPlanets()) {
856 if (curr.isStar())
continue;
858 if (curr.isGasGiant())
continue;
859 if (curr.getMarket() ==
null)
continue;
860 if (!curr.getMarket().isPlanetConditionMarketOnly())
continue;
861 if (curr.getCircularOrbitRadius() < 6000)
continue;
872 if (tundra ==
null) {
874 float orbitRadius = 7000;
875 if (!gaps.isEmpty()) {
876 orbitRadius = (gaps.get(0).start + gaps.get(0).end) * 0.5f;
878 float orbitDays = orbitRadius / (20f +
random.nextFloat() * 5f);
879 float radius = 100f +
random.nextFloat() * 50f;
880 float angle =
random.nextFloat() * 360f;
881 String type = Planets.BARREN;
883 String name = namePick.nameWithRomanSuffixIfAny;
884 tundra = system.addPlanet(Misc.genUID(), system.getStar(), name, type, angle, radius, orbitRadius, orbitDays);
886 if (tundra ==
null) {
887 if (
DEBUG) System.out.println(
"FAILED TO CREATE PLANET IN PK SYSTEM");
892 tundra.setName(
"Sentinel");
893 tundra.addTag(Tags.NOT_RANDOM_MISSION_TARGET);
897 if (
DEBUG) System.out.println(
"Setting planet [" + tundra.getName() +
"] to tundra");
898 tundra.changeType(Planets.TUNDRA,
random);
899 tundra.getMarket().getConditions().clear();
901 tundra.getMarket().removeCondition(Conditions.DECIVILIZED);
902 tundra.getMarket().removeCondition(Conditions.DECIVILIZED_SUBPOP);
903 tundra.getMarket().removeCondition(Conditions.RUINS_EXTENSIVE);
904 tundra.getMarket().removeCondition(Conditions.RUINS_SCATTERED);
905 tundra.getMarket().removeCondition(Conditions.RUINS_VAST);
906 tundra.getMarket().removeCondition(Conditions.RUINS_WIDESPREAD);
907 tundra.getMarket().removeCondition(Conditions.INIMICAL_BIOSPHERE);
909 tundra.getMarket().removeCondition(Conditions.FARMLAND_POOR);
910 tundra.getMarket().removeCondition(Conditions.FARMLAND_ADEQUATE);
911 tundra.getMarket().removeCondition(Conditions.FARMLAND_RICH);
912 tundra.getMarket().removeCondition(Conditions.FARMLAND_BOUNTIFUL);
913 tundra.getMarket().addCondition(Conditions.FARMLAND_POOR);
918 float pickHazard = tundra.getMarket().getHazardValue();
920 for (PlanetAPI curr : system.getPlanets()) {
921 if (curr.isStar())
continue;
922 if (curr.isGasGiant())
continue;
923 if (curr.getMarket() ==
null)
continue;
924 if (!curr.getMarket().isPlanetConditionMarketOnly())
continue;
925 if (curr == tundra)
continue;
927 float h = curr.getMarket().getHazardValue();
928 if (curr.hasCondition(Conditions.HABITABLE) && h <= pickHazard) {
929 curr.changeType(Planets.BARREN_VENUSLIKE,
random);
930 curr.getMarket().getConditions().clear();
935 for (SectorEntityToken curr : system.getEntitiesWithTag(Tags.STABLE_LOCATION)) {
936 system.removeEntity(curr);
938 for (SectorEntityToken curr : system.getEntitiesWithTag(Tags.OBJECTIVE)) {
939 system.removeEntity(curr);
944 float orbitRadius = 7000;
945 if (!gaps.isEmpty()) {
946 orbitRadius = (gaps.get(0).start + gaps.get(0).end) * 0.5f;
948 float radius = 500f + 200f *
random.nextFloat();
949 float area = radius * radius * 3.14f;
950 int count = (int) (area / 80000f);
952 if (count < 10) count = 10;
953 if (count > 100) count = 100;
954 float angle =
random.nextFloat() * 360f;
955 float orbitDays = orbitRadius / (20f +
random.nextFloat() * 5f);
957 SectorEntityToken field = system.addTerrain(Terrain.ASTEROID_FIELD,
958 new AsteroidFieldParams(
967 field.setCircularOrbit(system.getCenter(), angle, orbitRadius, orbitDays);
971 cache.addTag(Tags.NOT_RANDOM_MISSION_TARGET);
973 cache.setCircularOrbit(field, 0, 0, 100f);
980 StarSystemData data =
new StarSystemData();
981 WeightedRandomPicker<String> derelictShipFactions =
new WeightedRandomPicker<String>(
random);
982 derelictShipFactions.add(Factions.LUDDIC_PATH);
983 WeightedRandomPicker<String> hulls =
new WeightedRandomPicker<String>(
random);
984 hulls.add(
"prometheus2", 1f);
985 hulls.add(
"colossus2", 1f);
986 hulls.add(
"colossus2", 1f);
987 hulls.add(
"colossus2", 1f);
988 hulls.add(
"eradicator", 1f);
989 hulls.add(
"enforcer", 1f);
990 hulls.add(
"sunder", 1f);
991 hulls.add(
"venture_pather", 1f);
992 hulls.add(
"manticore_luddic_path", 1f);
993 hulls.add(
"cerberus_luddic_path", 1f);
994 hulls.add(
"hound_luddic_path", 1f);
995 hulls.add(
"buffalo2", 1f);
997 for (AddedEntity ae : data.generated) {
1004 JumpPointAPI fringePoint =
null;
1005 List<JumpPointAPI> points = system.getEntities(JumpPointAPI.class);
1006 for (JumpPointAPI curr : points) {
1007 float dist = curr.getCircularOrbitRadius();
1014 if (fringePoint !=
null) {
1015 data =
new StarSystemData();
1016 WeightedRandomPicker<String> remnantShipFactions =
new WeightedRandomPicker<String>(
random);
1017 remnantShipFactions.add(Factions.REMNANTS);
1018 hulls =
new WeightedRandomPicker<String>(
random);
1019 hulls.add(
"radiant", 0.25f);
1020 hulls.add(
"nova", 0.5f);
1021 hulls.add(
"brilliant", 1f);
1022 hulls.add(
"apex", 1f);
1023 hulls.add(
"scintilla", 1f);
1024 hulls.add(
"scintilla", 1f);
1025 hulls.add(
"fulgent", 1f);
1026 hulls.add(
"fulgent", 1f);
1027 hulls.add(
"glimmer", 1f);
1028 hulls.add(
"glimmer", 1f);
1029 hulls.add(
"lumen", 1f);
1030 hulls.add(
"lumen", 1f);
1034 for (AddedEntity ae : data.generated) {
1038 plugin.
getData().ship.condition = ShipCondition.WRECKED;
1044 SectorEntityToken dockyard = system.addCustomEntity(
"pk_dockyard",
1045 "Sentinel Gantries", Entities.ORBITAL_DOCKYARD,
"neutral");
1047 dockyard.setCircularOrbitPointingDown(tundra, 45, 300, 30);
1048 dockyard.setCustomDescriptionId(
"pk_orbital_dockyard");
1049 dockyard.getMemoryWithoutUpdate().set(
"$pkDockyard",
true);
1052 Misc.setAbandonedStationMarket(
"pk_dockyard", dockyard);
1056 CargoAPI cargo = dockyard.getMarket().getSubmarket(Submarkets.SUBMARKET_STORAGE).getCargo();
1057 cargo.initMothballedShips(Factions.HEGEMONY);
1060 temp.getFleetData().addFleetMember(
"enforcer_XIV_Elite");
1061 temp.getFleetData().addFleetMember(
"enforcer_XIV_Elite");
1062 temp.getFleetData().addFleetMember(
"eagle_xiv_Elite");
1063 temp.getFleetData().addFleetMember(
"dominator_XIV_Elite");
1064 DefaultFleetInflaterParams p =
new DefaultFleetInflaterParams();
1066 temp.setInflater(
new DefaultFleetInflater(p));
1067 temp.inflateIfNeeded();
1068 temp.setInflater(
null);
1071 for (FleetMemberAPI member : temp.getFleetData().getMembersListCopy()) {
1072 for (String slotId : member.getVariant().getFittedWeaponSlots()) {
1073 String weaponId = member.getVariant().getWeaponId(slotId);
1074 if (
random.nextFloat() < 0.5f) {
1075 member.getVariant().clearSlot(slotId);
1077 if (
random.nextFloat() < 0.25f) {
1078 cargo.addWeapons(weaponId, 1);
1081 if (index == 0 || index == 2) {
1082 cargo.getMothballedShips().addFleetMember(member);
1086 cargo.addCommodity(Commodities.METALS, 50f +
random.nextInt(51));
1089 float minDist = Float.MAX_VALUE;
1090 CampaignFleetAPI nexus =
null;
1091 for (CampaignFleetAPI curr : stations) {
1092 float dist = Misc.getDistanceLY(tundra, curr);
1093 if (dist < minDist) {
1098 if (nexus !=
null) {
1099 if (
DEBUG) System.out.println(
"Found Remnant nexus in [" + nexus.getContainingLocation().getName() +
"]");
1100 nexus.getMemoryWithoutUpdate().set(
PK_NEXUS_KEY,
true);
1104 Misc.addDefeatTrigger(nexus,
"PKNexusDefeated");
1109 if (
DEBUG) System.out.println(
"Looking for LOCR_LUDDIC planet");
1111 WeightedRandomPicker<PlanetAPI> picker =
new WeightedRandomPicker<PlanetAPI>(
random);
1112 WeightedRandomPicker<PlanetAPI> picker_fallback =
new WeightedRandomPicker<PlanetAPI>(
random);
1116 for (StarSystemAPI system : c.getSystems()) {
1118 if (system.hasTag(Tags.THEME_SPECIAL))
continue;
1119 if (system.isNebula())
continue;
1120 if (system.hasPulsar())
continue;
1121 if (system.hasBlackHole())
continue;
1122 if (!system.hasTag(Tags.THEME_MISC_SKIP) && !system.hasTag(Tags.THEME_MISC))
continue;
1123 if (system.hasTag(Tags.THEME_DERELICT))
continue;
1125 for (PlanetAPI curr : system.getPlanets()) {
1126 if (curr.isStar())
continue;
1127 if (!curr.getMarket().isPlanetConditionMarketOnly())
continue;
1129 if (curr.hasTag(Tags.NOT_RANDOM_MISSION_TARGET))
continue;
1130 if (curr.getMarket().hasCondition(Conditions.WATER_SURFACE))
continue;
1131 if (curr.isGasGiant())
continue;
1132 if (curr.getMarket().hasCondition(Conditions.DECIVILIZED_SUBPOP))
continue;
1135 if (curr.getMarket().hasCondition(
"farmland_rich") || curr.getMarket().hasCondition(
"farmland_bountiful"))
1139 else if ( curr.getMarket().hasCondition(
"farmland_adequate"))
1141 picker_fallback.add(curr);
1147 PlanetAPI planet = picker.pick();
1150 planet = picker_fallback.pick();
1153 if (planet !=
null) {
1157 DerelictShipData params =
new DerelictShipData(
new PerShipData(
"nebula_Standard", ShipCondition.BATTERED, 0f),
false);
1158 params.ship.shipName =
"CGR Light of Exultation";
1159 params.ship.nameAlwaysKnown =
true;
1163 ship.setDiscoverable(
true);
1164 float orbitDays = 200f / (10f + (float) Math.random() * 5f);
1165 ship.setCircularOrbit(planet, (
float) Math.random() * 360f, planet.getRadius() + 100f, orbitDays);
1166 ShipRecoverySpecialCreator creator =
new ShipRecoverySpecialCreator(
null, 0, 0,
false,
null,
null);
1167 Misc.setSalvageSpecial(ship, creator.createSpecial(ship,
null));
1173 if (
DEBUG) System.out.println(
"Adding LOCR_LUDDIC flag to [" + planet.getName() +
"] in [" + planet.getContainingLocation().getNameWithLowercaseType() +
"]");
1175 planet.getMemoryWithoutUpdate().set(
LOCR_LUDDIC,
true);
1179 planet.addTag(Tags.NOT_RANDOM_MISSION_TARGET);
1182 if (
DEBUG) System.out.println(
"Failed to find a LOCR_LUDDIC planet, may Ludd forgive you.");
1184 if (
DEBUG) System.out.println(
"Finished adding LOCR_LUDDIC planet\n\n\n");