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.StarSystemAPI;
11import com.fs.starfarer.api.campaign.comm.CommMessageAPI.MessageClickAction;
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.NPCHassler;
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.Sounds;
20import com.fs.starfarer.api.impl.campaign.intel.BaseIntelPlugin;
21import com.fs.starfarer.api.impl.campaign.intel.MessageIntel;
22import com.fs.starfarer.api.impl.campaign.intel.events.BaseEventIntel.EventStageData;
23import com.fs.starfarer.api.impl.campaign.intel.events.HostileActivityEventIntel.HAERandomEventData;
24import com.fs.starfarer.api.impl.campaign.intel.events.HostileActivityEventIntel.Stage;
25import com.fs.starfarer.api.impl.campaign.intel.inspection.HegemonyInspectionIntel;
26import com.fs.starfarer.api.impl.campaign.intel.inspection.HegemonyInspectionIntel.HegemonyInspectionOutcome;
27import com.fs.starfarer.api.impl.campaign.intel.inspection.HegemonyInspectionIntel.InspectionEndedListener;
28import com.fs.starfarer.api.impl.campaign.missions.FleetCreatorMission;
29import com.fs.starfarer.api.ui.LabelAPI;
30import com.fs.starfarer.api.ui.TooltipMakerAPI;
31import com.fs.starfarer.api.ui.TooltipMakerAPI.TooltipCreator;
32import com.fs.starfarer.api.util.DelayedActionScript;
33import com.fs.starfarer.api.util.Misc;
34import com.fs.starfarer.api.util.WeightedRandomPicker;
88 return super.getProgress(
intel);
102 return Misc.getGrayColor();
104 return Global.
getSector().getFaction(Factions.HEGEMONY).getBaseUIColor();
109 public void createTooltip(TooltipMakerAPI tooltip,
boolean expanded, Object tooltipParam) {
112 tooltip.addPara(
"The Hegemony considers the use of AI cores illegal and will not tolerate it "
113 +
"even outside the volume of the core worlds.", 0f);
114 tooltip.addPara(
"Fleets investigating your AI core use can sometimes be found in your space, not overtly "
115 +
"hostile, but harassing your shipping and generally acting in a high-handed way.", opad);
121 boolean shouldShowDueToCause =
false;
123 shouldShowDueToCause |= cause.shouldShow();
135 public CampaignFleetAPI
createFleet(StarSystemAPI system, Random random) {
152 boolean recon =
false;
157 difficulty = 1 + random.nextInt(2);
160 difficulty += (int) Math.round(f * 5f);
161 difficulty += random.nextInt(4);
165 FleetCreatorMission m =
new FleetCreatorMission(random);
168 Vector2f loc = system.getLocation();
169 String factionId = Factions.HEGEMONY;
172 m.createStandardFleet(difficulty, factionId, loc);
174 m.createStandardFleet(difficulty, factionId, loc);
177 m.triggerSetFleetType(FleetTypes.INVESTIGATORS);
178 m.triggerSetPatrol();
182 m.triggerSetFleetFlag(
"$hegemonyInvestigator");
183 m.triggerFleetAllowLongPursuit();
186 m.triggerMakeLowRepImpact();
188 CampaignFleetAPI fleet = m.createFleet();
190 if (fleet !=
null && !recon) {
191 fleet.addScript(
new NPCHassler(fleet, system));
209 ListInfoMode mode,
boolean isUpdate, Color tc,
float initPad) {
211 if (!(stage.rollData instanceof HAERandomEventData))
return;
212 HAERandomEventData data = (HAERandomEventData) stage.rollData;
213 MarketAPI target = (MarketAPI) data.custom;
216 if (target ==
null)
return;
219 if (from ==
null)
return;
221 Color c =
Global.
getSector().getFaction(Factions.HEGEMONY).getBaseUIColor();
223 LabelAPI label = info.addPara(
"Upcoming Hegemony AI inspection targeting %s",
224 initPad, tc, tc, target.getName());
225 label.setHighlight(
"Hegemony", target.getName());
226 label.setHighlightColors(c, Misc.getBasePlayerColor());
230 ListInfoMode mode,
boolean isUpdate, Color tc,
float initPad) {
231 info.addPara(
"Hegemony AI inspection averted", tc, initPad);
235 if (!(stage.rollData instanceof HAERandomEventData))
return;
236 HAERandomEventData data = (HAERandomEventData) stage.rollData;
237 MarketAPI target = (MarketAPI) data.custom;
240 if (target ==
null)
return;
243 if (from ==
null)
return;
245 Color c =
Global.
getSector().getFaction(Factions.HEGEMONY).getBaseUIColor();
252 LabelAPI label = info.addPara(
"You've received intel that the Hegemony is planning "
253 +
"an AI insprection targeting %s. If the inspection arrives at your colony, "
254 +
"your options would include open hostilities with the Hegemony, or the loss of "
255 +
"at least some of your AI cores.",
256 small, c, target.getName());
257 label.setHighlight(target.getName(),
"open hostilities",
"loss of at least some of your AI cores");
258 label.setHighlightColors(Misc.getBasePlayerColor(), Misc.getNegativeHighlightColor(), Misc.getNegativeHighlightColor());
262 label = info.addPara(
"If this inspection is defeated by military means, the Hegemony is likely to "
263 +
"escalate the conflict, although only up to a point.",
264 opad, Misc.getNegativeHighlightColor(),
"escalate the conflict");
265 label.setHighlight(
"escalate the conflict",
"up to a point");
266 label.setHighlightColors(Misc.getNegativeHighlightColor(), Misc.getPositiveHighlightColor());
268 info.addPara(
"If this massive inspection force - a declaration of war in all but name - is defeated,"
269 +
" the Hegemony is likely to reconsider the viability of their approach.",
270 opad, Misc.getPositiveHighlightColor(),
"reconsider");
274 stage.beginResetReqList(info,
true,
"crisis", opad);
275 info.addPara(
"The %s has no functional military bases", 0f, c,
"Hegemony");
276 stage.endResetReqList(info,
false,
"crisis", -1, -1);
287 if (stage.id == Stage.HA_EVENT) {
295 if (stage.id == Stage.HA_EVENT) {
310 float threshold = alpha + beta + gamma;
311 for (MarketAPI market : Misc.getPlayerMarkets(
false)) {
317 if (w <= threshold)
continue;
318 picker.add(market, w * w);
320 return picker.pick();
325 for (MarketAPI market :
Global.
getSector().getEconomy().getMarketsCopy()) {
326 if (market.getFactionId().equals(Factions.HEGEMONY)) {
327 Industry b = market.getIndustry(Industries.MILITARYBASE);
328 if (b ==
null) b = market.getIndustry(Industries.HIGHCOMMAND);
329 if (b ==
null || b.isDisrupted() || !b.isFunctional()) {
332 picker.add(market, market.getSize());
335 MarketAPI from = picker.pick();
346 if (market ==
null)
return;
349 if (from ==
null)
return;
351 HAERandomEventData data =
new HAERandomEventData(
this, stage);
352 data.custom = market;
353 stage.rollData = data;
363 if (!(stage.rollData instanceof HAERandomEventData))
return false;
364 HAERandomEventData data = (HAERandomEventData) stage.rollData;
365 MarketAPI market = (MarketAPI) data.custom;
367 if (market ==
null)
return false;
368 if (!market.isInEconomy())
return false;
371 if (from ==
null)
return false;
373 StarSystemAPI system = market.getStarSystem();
374 if (system ==
null)
return false;
386 if (from ==
null)
return false;
395 }
else if (defeated == 1) {
402 if (fpOverride !=
null) {
405 HegemonyInspectionIntel inspection =
new HegemonyInspectionIntel(from, target, fp);
406 if (inspection.isDone()) {
411 inspection.setListener(
this);
421 super.advance(amount);
424 if (stage !=
null && stage.rollData instanceof HAERandomEventData &&
425 ((HAERandomEventData)stage.rollData).factor ==
this) {
434 if (
intel ==
null)
return;
445 if (outcome == HegemonyInspectionOutcome.TASK_FORCE_DESTROYED) {
453 public void doAction() {
455 msg.
addLine(
"Major Hegemony defeat!", Misc.getBasePlayerColor());
457 "You may be able to discuss the situation with the High Hegemon on Chicomoztoc");
460 Global.
getSector().getCampaignUI().addMessage(msg, MessageClickAction.NOTHING);
static SettingsAPI getSettings()
static SectorAPI getSector()
void sendUpdateIfPlayerHasIntel(Object listInfoParam, TextPanelAPI textPanel)
static final String BULLET
void setIcon(String icon)
void addLine(String text)
void setSound(String sound)
void addBorder(TooltipMakerAPI info, Color c)
EventStageData getDataFor(Object stageId)
static boolean checkFactionExists(String factionId, boolean requireMilitary)
Random getRandomizedStageRandom()
List< HostileActivityCause2 > getCauses()
TooltipCreator getDefaultEventTooltip(final String title, final HostileActivityEventIntel intel, final EventStageData stage)
HostileActivityEventIntel intel
static float getAICorePoints(StarSystemAPI system)
void rollEvent(HostileActivityEventIntel intel, EventStageData stage)
boolean shouldShow(BaseEventIntel intel)
static String INSPECTION_ATTEMPTS
static float INSPECTION_STRENGTH_FINAL
TooltipCreator getStageTooltipImpl(final HostileActivityEventIntel intel, final EventStageData stage)
void notifyInspectionEnded(HegemonyInspectionOutcome outcome)
void notifyFactorRemoved()
Color getDescColor(BaseEventIntel intel)
MarketAPI pickSourceMarket()
boolean fireEvent(HostileActivityEventIntel intel, EventStageData stage)
static int INSPECTIONS_TO_DEFEAT
TooltipCreator getMainRowTooltip(BaseEventIntel intel)
static void setPlayerDefeatedHegemony()
HegemonyHostileActivityFactor(HostileActivityEventIntel intel)
static float INSPECTION_STRENGTH_SECOND
int getProgress(BaseEventIntel intel)
MarketAPI pickTargetMarket()
void addBulletPointForEventReset(HostileActivityEventIntel intel, EventStageData stage, TooltipMakerAPI info, ListInfoMode mode, boolean isUpdate, Color tc, float initPad)
CampaignFleetAPI createFleet(StarSystemAPI system, Random random)
boolean createInspection(MarketAPI target, Integer fpOverride)
static void incrInspectionAttempts()
static boolean isPlayerDefeatedHegemony()
String getNameForThreatList(boolean first)
void advance(float amount)
float getEventFrequency(HostileActivityEventIntel intel, EventStageData stage)
static String DEFEATED_HEGEMONY
static void avertInspectionIfNotInProgress()
int getMaxNumFleets(StarSystemAPI system)
String getProgressStr(BaseEventIntel intel)
void addBulletPointForEvent(HostileActivityEventIntel intel, EventStageData stage, TooltipMakerAPI info, ListInfoMode mode, boolean isUpdate, Color tc, float initPad)
String getDesc(BaseEventIntel intel)
static final String HASSLE_REASON
void addStageDescriptionForEvent(HostileActivityEventIntel intel, EventStageData stage, TooltipMakerAPI info)
String getEventStageIcon(HostileActivityEventIntel intel, EventStageData stage)
static int getInspectionAttempts()
static int getInspectionsDefeated()
static void incrInspectionsDefeated()
static String INSPECTIONS_DEFEATED
static float INSPECTION_STRENGTH_FIRST
HAERandomEventData getRollDataForEvent()
static HostileActivityEventIntel get()
float getMarketPresenceFactor(StarSystemAPI system)
float getFloat(String key)