1package com.fs.starfarer.api.impl.campaign.intel.bases;
3import java.util.ArrayList;
4import java.util.Collections;
5import java.util.Comparator;
6import java.util.Iterator;
8import java.util.Random;
13import com.fs.starfarer.api.Global;
14import com.fs.starfarer.api.campaign.BattleAPI;
15import com.fs.starfarer.api.campaign.CampaignEventListener.FleetDespawnReason;
16import com.fs.starfarer.api.campaign.CampaignFleetAPI;
17import com.fs.starfarer.api.campaign.FactionAPI;
18import com.fs.starfarer.api.campaign.SectorEntityToken;
19import com.fs.starfarer.api.campaign.comm.IntelInfoPlugin;
20import com.fs.starfarer.api.campaign.econ.Industry;
21import com.fs.starfarer.api.campaign.econ.MarketAPI;
22import com.fs.starfarer.api.campaign.listeners.FleetEventListener;
23import com.fs.starfarer.api.impl.campaign.DebugFlags;
24import com.fs.starfarer.api.impl.campaign.econ.RecentUnrest;
25import com.fs.starfarer.api.impl.campaign.fleets.EconomyFleetAssignmentAI;
26import com.fs.starfarer.api.impl.campaign.fleets.EconomyFleetAssignmentAI.EconomyRouteData;
27import com.fs.starfarer.api.impl.campaign.fleets.EconomyFleetRouteManager;
28import com.fs.starfarer.api.impl.campaign.fleets.RouteLocationCalculator;
29import com.fs.starfarer.api.impl.campaign.fleets.RouteManager;
30import com.fs.starfarer.api.impl.campaign.fleets.RouteManager.OptionalFleetData;
31import com.fs.starfarer.api.impl.campaign.fleets.RouteManager.RouteData;
32import com.fs.starfarer.api.impl.campaign.fleets.RouteManager.RouteFleetSpawner;
33import com.fs.starfarer.api.impl.campaign.fleets.RouteManager.RouteSegment;
34import com.fs.starfarer.api.impl.campaign.ids.Conditions;
35import com.fs.starfarer.api.impl.campaign.ids.Factions;
36import com.fs.starfarer.api.impl.campaign.ids.FleetTypes;
37import com.fs.starfarer.api.impl.campaign.ids.MemFlags;
38import com.fs.starfarer.api.impl.campaign.ids.Tags;
39import com.fs.starfarer.api.impl.campaign.intel.BaseIntelPlugin;
40import com.fs.starfarer.api.impl.campaign.intel.events.LuddicPathHostileActivityFactor;
41import com.fs.starfarer.api.impl.campaign.rulecmd.HA_CMD;
42import com.fs.starfarer.api.ui.Alignment;
43import com.fs.starfarer.api.ui.SectorMapAPI;
44import com.fs.starfarer.api.ui.TooltipMakerAPI;
45import com.fs.starfarer.api.util.IntervalUtil;
46import com.fs.starfarer.api.util.Misc;
47import com.fs.starfarer.api.util.WeightedRandomPicker;
71 public static enum IncidentType {
83 protected Random
random =
new Random();
122 float minDist = Float.MAX_VALUE;
127 if (dist < minDist) {
136 List<LuddicPathCellsIntel> result =
new ArrayList<LuddicPathCellsIntel>();
141 if (!includeSleeper && intel.
isSleeper())
continue;
150 if (
market ==
null)
return null;
166 return super.canMakeVisibleToPlayer(playerInRelayRange);
178 super.notifyEnding();
204 super.advanceImpl(amount);
268 RouteSegment segment =
smuggler.getCurrent();
288 if (mode == ListInfoMode.IN_DESC) initPad = opad;
295 if (mode != ListInfoMode.IN_DESC) {
304 info.
addPara(
"Incident averted by local security forces", initPad);
307 case INDUSTRY_SABOTAGE:
311 info.
addPara(ind.
getCurrentName() +
" operations disrupted for %s " + daysStr, initPad, tc, h, days);
313 case REDUCED_STABILITY:
317 info.
addPara(
"Colony destroyed by planetbuster", initPad, tc);
341 info.
addPara(
"The following activity is attracting Pather interest, whether due to AI core use or the inherent nature of the industry:", opad);
344 Iterator<Industry> iter = industries.iterator();
345 while (iter.hasNext()) {
346 if (iter.next().isHidden()) {
350 Collections.sort(industries,
new Comparator<Industry>() {
354 return (
int) Math.signum(s2 - s1);
359 boolean added =
false;
362 if (aiCoreId !=
null) {
365 info.
addPara(
indent +
"Suspected AI core administrator (%s)", initPad, h,
"" + s);
367 info.
addPara(
indent +
"AI core administrator (%s)", initPad, h,
"" + s);
375 float score = ind.getPatherInterest();
376 if ((
int)Math.round(score) != 0) {
377 int s = (int) Math.round(score);
378 info.
addPara(
indent + ind.getCurrentName() +
" (%s)", initPad, h,
"" + s);
391 info.
addPara(
"You defeated a Luddic Path armada sent against you, and "
392 +
"they are now more reluctant to take active measures against your colonies.", opad);
411 info.
addPara(
"The Pather cells " +
414 info.
addPara(
"There are indications that sleeper Luddic Path cells are being organized " +
416 info.
addPara(
"The Pathers have not made any significant moves, but are apparently preparing " +
417 "to do so if whatever activity they object to - industrial development, or the suspected " +
418 "use of AI cores, and other such - continues.", opad);
420 info.
addPara(
"There are active Luddic Path cells " +
425 info.
addPara(
"They are engaged in planning acts of terror and industrial sabotage, but " +
426 "are unlikely to carry them off unless the overal level of hostile activity in the system "
427 +
"provides sufficient cover."
428 +
" The cells also provide intel to Pather fleets operating in-system.", opad);
432 if (daysNum < 1) daysNum = 1;
434 info.
addPara(
"However, the base supporting these cells is no longer operational. " +
435 "It is projected that establishing a new support network will take at least " +
436 "%s " + days +
", provided another base exists.", opad,
444 " is providing support to these cells.", opad);
446 info.
addPara(
"You do not know the location of the Pather base providing support to these cells.", opad);
449 info.
addPara(
"If the base is destroyed, it will take some time to organize " +
450 "support from another base, and both ground and fleet operations will be disrupted.", opad);
467 "-" + (
int)stability);
470 info.
addPara(
"No perceptible impact on operations as of yet.", opad);
472 info.
addPara(
"No impact on operations due to lack of material support.", opad);
485 info.
addPara(
"There are indications that the Pather cells are preparing to sneak " +
487 "If they succeed, the colony will effectively be destroyed.", opad);
490 case INDUSTRY_SABOTAGE:
496 info.
addPara(
"The Pather cells have conducted a successful act of sabotage, " +
497 "disrupting " + ind.
getCurrentName() +
" operations for %s " + daysStr +
".",
502 case REDUCED_STABILITY:
503 info.
addPara(
"The Pather cells have conducted low-level attacks on various " +
504 "industrial, military, and civilian targets, reducing stability by %s.",
509 " and detonated it. The colony has been effectively destroyed.", opad);
516 case INDUSTRY_SABOTAGE:
519 info.
addPara(
"An attempted act of sabotage against " +
520 ind.
getCurrentName() +
" operations was averted by the local security forces.",
524 case REDUCED_STABILITY:
525 info.
addPara(
"Multiple planned attacks against various industrial, " +
526 "military, and civilian targets " +
527 " were averted by the local security forces.",
532 ", but the local security forces were able to locate and disarm it, thereby " +
533 "saving the colony.", opad);
553 List<ArrowData> result =
new ArrayList<ArrowData>();
559 if (iconEntity !=
null) {
560 entityFrom = iconEntity;
581 Set<String> tags = super.getIntelTags(map);
600 String base =
"Luddic Path Cells";
605 return base +
" - Incident";
607 return base +
" - Incident Averted";
613 return base +
" - Dissolved";
616 return base +
" - Disrupted";
619 return base +
" - Sleeper";
621 return base +
" - Active";
642 return super.getCommMessageSound();
677 if (base ==
null)
return;
681 types.
add(IncidentType.REDUCED_STABILITY, 10f);
683 types.
add(IncidentType.INDUSTRY_SABOTAGE, 10f);
727 return random.nextFloat() < pSuccess;
743 }
else if (
incidentType == IncidentType.INDUSTRY_SABOTAGE) {
746 if (!ind.canBeDisrupted())
continue;
747 picker.
add(ind, ind.getPatherInterest());
750 if (target ==
null) {
788 EconomyRouteData data =
new EconomyRouteData();
791 data.smuggling =
true;
795 OptionalFleetData extra =
new OptionalFleetData(data.from);
799 extra.strength = 50f;
803 float orbitDays = 3f +
random.nextFloat() * 3f;
830 Random
random =
new Random();
831 if (route.getSeed() !=
null) {
832 random =
new Random(route.getSeed());
836 if (fleet ==
null)
return null;;
static SettingsAPI getSettings()
static SectorAPI getSector()
static boolean SEND_UPDATES_WHEN_NO_COMM
static boolean PATHER_BASE_DEBUG
static RecentUnrest get(MarketAPI market)
void add(int stability, String reason)
static final String SOURCE_ID
static CampaignFleetAPI createTradeRouteFleet(RouteData route, Random random)
static final Integer ROUTE_SRC_LOAD
static final Integer ROUTE_TRAVEL_DST
static final Integer ROUTE_DST_UNLOAD
static final Integer ROUTE_DST_LOAD
static final Integer ROUTE_SRC_UNLOAD
static final Integer ROUTE_TRAVEL_SRC
static float getTravelDays(SectorEntityToken from, SectorEntityToken to)
RouteData addRoute(String source, MarketAPI market, Long seed, OptionalFleetData extra, RouteFleetSpawner spawner)
static RouteManager getInstance()
static final String PATHER_CELLS
static final String LUDDIC_PATH
static final String PLAYER
static final String TRADE_SMUGGLER
static final String SUSPECTED_AI
static final String FLEET_DO_NOT_IGNORE_PLAYER
static final String FLEET_IGNORES_OTHER_FLEETS
boolean isSendingUpdate()
void indent(TooltipMakerAPI info)
String getDays(float days)
void setPostingLocation(SectorEntityToken postingLocation)
void unindent(TooltipMakerAPI info)
boolean isPlayerVisible()
void sendUpdateIfPlayerHasIntel(Object listInfoParam, TextPanelAPI textPanel)
Object getListInfoParam()
Color getBulletColorForMode(ListInfoMode mode)
static String getDaysString(float days)
void bullet(TooltipMakerAPI info)
Color getTitleColor(ListInfoMode mode)
static void addMarketToList(TooltipMakerAPI info, MarketAPI market, float pad)
SectorEntityToken getMapLocation(SectorMapAPI map)
static float AI_CORE_ADMIN_INTEREST
List< ArrowData > getArrowData(SectorMapAPI map)
FactionAPI getFactionForUIColors()
static Object INCIDENT_PREVENTED
boolean shouldCancelRouteAfterDelayCheck(RouteData route)
void addBulletPoints(TooltipMakerAPI info, ListInfoMode mode)
CampaignFleetAPI spawnFleet(RouteData route)
static Object UPDATE_DISSOLVED
static Object INCIDENT_PREP
void setInertiaTime(float inertiaTime)
String getCommMessageSound()
IncidentType incidentType
void createSmallDescription(TooltipMakerAPI info, float width, float height)
static float INCIDENT_PROB
void addInterestInfo(TooltipMakerAPI info, float width, float height)
SectorEntityToken getMapLocation(SectorMapAPI map)
void advanceImpl(float amount)
static float MIN_SABOTAGE
void reportBattleOccurred(CampaignFleetAPI fleet, CampaignFleetAPI primaryWinner, BattleAPI battle)
void reportFleetDespawnedToListener(CampaignFleetAPI fleet, FleetDespawnReason reason, Object param)
void setSleeper(boolean sleeper)
String getSmallDescriptionTitle()
static Object INCIDENT_HAPPENED
static float MAX_SABOTAGE
void createIntelInfo(TooltipMakerAPI info, ListInfoMode mode)
Set< String > getIntelTags(SectorMapAPI map)
void reportAboutToBeDespawnedByRouteManager(RouteData route)
float getSleeperTimeout()
static List< LuddicPathCellsIntel > getCellsForBase(LuddicPathBaseIntel base, boolean includeSleeper)
void sendSmuggler(LuddicPathBaseIntel base)
LuddicPathCellsIntel(MarketAPI market, boolean sleeper)
static LuddicPathBaseIntel getClosestBase(MarketAPI market)
static Object UPDATE_DISRUPTED
IntervalUtil incidentTracker
void setSleeperTimeout(float sleeperTimeout)
IncidentType prevIncident
String getRouteSourceId()
boolean prevIncidentSucceeded
static float MIN_WARNING_DAYS
void makeSleeper(float sleeperTimeout)
void makeActiveIfPossible()
static String USED_PLANETBUSTER_KEY
boolean canMakeVisibleToPlayer(boolean playerInRelayRange)
boolean shouldRepeat(RouteData route)
static LuddicPathCellsIntel getCellsForMarket(MarketAPI market)
static int STABLITY_PENALTY
static boolean isPlayerDefeatedPatherExpedition()
static boolean playerHasPatherAgreement()
void advance(float amount)
static Color getTextColor()
static String ucFirst(String str)
static Color getGrayColor()
static float getDistance(SectorEntityToken from, SectorEntityToken to)
static float getDays(float amount)
static long genRandomSeed()
static Color getHighlightColor()
static float getAdjustedStrength(float fp, MarketAPI market)
String getSpriteName(String category, String id)
float getFloatFromArray(String key, int index)
float getFloat(String key)
List< CampaignFleetAPI > getSideFor(CampaignFleetAPI participantOrCombined)
boolean isInvolved(CampaignFleetAPI test)
String getPersonNamePrefix()
void addEventListener(FleetEventListener listener)
void removeEventListener(FleetEventListener listener)
String getNameWithLowercaseType()
void addScript(EveryFrameScript script)
void removeScript(EveryFrameScript script)
IntelManagerAPI getIntelManager()
FactionAPI getFaction(String factionId)
MemoryAPI getMemoryWithoutUpdate()
void addScript(EveryFrameScript script)
MemoryAPI getMemoryWithoutUpdate()
void addIntel(IntelInfoPlugin plugin)
List< IntelInfoPlugin > getIntel()
boolean isPlayerInRangeOfCommRelay()
void queueIntel(IntelInfoPlugin plugin, float maxCommQueueDays)
void setDisrupted(float days)
float getPatherInterest()
float getStabilityValue()
String addCondition(String id)
List< Industry > getIndustries()
Vector2f getLocationInHyperspace()
StarSystemAPI getStarSystem()
boolean hasCondition(String id)
void removeCondition(String id)
SectorEntityToken getPrimaryEntity()
void set(String key, Object value)
boolean getBoolean(String key)
MemoryAPI getMemoryWithoutUpdate()
SectorEntityToken getIntelIconEntity(IntelInfoPlugin plugin)