1package com.fs.starfarer.api.impl.campaign.intel.events;
3import 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.CommMessageAPI.MessageClickAction;
13import com.fs.starfarer.api.campaign.comm.IntelInfoPlugin.ListInfoMode;
14import com.fs.starfarer.api.campaign.econ.Industry;
15import com.fs.starfarer.api.campaign.econ.MarketAPI;
16import com.fs.starfarer.api.impl.campaign.NPCHassler;
17import com.fs.starfarer.api.impl.campaign.ids.Factions;
18import com.fs.starfarer.api.impl.campaign.ids.FleetTypes;
19import com.fs.starfarer.api.impl.campaign.ids.Industries;
20import com.fs.starfarer.api.impl.campaign.ids.Sounds;
21import com.fs.starfarer.api.impl.campaign.intel.BaseIntelPlugin;
22import com.fs.starfarer.api.impl.campaign.intel.MessageIntel;
23import com.fs.starfarer.api.impl.campaign.intel.events.BaseEventIntel.EventStageData;
24import com.fs.starfarer.api.impl.campaign.intel.events.HostileActivityEventIntel.HAERandomEventData;
25import com.fs.starfarer.api.impl.campaign.intel.events.HostileActivityEventIntel.Stage;
26import com.fs.starfarer.api.impl.campaign.intel.inspection.HegemonyInspectionIntel;
27import com.fs.starfarer.api.impl.campaign.intel.inspection.HegemonyInspectionIntel.HegemonyInspectionOutcome;
28import com.fs.starfarer.api.impl.campaign.intel.inspection.HegemonyInspectionIntel.InspectionEndedListener;
29import com.fs.starfarer.api.impl.campaign.missions.FleetCreatorMission;
30import com.fs.starfarer.api.ui.LabelAPI;
31import com.fs.starfarer.api.ui.TooltipMakerAPI;
32import com.fs.starfarer.api.ui.TooltipMakerAPI.TooltipCreator;
33import com.fs.starfarer.api.util.DelayedActionScript;
34import com.fs.starfarer.api.util.Misc;
35import com.fs.starfarer.api.util.WeightedRandomPicker;
89 return super.getProgress(
intel);
96 return super.getEffectMagnitude(system);
117 public void createTooltip(
TooltipMakerAPI tooltip,
boolean expanded, Object tooltipParam) {
120 tooltip.
addPara(
"The Hegemony considers the use of AI cores illegal and will not tolerate it "
121 +
"even outside the volume of the core worlds.", 0f);
122 tooltip.
addPara(
"Fleets investigating your AI core use can sometimes be found in your space, not overtly "
123 +
"hostile, but harassing your shipping and generally acting in a high-handed way.", opad);
129 boolean shouldShowDueToCause =
false;
131 shouldShowDueToCause |= cause.shouldShow();
160 boolean recon =
false;
165 difficulty = 1 + random.nextInt(2);
168 difficulty += (int) Math.round(f * 5f);
169 difficulty += random.nextInt(4);
198 if (fleet !=
null && !recon) {
217 ListInfoMode mode,
boolean isUpdate, Color tc,
float initPad) {
219 if (!(stage.rollData instanceof HAERandomEventData))
return;
220 HAERandomEventData data = (HAERandomEventData) stage.rollData;
224 if (target ==
null)
return;
227 if (from ==
null)
return;
231 LabelAPI label = info.
addPara(
"Upcoming Hegemony AI inspection targeting %s",
232 initPad, tc, tc, target.
getName());
238 ListInfoMode mode,
boolean isUpdate, Color tc,
float initPad) {
239 info.
addPara(
"Hegemony AI inspection averted", tc, initPad);
243 if (!(stage.rollData instanceof HAERandomEventData))
return;
244 HAERandomEventData data = (HAERandomEventData) stage.rollData;
248 if (target ==
null)
return;
251 if (from ==
null)
return;
260 LabelAPI label = info.
addPara(
"You've received intel that the Hegemony is planning "
261 +
"an AI insprection targeting %s. If the inspection arrives at your colony, "
262 +
"your options would include open hostilities with the Hegemony, or the loss of "
263 +
"at least some of your AI cores.",
265 label.
setHighlight(target.
getName(),
"open hostilities",
"loss of at least some of your AI cores");
270 label = info.
addPara(
"If this inspection is defeated by military means, the Hegemony is likely to "
271 +
"escalate the conflict, although only up to a point.",
273 label.
setHighlight(
"escalate the conflict",
"up to a point");
276 info.
addPara(
"If this massive inspection force - a declaration of war in all but name - is defeated,"
277 +
" the Hegemony is likely to reconsider the viability of their approach.",
282 stage.beginResetReqList(info,
true,
"crisis", opad);
283 info.
addPara(
"The %s has no functional military bases", 0f, c,
"Hegemony");
284 stage.endResetReqList(info,
false,
"crisis", -1, -1);
295 if (stage.id == Stage.HA_EVENT) {
303 if (stage.id == Stage.HA_EVENT) {
318 float threshold = alpha + beta + gamma;
325 if (w <= threshold)
continue;
326 picker.
add(market, w * w);
328 return picker.
pick();
340 picker.
add(market, market.getSize());
354 if (market ==
null)
return;
357 if (from ==
null)
return;
359 HAERandomEventData data =
new HAERandomEventData(
this, stage);
360 data.custom = market;
361 stage.rollData = data;
371 if (!(stage.rollData instanceof HAERandomEventData))
return false;
372 HAERandomEventData data = (HAERandomEventData) stage.rollData;
375 if (market ==
null)
return false;
379 if (from ==
null)
return false;
382 if (system ==
null)
return false;
394 if (from ==
null)
return false;
403 }
else if (defeated == 1) {
410 if (fpOverride !=
null) {
414 if (inspection.
isDone()) {
429 super.advance(amount);
432 if (stage !=
null && stage.rollData instanceof HAERandomEventData &&
433 ((HAERandomEventData)stage.rollData).factor ==
this) {
442 if (
intel ==
null)
return;
453 if (outcome == HegemonyInspectionOutcome.TASK_FORCE_DESTROYED) {
461 public void doAction() {
465 "You may be able to discuss the situation with the High Hegemon on Chicomoztoc");
static SettingsAPI getSettings()
static SectorAPI getSector()
static final String HEGEMONY
static final String INVESTIGATORS
static final String HIGHCOMMAND
static final String MILITARYBASE
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
float getEffectMagnitude(StarSystemAPI system)
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)
void setListener(InspectionEndedListener listener)
CampaignFleetAPI createFleet()
void createStandardFleet(int difficulty, String factionId, Vector2f locInHyper)
void triggerFleetAllowLongPursuit()
void triggerMakeLowRepImpact()
void triggerSetFleetType(String fleetType)
void triggerSetFleetFlag(String flag)
void triggerSetFleetHasslePlayer(String hassleType)
static Color getNegativeHighlightColor()
static Color getBasePlayerColor()
static Color getGrayColor()
static List< MarketAPI > getPlayerMarkets(boolean includeNonPlayerFaction)
static Color getPositiveHighlightColor()
float getFloat(String key)
void addMessage(String text)
void addScript(EveryFrameScript script)
MemoryAPI getPlayerMemoryWithoutUpdate()
CampaignUIAPI getCampaignUI()
FactionAPI getFaction(String factionId)
void addScript(EveryFrameScript script)
List< MarketAPI > getMarketsCopy()
StarSystemAPI getStarSystem()
void set(String key, Object value)
boolean getBoolean(String key)
void setHighlight(int start, int end)
void setHighlightColors(Color ... colors)