1package com.fs.starfarer.api.impl.campaign.intel.events;
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.StarSystemAPI;
12import com.fs.starfarer.api.campaign.comm.IntelInfoPlugin.ListInfoMode;
13import com.fs.starfarer.api.campaign.econ.Industry;
14import com.fs.starfarer.api.campaign.econ.MarketAPI;
15import com.fs.starfarer.api.impl.campaign.ids.Conditions;
16import com.fs.starfarer.api.impl.campaign.ids.Factions;
17import com.fs.starfarer.api.impl.campaign.ids.FleetTypes;
18import com.fs.starfarer.api.impl.campaign.ids.Industries;
19import com.fs.starfarer.api.impl.campaign.ids.Stats;
20import com.fs.starfarer.api.impl.campaign.intel.events.BaseEventIntel.EventStageData;
21import com.fs.starfarer.api.impl.campaign.intel.events.HostileActivityEventIntel.HAERandomEventData;
22import com.fs.starfarer.api.impl.campaign.intel.events.HostileActivityEventIntel.Stage;
23import com.fs.starfarer.api.impl.campaign.intel.events.TriTachyonStandardActivityCause.CompetitorData;
24import com.fs.starfarer.api.impl.campaign.intel.group.FGRaidAction.FGRaidType;
25import com.fs.starfarer.api.impl.campaign.intel.group.FleetGroupIntel;
26import com.fs.starfarer.api.impl.campaign.intel.group.FleetGroupIntel.FGIEventListener;
27import com.fs.starfarer.api.impl.campaign.intel.group.GenericRaidFGI.GenericRaidParams;
28import com.fs.starfarer.api.impl.campaign.intel.group.SindrianDiktatPunitiveExpedition;
29import com.fs.starfarer.api.impl.campaign.missions.FleetCreatorMission;
30import com.fs.starfarer.api.impl.campaign.missions.FleetCreatorMission.FleetStyle;
31import com.fs.starfarer.api.impl.campaign.rulecmd.salvage.MarketCMD.BombardType;
32import com.fs.starfarer.api.ui.LabelAPI;
33import com.fs.starfarer.api.ui.TooltipMakerAPI;
34import com.fs.starfarer.api.ui.TooltipMakerAPI.TooltipCreator;
35import com.fs.starfarer.api.util.CountingMap;
36import com.fs.starfarer.api.util.Misc;
39 implements FGIEventListener {
79 return "Sindrian Diktat";
83 return "Sindrian Diktat";
89 return Misc.getGrayColor();
96 public void createTooltip(TooltipMakerAPI tooltip,
boolean expanded, Object tooltipParam) {
98 tooltip.addPara(
"You've attracted the attention of the Sindrian Diktat.", 0f);
100 tooltip.addPara(
"Sindrian raider fleets have been sighted in your space, "
101 +
"attacking trade fleets regardless of their factional allegiance.", opad);
115 return super.getProgress(
intel);
120 return Misc.getGrayColor();
122 return Global.
getSector().getFaction(Factions.DIKTAT).getBaseUIColor();
131 public CampaignFleetAPI
createFleet(StarSystemAPI system, Random random) {
135 int difficulty = 4 + (int) Math.round(f * 4f);
137 FleetCreatorMission m =
new FleetCreatorMission(random);
140 Vector2f loc = system.getLocation();
141 String factionId = Factions.DIKTAT;
143 m.createQualityFleet(difficulty, factionId, loc);
145 m.triggerSetFleetType(FleetTypes.RAIDER);
147 m.triggerSetPirateFleet();
148 m.triggerMakeHostile();
149 m.triggerMakeNonHostileToFaction(Factions.DIKTAT);
150 m.triggerMakeNonHostileToFaction(Factions.PIRATES);
151 m.triggerMakeLowRepImpact();
152 m.triggerFleetAllowLongPursuit();
153 m.triggerMakeHostileToAllTradeFleets();
154 m.triggerMakeEveryoneJoinBattleAgainst();
158 m.triggerFleetMakeFaster(
true, 0,
true);
163 CampaignFleetAPI fleet = m.createFleet();
172 ListInfoMode mode,
boolean isUpdate, Color tc,
float initPad) {
173 Color c =
Global.
getSector().getFaction(Factions.DIKTAT).getBaseUIColor();
174 info.addPara(
"Impending Sindrian Diktat attack", initPad, tc, c,
"Sindrian Diktat");
178 ListInfoMode mode,
boolean isUpdate, Color tc,
float initPad) {
179 info.addPara(
"Sindrian Diktat attack averted", tc, initPad);
188 Color c =
Global.
getSector().getFaction(Factions.DIKTAT).getBaseUIColor();
190 Color h = Misc.getHighlightColor();
191 info.addPara(
"You've received intel that the Sindrian Diktat is planning an attack to "
192 +
"saturation-bombard your fuel production facilities.",
193 small, Misc.getNegativeHighlightColor(),
"saturation-bombard");
207 LabelAPI label = info.addPara(
"If the attack is defeated the Diktat will likely abandon "
208 +
"further efforts against you, and your ability to export fuel will be improved.",
210 label.setHighlight(
"Diktat",
211 "export fuel",
"improved");
212 label.setHighlightColors(
214 Misc.getPositiveHighlightColor(),
215 Misc.getPositiveHighlightColor());
218 stage.beginResetReqList(info,
true,
"crisis", opad);
219 info.addPara(
"You go to %s and make an agreement with the Diktat", 0f, c,
"Sindria");
220 info.addPara(
"%s is tactically bombarded", 0f, c,
"Sindria");
221 info.addPara(
"Fuel production on %s is significantly disrupted", 0f, c,
"Sindria");
222 stage.endResetReqList(info,
false,
"crisis", -1, -1);
233 if (stage.id == Stage.HA_EVENT) {
241 if (sindria ==
null)
return null;
243 Industry prod = sindria.getIndustry(Industries.FUELPROD);
247 public static MarketAPI
getSindria(
boolean requireMilitaryBase) {
248 MarketAPI sindria =
Global.
getSector().getEconomy().getMarket(
"sindria");
249 if (sindria ==
null || sindria.hasCondition(Conditions.DECIVILIZED)) {
252 if (requireMilitaryBase) {
253 Industry b = sindria.getIndustry(Industries.MILITARYBASE);
254 if (b ==
null) b = sindria.getIndustry(Industries.HIGHCOMMAND);
255 if (b ==
null || b.isDisrupted() || !b.isFunctional()) {
264 if (stage.id == Stage.HA_EVENT) {
272 if (SindrianDiktatPunitiveExpedition.get() !=
null) {
278 if (target !=
null && source !=
null) {
287 HAERandomEventData data =
new HAERandomEventData(
this, stage);
288 stage.rollData = data;
296 if (source ==
null || target ==
null) {
300 stage.rollData =
null;
307 CountingMap<MarketAPI> counts =
new CountingMap<MarketAPI>();
309 for (CompetitorData curr : data) {
310 for (MarketAPI market : curr.competitorProducers) {
311 StarSystemAPI system = market.getStarSystem();
312 if (system ==
null)
continue;
313 int weight = market.getCommodityData(curr.commodityId).getMaxSupply();
314 counts.add(market, weight);
318 return counts.getLargest();
341 super.advance(amount);
358 if (stage !=
null && stage.rollData instanceof HAERandomEventData &&
359 ((HAERandomEventData)stage.rollData).factor ==
this) {
362 boolean prodOk = prod !=
null && prod.getSpecialItem() !=
null && !prod.isDisrupted();
372 public boolean startAttack(MarketAPI source, MarketAPI target, StarSystemAPI system, EventStageData stage, Random random) {
373 GenericRaidParams params =
new GenericRaidParams(
new Random(random.nextLong()),
true);
375 params.makeFleetsHostile =
false;
377 params.factionId = source.getFactionId();
378 params.source = source;
380 params.prepDays = 14f + random.nextFloat() * 14f;
381 params.payloadDays = 27f + 7f * random.nextFloat();
383 params.raidParams.where = system;
384 params.raidParams.type = FGRaidType.SEQUENTIAL;
385 params.raidParams.tryToCaptureObjectives =
false;
386 params.raidParams.allowedTargets.add(target);
387 params.raidParams.allowNonHostileTargets =
true;
388 params.raidParams.setBombardment(BombardType.SATURATION);
390 params.style = FleetStyle.STANDARD;
394 float fleetSizeMult = source.getStats().getDynamic().getMod(Stats.COMBAT_FLEET_SIZE_MULT).computeEffective(0f);
398 float totalDifficulty = fleetSizeMult * 15f * (0.6f + 0.4f * f);
400 if (totalDifficulty < 15) {
403 if (totalDifficulty > 100) {
404 totalDifficulty = 100;
407 totalDifficulty -= 10;
409 params.fleetSizes.add(10);
411 while (totalDifficulty > 0) {
416 int diff = min + random.nextInt(max - min + 1);
418 params.fleetSizes.add(diff);
419 totalDifficulty -= diff;
423 SindrianDiktatPunitiveExpedition punex =
new SindrianDiktatPunitiveExpedition(params);
424 punex.setListener(
this);
static SettingsAPI getSettings()
static SectorAPI getSector()
void sendUpdateIfPlayerHasIntel(Object listInfoParam, TextPanelAPI textPanel)
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
float getMarketPresenceFactor(StarSystemAPI system)
void addBulletPointForEventReset(HostileActivityEventIntel intel, EventStageData stage, TooltipMakerAPI info, ListInfoMode mode, boolean isUpdate, Color tc, float initPad)
Color getDescColor(BaseEventIntel intel)
String getEventStageIcon(HostileActivityEventIntel intel, EventStageData stage)
CampaignFleetAPI createFleet(StarSystemAPI system, Random random)
static void setMadeDeal(boolean value)
static String RAIDER_FLEET
static boolean isMadeDeal()
String getDesc(BaseEventIntel intel)
static boolean brokeDeal()
void advance(float amount)
static String MADE_DIKTAT_DEAL
void notifyFactorRemoved()
static MarketAPI findExpeditionTarget(HostileActivityEventIntel intel, EventStageData stage)
String getNameForThreatList(boolean first)
void addBulletPointForEvent(HostileActivityEventIntel intel, EventStageData stage, TooltipMakerAPI info, ListInfoMode mode, boolean isUpdate, Color tc, float initPad)
void reportFGIAborted(FleetGroupIntel intel)
boolean shouldShow(BaseEventIntel intel)
static boolean isPlayerDefeatedDiktatAttack()
static void setBrokeDeal(boolean broke)
int getMaxNumFleets(StarSystemAPI system)
static MarketAPI getSindria(boolean requireMilitaryBase)
float getEventFrequency(HostileActivityEventIntel intel, EventStageData stage)
boolean fireEvent(HostileActivityEventIntel intel, EventStageData stage)
static void setPlayerDefeatedDiktatAttack()
int getProgress(BaseEventIntel intel)
boolean startAttack(MarketAPI source, MarketAPI target, StarSystemAPI system, EventStageData stage, Random random)
String getProgressStr(BaseEventIntel intel)
SindrianDiktatHostileActivityFactor(HostileActivityEventIntel intel)
TooltipCreator getMainRowTooltip(BaseEventIntel intel)
void rollEvent(HostileActivityEventIntel intel, EventStageData stage)
static String DEFEATED_DIKTAT_ATTACK
TooltipCreator getStageTooltipImpl(final HostileActivityEventIntel intel, final EventStageData stage)
static Industry getSindrianFuelProd()
Color getNameColor(float mag)
void addStageDescriptionForEvent(HostileActivityEventIntel intel, EventStageData stage, TooltipMakerAPI info)
static String BROKE_DIKTAT_DEAL
static List< CompetitorData > computePlayerCompetitionData()