Starsector API
Loading...
Searching...
No Matches
RaidSecretOutpostMission.java
Go to the documentation of this file.
1package com.fs.starfarer.api.impl.campaign.missions;
2
3import java.awt.Color;
4import java.util.List;
5import java.util.Map;
6
7import com.fs.starfarer.api.campaign.InteractionDialogAPI;
8import com.fs.starfarer.api.campaign.PlanetAPI;
9import com.fs.starfarer.api.campaign.StarSystemAPI;
10import com.fs.starfarer.api.campaign.econ.CommodityOnMarketAPI;
11import com.fs.starfarer.api.campaign.econ.MarketAPI;
12import com.fs.starfarer.api.campaign.rules.MemoryAPI;
13import com.fs.starfarer.api.characters.PersonAPI;
14import com.fs.starfarer.api.impl.campaign.ids.Conditions;
15import com.fs.starfarer.api.impl.campaign.ids.Factions;
16import com.fs.starfarer.api.impl.campaign.ids.FleetTypes;
17import com.fs.starfarer.api.impl.campaign.ids.Tags;
18import com.fs.starfarer.api.impl.campaign.missions.SmugglingMission.Stage;
19import com.fs.starfarer.api.impl.campaign.missions.hub.HubMissionWithBarEvent;
20import com.fs.starfarer.api.impl.campaign.missions.hub.ReqMode;
21import com.fs.starfarer.api.ui.TooltipMakerAPI;
22import com.fs.starfarer.api.util.Misc;
23import com.fs.starfarer.api.util.Misc.Token;
24
25public class RaidSecretOutpostMission extends HubMissionWithBarEvent {
26
27 //public static float PIRATE_PROB = 0.5f;
28 public static float MISSION_DAYS = 120f;
29 public static int RAID_DIFFICULTY = 48;
30 public static int MARINES_REQUIRED = RAID_DIFFICULTY / 2;
31 public static float MIN_VALUE = 80000f;
32 public static float MAX_VALUE = 140000f;
33
34 public static enum Stage {
35 GO_TO_OUTPOST,
36 COMPLETED,
37 FAILED,
38 }
39
40 public static enum Variation {
41 BASIC,
42 DECIV,
43 }
44
45 protected MarketAPI market;
46 protected PersonAPI person;
47 protected PlanetAPI planet;
48 protected int goodsAmount;
49 protected CommodityOnMarketAPI com;
50 protected int quantity;
51 //protected Variation variation;
52
53
54 @Override
55 protected boolean create(MarketAPI createdAt, boolean barEvent) {
56 // if this mission type was already accepted by the player, abort
57 if (!setGlobalReference("$rsom_ref")) {
58 return false;
59 }
60
61 resetSearch();
62 requireSystemTags(ReqMode.ANY, Tags.THEME_REMNANT_SUPPRESSED, Tags.THEME_DERELICT, Tags.THEME_MISC, Tags.THEME_RUINS);
63 requireSystemTags(ReqMode.NOT_ANY, Tags.THEME_SPECIAL);
64 requireSystemInInnerSector();
65 //requireSystemHasPulsar();
66 //requireSystemIsDense();
67 //requirePlanetIsGasGiant();
68 requirePlanetNotGasGiant(); // for the writing.
69 requirePlanetConditions(ReqMode.NOT_ANY, Conditions.DECIVILIZED);
70 requirePlanetUnpopulated();
71 preferPlanetNotFullySurveyed();
72 preferPlanetUnexploredRuins();
73 preferPlanetInDirectionOfOtherMissions();
74 planet = pickPlanet();
75
76// spawnEntity(Entities.INACTIVE_GATE, "$gaData_test", EntityLocationType.ORBITING_PARAM,
77// planet, planet.getStarSystem(), false);
78// spawnMissionNode("$gaData_test", EntityLocationType.ORBITING_PARAM, planet, planet.getStarSystem());
79
80 if (planet == null) return false;
81
82 person = getPerson();
83 if (person == null) return false;
84
85 market = person.getMarket();
86 if (market == null) return false;
87
88 setStartingStage(Stage.GO_TO_OUTPOST);
89 addSuccessStages(Stage.COMPLETED);
90 addFailureStages(Stage.FAILED);
91
92 makeImportant(planet, "$rsom_targetPlanet", Stage.GO_TO_OUTPOST);
93 //makeImportant(person, "$rsom_contact", Stage.RETURN);
94
95 connectWithGlobalFlag(Stage.GO_TO_OUTPOST, Stage.COMPLETED, "$rsom_raidedOutpost");
96 //connectWithGlobalFlag(Stage.RETURN, Stage.COMPLETED, "$rsom_returnedData");
97
98 setNoAbandon();
99 setTimeLimit(Stage.FAILED, MISSION_DAYS, null);
100
101 requireCommodityIllegal();
102 requireCommodityDemandAtLeast(1);
103
104 //market = com.getMarket();
105 //if (market == null) return false;
106
107 com = pickCommodity();
108 if (com == null) return false;
109
110 float value = MIN_VALUE + getQuality() * (MAX_VALUE - MIN_VALUE);
111 value *= 0.9f + genRandom.nextFloat() * 0.2f;
112
113 quantity = getRoundNumber(value / com.getCommodity().getBasePrice());
114 if (quantity < 10) quantity = 10;
115
116
117 //setCreditReward(CreditReward.AVERAGE);
118
119// spawnEntity(Entities.FUSION_LAMP, "$gaData_test", EntityLocationType.ORBITING_PARAM,
120// planet, planet.getStarSystem(), false);
121
122// beginStageTrigger(Stage.GET_IN_COMMS_RANGE);
123// triggerSpawnEntity(Entities.INACTIVE_GATE, "$gaData_test", EntityLocationType.ORBITING_PARAM,
124// planet, planet.getStarSystem(), false);
125// triggerEntityMakeImportant();
126// endTrigger();
127
128 //StarSystemAPI system = planet.getStarSystem();
129
130 setRepFactionChangesNone(); // intra-underworld meddling pans out to no change, let's say.
131
132 return true;
133 }
134
135 protected void updateInteractionDataImpl() {
136 set("$rsom_contactName", person.getNameString());
137 set("$rsom_market", market.getName());
138 set("$rsom_planetId", planet.getId());
139 set("$rsom_planetName", planet.getName());
140 set("$rsom_systemName", planet.getStarSystem().getNameWithLowercaseType());
141 set("$rsom_dist", getDistanceLY(planet));
142 set("$rsom_product", com.getCommodity().getLowerCaseName());
143 set("$rsom_productID", com.getCommodity().getId());
144 set("$rsom_quantity", quantity);
145 set("$rsom_marinesReq", MARINES_REQUIRED);
146 set("$rsom_raidDifficulty", RAID_DIFFICULTY);
147
148 }
149
150 @Override
151 protected boolean callAction(String action, String ruleId, final InteractionDialogAPI dialog,
152 List<Token> params, final Map<String, MemoryAPI> memoryMap) {
153 if ("giveOutpostPlunder".equals(action)) {
154
155 return true;
156 }
157
158 return super.callAction(action, ruleId, dialog, params, memoryMap);
159 }
160
161 @Override
162 public void addDescriptionForNonEndStage(TooltipMakerAPI info, float width, float height) {
163 float opad = 10f;
164 Color h = Misc.getHighlightColor();
165 if (currentStage == Stage.GO_TO_OUTPOST) {
166
167 info.addPara(getGoToPlanetTextPre(planet) +
168 ", use the codes to bypass defenses to raid and plunder the " + com.getCommodity().getLowerCaseName() + " in the hidden outpost there. "
169 + "Bring at least %s marines to ensure success.", opad, h, Misc.getWithDGS(MARINES_REQUIRED));
170
171 //} else if (currentStage == Stage.RETURN) {
172 // info.addPara(getReturnText(market), opad);
173 }
174// else {
175// super.addDescriptionForCurrentStage(info, width, height); // shows the completed/failed/abandoned text, if needed
176// }
177 }
178
179 @Override
180 public boolean addNextStepText(TooltipMakerAPI info, Color tc, float pad) {
181 Color h = Misc.getHighlightColor();
182 if (currentStage == Stage.GO_TO_OUTPOST) {
183 //info.addPara("Go to " + planet.getName() + " in the " + planet.getStarSystem().getNameWithLowercaseTypeShort(), tc, pad);
184 info.addPara(getGoToPlanetTextShort(planet), tc, pad);
185 return true;
186 //} else if (currentStage == Stage.RETURN) {
187 // info.addPara(getReturnTextShort(market), tc, pad);
188 // return true;
189 }
190 return false;
191 }
192
193 @Override
194 public String getBaseName() {
195 return "Raid Secret Outpost";
196 }
197
198 @Override
199 public String getBlurbText() {
200 return null; // rules.csv
201 }
202
203}
204
205
void addDescriptionForNonEndStage(TooltipMakerAPI info, float width, float height)
boolean callAction(String action, String ruleId, final InteractionDialogAPI dialog, List< Token > params, final Map< String, MemoryAPI > memoryMap)