Starsector API
Loading...
Searching...
No Matches
GACelestialObject.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.CampaignTerrainAPI;
6import com.fs.starfarer.api.campaign.SectorEntityToken;
7import com.fs.starfarer.api.campaign.StarSystemAPI;
8import com.fs.starfarer.api.campaign.econ.MarketAPI;
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.ids.Terrain;
13import com.fs.starfarer.api.impl.campaign.missions.hub.ReqMode;
14import com.fs.starfarer.api.ui.TooltipMakerAPI;
15import com.fs.starfarer.api.util.Misc;
16
17public class GACelestialObject extends GABaseMission {
18
19 public static float MISSION_DAYS = 120f;
20 public static float PROB_HOLOARTS = 0.33f;
21 public static float PROB_PATHERS = 0.5f;
22 public static float PROB_SLIPUP = 0.33f;
23
24 public static float PROB_PULSAR = 0.33f;
25 public static float PROB_BLACK_HOLE = 0.5f;
26
27 public static float PROB_NOT_ASTEROIDS = 0.5f;
28
29
30 public static enum Stage {
31 GO_TO_OBJECT,
32 COMPLETED,
33 FAILED,
34 }
35
36 public static enum Variation {
37 BASIC,
38 PULSAR,
39 BLACK_HOLE,
40 }
41
43 protected Variation variation;
45 protected boolean holoarts = false;
46 protected boolean slipUp = false;
47 protected int patherTithe = 0;
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("$gaCO_ref")) {
53 return false;
54 }
55
58 department = "Holoart Studies";
59 holoarts = true;
60 }
61
67 }
68
69 if (!holoarts) {
72 } else if (rollProbability(PROB_BLACK_HOLE)) {
74 }
75 } else {
78 }
79
80 // important to put these last - requirements that come earlier have higher priority
81 //preferTerrainHasSpecialName();
84
85 object = pickTerrain();
86
87 if (object == null) {
88 return false;
89 }
90
91 system = object.getStarSystem();
92
93 setStartingStage(Stage.GO_TO_OBJECT);
94 addSuccessStages(Stage.COMPLETED);
95 addFailureStages(Stage.FAILED);
96
97 //makeImportant(object, "$gaCO_object", Stage.GO_TO_OBJECT);
98 SectorEntityToken node = spawnMissionNode(new LocData(object));
99 makeImportant(node, "$gaCO_object", Stage.GO_TO_OBJECT);
100
101
102 setStageOnGlobalFlag(Stage.COMPLETED, "$gaCO_scanCompleted");
103 setStageOnGlobalFlag(Stage.FAILED, "$gaCO_gaveScannerToPathers");
104
105 if (WITH_TIME_LIMIT) {
106 setTimeLimit(Stage.FAILED, MISSION_DAYS, system);
107 }
108 //setCreditReward(30000, 40000);
109 setCreditReward(CreditReward.AVERAGE);
111
112 if (system.hasPulsar()) {
113 variation = Variation.PULSAR;
114 } else if (system.hasBlackHole()) {
115 variation = Variation.BLACK_HOLE;
116 } else {
117 variation = Variation.BASIC;
118 }
119
121
123 patherTithe = genRoundNumber(10000, 15000);
124
125 beginWithinHyperspaceRangeTrigger(object, 1f, false, Stage.GO_TO_OBJECT);
126 triggerCreateFleet(FleetSize.LARGE, FleetQuality.HIGHER, Factions.LUDDIC_PATH, FleetTypes.PATROL_MEDIUM, object);
132 triggerSpawnFleetAtPickedLocation("$gaCO_patherPermanentFlag", null);
135 // so that the tithe value is available if the interaction with the fleet is after the mission ends
137 triggerFleetMakeImportant("$gaCO_patherMissionInProgress", Stage.GO_TO_OBJECT);
138 endTrigger();
139
140 }
141
143
144
145 return true;
146 }
147
148 protected void updateInteractionDataImpl() {
149 set("$gaCO_department", department);
150 set("$gaCO_holoarts", holoarts);
151 set("$gaCO_slipUp", slipUp);
152 set("$gaCO_objectAOrAn", getTerrainNameAOrAn(object));
153 set("$gaCO_celestialObjectNameWithTypeShort", getObjectNameWithTypeShort());
154 set("$gaCO_celestialObjectNameWithTypeLong", getObjectNameWithTypeLong());
155 set("$gaCO_celestialObjectName", getTerrainName(object));
156 set("$gaCO_celestialObjectType", getTerrainType(object));
157 set("$gaCO_starName", system.getNameWithNoType());
158 set("$gaCO_systemName", system.getNameWithLowercaseTypeShort());
159 set("$gaCO_dist", getDistanceLY(object));
160 set("$gaCO_reward", Misc.getWithDGS(getCreditsReward()));
161 set("$gaCO_variation", variation);
162 }
163
164 @Override
165 public void addDescriptionForNonEndStage(TooltipMakerAPI info, float width, float height) {
166 float opad = 10f;
167 Color h = Misc.getHighlightColor();
168 if (currentStage == Stage.GO_TO_OBJECT) {
169 String extra = "";
170 if (variation == Variation.BLACK_HOLE) extra = " Avoid the black hole located in-system.";
171 else if (variation == Variation.PULSAR) extra = " Avoid the beam of the in-system pulsar.";
172 info.addPara("Run a scan package on " + getObjectNameWithTypeShort() +
173 " located in the " + system.getNameWithLowercaseTypeShort() + "." + extra, opad);
174 }
175 }
176
177 @Override
178 public boolean addNextStepText(TooltipMakerAPI info, Color tc, float pad) {
179 Color h = Misc.getHighlightColor();
180 if (currentStage == Stage.GO_TO_OBJECT) {
181 info.addPara("Scan " + getTerrainTypeAOrAn(object) + " " + getTerrainType(object) +
182 " in the " + system.getNameWithLowercaseTypeShort(), tc, pad);
183 return true;
184 }
185 return false;
186 }
187
188 protected String getObjectNameWithTypeLong() {
189 if (hasSpecialName(object)) {
190 return getTerrainName(object) + " - that's " + getTerrainTypeAOrAn(object) + " " + getTerrainType(object);
191 } else {
192 return getTerrainTypeAOrAn(object) + " " + getTerrainType(object);
193 }
194 }
195 protected String getObjectNameWithTypeShort() {
196 if (hasSpecialName(object)) {
197 return getTerrainName(object) + ", " + getTerrainTypeAOrAn(object) + " " + getTerrainType(object);
198 } else {
199 return getTerrainTypeAOrAn(object) + " " + getTerrainType(object);
200 }
201 }
202
203 @Override
204 public String getBaseName() {
205 return "Scan Celestial Object";
206 }
207
208}
209
210
void addDescriptionForNonEndStage(TooltipMakerAPI info, float width, float height)
boolean addNextStepText(TooltipMakerAPI info, Color tc, float pad)
void setTimeLimit(Object failStage, float days, StarSystemAPI noLimitWhileInSystem, Object ... noLimitAfterStages)
void makeImportant(PersonAPI person, String flag, Enum ... stages)
static String getTerrainNameAOrAn(CampaignTerrainAPI terrain)
static boolean hasSpecialName(CampaignTerrainAPI terrain)
static String getTerrainTypeAOrAn(CampaignTerrainAPI terrain)
void beginWithinHyperspaceRangeTrigger(SectorEntityToken entity, float rangeLY, boolean requirePlayerInHyperspace, Object ... stages)
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)