458 public boolean execute(String ruleId, InteractionDialogAPI dialog, List<Token> params, Map<String, MemoryAPI> memoryMap) {
459 if (dialog ==
null)
return false;
461 OptionPanelAPI options = dialog.getOptionPanel();
462 TextPanelAPI text = dialog.getTextPanel();
464 other = dialog.getInteractionTarget();
465 CargoAPI cargo = pf.getCargo();
468 String action = params.get(0).getString(memoryMap);
470 MemoryAPI memory = memoryMap.get(MemKeys.LOCAL);
471 if (memory ==
null)
return false;
475 StarSystemAPI system =
null;
476 if (dialog.getInteractionTarget().getContainingLocation() instanceof StarSystemAPI) {
477 system = (StarSystemAPI) dialog.getInteractionTarget().getContainingLocation();
480 if (
"baseInvolved".equals(action)) {
481 if (system ==
null)
return false;
482 PirateBaseIntel base = PirateBaseIntel.getIntelFor(dialog.getInteractionTarget());
483 if (base ==
null)
return false;
486 }
else if (
"addStationKingScript".equals(action)) {
488 PirateBaseIntel base = PirateBaseIntel.getIntelFor(dialog.getInteractionTarget());
489 if (base ==
null)
return false;
490 base.getSystem().addScript(
new StationKingScript(base));
495 HostileActivityEventIntel ha = HostileActivityEventIntel.get();
497 int tier = base.getTier().ordinal();
498 if (tier < 0) tier = 0;
499 if (tier > 4) tier = 4;
501 HAPirateKingDealFactor factor =
new HAPirateKingDealFactor(points);
502 ha.addFactor(factor, dialog);
505 Misc.adjustRep(base.getBaseCommander(), RepRewards.HIGH, text);
506 Misc.adjustRep(base.getBaseCommander().getFaction().getId(), RepRewards.MEDIUM, text);
507 }
else if (
"endStationKingDeal".equals(action)) {
508 PirateBaseIntel base = PirateBaseIntel.getIntelFor(dialog.getInteractionTarget());
509 if (base ==
null)
return false;
511 if (curr instanceof StationKingScript) {
512 StationKingScript script = (StationKingScript) curr;
513 script.endDeal(
true, dialog);
518 }
else if (
"playerColoniesHavePatherActvity".equals(action)) {
519 for (MarketAPI market : Misc.getPlayerMarkets(
false)) {
520 float interest = LuddicPathBaseManager.getLuddicPathMarketInterest(market);
521 if (market.hasCondition(Conditions.PATHER_CELLS) && interest > 0) {
532 }
else if (
"payMegaTithe".equals(action)) {
533 int megaTithe = memory.getInt(
"$LP_megaTithe");
534 int dur = memory.getInt(
"$LP_megaTitheDuration");
535 cargo.getCredits().subtract(megaTithe);
537 if (cargo.getCredits().get() <= 0) {
538 cargo.getCredits().set(0);
541 LuddicPathHostileActivityFactor.avertOrAbortAttack();
543 final String factionId = Factions.LUDDIC_PATH;
544 float range = 100000f;
545 List<CampaignFleetAPI> fleets = Misc.findNearbyFleets(pf, range,
new FleetFilter() {
546 public boolean accept(CampaignFleetAPI curr) {
547 return curr.getFaction().getId().equals(factionId);
551 for (CampaignFleetAPI curr : fleets) {
552 if (curr.getAI() !=
null) {
553 curr.getAI().setActionTextOverride(
null);
555 if (curr.getAI() instanceof ModularFleetAIAPI) {
556 ModularFleetAIAPI mAI = (ModularFleetAIAPI) curr.getAI();
557 mAI.getTacticalModule().forceTargetReEval();
559 Misc.giveStandardReturnToSourceAssignments(curr,
true);
562 HostileActivityEventIntel ha = HostileActivityEventIntel.get();
565 HALuddicPathDealFactor factor =
new HALuddicPathDealFactor(points);
566 ha.addFactor(factor, dialog);
570 }
else if (
"gavePKToPather".equals(action)) {
571 HostileActivityEventIntel ha = HostileActivityEventIntel.get();
574 HALuddicPathDealFactor factor =
new HALuddicPathDealFactor(points);
575 ha.addFactor(factor, dialog);
577 LuddicPathHostileActivityFactor.avertOrAbortAttack();
578 }
else if (
"computeMegaTithe".equals(action)) {
579 float credits = cargo.getCredits().get();
581 float normalTithe = (int)
Global.
getSector().getPlayerFleet().getFleetPoints() * 200;
588 for (MarketAPI market : Misc.getPlayerMarkets(
false)) {
589 float interest = LuddicPathBaseManager.getLuddicPathMarketInterest(market);
590 interest += market.getSize();
591 tithe += interest * market.getSize() * tithePerPointPerColonySize;
594 tithe += normalTithe;
596 tithe = (int) Misc.getRounded(tithe);
598 memoryMap.get(MemKeys.LOCAL).set(
"$LP_megaTithe", (
int)tithe, 0);
599 memoryMap.get(MemKeys.LOCAL).set(
"$LP_megaTitheDGS", Misc.getWithDGS(tithe), 0);
600 memoryMap.get(MemKeys.LOCAL).set(
"$LP_megaTitheDuration", titheDuration, 0);
603 }
else if (
"kazeronInstallNanoforge".equals(action)) {
604 MarketAPI kazeron = PerseanLeagueHostileActivityFactor.getKazeron(
false);
605 if (kazeron !=
null) {
606 SpecialItemData data =
new SpecialItemData(Items.PRISTINE_NANOFORGE,
null);
607 for (Industry ind : kazeron.getIndustries()) {
608 if (ind.wantsToUseSpecialItem(data)) {
609 ind.setSpecialItem(data);
614 }
else if (
"kazeronNanoforgeMissing".equals(action)) {
615 MarketAPI kazeron = PerseanLeagueHostileActivityFactor.getKazeron(
false);
616 if (kazeron ==
null)
return true;
617 for (Industry ind : kazeron.getIndustries()) {
618 if (ind.getSpecialItem() ==
null)
continue;
619 if (ind.getSpecialItem().getId().equals(Items.PRISTINE_NANOFORGE)) {
624 }
else if (
"stopPayingHouseHannan".equals(action)) {
625 PerseanLeagueMembership.stopPayingHouseHannan(params.get(1).getBoolean(memoryMap), dialog);
628 }
else if (
"leaveLeague".equals(action)) {
629 PerseanLeagueMembership m = PerseanLeagueMembership.get();
633 PerseanLeagueMembership.stopPayingHouseHannan(
false, dialog);
635 m.endMembership(AgreementEndingType.ENDED, dialog);
638 }
else if (
"printTriTachDealRepReq".equals(action)) {
639 FactionAPI triTach =
Global.
getSector().getFaction(Factions.TRITACHYON);
642 }
else if (
"isTTCRInProgress".equals(action)) {
643 return TriTachyonCommerceRaiding.get() !=
null;
644 }
else if (
"isTTRaidingPlayerCommerce".equals(action)) {
645 HostileActivityEventIntel intel = HostileActivityEventIntel.get();
647 EventFactor factor = intel.getFactorOfClass(TriTachyonHostileActivityFactor.class);
648 if (factor instanceof TriTachyonHostileActivityFactor) {
649 TriTachyonHostileActivityFactor ttFactor = (TriTachyonHostileActivityFactor) factor;
650 return ttFactor.getProgress(intel) > 0;
653 }
else if (
"makeTriTachDeal".equals(action)) {
654 if (TriTachyonDeal.get() ==
null) {
655 new TriTachyonDeal(dialog);
657 }
else if (
"breakTriTachDeal".equals(action)) {
658 if (TriTachyonDeal.get() !=
null) {
659 TriTachyonDeal.get().endAgreement(com.fs.starfarer.api.impl.campaign.intel.TriTachyonDeal.AgreementEndingType.BROKEN, dialog);
661 }
else if (
"printLCDealRepReq".equals(action)) {
662 FactionAPI luddicChurch =
Global.
getSector().getFaction(Factions.LUDDIC_CHURCH);
665 }
else if (
"breakLCDeal".equals(action)) {
666 if (LuddicChurchImmigrationDeal.get() !=
null) {
667 LuddicChurchImmigrationDeal.get().endAgreement(com.fs.starfarer.api.impl.campaign.intel.LuddicChurchImmigrationDeal.AgreementEndingType.BROKEN, dialog);
669 }
else if (
"KOLTakeoverInProgress".equals(action)) {
671 }
else if (
"makeLuddicChurchDeal".equals(action)) {
672 if (LuddicChurchImmigrationDeal.get() ==
null) {
673 new LuddicChurchImmigrationDeal(dialog);
675 }
else if (
"joinLeague".equals(action)) {
676 new PerseanLeagueMembership(dialog);
679 HegemonyHostileActivityFactor.avertInspectionIfNotInProgress();
680 }
else if (
"canJoinLeague".equals(action)) {
682 }
else if (
"isPLExpeditionInProgress".equals(action)) {
684 }
else if (
"isPLProtectingPlayerSpace".equals(action)) {
685 HostileActivityEventIntel intel = HostileActivityEventIntel.get();
687 EventFactor factor = intel.getFactorOfClass(PerseanLeagueHostileActivityFactor.class);
688 if (factor instanceof PerseanLeagueHostileActivityFactor) {
689 PerseanLeagueHostileActivityFactor plFactor = (PerseanLeagueHostileActivityFactor) factor;
690 return plFactor.getProgress(intel) > 0;
693 }
else if (
"canSendPLPunitiveExpedition".equals(action)) {
695 }
else if (
"updateLeagueData".equals(action)) {
699 memoryMap.get(MemKeys.LOCAL).set(
"$plDuesPercent", (
int)Math.round(duesF * 100f) +
"%", 0);
700 memoryMap.get(MemKeys.LOCAL).set(
"$hannanBribePercent", (
int)Math.round(hannanF * 100f) +
"%", 0);
703 }
else if (
"canRemakeDealWithHouseHannan".equals(action)) {
704 return GensHannanMachinations.canRemakeDealWithHouseHannan();
705 }
else if (
"endGHMachinations".equals(action)) {
706 GensHannanMachinations m = GensHannanMachinations.get();
708 m.endMachinations(text);
710 }
else if (
"doKOLTTakeover".equals(action)) {
711 KnightsOfLuddTakeoverExpedition takeover = KnightsOfLuddTakeoverExpedition.get();
712 if (takeover !=
null) {
713 takeover.performTakeover(
true);
715 }
else if (
"updateKOLTArmadaData".equals(action)) {
716 KnightsOfLuddTakeoverExpedition takeover = KnightsOfLuddTakeoverExpedition.get();
717 if (takeover !=
null) {
718 MemoryAPI mem = memoryMap.get(MemKeys.LOCAL);
719 mem.set(
"$KOLT_target", takeover.getBlockadeParams().specificMarket.getName());
722 }
else if (
"updateTTMAData".equals(action)) {
723 MemoryAPI mem = memoryMap.get(MemKeys.LOCAL);
730 TTMercenaryAttack attack = TTMercenaryAttack.get();
731 StarSystemAPI target = TriTachyonHostileActivityFactor.getPrimaryTriTachyonSystem();
732 boolean reversible = attack !=
null && !attack.isSpawning() && !attack.isFailed() &&
733 !attack.isSucceeded() && !attack.isAborted() && !attack.isEnding() && !attack.isEnded() &&
736 mem.set(
"$attackReversible", reversible);
737 if (target !=
null) {
738 mem.set(
"$triTachSystem", target.getNameWithLowercaseTypeShort());
742 }
else if (
"retargetTTMA".equals(action)) {
743 TTMercenaryReversedAttack.sendReversedAttack(dialog);
744 }
else if (
"computeSacredProtectorsData".equals(action)) {
745 MemoryAPI mem = memoryMap.get(MemKeys.LOCAL);
746 int supplies = (int)
Global.
getSector().getPlayerFleet().getFleetPoints() * 1;
747 mem.set(
"$SP_supplies", (
int)supplies, 0);
749 }
else if (
"sacredProtectorsCheckCargoPods".equals(action)) {
750 MemoryAPI mem = memoryMap.get(MemKeys.LOCAL);
751 int supplies = mem.getInt(
"$SP_supplies");
753 }
else if (
"knightsHasslingPlayerColonies".equals(action)) {
754 HostileActivityEventIntel intel = HostileActivityEventIntel.get();
756 HostileActivityCause2 cause = intel.getActivityCause(LuddicChurchHostileActivityFactor.class, LuddicChurchStandardActivityCause.class);
757 if (cause instanceof LuddicChurchStandardActivityCause) {
758 LuddicChurchStandardActivityCause lcCause = (LuddicChurchStandardActivityCause) cause;
759 return lcCause.getProgress() > 0;
762 }
else if (
"printSDDealRepReq".equals(action)) {
766 }
else if (
"breakSDDeal".equals(action)) {
767 if (SindrianDiktatFuelDeal.get() !=
null) {
768 SindrianDiktatFuelDeal.get().endAgreement(com.fs.starfarer.api.impl.campaign.intel.SindrianDiktatFuelDeal.AgreementEndingType.BROKEN, dialog);
770 }
else if (
"makeDiktatDeal".equals(action)) {
771 if (SindrianDiktatFuelDeal.get() ==
null) {
772 new SindrianDiktatFuelDeal(dialog);
774 }
else if (
"diktatConcernedByFuelProd".equals(action)) {
775 HostileActivityEventIntel intel = HostileActivityEventIntel.get();
777 HostileActivityCause2 cause = intel.getActivityCause(SindrianDiktatHostileActivityFactor.class, SindrianDiktatStandardActivityCause.class);
778 if (cause instanceof SindrianDiktatStandardActivityCause) {
779 SindrianDiktatStandardActivityCause lcCause = (SindrianDiktatStandardActivityCause) cause;
780 return lcCause.getProgress() > 0;
966 GenericRaidParams params =
new GenericRaidParams(
new Random(),
true);
967 params.factionId = data.kazeron.getFactionId();
968 params.source = data.kazeron;
970 Random random =
new Random();
972 params.prepDays = 14f + random.nextFloat() * 14f;
973 params.payloadDays = 27f + 7f * random.nextFloat();
975 params.raidParams.where = data.target;
977 Set<String> disrupt =
new LinkedHashSet<String>();
978 for (MarketAPI market : Misc.getMarketsInLocation(data.target, Factions.PLAYER)) {
979 params.raidParams.allowedTargets.add(market);
980 params.raidParams.allowNonHostileTargets =
true;
981 for (Industry ind : market.getIndustries()) {
982 if (ind.getSpec().hasTag(Industries.TAG_UNRAIDABLE))
continue;
983 disrupt.add(ind.getId());
991 params.raidParams.disrupt.addAll(disrupt);
992 params.raidParams.raidsPerColony = Math.min(disrupt.size(), 4);
993 if (disrupt.isEmpty()) {
994 params.raidParams.raidsPerColony = 2;
997 if (params.raidParams.allowedTargets.isEmpty()) {
1001 params.style = FleetStyle.STANDARD;
1004 float fleetSizeMult = data.kazeron.getStats().getDynamic().getMod(Stats.COMBAT_FLEET_SIZE_MULT).computeEffective(0f);
1006 float f = data.intel.getMarketPresenceFactor(data.target);
1008 float totalDifficulty = fleetSizeMult * 50f * (0.5f + 0.5f * f);
1009 if (totalDifficulty < 30) {
1012 if (totalDifficulty > 100) {
1013 totalDifficulty = 100;
1016 Random r = data.intel.getRandom();
1019 while (totalDifficulty > 0) {
1023 if (r.nextFloat() > 0.3f) {
1024 min = (int) Math.min(totalDifficulty, 8f);
1025 max = (int) Math.min(totalDifficulty, 10f);
1028 int diff = Math.round(StarSystemGenerator.getNormalRandom(r, min, max));
1030 params.fleetSizes.add(diff);
1031 totalDifficulty -= diff;
1034 PerseanLeaguePunitiveExpedition punex =
new PerseanLeaguePunitiveExpedition(params);
1035 punex.setPreFleetDeploymentDelay(30f + random.nextFloat() * 60f);
1037 TextPanelAPI text = dialog ==
null ? null : dialog.getTextPanel();