Starsector API
Loading...
Searching...
No Matches
LuddicKnightErrant.java
Go to the documentation of this file.
1package com.fs.starfarer.api.impl.campaign.missions.luddic;
2
3import java.awt.Color;
4import java.util.List;
5import java.util.Map;
6
7import org.lwjgl.util.vector.Vector2f;
8
9import com.fs.starfarer.api.Global;
10import com.fs.starfarer.api.campaign.InteractionDialogAPI;
11import com.fs.starfarer.api.campaign.RepLevel;
12import com.fs.starfarer.api.campaign.econ.MarketAPI;
13import com.fs.starfarer.api.campaign.rules.MemoryAPI;
14import com.fs.starfarer.api.characters.PersonAPI;
15import com.fs.starfarer.api.impl.campaign.econ.RecentUnrest;
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.People;
19import com.fs.starfarer.api.impl.campaign.missions.hub.HubMissionWithSearch;
20import com.fs.starfarer.api.impl.campaign.missions.hub.HubMissionWithTriggers.FleetQuality;
21import com.fs.starfarer.api.impl.campaign.missions.hub.HubMissionWithTriggers.FleetSize;
22import com.fs.starfarer.api.impl.campaign.missions.hub.HubMissionWithTriggers.OfficerNum;
23import com.fs.starfarer.api.impl.campaign.missions.hub.HubMissionWithTriggers.OfficerQuality;
24import com.fs.starfarer.api.ui.TooltipMakerAPI;
25import com.fs.starfarer.api.util.Misc;
26import com.fs.starfarer.api.util.Misc.Token;
27
28public class LuddicKnightErrant extends HubMissionWithSearch {
29
30 public static enum Stage {
31 GO_TO_CHALCEDON,
32 CONTACT_RECRUITER,
33 GO_TO_MAZALOT,
34 CONTACT_VIRENS,
35 CONTACT_BORNANEW,
36 RETURN_TO_GILEAD,
37 RETURN_TO_GILEAD2,
38 COMPLETED,
39 }
40
41 protected PersonAPI bornanew;
42 protected PersonAPI jaspis;
43 protected PersonAPI nile_virens;
44
45 protected MarketAPI chalcedon;
46 protected MarketAPI mazalot;
47 protected MarketAPI gilead;
48
49 //public static float MISSION_DAYS = 120f;
50
51 //protected int payment;
52 //protected int paymentHigh;
53
54 @Override
55 protected boolean create(MarketAPI createdAt, boolean barEvent) {
56 // if already accepted by the player, abort
57 if (!setGlobalReference("$lke_ref", "$lke_inProgress")) {
58 return false;
59 }
60
61 chalcedon = Global.getSector().getEconomy().getMarket("chalcedon");
62 if (chalcedon == null) return false;
63 if (!chalcedon.getFactionId().equals(Factions.LUDDIC_PATH)) return false;
64
65 gilead = Global.getSector().getEconomy().getMarket("gilead");
66 if (gilead == null) return false;
67 if (!gilead.getFactionId().equals(Factions.LUDDIC_CHURCH)) return false;
68
69 mazalot = Global.getSector().getEconomy().getMarket("mazalot");
70 if (mazalot == null) return false;
71 if (!mazalot.getFactionId().equals(Factions.PERSEAN)) return false;
72
73 bornanew = getImportantPerson(People.BORNANEW);
74 if (bornanew == null) return false;
75
76 jaspis = getImportantPerson(People.JASPIS);
77 if (bornanew == null) return false;
78
79 nile_virens = getImportantPerson(People.VIRENS);
80 if (nile_virens == null) return false;
81
82 setStoryMission();
83
84 setStartingStage(Stage.GO_TO_CHALCEDON);
85 makeImportant(chalcedon, "$lke_searchForBornanew", Stage.GO_TO_CHALCEDON);
86
87 setStageOnGlobalFlag(Stage.CONTACT_RECRUITER, "$lke_contactRecruiter");
88 makeImportant(chalcedon, "$lke_contactRecruiter", Stage.CONTACT_RECRUITER);
89
90 setStageOnGlobalFlag(Stage.GO_TO_MAZALOT, "$lke_gotBornanewLead");
91 makeImportant(mazalot, "$lke_searchForBornanew2", Stage.GO_TO_MAZALOT);
92
93 setStageOnGlobalFlag(Stage.CONTACT_VIRENS, "$lke_contactVirens");
94 makeImportant(mazalot, "$lke_contactVirens", Stage.CONTACT_VIRENS);
95
96 setStageOnGlobalFlag(Stage.CONTACT_BORNANEW, "$lke_contactBornanew");
97 makeImportant(mazalot, "$lke_contactBornanew", Stage.CONTACT_BORNANEW);
98
99 setStageOnGlobalFlag(Stage.RETURN_TO_GILEAD, "$lke_foundBornanew"); // he's alive
100 makeImportant(gilead, "$lke_returnWithBornanew", Stage.RETURN_TO_GILEAD);
101 makeImportant(jaspis, "$lke_returnWithBornanew", Stage.RETURN_TO_GILEAD);
102
103 setStageOnGlobalFlag(Stage.RETURN_TO_GILEAD2, "$lke_foundBornanew2"); // he's "dead"
104 makeImportant(gilead, "$lke_returnWithBornanewNews", Stage.RETURN_TO_GILEAD2);
105 makeImportant(jaspis, "$lke_returnWithBornanewNews", Stage.RETURN_TO_GILEAD2);
106
107 setStageOnGlobalFlag(Stage.COMPLETED, "$lke_completed");
108 addSuccessStages(Stage.COMPLETED);
109
110
111 setName("Knight Errant");
112 setRepFactionChangesNone();
113 setRepPersonChangesNone();
114
115 beginStageTrigger(Stage.COMPLETED);
116 triggerMakeNonStoryCritical("chalcedon", "mazalot", "gilead");
117 triggerSetGlobalMemoryValue("$lke_completed", true);
118 endTrigger();
119
120
121 // Spawn a Pather fleet near Chalcedon to spice things up.
122 //beginStageTrigger(Stage.GO_TO_CHALCEDON);
123 beginWithinHyperspaceRangeTrigger(chalcedon.getPlanetEntity(), 1f, false,Stage.GO_TO_CHALCEDON);
124 triggerCreateFleet(FleetSize.LARGE, FleetQuality.DEFAULT, Factions.LUDDIC_PATH, FleetTypes.PATROL_LARGE, chalcedon.getPlanetEntity());
125 triggerSetFleetFaction(Factions.LUDDIC_PATH);
126 triggerPickLocationAroundEntity(chalcedon.getPlanetEntity(), 800f);
127 triggerOrderFleetPatrol(chalcedon.getPlanetEntity());
128 triggerSpawnFleetAtPickedLocation("$lke_patherGoblins", null);
129 triggerSetFleetMissionRef("$lke_ref");
130
131 // if player is hostile to Path, Path fleet is hostile to player.
132 // if( Global.getSector().getFaction(Factions.LUDDIC_PATH).getRelToPlayer().isAtBest(RepLevel.HOSTILE) )
133 //{
134 // triggerMakeHostileAndAggressive();
135 //}
136
137 //triggerFleetSetPatrolLeashRange(1000f);
138 //triggerMakeFleetGoAwayAfterDefeat();
139 endTrigger();
140
141 // Luddic intercept fleet post-Chalcedon
142 beginWithinHyperspaceRangeTrigger(chalcedon, 3f, true, Stage.GO_TO_MAZALOT);
143 triggerCreateFleet(FleetSize.LARGER, FleetQuality.HIGHER, Factions.LUDDIC_PATH, FleetTypes.PATROL_LARGE, mazalot.getLocationInHyperspace());
144 triggerSetFleetOfficers(OfficerNum.MORE, OfficerQuality.HIGHER);
145 triggerMakeHostileAndAggressive();
146 triggerMakeLowRepImpact();
147 triggerFleetMakeFaster(true, 2, true);
148 triggerSetFleetAlwaysPursue();
149 triggerPickLocationTowardsEntity(chalcedon.getStarSystem().getHyperspaceAnchor(), 30f, getUnits(1.5f));
150 triggerSpawnFleetAtPickedLocation("$lke_patherIntercept", null);
151 triggerOrderFleetInterceptPlayer();
152 triggerOrderFleetEBurn(1f);
153 triggerSetFleetMissionRef("$lke_ref");
154 triggerFleetMakeImportant(null, Stage.GO_TO_MAZALOT);
155 endTrigger();
156
157 return true;
158 }
159
160 protected void updateInteractionDataImpl() {
161 set("$lke_stage", getCurrentStage());
162 //set("$anh_robedman", robed_man);
163 }
164
165 @Override
166 protected boolean callAction(String action, String ruleId, final InteractionDialogAPI dialog,
167 List<Token> params, final Map<String, MemoryAPI> memoryMap) {
168// if ("THEDUEL".equals(action)) {
169// TextPanelAPI text = dialog.getTextPanel();
170// text.setFontOrbitronUnnecessarilyLarge();
171// Color color = Misc.getBasePlayerColor();
172// color = Global.getSector().getFaction(Factions.HEGEMONY).getBaseUIColor();
173// text.addPara("THE DUEL", color);
174// text.setFontInsignia();
175// text.addImage("misc", "THEDUEL");
176// return true;
177// }
178
179 if ("postMissionCleanup".equals(action)) {
180 // clean up any unneeded memory things.
181 //Global.getSector().getMemoryWithoutUpdate().unset("$lpp_didHesperusFirstShrineAttempt");
182 Global.getSector().getMemoryWithoutUpdate().unset("$global.lke_foundBornanew");
183
184 mazalot.getMemoryWithoutUpdate().unset("$market.dardanWontTalkLKE");
185
186 return true;
187 }
188 else if ("shootEm".equals(action))
189 {
190 Global.getSoundPlayer().playSound("storyevent_diktat_execution", 1, 1, Global.getSoundPlayer().getListenerPos(), new Vector2f());
191 return true;
192 }
193 else if ("resumeMusic".equals(action))
194 {
197 return true;
198 }
199 else if ("endMusic".equals(action))
200 {
203 //Global.getSoundPlayer().restartCurrentMusic();
204 return true;
205 }
206 else if ("playMusicCombat".equals(action))
207 {
208 Global.getSoundPlayer().playCustomMusic(1, 1, "music_combat", true);
209 return true;
210 }
211 else if ("playMusicSedge".equals(action))
212 {
213 Global.getSoundPlayer().playCustomMusic(1, 1, "music_luddite_encounter_hostile", true);
214 return true;
215 }
216 else if ("playMusicVirens".equals(action))
217 {
218 Global.getSoundPlayer().playCustomMusic(1, 1, "music_luddite_market_hostile", true);
219 return true;
220 }
221 else if ("playMusicJethro".equals(action))
222 {
223 Global.getSoundPlayer().playCustomMusic(1, 1, "music_luddite_market_friendly", true);
224 return true;
225 }
226 else if ("playMusicDardan".equals(action))
227 {
228 Global.getSoundPlayer().playCustomMusic(1, 1, "music_persean_league_market_hostile", true);
229 return true;
230 }
231 else if ("didMazalotRaid".equals(action))
232 {
233 RecentUnrest.get(mazalot).add(10, "Raided Mazalot and caused a Luddic uprising");
234 return true;
235 }
236 else if ("doCleanup".equals(action))
237 {
238
239 Global.getSector().getMemoryWithoutUpdate().unset("$lke_gotVirensContactFreebie");
240 Global.getSector().getMemoryWithoutUpdate().unset("$lke_didMazBarAgentEncounter");
241 chalcedon.getMemoryWithoutUpdate().unset("$lkeBuggedVIPs");
242 mazalot.getMemoryWithoutUpdate().unset("$lke_wontTellLied");
243 mazalot.getMemoryWithoutUpdate().unset("$lke_askedPMChurch");
244 mazalot.getMemoryWithoutUpdate().unset("$lkeSetUpVirensMeeting");
245 mazalot.getMemoryWithoutUpdate().unset("$dardanWontTalkLKE");
246
247 return true;
248 }
249
250 return super.callAction(action, ruleId, dialog, params, memoryMap);
251 }
252
253 /*
254 @Override
255 public void createSmallDescription(TooltipMakerAPI info, float width, float height) {
256 Color h = Misc.getHighlightColor();
257 Color g = Misc.getGrayColor();
258 float pad = 3f;
259 float opad = 10f;
260
261 FactionAPI faction = getFactionForUIColors();
262 PersonAPI person = getPerson();
263
264 //info.addImage(Global.getSettings().getSpriteName("illustrations", "luddic_shrine"), width, opad);
265
266 addDescriptionForCurrentStage(info, width, height);
267
268 addBulletPoints(info, ListInfoMode.IN_DESC);
269 }
270 */
271
272 @Override
273 public void addDescriptionForNonEndStage(TooltipMakerAPI info, float width, float height) {
274 float opad = 10f;
275 //Color h = Misc.getHighlightColor();
276
277 //Color h2 = Misc.getDarkHighlightColor();
278 //FactionAPI church = Global.getSector().getFaction(Factions.LUDDIC_CHURCH);
279
280 //info.addImage(robed_man.getPortraitSprite(), width, 128, opad);
281
282 if (currentStage == Stage.GO_TO_CHALCEDON) {
283 info.addPara("Find Bornanew. His last mission was the infiltration of a Pather cell; someone must known something about where he is.", opad);
284 addStandardMarketDesc("Go to " + chalcedon.getOnOrAt(), chalcedon, info, opad);
285 }
286 else if (currentStage == Stage.CONTACT_RECRUITER) {
287 info.addPara("You have been told to meet with someone in a spacer bar on the surface of Chalcedon, presumably a recruiter for the Luddic Path.", opad);
288 addStandardMarketDesc("Go to " + chalcedon.getOnOrAt(), chalcedon, info, opad);
289 }
290 else if (currentStage == Stage.GO_TO_MAZALOT) {
291 info.addPara("A Pather, Sedge, claims that Jethro Bornanew travelled to Mazalot. Find him, or find where he has gone from there.", opad);
292 addStandardMarketDesc("Go to " + mazalot.getOnOrAt(), mazalot, info, opad);
293 }
294 else if (currentStage == Stage.CONTACT_VIRENS) {
295 info.addPara("Nile Virens runs the Luddic Path on Mazalot. If anyone knows where Bornanew is, it would be him or his organization. He might be persuaded to help by force or diplomacy.", opad);
296 addStandardMarketDesc("Contact Nile Virens " + mazalot.getOnOrAt(), mazalot, info, opad);
297 info.addImage(nile_virens.getPortraitSprite(), width, 128, opad);
298 info.addImage(nile_virens.getFaction().getCrest(), width, 128, opad);
299 }
300 else if (currentStage == Stage.CONTACT_BORNANEW) {
301 info.addPara("Nile Virens has provided you with the location of Jethro Bornanew, or so he claims. This consists of coordinates for a location on the surface of Mazalot, outside of a Luddic-majority settlement.", opad);
302 addStandardMarketDesc("Contact Jethro Bornanew " + mazalot.getOnOrAt(), mazalot, info, opad);
303 //info.addImage(bornanew.getPortraitSprite(), width, 128, opad);
304 }
305 else if (currentStage == Stage.RETURN_TO_GILEAD) {
306 info.addPara("Return with Jethro Bornanew to the office of Archcurate Jaspis.", opad);
307 addStandardMarketDesc("Go to " + gilead.getOnOrAt(), gilead, info, opad);
308 }
309 else if (currentStage == Stage.RETURN_TO_GILEAD2) {
310 info.addPara("Return to the office of Archcurate Jaspis with news of Jethro Bornanew's 'death'.", opad);
311 addStandardMarketDesc("Go to " + gilead.getOnOrAt(), gilead, info, opad);
312 }
313
314 }
315
316 @Override
317 public boolean addNextStepText(TooltipMakerAPI info, Color tc, float pad) {
318 //Color h = Misc.getHighlightColor();
319
320 if (currentStage == Stage.GO_TO_CHALCEDON) {
321 info.addPara("Go to Chalcedon and find Jethro Bornanew", tc, pad);
322 return true;
323 }
324 else if (currentStage == Stage.CONTACT_RECRUITER) {
325 info.addPara("Go to the spacer bar on Chalcedon and speak with the Luddic Path recruiter", tc, pad);
326 return true;
327 }
328 else if (currentStage == Stage.GO_TO_MAZALOT) {
329 info.addPara("Go to Mazalot and find Jethro Bornanew", tc, pad);
330 return true;
331 }
332 else if (currentStage == Stage.CONTACT_VIRENS) {
333 info.addPara("Talk to or raid Nile Virens on Mazalot", tc, pad);
334 return true;
335 }
336 else if (currentStage == Stage.CONTACT_BORNANEW) {
337 info.addPara("Go to the alleged location of Jethro Bornanew on Mazalot", tc, pad);
338 return true;
339 }
340 else if (currentStage == Stage.RETURN_TO_GILEAD) {
341 info.addPara("Return to Gilead with Bornanew", tc, pad);
342 return true;
343 }
344 else if (currentStage == Stage.RETURN_TO_GILEAD2) {
345 info.addPara("Return to Gilead with news of Bornanew's 'death'.", tc, pad);
346 return true;
347 }
348
349 return false;
350
351 /*
352 Color h = Misc.getHighlightColor();
353 if (currentStage == Stage.DROP_OFF) {
354 info.addPara("Deliver " + getWithoutArticle(thing) + " to specified location in the " +
355 system.getNameWithLowercaseTypeShort(), tc, pad);
356 return true;
357 }
358 */
359 }
360
361 @Override
362 public String getBaseName() {
363 return "Knight Errant";
364 }
365
366 @Override
367 public String getPostfixForState() {
368 if (startingStage != null) {
369 return "";
370 }
371 return super.getPostfixForState();
372 }
373}
374
375
376
377
378
static SoundPlayerAPI getSoundPlayer()
Definition Global.java:43
static SectorAPI getSector()
Definition Global.java:59
boolean callAction(String action, String ruleId, final InteractionDialogAPI dialog, List< Token > params, final Map< String, MemoryAPI > memoryMap)
boolean addNextStepText(TooltipMakerAPI info, Color tc, float pad)
void addDescriptionForNonEndStage(TooltipMakerAPI info, float width, float height)
void setSuspendDefaultMusicPlayback(boolean suspendMusicPlayback)
void playCustomMusic(int fadeOutIfAny, int fadeIn, String musicSetId)
SoundAPI playSound(String id, float pitch, float volume, Vector2f loc, Vector2f vel)