1package com.fs.starfarer.api.impl.campaign.intel.group;
3import java.util.ArrayList;
5import java.util.Random;
10import org.lwjgl.util.vector.Vector2f;
12import com.fs.starfarer.api.Global;
13import com.fs.starfarer.api.campaign.CampaignFleetAPI;
14import com.fs.starfarer.api.campaign.FactionAPI;
15import com.fs.starfarer.api.campaign.SectorEntityToken;
16import com.fs.starfarer.api.campaign.StarSystemAPI;
17import com.fs.starfarer.api.campaign.econ.MarketAPI;
18import com.fs.starfarer.api.impl.campaign.ids.Factions;
19import com.fs.starfarer.api.impl.campaign.intel.group.FGRaidAction.FGRaidParams;
20import com.fs.starfarer.api.impl.campaign.missions.FleetCreatorMission;
21import com.fs.starfarer.api.impl.campaign.missions.FleetCreatorMission.FleetStyle;
22import com.fs.starfarer.api.impl.campaign.missions.hub.BaseHubMission;
23import com.fs.starfarer.api.impl.campaign.missions.hub.HubMissionWithTriggers.ComplicationRepImpact;
24import com.fs.starfarer.api.impl.campaign.rulecmd.salvage.MarketCMD.BombardType;
25import com.fs.starfarer.api.ui.Alignment;
26import com.fs.starfarer.api.ui.LabelAPI;
27import com.fs.starfarer.api.ui.SectorMapAPI;
28import com.fs.starfarer.api.ui.TooltipMakerAPI;
29import com.fs.starfarer.api.util.Misc;
30import com.fs.starfarer.api.util.WeightedRandomPicker;
40 public static interface GenericPayloadAction
extends FGAction {
41 Color getSystemNameHighlightColor();
42 float getSuccessFraction();
47 public static class GenericRaidParams {
48 public Random random =
new Random();
49 public boolean playerTargeted;
50 public boolean remnant =
false;
52 public String factionId;
53 public List<Integer> fleetSizes =
new ArrayList<Integer>();
54 public FleetStyle style = FleetStyle.STANDARD;
55 public FGRaidParams raidParams =
new FGRaidParams();
56 public float prepDays = 5f;
57 public float payloadDays = 30f;
58 public boolean makeFleetsHostile =
true;
59 public ComplicationRepImpact repImpact = ComplicationRepImpact.LOW;
61 public String forcesNoun;
63 public String memoryKey =
null;
65 public GenericRaidParams(Random random,
boolean playerTargeted) {
67 this.playerTargeted = playerTargeted;
90 if (
params.memoryKey !=
null) {
107 "preparing for departure");
130 for (Integer i :
params.fleetSizes) total += i;
141 if (
route !=
null &&
route.getExtra() !=
null) {
142 damage =
route.getExtra().damage;
144 if (damage ==
null) damage = 0f;
150 for (Integer i :
params.fleetSizes) total += i;
152 float spawnsToSkip = total * damage * 0.5f;
162 if (skipped < spawnsToSkip &&
getRandom().nextFloat() < damage) {
169 if (fleet !=
null &&
route !=
null) {
187 if (factionId ==
null) factionId =
params.factionId;
205 if (
params.makeFleetsHostile) {
215 if (
params.repImpact == ComplicationRepImpact.LOW ||
params.repImpact ==
null) {
217 }
else if (
params.repImpact == ComplicationRepImpact.NONE) {
221 if (
params.repImpact != ComplicationRepImpact.FULL) {
252 Color s =
raidAction.getSystemNameHighlightColor();
260 Color s =
raidAction.getSystemNameHighlightColor();
270 if (mode == ListInfoMode.MESSAGES ||
getElapsed() <= 0f) {
274 if (untilDeployment > 0) {
275 addETABulletPoints(
null,
null,
false, untilDeployment, ETAType.DEPLOYMENT, info, tc, initPad);
277 }
else if (untilDeparture > 0) {
278 addETABulletPoints(
null,
null,
false, untilDeparture, ETAType.DEPARTURE, info, tc, initPad);
281 if (untilRaid > 0 &&
getSource().getContainingLocation() != system) {
287 mode != ListInfoMode.INTEL) {
294 if ((mode == ListInfoMode.INTEL || mode == ListInfoMode.MAP_TOOLTIP)
303 if (mode != ListInfoMode.IN_DESC &&
isEnding()) {
306 info.
addPara(
"The " + forces +
" have failed to achieve their objective", tc, initPad);
309 info.
addPara(
"The " + forces +
" have failed to achieve their objective", tc, initPad);
311 info.
addPara(
"The " + forces +
" have been defeated and scatter", tc, initPad);
322 Color s =
raidAction.getSystemNameHighlightColor();
326 info.
addPara(
"The " + noun +
" was aborted in the planning stages", tc, initPad);
328 info.
addPara(
"The " + forces +
" have been defeated and scatter", tc, initPad);
333 info.
addPara(
"Fleet deployment in progress", tc, initPad);
335 if (untilDeparture > 0) {
336 addETABulletPoints(
null,
null,
false, untilDeparture, ETAType.DEPARTURE, info, tc, initPad);
338 if (untilRaid > 0 &&
getSource().getContainingLocation() != system) {
350 info.
addPara(
"The " + forces +
" are withdrawing", tc, initPad);
353 info.
addPara(
"The " + forces +
" have been defeated and scatter", tc, initPad);
355 info.
addPara(
"The " + forces +
" have failed to achieve their objective", tc, initPad);
376 return super.shouldSendIntelUpdateWhenActionFinished(action);
400 List<MarketAPI> targets =
params.raidParams.allowedTargets;
406 if (targets.isEmpty()) {
407 info.
addPara(
"There are no colonies for the " + noun +
" to target in the system.", opad);
414 "the " + noun +
" is unlikely to find success",
415 "the outcome of the " + noun +
" is uncertain",
416 "the " + noun +
" is likely to find success");
418 if (potentialDanger) {
419 String safe =
"should be safe from the " + noun;
420 String risk =
"are at risk of being raided and losing stability:";
421 String highlight =
"losing stability:";
422 if (
params.raidParams.bombardment == BombardType.SATURATION) {
423 risk =
"are at risk of suffering a saturation bombardment resulting in catastrophic damage:";
424 highlight =
"catastrophic damage";
425 }
else if (
params.raidParams.bombardment == BombardType.TACTICAL) {
426 risk =
"are at risk of suffering a tactical bombardment and having their military infrastructure disrupted:";
427 highlight =
"military infrastructure disrupted";
428 }
else if (!
params.raidParams.disrupt.isEmpty()) {
429 risk =
"are at risk of being raided and having their operations severely disrupted";
430 highlight =
"operations severely disrupted";
439 safe, risk, highlight);
460 info.
addPara(
"Conducting operations in the " +
478 info.
addPara(
"The " + forces +
" are withdrawing.", opad);
480 info.
addPara(
"The " + forces +
" have been defeated and any "
481 +
"remaining ships are retreating in disarray.", opad);
484 info.
addPara(
"The " + forces +
" are withdrawing.", opad);
487 info.
addPara(
"The " + noun +
" was successful and the " + forces +
" are withdrawing.", opad);
488 }
else if (curr !=
null) {
496 info.
addPara(
"Disrupting the military facilities " +
getSource().getMarket().getOnOrAt() +
497 " " +
getSource().getMarket().
getName() +
" will abort the " + noun +
".", opad);
509 info.
addPara(
"Traveling to the " +
517 info.
addPara(
"Returning to their port of origin.", opad);
532 String noun =
"raid";
533 if (
params.raidParams.bombardment !=
null) {
540 if (
params.forcesNoun !=
null)
return params.forcesNoun;
542 String forces =
"raiding forces";
543 if (!
getNoun().equals(
"raid")) {
544 forces =
"attacking forces";
595 if (
params.playerTargeted) {
598 return super.getCommMessageSound();
602 return params.playerTargeted;
608 return super.getIntelTags(map);
616 return super.getArrowData(map);
645 if (m ==
null ||
route ==
null ||
route.getExtra() ==
null ||
route.getExtra().quality ==
null)
return;
static SectorAPI getSector()
static final String LUDDIC_PATH
static final String CUSTOM_PIRATE_BEHAVIOR
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)
void setFleetCreatorQualityFromRoute(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()
CampaignFleetAPI createFleet()
static void addStandardMarketDesc(String prefix, MarketAPI market, TooltipMakerAPI info, float pad)
void triggerMakeAlwaysSpreadTOffHostility()
void triggerMakeHostile()
void triggerSetWarFleet()
void triggerFleetPatherNoDefaultTithe()
CreateFleetAction getPreviousCreateFleetAction()
void triggerMakeLowRepImpact()
void triggerMakeNoRepImpact()
void setFleetDamageTaken(float damage)
void triggerMakeHostileToFaction(String factionId)
void setFleetSource(MarketAPI... preferred)
void triggerSetRemnantConfigActive()
void triggerSetPirateFleet()
void triggerSetFleetFaction(final String factionId)
static String ucFirst(String str)
static Color getHighlightColor()
void addAll(Collection< T > items)
String getPersonNamePrefixAOrAn()
boolean getCustomBoolean(String key)
String getPersonNamePrefix()
String getNameWithNoType()
String getNameWithLowercaseTypeShort()
MemoryAPI getMemoryWithoutUpdate()
LocationAPI getContainingLocation()
StarSystemAPI getStarSystem()
Vector2f getLocationInHyperspace()
SectorEntityToken getHyperspaceAnchor()
SectorEntityToken getCenter()
SectorEntityToken getPrimaryEntity()
void set(String key, Object value)
boolean isActionFinished()
void setHighlight(int start, int end)
void setHighlightColors(Color ... colors)