1package com.fs.starfarer.api.impl.campaign.intel.group;
4import java.util.ArrayList;
6import java.util.Random;
9import org.lwjgl.util.vector.Vector2f;
11import com.fs.starfarer.api.Global;
12import com.fs.starfarer.api.campaign.CampaignFleetAPI;
13import com.fs.starfarer.api.campaign.FactionAPI;
14import com.fs.starfarer.api.campaign.SectorEntityToken;
15import com.fs.starfarer.api.campaign.StarSystemAPI;
16import com.fs.starfarer.api.campaign.econ.MarketAPI;
17import com.fs.starfarer.api.impl.campaign.ids.Factions;
18import com.fs.starfarer.api.impl.campaign.intel.group.FGRaidAction.FGRaidParams;
19import com.fs.starfarer.api.impl.campaign.missions.FleetCreatorMission;
20import com.fs.starfarer.api.impl.campaign.missions.FleetCreatorMission.FleetStyle;
21import com.fs.starfarer.api.impl.campaign.missions.hub.BaseHubMission;
22import com.fs.starfarer.api.impl.campaign.missions.hub.HubMissionWithTriggers.ComplicationRepImpact;
23import com.fs.starfarer.api.impl.campaign.rulecmd.salvage.MarketCMD.BombardType;
24import com.fs.starfarer.api.ui.Alignment;
25import com.fs.starfarer.api.ui.LabelAPI;
26import com.fs.starfarer.api.ui.SectorMapAPI;
27import com.fs.starfarer.api.ui.TooltipMakerAPI;
28import com.fs.starfarer.api.util.Misc;
29import com.fs.starfarer.api.util.WeightedRandomPicker;
39 public static interface GenericPayloadAction
extends FGAction {
40 Color getSystemNameHighlightColor();
41 float getSuccessFraction();
42 StarSystemAPI getWhere();
46 public static class GenericRaidParams {
47 public Random random =
new Random();
48 public boolean playerTargeted;
49 public boolean remnant =
false;
50 public MarketAPI source;
51 public String factionId;
52 public List<Integer> fleetSizes =
new ArrayList<Integer>();
53 public FleetStyle style = FleetStyle.STANDARD;
54 public FGRaidParams raidParams =
new FGRaidParams();
55 public float prepDays = 5f;
56 public float payloadDays = 30f;
57 public boolean makeFleetsHostile =
true;
58 public ComplicationRepImpact repImpact = ComplicationRepImpact.LOW;
60 public String forcesNoun;
62 public String memoryKey =
null;
64 public GenericRaidParams(Random random,
boolean playerTargeted) {
66 this.playerTargeted = playerTargeted;
89 if (
params.memoryKey !=
null) {
106 "preparing for departure");
117 SectorEntityToken returnWhere =
params.source.getPrimaryEntity();
118 if (returnWhere.getStarSystem() !=
null) {
119 returnWhere = returnWhere.getStarSystem().getCenter();
122 params.source.getPrimaryEntity());
129 for (Integer i :
params.fleetSizes) total += i;
140 if (
route !=
null &&
route.getExtra() !=
null) {
141 damage =
route.getExtra().damage;
143 if (damage ==
null) damage = 0f;
145 WeightedRandomPicker<Integer> picker =
new WeightedRandomPicker<Integer>(
getRandom());
146 picker.addAll(
params.fleetSizes);
149 for (Integer i :
params.fleetSizes) total += i;
151 float spawnsToSkip = total * damage * 0.5f;
159 while (!picker.isEmpty()) {
160 Integer size = picker.pickAndRemove();
161 if (skipped < spawnsToSkip &&
getRandom().nextFloat() < damage) {
166 CampaignFleetAPI fleet =
createFleet(size, damage);
168 if (fleet !=
null &&
route !=
null) {
176 Vector2f loc =
origin.getLocationInHyperspace();
177 boolean pirate =
faction.getCustomBoolean(Factions.CUSTOM_PIRATE_BEHAVIOR);
179 FleetCreatorMission m =
new FleetCreatorMission(
getRandom());
186 if (factionId ==
null) factionId =
params.factionId;
188 m.createFleet(
params.style, size, factionId, loc);
189 m.triggerSetFleetFaction(
params.factionId);
191 m.setFleetSource(
params.source);
192 m.setFleetDamageTaken(damage);
194 m.triggerSetPirateFleet();
196 m.triggerSetWarFleet();
200 m.triggerSetRemnantConfigActive();
203 if (
params.makeFleetsHostile) {
204 for (MarketAPI market :
params.raidParams.allowedTargets) {
205 m.triggerMakeHostileToFaction(market.getFactionId());
207 m.triggerMakeHostile();
208 if (Factions.LUDDIC_PATH.equals(
faction.getId())) {
209 m.triggerFleetPatherNoDefaultTithe();
213 if (
params.repImpact == ComplicationRepImpact.LOW ||
params.repImpact ==
null) {
214 m.triggerMakeLowRepImpact();
215 }
else if (
params.repImpact == ComplicationRepImpact.NONE) {
216 m.triggerMakeNoRepImpact();
219 if (
params.repImpact != ComplicationRepImpact.FULL) {
220 m.triggerMakeAlwaysSpreadTOffHostility();
225 CampaignFleetAPI fleet = m.createFleet();
250 Color s =
raidAction.getSystemNameHighlightColor();
251 LabelAPI label = info.addPara(
"Targeting the " + system.getNameWithLowercaseTypeShort(), tc, initPad);
252 label.setHighlightColors(s);
253 label.setHighlight(system.getNameWithNoType());
257 Color h = Misc.getHighlightColor();
258 Color s =
raidAction.getSystemNameHighlightColor();
268 if (mode == ListInfoMode.MESSAGES ||
getElapsed() <= 0f) {
272 if (untilDeployment > 0) {
273 addETABulletPoints(
null,
null,
false, untilDeployment, ETAType.DEPLOYMENT, info, tc, initPad);
275 }
else if (untilDeparture > 0) {
276 addETABulletPoints(
null,
null,
false, untilDeparture, ETAType.DEPARTURE, info, tc, initPad);
279 if (untilRaid > 0 &&
getSource().getContainingLocation() != system) {
280 addETABulletPoints(system.getNameWithLowercaseTypeShort(), s,
false, untilRaid, ETAType.ARRIVING,
285 mode != ListInfoMode.INTEL) {
286 StarSystemAPI from =
getSource().getStarSystem();
288 addETABulletPoints(from.getNameWithLowercaseTypeShort(),
null,
false, untilReturn, ETAType.RETURNING,
292 if ((mode == ListInfoMode.INTEL || mode == ListInfoMode.MAP_TOOLTIP)
294 LabelAPI label = info.addPara(
"Operating in the " + system.getNameWithLowercaseTypeShort(), tc, initPad);
295 label.setHighlightColors(s);
296 label.setHighlight(system.getNameWithNoType());
301 if (mode != ListInfoMode.IN_DESC &&
isEnding()) {
304 info.addPara(
"The " + forces +
" have failed to achieve their objective", tc, initPad);
307 info.addPara(
"The " + forces +
" have failed to achieve their objective", tc, initPad);
309 info.addPara(
"The " + forces +
" have been defeated and scatter", tc, initPad);
316 protected void addUpdateBulletPoints(TooltipMakerAPI info, Color tc, Object param, ListInfoMode mode,
float initPad) {
320 Color s =
raidAction.getSystemNameHighlightColor();
324 info.addPara(
"The " + noun +
" was aborted in the planning stages", tc, initPad);
326 info.addPara(
"The " + forces +
" have been defeated and scatter", tc, initPad);
331 info.addPara(
"Fleet deployment in progress", tc, initPad);
333 if (untilDeparture > 0) {
334 addETABulletPoints(
null,
null,
false, untilDeparture, ETAType.DEPARTURE, info, tc, initPad);
336 if (untilRaid > 0 &&
getSource().getContainingLocation() != system) {
337 addETABulletPoints(system.getNameWithLowercaseTypeShort(), s,
false, untilRaid, ETAType.ARRIVING,
342 addETABulletPoints(system.getNameWithLowercaseTypeShort(), s,
true, untilRaid, ETAType.ARRIVING,
348 info.addPara(
"The " + forces +
" are withdrawing", tc, initPad);
351 info.addPara(
"The " + forces +
" have been defeated and scatter", tc, initPad);
353 info.addPara(
"The " + forces +
" have failed to achieve their objective", tc, initPad);
374 return super.shouldSendIntelUpdateWhenActionFinished(action);
378 info.addImage(
getFaction().getLogo(), width, 128, opad);
386 info.addPara(Misc.ucFirst(
faction.getPersonNamePrefixAOrAn()) +
" %s " + noun +
" against "
387 +
"the " + system.getNameWithLowercaseTypeShort() +
".", opad,
394 Color h = Misc.getHighlightColor();
398 List<MarketAPI> targets =
params.raidParams.allowedTargets;
402 info.addSectionHeading(
"Assessment",
403 faction.getBaseUIColor(),
faction.getDarkUIColor(), Alignment.MID, opad);
404 if (targets.isEmpty()) {
405 info.addPara(
"There are no colonies for the " + noun +
" to target in the system.", opad);
412 "the " + noun +
" is unlikely to find success",
413 "the outcome of the " + noun +
" is uncertain",
414 "the " + noun +
" is likely to find success");
416 if (potentialDanger) {
417 String safe =
"should be safe from the " + noun;
418 String risk =
"are at risk of being raided and losing stability:";
419 String highlight =
"losing stability:";
420 if (
params.raidParams.bombardment == BombardType.SATURATION) {
421 risk =
"are at risk of suffering a saturation bombardment resulting in catastrophic damage:";
422 highlight =
"catastrophic damage";
423 }
else if (
params.raidParams.bombardment == BombardType.TACTICAL) {
424 risk =
"are at risk of suffering a tactical bombardment and having their military infrastructure disrupted:";
425 highlight =
"military infrastructure disrupted";
426 }
else if (!
params.raidParams.disrupt.isEmpty()) {
427 risk =
"are at risk of being raided and having their operations severely disrupted";
428 highlight =
"operations severely disrupted";
437 safe, risk, highlight);
458 info.addPara(
"Conducting operations in the " +
459 to.getNameWithLowercaseTypeShort() +
".", opad);
463 protected void addStatusSection(TooltipMakerAPI info,
float width,
float height,
float opad) {
471 info.addSectionHeading(
"Status",
472 faction.getBaseUIColor(),
faction.getDarkUIColor(), Alignment.MID, opad);
476 info.addPara(
"The " + forces +
" are withdrawing.", opad);
478 info.addPara(
"The " + forces +
" have been defeated and any "
479 +
"remaining ships are retreating in disarray.", opad);
482 info.addPara(
"The " + forces +
" are withdrawing.", opad);
485 info.addPara(
"The " + noun +
" was successful and the " + forces +
" are withdrawing.", opad);
486 }
else if (curr !=
null) {
490 BaseHubMission.addStandardMarketDesc(
"The " + noun +
" is in the planning stages on",
494 info.addPara(
"Disrupting the military facilities " +
getSource().getMarket().getOnOrAt() +
495 " " +
getSource().getMarket().
getName() +
" will abort the " + noun +
".", opad);
500 BaseHubMission.addStandardMarketDesc(
"Making preparations in orbit around",
503 info.addPara(
"Making preparations in orbit around " +
getSource().
getName() +
".", opad);
507 info.addPara(
"Traveling to the " +
508 to.getNameWithLowercaseTypeShort() +
".", opad);
510 info.addPara(
"Traveling from " +
getSource().getMarket().
getName() +
" to the " +
511 to.getNameWithLowercaseTypeShort() +
".", opad);
515 info.addPara(
"Returning to their port of origin.", opad);
517 info.addPara(
"Returning to " +
getSource().getMarket().
getName() +
" in the " +
518 origin.getContainingLocation().getNameWithLowercaseTypeShort() +
".", opad);
530 String noun =
"raid";
531 if (
params.raidParams.bombardment !=
null) {
538 if (
params.forcesNoun !=
null)
return params.forcesNoun;
540 String forces =
"raiding forces";
541 if (!
getNoun().equals(
"raid")) {
542 forces =
"attacking forces";
549 return Misc.ucFirst(
getFaction().getPersonNamePrefix()) +
" " + Misc.ucFirst(
getNoun());
565 return raidAction.getWhere().getHyperspaceAnchor();
593 if (
params.playerTargeted) {
596 return super.getCommMessageSound();
600 return params.playerTargeted;
606 return super.getIntelTags(map);
614 return super.getArrowData(map);
static SectorAPI getSector()
boolean isSendingUpdate()
static String getSoundStandardUpdate()
static String getSoundColonyThreat()
void setTravelText(String travelText)
List< CampaignFleetAPI > fleets
boolean isInPreLaunchDelay()
void addArrivedBulletPoint(String destName, Color destHL, TooltipMakerAPI info, Color tc, float initPad)
void createRoute(String factionId, int approximateTotalDifficultyPoints, int approximateNumberOfFleets, Object custom)
FGAction getCurrentAction()
boolean isFailedButNotDefeated()
void addETABulletPoints(String destName, Color destHL, boolean withDepartedText, float eta, ETAType type, TooltipMakerAPI info, Color tc, float initPad)
static String FLEET_LAUNCH_UPDATE
float getDelayRemaining()
void showMarketsInDanger(TooltipMakerAPI info, float opad, float width, StarSystemAPI system, List< MarketAPI > targets, String safeStr, String riskStr, String riskStrHighlight)
static String ABORT_UPDATE
float getETAUntil(String actionId)
void addAction(FGAction action, String id)
void setRandom(Random random)
boolean addStrengthDesc(TooltipMakerAPI info, float opad, StarSystemAPI system, String forces, String outcomeFailure, String outcomeUncertain, String outcomeSuccess)
void setFaction(String factionId)
static void setLocationAndCoordinates(CampaignFleetAPI fleet, RouteSegment current)
boolean isSourceFunctionalMilitaryMarket()
List< ArrowData > getArrowData(SectorMapAPI map)
String getFleetCreationFactionOverride(int size)
boolean hasCustomRaidAction()
static String PREPARE_ACTION
FGWaitAction getWaitAction()
boolean shouldSendIntelUpdateWhenActionFinished(FGAction action)
void configureFleet(int size, FleetCreatorMission m)
static String TRAVEL_ACTION
GenericRaidFGI(GenericRaidParams params)
StarSystemAPI getTargetSystem()
void addPayloadActionStatus(TooltipMakerAPI info, float width, float height, float opad)
void addNonUpdateBulletPoints(TooltipMakerAPI info, Color tc, Object param, ListInfoMode mode, float initPad)
String getAssessmentRiskStringHighlightOverride()
void addStatusSection(TooltipMakerAPI info, float width, float height, float opad)
void addPostAssessmentSection(TooltipMakerAPI info, float width, float height, float opad)
void addBasicDescription(TooltipMakerAPI info, float width, float height, float opad)
void addTargetingBulletPoint(TooltipMakerAPI info, Color tc, Object param, ListInfoMode mode, float initPad)
FGTravelAction getTravelAction()
SectorEntityToken getMapLocation(SectorMapAPI map)
GenericPayloadAction raidAction
void configureFleet(int size, CampaignFleetAPI fleet)
static String PAYLOAD_ACTION
void doCustomRaidAction(CampaignFleetAPI fleet, MarketAPI market, float raidStr)
String getCommMessageSound()
void preConfigureFleet(int size, FleetCreatorMission m)
void addAssessmentSection(TooltipMakerAPI info, float width, float height, float opad)
GenericPayloadAction createPayloadAction()
boolean isPlayerTargeted()
void addUpdateBulletPoints(TooltipMakerAPI info, Color tc, Object param, ListInfoMode mode, float initPad)
void setOrigin(SectorEntityToken origin)
SectorEntityToken getDestination()
Set< String > getIntelTags(SectorMapAPI map)
GenericPayloadAction getRaidAction()
SectorEntityToken getSource()
GenericRaidParams getParams()
static String RETURN_ACTION
FGTravelAction returnAction
CampaignFleetAPI createFleet(int size, float damage)
FGTravelAction getReturnAction()
FGTravelAction travelAction
String getAssessmentRiskStringOverride()