1package com.fs.starfarer.api.impl.campaign.intel.events;
4import java.util.Random;
8import org.lwjgl.util.vector.Vector2f;
10import com.fs.starfarer.api.Global;
11import com.fs.starfarer.api.campaign.CampaignFleetAPI;
12import com.fs.starfarer.api.campaign.StarSystemAPI;
13import com.fs.starfarer.api.campaign.comm.CommMessageAPI.MessageClickAction;
14import com.fs.starfarer.api.campaign.comm.IntelInfoPlugin;
15import com.fs.starfarer.api.campaign.comm.IntelInfoPlugin.ListInfoMode;
16import com.fs.starfarer.api.campaign.econ.MarketAPI;
17import com.fs.starfarer.api.campaign.listeners.ListenerUtil;
18import com.fs.starfarer.api.campaign.listeners.PatherCellListener;
19import com.fs.starfarer.api.impl.campaign.ids.Factions;
20import com.fs.starfarer.api.impl.campaign.ids.Sounds;
21import com.fs.starfarer.api.impl.campaign.intel.MessageIntel;
22import com.fs.starfarer.api.impl.campaign.intel.bases.LuddicPathBaseIntel;
23import com.fs.starfarer.api.impl.campaign.intel.bases.LuddicPathBaseManager;
24import com.fs.starfarer.api.impl.campaign.intel.bases.LuddicPathCellsIntel;
25import com.fs.starfarer.api.impl.campaign.intel.events.BaseEventIntel.EventStageData;
26import com.fs.starfarer.api.impl.campaign.intel.events.HostileActivityEventIntel.HAERandomEventData;
27import com.fs.starfarer.api.impl.campaign.intel.events.HostileActivityEventIntel.Stage;
28import com.fs.starfarer.api.impl.campaign.intel.group.FleetGroupIntel;
29import com.fs.starfarer.api.impl.campaign.intel.group.FleetGroupIntel.FGIEventListener;
30import com.fs.starfarer.api.impl.campaign.intel.group.GenericRaidFGI;
31import com.fs.starfarer.api.impl.campaign.intel.group.GenericRaidFGI.GenericRaidParams;
32import com.fs.starfarer.api.impl.campaign.missions.FleetCreatorMission;
33import com.fs.starfarer.api.impl.campaign.missions.FleetCreatorMission.FleetStyle;
34import com.fs.starfarer.api.impl.campaign.rulecmd.HA_CMD;
35import com.fs.starfarer.api.impl.campaign.rulecmd.salvage.MarketCMD.BombardType;
36import com.fs.starfarer.api.ui.LabelAPI;
37import com.fs.starfarer.api.ui.TooltipMakerAPI;
38import com.fs.starfarer.api.ui.TooltipMakerAPI.TooltipCreator;
39import com.fs.starfarer.api.util.Misc;
40import com.fs.starfarer.api.util.WeightedRandomPicker;
56 public static class HAPatherCellsEventData {
59 public float interest;
82 if (first)
return "Luddic Path";
101 public void createTooltip(
TooltipMakerAPI tooltip,
boolean expanded, Object tooltipParam) {
104 tooltip.
addPara(
"Advanced technology and artificial intelligence are anathema to the Luddic Path.", 0f);
105 tooltip.
addPara(
"Most of the Pather fleets are small, engaging in reconnaissance and demanding tithes "
106 +
"from unwary travellers, but occasionaly a larger raiding force will make an appearance.", opad);
120 if (days < 1 && days > 0) days = 1;
121 days = Math.round(days);
122 String dStr =
"days";
123 if ((
int)days == 1) dStr =
"day";
124 tooltip.
addPara(
"You've %s a signficant amount to the Pathers, and their fleets and "
125 +
"ground-based cells should leave your colonies alone for another %s " + dStr +
".",
126 initPad,
new Color[] {p, h},
"tithed",
"" + (int)days);
128 tooltip.
addPara(
"You've reached an understanding with the Pathers, and their fleets and "
129 +
"ground-based cells should leave your colonies alone in the future, "
130 +
"barring unexpected events.",
131 initPad, p,
"understanding");
134 tooltip.
addPara(
"It's possible that you might reach some kind of understanding with the Pathers, "
135 +
"provided you find the right people to talk to.", initPad,
136 h,
"find the right people");
166 boolean small = random.nextFloat() < p;
171 difficulty = 1 + random.nextInt(2);
174 difficulty += (int) Math.round(f * 5f);
175 difficulty += random.nextInt(6);
215 if (stage ==
null)
return null;
216 if (stage.rollData instanceof HAERandomEventData) {
217 HAERandomEventData data = (HAERandomEventData) stage.rollData;
218 if (data.custom instanceof HAPatherCellsEventData) {
219 HAPatherCellsEventData attackData = (HAPatherCellsEventData) data.custom;
228 ListInfoMode mode,
boolean isUpdate, Color tc,
float initPad) {
233 if (data ==
null)
return;
235 LabelAPI label = info.
addPara(
"Signs of a Luddic Path attack targeting %s",
236 initPad, tc, tc, data.market.getName());
237 label.
setHighlight(
"Luddic Path", data.market.getName());
242 ListInfoMode mode,
boolean isUpdate, Color tc,
float initPad) {
243 info.
addPara(
"Luddic Path attack averted", tc, initPad);
248 if (data ==
null)
return;
257 LabelAPI label = info.
addPara(
"There are signs of an impending Luddic Path attack targeting %s."
258 +
" If the attack is successful, the colony will suffer a catastrophic saturation bombardment.",
259 small, c, data.market.getName());
260 label.
setHighlight(data.market.getName(),
"catastrophic saturation bombardment");
264 info.
addPara(
"This attack represents a significant resource investment by the Pathers. "
265 +
"If it is defeated, Luddic Path cells Sector-wide will be disrupted and Pathers will take "
266 +
"less interest in your operations in the future.",
270 stage.beginResetReqList(info,
true,
"crisis", opad);
271 label = info.
addPara(
"The Luddic Path cells on %s are disrupted",
273 label.
setHighlight(
"Luddic Path", data.market.getName());
276 info.
addPara(
"An agreement is reached with the Luddic Path",
278 stage.endResetReqList(info,
false,
"crisis", -1, -1);
289 if (stage.id == Stage.HA_EVENT) {
320 if (stage.id == Stage.HA_EVENT) {
336 if (cells ==
null || cells.
isSleeper())
continue;
339 picker.
add(market, w * w);
341 return picker.
pick();
357 if (market ==
null || cells ==
null)
return;
359 HAERandomEventData data =
new HAERandomEventData(
this, stage);
360 data.custom =
new HAPatherCellsEventData(cells, market);
361 stage.rollData = data;
369 if (data ==
null || data.market ==
null || data.cells ==
null || data.cells.isSleeper()) {
373 if (!data.market.isInEconomy())
return false;
376 if (base ==
null)
return false;
379 if (system ==
null)
return false;
389 if (data !=
null && data.cells == cell && stage.rollData !=
null) {
400 if (
intel ==
null)
return;
404 if (data !=
null && stage.rollData !=
null) {
411 GenericRaidParams params =
new GenericRaidParams(
new Random(random.nextLong()),
true);
413 params.source = source;
415 params.prepDays = 14f + random.nextFloat() * 14f;
416 params.payloadDays = 27f + 7f * random.nextFloat();
418 params.raidParams.where = system;
419 params.raidParams.allowedTargets.add(target);
420 params.raidParams.allowNonHostileTargets =
true;
421 params.raidParams.setBombardment(BombardType.SATURATION);
423 params.style = FleetStyle.STANDARD;
427 w += Math.max(0f, (target.
getSize() - 2)) * 10f;
429 if (w > 50f) w = 50f;
432 float totalDifficulty = (0.25f + f * 0.75f) * 40f;
435 if (r.nextFloat() < 0.33f) {
436 params.style = FleetStyle.QUANTITY;
439 while (totalDifficulty > 0) {
445 int diff = (int) Math.min(10f, totalDifficulty);
446 if (diff < 2) diff = 2;
448 params.fleetSizes.add(diff);
449 totalDifficulty -= diff;
static SettingsAPI getSettings()
static SectorAPI getSector()
static void reportCellDisrupted(LuddicPathCellsIntel cell)
static final String LUDDIC_PATH
boolean isPlayerVisible()
void sendUpdateIfPlayerHasIntel(Object listInfoParam, TextPanelAPI textPanel)
void setIcon(String icon)
void addLine(String text)
void setSound(String sound)
static LuddicPathBaseIntel getIntelFor(StarSystemAPI system)
static Object DISCOVERED_PARAM
static float getLuddicPathMarketInterest(MarketAPI market)
static LuddicPathBaseIntel getClosestBase(MarketAPI market)
static LuddicPathCellsIntel getCellsForMarket(MarketAPI market)
void addBorder(TooltipMakerAPI info, Color c)
EventStageData getDataFor(Object stageId)
float getEffectMagnitude(StarSystemAPI system)
Random getRandomizedStageRandom()
TooltipCreator getDefaultEventTooltip(final String title, final HostileActivityEventIntel intel, final EventStageData stage)
HostileActivityEventIntel intel
int getProgress(BaseEventIntel intel)
static HostileActivityEventIntel get()
static void addAgreementStatus(TooltipMakerAPI tooltip, float initPad)
boolean shouldShow(BaseEventIntel intel)
void reportCellsDisrupted(LuddicPathCellsIntel cell)
float getEventFrequency(HostileActivityEventIntel intel, EventStageData stage)
void addStageDescriptionForEvent(HostileActivityEventIntel intel, EventStageData stage, TooltipMakerAPI info)
Color getDescColor(BaseEventIntel intel)
String getProgressStr(BaseEventIntel intel)
String getNameForThreatList(boolean first)
TooltipCreator getMainRowTooltip(BaseEventIntel intel)
void addBulletPointForEventReset(HostileActivityEventIntel intel, EventStageData stage, TooltipMakerAPI info, ListInfoMode mode, boolean isUpdate, Color tc, float initPad)
boolean startRaid(MarketAPI source, MarketAPI target, float interest, StarSystemAPI system, EventStageData stage, Random random)
boolean fireEvent(HostileActivityEventIntel intel, EventStageData stage)
static void setPlayerDefeatedPatherExpedition()
LuddicPathHostileActivityFactor(HostileActivityEventIntel intel)
static void avertOrAbortAttack()
static HAPatherCellsEventData getPatherCellData(EventStageData stage)
void addBulletPointForEvent(HostileActivityEventIntel intel, EventStageData stage, TooltipMakerAPI info, ListInfoMode mode, boolean isUpdate, Color tc, float initPad)
static boolean isPlayerDefeatedPatherExpedition()
void rollEvent(HostileActivityEventIntel intel, EventStageData stage)
void notifyFactorRemoved()
TooltipCreator getStageTooltipImpl(final HostileActivityEventIntel intel, final EventStageData stage)
void reportFGIAborted(FleetGroupIntel intel)
String getEventStageIcon(HostileActivityEventIntel intel, EventStageData stage)
String getDesc(BaseEventIntel intel)
MarketAPI pickTargetMarket()
CampaignFleetAPI createFleet(StarSystemAPI system, Random random)
static String DEFEATED_PATHER_EXPEDITION
Color getNameColorForThreatList()
int getMaxNumFleets(StarSystemAPI system)
void finish(boolean isAbort)
void setListener(FGIEventListener listener)
static GenericRaidFGI get(String key)
CampaignFleetAPI createFleet()
void createStandardFleet(int difficulty, String factionId, Vector2f locInHyper)
void triggerFleetAllowLongPursuit()
void triggerMakeLowRepImpact()
void triggerSetPirateFleet()
static boolean playerPatherAgreementIsPermanent()
static float getPlayerPatherAgreementDays()
static boolean playerHasPatherAgreement()
static boolean isHiddenBase(MarketAPI market)
static Color getNegativeHighlightColor()
static Color getBasePlayerColor()
static Color getGrayColor()
static Color getHighlightColor()
static List< MarketAPI > getPlayerMarkets(boolean includeNonPlayerFaction)
static Color getPositiveHighlightColor()
String getSpriteName(String category, String id)
float getFloat(String key)
void addMessage(String text)
MemoryAPI getPlayerMemoryWithoutUpdate()
IntelManagerAPI getIntelManager()
CampaignUIAPI getCampaignUI()
FactionAPI getFaction(String factionId)
ListenerManagerAPI getListenerManager()
void addIntel(IntelInfoPlugin plugin)
List< IntelInfoPlugin > getIntel()
float getDaysInExistence()
void addListener(Object listener)
void removeListener(Object listener)
void set(String key, Object value)
boolean getBoolean(String key)
void setHighlight(int start, int end)
void setHighlightColors(Color ... colors)