Starsector API
Loading...
Searching...
No Matches
DisposableLuddicPathFleetManager.java
Go to the documentation of this file.
1package com.fs.starfarer.api.impl.campaign.fleets;
2
3import com.fs.starfarer.api.Global;
4import com.fs.starfarer.api.campaign.CampaignFleetAPI;
5import com.fs.starfarer.api.campaign.StarSystemAPI;
6import com.fs.starfarer.api.campaign.econ.MarketAPI;
7import com.fs.starfarer.api.campaign.econ.MarketConditionAPI;
8import com.fs.starfarer.api.impl.campaign.ids.Conditions;
9import com.fs.starfarer.api.impl.campaign.ids.Factions;
10import com.fs.starfarer.api.impl.campaign.ids.FleetTypes;
11import com.fs.starfarer.api.impl.campaign.ids.MemFlags;
12import com.fs.starfarer.api.impl.campaign.intel.bases.LuddicPathCells;
13import com.fs.starfarer.api.impl.campaign.intel.bases.PirateBaseManager;
14import com.fs.starfarer.api.util.Misc;
15
26
27 protected Object readResolve() {
28 super.readResolve();
29 return this;
30 }
31
32 @Override
33 protected String getSpawnId() {
34 return "luddic_path"; // not a faction id, just an identifier for this spawner
35 }
36
37 @Override
39 MarketAPI pather = getLargestMarket(Factions.LUDDIC_PATH);
40 MarketAPI church = getLargestMarket(Factions.LUDDIC_CHURCH);
41
42 float desiredNumFleets = 1f;
43
44 if (church != null) {
45 desiredNumFleets++;
46 }
47 if (pather != null) {
48 desiredNumFleets += pather.getSize();
49 }
50
51 int cells = getPatherCellsLevel();
52 desiredNumFleets += cells;
53
54 return (int) Math.round(desiredNumFleets);
55 }
56
57 protected int getPatherCellsLevel() {
58 if (currSpawnLoc == null) return 0;
59 int total = 0;
60 for (MarketAPI market : Global.getSector().getEconomy().getMarkets(currSpawnLoc)) {
61 if (market.isHidden()) continue;
62 MarketConditionAPI mc = market.getCondition(Conditions.PATHER_CELLS);
63 if (mc != null && mc.getPlugin() instanceof LuddicPathCells) {
64 LuddicPathCells cells = (LuddicPathCells) mc.getPlugin();
65 if (cells.getIntel() != null) {
66 if (cells.getIntel().isSleeper()) {
67 total++;
68 } else {
69 total += 2;
70 }
71 }
72 }
73 }
74 return 0;
75 }
76
77
78 protected MarketAPI getLargestMarket(String faction) {
79 if (currSpawnLoc == null) return null;
80 MarketAPI largest = null;
81 int maxSize = 0;
82 for (MarketAPI market : Global.getSector().getEconomy().getMarkets(currSpawnLoc)) {
83 if (market.isHidden()) continue;
84 if (!market.getFactionId().equals(faction)) continue;
85
86 if (market.getSize() > maxSize) {
87 maxSize = market.getSize();
88 largest = market;
89 }
90 }
91 return largest;
92 }
93
94 protected CampaignFleetAPI spawnFleetImpl() {
95 StarSystemAPI system = currSpawnLoc;
96 if (system == null) return null;
97
98 CampaignFleetAPI player = Global.getSector().getPlayerFleet();
99 if (player == null) return null;
100
101 int num = Misc.getMarketsInLocation(system).size();
102 if (Misc.getMarketsInLocation(system, Factions.PLAYER).size() == num && num > 0) {
103 return null; // handled by HostileActivityIntel, DisposableHostileActivityFleetManager, etc
104 }
105
106
107 String fleetType = FleetTypes.PATROL_SMALL;
108
109
110 float combat = 1;
111 for (int i = 0; i < 3; i++) {
112 if ((float) Math.random() > 0.5f) {
113 combat++;
114 }
115 }
116
117 float desired = getDesiredNumFleetsForSpawnLocation();
118 if (desired > 2) {
119 float timeFactor = (PirateBaseManager.getInstance().getDaysSinceStart() - 180f) / (365f * 2f);
120 if (timeFactor < 0) timeFactor = 0;
121 if (timeFactor > 1) timeFactor = 1;
122
123 combat += ((desired - 2) * (0.5f + (float) Math.random() * 0.5f)) * 1f * timeFactor;
124 //combat += (desired - 2) * (0.5f + (float) Math.random() * 0.5f);
125 }
126
127 combat *= 5f;
128
129 FleetParamsV3 params = new FleetParamsV3(
130 null, // source market
131 system.getLocation(),
132 Factions.LUDDIC_PATH,
133 null,
134 fleetType,
135 combat, // combatPts
136 0, // freighterPts
137 0, // tankerPts
138 0f, // transportPts
139 0f, // linerPts
140 0f, // utilityPts
141 0f // qualityMod
142 );
143 params.ignoreMarketFleetSizeMult = true;
144
145 //params.random = random;
146 CampaignFleetAPI fleet = FleetFactoryV3.createFleet(params);
147 if (fleet == null || fleet.isEmpty()) return null;
148
149 // setting the below means: transponder off and more "go dark" use when traveling
150 //fleet.getMemoryWithoutUpdate().set(MemFlags.MEMORY_KEY_PIRATE, true);
151
152 fleet.getMemoryWithoutUpdate().set(MemFlags.FLEET_NO_MILITARY_RESPONSE, true);
153
155
156 if (nf == 1) {
157 setLocationAndOrders(fleet, 1f, 1f);
158 } else {
159 setLocationAndOrders(fleet, 0.5f, 1f);
160 }
161
162 return fleet;
163 }
164
165}
166
167
168
169
170
171
172
173
static SectorAPI getSector()
Definition Global.java:59
void setLocationAndOrders(CampaignFleetAPI fleet, float probStartInHyper, float probStayInHyper)
static CampaignFleetAPI createFleet(FleetParamsV3 params)