Starsector API
Loading...
Searching...
No Matches
LuddicPilgrimTransport.java
Go to the documentation of this file.
1package com.fs.starfarer.api.impl.campaign.missions;
2
3import java.awt.Color;
4
5import com.fs.starfarer.api.Global;
6import com.fs.starfarer.api.campaign.PersonImportance;
7import com.fs.starfarer.api.campaign.SectorEntityToken;
8import com.fs.starfarer.api.campaign.StarSystemAPI;
9import com.fs.starfarer.api.campaign.econ.CommodityOnMarketAPI;
10import com.fs.starfarer.api.campaign.econ.MarketAPI;
11import com.fs.starfarer.api.characters.PersonAPI;
12import com.fs.starfarer.api.impl.campaign.ids.Factions;
13import com.fs.starfarer.api.impl.campaign.ids.Ranks;
14import com.fs.starfarer.api.impl.campaign.ids.Tags;
15import com.fs.starfarer.api.impl.campaign.missions.academy.GACelestialObject.Variation;
16import com.fs.starfarer.api.impl.campaign.missions.askonia.TheUsurpers.Stage;
17import com.fs.starfarer.api.impl.campaign.missions.hub.HubMissionWithBarEvent;
18import com.fs.starfarer.api.impl.campaign.missions.hub.ReqMode;
19import com.fs.starfarer.api.ui.TooltipMakerAPI;
20import com.fs.starfarer.api.util.Misc;
21
22public class LuddicPilgrimTransport extends HubMissionWithBarEvent {
23
24 //graphics/icons/missions/luddic_pilgrim_transport.png
25 public static float MISSION_DAYS = 60f;
26 public static float MIN_VALUE = 10000f;
27 public static float MAX_VALUE = 20000f;
28 public static float PROB_RICH = 0.5f;
29
30 public static enum Stage {
31 TRANSPORT,
32 COMPLETED,
33 FAILED,
34 }
35
36 public static enum Variation {
37 RICH,
38 POOR,
39 }
40
41
42 protected MarketAPI source_market;
43 protected StarSystemAPI destination_system;
44 protected SectorEntityToken destination_entity;
45 protected int quantity;
46 protected String destination_shrine;
47 protected Variation variation;
48
49 @Override
50 protected boolean create(MarketAPI createdAt, boolean barEvent) {
51 // if already accepted by the player, abort
52 if (!setGlobalReference("$lpt_ref", "$lpt_inProgress")) {
53 return false;
54 }
55
56 //genRandom = Misc.random;
57
58 //if (Factions.PIRATES.equals(createdAt.getFaction().getId())) return false;
59
60 source_market = createdAt;
61
62 // let's just whitelist core worlds. Should be based on places that plausibly have a significant/interesting Luddic population
63 if ( !( source_market.getId().equals("chicomoztoc") ||
64 source_market.getId().equals("mazalot") ||
65 source_market.getId().equals("ilm") ||
66 source_market.getId().equals("volturn") ||
67 source_market.getId().equals("jangala") ||
68 source_market.getId().equals("epiphany") ||
69 source_market.getId().equals("cibola") ||
70 source_market.getId().equals("madeira") ||
71 source_market.getId().equals("chalcedon") ||
72 source_market.getId().equals("tartessus") ||
73 source_market.getId().equals("hesperus") ||
74 source_market.getId().equals("fikenhild") ||
75 source_market.getId().equals("athulf") ||
76 source_market.getId().equals("suddene")) ) {
77 return false;
78 }
79
80 if (rollProbability(PROB_RICH)) {
81 variation = Variation.RICH;
82 float value = MIN_VALUE + getQuality() * (MAX_VALUE - MIN_VALUE);
83 value *= 0.9f + genRandom.nextFloat() * 0.2f;
84 setCreditReward((int)(value * 0.5f), (int)(value * 0.7f));
85 } else {
86 variation = Variation.POOR;
87 }
88
89 if (barEvent) {
90 setGiverRank(Ranks.CITIZEN);
91 setGiverPost(Ranks.POST_PILGRIM);
92 //setGiverImportance(pickImportance());
93 setGiverImportance(PersonImportance.VERY_LOW); // irrelevant anyway.
94 setGiverFaction(Factions.LUDDIC_CHURCH);
95 findOrCreateGiver(createdAt, false, false);
96 }
97
98 PersonAPI person = getPerson();
99 if (person == null) return false;
100
101
102 if (!setPersonMissionRef(person, "$lpt_ref")) {
103 return false;
104 }
105
106 setRepFactionChangesNone();
107 setIconName("campaignMissions", "luddic_pilgrim_transport");
108
109 // Maybe handle non-"public" shrines later.
110 destination_shrine = pickOne("gilead", "beholder_station");
111
112 if (destination_shrine.equals("gilead"))
113 {
114 destination_system = Global.getSector().getStarSystem("canaan");
115 destination_entity = Global.getSector().getEconomy().getMarket("gilead").getPlanetEntity();
116 if (destination_entity == null) return false;
117 if (!destination_entity.getMarket().getFactionId().equals(Factions.LUDDIC_CHURCH)) return false;
118 }
119 else if (destination_shrine.equals("beholder_station"))
120 {
121 destination_system = Global.getSector().getStarSystem("kumari kandam");
122 for (SectorEntityToken beholder_station : destination_system.getEntitiesWithTag(Tags.LUDDIC_SHRINE)) {
123 destination_entity = beholder_station;
124 break;
125 }
126 }
127
128 if (!setEntityMissionRef(destination_entity, "$lpt_ref")) {
129 return false;
130 }
131
132 makeImportant(destination_entity, "$lpt_target", Stage.TRANSPORT);
133
134 setStartingStage(Stage.TRANSPORT);
135 setSuccessStage(Stage.COMPLETED);
136 setFailureStage(Stage.FAILED);
137
138 setStageOnMemoryFlag(Stage.COMPLETED, destination_entity, "$lpt_completed");
139 // setStageOnGlobalFlag(Stage.COMPLETED, "lpt_completed");
140 setNoAbandon();
141 setTimeLimit(Stage.FAILED, MISSION_DAYS, null);
142
143
144
145 //setCreditRewardWithBonus(CreditReward.VERY_LOW, (int) (value * 0.5f));
146
147 return true;
148 }
149
150 protected void updateInteractionDataImpl() {
151 //set("$lpt_destinationShrine", destination_shrine);
152 set("$lpt_barEvent", isBarEvent());
153 set("$lpt_reward", Misc.getWithDGS(getCreditsReward()));
154
155 set("$lpt_manOrWoman", getPerson().getManOrWoman());
156 set("$lpt_heOrShe", getPerson().getHeOrShe());
157 set("$lpt_hisOrHer", getPerson().getHisOrHer());
158 set("$lpt_himOrHer", getPerson().getHimOrHer());
159 set("$lpt_HeOrShe", getPerson().getHeOrShe().substring(0, 1).toUpperCase() + getPerson().getHeOrShe().substring(1));
160 set("$lpt_HisOrHer", getPerson().getHisOrHer().substring(0, 1).toUpperCase() + getPerson().getHisOrHer().substring(1));
161 set("$lpt_HimOrHer", getPerson().getHimOrHer().substring(0, 1).toUpperCase() + getPerson().getHimOrHer().substring(1));
162
163 if( variation == variation.POOR)
164 set("$lpt_wealth", "poor");
165 else set("$lpt_wealth", "rich");
166
167 set("$lpt_personName", getPerson().getNameString());
168 set("$lpt_systemName", destination_system.getNameWithLowercaseTypeShort());
169 set("$lpt_entityName", destination_entity.getName());
170 set("$lpt_sourceName", source_market.getName());
171
172 //if (destination_entity.m)
173 //set("$lpt_marketOnOrAt", destination_entity.getOnOrAt());
174
175 set("$lpt_dist", getDistanceLY(destination_entity));
176 }
177
178 @Override
179 public void addDescriptionForNonEndStage(TooltipMakerAPI info, float width, float height) {
180 float opad = 10f;
181 Color h = Misc.getHighlightColor();
182 if (currentStage == Stage.TRANSPORT) {
183 info.addPara("Transport a small party of Luddic pilgrims to " + destination_entity.getName() +
184 " in the " + destination_system.getNameWithLowercaseTypeShort() + ".", opad,
185 h, Misc.getWithDGS(quantity));
186
187 info.addPara("The pilgrims will expect to arrive at the shrine within " + MISSION_DAYS + " days.", opad);
188 }
189 }
190
191 @Override
192 public boolean addNextStepText(TooltipMakerAPI info, Color tc, float pad) {
193 Color h = Misc.getHighlightColor();
194 if (currentStage == Stage.TRANSPORT) {
195 info.addPara("Transport a small party of Luddic pilgrims to " + destination_entity.getName() +
196 " in the " + destination_system.getNameWithLowercaseTypeShort(), pad, tc,
197 h, Misc.getWithDGS(quantity));
198 return true;
199 }
200 return false;
201 }
202
203 @Override
204 public String getBaseName() {
205 return "Luddic Pilgrim Transport";
206 }
207
208}
209
static SectorAPI getSector()
Definition Global.java:59
boolean addNextStepText(TooltipMakerAPI info, Color tc, float pad)
void addDescriptionForNonEndStage(TooltipMakerAPI info, float width, float height)