1package com.fs.starfarer.api.impl.campaign.intel.group;
5import java.util.Random;
7import org.lwjgl.util.vector.Vector2f;
9import com.fs.starfarer.api.Global;
10import com.fs.starfarer.api.campaign.CampaignFleetAPI;
11import com.fs.starfarer.api.campaign.FactionAPI;
12import com.fs.starfarer.api.campaign.SectorEntityToken;
13import com.fs.starfarer.api.campaign.StarSystemAPI;
14import com.fs.starfarer.api.campaign.econ.MarketAPI;
15import com.fs.starfarer.api.impl.campaign.ids.Factions;
16import com.fs.starfarer.api.impl.campaign.ids.Industries;
17import com.fs.starfarer.api.impl.campaign.intel.group.FGRaidAction.FGRaidParams;
18import com.fs.starfarer.api.impl.campaign.missions.FleetCreatorMission;
19import com.fs.starfarer.api.impl.campaign.missions.hub.BaseHubMission;
20import com.fs.starfarer.api.ui.Alignment;
21import com.fs.starfarer.api.ui.TooltipMakerAPI;
22import com.fs.starfarer.api.util.Misc;
23import com.fs.starfarer.api.util.WeightedRandomPicker;
39 MarketAPI garnir =
Global.
getSector().getEconomy().getMarket(
"corvus_IIIa");
40 MarketAPI jangala =
Global.
getSector().getEconomy().getMarket(
"jangala");
54 gilead.getPrimaryEntity().getStarSystem().getCenter()),
60 FGRaidParams params =
new FGRaidParams();
61 params.where = gilead.getPrimaryEntity().getStarSystem();
62 params.allowedTargets.add(gilead);
63 params.allowedTargets.add(asher);
65 params.setDisrupt(Industries.FARMING, Industries.MEGAPORT);
71 garnir.getPrimaryEntity().getStarSystem().getCenter()),
75 origin = garnir.getPrimaryEntity();
81 MarketAPI garnir =
Global.
getSector().getEconomy().getMarket(
"corvus_IIIa");
82 Vector2f loc = garnir.getLocationInHyperspace();
85 if (
route !=
null &&
route.getExtra() !=
null) {
86 damage =
route.getExtra().damage;
88 if (damage ==
null) damage = 0f;
91 factionId = Factions.LUDDIC_CHURCH;
92 factionId = Factions.PIRATES;
95 WeightedRandomPicker<Integer> picker =
new WeightedRandomPicker<Integer>(
getRandom());
105 for (Integer i : picker.getItems()) total += i;
107 float spawnsToSkip = total * damage * 0.5f;
111 while (!picker.isEmpty()) {
112 Integer size = picker.pickAndRemove();
113 if (skipped < spawnsToSkip &&
getRandom().nextFloat() < damage) {
118 FleetCreatorMission m =
new FleetCreatorMission(
new Random());
121 m.createQualityFleet(size, factionId, loc);
122 m.setFleetSource(garnir);
123 m.setFleetDamageTaken(damage);
126 m.triggerSetPirateFleet();
128 m.triggerMakeNoRepImpact();
130 CampaignFleetAPI fleet = m.createFleet();
131 if (fleet !=
null &&
route !=
null) {
140 Color h = Misc.getHighlightColor();
148 if (mode == ListInfoMode.MESSAGES) {
149 info.addPara(
"Targeting the " + system.getNameWithLowercaseTypeShort(), tc, initPad);
152 if (untilDeparture > 0) {
153 addETABulletPoints(
null,
null,
false, untilDeparture, ETAType.DEPARTURE, info, tc, initPad);
155 if (untilRaid > 0 &&
getSource().getContainingLocation() != system) {
156 addETABulletPoints(system.getNameWithLowercaseTypeShort(),
null,
false, untilRaid, ETAType.ARRIVING,
161 StarSystemAPI from =
getSource().getStarSystem();
163 addETABulletPoints(from.getNameWithLowercaseTypeShort(),
null,
false, untilReturn, ETAType.RETURNING,
167 if (mode == ListInfoMode.INTEL && curr !=
null && curr.
getId().equals(
RAID_ACTION)) {
168 info.addPara(
"Operating in the " + system.getNameWithLowercaseTypeShort(), tc, initPad);
171 if (mode != ListInfoMode.IN_DESC &&
isEnding()) {
173 info.addPara(
"The raiding forces have been defeated and scatter", tc, initPad);
178 protected void addUpdateBulletPoints(TooltipMakerAPI info, Color tc, Object param, ListInfoMode mode,
float initPad) {
182 info.addPara(
"The raiding forces have been defeated and scatter", tc, initPad);
185 addETABulletPoints(system.getNameWithLowercaseTypeShort(),
null,
true, untilRaid, ETAType.ARRIVING,
191 info.addPara(
"The raiding forces are withdrawing", tc, initPad);
193 info.addPara(
"The raiding forces have been defeated and scatter", tc, initPad);
210 return super.shouldSendIntelUpdateWhenActionFinished(action);
214 info.addImage(
getFaction().getLogo(), width, 128, opad);
218 info.addPara(Misc.ucFirst(
faction.getPersonNamePrefixAOrAn()) +
" %s raid against "
219 +
"the " + system.getNameWithLowercaseTypeShort() +
".", opad,
224 Color h = Misc.getHighlightColor();
231 info.addSectionHeading(
"Assessment",
232 faction.getBaseUIColor(),
faction.getDarkUIColor(), Alignment.MID, opad);
233 if (targets.isEmpty()) {
234 info.addPara(
"There are no colonies for the raid to target in the system.", opad);
238 boolean potentialDanger =
addStrengthDesc(info, opad, system,
"raiding forces",
239 "the raid is unlikely to find success",
240 "the raid's outcome is uncertain",
241 "the raid is likely to find success");
243 if (potentialDanger) {
245 "should be safe from the raid",
246 "are at risk of being raided and losing stability:",
254 protected void addStatusSection(TooltipMakerAPI info,
float width,
float height,
float opad) {
260 info.addSectionHeading(
"Status",
261 faction.getBaseUIColor(),
faction.getDarkUIColor(), Alignment.MID, opad);
263 info.addPara(
"The raiding forces have been defeated and any "
264 +
"remaining ships are retreating in disarray.", opad);
266 info.addPara(
"The raid was successful and the raiding forces are withdrawing.", opad);
267 }
else if (curr !=
null) {
271 BaseHubMission.addStandardMarketDesc(
"Making preparations in orbit around",
274 info.addPara(
"Traveling from " +
getSource().getMarket().
getName() +
" to the " +
275 to.getNameWithLowercaseTypeShort() +
".", opad);
277 info.addPara(
"Conducting operations in the " +
278 to.getNameWithLowercaseTypeShort() +
".", opad);
286 return Misc.ucFirst(
getFaction().getPersonNamePrefix()) +
" Raid";
static SectorAPI getSector()
boolean isActionFinished()
float getSuccessFraction()
List< CampaignFleetAPI > fleets
void addArrivedBulletPoint(String destName, Color destHL, TooltipMakerAPI info, Color tc, float initPad)
void createRoute(String factionId, int approximateTotalDifficultyPoints, int approximateNumberOfFleets, Object custom)
FGAction getCurrentAction()
void addETABulletPoints(String destName, Color destHL, boolean withDepartedText, float eta, ETAType type, TooltipMakerAPI info, Color tc, float initPad)
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)
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)
SectorEntityToken getSource()
void addNonUpdateBulletPoints(TooltipMakerAPI info, Color tc, Object param, ListInfoMode mode, float initPad)
void addUpdateBulletPoints(TooltipMakerAPI info, Color tc, Object param, ListInfoMode mode, float initPad)
static String PREPARE_ACTION
static String RETURN_ACTION
void addBasicDescription(TooltipMakerAPI info, float width, float height, float opad)
void addStatusSection(TooltipMakerAPI info, float width, float height, float opad)
static String TRAVEL_ACTION
boolean isPlayerTargeted()
static String RAID_ACTION
boolean shouldSendIntelUpdateWhenActionFinished(FGAction action)
SectorEntityToken getDestination()
void addAssessmentSection(TooltipMakerAPI info, float width, float height, float opad)