Starsector API
Loading...
Searching...
No Matches
LuddicPilgrimsPath.java
Go to the documentation of this file.
1package com.fs.starfarer.api.impl.campaign.missions.luddic;
2
3import java.awt.Color;
4import java.util.List;
5import java.util.Map;
6
7import com.fs.starfarer.api.Global;
8import com.fs.starfarer.api.campaign.FactionAPI;
9import com.fs.starfarer.api.campaign.InteractionDialogAPI;
10import com.fs.starfarer.api.campaign.SectorEntityToken;
11import com.fs.starfarer.api.campaign.StarSystemAPI;
12import com.fs.starfarer.api.campaign.comm.IntelInfoPlugin;
13import com.fs.starfarer.api.campaign.econ.MarketAPI;
14import com.fs.starfarer.api.campaign.rules.MemoryAPI;
15import com.fs.starfarer.api.characters.PersonAPI;
16import com.fs.starfarer.api.impl.campaign.ids.Tags;
17import com.fs.starfarer.api.impl.campaign.intel.misc.LuddicShrineIntel;
18import com.fs.starfarer.api.impl.campaign.missions.academy.GACelestialObject.Variation;
19import com.fs.starfarer.api.impl.campaign.missions.hub.HubMissionWithSearch;
20import com.fs.starfarer.api.ui.IntelUIAPI;
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 LuddicPilgrimsPath extends HubMissionWithSearch {
26
27 public static enum Stage {
28 VISIT_SHRINES,
29 RETURN_TO_GILEAD,
30 COMPLETED,
31 }
32
33 public static String VISITED_SHRINE_JANGALA = "$lpp_visitedShrineJangala";
34 public static String VISITED_SHRINE_KILLA = "$lpp_visitedShrineKilla";
35 public static String VISITED_SHRINE_VOLTURN = "$lpp_visitedShrineVolturn";
36 public static String VISITED_SHRINE_CHICOMOZTOC = "$lpp_visitedShrineChicomoztoc";
37 public static String VISITED_SHRINE_GILEAD = "$lpp_visitedShrineGilead";
38 public static String VISITED_SHRINE_BEHOLDER = "$lpp_visitedShrineBeholder";
39
40 protected int xpRewardBase = 10000;
41 protected int xpRewardIncrease = 2000;
42 protected int num_rewards_given = 0;
43
44 //protected PersonAPI robed_man;
45 //protected PersonAPI some_kid;
46 //protected PersonAPI robot;
47
48 protected MarketAPI volturn;
49 protected MarketAPI gilead;
50 protected MarketAPI jangala;
51 protected MarketAPI hesperus;
52 protected SectorEntityToken killa;
53 protected SectorEntityToken beholder_station;
54 //public static float MISSION_DAYS = 120f;
55
56 //protected int payment;
57 //protected int paymentHigh;
58
59 @Override
60 protected boolean create(MarketAPI createdAt, boolean barEvent) {
61 // if already accepted by the player, abort
62 if (!setGlobalReference("$lpp_ref", "$lpp_inProgress")) {
63 return false;
64 }
65
66 volturn = Global.getSector().getEconomy().getMarket("volturn");
67 if (volturn == null) return false;
68 //if (!volturn.getFactionId().equals("sindrian_diktat")) return false;
69
70
71 gilead = Global.getSector().getEconomy().getMarket("gilead");
72 if (gilead == null) return false;
73
74 jangala = Global.getSector().getEconomy().getMarket("jangala");
75 if (jangala == null) return false;
76
77 hesperus = Global.getSector().getEconomy().getMarket("hesperus");
78 if (hesperus == null) return false;
79
80 // Find Killa!
81 StarSystemAPI yma = Global.getSector().getStarSystem("yma");
82 for (SectorEntityToken curr : yma.getEntitiesWithTag(Tags.LUDDIC_SHRINE)) {
83 killa = curr;
84 break;
85 }
86 if (killa == null) return false;
87
88 // Find Beholder Station!
89 StarSystemAPI kumarikandam = Global.getSector().getStarSystem("kumari kandam");
90 for (SectorEntityToken curr : kumarikandam.getEntitiesWithTag(Tags.LUDDIC_SHRINE)) {
91 beholder_station = curr;
92 break;
93 }
94 if (beholder_station == null) return false;
95
96 setStartingStage(Stage.VISIT_SHRINES);
97 addSuccessStages(Stage.COMPLETED);
98
99 setStoryMission();
100 //addTag(Tags.INTEL_SHRINES);
101
102 // yes, these exact numbers.
103 //payment = 10000;
104 //paymentHigh = 17000;
105
106
107 // TODO - makeImportant all the shrines!
108 setStageOnGlobalFlag(Stage.RETURN_TO_GILEAD, "$lpp_visitedAllShrines");
109
110 makeImportant(gilead, "$lpp_finishPilgrimage", Stage.RETURN_TO_GILEAD);
111 //setStageOnMemoryFlag(Stage.COMPLETED, gilead, "$lpp_completed");
112
113 setStageOnGlobalFlag(Stage.COMPLETED, "$lpp_completed");
114
115
116
117 setName("The Pilgrim's Path");
118 setRepFactionChangesNone();
119 setRepPersonChangesNone();
120
121 beginStageTrigger(Stage.COMPLETED);
122 triggerMakeNonStoryCritical("jangala", "hesperus", "gilead", "volturn");
123 triggerSetGlobalMemoryValue("$lpp_missionCompleted", true);
124 endTrigger();
125
126
127 //makeImportant(coureuse, null, Stage.TALK_TO_COUREUSE);
128// Global.getSector().getMemoryWithoutUpdate().unset("$gaFC_triedToSeeCavin");
129 return true;
130 }
131
132 protected void updateInteractionDataImpl() {
133 set("$lpp_stage", getCurrentStage());
134 //set("$anh_robedman", robed_man);
135 }
136
137 @Override
138 protected boolean callAction(String action, String ruleId, final InteractionDialogAPI dialog,
139 List<Token> params, final Map<String, MemoryAPI> memoryMap) {
140// if ("THEDUEL".equals(action)) {
141// TextPanelAPI text = dialog.getTextPanel();
142// text.setFontOrbitronUnnecessarilyLarge();
143// Color color = Misc.getBasePlayerColor();
144// color = Global.getSector().getFaction(Factions.HEGEMONY).getBaseUIColor();
145// text.addPara("THE DUEL", color);
146// text.setFontInsignia();
147// text.addImage("misc", "THEDUEL");
148// return true;
149// }
150
151 if ("giveVisitXP".equals(action))
152 {
154 long xp_to_give = (long)(num_rewards_given * xpRewardIncrease + xpRewardBase);
155 Global.getSector().getPlayerStats().addXP(xp_to_give, dialog.getTextPanel());
156 return true;
157 }
158 else if ("giveLastVisitXP".equals(action))
159 {
161 long xp_to_give = (long)(num_rewards_given * xpRewardIncrease + xpRewardBase);
162
163 // it's possible the player visited shrines before taking on the mission
164 // so add all that XP as a lump sum onto the end
165 int visited_shrines = getNumberOfShrinesVisited();
166 if (num_rewards_given < visited_shrines)
167 {
168 for (int i = num_rewards_given; i < visited_shrines; i++)
169 {
170 xp_to_give += (long)(i * xpRewardIncrease + xpRewardBase);
171 }
172 }
173
174 Global.getSector().getPlayerStats().addXP(xp_to_give, dialog.getTextPanel());
175 return true;
176 }
177 else if ("checkShrinesVisited".equals(action)) {
178
179 int visited_shrines = getNumberOfShrinesVisited();
180 int numberOfShrinesToComplete = 6;
181 System.out.print("checkShrinesVisited = " + Integer.toString(visited_shrines));
182
183 if( visited_shrines >= numberOfShrinesToComplete) {
184 Global.getSector().getMemoryWithoutUpdate().set("$lpp_visitedAllShrines", true);
185 }
186 return true;
187 }
188 else if ("postMissionCleanup".equals(action)) {
189 // clean up any unneeded memory things.
190 Global.getSector().getMemoryWithoutUpdate().unset("$lpp_didHesperusFirstShrineAttempt");
191 Global.getSector().getMemoryWithoutUpdate().unset("$lpp_didHookStart");
192 gilead.getMemoryWithoutUpdate().unset("$lpp_finishPilgrimage");
193 return true;
194 }
195
196 return super.callAction(action, ruleId, dialog, params, memoryMap);
197 }
198
199 @Override
200 public void createSmallDescription(TooltipMakerAPI info, float width, float height) {
201 Color h = Misc.getHighlightColor();
202 Color g = Misc.getGrayColor();
203 float pad = 3f;
204 float opad = 10f;
205
206 FactionAPI faction = getFactionForUIColors();
207 PersonAPI person = getPerson();
208
209 info.addImage(Global.getSettings().getSpriteName("illustrations", "luddic_shrine"), width, opad);
210
211 addDescriptionForCurrentStage(info, width, height);
212
213 addBulletPoints(info, ListInfoMode.IN_DESC);
214 }
215
216
217 @Override
218 public void addDescriptionForNonEndStage(TooltipMakerAPI info, float width, float height) {
219 float opad = 10f;
220 Color h = Misc.getHighlightColor();
221 //Color h2 = Misc.getDarkHighlightColor();
222 //FactionAPI church = Global.getSector().getFaction(Factions.LUDDIC_CHURCH);
223
224 //info.addImage(robed_man.getPortraitSprite(), width, 128, opad);
225 /*
226 if (Global.getSector().getMemoryWithoutUpdate().getBoolean(VISITED_SHRINE_JANGALA)) {
227
228 }
229 */
230
231 if (currentStage == Stage.VISIT_SHRINES) {
232 info.addPara("Visit the six shrines of the Pilgrim's Path. The pilgrimage is traditionally completed by returning to Gilead, in the Canaan system.", opad);
233 }
234 else if (currentStage == Stage.RETURN_TO_GILEAD) {
235 info.addPara("Return to the shrine of Gilead in the Canaan system to complete the Pilgrim's Path.", opad);
236 }
237
238 LuddicShrineIntel.addShowShrinesButton(this, width, height, info);
239 }
240
241 @Override
242 public boolean addNextStepText(TooltipMakerAPI info, Color tc, float pad) {
243 Color h = Misc.getHighlightColor();
244 if (currentStage == Stage.VISIT_SHRINES) {
245 info.addPara("Visit the six Luddic shrines", tc, pad);
246 return true;
247 }
248 else if (currentStage == Stage.RETURN_TO_GILEAD) {
249 info.addPara("Complete the pilgrimage on Gilead, in the Canaan system", tc, pad);
250 return true;
251 }
252 return false;
253
254 /*
255 Color h = Misc.getHighlightColor();
256 if (currentStage == Stage.DROP_OFF) {
257 info.addPara("Deliver " + getWithoutArticle(thing) + " to specified location in the " +
258 system.getNameWithLowercaseTypeShort(), tc, pad);
259 return true;
260 }
261 */
262 }
263
264 @Override
265 public String getBaseName() {
266 return "Pilgrim's Path";
267 }
268
269 @Override
270 public String getPostfixForState() {
271 if (startingStage != null) {
272 return "";
273 }
274 return super.getPostfixForState();
275 }
276
277 public void buttonPressConfirmed(Object buttonId, IntelUIAPI ui) {
278 if (buttonId == LuddicShrineIntel.BUTTON_SHOW_SHRINES) {
279 LuddicShrineIntel.toggleShrineList(this, ui);
280 return;
281 }
282 super.buttonPressConfirmed(buttonId, ui);
283 }
284
285
287 int count = 0;
288
289 for (IntelInfoPlugin intel : Global.getSector().getIntelManager().getIntel(LuddicShrineIntel.class)) {
290 LuddicShrineIntel shrine = (LuddicShrineIntel) intel;
291 if (LuddicShrineIntel.isVisited(shrine.getEntity())) {
292 count++;
293 }
294 }
295
296 System.out.print(" Shrine count found = " + count);
297 return count;
298 }
299
300
301
302 public static int getTotalShrines() {
303 return Global.getSector().getIntelManager().getIntel(LuddicShrineIntel.class).size();
304 }
305}
306
307
308
309
310
static SettingsAPI getSettings()
Definition Global.java:51
static SectorAPI getSector()
Definition Global.java:59
void addDescriptionForNonEndStage(TooltipMakerAPI info, float width, float height)
boolean addNextStepText(TooltipMakerAPI info, Color tc, float pad)
void createSmallDescription(TooltipMakerAPI info, float width, float height)
boolean callAction(String action, String ruleId, final InteractionDialogAPI dialog, List< Token > params, final Map< String, MemoryAPI > memoryMap)
String getSpriteName(String category, String id)