Starsector API
Loading...
Searching...
No Matches
GATransverseJump.java
Go to the documentation of this file.
1package com.fs.starfarer.api.impl.campaign.missions.academy;
2
3import java.awt.Color;
4import java.util.List;
5import java.util.Map;
6
7import com.fs.starfarer.api.Global;
8import com.fs.starfarer.api.campaign.CampaignFleetAPI;
9import com.fs.starfarer.api.campaign.InteractionDialogAPI;
10import com.fs.starfarer.api.campaign.PlanetAPI;
11import com.fs.starfarer.api.campaign.SectorEntityToken;
12import com.fs.starfarer.api.campaign.StarSystemAPI;
13import com.fs.starfarer.api.campaign.econ.MarketAPI;
14import com.fs.starfarer.api.campaign.rules.MemoryAPI;
15import com.fs.starfarer.api.characters.PersonAPI;
16import com.fs.starfarer.api.impl.campaign.ids.Factions;
17import com.fs.starfarer.api.impl.campaign.ids.FleetTypes;
18import com.fs.starfarer.api.impl.campaign.ids.Ranks;
19import com.fs.starfarer.api.impl.campaign.ids.Tags;
20import com.fs.starfarer.api.impl.campaign.missions.hub.ReqMode;
21import com.fs.starfarer.api.impl.campaign.rulecmd.salvage.special.TransmitterTrapSpecial;
22import com.fs.starfarer.api.ui.TooltipMakerAPI;
23import com.fs.starfarer.api.util.Misc;
24import com.fs.starfarer.api.util.Misc.Token;
25
26public class GATransverseJump extends GABaseMission {
27
28 public static enum Stage {
29 GO_TO_OUTPOST,
30 RETURN_TO_ACADEMY,
31 COMPLETED,
32 FAILED,
33 }
34
35 //public static List<SectorEntityToken> system_jumppoints;
36
37 protected StarSystemAPI system;
38 protected PlanetAPI planet;
39 protected PersonAPI researcher;
40
41 @Override
42 protected boolean create(MarketAPI createdAt, boolean barEvent) {
43 // replaced this with "non_repeatable" tag in person_missions.csv
44 // if this mission was EVER completed by the player, abort!
45 //if (getCreator().getNumCompleted() > 0) return false;
46
47 // if this mission type was already accepted by the player, abort
48 if (!setGlobalReference("$gaTJ_ref")) {
49 return false;
50 }
51
52 //genRandom = Misc.random; // for testing purposes to roll new search results each time
53
54 resetSearch();
55 // expanded from just THEME_MISC
56 // since the various jump point-related requirements narrows down the valid options
57 requireSystemTags(ReqMode.ANY, Tags.THEME_MISC, Tags.THEME_MISC_SKIP, Tags.THEME_RUINS);
58 requireSystemTags(ReqMode.NOT_ANY, Tags.THEME_UNSAFE, Tags.THEME_CORE);
59 requireSystemNotAlreadyUsedForStory();
60 requireSystemNotHasPulsar();
61 requireSystemHasAtLeastNumJumpPoints(2);
62 preferSystemHasAtLeastNumJumpPoints(3);
63 preferSystemOnFringeOfSector();
64 preferSystemUnexplored();
65 //preferSystemInDirectionOfOtherMissions();
66 requirePlanetNotStar();
67 requirePlanetUnpopulated();
68 requirePlanetNotGasGiant();
69 preferPlanetNotNearJumpPoint(5000f);
70 preferPlanetNotNearJumpPoint(2000f);
71 preferPlanetNotFullySurveyed();
72
73 planet = pickPlanet();
74
75 if (planet == null) {
76 return false;
77 }
78
79 system = planet.getStarSystem();
80
81 setStartingStage(Stage.GO_TO_OUTPOST);
82 addSuccessStages(Stage.COMPLETED);
83 addFailureStages(Stage.FAILED);
84
85 setStoryMission();
86
87 makeImportant(planet, "$gaTJ_targetPlanet", Stage.GO_TO_OUTPOST);
88 makeImportant(getPerson(), "$gaTJ_needToReturn", Stage.RETURN_TO_ACADEMY);
89
90 connectWithGlobalFlag(Stage.GO_TO_OUTPOST, Stage.RETURN_TO_ACADEMY, "$gaTJ_needToReturn");
91 setStageOnGlobalFlag(Stage.COMPLETED, "$gaTJ_completed");
92
93
94 setCreditReward(CreditReward.HIGH);
95
96 researcher = Global.getSector().getFaction(Factions.INDEPENDENT).createRandomPerson(genRandom);
97 researcher.setRankId(Ranks.CITIZEN);
98 researcher.setPostId(Ranks.POST_ACADEMICIAN);
99
100 // Tri-Tach black ops merc patrol(s) spawn
101 // ideally spawned to guard all possible system jump-points
102 // then, once player grabs Baird's spy, they all move to planet and start search pattern
103
104 List<SectorEntityToken> jumpPoints = system.getJumpPoints();
105 for (SectorEntityToken point : jumpPoints) {
106 addMercFleet(point);
107 }
108
109 beginStageTrigger(Stage.COMPLETED);
110 triggerSetGlobalMemoryValuePermanent("$asebSayBairdWantsToTalk", true);
111 endTrigger();
112
113 setSystemWasUsedForStory(Stage.GO_TO_OUTPOST, system);
114
115 return true;
116 }
117
118 @Override
119 protected boolean callAction(String action, String ruleId, InteractionDialogAPI dialog, List<Token> params,
120 Map<String, MemoryAPI> memoryMap) {
121 if (dialog != null && action.equals("showResearcher")) {
122 showPersonInfo(researcher, dialog, false, false);
123 return true;
124 }
125 if ("triggerMercFleets".equals(action)) {
126 for (CampaignFleetAPI fleet : system.getFleets()) {
127 if (fleet.getMemoryWithoutUpdate().contains("$gaTJ_merc")) {
128 TransmitterTrapSpecial.makeFleetInterceptPlayer(fleet, true, false, true, 1000f);
129 }
130 }
131
132 return true;
133 }
134 return false;
135 }
136
137 protected void updateInteractionDataImpl() {
138 set("$gaTJ_planetId", planet.getId());
139 set("$gaTJ_planetName", planet.getName());
140 set("$gaTJ_systemName", planet.getStarSystem().getNameWithNoType());
141 set("$gaTJ_dist", getDistanceLY(planet));
142 set("$gaTJ_reward", Misc.getWithDGS(getCreditsReward()));
143 set("$gaTJ_researcherName", researcher.getNameString());
144 set("$gaTJ_heOrShe", researcher.getHeOrShe());
145 set("$gaTJ_HeOrShe", researcher.getHeOrShe().substring(0, 1).toUpperCase() + researcher.getHeOrShe().substring(1));
146 set("$gaTJ_hisOrHer", researcher.getHisOrHer());
147 set("$gaTJ_HisOrHet", researcher.getHisOrHer().substring(0, 1).toUpperCase() + researcher.getHisOrHer().substring(1));
148 set("$gaTJ_himOrHer", researcher.getHimOrHer());
149 set("$gaTJ_HimOrHet", researcher.getHimOrHer().substring(0, 1).toUpperCase() + researcher.getHimOrHer().substring(1));
150
151 }
152
153 @Override
154 public void addDescriptionForNonEndStage(TooltipMakerAPI info, float width, float height) {
155 float opad = 10f;
156 Color h = Misc.getHighlightColor();
157 if (currentStage == Stage.GO_TO_OUTPOST) {
158 info.addPara(getGoToPlanetTextPre(planet) +
159 ", and contact the 'researcher' at the Tri-Tachyon black research site located there.", opad);
160 } else if (currentStage == Stage.RETURN_TO_ACADEMY) {
161 // shared way to get the same text to ensure consistency across different missions
162 info.addPara(getReturnText("the Galatia Academy") + ".", opad);
163 }
164 }
165
166 @Override
167 public boolean addNextStepText(TooltipMakerAPI info, Color tc, float pad) {
168 Color h = Misc.getHighlightColor();
169 if (currentStage == Stage.GO_TO_OUTPOST) {
170 info.addPara(getGoToPlanetTextShort(planet), tc, pad);
171 return true;
172 } else if (currentStage == Stage.RETURN_TO_ACADEMY) {
173 // shared way to get the same text to ensure consistency across different missions
174 info.addPara(getReturnTextShort("the Galatia Academy"), tc, pad);
175 return true;
176 }
177 return false;
178 }
179
180 @Override
181 public String getBaseName() {
182 return "Extract 'Researcher'";
183 }
184
185 protected void addMercFleet(SectorEntityToken patrolPoint) {
186 // changed requirePlayerInHyperspace to false so that if ctrl-clicking into the system, the mercs
187 // still spawn. Generally only want to requirePlayerInHyperspace for an encounter intended to be in
188 // hyperspace, and even then that's situational
189 beginWithinHyperspaceRangeTrigger(planet, 3f, false, Stage.GO_TO_OUTPOST);
190 triggerCreateFleet(FleetSize.LARGE, FleetQuality.VERY_HIGH, Factions.MERCENARY, FleetTypes.PATROL_LARGE, system);
191 triggerSetFleetFaction(Factions.INDEPENDENT);
192 triggerSetFleetOfficers(OfficerNum.MORE, OfficerQuality.HIGHER);
193
194 // do we want this here? Probably not, this is a one-off mission and so the strength shouldn't scale
195 //triggerAutoAdjustFleetStrengthMajor();
196
197 triggerMakeHostileAndAggressive();
198 triggerMakeNoRepImpact();
199 triggerFleetAllowLongPursuit();
200 triggerSetFleetAlwaysPursue();
201
202 triggerPickLocationAroundEntity(patrolPoint, 1000f);
203 triggerSpawnFleetAtPickedLocation("$gaTJ_merc", null);
204 triggerOrderFleetPatrol(true, patrolPoint);
205
206 //triggerFleetMakeImportant(null, Stage.RETURN_TO_ACADEMY);
207 endTrigger();
208 }
209}
210
211
212
213
214
static SectorAPI getSector()
Definition Global.java:59
boolean callAction(String action, String ruleId, InteractionDialogAPI dialog, List< Token > params, Map< String, MemoryAPI > memoryMap)
void addDescriptionForNonEndStage(TooltipMakerAPI info, float width, float height)
boolean addNextStepText(TooltipMakerAPI info, Color tc, float pad)