Starsector API
Loading...
Searching...
No Matches
TutorialMissionEvent.java
Go to the documentation of this file.
1package com.fs.starfarer.api.impl.campaign.tutorial;
2
3import java.awt.Color;
4import java.util.ArrayList;
5import java.util.List;
6import java.util.Map;
7import java.util.Random;
8
9import com.fs.starfarer.api.Global;
10import com.fs.starfarer.api.campaign.BaseOnMessageDeliveryScript;
11import com.fs.starfarer.api.campaign.CampaignFleetAPI;
12import com.fs.starfarer.api.campaign.CargoAPI;
13import com.fs.starfarer.api.campaign.CommDirectoryEntryAPI;
14import com.fs.starfarer.api.campaign.FactionAPI;
15import com.fs.starfarer.api.campaign.InteractionDialogAPI;
16import com.fs.starfarer.api.campaign.OnMessageDeliveryScript;
17import com.fs.starfarer.api.campaign.PlanetAPI;
18import com.fs.starfarer.api.campaign.SectorEntityToken;
19import com.fs.starfarer.api.campaign.StarSystemAPI;
20import com.fs.starfarer.api.campaign.CommDirectoryEntryAPI.EntryType;
21import com.fs.starfarer.api.campaign.comm.CommMessageAPI;
22import com.fs.starfarer.api.campaign.comm.MessagePriority;
23import com.fs.starfarer.api.campaign.econ.MarketAPI;
24import com.fs.starfarer.api.campaign.events.CampaignEventTarget;
25import com.fs.starfarer.api.campaign.rules.MemoryAPI;
26import com.fs.starfarer.api.characters.PersonAPI;
27import com.fs.starfarer.api.fleet.FleetMemberAPI;
28import com.fs.starfarer.api.fleet.FleetMemberType;
29import com.fs.starfarer.api.impl.campaign.JumpPointInteractionDialogPluginImpl;
30import com.fs.starfarer.api.impl.campaign.events.BaseEventPlugin;
31import com.fs.starfarer.api.impl.campaign.ids.Abilities;
32import com.fs.starfarer.api.impl.campaign.ids.Commodities;
33import com.fs.starfarer.api.impl.campaign.ids.Entities;
34import com.fs.starfarer.api.impl.campaign.ids.Factions;
35import com.fs.starfarer.api.impl.campaign.ids.MemFlags;
36import com.fs.starfarer.api.impl.campaign.ids.Ranks;
37import com.fs.starfarer.api.impl.campaign.ids.Submarkets;
38import com.fs.starfarer.api.impl.campaign.ids.Tags;
39import com.fs.starfarer.api.impl.campaign.intel.SystemBountyIntel;
40import com.fs.starfarer.api.impl.campaign.intel.SystemBountyManager;
41import com.fs.starfarer.api.impl.campaign.rulecmd.AddRemoveCommodity;
42import com.fs.starfarer.api.impl.campaign.submarkets.StoragePlugin;
43import com.fs.starfarer.api.loading.WeaponSlotAPI;
44import com.fs.starfarer.api.ui.HintPanelAPI;
45import com.fs.starfarer.api.util.Misc;
46import com.fs.starfarer.api.util.Misc.Token;
47
48public class TutorialMissionEvent extends BaseEventPlugin {
49
50 public static final String TUT_STAGE = "$tutStage";
51
52 public static final String REASON = "tut";
53
54 public static enum TutorialMissionStage {
55 INIT,
56 GO_GET_DATA,
57 GOT_DATA,
58 GO_GET_AI_CORE,
59 GOT_AI_CORE,
60 GO_RECOVER_SHIPS,
61 RECOVERED_SHIPS,
62 GO_STABILIZE,
63 STABILIZED,
64 DELIVER_REPORT,
65 DONE,
66 ;
67 }
68
69 protected float elapsedDays = 0;
70 protected boolean ended = false;
71
72 //protected TutorialMissionEventData data;
73 protected StarSystemAPI system;
74 protected PlanetAPI ancyra;
75 protected PlanetAPI pontus;
76 protected PlanetAPI tetra;
77 protected SectorEntityToken derinkuyu;
78 protected SectorEntityToken probe;
79 protected SectorEntityToken inner;
80 protected SectorEntityToken fringe;
81 protected SectorEntityToken detachment;
82 protected SectorEntityToken relay;
83
84 protected PersonAPI mainContact;
85 protected PersonAPI dataContact;
86 protected PersonAPI jangalaContact;
87 protected PlanetAPI jangala;
88
89 protected TutorialMissionStage stage = TutorialMissionStage.INIT;
90
91 public void init(String type, CampaignEventTarget eventTarget) {
92 super.init(type, eventTarget, false);
93 }
94
95 @Override
96 public void setParam(Object param) {
97 //data = (TutorialMissionEventData) param;
98 }
99
100 public void startEvent() {
101 super.startEvent();
102
103 system = Global.getSector().getStarSystem("galatia");
104 ancyra = (PlanetAPI) system.getEntityById("ancyra");
105 pontus = (PlanetAPI) system.getEntityById("pontus");
106 tetra = (PlanetAPI) system.getEntityById("tetra");
107 derinkuyu = system.getEntityById("derinkuyu_station");
108 probe = system.getEntityById("galatia_probe");
109 inner = system.getEntityById("galatia_jump_point_alpha");
110 fringe = system.getEntityById("galatia_jump_point_fringe");
111 detachment = system.getEntityById("tutorial_security_detachment");
112 relay = system.getEntityById("ancyra_relay");
113
114// mainContact = ancyra.getFaction().createRandomPerson();
115// mainContact.setRankId(Ranks.CITIZEN);
116// mainContact.setPostId(Ranks.POST_STATION_COMMANDER);
117// ancyra.getMarket().getCommDirectory().addPerson(mainContact);
119
120 dataContact = Global.getSector().getFaction(Factions.INDEPENDENT).createRandomPerson();
121 dataContact.setRankId(Ranks.AGENT);
122 dataContact.setPostId(Ranks.POST_AGENT);
123 derinkuyu.getMarket().getCommDirectory().addPerson(dataContact);
124
125 String stageId = "start";
126 Global.getSector().reportEventStage(this, stageId, Global.getSector().getPlayerFleet(),
127 MessagePriority.DELIVER_IMMEDIATELY, createSetMessageLocationScript(ancyra));
128
129
130 mainContact.getMemoryWithoutUpdate().set("$tut_mainContact", true);
131 mainContact.getMemoryWithoutUpdate().set("$tut_eventRef", this);
132 Misc.makeImportant(mainContact, REASON);
133
134 updateStage(TutorialMissionStage.INIT);
135 }
136
137 public static PersonAPI createMainContact(PlanetAPI ancyra) {
138 PersonAPI mainContact = ancyra.getFaction().createRandomPerson();
139 mainContact.setRankId(Ranks.CITIZEN);
140 mainContact.setPostId(Ranks.POST_STATION_COMMANDER);
141 ancyra.getMarket().getCommDirectory().addPerson(mainContact);
142
143 return mainContact;
144 }
145
146 public static PersonAPI getJangalaContact() {
147 StarSystemAPI corvus = Global.getSector().getStarSystem("Corvus");
148 PlanetAPI jangala = (PlanetAPI) corvus.getEntityById("jangala");
149
150 for (CommDirectoryEntryAPI entry : jangala.getMarket().getCommDirectory().getEntriesCopy()) {
151 if (entry.getType() == EntryType.PERSON && entry.getEntryData() instanceof PersonAPI) {
152 PersonAPI curr = (PersonAPI) entry.getEntryData();
153 if (Ranks.POST_STATION_COMMANDER.equals(curr.getPostId())) {
154 return curr;
155 }
156 }
157 }
158 return null;
159 }
160
161 public PersonAPI getMainContact() {
162 return mainContact;
163 }
164
165 protected void updateStage(TutorialMissionStage stage) {
166 this.stage = stage;
167 Global.getSector().getMemoryWithoutUpdate().set(TUT_STAGE, stage.name());
168 }
169
170 protected void endEvent() {
171 ended = true;
172 Global.getSector().getMemoryWithoutUpdate().unset(TUT_STAGE);
173 }
174
175 public void advance(float amount) {
176 if (!isEventStarted()) return;
177 if (isDone()) return;
178
179 float days = Global.getSector().getClock().convertToDays(amount);
180
181 CampaignFleetAPI player = Global.getSector().getPlayerFleet();
182 if (player == null) return;
183
184 //memory.advance(days);
185 elapsedDays += days;
186
187 if (probe == null) probe = system.getEntityById("galatia_probe");
188 if (tetra == null) tetra = (PlanetAPI) system.getEntityById("tetra");
189 if (derinkuyu == null) derinkuyu = system.getEntityById("derinkuyu_station");
190 if (inner == null) inner = system.getEntityById("galatia_jump_point_alpha");
191 if (fringe == null) fringe = system.getEntityById("galatia_jump_point_fringe");
192 if (detachment == null) detachment = system.getEntityById("tutorial_security_detachment");
193
194 if (stage == TutorialMissionStage.GO_GET_AI_CORE) {
195 int cores = (int) player.getCargo().getCommodityQuantity(Commodities.GAMMA_CORE);
196 float distToProbe = Misc.getDistance(player.getLocation(), probe.getLocation());
197 if (cores > 0 && (!probe.isAlive() || distToProbe < 300)) {
198 Global.getSector().reportEventStage(this, "salvage_core_end", Global.getSector().getPlayerFleet(),
199 MessagePriority.DELIVER_IMMEDIATELY, createSetMessageLocationScript(ancyra));
200 Misc.makeImportant(mainContact, REASON);
201 updateStage(TutorialMissionStage.GOT_AI_CORE);
202 }
203 }
204
205 if (stage == TutorialMissionStage.GO_RECOVER_SHIPS) {
206 int count = 0;
207 for (FleetMemberAPI member : player.getFleetData().getMembersListCopy()) {
208 //if (member.getVariant().getHullSpec().isDHull()) count++;
209 count++;
210 }
211
212 int wrecks = 0;
213 for (SectorEntityToken entity : system.getEntitiesWithTag(Tags.SALVAGEABLE)) {
214 String id = entity.getCustomEntityType();
215 if (id == null) continue;
216 if (Entities.WRECK.equals(id)) {
217 wrecks ++;
218 }
219 }
220
221 if (count >= 5 || wrecks < 3) {
222 Global.getSector().reportEventStage(this, "ship_recovery_end", Global.getSector().getPlayerFleet(),
223 MessagePriority.DELIVER_IMMEDIATELY, createSetMessageLocationScript(ancyra));
224 Misc.makeImportant(mainContact, REASON);
225 Misc.makeUnimportant(tetra, REASON);
226 updateStage(TutorialMissionStage.RECOVERED_SHIPS);
227 }
228 }
229
230 if (stage == TutorialMissionStage.GO_STABILIZE) {
231 boolean innerStable = inner.getMemoryWithoutUpdate().getExpire(JumpPointInteractionDialogPluginImpl.UNSTABLE_KEY) > 0;
232 boolean fringeStable = fringe.getMemoryWithoutUpdate().getExpire(JumpPointInteractionDialogPluginImpl.UNSTABLE_KEY) > 0;
233
234 if (innerStable || fringeStable) {
235 Global.getSector().reportEventStage(this, "stabilize_jump_point_done", Global.getSector().getPlayerFleet(),
236 MessagePriority.DELIVER_IMMEDIATELY, createSetMessageLocationScript(ancyra));
237 Misc.makeImportant(mainContact, REASON);
238 Misc.makeUnimportant(inner, REASON);
239 updateStage(TutorialMissionStage.STABILIZED);
240 }
241
242 }
243
244 }
245
246
247 @Override
248 public boolean callEvent(String ruleId, final InteractionDialogAPI dialog, List<Token> params, Map<String, MemoryAPI> memoryMap) {
249 String action = params.get(0).getString(memoryMap);
250
251 CampaignFleetAPI playerFleet = Global.getSector().getPlayerFleet();
252 CargoAPI cargo = playerFleet.getCargo();
253
254 if (action.equals("startGetData")) {
255 Global.getSector().reportEventStage(this, "sneak_start", Global.getSector().getPlayerFleet(),
256 MessagePriority.DELIVER_IMMEDIATELY, createSetMessageLocationScript(derinkuyu));
257
258 dataContact.getMemoryWithoutUpdate().set("$tut_dataContact", true);
259 dataContact.getMemoryWithoutUpdate().set("$tut_eventRef", this);
260 Misc.makeImportant(dataContact, REASON);
261 Misc.makeUnimportant(mainContact, REASON);
262
263 detachment.getMemoryWithoutUpdate().set(MemFlags.MEMORY_KEY_PATROL_ALLOW_TOFF, true);
264
265 updateStage(TutorialMissionStage.GO_GET_DATA);
266
267 saveNag();
268 } else if (action.equals("endGetData")) {
269
270 Global.getSector().reportEventStage(this, "sneak_end", Global.getSector().getPlayerFleet(),
271 MessagePriority.DELIVER_IMMEDIATELY, createSetMessageLocationScript(ancyra));
272 Misc.cleanUpMissionMemory(dataContact.getMemoryWithoutUpdate(), "tut_");
273
274 Misc.makeUnimportant(dataContact, REASON);
275 Misc.makeImportant(mainContact, REASON);
276
277 updateStage(TutorialMissionStage.GOT_DATA);
278
279 } else if (action.equals("goSalvage")) {
280 Global.getSector().reportEventStage(this, "salvage_core_start", Global.getSector().getPlayerFleet(),
281 MessagePriority.DELIVER_IMMEDIATELY, createSetMessageLocationScript(pontus));
282 Misc.makeUnimportant(mainContact, REASON);
283 Misc.makeImportant(probe, REASON);
284
285 updateStage(TutorialMissionStage.GO_GET_AI_CORE);
286
287 saveNag();
288 } else if (action.equals("goRecover")) {
289 Global.getSector().reportEventStage(this, "ship_recovery_start", Global.getSector().getPlayerFleet(),
290 MessagePriority.DELIVER_IMMEDIATELY, createSetMessageLocationScript(tetra));
291 Misc.makeUnimportant(mainContact, REASON);
292 Misc.makeImportant(tetra, REASON);
293
294 FleetMemberAPI member = Global.getFactory().createFleetMember(FleetMemberType.SHIP, "mudskipper_Standard");
295 playerFleet.getFleetData().addFleetMember(member);
296 AddRemoveCommodity.addFleetMemberGainText(member, dialog.getTextPanel());
297
298 updateStage(TutorialMissionStage.GO_RECOVER_SHIPS);
299 } else if (action.equals("goStabilize")) {
300 Global.getSector().reportEventStage(this, "stabilize_jump_point", Global.getSector().getPlayerFleet(),
301 MessagePriority.DELIVER_IMMEDIATELY, createSetMessageLocationScript(inner));
302 Misc.makeUnimportant(mainContact, REASON);
303 Misc.makeImportant(inner, REASON);
304
306
307 inner.getMemoryWithoutUpdate().set(JumpPointInteractionDialogPluginImpl.CAN_STABILIZE, true);
308 fringe.getMemoryWithoutUpdate().set(JumpPointInteractionDialogPluginImpl.CAN_STABILIZE, true);
309
310 updateStage(TutorialMissionStage.GO_STABILIZE);
311
312 saveNag();
313 } else if (action.equals("pickJangalaContact")) {
314
315 StarSystemAPI corvus = Global.getSector().getStarSystem("Corvus");
316 jangala = (PlanetAPI) corvus.getEntityById("jangala");
317
319
320 MemoryAPI mem = mainContact.getMemoryWithoutUpdate();
321 mem.set("$jangalaContactPost", jangalaContact.getPost().toLowerCase(), 0);
322 mem.set("$jangalaContactLastName", jangalaContact.getName().getLast(), 0);
323
324 float distLY = Misc.getDistanceLY(playerFleet.getLocationInHyperspace(), jangala.getLocationInHyperspace());
325 distLY += 4f;
326
327 float fuel = playerFleet.getLogistics().getFuelCostPerLightYear() * distLY;
328 fuel = (float) (Math.ceil(fuel / 10) * 10);
329 mem.set("$jangalaFuel", (int) fuel);
330
331 } else if (action.equals("deliverReport")) {
332 Global.getSector().reportEventStage(this, "deliver_message", Global.getSector().getPlayerFleet(),
333 MessagePriority.DELIVER_IMMEDIATELY, createSetMessageLocationScript(jangala));
334
335 Misc.makeUnimportant(mainContact, REASON);
336 Misc.cleanUpMissionMemory(mainContact.getMemoryWithoutUpdate(), REASON + "_");
337 Misc.makeUnimportant(inner, REASON);
338
339 jangalaContact.getMemoryWithoutUpdate().set("$tut_jangalaContact", true);
340 jangalaContact.getMemoryWithoutUpdate().set("$tut_eventRef", this);
341 Misc.makeImportant(jangalaContact, REASON);
342
343 updateStage(TutorialMissionStage.DELIVER_REPORT);
344
346
347 Global.getSector().getMemoryWithoutUpdate().unset(CampaignTutorialScript.USE_TUTORIAL_RESPAWN);
348
349 } else if (action.equals("reportDelivered")) {
350 Global.getSector().reportEventStage(this, "end", Global.getSector().getPlayerFleet(),
351 MessagePriority.DELIVER_IMMEDIATELY, createSetMessageLocationScript(jangala));
352
353 Misc.makeUnimportant(jangalaContact, REASON);
354 Misc.cleanUpMissionMemory(jangalaContact.getMemoryWithoutUpdate(), REASON + "_");
355
356 updateStage(TutorialMissionStage.DONE);
357
358 MarketAPI jangala = Global.getSector().getEconomy().getMarket("jangala");
359
360 if (jangala != null) {
361 SystemBountyManager.getInstance().addOrResetBounty(jangala);
362 }
363
364 endEvent();
365 } else if (action.equals("printRefitHint")) {
366 String refit = Global.getSettings().getControlStringForEnumName("CORE_REFIT");
367 String autofit = Global.getSettings().getControlStringForEnumName("REFIT_MANAGE_VARIANTS");
368 String transponder = "";
369 if (!playerFleet.isTransponderOn()) {
370 transponder = "\n\nAlso: you'll need to re-dock with your transponder turned on to take advantage of Ancyra's facilities.";
371 }
372 dialog.getTextPanel().addPara("(Once this conversation is over, press %s to open the refit screen. " +
373 "After selecting a specific ship, you can press %s to %s - pick a desired loadout, " +
374 "and the ship will be automatically refitted to match it, using what weapons are available." +
375 transponder + "",
376 Misc.getHighlightColor(), refit, autofit, "\"autofit\"");
377
378 dialog.getTextPanel().addPara("In addition, you now have access to local storage at Ancyra, " +
379 "and some weapons and supplies have been placed there. To access it, click on the " +
380 "\"Storage\" button in the trade screen.)",
381 Misc.getHighlightColor(), refit, autofit, "\"Storage\"");
382 }
383
384 return true;
385 }
386
387 public static void endGalatiaPortionOfMission() {
388
389 StarSystemAPI system = Global.getSector().getStarSystem("galatia");
390 PlanetAPI ancyra = (PlanetAPI) system.getEntityById("ancyra");
391 PlanetAPI pontus = (PlanetAPI) system.getEntityById("pontus");
392 PlanetAPI tetra = (PlanetAPI) system.getEntityById("tetra");
393 SectorEntityToken derinkuyu = system.getEntityById("derinkuyu_station");
394 SectorEntityToken probe = system.getEntityById("galatia_probe");
395 SectorEntityToken inner = system.getEntityById("galatia_jump_point_alpha");
396 SectorEntityToken fringe = system.getEntityById("galatia_jump_point_fringe");
397 SectorEntityToken relay = system.getEntityById("ancyra_relay");
398
399 relay.getMemoryWithoutUpdate().unset(MemFlags.OBJECTIVE_NON_FUNCTIONAL);
400
401 Global.getSector().getCharacterData().addAbility(Abilities.TRANSPONDER);
402 Global.getSector().getCharacterData().addAbility(Abilities.GO_DARK);
403 Global.getSector().getCharacterData().addAbility(Abilities.SENSOR_BURST);
404 Global.getSector().getCharacterData().addAbility(Abilities.EMERGENCY_BURN);
405 Global.getSector().getCharacterData().addAbility(Abilities.SUSTAINED_BURN);
406 Global.getSector().getCharacterData().addAbility(Abilities.SCAVENGE);
407 Global.getSector().getCharacterData().addAbility(Abilities.INTERDICTION_PULSE);
408 Global.getSector().getCharacterData().addAbility(Abilities.DISTRESS_CALL);
409
410 FactionAPI hegemony = Global.getSector().getFaction(Factions.HEGEMONY);
411 if (hegemony.getRelToPlayer().getRel() < 0) {
412 hegemony.getRelToPlayer().setRel(0);
413 }
414
415 Global.getSector().getEconomy().addMarket(ancyra.getMarket(), false);
416 Global.getSector().getEconomy().addMarket(derinkuyu.getMarket(), false);
417
418 HintPanelAPI hints = Global.getSector().getCampaignUI().getHintPanel();
419 if (hints != null) {
420 hints.clearHints(false);
421 }
422
423 if (!SystemBountyManager.getInstance().isActive(ancyra.getMarket())) {
424 SystemBountyManager.getInstance().addActive(new SystemBountyIntel(ancyra.getMarket()));
425 }
426// CampaignEventManagerAPI eventManager = Global.getSector().getEventManager();
427// eventManager.startEvent(new CampaignEventTarget(ancyra.getMarket()), Events.SYSTEM_BOUNTY, null);
428
430 for (int i = 0; i < 20; i++) {
431 script.advance(1f);
432 }
433 system.addScript(script);
434
435 for (CampaignFleetAPI fleet : system.getFleets()) {
436 if (Factions.PIRATES.equals(fleet.getFaction().getId())) {
437 fleet.removeScriptsOfClass(TutorialLeashAssignmentAI.class);
438 }
439 }
440
441 inner.getMemoryWithoutUpdate().unset(JumpPointInteractionDialogPluginImpl.UNSTABLE_KEY);
442 inner.getMemoryWithoutUpdate().unset(JumpPointInteractionDialogPluginImpl.CAN_STABILIZE);
443
444 fringe.getMemoryWithoutUpdate().unset(JumpPointInteractionDialogPluginImpl.UNSTABLE_KEY);
445 fringe.getMemoryWithoutUpdate().unset(JumpPointInteractionDialogPluginImpl.CAN_STABILIZE);
446 }
447
448
449
450
451 protected void saveNag() {
452 if (!Global.getSector().hasScript(SaveNagScript.class)) {
453 Global.getSector().addScript(new SaveNagScript(10f));
454 }
455 }
456
457
458 public void addWeaponsToStorage() {
459 StoragePlugin plugin = ((StoragePlugin)ancyra.getMarket().getSubmarket(Submarkets.SUBMARKET_STORAGE).getPlugin());
460 plugin.setPlayerPaidToUnlock(true);
461
462 CargoAPI cargo = plugin.getCargo();
463
464 CampaignFleetAPI player = Global.getSector().getPlayerFleet();
465 for (FleetMemberAPI member : player.getFleetData().getMembersListCopy()) {
466 //if (member.getVariant().getHullSpec().isDHull()) {
467 for (WeaponSlotAPI slot : member.getVariant().getHullSpec().getAllWeaponSlotsCopy()) {
468 //if (member.getVariant().getWeaponId(slot.getId()) == null) {
469 String weaponId = getWeaponForSlot(slot);
470 if (weaponId != null) {
471 cargo.addWeapons(weaponId, 1);
472 }
473 //}
474 }
475 //}
476 }
477
478 cargo.addFighters("broadsword_wing", 1);
479 cargo.addFighters("piranha_wing", 1);
480
481 cargo.addSupplies(50);
482 cargo.sort();
483 }
484
485 public String getWeaponForSlot(WeaponSlotAPI slot) {
486 switch (slot.getWeaponType()) {
487 case BALLISTIC:
488 case COMPOSITE:
489 case HYBRID:
490 case UNIVERSAL:
491 switch (slot.getSlotSize()) {
492 case LARGE: return pick("mark9", "hephag", "hellbore");
493 case MEDIUM: return pick("arbalest", "heavymortar", "shredder");
494 case SMALL: return pick("lightmg", "lightac", "lightmortar");
495 }
496 break;
497 case MISSILE:
498 case SYNERGY:
499 switch (slot.getSlotSize()) {
500 case LARGE: return pick("hammerrack");
501 case MEDIUM: return pick("pilum", "annihilatorpod");
502 case SMALL: return pick("harpoon", "sabot", "annihilator");
503 }
504 break;
505 case ENERGY:
506 switch (slot.getSlotSize()) {
507 case LARGE: return pick("autopulse", "hil");
508 case MEDIUM: return pick("miningblaster", "gravitonbeam", "pulselaser");
509 case SMALL: return pick("mininglaser", "taclaser", "pdlaser", "ioncannon");
510 }
511 break;
512 }
513
514
515 return null;
516 }
517
518 public String pick(String ...strings) {
519 return strings[new Random().nextInt(strings.length)];
520 }
521
522
523 public OnMessageDeliveryScript createSetMessageLocationScript(final SectorEntityToken entity) {
524 return new BaseOnMessageDeliveryScript() {
525 public void beforeDelivery(CommMessageAPI message) {
526 if (entity != null && entity.getContainingLocation() instanceof StarSystemAPI) {
527 message.setStarSystemId(entity.getContainingLocation().getId());
528 } else {
529 message.setStarSystemId(system.getId());
530 }
531 message.setCenterMapOnEntity(entity);
532 }
533 };
534 }
535
536
537 public Map<String, String> getTokenReplacements() {
538
539 Map<String, String> map = super.getTokenReplacements();
540
541 addPersonTokens(map, "mainContact", mainContact);
542
543 if (dataContact != null) {
544 addPersonTokens(map, "dataContact", dataContact);
545 }
546
547 if (jangalaContact != null) {
548 addPersonTokens(map, "jangalaContact", jangalaContact);
549 }
550
551 //map.put("$sender", "Ancyra Research Facility");
552
553 map.put("$systemName", system.getNameWithLowercaseType());
554
555
556 return map;
557 }
558
559 @Override
560 public String[] getHighlights(String stageId) {
561 List<String> result = new ArrayList<String>();
562
563 if ("posting".equals(stageId)) {
564 } else if ("success".equals(stageId)) {
565 } else {
566 //addTokensToList(result, "$rewardCredits");
567 }
568
569 return result.toArray(new String[0]);
570 }
571
572 @Override
573 public Color[] getHighlightColors(String stageId) {
574 return super.getHighlightColors(stageId);
575 }
576
577 public boolean isDone() {
578 return ended;
579 }
580
581 public String getEventName() {
582 if (stage == TutorialMissionStage.INIT) {
583 return "Contact " + mainContact.getPost() + " " + mainContact.getName().getLast();
584 }
585 if (stage == TutorialMissionStage.DELIVER_REPORT) {
586 return "Deliver Report to Jangala";
587 }
588 if (stage == TutorialMissionStage.DONE) {
589 return "Deliver Report to Jangala - completed";
590 }
591 return "Stabilize the Jump-points";
592 }
593
594
595
596 @Override
597 public CampaignEventCategory getEventCategory() {
598 return CampaignEventCategory.MISSION;
599 }
600
601 @Override
602 public String getEventIcon() {
603 return Global.getSettings().getSpriteName("campaignMissions", "tutorial");
604 }
605
606 @Override
607 public String getCurrentImage() {
608 return ancyra.getFaction().getLogo();
609 }
610
611
612
613}
614
615
616
static SettingsAPI getSettings()
Definition Global.java:51
static FactoryAPI getFactory()
Definition Global.java:35
static SectorAPI getSector()
Definition Global.java:59
void init(String type, CampaignEventTarget eventTarget)
boolean callEvent(String ruleId, final InteractionDialogAPI dialog, List< Token > params, Map< String, MemoryAPI > memoryMap)
OnMessageDeliveryScript createSetMessageLocationScript(final SectorEntityToken entity)
FleetMemberAPI createFleetMember(FleetMemberType type, String variantOrWingId)
String getSpriteName(String category, String id)
String getControlStringForEnumName(String name)