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
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
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
73
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
100 variation = Variation.REMNANTS;
101 //setCreditReward(50000, 60000);
102 setCreditReward(CreditReward.HIGH);
103 } else {
105 variation = Variation.PIRATES;
106 } else if (rollProbability(PROB_SCAVENGER)) {
107 variation = Variation.SCAVENGER;
108 } else {
109 variation = Variation.BASIC;
110 }
111 }
112
114
115// variation = Variation.BASIC;
116// variation = Variation.PIRATES;
117// variation = Variation.SCAVENGER;
118
119 if (variation == Variation.PIRATES) {
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);
140 triggerFleetMakeImportant("$gaDA_pirate", Stage.GET_IT_FROM_PIRATES);
141 triggerFleetAddDefeatTrigger("gaDAFleetWithWidgetDefeated");
142 endTrigger();
143 } else if (variation == Variation.SCAVENGER) {
144 scavPayment = genRoundNumber(10000, 15000);
145 scavPaymentHigh = genRoundNumber(20000, 25000);
146
147 beginStageTrigger(Stage.GET_IT_FROM_SCAVENGER);
148 triggerCreateFleet(FleetSize.MEDIUM, FleetQuality.LOWER, Factions.SCAVENGERS, FleetTypes.SCAVENGER_MEDIUM, system);
151
152// triggerFleetSetSingleShipOnly();
153// triggerFleetSetAllWeapons();
154// triggerFleetSetFlagship("radiant_Standard");
155// triggerFleetSetOfficers(OfficerNum.FC_ONLY, OfficerQuality.AI_ALPHA);
156
158
163
164 triggerFleetSetTravelActionText("exploring system");
165 triggerFleetSetPatrolActionText("preparing to leave system");
167
168 triggerFleetMakeImportant("$gaDA_scavenger", Stage.GET_IT_FROM_SCAVENGER);
169 triggerFleetAddDefeatTrigger("gaDAFleetWithWidgetDefeated");
170 endTrigger();
171 }
172
173 return true;
174 }
175
176 protected void updateInteractionDataImpl() {
177 set("$gaDA_department", department);
178 set("$gaDA_widget", widget);
179 set("$gaDA_widgetNoArticle", getWidgetWithoutArticle());
180 set("$gaDA_starName", entity.getStarSystem().getNameWithNoType());
181 set("$gaDA_systemName", entity.getStarSystem().getNameWithLowercaseTypeShort());
182 set("$gaDA_dist", getDistanceLY(entity));
183 set("$gaDA_fuel", getFuel(entity, true));
184 set("$gaDA_reward", Misc.getWithDGS(getCreditsReward()));
185 set("$gaDA_piratePayment", Misc.getWithDGS(piratePayment));
186 set("$gaDA_piratePaymentLow", Misc.getWithDGS(piratePaymentLow));
187 set("$gaDA_scavPayment", Misc.getWithDGS(scavPayment));
188 set("$gaDA_scavPaymentHigh", Misc.getWithDGS(scavPaymentHigh));
189
190 set("$gaDA_notRemnants", variation != Variation.REMNANTS);
191 set("$gaDA_variation", variation);
192 }
193
194 protected String getWidgetWithoutArticle() {
195 if (widget.startsWith("a ")) {
196 return widget.replaceFirst("a ", "");
197 }
198 if (widget.startsWith("an ")) {
199 return widget.replaceFirst("an ", "");
200 }
201 return widget;
202 }
203
204 @Override
205 public void addDescriptionForNonEndStage(TooltipMakerAPI info, float width, float height) {
206 float opad = 10f;
207 Color h = Misc.getHighlightColor();
208 if (currentStage == Stage.GO_TO_DERELCIT) {
209 String extra = "";
210 if (variation == Variation.REMNANTS) extra = " 'Autonomous weapon systems' may pose a danger.";
211 info.addPara("Retrieve " + widget + " from a derelict ship " + getLocated(entity) + "." + extra, opad);
212 } else if (currentStage == Stage.GET_IT_FROM_PIRATES) {
213 SectorEntityToken cache = getEntityFromGlobal("$gaDA_cache");
214 info.addPara("Retrieve the " + getWidgetWithoutArticle() +
215 " from the pirates as they resupply from a cache " + getLocated(cache) + ".", opad);
216 } else if (currentStage == Stage.GET_IT_FROM_SCAVENGER) {
217 info.addPara("Go to the nearest jump-point and retrieve the " + getWidgetWithoutArticle() +
218 " from scavengers before they leave the system.", opad);
219 } else if (currentStage == Stage.RETURN_TO_ACADEMY) {
220 info.addPara("Return the " + getWidgetWithoutArticle() + " to the Galatia Academy and talk to " +
221 getPerson().getNameString() + " to receive your reward.", opad);
222 }
223 }
224
225 @Override
226 public boolean addNextStepText(TooltipMakerAPI info, Color tc, float pad) {
227 Color h = Misc.getHighlightColor();
228 if (currentStage == Stage.GO_TO_DERELCIT) {
230 info.addPara("Retrieve the " + getWidgetWithoutArticle() + " from a derelict ship", tc, pad);
231 } else {
232 info.addPara(getGoToSystemTextShort(system), tc, pad);
233 }
234 return true;
235 } else if (currentStage == Stage.GET_IT_FROM_PIRATES) {
236 info.addPara("Retrieve the " + getWidgetWithoutArticle() + " from pirates in the " +
238 } else if (currentStage == Stage.GET_IT_FROM_SCAVENGER) {
239 info.addPara("Retrieve the " + getWidgetWithoutArticle() + " from scavengers at the nearest jump-point",
240 tc, pad);
241 } else if (currentStage == Stage.RETURN_TO_ACADEMY) {
242 info.addPara("Return to the Galatia Academy and talk to " + getPerson().getNameString(), tc, pad);
243 return true;
244 }
245 return false;
246 }
247
248 @Override
249 public String getBaseName() {
250 return "Derelict Artifact Recovery";
251 }
252
253}
254
255
static final String THEME_REMNANT_SECONDARY
Definition Tags.java:184
static final String THEME_REMNANT_RESURGENT
Definition Tags.java:188
static final String THEME_REMNANT_SUPPRESSED
Definition Tags.java:187
boolean addNextStepText(TooltipMakerAPI info, Color tc, float pad)
void addDescriptionForNonEndStage(TooltipMakerAPI info, float width, float height)
void connectWithGlobalFlag(Object from, Object to, String flag)
void setTimeLimit(Object failStage, float days, StarSystemAPI noLimitWhileInSystem, Object ... noLimitAfterStages)
SectorEntityToken spawnDerelictOfType(DerelictType type, LocData data)
void makeImportant(PersonAPI person, String flag, Enum ... stages)
int getFuel(SectorEntityToken entity, boolean bothWays)
void triggerCreateFleet(FleetSize size, FleetQuality quality, String factionId, String type, StarSystemAPI roughlyWhere)
static String getWithDGS(float num)
Definition Misc.java:1381
static Color getHighlightColor()
Definition Misc.java:792
LabelAPI addPara(String format, float pad, Color hl, String... highlights)