Starsector API
Loading...
Searching...
No Matches
GAAtTheGates.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.ArrayList;
5import java.util.Arrays;
6import java.util.List;
7import java.util.Map;
8
9import org.lwjgl.util.vector.Vector2f;
10
11import com.fs.starfarer.api.Global;
12import com.fs.starfarer.api.campaign.CampaignEventListener.FleetDespawnReason;
13import com.fs.starfarer.api.campaign.CampaignFleetAPI;
14import com.fs.starfarer.api.campaign.CargoAPI;
15import com.fs.starfarer.api.campaign.CargoAPI.CargoItemType;
16import com.fs.starfarer.api.campaign.CargoStackAPI;
17import com.fs.starfarer.api.campaign.InteractionDialogAPI;
18import com.fs.starfarer.api.campaign.LocationAPI;
19import com.fs.starfarer.api.campaign.SectorEntityToken;
20import com.fs.starfarer.api.campaign.SpecialItemData;
21import com.fs.starfarer.api.campaign.StarSystemAPI;
22import com.fs.starfarer.api.campaign.TextPanelAPI;
23import com.fs.starfarer.api.campaign.econ.MarketAPI;
24import com.fs.starfarer.api.campaign.listeners.BaseFleetEventListener;
25import com.fs.starfarer.api.campaign.listeners.CurrentLocationChangedListener;
26import com.fs.starfarer.api.campaign.rules.MemoryAPI;
27import com.fs.starfarer.api.characters.PersonAPI;
28import com.fs.starfarer.api.impl.campaign.DerelictShipEntityPlugin.DerelictShipData;
29import com.fs.starfarer.api.impl.campaign.GateEntityPlugin;
30import com.fs.starfarer.api.impl.campaign.ids.Entities;
31import com.fs.starfarer.api.impl.campaign.ids.Factions;
32import com.fs.starfarer.api.impl.campaign.ids.FleetTypes;
33import com.fs.starfarer.api.impl.campaign.ids.Items;
34import com.fs.starfarer.api.impl.campaign.ids.MemFlags;
35import com.fs.starfarer.api.impl.campaign.ids.People;
36import com.fs.starfarer.api.impl.campaign.ids.Ranks;
37import com.fs.starfarer.api.impl.campaign.ids.Tags;
38import com.fs.starfarer.api.impl.campaign.procgen.themes.BaseThemeGenerator;
39import com.fs.starfarer.api.impl.campaign.procgen.themes.SalvageSpecialAssigner.ShipRecoverySpecialCreator;
40import com.fs.starfarer.api.impl.campaign.rulecmd.AddRemoveCommodity;
41import com.fs.starfarer.api.impl.campaign.rulecmd.missions.GateCMD;
42import com.fs.starfarer.api.impl.campaign.rulecmd.salvage.special.ShipRecoverySpecial.PerShipData;
43import com.fs.starfarer.api.impl.campaign.rulecmd.salvage.special.ShipRecoverySpecial.ShipCondition;
44import com.fs.starfarer.api.ui.TooltipMakerAPI;
45import com.fs.starfarer.api.util.Misc;
46import com.fs.starfarer.api.util.Misc.Token;
47import com.fs.starfarer.api.util.WeightedRandomPicker;
48
49public class GAAtTheGates extends GABaseMission implements CurrentLocationChangedListener {
50
51 public static String SHOW_GATE_SCAN_COUNT = "show_gate_scan_count";
52
53 public static enum Stage {
54 TALK_TO_COUREUSE,
55 TALK_TO_YARIBAY,
56 TALK_TO_HEGEMON,
57 MEET_DAUD,
58 DO_SCANS,
59 RETURN_WITH_DEAL_AND_SCANS,
60 FIRST_JANUS_EXPERIMENT,
61 FIRST_JANUS_RESULTS,
62 COUREUSE_MISSION,
63 TALK_TO_KANTA,
64 FINDING_LOKE,
65 RETURN_TO_KANTA,
66 GO_TO_MAGEC_GATE,
67 ZAL_TO_GALATIA,
68 COMPLETED,
69 }
70
71 protected PersonAPI baird;
72 protected PersonAPI coureuse;
73 protected PersonAPI gargoyle;
74
75 protected PersonAPI horus_yaribay;
76 protected PersonAPI siyavong;
77 protected MarketAPI kazeron;
78 //protected StarSystemAPI magec;
79 protected SectorEntityToken magecGate;
80 protected SectorEntityToken galatiaGate;
81
82 protected PersonAPI daud;
83 protected MarketAPI chicomoztoc;
84
85 protected PersonAPI kanta;
86 protected PersonAPI loke;
87 protected PersonAPI cotton;
88 protected PersonAPI zal;
89 protected PersonAPI kantasDenStationCommander;
90 protected MarketAPI kantasDen;
91 protected MarketAPI epiphany;
92
93 protected SectorEntityToken encounterGateHegemony;
94 protected CampaignFleetAPI encounterHegemonyFleet;
95
96 protected SectorEntityToken encounterGateLuddic;
97 protected CampaignFleetAPI encounterLuddicFleet;
98
99 protected SectorEntityToken encounterGateTT;
100 protected CampaignFleetAPI encounterTTFleet;
101 protected int ttScanCost;
102 protected int pirateScanCost;
103 protected int coureuseCredits;
104
105 protected SectorEntityToken encounterGatePirate;
106 protected CampaignFleetAPI encounterPirateFleet;
107
108 //protected SectorEntityToken encounterGateAlarm;
109 //protected CampaignFleetAPI encounterHegemonyFleet;
110
111 protected List<ScanEncounterVariation> scanEncounterVariations;
112
113 public static float SYSTEM_NO_GATE_ENCOUNTER_CHANCE = 0.2f;
114 public static float FACTION_GATE_ENCOUNTER_CHANCE = 0.5f;
115
116 public static enum ScanEncounterVariation {
117 HEGEMONY,
118 TRITACHYON,
119 LUDDIC,
120 PIRATE,
121 DERELICT,
122 JAMMER,
123 SCAVENGER,
124 PATHER,
125 ALARM,
126 }
127
128 public static float KANTA_RAID_DIFFICULTY = 1000f;
129 public static float COTTON_RAID_DIFFICULTY = 1000f;
130
131 @Override
132 protected boolean create(MarketAPI createdAt, boolean barEvent) {
133 // if already accepted by the player, abort
134 if (!setGlobalReference("$gaATG_ref", "$gaATG_inProgress")) {
135 return false;
136 }
137
138 baird = getImportantPerson(People.BAIRD);
139 if (baird == null) return false;
140
141 coureuse = getImportantPerson(People.COUREUSE);
142 if (coureuse == null) return false;
143
144 gargoyle = getImportantPerson(People.GARGOYLE);
145 if (gargoyle == null) return false;
146
147 horus_yaribay = getImportantPerson(People.HORUS_YARIBAY);
148 if (horus_yaribay == null) return false;
149
150 siyavong = getImportantPerson(People.SIYAVONG);
151 if (siyavong == null) return false;
152
153 daud = getImportantPerson(People.DAUD);
154 if (daud == null) return false;
155
156 kanta = getImportantPerson(People.KANTA);
157 if (kanta == null) return false;
158
159 loke = getImportantPerson(People.CLONE_LOKE);
160 if (loke == null) return false;
161
162 cotton = getImportantPerson(People.COTTON);
163 if (cotton == null) return false;
164
165 zal = getImportantPerson(People.ZAL);
166 if (zal == null) return false;
167
168 kazeron = Global.getSector().getEconomy().getMarket("kazeron");
169 if (kazeron == null) return false;
170
171 chicomoztoc = Global.getSector().getEconomy().getMarket("chicomoztoc");
172 if (chicomoztoc == null) return false;
173
174 kantasDen = Global.getSector().getEconomy().getMarket("kantas_den");
175 if (kantasDen == null) return false;
176
177 kantasDenStationCommander = getPersonAtMarketPost(kantasDen, Ranks.POST_STATION_COMMANDER);
178 if (kantasDenStationCommander == null) return false;
179
180 epiphany = Global.getSector().getEconomy().getMarket("epiphany");
181 if (epiphany == null) return false;
182
183 // find the Magec gate!
184 StarSystemAPI magec = kantasDen.getStarSystem();
185 for (SectorEntityToken curr : magec.getCustomEntitiesWithTag(Tags.GATE)) {
186 //if (GateEntityPlugin.isScanned(curr)) continue;
187 //if (GateEntityPlugin.isActive(curr)) continue;
188 // plus whatever other checks are needed
189 magecGate = curr;
190 break;
191 }
192 if (magecGate == null) return false;
193
194 // and Galatia Gate
195 StarSystemAPI galatia = Global.getSector().getStarSystem("galatia");
196 for (SectorEntityToken curr : galatia.getCustomEntitiesWithTag(Tags.GATE)) {
197 //if (GateEntityPlugin.isScanned(curr)) continue;
198 //if (GateEntityPlugin.isActive(curr)) continue;
199 // plus whatever other checks are needed
200 galatiaGate = curr;
201 break;
202 }
203 if (galatiaGate == null) return false;
204
205 setName("At The Gates");
206 setRepFactionChangesNone();
207 setRepPersonChangesNone();
208
209 // set up our fleet spawns!
210 // Siyavong first
211 // Siyavong gets a patrol fleet to intercept player
212 //beginWithinHyperspaceRangeTrigger(kazeron, 1f, false, Stage.TALK_TO_HEGEMON);
213 //triggerCreateFleet(FleetSize.SMALL, FleetQuality.VERY_LOW, Factions.LUDDIC_PATH, FleetTypes.PATROL_SMALL, probeSystem);
214
215 beginStageTrigger(Stage.TALK_TO_HEGEMON);
216 triggerCreateFleet(FleetSize.MEDIUM, FleetQuality.HIGHER, Factions.PERSEAN, FleetTypes.PATROL_MEDIUM, kazeron.getStarSystem());
217 triggerSetFleetOfficers(OfficerNum.MORE, OfficerQuality.HIGHER);
218 triggerMakeNonHostile();
219 triggerMakeFleetIgnoreOtherFleetsExceptPlayer(); // don't go chasing others, please.
220 triggerFleetAllowLongPursuit();
221 triggerSetFleetAlwaysPursue();
222 triggerFleetMakeFaster(true, 1, true);
223
224 triggerPickLocationAroundEntity(kazeron.getStarSystem().getHyperspaceAnchor(), 250f);
225 triggerSpawnFleetAtPickedLocation("$gaATG_siyavongFleet", null);
226 //triggerSpawnFleetAtPickedLocation("$gaATG_pirateScanFleet", null);
227
228 //triggerPickLocationTowardsEntity(kazeron.getStarSystem().getHyperspaceAnchor(), 90f, getUnits(1f));
229 triggerSetFleetMissionRef("$gaATG_ref"); // so they can be made unimportant
230 triggerOrderFleetInterceptPlayer();
231 triggerOrderFleetEBurn(1f);
232 triggerFleetMakeImportant(null, Stage.TALK_TO_HEGEMON);
233 endTrigger();
234
235
236 // For the big showdown w/ Kanta
237 List<SectorEntityToken> jumpPoints = magecGate.getStarSystem().getJumpPoints();
238 for (SectorEntityToken point : jumpPoints) {
240 spawnKantaVengeanceFleetPirateScout(point); // 2 scouts per.
243 }
245
246 //scanEncounterVariations = Arrays.asList(ScanEncounterVariation.values()); // NO. Bad list.
247 scanEncounterVariations = new ArrayList<ScanEncounterVariation>(Arrays.asList(ScanEncounterVariation.values()));
248
249 ttScanCost = genRoundNumber(20000, 30000); // bribe for TT scanning fleet
250 pirateScanCost = genRoundNumber(10000, 20000); // bribe for Pirate gate-blockers
251 coureuseCredits = genRoundNumber(10000, 20000); // Coureuse's pathetic savings
252
253 setStoryMission();
254
255 setStartingStage(Stage.TALK_TO_COUREUSE);
256 addSuccessStages(Stage.COMPLETED);
257
258 makeImportant(coureuse, null, Stage.TALK_TO_COUREUSE);
259 makeImportant(horus_yaribay, null, Stage.TALK_TO_YARIBAY);
260 makeImportant(daud, null, Stage.TALK_TO_HEGEMON);
261 makeImportant(chicomoztoc, null, Stage.MEET_DAUD);
262 makeImportant(baird, null, Stage.RETURN_WITH_DEAL_AND_SCANS);
263 makeImportant(baird, null, Stage.FIRST_JANUS_RESULTS);
264 makeImportant(coureuse, null, Stage.COUREUSE_MISSION);
265 makeImportant(kantasDen, "$gaATG_talkToKanta", Stage.TALK_TO_KANTA);
266 makeImportant(epiphany, "$gaATG_findingLoke", Stage.FINDING_LOKE);
267 makeImportant(kanta.getMarket(), null, Stage.RETURN_TO_KANTA);
268 makeImportant(magecGate, null, Stage.GO_TO_MAGEC_GATE);
269 makeImportant(baird.getMarket(), null, Stage.ZAL_TO_GALATIA);
270
271 //setStageOnGlobalFlag(Stage.TALK_TO_COUREUSE, "$gaATG_goTalkToCoureuse");
272 connectWithGlobalFlag(Stage.TALK_TO_COUREUSE, Stage.TALK_TO_YARIBAY, "$gaATG_goTalkToYaribay");
273 connectWithGlobalFlag(Stage.TALK_TO_YARIBAY, Stage.TALK_TO_HEGEMON, "$gaATG_goTalkToDaud");
274 connectWithGlobalFlag(Stage.TALK_TO_HEGEMON, Stage.MEET_DAUD, "$gaATG_goToDaudMeeting");
275 connectWithGlobalFlag(Stage.MEET_DAUD, Stage.DO_SCANS, "$gaATG_gotDaudDeal");
276 connectWithGlobalFlag(Stage.DO_SCANS, Stage.RETURN_WITH_DEAL_AND_SCANS, "$gaATG_scannedSixGates");
277 setStageOnGlobalFlag(Stage.FIRST_JANUS_EXPERIMENT, "$gaATG_useJanusPrototype");
278 setStageOnGlobalFlag(Stage.FIRST_JANUS_RESULTS, "$gaATG_firstJanusResults");
279 setStageOnGlobalFlag(Stage.COUREUSE_MISSION, "$gaATG_getMissionFromCoureuse");
280 setStageOnGlobalFlag(Stage.TALK_TO_KANTA, "$gaATG_gotKantaToken");
281 setStageOnGlobalFlag(Stage.FINDING_LOKE, "$gaATG_findingLoke");
282 setStageOnGlobalFlag(Stage.RETURN_TO_KANTA, "$gaATG_foundLoke");
283 setStageOnGlobalFlag(Stage.GO_TO_MAGEC_GATE, "$gaATG_foundZal");
284
285 connectWithEnteredLocation(Stage.GO_TO_MAGEC_GATE, Stage.ZAL_TO_GALATIA, galatia);
286 //setStageOnGlobalFlag(Stage.ZAL_TO_GALATIA, "$gaATG_zalToGalatia");
287 setStageOnGlobalFlag(Stage.COMPLETED, "$gaATG_completed");
288
289 // so they can decivilize etc but not before this and any other story missions using these are completed
290 beginStageTrigger(Stage.COMPLETED);
291 triggerSetGlobalMemoryValue("$gaATG_missionCompleted", true);
292 triggerMakeNonStoryCritical(kazeron, chicomoztoc, epiphany, siyavong.getMarket(), kanta.getMarket());
293 endTrigger();
294
295 return true;
296 }
297 @Override
298 protected boolean callAction(String action, String ruleId, InteractionDialogAPI dialog, List<Token> params,
299 Map<String, MemoryAPI> memoryMap) {
300
301 // $global.numGatesScanned tracks this too; maybe not ideal to dupe the var, but yolo -dgb
302 if ("scannedGateForCoureuse".equals(action)) {
303 sendUpdate(SHOW_GATE_SCAN_COUNT, dialog.getTextPanel());
304 return true;
305 }
306 else if ("setGalatiaGateScanned".equals(action))
307 {
308 galatiaGate.getMemoryWithoutUpdate().set(GateEntityPlugin.GATE_SCANNED, true);
309 GateCMD.notifyScanned(galatiaGate);
310 return true;
311 }
312 else if ("clearedHegemonyGate".equals(action)) {
313 encounterGateHegemony.getMemoryWithoutUpdate().unset("$GAATGhegemonyScanFleet");
314 return true;
315 }
316 else if ("clearedHegemonyGateSendScans".equals(action)) {
317 encounterGateHegemony.getMemoryWithoutUpdate().set("$GAATGhegSendScan", true);
318 encounterGateHegemony.getMemoryWithoutUpdate().unset("$GAATGhegemonyScanFleet");
319 encounterHegemonyFleet.getMemoryWithoutUpdate().unset("$youDoTheScan");
320 encounterHegemonyFleet.getMemoryWithoutUpdate().set("$youDidTheScan", true);
321 return true;
322 }
323 else if ("sentHegemonyScan".equals(action)) {
324 encounterHegemonyFleet.getMemoryWithoutUpdate().set(MemFlags.MEMORY_KEY_IGNORE_PLAYER_COMMS, true);
325 return true;
326 }
327 else if ("clearedLuddicGate".equals(action)) {
328 encounterGateLuddic.getMemoryWithoutUpdate().unset("$GAATGluddicScanGate");
329 return true;
330 }
331 else if ("luddicGateFleetMoveAway".equals(action)) {
332 encounterGateLuddic.getMemoryWithoutUpdate().unset("$GAATGluddicScanGate");
333 encounterGateLuddic.getMemoryWithoutUpdate().set("$GAATGluddicPostScan", true);
334 encounterLuddicFleet.getMemoryWithoutUpdate().set(MemFlags.MEMORY_KEY_AVOID_PLAYER_SLOWLY, true);
335 encounterLuddicFleet.getMemoryWithoutUpdate().set(MemFlags.MEMORY_KEY_IGNORE_PLAYER_COMMS, true);
336 return true;
337 }
338 else if ("luddicGateFleetMoveBack".equals(action)) {
339 //encounterGateLuddic.getMemoryWithoutUpdate().unset("$GAATGluddicScanGate");
340 encounterLuddicFleet.getMemoryWithoutUpdate().unset(MemFlags.MEMORY_KEY_AVOID_PLAYER_SLOWLY);
341 encounterLuddicFleet.getMemoryWithoutUpdate().unset(MemFlags.MEMORY_KEY_IGNORE_PLAYER_COMMS);
342 encounterLuddicFleet.getMemoryWithoutUpdate().set("$resumedVigil", true);
343 return true;
344 }
345
346 else if ("boughtTTscan".equals(action)) {
347 encounterGateTT.getMemoryWithoutUpdate().unset("$GAATGttScanGate");
348 encounterGateTT.getMemoryWithoutUpdate().set(GateEntityPlugin.GATE_SCANNED, true);
349 GateCMD.notifyScanned(encounterGateTT);
350 sendUpdate(SHOW_GATE_SCAN_COUNT, dialog.getTextPanel());
351 return true;
352 }
353 else if ("clearedTTGate".equals(action)) {
354 encounterGateTT.getMemoryWithoutUpdate().unset("$GAATGttScanGate");
355 return true;
356 }
357 else if ("clearedPirateGate".equals(action)) {
358 encounterGatePirate.getMemoryWithoutUpdate().unset("$GAATGpirateScanGate");
359 encounterPirateFleet.getMemoryWithoutUpdate().unset("$gaATG_pirateScanFleet");
360 return true;
361 }
362 else if ("doZalEscape".equals(action)) {
363 Global.getSector().layInCourseFor(magecGate);
364 galatiaGate.getMemoryWithoutUpdate().set(GateEntityPlugin.GATE_SCANNED, true);
365 return true;
366 }
367 else if ("giveJanusDevice".equals(action)) {
368 CargoAPI cargo = Global.getSector().getPlayerFleet().getCargo();
369 cargo.addSpecial(new SpecialItemData(Items.JANUS, null), 1);
370 CargoStackAPI stack = Global.getFactory().createCargoStack(CargoItemType.SPECIAL, new SpecialItemData(Items.JANUS, null), null);
371 AddRemoveCommodity.addStackGainText(stack, dialog.getTextPanel());
372 return true;
373 }
374 else if ("endMissionCleanup".equals(action)){
375
376 epiphany.getMemoryWithoutUpdate().unset("$askedForKidnapperCotton");
377 epiphany.getMemoryWithoutUpdate().unset("$offeredBribeForCotton");
378 epiphany.getMemoryWithoutUpdate().unset("$setUpCottonMeeting");
379 epiphany.getMemoryWithoutUpdate().unset("$askedBarCotton");
380 epiphany.getMemoryWithoutUpdate().unset("$setUpCottonMeeting");
381
382 //magecGate.getMemoryWithoutUpdate().unset("$visitedWithZal");
383 return true;
384 }
385 else if ("zalCommHack".equals(action)){
386
387 TextPanelAPI text = dialog.getTextPanel();
388 text.setFontVictor();
389 Color red = Misc.getNegativeHighlightColor();
390 text.addParagraph("COMM FEED 0 INTERRUPTED \nCOMM FEED 1 INTERRUPTED", red);
391 //text.setFontSmallInsignia();
392 text.setFontInsignia();
393 return true;
394 }
395 else if ("zalMinesHack".equals(action))
396 {
397 Global.getSoundPlayer().playSound("hit_heavy", 1, 1, Global.getSoundPlayer().getListenerPos(), new Vector2f());
398 return true;
399 }
400 else if ("giveJanusDevice".equals(action))
401 {
402 CargoAPI cargo = Global.getSector().getPlayerFleet().getCargo();
403 cargo.addSpecial(new SpecialItemData(Items.JANUS, null), 1);
404 CargoStackAPI stack = Global.getFactory().createCargoStack(CargoItemType.SPECIAL, new SpecialItemData(Items.JANUS, null), null);
405 AddRemoveCommodity.addStackGainText(stack, dialog.getTextPanel());
406 return true;
407 }
408 //else if ("addYaribayContact".equals(action))
409 //{
410 // ContactIntel.addPotentialContact(horus_yaribay, kazeron, dialog.getTextPanel());
411 // //setPersonIsPotentialContactOnSuccess(horus_yaribay, 1f); // probability = 1f, otherwise it's only a chance (default 0.25)
412 // return true;
413 //}
414
415 return false;
416 }
417
418 protected void updateInteractionDataImpl() {
419 set("$gaATG_stage", getCurrentStage());
420 set("$gaATG_gatesScanned", GateEntityPlugin.getNumGatesScanned());
421 set("$gaATG_ttScanCost", Misc.getWithDGS(ttScanCost));
422 set("$gaATG_pirateScanCost", Misc.getWithDGS(pirateScanCost));
423 set("$gaATG_coureuseCredits", Misc.getWithDGS(coureuseCredits));
424
425 set("$gaATG_kantaRaidDifficulty", KANTA_RAID_DIFFICULTY);
426 set("$gaATG_cottonRaidDifficulty", COTTON_RAID_DIFFICULTY);
427 set("$kantasDenStationCommander", kantasDenStationCommander.getId()); // kantasDenStationCommander);
428 }
429
430 @Override
431 public void advance(float amount) {
432 super.advance(amount);
433 if ( currentStage == Stage.TALK_TO_COUREUSE ||
434 currentStage == Stage.TALK_TO_YARIBAY ||
435 currentStage == Stage.TALK_TO_HEGEMON ||
436 currentStage == Stage.DO_SCANS) {
437 int scanned = GateEntityPlugin.getNumGatesScanned();
438 if (scanned >= 6 &&
439 !Global.getSector().getMemoryWithoutUpdate().contains("$gaATG_scannedSixGates")) { // failsafe; apparently possible to not have this be set?
440 Global.getSector().getMemoryWithoutUpdate().set("$gaATG_scannedSixGates", true);
441 checkStageChangesAndTriggers(null, null);
442 }
443 }
444 }
445
446 @Override
447 public void addDescriptionForNonEndStage(TooltipMakerAPI info, float width, float height) {
448
449
450
451 float opad = 10f;
452 Color h = Misc.getHighlightColor();
453
454 // Contact the High Hegemon
455 if (currentStage == Stage.TALK_TO_COUREUSE ||
456 currentStage == Stage.TALK_TO_YARIBAY ) {
457 info.addPara("Contact Horus Yaribay to get envoy credentials so you can contact High Hegemon Daud.", opad);
458 addStandardMarketDesc("Gens Yaribay is based " + kazeron.getOnOrAt(), kazeron, info, opad);
459 }
460 else if (currentStage == Stage.TALK_TO_HEGEMON)
461 {
462 info.addPara("Set up a private meeting with High Hegemon Baikal Daud and get him to accept the deal with Provost Baird.", opad);
463 info.addPara("Optional: provide Daud with encrypted Yaribay comm codes.", opad);
464 addStandardMarketDesc("The High Hegemon's office is based " + chicomoztoc.getOnOrAt(), chicomoztoc, info, opad);
465 }
466 else if (currentStage == Stage.MEET_DAUD)
467 {
468 info.addPara("Meet with High Hegemon Baikal Daud on a shipyard orbiting Chicomoztoc.", opad);
469 info.addPara("Optional: provide Daud with encrypted Yaribay comm codes.", opad);
470 addStandardMarketDesc("The High Hegemon's office is based " + chicomoztoc.getOnOrAt(), chicomoztoc, info, opad);
471 }
472 else if (currentStage == Stage.MEET_DAUD)
473 {
474
475 }
476 else if (currentStage == Stage.RETURN_WITH_DEAL_AND_SCANS)
477 {
478 info.addPara("You've arranged a deal between High Hegemon Daud and Provost Baird which allows "
479 + "the Galatia Academy to resume overt research on Gate technology.",opad);
480 }
481
482
483 // Scan six Gates
484 if ( currentStage == Stage.TALK_TO_COUREUSE)
485 {
486 info.addPara("Get the Gate scanning instrument from Academician Coureuse.", opad);
487 }
488 else if ( currentStage == Stage.TALK_TO_COUREUSE ||
489 currentStage == Stage.TALK_TO_YARIBAY ||
490 currentStage == Stage.TALK_TO_HEGEMON ||
491 currentStage == Stage.DO_SCANS &&
493 {
494 info.addPara("Scan six Gates with the instruments provided by Academician Coureuse.", opad);
495 bullet(info);
496 info.addPara("%s Gates scanned", opad, Misc.getHighlightColor(),
497 "" + GateEntityPlugin.getNumGatesScanned() + " / 6");
498 unindent(info);
499 }
500
501 // Everything else in the mission arc.
502 if (currentStage == Stage.RETURN_WITH_DEAL_AND_SCANS)
503 {
504 info.addPara("Return to the Galatia Academy with the six completed Gate scans.", opad);
505 }
506 else if (currentStage == Stage.FIRST_JANUS_EXPERIMENT)
507 {
508 info.addPara("Use the prototype Janus Device on a Gate in an uninhabited system outside of the "
509 + "Core worlds.", opad);
510 }
511 else if (currentStage == Stage.FIRST_JANUS_RESULTS)
512 {
513 info.addPara("Return to the Galatia Academy to report the results of the first Janus Prototype "
514 + "experiment.", opad);
515 }
516 else if (currentStage == Stage.COUREUSE_MISSION)
517 {
518 info.addPara("Contact Academician Scylla Coureuse about what she needs you to do.", opad);
519 }
520 else if (currentStage == Stage.TALK_TO_KANTA)
521 {
522 info.addPara("Use Gargoyle's token to arrange a meeting with Warlord Kanta in the Magec system - or find some other way to extract Zal.", opad);
523 }
524 else if (currentStage == Stage.FINDING_LOKE)
525 {
526 info.addPara("Find and extract the clone of Loke from the Pather kidnappers.", opad);
527 }
528 else if (currentStage == Stage.RETURN_TO_KANTA)
529 {
530 info.addPara("Return Clone Loke to Warlord Kanta.", opad);
531 }
532 else if (currentStage == Stage.GO_TO_MAGEC_GATE)
533 {
534 info.addPara("Go to the Magec Gate and jump to Galatia.", opad);
535 }
536 else if (currentStage == Stage.ZAL_TO_GALATIA)
537 {
538 info.addPara("Return to the Galatia Academy with Elissa Zal and the working Janus Device.", opad);
539 }
540 }
541
542 @Override
543 protected boolean shouldSendUpdateForStage(Object id) {
544 if (getCurrentStage() == Stage.DO_SCANS && GateEntityPlugin.getNumGatesScanned() >= 6) {
545 return false; // going straight to RETURN_WITH_DEAL_AND_SCANS
546 }
547 return super.shouldSendUpdateForStage(id);
548 }
549 @Override
550 public boolean addNextStepText(TooltipMakerAPI info, Color tc, float pad) {
551
552 Color h = Misc.getHighlightColor();
553
554 if (getListInfoParam() == SHOW_GATE_SCAN_COUNT) {
555// if (GateEntityPlugin.getNumGatesScanned() >= 6)
556// {
557// // We don't want to end up writing 7/6 if the player gets excitable about scanning before talking to Daud -dgb
558 // I kind of think we do - it looks confusing if they scan but the number doesn't go up
559 // and in most cases there's no notification, if it's over 6, anyway -am
560// info.addPara("%s Gates scanned", pad, tc, Misc.getHighlightColor(), "6 / 6");
561// }
562// else
563// {
564 info.addPara("%s Gates scanned", pad, tc, Misc.getHighlightColor(),
565 "" + GateEntityPlugin.getNumGatesScanned() + " / 6");
566// }
567 return true;
568
569 }
570
571 // Scanning equipment
572 // Do this first because the player should talk to Coureuse while still at the GA -dgb
573 if (currentStage == Stage.TALK_TO_COUREUSE)
574 {
575 info.addPara("Get the Gate scanning device from Scylla Coureuse", tc, pad);
576 pad = 0; // the padding passed in is just for before the first item
577 }
578
579 // High Hegemon contact
580 if (currentStage == Stage.TALK_TO_COUREUSE ||
581 currentStage == Stage.TALK_TO_YARIBAY ) {
582 info.addPara("Contact Horus Yaribay on Kazeron to get envoy credentials", tc, pad);
583 pad = 0;
584 }
585 else if (currentStage == Stage.TALK_TO_HEGEMON)
586 {
587 info.addPara("Horus Yaribay has provided you with official envoy credentials to set up a private meeting with High "
588 + "Hegemon Baikal Daud", tc, pad);
589 //info.addPara("Optional: provide Daud with encrypted Yaribay comm codes.", opad);
590 //info.addPara("Use the gens Yaribay envoy credentials to set up a private meeting with High "
591 // + "Hegemon Baikal Daud. Get him to accept a new arrangement with Provost Baird.", opad);
592 pad = 0;
593 }
594 else if (currentStage == Stage.MEET_DAUD)
595 {
596 info.addPara("Meet with the High Hegemon in Chicomoztoc orbit and secure Baird's deal", tc, pad);
597 pad = 0;
598 }
599 else if (currentStage == Stage.RETURN_WITH_DEAL_AND_SCANS)
600 {
601 info.addPara("Return to Provost Baird at the Galatia Academy with news of the deal made with "
602 + "High Hegemon Daud", tc, pad);
603 pad = 0;
604 }
605
606 // ... Then scan six Gates; this appears below Yaribay/Daud stuff as it's the next objective -dgb
607 if ( ( currentStage == Stage.TALK_TO_YARIBAY ||
608 currentStage == Stage.TALK_TO_HEGEMON ||
609 currentStage == Stage.MEET_DAUD ||
610 currentStage == Stage.DO_SCANS)
612 // Though this last point is implicit in the Stage, perhaps? Maybe not though,
613 // because you can scan all the gates while doing the Hegemon stuff. So keep this. -dgb
614 {
615 info.addPara("Scan six Gates with the instruments provided by Academician Coureuse", tc, pad);
616 pad = 0;
617 }
618
619 if (currentStage == Stage.RETURN_WITH_DEAL_AND_SCANS)
620 {
621 info.addPara("Return to the Galatia Academy with the six completed Gate scans", tc, pad);
622 }
623 else if (currentStage == Stage.FIRST_JANUS_EXPERIMENT)
624 {
625 info.addPara("Use the prototype Janus Device on a Gate in an uninhabited system outside of the "
626 + "Core worlds", tc, pad);
627 }
628 else if (currentStage == Stage.FIRST_JANUS_RESULTS)
629 {
630 info.addPara("Return to the Galatia Academy to report the results of the first Janus Prototype "
631 + "experiment", tc, pad);
632 }
633 else if (currentStage == Stage.COUREUSE_MISSION)
634 {
635 info.addPara("Contact Academician Scylla Coureuse about what she needs you to do", tc, pad);
636 }
637 else if (currentStage == Stage.TALK_TO_KANTA)
638 {
639 info.addPara("Use Gargoyle's token to arrange a meeting with Warlord Kanta in the Magec system - or find some other way to extract Zal", tc, pad);
640 }
641 else if (currentStage == Stage.FINDING_LOKE)
642 {
643 info.addPara("Find and extract the clone of Loke from the Pather kidnappers", tc, pad);
644 }
645 else if (currentStage == Stage.RETURN_TO_KANTA)
646 {
647 info.addPara("Return Clone Loke to Warlord Kanta", tc, pad);
648 }
649 else if (currentStage == Stage.GO_TO_MAGEC_GATE)
650 {
651 info.addPara("Go to the Magec Gate", tc, pad);
652 }
653 else if (currentStage == Stage.ZAL_TO_GALATIA)
654 {
655 info.addPara("Return to the Galatia Academy with Elissa Zal and the working Janus Device", tc, pad);
656 }
657
658 return false;
659 }
660
661 @Override
662 public String getBaseName() {
663 return "At The Gates";
664 }
665
666 @Override
667 public String getPostfixForState() {
668 if (startingStage != null) {
669 return "";
670 }
671 return super.getPostfixForState();
672 }
673
674
675 @Override
676 public void acceptImpl(InteractionDialogAPI dialog, Map<String, MemoryAPI> memoryMap) {
677 super.acceptImpl(dialog, memoryMap);
678 Global.getSector().getListenerManager().addListener(this);
679 }
680
681 @Override
682 protected void notifyEnding() {
683 Global.getSector().getListenerManager().removeListener(this);
684 super.notifyEnding();
685 }
686
687 // I guess either this doesn't need to be weighted, or I should integrate the weighted choice
688 // into this dang function. I'll do it ... later, maybe. -dgb, TODO
689 public ScanEncounterVariation pickGateEvent() {
690 WeightedRandomPicker<ScanEncounterVariation> picker = new WeightedRandomPicker<ScanEncounterVariation>(genRandom);
691 for (ScanEncounterVariation event : scanEncounterVariations) {
692 picker.add(event, 1f);
693 }
694 /*FactionData data = FACTION_DATA.get(factionId);
695 if (data != null) {
696 float w = Math.max(1f, data.events.length) / Math.max(1f, picker.getTotal());
697 w *= SPECIFIC_FACTION_SUBJECT_EVENT_LIKELIHOOD; // faction-specific is more likely than generic, overall
698 for (String event : data.events) {
699 picker.add(event, w);
700 }
701 }*/
702 return picker.pick();
703 }
704
705 public static String CHECKED_FOR_ENCOUNTER = "$gaATG_checkedForEncounter";
706 public void reportCurrentLocationChanged(LocationAPI prev, LocationAPI currLoc) {
707 if (getCurrentStage() == null) return;
708
709 // if in the wrong stage for gate encounters: return
710 if (((Enum)getCurrentStage()).ordinal() >= Stage.RETURN_WITH_DEAL_AND_SCANS.ordinal()) return;
711 if (((Enum)getCurrentStage()).ordinal() < Stage.TALK_TO_YARIBAY.ordinal()) return;
712
713 if(!(currLoc instanceof StarSystemAPI)) return;
714
715 // if no gate encounters remain, return.
716 if (scanEncounterVariations.isEmpty()) return;
717
718 StarSystemAPI system = (StarSystemAPI) currLoc;
719 if (system.getMemoryWithoutUpdate().getBoolean(CHECKED_FOR_ENCOUNTER)) return;
720 system.getMemoryWithoutUpdate().set(CHECKED_FOR_ENCOUNTER, true);
721
722 // We don't want the encounter fleet to get destroyed by pulsars or Remnants.
723 // Plus, this should make the Gate "interesting" enough already.
724 if (system.hasTag(Tags.THEME_UNSAFE)) return;
725 if(Misc.hasPulsar(system)) return;
726
727 // if the system is unsuitable - no gate, or gate is scanned: return
728 SectorEntityToken gate = null;
729 for (SectorEntityToken curr : system.getCustomEntitiesWithTag(Tags.GATE)) {
730 if (GateEntityPlugin.isScanned(curr)) continue;
731 if (GateEntityPlugin.isActive(curr)) continue;
732 // plus whatever other checks are needed
733 gate = curr;
734 break;
735 }
736
737 if (gate == null) return;
738
739 // Not every Gate has a cool story, right?
740 if (rollProbability(SYSTEM_NO_GATE_ENCOUNTER_CHANCE)) return;
741
742 // pick what type of encounter to do and spawn it
743 // also add a temporary flag to the system to not spawn *another* encounter here
744
745 ScanEncounterVariation chosenEncounter = null;
746
747 // testing.
748 //chosenEncounter = ScanEncounterVariation.HEGEMONY;
749
750
751 for (MarketAPI market : Global.getSector().getEconomy().getMarkets(system)) {
752 if (scanEncounterVariations.contains(ScanEncounterVariation.HEGEMONY) &&
753 market.getFactionId().equals(Factions.HEGEMONY) &&
754 rollProbability(FACTION_GATE_ENCOUNTER_CHANCE))
755 {
756 chosenEncounter = ScanEncounterVariation.HEGEMONY;
757 break;
758 }
759 else if (scanEncounterVariations.contains(ScanEncounterVariation.TRITACHYON) &&
760 market.getFactionId().equals(Factions.TRITACHYON) &&
761 rollProbability(FACTION_GATE_ENCOUNTER_CHANCE))
762 {
763 chosenEncounter = ScanEncounterVariation.TRITACHYON;
764 break;
765 }
766 else if (scanEncounterVariations.contains(ScanEncounterVariation.LUDDIC) &&
767 market.getFactionId().equals(Factions.LUDDIC_CHURCH) &&
768 rollProbability(FACTION_GATE_ENCOUNTER_CHANCE))
769 {
770 chosenEncounter = ScanEncounterVariation.LUDDIC;
771 break;
772 }
773 else if (scanEncounterVariations.contains(ScanEncounterVariation.LUDDIC) &&
774 market.getFactionId().equals(Factions.LUDDIC_CHURCH) &&
775 rollProbability(FACTION_GATE_ENCOUNTER_CHANCE))
776 {
777 chosenEncounter = ScanEncounterVariation.LUDDIC;
778 break;
779 }
780 else if (scanEncounterVariations.contains(ScanEncounterVariation.PIRATE) &&
781 market.getFactionId().equals(Factions.PIRATES) &&
782 rollProbability(FACTION_GATE_ENCOUNTER_CHANCE))
783 {
784 chosenEncounter = ScanEncounterVariation.PIRATE;
785 break;
786 }
787 }
788
789 // Choose randomly from the remaining options if none was picked.
790 if( chosenEncounter == null)
791 {
792 chosenEncounter = pickGateEvent();
793 }
794
795 if( chosenEncounter == null) return; // Uh oh?
796
797 scanEncounterVariations.remove(chosenEncounter);
798/*
799 System.out.println("scan chosen is " + chosenEncounter.toString());
800 System.out.println("remaining encounters:");
801 for (ScanEncounterVariation v : scanEncounterVariations) {
802 System.out.println(v.toString());
803 }
804 */
805
806 // if (system.getId().equals("corvus")) {
807 // // an alternate way to figure out what's appropriate where
808 // hasHegemony = true;
809 // }
810
811 // of note: since this happens when the player enters a system - i.e. not during mission creation,
812 // but while the actual mission is in progress - it's also ok to do things here directly in code
813 // instead of having to use triggers. The above commented out block is using a trigger (+ runTriggers())
814 // just because it's an easy way to spawn a fleet.
815
816 if(chosenEncounter == ScanEncounterVariation.DERELICT)
817 {
818 DerelictShipData params = new DerelictShipData(new PerShipData("apogee_Balanced", ShipCondition.BATTERED, 0f), false);
819
820 SectorEntityToken ship = BaseThemeGenerator.addSalvageEntity(system, Entities.WRECK, Factions.NEUTRAL, params);
821 ship.setDiscoverable(true);
822
823 ship.setCircularOrbit(gate, (float) Math.random() * 360f, 40f, 20f);
824
825 // Eh, maybe some base chance of recoverable vs. not? -dgb
826 ShipRecoverySpecialCreator creator = new ShipRecoverySpecialCreator(null, 0, 0, false, null, null);
827 Misc.setSalvageSpecial(ship, creator.createSpecial(ship, null));
828
829 ship.getMemoryWithoutUpdate().set("$gateScanDerelict", true);
830 }
831 else if(chosenEncounter == ScanEncounterVariation.HEGEMONY)
832 {
833 //gate.addTag("GAATGhegemonyScanFleet");
834
835 //if (hasHegemony) { // whatever conditions are appropriate
836 beginStageTrigger(getCurrentStage());
837 triggerCreateFleet(FleetSize.MEDIUM, FleetQuality.HIGHER, Factions.HEGEMONY, FleetTypes.PATROL_MEDIUM, gate);
838 triggerMakeNonHostile(); // should it be hostile?
839 //triggerMakeHostileAndAggressive();
840 //triggerMakeLowRepImpact();
841 //triggerFleetPatherNoDefaultTithe();
842
843 triggerPickLocationAroundEntity(gate, 100f);
844 triggerSpawnFleetAtPickedLocation("$gaATG_hegScanFleet", null);
845
846 triggerFleetSetPatrolActionText("scanning");
847 triggerFleetSetTravelActionText("repositioning");
848 triggerOrderFleetPatrol(true, gate);
849 triggerMakeFleetIgnoreOtherFleets(); // don't go chasing pirates, please.
850 triggerMakeFleetGoAwayAfterDefeat();
851 triggerFleetSetPatrolLeashRange(100f);
852
853 //triggerMakeFleetIgnoredByOtherFleets();
854
855 //triggerPickSetLocation(gate.getContainingLocation(), gate.getLocation()); // fleet should appear AT the gate.
856 //triggerPickLocationAtClosestToPlayerJumpPoint(probeSystem);
857 //triggerSetEntityToPickedJumpPoint();
858 //triggerPickLocationTowardsEntity(gate, 15f, getUnits(1.0f));
859 //triggerFleetMakeImportant(null, Stage.FOLLOW_THE_EXPERIMENTS);
860 //triggerOrderFleetInterceptPlayer();
861
862 triggerSetFleetMissionRef("$gaATG_ref"); // so they can be made unimportant
863 triggerFleetAddDefeatTrigger("GAATGhegGateScanFleetDefeated");
864 triggerFleetSetName("Special Task Force");
865 endTrigger();
866
867 // this'll execute the trigger added above immediately
868 List<CampaignFleetAPI> fleets = runStageTriggersReturnFleets(getCurrentStage());
869 if (fleets.isEmpty())
870 {
871 return; // something went wrong spawning a fleet, unlikely but technically possible
872 }
873 final CampaignFleetAPI fleet = fleets.get(0);
874
875 fleet.addEventListener(new BaseFleetEventListener() {
876 @Override
877 public void reportFleetDespawnedToListener(CampaignFleetAPI fleet, FleetDespawnReason reason, Object param) {
878 if (reason == FleetDespawnReason.DESTROYED_BY_BATTLE) {
879 // Cool! So now the fleet no longer blocks the Gate, and the Gate is no longer blocked. -dgb
880 fleet.getMemoryWithoutUpdate().unset("$gaATG_hegScanFleet");
881 encounterGateHegemony.getMemoryWithoutUpdate().unset("$GAATGhegemonyScanFleet");
882 }
883 }
884 });
885
886 encounterHegemonyFleet = fleets.get(0);
887
888 // Let's do this after the potential abort, just to be safe.
889 // If anything above fails, then the Gate isn't blocked -dgb.
891 setFlag(gate, "$GAATGhegemonyScanFleet", true);
892 }
893 else if(chosenEncounter == ScanEncounterVariation.JAMMER)
894 {
895 setFlag(gate, "$GAATGscanJammer", true);
896 }
897 else if(chosenEncounter == ScanEncounterVariation.ALARM)
898 {
899 setFlag(gate, "$GAATGscanAlarm", true);
900 }
901 else if(chosenEncounter == ScanEncounterVariation.LUDDIC)
902 {
903 beginStageTrigger(getCurrentStage());
904 triggerCreateFleet(FleetSize.MEDIUM, FleetQuality.LOWER, Factions.LUDDIC_CHURCH, FleetTypes.TRADE_LINER, gate);
905 triggerMakeNonHostile();
906 //triggerMakeLowRepImpact(); // Yeah uh, blowing away a civilian fleet would look bad.
907 triggerSetFleetSizeFraction(0.5f);
908 triggerSetFleetComposition(2f, 1f, 1f, 10f, 1f);
909 triggerPickLocationAroundEntity(gate, 50f);
910 triggerSpawnFleetAtPickedLocation("$gaATG_luddicScanFleet", null);
911 triggerFleetSetTravelActionText("holding vigil");
912 triggerFleetSetPatrolActionText("holding vigil");
913 triggerOrderFleetPatrol(true, gate);
914 triggerMakeFleetIgnoreOtherFleets(); // don't go chasing pirates, please.
915 triggerMakeFleetGoAwayAfterDefeat();
916 triggerFleetSetPatrolLeashRange(30f); // very close.
917 //triggerMakeFleetIgnoredByOtherFleets();
918 triggerSetFleetMissionRef("$gaATG_ref"); // so they can be made unimportant
919 triggerFleetAddDefeatTrigger("GAATGluddicScanFleetDefeated");
920 triggerFleetSetName("Sacred Vigil Flotilla");
921 endTrigger();
922
923 // this'll execute the trigger added above immediately
924 List<CampaignFleetAPI> fleets = runStageTriggersReturnFleets(getCurrentStage());
925 if (fleets.isEmpty())
926 {
927 return; // something went wrong spawning a fleet, unlikely but technically possible
928 }
929 final CampaignFleetAPI fleet = fleets.get(0);
930 encounterLuddicFleet = fleet;
931 encounterGateLuddic = gate;
932 setFlag(gate, "$GAATGluddicScanGate", true);
933
934 fleet.addEventListener(new BaseFleetEventListener() {
935 public void reportFleetDespawnedToListener(CampaignFleetAPI fleet, FleetDespawnReason reason, Object param) {
936 if (reason == FleetDespawnReason.DESTROYED_BY_BATTLE) {
937 fleet.getMemoryWithoutUpdate().unset("$gaATG_luddicScanFleet");
938 encounterGateLuddic.getMemoryWithoutUpdate().unset("$GAATGluddicScanGate");
939 }
940 }
941 });
942 }
943 else if(chosenEncounter == ScanEncounterVariation.PATHER)
944 {
945 // Just hostile Pathers. Maybe they should share their feelings/motivations with the player.
946 beginStageTrigger(getCurrentStage());
947 triggerCreateFleet(FleetSize.MEDIUM, FleetQuality.HIGHER, Factions.LUDDIC_PATH, FleetTypes.MERC_PRIVATEER, gate);
948 triggerFleetPatherNoDefaultTithe(); // They want to kill you.
949 triggerPickLocationAroundEntity(gate, 200f);
950 triggerSpawnFleetAtPickedLocation("$gaATG_patherScanFleet", null);
951 triggerOrderFleetPatrol(true, gate);
952 //triggerFleetSetPatrolActionText("guarding");
953 //triggerMakeFleetIgnoreOtherFleets(); // actually yes, chase the player. Or anyone else, who cares.
954 triggerMakeFleetGoAwayAfterDefeat();
955 triggerFleetSetPatrolLeashRange(60f); // very close.
956 triggerSetFleetMissionRef("$gaATG_ref"); // so they can be made unimportant
957 //triggerFleetAddDefeatTrigger("GAATGpatherScanFleetDefeated"); // don't need it - they won't block the gate except via hostility.
958 triggerFleetSetName("Ambush Fleet");
959 endTrigger();
960 }
961 else if(chosenEncounter == ScanEncounterVariation.PIRATE)
962 {
963 beginStageTrigger(getCurrentStage());
964 triggerCreateFleet(FleetSize.MEDIUM, FleetQuality.VERY_HIGH, Factions.PIRATES, FleetTypes.PATROL_LARGE, gate);
965 triggerMakeNonHostile(); // Will go hostile after yelling at you, or if you don't talk to them.
966 triggerMakeLowRepImpact(); // Yeah uh, blowing away a civilian fleet would look bad.
967 triggerPickLocationAroundEntity(gate, 250f);
968 triggerSpawnFleetAtPickedLocation("$gaATG_pirateScanFleet", null);
969 triggerFleetSetPatrolActionText("loitering");
970 triggerFleetSetTravelActionText("maneuvering");
971 triggerOrderFleetPatrol(true, gate);
972
973 triggerFleetSetPatrolLeashRange(250f); // fairly close.
974 //triggerMakeFleetIgnoredByOtherFleets();
975 triggerSetFleetMissionRef("$gaATG_ref"); // so they can be made unimportant
976 triggerFleetAddDefeatTrigger("GAATGpirateScanFleetDefeated");
977 triggerMakeFleetGoAwayAfterDefeat();
978 endTrigger();
979
980 // this'll execute the trigger added above immediately
981 List<CampaignFleetAPI> fleets = runStageTriggersReturnFleets(getCurrentStage());
982 if (fleets.isEmpty())
983 {
984 return; // something went wrong spawning a fleet, unlikely but technically possible
985 }
986 final CampaignFleetAPI fleet = fleets.get(0);
987
988 fleet.addEventListener(new BaseFleetEventListener() {
989 @Override
990 public void reportFleetDespawnedToListener(CampaignFleetAPI fleet, FleetDespawnReason reason, Object param) {
991 if (reason == FleetDespawnReason.DESTROYED_BY_BATTLE) {
992 fleet.getMemoryWithoutUpdate().unset("$gaATG_pirateScanFleet");
993 encounterGatePirate.getMemoryWithoutUpdate().unset("$GAATGpirateScanGate");
994 }
995 }
996 });
997 encounterGatePirate = gate;
998 encounterPirateFleet = fleet;
999 setFlag(gate, "$GAATGpirateScanGate", true);
1000 }
1001 else if(chosenEncounter == ScanEncounterVariation.SCAVENGER)
1002 {
1003 // Just a scavenger suspiciously nearby. Doesn't block the gate.
1004 beginStageTrigger(getCurrentStage());
1005 triggerCreateFleet(FleetSize.SMALL, FleetQuality.DEFAULT, Factions.INDEPENDENT, FleetTypes.SCAVENGER_MEDIUM, gate);
1006 triggerMakeNonHostile();
1007 triggerMakeLowRepImpact();
1008 triggerPickLocationAroundEntity(gate, 100f);
1009 triggerSpawnFleetAtPickedLocation("$gaATG_scavScanFleet", null);
1010 triggerFleetSetPatrolActionText("observing");
1011 triggerFleetSetTravelActionText("observing");
1012 triggerOrderFleetPatrol(true, gate);
1013 triggerMakeFleetIgnoreOtherFleets(); // don't go chasing pirates, please.
1014 triggerFleetSetPatrolLeashRange(250f);
1015 triggerMakeFleetIgnoredByOtherFleets(); // would be disappointing if they just got blasted.
1016 triggerSetFleetMissionRef("$gaATG_ref"); // so they can be made unimportant
1017 //triggerFleetAddDefeatTrigger("GAATGluddicScanFleetDefeated"); n/a
1018 triggerFleetSetName("Suspect Scavenger");
1019 triggerMakeFleetGoAwayAfterDefeat();
1020 endTrigger();
1021
1022 List<CampaignFleetAPI> fleets = runStageTriggersReturnFleets(getCurrentStage());
1023 if (fleets.isEmpty()) return;
1024 }
1025 else if(chosenEncounter == ScanEncounterVariation.TRITACHYON)
1026 {
1027 beginStageTrigger(getCurrentStage());
1028 triggerCreateFleet(FleetSize.LARGE, FleetQuality.HIGHER, Factions.TRITACHYON, FleetTypes.PATROL_LARGE, gate);
1029 triggerMakeNonHostile();
1030 //triggerMakeHostileAndAggressive();
1031 //triggerMakeLowRepImpact();
1032 //triggerFleetPatherNoDefaultTithe();
1033
1034 triggerPickLocationAroundEntity(gate, 100f);
1035 triggerSpawnFleetAtPickedLocation("$gaATG_ttScanFleet", null);
1036 triggerFleetSetTravelActionText("repositioning");
1037 triggerFleetSetPatrolActionText("scanning");
1038 triggerOrderFleetPatrol(true, gate);
1039 triggerMakeFleetIgnoreOtherFleets(); // don't go chasing pirates, please.
1040 triggerMakeFleetGoAwayAfterDefeat();
1041 triggerFleetSetPatrolLeashRange(100f);
1042
1043 //triggerMakeFleetIgnoredByOtherFleets();
1044
1045 triggerSetFleetMissionRef("$gaATG_ref"); // so they can be made unimportant
1046 triggerFleetAddDefeatTrigger("GAATGttGateScanFleetDefeated");
1047 triggerFleetSetName("Special Projects Detachment");
1048 endTrigger();
1049
1050 // this'll execute the trigger added above immediately
1051 List<CampaignFleetAPI> fleets = runStageTriggersReturnFleets(getCurrentStage());
1052 if (fleets.isEmpty())
1053 {
1054 return; // something went wrong spawning a fleet, unlikely but technically possible
1055 }
1056 final CampaignFleetAPI fleet = fleets.get(0);
1057
1058 fleet.addEventListener(new BaseFleetEventListener() {
1059 @Override
1060 public void reportFleetDespawnedToListener(CampaignFleetAPI fleet, FleetDespawnReason reason, Object param) {
1061 if (reason == FleetDespawnReason.DESTROYED_BY_BATTLE) {
1062 // Cool! So now the fleet no longer blocks the Gate, and the Gate is no longer blocked. -dgb
1063 fleet.getMemoryWithoutUpdate().unset("$gaATG_ttScanFleet");
1064 encounterGateTT.getMemoryWithoutUpdate().unset("$GAATGttScanGate");
1065 }
1066 }
1067 });
1068
1069 //encounterHegemonyFleet = fleets.get(0);
1070
1071 encounterGateTT = gate;
1072 setFlag(gate, "$GAATGttScanGate", true);
1073 }
1074 else
1075 {
1076 // none chosen? I guess don't do anything, huh. How'd you get here, anyway?
1077 return;
1078 }
1079 }
1080
1081 protected void spawnKantaVengeanceFleetPirateArmada(SectorEntityToken spawnPoint) {
1082 beginWithinHyperspaceRangeTrigger(magecGate, 3f, false, Stage.GO_TO_MAGEC_GATE);
1083 triggerCreateFleet(FleetSize.HUGE, FleetQuality.HIGHER, Factions.PIRATES, FleetTypes.PATROL_LARGE, spawnPoint);
1084 triggerSetFleetFaction(Factions.PIRATES);
1085 triggerSetFleetOfficers(OfficerNum.MORE, OfficerQuality.HIGHER);
1086 triggerAutoAdjustFleetStrengthMajor();
1087 triggerMakeHostileAndAggressive();
1088 triggerMakeNoRepImpact();
1089 triggerFleetAllowLongPursuit();
1090 triggerSetFleetAlwaysPursue();
1091 triggerPickLocationAroundEntity(spawnPoint, 100f);
1092 triggerSetFleetMissionRef("$gaATG_ref");
1093 triggerSpawnFleetAtPickedLocation("$gaATG_kantaVengeanceFleet", null);
1094 triggerOrderFleetInterceptPlayer();
1095 endTrigger();
1096 }
1097
1098 protected void spawnKantaVengeanceFleetPirateScout(SectorEntityToken spawnPoint) {
1099 beginWithinHyperspaceRangeTrigger(magecGate, 3f, false, Stage.GO_TO_MAGEC_GATE);
1100 triggerCreateFleet(FleetSize.MEDIUM, FleetQuality.HIGHER, Factions.PIRATES, FleetTypes.PATROL_SMALL, spawnPoint);
1101 triggerSetFleetFaction(Factions.PIRATES);
1102 triggerSetFleetOfficers(OfficerNum.MORE, OfficerQuality.DEFAULT);
1103 triggerAutoAdjustFleetStrengthMajor();
1104 triggerMakeHostileAndAggressive();
1105 triggerMakeNoRepImpact();
1106 triggerFleetAllowLongPursuit();
1107 triggerSetFleetAlwaysPursue();
1108 triggerFleetMakeFaster(true, 0, true);
1109 triggerPickLocationAroundEntity(spawnPoint, 100f);
1110 triggerSetFleetMissionRef("$gaATG_ref");
1111 triggerSpawnFleetAtPickedLocation("$gaATG_kantaVengeanceFleet", null);
1112 triggerOrderFleetInterceptPlayer();
1113 endTrigger();
1114 }
1115
1116 protected void spawnKantaVengeanceFleetMerc(SectorEntityToken spawnPoint) {
1117 beginWithinHyperspaceRangeTrigger(magecGate, 3f, false, Stage.GO_TO_MAGEC_GATE);
1118 triggerCreateFleet(FleetSize.LARGE, FleetQuality.VERY_HIGH, Factions.MERCENARY, FleetTypes.MERC_ARMADA, spawnPoint);
1119 triggerSetFleetFaction(Factions.PIRATES);
1120 triggerSetFleetOfficers(OfficerNum.MORE, OfficerQuality.HIGHER);
1121 triggerAutoAdjustFleetStrengthMajor();
1122 triggerMakeHostileAndAggressive();
1123 triggerMakeNoRepImpact();
1124 triggerFleetAllowLongPursuit();
1125 triggerSetFleetAlwaysPursue();
1126 triggerFleetMakeFaster(true, 1, true);
1127 triggerPickLocationAroundEntity(spawnPoint, 100f);
1128 triggerSetFleetMissionRef("$gaATG_ref");
1129 triggerSpawnFleetAtPickedLocation("$gaATG_kantaVengeanceFleet", null);
1130 triggerOrderFleetInterceptPlayer();
1131 endTrigger();
1132 }
1133}
1134
1135
1136
1137
1138
static SoundPlayerAPI getSoundPlayer()
Definition Global.java:43
static FactoryAPI getFactory()
Definition Global.java:35
static SectorAPI getSector()
Definition Global.java:59
static boolean isScanned(SectorEntityToken gate)
static boolean isActive(SectorEntityToken gate)
boolean callAction(String action, String ruleId, InteractionDialogAPI dialog, List< Token > params, Map< String, MemoryAPI > memoryMap)
boolean addNextStepText(TooltipMakerAPI info, Color tc, float pad)
void acceptImpl(InteractionDialogAPI dialog, Map< String, MemoryAPI > memoryMap)
boolean create(MarketAPI createdAt, boolean barEvent)
void reportCurrentLocationChanged(LocationAPI prev, LocationAPI currLoc)
void addDescriptionForNonEndStage(TooltipMakerAPI info, float width, float height)
void spawnKantaVengeanceFleetPirateArmada(SectorEntityToken spawnPoint)
CargoStackAPI createCargoStack(CargoItemType type, Object data, CargoAPI cargo)
SoundAPI playSound(String id, float pitch, float volume, Vector2f loc, Vector2f vel)