1package com.fs.starfarer.api.impl.campaign.intel.events;
4import java.util.Random;
6import com.fs.starfarer.api.Global;
7import com.fs.starfarer.api.campaign.CampaignFleetAPI;
8import com.fs.starfarer.api.campaign.StarSystemAPI;
9import com.fs.starfarer.api.campaign.comm.IntelInfoPlugin.ListInfoMode;
10import com.fs.starfarer.api.campaign.econ.MarketAPI;
11import com.fs.starfarer.api.impl.campaign.ids.Factions;
12import com.fs.starfarer.api.impl.campaign.ids.Stats;
13import com.fs.starfarer.api.impl.campaign.intel.events.BaseEventIntel.EventStageData;
14import com.fs.starfarer.api.impl.campaign.intel.events.HostileActivityEventIntel.HAERandomEventData;
15import com.fs.starfarer.api.impl.campaign.intel.events.HostileActivityEventIntel.Stage;
16import com.fs.starfarer.api.impl.campaign.intel.group.FGRaidAction.FGRaidType;
17import com.fs.starfarer.api.impl.campaign.intel.group.FleetGroupIntel;
18import com.fs.starfarer.api.impl.campaign.intel.group.FleetGroupIntel.FGIEventListener;
19import com.fs.starfarer.api.impl.campaign.intel.group.GenericRaidFGI;
20import com.fs.starfarer.api.impl.campaign.intel.group.GenericRaidFGI.GenericRaidParams;
21import com.fs.starfarer.api.impl.campaign.missions.FleetCreatorMission.FleetStyle;
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.LabelAPI;
25import com.fs.starfarer.api.ui.TooltipMakerAPI;
26import com.fs.starfarer.api.ui.TooltipMakerAPI.TooltipCreator;
27import com.fs.starfarer.api.util.Misc;
28import com.fs.starfarer.api.util.WeightedRandomPicker;
31 implements FGIEventListener {
61 public void createTooltip(
TooltipMakerAPI tooltip,
boolean expanded, Object tooltipParam) {
63 tooltip.
addPara(
"Remnant fleets have been sighted in your space.", opad);
74 return super.getProgress(
intel);
132 ListInfoMode mode,
boolean isUpdate, Color tc,
float initPad) {
134 info.
addPara(
"Impending Remnant attack", initPad, tc, c,
"Remnant");
138 ListInfoMode mode,
boolean isUpdate, Color tc,
float initPad) {
139 info.
addPara(
"Remnant attack averted", tc, initPad);
150 if (!(stage.rollData instanceof HAERandomEventData))
return;
151 HAERandomEventData data = (HAERandomEventData) stage.rollData;
152 if (!(data.custom instanceof
MarketAPI))
return;
157 info.
addPara(
"There are signs of activity at a Remnant Nexus in your system. Intel evaluates "
158 +
"a high probability of an attack fleet being assembled to saturation-bombard " +
162 LabelAPI label = info.
addPara(
"Defeating the attack fleet would only put off the problem, "
163 +
"but destroying the Remnant Nexus will end the threat for good.",
171 stage.beginResetReqList(info,
true,
"crisis", opad);
172 info.
addPara(
"The %s is destroyed", 0f, c,
"Remnant Nexus");
173 stage.endResetReqList(info,
false,
"crisis", -1, -1);
184 if (stage.id == Stage.HA_EVENT) {
191 if (system ==
null)
return null;
196 if (!fleet.isStationMode())
continue;
206 if (stage.id == Stage.HA_EVENT) {
209 if (target ==
null || target.
getStarSystem() ==
null)
return 0f;
212 if (nexus ==
null)
return 0f;
222 if (target ==
null)
return;
224 HAERandomEventData data =
new HAERandomEventData(
this, stage);
225 data.custom = target;
226 stage.rollData = data;
232 if (target ==
null || target.
getStarSystem() ==
null)
return false;
235 if (nexus ==
null)
return false;
237 stage.rollData =
null;
249 picker.
add(curr, curr.getSize() * curr.getSize() * curr.getSize());
253 return picker.
pick();
269 super.advance(amount);
272 if (stage !=
null && stage.rollData instanceof HAERandomEventData &&
273 ((HAERandomEventData)stage.rollData).factor ==
this) {
275 HAERandomEventData data = (HAERandomEventData) stage.rollData;
291 GenericRaidParams params =
new GenericRaidParams(
new Random(random.nextLong()),
true);
293 params.makeFleetsHostile =
true;
294 params.remnant =
true;
302 "nexus_" + nexus.
getId(), 1f);
306 params.source = fake;
308 params.prepDays = 0f;
309 params.payloadDays = 27f + 7f * random.nextFloat();
311 params.raidParams.where = system;
312 params.raidParams.type = FGRaidType.SEQUENTIAL;
313 params.raidParams.tryToCaptureObjectives =
false;
314 params.raidParams.allowedTargets.add(target);
315 params.raidParams.allowNonHostileTargets =
true;
316 params.raidParams.setBombardment(BombardType.SATURATION);
317 params.forcesNoun =
"remnant forces";
319 params.style = FleetStyle.STANDARD;
320 params.repImpact = ComplicationRepImpact.FULL;
324 float fleetSizeMult = 1f;
327 fleetSizeMult = 0.5f;
330 float totalDifficulty = fleetSizeMult * 50f;
332 totalDifficulty -= 10;
333 params.fleetSizes.add(10);
335 while (totalDifficulty > 0) {
339 int diff = min + random.nextInt(max - min + 1);
341 params.fleetSizes.add(diff);
342 totalDifficulty -= diff;
static FactoryAPI getFactory()
static SectorAPI getSector()
void modifyFlat(String source, float value)
static final String REMNANTS
static final String PLAYER
static final String FLEET_QUALITY_MOD
void sendUpdateIfPlayerHasIntel(Object listInfoParam, TextPanelAPI textPanel)
void addBorder(TooltipMakerAPI info, Color c)
EventStageData getDataFor(Object stageId)
Random getRandomizedStageRandom()
TooltipCreator getDefaultEventTooltip(final String title, final HostileActivityEventIntel intel, final EventStageData stage)
HostileActivityEventIntel intel
int getProgress(BaseEventIntel intel)
void rollEvent(HostileActivityEventIntel intel, EventStageData stage)
static CampaignFleetAPI getRemnantNexus(StarSystemAPI system)
boolean shouldShow(BaseEventIntel intel)
void notifyFactorRemoved()
boolean startAttack(CampaignFleetAPI nexus, MarketAPI target, StarSystemAPI system, EventStageData stage, Random random)
String getNameForThreatList(boolean first)
void addBulletPointForEventReset(HostileActivityEventIntel intel, EventStageData stage, TooltipMakerAPI info, ListInfoMode mode, boolean isUpdate, Color tc, float initPad)
TooltipCreator getMainRowTooltip(BaseEventIntel intel)
int getMaxNumFleets(StarSystemAPI system)
Color getNameColor(float mag)
float getEventFrequency(HostileActivityEventIntel intel, EventStageData stage)
String getDesc(BaseEventIntel intel)
boolean fireEvent(HostileActivityEventIntel intel, EventStageData stage)
MarketAPI findAttackTarget(HostileActivityEventIntel intel, EventStageData stage)
CampaignFleetAPI createFleet(StarSystemAPI system, Random random)
TooltipCreator getStageTooltipImpl(final HostileActivityEventIntel intel, final EventStageData stage)
Color getDescColor(BaseEventIntel intel)
void addStageDescriptionForEvent(HostileActivityEventIntel intel, EventStageData stage, TooltipMakerAPI info)
void addBulletPointForEvent(HostileActivityEventIntel intel, EventStageData stage, TooltipMakerAPI info, ListInfoMode mode, boolean isUpdate, Color tc, float initPad)
String getProgressStr(BaseEventIntel intel)
RemnantHostileActivityFactor(HostileActivityEventIntel intel)
void reportFGIAborted(FleetGroupIntel intel)
void advance(float amount)
String getEventStageIcon(HostileActivityEventIntel intel, EventStageData stage)
void setListener(FGIEventListener listener)
static List< MarketAPI > getMarketsInLocation(LocationAPI location, String factionId)
static Color getNegativeHighlightColor()
static List< StarSystemAPI > getPlayerSystems(boolean includeNonPlayerFaction)
static Color getGrayColor()
static Color getHighlightColor()
static Color getPositiveHighlightColor()
MarketAPI createMarket(String id, String name, int size)
List< CampaignFleetAPI > getFleets()
IntelManagerAPI getIntelManager()
FactionAPI getFaction(String factionId)
MemoryAPI getMemoryWithoutUpdate()
void addIntel(IntelInfoPlugin plugin)
void setFactionId(String factionId)
void setPrimaryEntity(SectorEntityToken primaryEntity)
MutableMarketStatsAPI getStats()
StarSystemAPI getStarSystem()
boolean getBoolean(String key)
DynamicStatsAPI getDynamic()
void setHighlight(int start, int end)
void setHighlightColors(Color ... colors)
StatBonus getMod(String id)