Starsector API
Loading...
Searching...
No Matches
GADataFromRuins.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.PlanetAPI;
6import com.fs.starfarer.api.campaign.StarSystemAPI;
7import com.fs.starfarer.api.campaign.econ.MarketAPI;
8import com.fs.starfarer.api.impl.campaign.ids.Conditions;
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 GADataFromRuins extends GABaseMission {
17
18// public static class GADataFromRuinsCreator extends BaseHubMissionCreator {
19// @Override
20// public HubMission createHubMission(MissionHub hub) {
21// return new GADataFromRuins();
22// }
23// }
24
25 public static float PIRATE_PROB = 0.5f;
26 public static float MISSION_DAYS = 120f;
27 public static int RAID_DIFFICULTY = 100;
28 public static int MARINES_REQUIRED = RAID_DIFFICULTY / 2;
29
30
31 public static enum Stage {
32 GO_TO_RUINS,
33 GET_IN_COMMS_RANGE,
34 COMPLETED,
35 FAILED,
36 }
37
38 public static enum Variation {
39 BASIC,
40 REMNANTS,
41 PULSAR,
42 DECIV,
43 }
44
45 protected PlanetAPI planet;
46 protected String targetWithArticle;
47 protected String target;
48 protected Variation variation;
49 protected int piratePayment;
50
51 @Override
52 protected boolean create(MarketAPI createdAt, boolean barEvent) {
53 // if this mission type was already accepted by the player, abort
54 if (!setGlobalReference("$gaData_ref")) {
55 return false;
56 }
57
59 targetWithArticle = pickOne("a library", "a datavault", "an archive", "a laboratory");
60 target = targetWithArticle.substring(targetWithArticle.indexOf(" ") + 1);
61
62 resetSearch();
63 requireSystemTags(ReqMode.ANY, Tags.THEME_REMNANT_RESURGENT, Tags.THEME_REMNANT_SUPPRESSED,
64 Tags.THEME_DERELICT, Tags.THEME_MISC, Tags.THEME_RUINS);
65 requireSystemTags(ReqMode.NOT_ANY, Tags.THEME_REMNANT_SECONDARY); // remove not-very-dangerous remnant systems
66 //requireSystemInInnerSector();
67 //requireSystemHasPulsar();
68 //requireSystemIsDense();
69 //requirePlanetIsGasGiant();
70 //requirePlanetConditions(ReqMode.ALL, Conditions.DECIVILIZED);
71 requirePlanetUnpopulated();
72 requirePlanetWithRuins();
73 preferPlanetNotFullySurveyed();
74 preferPlanetUnexploredRuins();
75 preferPlanetInDirectionOfOtherMissions();
76 planet = pickPlanet();
77
78// spawnEntity(Entities.INACTIVE_GATE, "$gaData_test", EntityLocationType.ORBITING_PARAM,
79// planet, planet.getStarSystem(), false);
80// spawnMissionNode("$gaData_test", EntityLocationType.ORBITING_PARAM, planet, planet.getStarSystem());
81
82 if (planet == null) {
83 return false;
84 }
85
86 setStartingStage(Stage.GO_TO_RUINS);
87 addSuccessStages(Stage.COMPLETED);
88 addFailureStages(Stage.FAILED);
89
90 makeImportant(planet, "$gaData_targetPlanet", Stage.GO_TO_RUINS);
91
92 connectWithGlobalFlag(Stage.GO_TO_RUINS, Stage.GET_IN_COMMS_RANGE, "$gaData_gotData");
93 connectWithInRangeOfCommRelay(Stage.GET_IN_COMMS_RANGE, Stage.COMPLETED);
94
95 setStageOnGlobalFlag(Stage.FAILED, "$gaData_gaveCoordsToPirates");
96 if (WITH_TIME_LIMIT) {
97 setTimeLimit(Stage.FAILED, MISSION_DAYS, planet.getStarSystem(), Stage.GET_IN_COMMS_RANGE);
98 }
99 //setCreditReward(30000, 40000);
100 setCreditReward(CreditReward.AVERAGE);
102
103// spawnEntity(Entities.FUSION_LAMP, "$gaData_test", EntityLocationType.ORBITING_PARAM,
104// planet, planet.getStarSystem(), false);
105
106// beginStageTrigger(Stage.GET_IN_COMMS_RANGE);
107// triggerSpawnEntity(Entities.INACTIVE_GATE, "$gaData_test", EntityLocationType.ORBITING_PARAM,
108// planet, planet.getStarSystem(), false);
109// triggerEntityMakeImportant();
110// endTrigger();
111
112 StarSystemAPI system = planet.getStarSystem();
113 if (system.hasTag(Tags.THEME_REMNANT)) {
114 variation = Variation.REMNANTS;
115 //setCreditReward(50000, 60000);
116 setCreditReward(CreditReward.HIGH);
117 } else if (Misc.hasPulsar(system)) {
118 variation = Variation.PULSAR;
119 } else if (planet.hasCondition(Conditions.DECIVILIZED)) {
120 variation = Variation.DECIV;
121 } else {
122 variation = Variation.BASIC;
123 }
124
125 //PIRATE_PROB = 1f;
126 if ((variation == Variation.BASIC || variation == Variation.DECIV) && rollProbability(PIRATE_PROB)) {
127 beginWithinHyperspaceRangeTrigger(planet, 1f, false, Stage.GO_TO_RUINS);
128 triggerCreateFleet(FleetSize.MEDIUM, FleetQuality.DEFAULT, Factions.PIRATES, FleetTypes.PATROL_MEDIUM, planet);
129 triggerAutoAdjustFleetStrengthMajor();
130 triggerSetStandardAggroPirateFlags();
131 //triggerFleetAllowLongPursuit();
132 //triggerPickLocationAroundEntity(planet, 3000f);
133 triggerPickLocationAtInSystemJumpPoint(planet.getStarSystem());
134 triggerSpawnFleetAtPickedLocation("$gaData_pirate", null);
135 triggerOrderFleetPatrol(planet);
136 triggerFleetMakeImportant(null, Stage.GO_TO_RUINS);
137 endTrigger();
138
139 piratePayment = genRoundNumber(5000, 15000);
140 }
141
142 return true;
143 }
144
145 protected void updateInteractionDataImpl() {
146 set("$gaData_department", department);
147 set("$gaData_target", target);
148 set("$gaData_planetId", planet.getId());
149 set("$gaData_planetName", planet.getName());
150 set("$gaData_systemName", planet.getStarSystem().getNameWithNoType());
151 set("$gaData_dist", getDistanceLY(planet));
152 set("$gaData_reward", Misc.getWithDGS(getCreditsReward()));
153 set("$gaData_piratePayment", Misc.getWithDGS(piratePayment));
154 //variation = Variation.BASIC;
155 set("$gaData_variation", variation);
156 if (variation == Variation.DECIV) {
157 set("$gaData_marinesReq", MARINES_REQUIRED);
158 set("$gaData_raidDifficulty", RAID_DIFFICULTY);
159 } else if (variation == Variation.PULSAR) {
160 PlanetAPI pulsar = Misc.getPulsarInSystem(planet.getStarSystem());
161 if (pulsar != null) {
162 set("$gaData_pulsarName", planet.getStarSystem().getNameWithNoType());
163 }
164 }
165 }
166
167 @Override
168 public void addDescriptionForNonEndStage(TooltipMakerAPI info, float width, float height) {
169 float opad = 10f;
170 Color h = Misc.getHighlightColor();
171 if (currentStage == Stage.GO_TO_RUINS) {
172 if (variation == Variation.DECIV) {
173 info.addPara(getGoToPlanetTextPre(planet) +
174 ", and retrieve the data from " + targetWithArticle + " found in the ruins there. Around %s " +
175 "marines will be needed to perform the recovery.", opad, h, Misc.getWithDGS(MARINES_REQUIRED));
176 } else {
177 String extra = "";
178 if (variation == Variation.REMNANTS) extra = " 'Autonomous weapon systems' may pose a danger.";
179 if (variation == Variation.PULSAR) extra = " Rapidly spinning jets of high energy charged particles are a once-in-a-lifetime sight.";
180 info.addPara(getGoToPlanetTextPre(planet) +
181 ", and retrieve the data from " + targetWithArticle + " found in the ruins there." + extra, opad);
182 }
183 } else if (currentStage == Stage.GET_IN_COMMS_RANGE) {
184 info.addPara(getGetWithinCommsRangeText(), opad);
185 }
186// else {
187// super.addDescriptionForCurrentStage(info, width, height); // shows the completed/failed/abandoned text, if needed
188// }
189 }
190
191 @Override
192 public boolean addNextStepText(TooltipMakerAPI info, Color tc, float pad) {
193 Color h = Misc.getHighlightColor();
194 if (currentStage == Stage.GO_TO_RUINS) {
195 //info.addPara("Go to " + planet.getName() + " in the " + planet.getStarSystem().getNameWithLowercaseTypeShort(), tc, pad);
196 info.addPara(getGoToPlanetTextShort(planet), tc, pad);
197 return true;
198 } else if (currentStage == Stage.GET_IN_COMMS_RANGE) {
199 info.addPara(getGetWithinCommsRangeTextShort(), tc, pad);
200 return true;
201 }
202 return false;
203 }
204
205 @Override
206 public String getBaseName() {
207 return "Ruins Data Recovery";
208 }
209
210 @Override
211 public String getBlurbText() {
212 return null; // moved this to rules.csv
213 }
214
215}
216
217
boolean addNextStepText(TooltipMakerAPI info, Color tc, float pad)
void addDescriptionForNonEndStage(TooltipMakerAPI info, float width, float height)