Starsector API
Loading...
Searching...
No Matches
GADerelictArtifact.java
Go to the documentation of this file.
1package com.fs.starfarer.api.impl.campaign.missions.academy;
2
3import java.awt.Color;
4
5import com.fs.starfarer.api.campaign.SectorEntityToken;
6import com.fs.starfarer.api.campaign.StarSystemAPI;
7import com.fs.starfarer.api.campaign.econ.MarketAPI;
8import com.fs.starfarer.api.impl.campaign.ids.Entities;
9import com.fs.starfarer.api.impl.campaign.ids.Factions;
10import com.fs.starfarer.api.impl.campaign.ids.FleetTypes;
11import com.fs.starfarer.api.impl.campaign.ids.Tags;
12import com.fs.starfarer.api.impl.campaign.missions.hub.ReqMode;
13import com.fs.starfarer.api.ui.TooltipMakerAPI;
14import com.fs.starfarer.api.util.Misc;
15
16public class GADerelictArtifact extends GABaseMission {
17
18 public static float MISSION_DAYS = 120f;
19 public static float PROB_PIRATES = 0.33f;
20 public static float PROB_SCAVENGER = 0.5f;
21
22
23 public static enum Stage {
24 GO_TO_DERELCIT,
25 GET_IT_FROM_PIRATES,
26 GET_IT_FROM_SCAVENGER,
27 RETURN_TO_ACADEMY,
28 COMPLETED,
29 FAILED,
30 }
31
32 public static enum Variation {
33 BASIC,
34 REMNANTS,
35 PIRATES,
36 SCAVENGER,
37 }
38
39 protected StarSystemAPI system;
40 protected SectorEntityToken entity;
41 protected StarSystemAPI pirateSystem;
42 protected String widget;
43 protected Variation variation;
44 protected int piratePayment;
45 protected int piratePaymentLow;
46 protected int scavPayment;
47 protected int scavPaymentHigh;
48
49 @Override
50 protected boolean create(MarketAPI createdAt, boolean barEvent) {
51 // if this mission type was already accepted by the player, abort
52 if (!setGlobalReference("$gaDA_ref")) {
53 return false;
54 }
55
58 widget = pickOne( "unique superconducting structural element",
59 "an advanced field conversion prototype",
60 "a transparametric integrator",
61 "an extremely rare material sample",
62 "an uncommon power system component",
63 "a Domain-era forge component",
64 "a small-scale momentum decoupling device",
65 "a fascinating low-power field projector");
66
67 requireSystemTags(ReqMode.ANY, Tags.THEME_REMNANT_RESURGENT, Tags.THEME_REMNANT_SUPPRESSED,
68 Tags.THEME_DERELICT, Tags.THEME_MISC, Tags.THEME_RUINS);
69 //requireSystemTags(ReqMode.ANY, Tags.THEME_REMNANT_RESURGENT, Tags.THEME_REMNANT_SUPPRESSED);
70 requireSystemTags(ReqMode.NOT_ANY, Tags.THEME_REMNANT_SECONDARY); // remove not-very-dangerous remnant systems
71 preferSystemUnexplored();
72 preferSystemInDirectionOfOtherMissions();
73
74 system = pickSystem();
75 if (system == null) return false;
76
77 entity = spawnDerelictOfType(null, new LocData(EntityLocationType.HIDDEN, null, system, false));
78 if (entity == null) return false;
79
80 setStartingStage(Stage.GO_TO_DERELCIT);
81 addSuccessStages(Stage.COMPLETED);
82 addFailureStages(Stage.FAILED);
83
84 makeImportant(entity, "$gaDA_entity", Stage.GO_TO_DERELCIT);
85 makeImportant(getPerson(), "$gaDA_returnHere", Stage.RETURN_TO_ACADEMY);
86
87 connectWithGlobalFlag(Stage.GO_TO_DERELCIT, Stage.GET_IT_FROM_PIRATES, "$gaDA_piratesTookIt");
88 connectWithGlobalFlag(Stage.GO_TO_DERELCIT, Stage.GET_IT_FROM_SCAVENGER, "$gaDA_scavengerTookIt");
89 setStageOnGlobalFlag(Stage.RETURN_TO_ACADEMY, "$gaDA_gotWidget");
90 connectWithGlobalFlag(Stage.RETURN_TO_ACADEMY, Stage.COMPLETED, "$gaDA_returnedWidget");
91
92 if (WITH_TIME_LIMIT) {
93 setTimeLimit(Stage.FAILED, MISSION_DAYS, entity.getStarSystem(), Stage.RETURN_TO_ACADEMY);
94 }
95 //setCreditReward(30000, 40000);
96 setCreditReward(CreditReward.AVERAGE);
98
99 if (system.hasTag(Tags.THEME_REMNANT)) {
100 variation = Variation.REMNANTS;
101 //setCreditReward(50000, 60000);
102 setCreditReward(CreditReward.HIGH);
103 } else {
104 if (rollProbability(PROB_PIRATES)) {
105 variation = Variation.PIRATES;
106 } else if (rollProbability(PROB_SCAVENGER)) {
107 variation = Variation.SCAVENGER;
108 } else {
109 variation = Variation.BASIC;
110 }
111 }
112
113 setMapMarkerNameColorBasedOnStar(system);
114
115// variation = Variation.BASIC;
116// variation = Variation.PIRATES;
117// variation = Variation.SCAVENGER;
118
119 if (variation == Variation.PIRATES) {
120 requireSystemTags(ReqMode.ANY, Tags.THEME_MISC_SKIP, Tags.THEME_DERELICT, Tags.THEME_MISC, Tags.THEME_RUINS);
121 requireSystemTags(ReqMode.NOT_ANY, Tags.THEME_UNSAFE);
122 requireSystemNot(system);
123 requireSystemWithinRangeOf(entity.getLocationInHyperspace(), 10);
124 pirateSystem = pickSystem();
125 if (pirateSystem == null) return false;
126
127 piratePayment = genRoundNumber(10000, 15000);
128 piratePaymentLow = genRoundNumber(2000, 5000);
129
130 beginStageTrigger(Stage.GET_IT_FROM_PIRATES);
131 triggerSpawnEntity(Entities.SUPPLY_CACHE, new LocData(EntityLocationType.HIDDEN, null, pirateSystem, false));
132 triggerSaveGlobalEntityRef("$gaDA_cache");
133 triggerCreateFleet(FleetSize.LARGE, FleetQuality.DEFAULT, Factions.PIRATES, FleetTypes.PATROL_MEDIUM, pirateSystem);
134 triggerAutoAdjustFleetStrengthMajor();
135 triggerSetStandardHostilePirateFlags();
136 triggerPickLocationAtInSystemJumpPoint(pirateSystem);
137 triggerSpawnFleetAtPickedLocation();
138 triggerOrderFleetPatrolEntity(true);
139 triggerFleetMakeImportant("$gaDA_pirate", Stage.GET_IT_FROM_PIRATES);
140 triggerFleetAddDefeatTrigger("gaDAFleetWithWidgetDefeated");
141 endTrigger();
142 } else if (variation == Variation.SCAVENGER) {
143 scavPayment = genRoundNumber(10000, 15000);
144 scavPaymentHigh = genRoundNumber(20000, 25000);
145
146 beginStageTrigger(Stage.GET_IT_FROM_SCAVENGER);
147 triggerCreateFleet(FleetSize.MEDIUM, FleetQuality.LOWER, Factions.SCAVENGERS, FleetTypes.SCAVENGER_MEDIUM, system);
148 triggerAutoAdjustFleetStrengthModerate();
149 triggerSetFleetFaction(Factions.INDEPENDENT);
150
151// triggerFleetSetSingleShipOnly();
152// triggerFleetSetAllWeapons();
153// triggerFleetSetFlagship("radiant_Standard");
154// triggerFleetSetOfficers(OfficerNum.FC_ONLY, OfficerQuality.AI_ALPHA);
155
156 triggerMakeLowRepImpact();
157
158 triggerPickLocationAtClosestToPlayerJumpPoint(system);
159 triggerSetEntityToPickedJumpPoint();
160 triggerPickLocationAroundEntity(5000);
161 triggerSpawnFleetAtPickedLocation();
162
163 triggerFleetSetTravelActionText("exploring system");
164 triggerFleetSetPatrolActionText("preparing to leave system");
165 triggerOrderFleetPatrolEntity(false);
166
167 triggerFleetMakeImportant("$gaDA_scavenger", Stage.GET_IT_FROM_SCAVENGER);
168 triggerFleetAddDefeatTrigger("gaDAFleetWithWidgetDefeated");
169 endTrigger();
170 }
171
172 return true;
173 }
174
175 protected void updateInteractionDataImpl() {
176 set("$gaDA_department", department);
177 set("$gaDA_widget", widget);
178 set("$gaDA_widgetNoArticle", getWidgetWithoutArticle());
179 set("$gaDA_starName", entity.getStarSystem().getNameWithNoType());
180 set("$gaDA_systemName", entity.getStarSystem().getNameWithLowercaseTypeShort());
181 set("$gaDA_dist", getDistanceLY(entity));
182 set("$gaDA_fuel", getFuel(entity, true));
183 set("$gaDA_reward", Misc.getWithDGS(getCreditsReward()));
184 set("$gaDA_piratePayment", Misc.getWithDGS(piratePayment));
185 set("$gaDA_piratePaymentLow", Misc.getWithDGS(piratePaymentLow));
186 set("$gaDA_scavPayment", Misc.getWithDGS(scavPayment));
187 set("$gaDA_scavPaymentHigh", Misc.getWithDGS(scavPaymentHigh));
188
189 set("$gaDA_notRemnants", variation != Variation.REMNANTS);
190 set("$gaDA_variation", variation);
191 }
192
193 protected String getWidgetWithoutArticle() {
194 if (widget.startsWith("a ")) {
195 return widget.replaceFirst("a ", "");
196 }
197 if (widget.startsWith("an ")) {
198 return widget.replaceFirst("an ", "");
199 }
200 return widget;
201 }
202
203 @Override
204 public void addDescriptionForNonEndStage(TooltipMakerAPI info, float width, float height) {
205 float opad = 10f;
206 Color h = Misc.getHighlightColor();
207 if (currentStage == Stage.GO_TO_DERELCIT) {
208 String extra = "";
209 if (variation == Variation.REMNANTS) extra = " 'Autonomous weapon systems' may pose a danger.";
210 info.addPara("Retrieve " + widget + " from a derelict ship " + getLocated(entity) + "." + extra, opad);
211 } else if (currentStage == Stage.GET_IT_FROM_PIRATES) {
212 SectorEntityToken cache = getEntityFromGlobal("$gaDA_cache");
213 info.addPara("Retrieve the " + getWidgetWithoutArticle() +
214 " from the pirates as they resupply from a cache " + getLocated(cache) + ".", opad);
215 } else if (currentStage == Stage.GET_IT_FROM_SCAVENGER) {
216 info.addPara("Go to the nearest jump-point and retrieve the " + getWidgetWithoutArticle() +
217 " from scavengers before they leave the system.", opad);
218 } else if (currentStage == Stage.RETURN_TO_ACADEMY) {
219 info.addPara("Return the " + getWidgetWithoutArticle() + " to the Galatia Academy and talk to " +
220 getPerson().getNameString() + " to receive your reward.", opad);
221 }
222 }
223
224 @Override
225 public boolean addNextStepText(TooltipMakerAPI info, Color tc, float pad) {
226 Color h = Misc.getHighlightColor();
227 if (currentStage == Stage.GO_TO_DERELCIT) {
228 if (system.isCurrentLocation()) {
229 info.addPara("Retrieve the " + getWidgetWithoutArticle() + " from a derelict ship", tc, pad);
230 } else {
231 info.addPara(getGoToSystemTextShort(system), tc, pad);
232 }
233 return true;
234 } else if (currentStage == Stage.GET_IT_FROM_PIRATES) {
235 info.addPara("Retrieve the " + getWidgetWithoutArticle() + " from pirates in the " +
236 pirateSystem.getNameWithLowercaseType(), tc, pad);
237 } else if (currentStage == Stage.GET_IT_FROM_SCAVENGER) {
238 info.addPara("Retrieve the " + getWidgetWithoutArticle() + " from scavengers at the nearest jump-point",
239 tc, pad);
240 } else if (currentStage == Stage.RETURN_TO_ACADEMY) {
241 info.addPara("Return to the Galatia Academy and talk to " + getPerson().getNameString(), tc, pad);
242 return true;
243 }
244 return false;
245 }
246
247 @Override
248 public String getBaseName() {
249 return "Derelict Artifact Recovery";
250 }
251
252}
253
254
boolean addNextStepText(TooltipMakerAPI info, Color tc, float pad)
void addDescriptionForNonEndStage(TooltipMakerAPI info, float width, float height)