Starsector API
Loading...
Searching...
No Matches
TriTachyonHostileActivityFactor.java
Go to the documentation of this file.
1package com.fs.starfarer.api.impl.campaign.intel.events;
2
3import java.awt.Color;
4import java.util.LinkedHashSet;
5import java.util.List;
6import java.util.Random;
7import java.util.Set;
8
9import org.lwjgl.util.vector.Vector2f;
10
11import com.fs.starfarer.api.Global;
12import com.fs.starfarer.api.campaign.BattleAPI;
13import com.fs.starfarer.api.campaign.CampaignEventListener.FleetDespawnReason;
14import com.fs.starfarer.api.campaign.CampaignFleetAPI;
15import com.fs.starfarer.api.campaign.CargoAPI;
16import com.fs.starfarer.api.campaign.InteractionDialogAPI;
17import com.fs.starfarer.api.campaign.StarSystemAPI;
18import com.fs.starfarer.api.campaign.comm.IntelInfoPlugin.ListInfoMode;
19import com.fs.starfarer.api.campaign.econ.Industry;
20import com.fs.starfarer.api.campaign.econ.MarketAPI;
21import com.fs.starfarer.api.campaign.listeners.ColonyPlayerHostileActListener;
22import com.fs.starfarer.api.campaign.listeners.FleetEventListener;
23import com.fs.starfarer.api.fleet.FleetMemberAPI;
24import com.fs.starfarer.api.impl.campaign.fleets.EconomyFleetAssignmentAI.EconomyRouteData;
25import com.fs.starfarer.api.impl.campaign.fleets.EconomyFleetRouteManager;
26import com.fs.starfarer.api.impl.campaign.fleets.RouteManager;
27import com.fs.starfarer.api.impl.campaign.fleets.RouteManager.RouteData;
28import com.fs.starfarer.api.impl.campaign.ids.Conditions;
29import com.fs.starfarer.api.impl.campaign.ids.Factions;
30import com.fs.starfarer.api.impl.campaign.ids.FleetTypes;
31import com.fs.starfarer.api.impl.campaign.ids.Industries;
32import com.fs.starfarer.api.impl.campaign.ids.Skills;
33import com.fs.starfarer.api.impl.campaign.ids.Strings;
34import com.fs.starfarer.api.impl.campaign.intel.events.BaseEventIntel.EventStageData;
35import com.fs.starfarer.api.impl.campaign.intel.events.HostileActivityEventIntel.HAERandomEventData;
36import com.fs.starfarer.api.impl.campaign.intel.events.HostileActivityEventIntel.Stage;
37import com.fs.starfarer.api.impl.campaign.intel.events.TriTachyonStandardActivityCause.CompetitorData;
38import com.fs.starfarer.api.impl.campaign.intel.events.ttcr.TTCRCommerceRaidersDestroyedFactor;
39import com.fs.starfarer.api.impl.campaign.intel.events.ttcr.TTCRIndustryDisruptedFactor;
40import com.fs.starfarer.api.impl.campaign.intel.events.ttcr.TTCRMercenariesDefeatedFactor;
41import com.fs.starfarer.api.impl.campaign.intel.events.ttcr.TTCRPoints;
42import com.fs.starfarer.api.impl.campaign.intel.events.ttcr.TTCRTradeFleetsDestroyedFactor;
43import com.fs.starfarer.api.impl.campaign.intel.events.ttcr.TriTachyonCommerceRaiding;
44import com.fs.starfarer.api.impl.campaign.intel.group.FGRaidAction.FGRaidType;
45import com.fs.starfarer.api.impl.campaign.intel.group.FleetGroupIntel;
46import com.fs.starfarer.api.impl.campaign.intel.group.FleetGroupIntel.FGIEventListener;
47import com.fs.starfarer.api.impl.campaign.intel.group.GenericRaidFGI.GenericRaidParams;
48import com.fs.starfarer.api.impl.campaign.intel.group.TTMercenaryAttack;
49import com.fs.starfarer.api.impl.campaign.missions.FleetCreatorMission;
50import com.fs.starfarer.api.impl.campaign.missions.FleetCreatorMission.FleetStyle;
51import com.fs.starfarer.api.impl.campaign.missions.hub.HubMissionWithTriggers.ComplicationRepImpact;
52import com.fs.starfarer.api.impl.campaign.missions.hub.HubMissionWithTriggers.FleetQuality;
53import com.fs.starfarer.api.impl.campaign.rulecmd.salvage.MarketCMD.TempData;
54import com.fs.starfarer.api.ui.TooltipMakerAPI;
55import com.fs.starfarer.api.ui.TooltipMakerAPI.TooltipCreator;
56import com.fs.starfarer.api.util.CountingMap;
57import com.fs.starfarer.api.util.Misc;
58import com.fs.starfarer.api.util.TimeoutTracker;
59
61 implements FGIEventListener, FleetEventListener, ColonyPlayerHostileActListener {
62
63 public static String COUNTER_RAIDED_TRITACH = "$counterRaidedTriTach";
64 public static String DEFEATED_MERC_ATTACK = "$defeatedTTMercAttack";
65 public static String BRIBED_MERC_ATTACK = "$bribedTTMercAttack";
66
67 public static String COMMERCE_RAIDER_FLEET = "$triTachCommerceRaider";
68
69 public static float DEALT_WITH_MERC_PROGRESS_MULT = 0.25f;
70
71 public static boolean isPlayerCounterRaidedTriTach() {
72 return Global.getSector().getPlayerMemoryWithoutUpdate().getBoolean(COUNTER_RAIDED_TRITACH);
73 }
74 public static void setPlayerCounterRaidedTriTach() {
75 Global.getSector().getPlayerMemoryWithoutUpdate().set(COUNTER_RAIDED_TRITACH, true);
76 }
77
78 public static boolean isPlayerDefeatedMercAttack() {
79 return Global.getSector().getPlayerMemoryWithoutUpdate().getBoolean(DEFEATED_MERC_ATTACK);
80 }
81 public static void setPlayerDefeatedMercAttack() {
82 Global.getSector().getPlayerMemoryWithoutUpdate().set(DEFEATED_MERC_ATTACK, true);
83 }
84
85 public static boolean isDealtWithMercAttack() {
87 }
88
92 public static boolean isPlayerBribedMercAttack() {
93 return Global.getSector().getPlayerMemoryWithoutUpdate().getBoolean(BRIBED_MERC_ATTACK);
94 }
95 public static void setPlayerBribedMercAttack() {
96 Global.getSector().getPlayerMemoryWithoutUpdate().set(BRIBED_MERC_ATTACK, true);
97 }
98
99
100
101 protected TimeoutTracker<Industry> recentlyDisrupted = new TimeoutTracker<Industry>();
102
103
105 super(intel);
106
107 Global.getSector().getListenerManager().addListener(this);
108 }
109
110 protected Object readResolve() {
111 if (recentlyDisrupted == null) {
112 recentlyDisrupted = new TimeoutTracker<Industry>();
113 }
114 return this;
115 }
116
118 return "";
119 }
120
121 @Override
123 if (!checkFactionExists(Factions.TRITACHYON, true)) {
124 return 0;
125 }
126 return super.getProgress(intel);
127 }
128
129 public String getDesc(BaseEventIntel intel) {
130 return "Tri-Tachyon Corporation";
131 }
132
133 public String getNameForThreatList(boolean first) {
134 return "Tri-Tachyon";
135 }
136
137
139 if (getProgress(intel) <= 0) {
140 return Misc.getGrayColor();
141 }
142 return Global.getSector().getFaction(Factions.TRITACHYON).getBaseUIColor();
143 }
144
145 public TooltipCreator getMainRowTooltip(BaseEventIntel intel) {
146 return new BaseFactorTooltip() {
147 public void createTooltip(TooltipMakerAPI tooltip, boolean expanded, Object tooltipParam) {
148 float opad = 10f;
149 tooltip.addPara("Your independent polity has become enough of a presence in the Sector to "
150 + "start cutting into the profit margins of the Tri-Tachyon Corporation.", 0f);
151
152 tooltip.addPara("Independent-flagged commerce raiders - little more than sanctioned pirates - "
153 + "have been sighted in your space, "
154 + "attacking trade fleets regardless of their factional allegiance.", opad);
155
156 addDealtSectionToTooltip(tooltip, opad);
157 }
158 };
159 }
160
161 public static void addDealtSectionToTooltip(TooltipMakerAPI tooltip, float opad) {
162 if (isDealtWithMercAttack()) {
163 tooltip.addPara("You've dealt with the mercenary attack sent against you, and " +
164 "this has considerably cooled the enthusiasm for continued aggression. " +
165 "Commerce-raiding continues, but the event progress value is reduced by %s, "
166 + "and no further large-scale attacks are likely to be mounted.", opad,
167 Misc.getHighlightColor(), Strings.X + DEALT_WITH_MERC_PROGRESS_MULT);
168 }
169 }
170
172 return getProgress(intel) > 0;
173 }
174
175
176 public Color getNameColor(float mag) {
177 if (mag <= 0f) {
178 return Misc.getGrayColor();
179 }
180 return Global.getSector().getFaction(Factions.TRITACHYON).getBaseUIColor();
181 }
182
183
184 @Override
185 public int getMaxNumFleets(StarSystemAPI system) {
186 return Global.getSettings().getInt("triTachyonMaxFleets");
187 }
188
189 public CampaignFleetAPI createFleet(StarSystemAPI system, Random random) {
190
191 float f = intel.getMarketPresenceFactor(system);
192
193 // even if magnitude is not factored in, if it's 0 fleets won't spawn
194 // and its value affects the likelihood of tritach fleets spawning
195 //getEffectMagnitude(system);
196
197 int difficulty = 4 + (int) Math.round(f * 4f);
198
199 FleetCreatorMission m = new FleetCreatorMission(random);
200 m.beginFleet();
201
202 Vector2f loc = system.getLocation();
203 String factionId = Factions.TRITACHYON;
204 if (random.nextFloat() < 0.5f) {
205 factionId = Factions.MERCENARY;
206 }
207
208 m.createQualityFleet(difficulty, factionId, loc);
209
210 if (difficulty <= 5) {
211 m.triggerSetFleetQuality(FleetQuality.SMOD_1);
212 } else if (difficulty <= 7) {
213 m.triggerSetFleetQuality(FleetQuality.SMOD_2);
214 } else {
215 m.triggerSetFleetQuality(FleetQuality.SMOD_3);
216 }
217
218 m.triggerSetFleetFaction(Factions.INDEPENDENT);
219 m.triggerSetFleetType(FleetTypes.COMMERCE_RAIDERS);
220
221 m.triggerSetPirateFleet();
222 //m.triggerMakeHostile();
223 m.triggerMakeNonHostileToFaction(Factions.TRITACHYON);
224 m.triggerMakeHostileToAllTradeFleets();
225 m.triggerMakeEveryoneJoinBattleAgainst();
226
227 m.triggerMakeNonHostileToFaction(Factions.PIRATES);
228 m.triggerMakeNoRepImpact();
229 m.triggerFleetAllowLongPursuit();
230
231 m.triggerFleetAddCommanderSkill(Skills.COORDINATED_MANEUVERS, 1);
232 m.triggerFleetAddCommanderSkill(Skills.ELECTRONIC_WARFARE, 1);
233// m.triggerFleetAddCommanderSkill(Skills.FLUX_REGULATION, 1);
234// m.triggerFleetAddCommanderSkill(Skills.PHASE_CORPS, 1);
235// m.triggerFleetAddCommanderSkill(Skills.CARRIER_GROUP, 1);
236
237 m.triggerSetFleetFlag(COMMERCE_RAIDER_FLEET);
238
239 int tugs = 0;
240 if (Factions.MERCENARY.equals(factionId)) {
241 tugs = random.nextInt(3);
242 }
243
244 m.triggerFleetMakeFaster(true, tugs, true);
245 m.triggerSetFleetMaxShipSize(3);
246
247
248 CampaignFleetAPI fleet = m.createFleet();
249
250 return fleet;
251 }
252
253
254
255
256 public void addBulletPointForEvent(HostileActivityEventIntel intel, EventStageData stage, TooltipMakerAPI info,
257 ListInfoMode mode, boolean isUpdate, Color tc, float initPad) {
258 Color c = Global.getSector().getFaction(Factions.TRITACHYON).getBaseUIColor();
259 info.addPara("Impending Tri-Tachyon mercenary attack", initPad, tc, c, "Tri-Tachyon");
260 }
261
262 public void addBulletPointForEventReset(HostileActivityEventIntel intel, EventStageData stage, TooltipMakerAPI info,
263 ListInfoMode mode, boolean isUpdate, Color tc, float initPad) {
264 info.addPara("Tri-Tachyon mercenary attack averted", tc, initPad);
265 }
266
267 public void addStageDescriptionForEvent(HostileActivityEventIntel intel, EventStageData stage, TooltipMakerAPI info) {
268 float small = 0f;
269 float opad = 10f;
270
271 small = 8f;
272
273 Color c = Global.getSector().getFaction(Factions.TRITACHYON).getBaseUIColor();
274
275 Color h = Misc.getHighlightColor();
276 info.addPara("You've received intel that the Tri-Tachyon Corporation is allocating funds to hire and "
277 + "equip a mercenary company to raid and disrupt your industrial base.",
278 small, Misc.getNegativeHighlightColor(), "raid and disrupt your industrial base");
279
280 info.addPara("If the mercenary attack is defeated, it will go a long way towards convincing "
281 + "the Tri-Tachyon Corporation to abandon its anti-competitive efforts.",
282 //opad, tri, "Tri-Tachyon Corporation");
283 opad, h, "abandon its anti-competitive efforts");
284
285 stage.beginResetReqList(info, true, "crisis", opad);
286 info.addPara("The %s is convinced that its efforts are unprofitable", 0f, c, "Tri-Tachyon Corporation");
287 stage.endResetReqList(info, false, "crisis", -1, -1);
288
289 addBorder(info, Global.getSector().getFaction(Factions.TRITACHYON).getBaseUIColor());
290 }
291
292
293 public String getEventStageIcon(HostileActivityEventIntel intel, EventStageData stage) {
294 return Global.getSector().getFaction(Factions.TRITACHYON).getCrest();
295 }
296
297 public TooltipCreator getStageTooltipImpl(final HostileActivityEventIntel intel, final EventStageData stage) {
298 if (stage.id == Stage.HA_EVENT) {
299 return getDefaultEventTooltip("Tri-Tachyon mercenary attack", intel, stage);
300 }
301 return null;
302 }
303
304
305 public float getEventFrequency(HostileActivityEventIntel intel, EventStageData stage) {
306 if (stage.id == Stage.HA_EVENT) {
307
309 return 0f;
310 }
311
313 return 0f;
314 }
315
316 StarSystemAPI target = findExpeditionTarget(intel, stage);
317 MarketAPI source = findExpeditionSource(intel, stage, target);
318 if (target != null && source != null) {
319 return 10f;
320 }
321 }
322 return 0;
323 }
324
325
326 public void rollEvent(HostileActivityEventIntel intel, EventStageData stage) {
327 HAERandomEventData data = new HAERandomEventData(this, stage);
328 stage.rollData = data;
330 }
331
332 public boolean fireEvent(HostileActivityEventIntel intel, EventStageData stage) {
333 StarSystemAPI target = findExpeditionTarget(intel, stage);
334 MarketAPI source = findExpeditionSource(intel, stage, target);
335
336 if (source == null || target == null) {
337 return false;
338 }
339
340 stage.rollData = null;
341 return startMercenaryAttack(source, target, stage, intel, getRandomizedStageRandom(3));
342 }
343
344
345 public static StarSystemAPI findExpeditionTarget(HostileActivityEventIntel intel, EventStageData stage) {
347 CountingMap<StarSystemAPI> counts = new CountingMap<StarSystemAPI>();
348
349 for (CompetitorData curr : data) {
350 for (MarketAPI market : curr.competitorProducers) {
351 StarSystemAPI system = market.getStarSystem();
352 if (system == null) continue;
353 int weight = market.getCommodityData(curr.commodityId).getMaxSupply();
354 counts.add(system, weight);
355 }
356 }
357
358 return counts.getLargest();
359 }
360
361 public static MarketAPI findExpeditionSource(HostileActivityEventIntel intel, EventStageData stage, StarSystemAPI target) {
362 if (getNortia() != null) return getNortia();
363
364
365 CountingMap<MarketAPI> scores = new CountingMap<MarketAPI>();
366 for (MarketAPI market : Misc.getFactionMarkets(Factions.TRITACHYON)) {
367 int size = market.getSize();
368 int weight = size;
369 if (!Misc.isMilitary(market)) weight += size * 10;
370 if (market.hasIndustry(Industries.ORBITALWORKS)) weight += size;
371 if (market.hasIndustry(Industries.HEAVYINDUSTRY)) weight += size;
372
373 scores.add(market, weight);
374 }
375
376 return scores.getLargest();
377 }
378
379 public static MarketAPI getNortia() {
380 MarketAPI nortia = Global.getSector().getEconomy().getMarket("nortia");
381 if (nortia == null || nortia.hasCondition(Conditions.DECIVILIZED)) {
382 return null;
383 }
384 return nortia;
385 }
386
387
388
389
390 public void reportFGIAborted(FleetGroupIntel intel) {
392 TriTachyonCommerceRaiding.addFactorCreateIfNecessary(new TTCRMercenariesDefeatedFactor(), null);
393 }
394
395
396
397 @Override
398 public void notifyFactorRemoved() {
399 Global.getSector().getListenerManager().removeListener(this);
400 }
401
402 public void notifyEventEnding() {
404 }
405
406
407 @Override
408 public void advance(float amount) {
409 super.advance(amount);
410
411 float days = Misc.getDays(amount);
412 recentlyDisrupted.advance(days);
413
414// if (!Global.getSector().getListenerManager().hasListener(this)) {
415// Global.getSector().getListenerManager().addListener(this);
416// }
417
418// System.out.println("LISTENERS:");
419// for (Object o : Global.getSector().getListenerManager().getListeners(Object.class)) {
420// System.out.println("Listener: " + o.getClass().getSimpleName() + " [" + o.hashCode() + "]");
421// }
422// System.out.println("-----");
423// System.out.println("-----");
424// System.out.println("-----");
425// System.out.println("-----");
426
427 EventStageData stage = intel.getDataFor(Stage.HA_EVENT);
428 if (stage != null && stage.rollData instanceof HAERandomEventData &&
429 ((HAERandomEventData)stage.rollData).factor == this) {
432 }
433 }
434 if (isPlayerCounterRaidedTriTach() && TTMercenaryAttack.get() != null) {
435 TTMercenaryAttack.get().finish(false);
436 }
437 }
438
439
440 public static StarSystemAPI getPrimaryTriTachyonSystem() {
441 CountingMap<StarSystemAPI> counts = new CountingMap<StarSystemAPI>();
442 for (MarketAPI market : Global.getSector().getEconomy().getMarketsCopy()) {
443 if (!Factions.TRITACHYON.equals(market.getFactionId())) continue;
444 StarSystemAPI system = market.getStarSystem();
445 if (system == null) continue;
446 int size = market.getSize();
447 int weight = size;
448 if (Misc.isMilitary(market)) weight += size;
449 if (market.hasIndustry(Industries.ORBITALWORKS)) weight += size;
450 if (market.hasIndustry(Industries.HEAVYINDUSTRY)) weight += size;
451
452 counts.add(system, weight);
453 }
454 return counts.getLargest();
455 }
456
457
458 public boolean startMercenaryAttack(MarketAPI source, StarSystemAPI target,
459 EventStageData stage, HostileActivityEventIntel intel, Random random) {
460 if (isPlayerCounterRaidedTriTach()) return false;
461 if (source == null || target == null) return false;
462
463 GenericRaidParams params = new GenericRaidParams(new Random(random.nextLong()), true);
464 params.makeFleetsHostile = false; // will be made hostile when they arrive, not before
465 params.source = source;
466
467 params.prepDays = 21f + random.nextFloat() * 7f;
468 params.payloadDays = 27f + 7f * random.nextFloat();
469
470 params.raidParams.where = target;
471 params.raidParams.type = FGRaidType.SEQUENTIAL;
472
473 Set<String> disrupt = new LinkedHashSet<String>();
474 for (MarketAPI market : Misc.getMarketsInLocation(target, Factions.PLAYER)) {
475 params.raidParams.allowedTargets.add(market);
476 params.raidParams.allowNonHostileTargets = true;
477 for (Industry ind : market.getIndustries()) {
478 if (ind.getSpec().hasTag(Industries.TAG_UNRAIDABLE)) continue;
479 disrupt.add(ind.getId());
480
481 }
482 }
483
484 params.raidParams.disrupt.addAll(disrupt);
485 params.raidParams.raidsPerColony = Math.min(disrupt.size(), 4);
486 if (disrupt.isEmpty()) {
487 params.raidParams.raidsPerColony = 2;
488 }
489
490 if (params.raidParams.allowedTargets.isEmpty()) {
491 return false;
492 }
493
494 params.factionId = Factions.INDEPENDENT;
495 params.style = FleetStyle.QUALITY;
496 params.repImpact = ComplicationRepImpact.NONE;
497
498
499 float fleetSizeMult = 1f;
500
501 float f = intel.getMarketPresenceFactor(target);
502
503 float totalDifficulty = fleetSizeMult * 50f * (0.5f + 0.5f * f);
504
505 totalDifficulty -= 10;
506 params.fleetSizes.add(10); // first size 10 pick becomes the Operational Command
507
508 while (totalDifficulty > 0) {
509 int min = 3;
510 int max = 8;
511
512 //int diff = Math.round(StarSystemGenerator.getNormalRandom(random, min, max));
513 int diff = min + random.nextInt(max - min + 1);
514
515 params.fleetSizes.add(diff);
516 totalDifficulty -= diff;
517 }
518
519 TTMercenaryAttack attack = new TTMercenaryAttack(params);
520 attack.setListener(this);
521 //attack.setPreFleetDeploymentDelay(30f + random.nextFloat() * 60f);
522 //attack.setPreFleetDeploymentDelay(1f);
523 Global.getSector().getIntelManager().addIntel(attack, false);
524
525 return true;
526 }
527
528
529
530 public void reportFleetDespawnedToListener(CampaignFleetAPI fleet, FleetDespawnReason reason, Object param) {
531
532 }
533 public void reportBattleOccurred(CampaignFleetAPI fleet, CampaignFleetAPI primaryWinner, BattleAPI battle) {
534 if (isPlayerCounterRaidedTriTach()) return;
535
536 if (!battle.isPlayerInvolved()) return;
537
538 if (getProgress(null) <= 0 && TriTachyonCommerceRaiding.get() == null) return;
539
540 int traderFP = 0;
541 int raiderFP = 0;
542 for (CampaignFleetAPI otherFleet : battle.getNonPlayerSideSnapshot()) {
543 //if (!Global.getSector().getPlayerFaction().isHostileTo(otherFleet.getFaction())) continue;
544 boolean trader = isTraderServingATTColony(otherFleet);
545 boolean raider = isCommerceRaider(otherFleet);
546
547 if (!trader && !raider) continue;
548
549 int mult = 1;
550 if (trader) mult = TTCRPoints.TRADE_FLEET_FP_MULT;
551
552 for (FleetMemberAPI loss : Misc.getSnapshotMembersLost(otherFleet)) {
553 int fp = loss.getFleetPointCost() * mult;
554 if (trader) {
555 traderFP += fp;
556 } else if (raider) {
557 raiderFP += fp;
558 }
559 }
560 }
561
562 if (traderFP > 0) {
563 int points = computeTTCRProgressPoints(traderFP);
564 if (points > 0) {
565 TTCRTradeFleetsDestroyedFactor factor = new TTCRTradeFleetsDestroyedFactor(points);
566 TriTachyonCommerceRaiding.addFactorCreateIfNecessary(factor, null);
567 }
568 }
569 if (raiderFP > 0) {
570 int points = computeTTCRProgressPoints(raiderFP);
571 if (points > 0) {
572 TTCRCommerceRaidersDestroyedFactor factor = new TTCRCommerceRaidersDestroyedFactor(points);
573 TriTachyonCommerceRaiding.addFactorCreateIfNecessary(factor, null);
574 }
575 }
576 }
577
578 public static boolean isCommerceRaider(CampaignFleetAPI fleet) {
579 return fleet.getMemoryWithoutUpdate().getBoolean(TriTachyonHostileActivityFactor.COMMERCE_RAIDER_FLEET);
580 }
581 public static boolean isTraderServingATTColony(CampaignFleetAPI fleet) {
582 boolean trader = Misc.isTrader(fleet);
583 boolean smuggler = Misc.isSmuggler(fleet);
584
585 if (!trader && !smuggler) return false;
586
587 RouteData route = RouteManager.getInstance().getRoute(EconomyFleetRouteManager.SOURCE_ID, fleet);
588 if (route == null) return false;
589
590 EconomyRouteData data = (EconomyRouteData) route.getCustom();
591 if (data == null) return false;
592
593 if (data.from != null && Factions.TRITACHYON.equals(data.from.getFactionId())) {
594 return true;
595 }
596 if (data.to != null && Factions.TRITACHYON.equals(data.to.getFactionId())) {
597 return true;
598 }
599
600 return false;
601 }
602
603 public static int computeTTCRProgressPoints(float fleetPointsDestroyed) {
604 if (fleetPointsDestroyed <= 0) return 0;
605
606 int points = Math.round(fleetPointsDestroyed / (float) TTCRPoints.FP_PER_POINT);
607 if (points < 1) points = 1;
608 return points;
609 }
610
611 public static int computeIndustryDisruptPoints(Industry ind) {
612 float base = ind.getSpec().getDisruptDanger().disruptionDays;
613 float per = TTCRPoints.BASE_POINTS_FOR_INDUSTRY_DISRUPT;
614
615 float days = ind.getDisruptedDays();
616
617 int points = (int) Math.round(days / base * per);
618 if (points > TTCRPoints.MAX_POINTS_FOR_INDUSTRY_DISRUPT) {
619 points = TTCRPoints.MAX_POINTS_FOR_INDUSTRY_DISRUPT;
620 }
621 return points;
622 }
623
624 public void reportRaidForValuablesFinishedBeforeCargoShown(InteractionDialogAPI dialog, MarketAPI market,
625 TempData actionData, CargoAPI cargo) {
626
627 }
628 public void reportRaidToDisruptFinished(InteractionDialogAPI dialog, MarketAPI market, TempData actionData,
629 Industry industry) {
630 if (isPlayerCounterRaidedTriTach()) return;
631 if (getProgress(null) <= 0 && TriTachyonCommerceRaiding.get() == null) return;
632
633 if (market != null && Factions.TRITACHYON.equals(market.getFactionId())) {
634 applyIndustryDisruptionToTTCR(industry, dialog);
635 }
636 }
637 public void reportTacticalBombardmentFinished(InteractionDialogAPI dialog, MarketAPI market, TempData actionData) {
638 if (isPlayerCounterRaidedTriTach()) return;
639 if (getProgress(null) <= 0 && TriTachyonCommerceRaiding.get() == null) return;
640
641 if (market != null && Factions.TRITACHYON.equals(market.getFactionId())) {
642 applyMassIndustryDisruptionToTTCR(market, dialog);
643 }
644 }
645 public void reportSaturationBombardmentFinished(InteractionDialogAPI dialog, MarketAPI market,
646 TempData actionData) {
647 if (isPlayerCounterRaidedTriTach()) return;
648 if (getProgress(null) <= 0 && TriTachyonCommerceRaiding.get() == null) return;
649
650 if (market != null && Factions.TRITACHYON.equals(market.getFactionId())) {
651 applyMassIndustryDisruptionToTTCR(market, dialog);
652 }
653 }
654
655 public void applyMassIndustryDisruptionToTTCR(MarketAPI market, InteractionDialogAPI dialog) {
656 if (isPlayerCounterRaidedTriTach()) return;
657 if (getProgress(null) <= 0 && TriTachyonCommerceRaiding.get() == null) return;
658
659 int points = 0;
660 for (Industry industry : market.getIndustries()) {
661 if (recentlyDisrupted.contains(industry)) continue;
662 if (industry.getSpec().hasTag(Industries.TAG_UNRAIDABLE)) continue;
663
664 int curr = computeIndustryDisruptPoints(industry);
665 if (curr > 0) {
666 points += curr;
667 recentlyDisrupted.add(industry, industry.getDisruptedDays());
668 }
669 }
670
671 if (points > 0) {
672 TTCRIndustryDisruptedFactor factor = new TTCRIndustryDisruptedFactor(
673 "Disrupted industries " + market.getOnOrAt() + " " + market.getName(), points);
674 TriTachyonCommerceRaiding.addFactorCreateIfNecessary(factor, dialog);
675 }
676 }
677 public void applyIndustryDisruptionToTTCR(Industry industry, InteractionDialogAPI dialog) {
678 if (isPlayerCounterRaidedTriTach()) return;
679 if (getProgress(null) <= 0 && TriTachyonCommerceRaiding.get() == null) return;
680
681 if (!recentlyDisrupted.contains(industry)) {
682 if (industry.getSpec().hasTag(Industries.TAG_UNRAIDABLE)) return;
683 MarketAPI market = industry.getMarket();
684 if (market == null) return;
685
686 int points = computeIndustryDisruptPoints(industry);
687 if (points > 0) {
688 TTCRIndustryDisruptedFactor factor = new TTCRIndustryDisruptedFactor(
689 industry.getCurrentName() + " " + market.getOnOrAt() + " " + market.getName() +
690 " disrupted", points);
691 TriTachyonCommerceRaiding.addFactorCreateIfNecessary(factor, dialog);
692 recentlyDisrupted.add(industry, industry.getDisruptedDays());
693 }
694 }
695 }
696 @Override
698 return super.getNameColorForThreatList();
699 }
700
701
702}
703
704
705
706
static SettingsAPI getSettings()
Definition Global.java:51
static SectorAPI getSector()
Definition Global.java:59
void sendUpdateIfPlayerHasIntel(Object listInfoParam, TextPanelAPI textPanel)
static boolean checkFactionExists(String factionId, boolean requireMilitary)
TooltipCreator getDefaultEventTooltip(final String title, final HostileActivityEventIntel intel, final EventStageData stage)
void reportFleetDespawnedToListener(CampaignFleetAPI fleet, FleetDespawnReason reason, Object param)
void reportTacticalBombardmentFinished(InteractionDialogAPI dialog, MarketAPI market, TempData actionData)
void reportBattleOccurred(CampaignFleetAPI fleet, CampaignFleetAPI primaryWinner, BattleAPI battle)
void reportRaidToDisruptFinished(InteractionDialogAPI dialog, MarketAPI market, TempData actionData, Industry industry)
void addStageDescriptionForEvent(HostileActivityEventIntel intel, EventStageData stage, TooltipMakerAPI info)
void reportRaidForValuablesFinishedBeforeCargoShown(InteractionDialogAPI dialog, MarketAPI market, TempData actionData, CargoAPI cargo)
void reportSaturationBombardmentFinished(InteractionDialogAPI dialog, MarketAPI market, TempData actionData)
void addBulletPointForEventReset(HostileActivityEventIntel intel, EventStageData stage, TooltipMakerAPI info, ListInfoMode mode, boolean isUpdate, Color tc, float initPad)
TooltipCreator getStageTooltipImpl(final HostileActivityEventIntel intel, final EventStageData stage)
static StarSystemAPI findExpeditionTarget(HostileActivityEventIntel intel, EventStageData stage)
static MarketAPI findExpeditionSource(HostileActivityEventIntel intel, EventStageData stage, StarSystemAPI target)
void addBulletPointForEvent(HostileActivityEventIntel intel, EventStageData stage, TooltipMakerAPI info, ListInfoMode mode, boolean isUpdate, Color tc, float initPad)
boolean startMercenaryAttack(MarketAPI source, StarSystemAPI target, EventStageData stage, HostileActivityEventIntel intel, Random random)