1package com.fs.starfarer.api.impl.campaign.intel.events;
4import java.util.Random;
6import org.lwjgl.util.vector.Vector2f;
8import com.fs.starfarer.api.Global;
9import com.fs.starfarer.api.campaign.CampaignFleetAPI;
10import com.fs.starfarer.api.campaign.CargoAPI;
11import com.fs.starfarer.api.campaign.FactionAPI;
12import com.fs.starfarer.api.campaign.InteractionDialogAPI;
13import com.fs.starfarer.api.campaign.StarSystemAPI;
14import com.fs.starfarer.api.campaign.comm.IntelInfoPlugin.ListInfoMode;
15import com.fs.starfarer.api.campaign.econ.Industry;
16import com.fs.starfarer.api.campaign.econ.MarketAPI;
17import com.fs.starfarer.api.campaign.listeners.ColonyPlayerHostileActListener;
18import com.fs.starfarer.api.impl.campaign.NPCHassler;
19import com.fs.starfarer.api.impl.campaign.ids.Conditions;
20import com.fs.starfarer.api.impl.campaign.ids.Factions;
21import com.fs.starfarer.api.impl.campaign.ids.FleetTypes;
22import com.fs.starfarer.api.impl.campaign.ids.Industries;
23import com.fs.starfarer.api.impl.campaign.ids.MemFlags;
24import com.fs.starfarer.api.impl.campaign.ids.Stats;
25import com.fs.starfarer.api.impl.campaign.intel.PerseanLeagueMembership;
26import com.fs.starfarer.api.impl.campaign.intel.events.BaseEventIntel.EventStageData;
27import com.fs.starfarer.api.impl.campaign.intel.events.HostileActivityEventIntel.HAERandomEventData;
28import com.fs.starfarer.api.impl.campaign.intel.events.HostileActivityEventIntel.Stage;
29import com.fs.starfarer.api.impl.campaign.intel.group.FGBlockadeAction.FGBlockadeParams;
30import com.fs.starfarer.api.impl.campaign.intel.group.FleetGroupIntel;
31import com.fs.starfarer.api.impl.campaign.intel.group.FleetGroupIntel.FGIEventListener;
32import com.fs.starfarer.api.impl.campaign.intel.group.GenericRaidFGI.GenericRaidParams;
33import com.fs.starfarer.api.impl.campaign.intel.group.PerseanLeagueBlockade;
34import com.fs.starfarer.api.impl.campaign.intel.group.PerseanLeaguePunitiveExpedition;
35import com.fs.starfarer.api.impl.campaign.missions.FleetCreatorMission;
36import com.fs.starfarer.api.impl.campaign.missions.FleetCreatorMission.FleetStyle;
37import com.fs.starfarer.api.impl.campaign.procgen.StarSystemGenerator;
38import com.fs.starfarer.api.impl.campaign.rulecmd.salvage.MarketCMD.TempData;
39import com.fs.starfarer.api.ui.LabelAPI;
40import com.fs.starfarer.api.ui.TooltipMakerAPI;
41import com.fs.starfarer.api.ui.TooltipMakerAPI.TooltipCreator;
42import com.fs.starfarer.api.util.Misc;
45 FGIEventListener, ColonyPlayerHostileActListener {
68 return super.getProgress(
intel);
72 return "Persean League";
76 return "Persean League";
82 return Misc.getGrayColor();
84 return Global.
getSector().getFaction(Factions.PERSEAN).getBaseUIColor();
89 public void createTooltip(TooltipMakerAPI tooltip,
boolean expanded, Object tooltipParam) {
91 tooltip.addPara(
"A large independent polity is a tantalizing prize for the Persean League, and "
92 +
"they will go quite far in exerting pressure for you to join them. League "
93 +
"\"enforcer\" fleets prowl your systems, ostensibly to protect the League's "
94 +
"interests in \"unclaimed territory\".", 0f);
113 return Misc.getGrayColor();
115 return Global.
getSector().getFaction(Factions.PERSEAN).getBaseUIColor();
130 public CampaignFleetAPI
createFleet(StarSystemAPI system, Random random) {
135 int difficulty = 0 + (int) Math.max(1f, Math.round(f * 4f));
136 difficulty += random.nextInt(6);
138 FleetCreatorMission m =
new FleetCreatorMission(random);
141 Vector2f loc = system.getLocation();
142 String factionId = Factions.PERSEAN;
144 m.createStandardFleet(difficulty, factionId, loc);
145 m.triggerSetFleetType(FleetTypes.LEAGUE_ENFORCER);
146 m.triggerSetPatrol();
148 m.triggerSetFleetFlag(
"$leagueEnforcer");
150 m.triggerFleetAllowLongPursuit();
151 m.triggerMakeLowRepImpact();
156 CampaignFleetAPI fleet = m.createFleet();
159 fleet.addScript(
new NPCHassler(fleet, system));
169 ListInfoMode mode,
boolean isUpdate, Color tc,
float initPad) {
171 Color c =
Global.
getSector().getFaction(Factions.PERSEAN).getBaseUIColor();
172 info.addPara(
"Impending Persean League blockade", initPad, tc, c,
"Persean League");
176 ListInfoMode mode,
boolean isUpdate, Color tc,
float initPad) {
177 info.addPara(
"Persean League blockade averted", tc, initPad);
186 info.addPara(
"You've received intel that the Persean League is planning a lengthy blockade of one of your systems. "
187 +
"Colonies in that system will suffer a major accessibility penalty for as long as the blockade lasts.",
188 small, Misc.getNegativeHighlightColor(),
"major accessibility penalty");
190 LabelAPI label = info.addPara(
"If the blockading force is defeated, your standing with the Hegemony "
191 +
"and the independents will increase substantially, and the Persean League will likely abandon "
192 +
"further efforts to strong-arm you and be more open to negotiation.",
194 label.setHighlight(
"Hegemony",
"independents",
"increase substantially",
"Persean League");
195 label.setHighlightColors(
Global.
getSector().getFaction(Factions.HEGEMONY).getBaseUIColor(),
197 Misc.getPositiveHighlightColor(),
200 Color c =
Global.
getSector().getFaction(Factions.PERSEAN).getBaseUIColor();
201 stage.beginResetReqList(info,
true,
"crisis", opad);
202 info.addPara(
"You go to %s and make an agreement about joining the League", 0f, c,
"Kazeron");
203 info.addPara(
"%s is tactically bombarded", 0f, c,
"Kazeron");
205 stage.endResetReqList(info,
false,
"crisis", -1, -1);
216 if (stage.id == Stage.HA_EVENT) {
224 if (stage.id == Stage.HA_EVENT) {
229 if (PerseanLeagueBlockade.get() !=
null) {
232 if (PerseanLeaguePunitiveExpedition.get() !=
null) {
238 if (target !=
null && source !=
null) {
247 HAERandomEventData data =
new HAERandomEventData(
this, stage);
248 stage.rollData = data;
255 if (source ==
null || target ==
null) {
259 stage.rollData =
null;
266 StarSystemAPI best =
null;
267 for (StarSystemAPI system : Misc.getPlayerSystems(
false)) {
281 public static MarketAPI
getKazeron(
boolean requireMilitaryBase) {
282 MarketAPI kazeron =
Global.
getSector().getEconomy().getMarket(
"kazeron");
283 if (kazeron ==
null || kazeron.hasCondition(Conditions.DECIVILIZED)) {
286 if (requireMilitaryBase) {
287 Industry b = kazeron.getIndustry(Industries.MILITARYBASE);
288 if (b ==
null) b = kazeron.getIndustry(Industries.HIGHCOMMAND);
289 if (b ==
null || b.isDisrupted() || !b.isFunctional()) {
298 if (faction !=
null) {
299 return faction.getMemoryWithoutUpdate().getInt(MemFlags.FACTION_SATURATION_BOMBARED_BY_PLAYER) > 0;
305 public boolean startBlockade(MarketAPI source, StarSystemAPI target, EventStageData stage, Random random) {
306 GenericRaidParams params =
new GenericRaidParams(
new Random(random.nextLong()),
true);
307 params.factionId = source.getFactionId();
308 params.source = source;
310 params.prepDays = 7f + random.nextFloat() * 14f;
311 params.payloadDays = 365f;
313 params.makeFleetsHostile =
false;
315 FGBlockadeParams bParams =
new FGBlockadeParams();
316 bParams.where = target;
317 bParams.targetFaction = Factions.PLAYER;
320 params.style = FleetStyle.STANDARD;
324 float fleetSizeMult = source.getStats().getDynamic().getMod(Stats.COMBAT_FLEET_SIZE_MULT).computeEffective(0f);
328 float totalDifficulty = fleetSizeMult * 50f * (0.5f + 0.5f * f);
329 if (totalDifficulty < 30) {
332 if (totalDifficulty > 100) {
333 totalDifficulty = 100;
337 totalDifficulty -= 10;
338 totalDifficulty -= 5;
339 totalDifficulty -= 4;
340 totalDifficulty -= 1;
341 totalDifficulty -= 1;
342 params.fleetSizes.add(10);
343 params.fleetSizes.add(5);
344 params.fleetSizes.add(4);
345 params.fleetSizes.add(1);
346 params.fleetSizes.add(1);
351 while (totalDifficulty > 0) {
355 if (r.nextFloat() > 0.3f) {
356 min = (int) Math.min(totalDifficulty, 10f);
357 max = (int) Math.min(totalDifficulty, 10f);
360 int diff = Math.round(StarSystemGenerator.getNormalRandom(r, min, max));
363 params.fleetSizes.add(diff);
364 totalDifficulty -= diff;
367 PerseanLeagueBlockade blockade =
new PerseanLeagueBlockade(params, bParams);
368 blockade.setListener(
this);
394 TempData actionData, CargoAPI cargo) {
404 if (market !=
null && market == kazeron) {
407 boolean thisEvent = stage.rollData instanceof HAERandomEventData &&
408 ((HAERandomEventData)stage.rollData).factor ==
this;
432 super.advance(amount);
439 if (stage !=
null && stage.rollData instanceof HAERandomEventData &&
440 ((HAERandomEventData)stage.rollData).factor ==
this) {
static SettingsAPI getSettings()
static SectorAPI getSector()
void sendUpdateIfPlayerHasIntel(Object listInfoParam, TextPanelAPI textPanel)
static void setDefeatedBlockade(boolean value)
void addBorder(TooltipMakerAPI info, Color c)
EventStageData getDataFor(Object stageId)
static boolean checkFactionExists(String factionId, boolean requireMilitary)
Random getRandomizedStageRandom()
TooltipCreator getDefaultEventTooltip(final String title, final HostileActivityEventIntel intel, final EventStageData stage)
HostileActivityEventIntel intel
void addFactor(EventFactor factor)
float getMarketPresenceFactor(StarSystemAPI system)
boolean fireEvent(HostileActivityEventIntel intel, EventStageData stage)
void reportSaturationBombardmentFinished(InteractionDialogAPI dialog, MarketAPI market, TempData actionData)
void reportFGIAborted(FleetGroupIntel intel)
void reportTacticalBombardmentFinished(InteractionDialogAPI dialog, MarketAPI market, TempData actionData)
TooltipCreator getMainRowTooltip(BaseEventIntel intel)
static float INDEPENDENT_REP_FOR_DEFEATING
CampaignFleetAPI createFleet(StarSystemAPI system, Random random)
MarketAPI getBlockadeSource(HostileActivityEventIntel intel, EventStageData stage, final StarSystemAPI target)
void reportRaidForValuablesFinishedBeforeCargoShown(InteractionDialogAPI dialog, MarketAPI market, TempData actionData, CargoAPI cargo)
void addStageDescriptionForEvent(HostileActivityEventIntel intel, EventStageData stage, TooltipMakerAPI info)
static boolean wasPLEverSatBombardedByPlayer()
int getMaxNumFleets(StarSystemAPI system)
void advance(float amount)
TooltipCreator getStageTooltipImpl(final HostileActivityEventIntel intel, final EventStageData stage)
int getProgress(BaseEventIntel intel)
String getDesc(BaseEventIntel intel)
String getEventStageIcon(HostileActivityEventIntel intel, EventStageData stage)
String getNameForThreatList(boolean first)
Color getDescColor(BaseEventIntel intel)
static StarSystemAPI findBlockadeTarget(HostileActivityEventIntel intel, EventStageData stage)
void addBulletPointForEvent(HostileActivityEventIntel intel, EventStageData stage, TooltipMakerAPI info, ListInfoMode mode, boolean isUpdate, Color tc, float initPad)
float getSpawnInHyperProbability(StarSystemAPI system)
String getProgressStr(BaseEventIntel intel)
static MarketAPI getKazeron(boolean requireMilitaryBase)
float getEventFrequency(HostileActivityEventIntel intel, EventStageData stage)
void rollEvent(HostileActivityEventIntel intel, EventStageData stage)
static float HEGEMONY_REP_FOR_DEFEATING
void reportRaidToDisruptFinished(InteractionDialogAPI dialog, MarketAPI market, TempData actionData, Industry industry)
boolean startBlockade(MarketAPI source, StarSystemAPI target, EventStageData stage, Random random)
Color getNameColor(float mag)
boolean shouldShow(BaseEventIntel intel)
static final String HASSLE_REASON
void notifyFactorRemoved()
PerseanLeagueHostileActivityFactor(HostileActivityEventIntel intel)
void addBulletPointForEventReset(HostileActivityEventIntel intel, EventStageData stage, TooltipMakerAPI info, ListInfoMode mode, boolean isUpdate, Color tc, float initPad)