Starsector API
Loading...
Searching...
No Matches
DeadDropMission.java
Go to the documentation of this file.
1package com.fs.starfarer.api.impl.campaign.missions;
2
3import java.awt.Color;
4
5import org.lwjgl.util.vector.Vector2f;
6
7import com.fs.starfarer.api.campaign.SectorEntityToken;
8import com.fs.starfarer.api.campaign.StarSystemAPI;
9import com.fs.starfarer.api.campaign.econ.MarketAPI;
10import com.fs.starfarer.api.characters.PersonAPI;
11import com.fs.starfarer.api.impl.campaign.ids.Factions;
12import com.fs.starfarer.api.impl.campaign.ids.FleetTypes;
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.hub.HubMissionWithBarEvent;
16import com.fs.starfarer.api.ui.TooltipMakerAPI;
17import com.fs.starfarer.api.util.Misc;
18
19public class DeadDropMission extends HubMissionWithBarEvent {
20
21 public static float PROB_COMPLICATIONS = 0.5f;
22 public static float PROB_PATROL_AFTER = 0.5f;
23 public static float MISSION_DAYS = 120f;
24
25 public static enum Stage {
26 DROP_OFF,
27 COMPLETED,
28 FAILED,
29 }
30
31 protected String thing;
32 protected SectorEntityToken target;
33 protected StarSystemAPI system;
34
35 @Override
36 protected boolean create(MarketAPI createdAt, boolean barEvent) {
37 //genRandom = Misc.random;
38
39 if (barEvent) {
40 setGiverRank(Ranks.CITIZEN);
41 setGiverPost(pickOne(Ranks.POST_AGENT, Ranks.POST_SMUGGLER, Ranks.POST_GANGSTER,
42 Ranks.POST_FENCE, Ranks.POST_CRIMINAL));
43 setGiverImportance(pickImportance());
44 setGiverFaction(Factions.PIRATES);
45 setGiverTags(Tags.CONTACT_UNDERWORLD);
46 findOrCreateGiver(createdAt, false, false);
47 }
48
49 // I may have had a bit too much fun with this
50 thing = pickOne("an apparently inert data chip",
51 "a rad-shielded salvors' TriPad",
52 "a cloudy, damaged data crystal",
53 "a small EM-shielded safe",
54 "a hardcopy book made of paper",
55 "a sewing kit with strangely curved needles",
56 "a single rose in a miniaturized stasis field",
57 "a small packet of seeds embossed with a Luddic sigil",
58 "an aged, twisted piece of wood",
59 "an irradiated bulkhead in a shielded crate",
60 "a black Volturnian lobster shell",
61 "a biosample in sealed cylinder",
62 "a peculiar vial of blood",
63 "a powdered substance in a triple-sealed container",
64 "a single vacuum-desiccated finger",
65 "a tiny unicorn pendant",
66 "a delicate crane made of folded paper",
67 "a scratched golden ring",
68 "a gravimatic trap holding some kind of glowing mote",
69 "a battered Hegemony officer's pistol",
70 "a large brilliant-cut diamond",
71 "a captain's safe cut from its bulkhead",
72 "a glowing blue crystal in a sealed tube"
73 );
74
75 PersonAPI person = getPerson();
76 if (person == null) return false;
77
78
79 if (!setPersonMissionRef(person, "$ddro_ref")) {
80 return false;
81 }
82
83 if (barEvent) {
84 setGiverIsPotentialContactOnSuccess();
85 }
86
87// requireSystemTags(ReqMode.NOT_ANY, Tags.THEME_UNSAFE, Tags.THEME_CORE);
88// preferSystemTags(ReqMode.ANY, Tags.THEME_INTERESTING, Tags.THEME_INTERESTING_MINOR);
89 requireSystemNot(createdAt.getStarSystem());
90 requireSystemInterestingAndNotUnsafeOrCore();
91 preferSystemInInnerSector();
92 preferSystemUnexplored();
93 preferSystemInDirectionOfOtherMissions();
94
95 system = pickSystem();
96 if (system == null) return false;
97
98 target = spawnMissionNode(new LocData(EntityLocationType.HIDDEN_NOT_NEAR_STAR, null, system));
99 if (!setEntityMissionRef(target, "$ddro_ref")) return false;
100
101 makeImportant(target, "$ddro_target", Stage.DROP_OFF);
102 //setMapMarkerNameColor(Misc.getGrayColor());
103
104 setStartingStage(Stage.DROP_OFF);
105 setSuccessStage(Stage.COMPLETED);
106 setFailureStage(Stage.FAILED);
107
108 setStageOnMemoryFlag(Stage.COMPLETED, target, "$ddro_completed");
109 setTimeLimit(Stage.FAILED, MISSION_DAYS, null);
110
111
112 setCreditReward(CreditReward.HIGH);
113
114 if (rollProbability(PROB_COMPLICATIONS)) {
115 triggerComplicationBegin(Stage.DROP_OFF, ComplicationSpawn.APPROACHING_OR_ENTERING,
116 system, Factions.PIRATES,
117 "the " + getWithoutArticle(thing), "it",
118 "the " + getWithoutArticle(thing) + " given to you by " + person.getNameString(),
119 0,
120 true, ComplicationRepImpact.NONE, null);
121 triggerComplicationEnd(true);
122 }
123
124 return true;
125 }
126
127 @Override
128 protected void notifyEnding() {
129 super.notifyEnding();
130
131 if (isSucceeded() && rollProbability(PROB_PATROL_AFTER)) {
132 PersonAPI person = getPerson();
133 if (person == null || person.getMarket() == null) return;
134 String patrolFaction = person.getMarket().getFactionId();
135 if (patrolFaction.equals(person.getFaction().getId()) ||
136 Misc.isPirateFaction(person.getMarket().getFaction()) ||
137 Factions.PLAYER.equals(patrolFaction)) {
138 return;
139 }
140
141 DelayedFleetEncounter e = new DelayedFleetEncounter(genRandom, getMissionId());
142 e.setDelayNone();
143 e.setLocationInnerSector(true, patrolFaction);
144 e.beginCreate();
145 e.triggerCreateFleet(FleetSize.LARGE, FleetQuality.DEFAULT, patrolFaction, FleetTypes.PATROL_LARGE, new Vector2f());
146 e.setFleetWantsThing(patrolFaction,
147 "the dead drop coordinates", "they",
148 "the dead drop coordinates given to you by " + person.getNameString(),
149 0,
150 true, ComplicationRepImpact.LOW,
152 e.triggerSetAdjustStrengthBasedOnQuality(true, getQuality());
153 e.triggerMakeLowRepImpact();
154 e.triggerSetPatrol();
156 e.endCreate();
157 }
158 }
159
160
161
162 protected void updateInteractionDataImpl() {
163 set("$ddro_barEvent", isBarEvent());
164 set("$ddro_manOrWoman", getPerson().getManOrWoman());
165 set("$ddro_heOrShe", getPerson().getHeOrShe());
166 set("$ddro_reward", Misc.getWithDGS(getCreditsReward()));
167
168 set("$ddro_aOrAnThing", thing);
169 set("$ddro_thing", getWithoutArticle(thing));
170
171 set("$ddro_personName", getPerson().getNameString());
172 set("$ddro_systemName", system.getNameWithLowercaseTypeShort());
173 set("$ddro_dist", getDistanceLY(target));
174 }
175
176 @Override
177 public void addDescriptionForNonEndStage(TooltipMakerAPI info, float width, float height) {
178 float opad = 10f;
179 Color h = Misc.getHighlightColor();
180 if (currentStage == Stage.DROP_OFF) {
181 info.addPara("Deliver " + thing + " to the dead drop location at the " +
182 "specified coordinates in the " + system.getNameWithLowercaseTypeShort() + ".", opad);
183 }
184 }
185
186 @Override
187 public boolean addNextStepText(TooltipMakerAPI info, Color tc, float pad) {
188 Color h = Misc.getHighlightColor();
189 if (currentStage == Stage.DROP_OFF) {
190 info.addPara("Deliver " + getWithoutArticle(thing) + " to specified location in the " +
191 system.getNameWithLowercaseTypeShort(), tc, pad);
192 return true;
193 }
194 return false;
195 }
196
197 @Override
198 public String getBaseName() {
199 return "Dead Drop";
200 }
201
202}
203
204
205
206
207
208
void addDescriptionForNonEndStage(TooltipMakerAPI info, float width, float height)
boolean addNextStepText(TooltipMakerAPI info, Color tc, float pad)
boolean create(MarketAPI createdAt, boolean barEvent)
void setFleetWantsThing(String originalFactionId, String thing, String thingItOrThey, String thingDesc, int paymentOffered, boolean aggressiveIfDeclined, ComplicationRepImpact repImpact, String failTrigger, PersonAPI personForRepLoss)
void triggerCreateFleet(FleetSize size, FleetQuality quality, String factionId, String type, SectorEntityToken roughlyWhere)
void setLocationInnerSector(boolean allowInsidePopulatedSystems, String requireLargestMarketNotHostileToFaction)