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.CargoAPI;
11import com.fs.starfarer.api.campaign.InteractionDialogAPI;
12import com.fs.starfarer.api.campaign.StarSystemAPI;
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.campaign.listeners.ColonyPlayerHostileActListener;
17import com.fs.starfarer.api.campaign.listeners.ColonySizeChangeListener;
18import com.fs.starfarer.api.impl.campaign.NPCHassler;
19import com.fs.starfarer.api.impl.campaign.econ.LuddicMajority;
20import com.fs.starfarer.api.impl.campaign.ids.Conditions;
21import com.fs.starfarer.api.impl.campaign.ids.Factions;
22import com.fs.starfarer.api.impl.campaign.ids.FleetTypes;
23import com.fs.starfarer.api.impl.campaign.ids.Industries;
24import com.fs.starfarer.api.impl.campaign.intel.events.BaseEventIntel.EventStageData;
25import com.fs.starfarer.api.impl.campaign.intel.events.HostileActivityEventIntel.HAERandomEventData;
26import com.fs.starfarer.api.impl.campaign.intel.events.HostileActivityEventIntel.Stage;
27import com.fs.starfarer.api.impl.campaign.intel.group.FGBlockadeAction.FGBlockadeParams;
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.GenericRaidParams;
31import com.fs.starfarer.api.impl.campaign.intel.group.KnightsOfLuddTakeoverExpedition;
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.missions.hub.HubMissionWithTriggers.FleetQuality;
35import com.fs.starfarer.api.impl.campaign.rulecmd.salvage.MarketCMD.TempData;
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;
43 FGIEventListener, ColonyPlayerHostileActListener, ColonySizeChangeListener {
96 return super.getProgress(
intel);
100 return "Luddic Church";
104 return "Knights of Ludd";
110 return Misc.getGrayColor();
112 return Global.
getSector().getFaction(Factions.LUDDIC_CHURCH).getBaseUIColor();
117 public void createTooltip(TooltipMakerAPI tooltip,
boolean expanded, Object tooltipParam) {
119 tooltip.addPara(
"A large community of the faithful -"
120 +
" not under their direct control, and with potential to emerge as a major cultural center - "
121 +
"is a growing source of concern to the Church. "
122 +
"\"Protector\" fleets operated by the Knights of Ludd can be found in your systems, "
123 +
"ostensibly there to protect the "
124 +
"interests of the local Luddic population.", 0f);
136 return Misc.getGrayColor();
138 return Global.
getSector().getFaction(Factions.LUDDIC_CHURCH).getBaseUIColor();
153 public CampaignFleetAPI
createFleet(StarSystemAPI system, Random random) {
158 for (MarketAPI curr : Misc.getMarketsInLocation(system, Factions.PLAYER)) {
159 maxSize = Math.max(curr.getSize(), maxSize);
163 int difficulty = maxSize + 1;
164 difficulty += random.nextInt(4);
165 if (difficulty > 10) difficulty = 10;
167 FleetCreatorMission m =
new FleetCreatorMission(random);
170 Vector2f loc = system.getLocation();
171 String factionId = Factions.LUDDIC_CHURCH;
173 m.createStandardFleet(difficulty, factionId, loc);
174 m.triggerSetFleetQuality(FleetQuality.HIGHER);
175 m.triggerSetFleetType(FleetTypes.SACRED_PROTECTORS);
176 m.triggerSetPatrol();
178 m.triggerSetFleetFlag(
"$sacredProtectors");
180 m.triggerFleetAllowLongPursuit();
181 m.triggerMakeLowRepImpact();
186 CampaignFleetAPI fleet = m.createFleet();
189 fleet.setName(
"Knights of Ludd " + fleet.getName());
190 fleet.setNoFactionInName(
true);
193 fleet.addScript(hassle);
201 ListInfoMode mode,
boolean isUpdate, Color tc,
float initPad) {
202 Color c =
Global.
getSector().getFaction(Factions.LUDDIC_CHURCH).getBaseUIColor();
203 info.addPara(
"Impending Luddic Church takeover operation", initPad, tc, c,
"Luddic Church");
207 ListInfoMode mode,
boolean isUpdate, Color tc,
float initPad) {
208 info.addPara(
"Luddic Church takeover averted", tc, initPad);
217 LabelAPI label = info.addPara(
"You've received intel that the Knights of Ludd, under the aegis of the Luddic Church, "
218 +
"are planning an operation to take over one of your colonies that has a Luddic Majority "
220 small, Misc.getNegativeHighlightColor(),
"take over one of your colonies");
221 label.setHighlight(
"take over one of your colonies",
"Luddic Majority");
222 label.setHighlightColors(Misc.getNegativeHighlightColor(),
223 Global.
getSector().getFaction(Factions.LUDDIC_CHURCH).getBaseUIColor());
225 label = info.addPara(
"If the expedition is defeated, the Luddic faithful leaving the Church worlds "
226 +
"will feel more secure, resulting in increased immigration, stability, and productivity, "
227 +
"and the Luddic Church will likely abandon further efforts of this sort.",
229 label.setHighlight(
"increased immigration, stability, and productivity",
"Luddic Church");
230 label.setHighlightColors(Misc.getPositiveHighlightColor(),
231 Global.
getSector().getFaction(Factions.LUDDIC_CHURCH).getBaseUIColor());
233 Color c =
Global.
getSector().getFaction(Factions.LUDDIC_CHURCH).getBaseUIColor();
234 stage.beginResetReqList(info,
true,
"crisis", opad);
235 info.addPara(
"You make an agreement with the Church", 0f);
236 info.addPara(
"%s is tactically bombarded", 0f, c,
"Hesperus");
237 stage.endResetReqList(info,
false,
"crisis", -1, -1);
244 return Global.
getSector().getFaction(Factions.LUDDIC_CHURCH).getCrest();
248 if (stage.id == Stage.HA_EVENT) {
256 if (stage.id == Stage.HA_EVENT) {
261 if (KnightsOfLuddTakeoverExpedition.get() !=
null) {
267 if (target !=
null && source !=
null) {
276 HAERandomEventData data =
new HAERandomEventData(
this, stage);
277 stage.rollData = data;
284 if (source ==
null || target ==
null) {
288 stage.rollData =
null;
295 for (MarketAPI market : Misc.getPlayerMarkets(
false)) {
296 if (market.getStarSystem() ==
null)
continue;
297 if (market.hasCondition(Conditions.LUDDIC_MAJORITY)) {
298 float size = market.getSize();
299 float w = Math.max(size - 3f, 1f);
301 picker.add(market, w);
304 return picker.pick();
311 public static MarketAPI
getHesperus(
boolean requireMilitaryBase) {
312 MarketAPI kazeron =
Global.
getSector().getEconomy().getMarket(
"hesperus");
313 if (kazeron ==
null || kazeron.hasCondition(Conditions.DECIVILIZED)) {
316 if (requireMilitaryBase) {
317 Industry b = kazeron.getIndustry(Industries.MILITARYBASE);
318 if (b ==
null) b = kazeron.getIndustry(Industries.HIGHCOMMAND);
319 if (b ==
null || b.isDisrupted() || !b.isFunctional()) {
327 public boolean startExpedition(MarketAPI source, MarketAPI target, EventStageData stage, Random random) {
329 GenericRaidParams params =
new GenericRaidParams(
new Random(random.nextLong()),
true);
330 params.factionId = source.getFactionId();
331 params.source = source;
333 params.prepDays = 7f + random.nextFloat() * 14f;
334 params.payloadDays = 180f;
336 params.makeFleetsHostile =
false;
338 FGBlockadeParams bParams =
new FGBlockadeParams();
339 bParams.where = target.getStarSystem();
340 bParams.targetFaction = Factions.PLAYER;
341 bParams.specificMarket = target;
343 params.noun =
"takeover";
344 params.forcesNoun =
"Luddic forces";
346 params.style = FleetStyle.STANDARD;
349 params.fleetSizes.add(10);
352 params.fleetSizes.add(4);
353 params.fleetSizes.add(4);
354 params.fleetSizes.add(3);
355 params.fleetSizes.add(3);
358 KnightsOfLuddTakeoverExpedition blockade =
new KnightsOfLuddTakeoverExpedition(params, bParams);
359 blockade.setListener(
this);
382 TempData actionData, CargoAPI cargo) {
392 if (market !=
null && market == hesperus) {
395 boolean thisEvent = stage.rollData instanceof HAERandomEventData &&
396 ((HAERandomEventData)stage.rollData).factor ==
this;
415 super.advance(amount);
422 if (stage !=
null && stage.rollData instanceof HAERandomEventData &&
423 ((HAERandomEventData)stage.rollData).factor ==
this) {
426 if (hesperus ==
null) {
432 if (!market.isPlayerOwned())
return;
434 boolean matches = LuddicMajority.matchesBonusConditions(market);
436 if (market.hasCondition(Conditions.LUDDIC_MAJORITY) && !matches) {
437 market.removeCondition(Conditions.LUDDIC_MAJORITY);
438 }
else if (!market.hasCondition(Conditions.LUDDIC_MAJORITY) && matches) {
439 market.addCondition(Conditions.LUDDIC_MAJORITY);
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
void addFactor(EventFactor factor)
String getDesc(BaseEventIntel intel)
void reportFGIAborted(FleetGroupIntel intel)
String getNameForThreatList(boolean first)
void reportSaturationBombardmentFinished(InteractionDialogAPI dialog, MarketAPI market, TempData actionData)
static boolean isDefeatedExpedition()
boolean shouldShow(BaseEventIntel intel)
void reportColonySizeChanged(MarketAPI market, int prevSize)
void notifyFactorRemoved()
MarketAPI getExpeditionSource(HostileActivityEventIntel intel, EventStageData stage, final MarketAPI target)
boolean startExpedition(MarketAPI source, MarketAPI target, EventStageData stage, Random random)
float getEventFrequency(HostileActivityEventIntel intel, EventStageData stage)
Color getDescColor(BaseEventIntel intel)
static boolean brokeDeal()
void reportTacticalBombardmentFinished(InteractionDialogAPI dialog, MarketAPI market, TempData actionData)
static final String HASSLE_REASON
void reportRaidForValuablesFinishedBeforeCargoShown(InteractionDialogAPI dialog, MarketAPI market, TempData actionData, CargoAPI cargo)
static void setBrokeDeal(boolean broke)
int getProgress(BaseEventIntel intel)
String getEventStageIcon(HostileActivityEventIntel intel, EventStageData stage)
Color getNameColor(float mag)
float getSpawnInHyperProbability(StarSystemAPI system)
void reportRaidToDisruptFinished(InteractionDialogAPI dialog, MarketAPI market, TempData actionData, Industry industry)
void rollEvent(HostileActivityEventIntel intel, EventStageData stage)
static boolean isMadeDeal()
static void setDefeatedExpedition(boolean value)
static void setMadeDeal(boolean value)
void advance(float amount)
void addBulletPointForEvent(HostileActivityEventIntel intel, EventStageData stage, TooltipMakerAPI info, ListInfoMode mode, boolean isUpdate, Color tc, float initPad)
TooltipCreator getMainRowTooltip(BaseEventIntel intel)
LuddicChurchHostileActivityFactor(HostileActivityEventIntel intel)
String getProgressStr(BaseEventIntel intel)
CampaignFleetAPI createFleet(StarSystemAPI system, Random random)
void addBulletPointForEventReset(HostileActivityEventIntel intel, EventStageData stage, TooltipMakerAPI info, ListInfoMode mode, boolean isUpdate, Color tc, float initPad)
static MarketAPI getHesperus(boolean requireMilitaryBase)
MarketAPI findExpeditionTarget(HostileActivityEventIntel intel, EventStageData stage)
TooltipCreator getStageTooltipImpl(final HostileActivityEventIntel intel, final EventStageData stage)
static final String DEFEATED_LUDDIC_CHURCH_EXPEDITION
static final String BROKE_LUDDIC_CHURCH_DEAL
int getMaxNumFleets(StarSystemAPI system)
static final String MADE_IMMIGRATION_DEAL_WITH_LUDDIC_CHURCH
boolean fireEvent(HostileActivityEventIntel intel, EventStageData stage)
void addStageDescriptionForEvent(HostileActivityEventIntel intel, EventStageData stage, TooltipMakerAPI info)