Starsector API
Loading...
Searching...
No Matches
GensHannanMachinations.java
Go to the documentation of this file.
1package com.fs.starfarer.api.impl.campaign.intel;
2
3import java.awt.Color;
4import java.util.Random;
5import java.util.Set;
6
7import org.lwjgl.util.vector.Vector2f;
8
9import com.fs.starfarer.api.Global;
10import com.fs.starfarer.api.campaign.FactionAPI;
11import com.fs.starfarer.api.campaign.InteractionDialogAPI;
12import com.fs.starfarer.api.campaign.RepLevel;
13import com.fs.starfarer.api.campaign.ReputationActionResponsePlugin.ReputationAdjustmentResult;
14import com.fs.starfarer.api.campaign.SectorEntityToken;
15import com.fs.starfarer.api.campaign.TextPanelAPI;
16import com.fs.starfarer.api.campaign.econ.MarketAPI;
17import com.fs.starfarer.api.characters.PersonAPI;
18import com.fs.starfarer.api.impl.campaign.CoreReputationPlugin;
19import com.fs.starfarer.api.impl.campaign.ids.Factions;
20import com.fs.starfarer.api.impl.campaign.ids.FleetTypes;
21import com.fs.starfarer.api.impl.campaign.ids.People;
22import com.fs.starfarer.api.impl.campaign.intel.events.PerseanLeagueHostileActivityFactor;
23import com.fs.starfarer.api.impl.campaign.missions.DelayedFleetEncounter;
24import com.fs.starfarer.api.impl.campaign.missions.hub.HubMissionWithTriggers.FleetQuality;
25import com.fs.starfarer.api.impl.campaign.missions.hub.HubMissionWithTriggers.FleetSize;
26import com.fs.starfarer.api.impl.campaign.missions.hub.HubMissionWithTriggers.OfficerNum;
27import com.fs.starfarer.api.impl.campaign.missions.hub.HubMissionWithTriggers.OfficerQuality;
28import com.fs.starfarer.api.ui.Alignment;
29import com.fs.starfarer.api.ui.SectorMapAPI;
30import com.fs.starfarer.api.ui.TooltipMakerAPI;
31import com.fs.starfarer.api.util.IntervalUtil;
32import com.fs.starfarer.api.util.Misc;
33
35
36
37 // in $player memory
38 public static String AGREED_TO_PAY_HOUSE_HANNAN_AGAIN = "$agreedToPayHouseHannanAgain";
39
40 // in $global memory
41 public static String MACHINATIONS_IN_EFFECT = "$houseHannanMachinationsInEffect";
42
55
62
63 public static String KEY = "$plGHMachinations_ref";
67
68 public static String UPDATE_PARAM_START = "update_param_start";
69 public static String UPDATE_PARAM_MACHINATION = "update_param_machination";
70
71 public static float PROB_ACTION_TAKEN = 0.5f;
72 public static float PROB_BOUNTY_HUNTER = 0.25f;
73
74
75 protected FactionAPI faction = null;
76 protected IntervalUtil interval = new IntervalUtil(10f, 110f);
77 protected Random random = new Random();
78 protected int repDamageRemaining = 100;
79
80 protected ReputationAdjustmentResult recent = null;
81 protected boolean recentIsBountyHunter = false;
82 protected long recentTimestamp = 0L;
83
85 if (get() != null) return;
86
87 this.faction = Global.getSector().getFaction(Factions.PERSEAN);
88
89 setImportant(true);
90
91 TextPanelAPI text = null;
92 if (dialog != null) text = dialog.getTextPanel();
93
95 //Global.getSector().getListenerManager().addListener(this);
97
99
101
102 sendUpdateIfPlayerHasIntel(dialog, text);
103 }
104
105 @Override
106 protected void advanceImpl(float amount) {
107 super.advanceImpl(amount);
108
109 if (isEnded() || isEnding()) return;
110
111
112 float days = Misc.getDays(amount);
113 //days *= 100f;
114 interval.advance(days);
115
116 if (!interval.intervalElapsed()) return;
117
119 setImportant(false);
121 return;
122 }
123
124 if (random.nextFloat() > PROB_ACTION_TAKEN) return;
125
126
129 return;
130 }
131
132 int repLoss = 5 + random.nextInt(11);
133 repLoss = Math.min(repLoss, repDamageRemaining);
134
135 RepLevel limit = RepLevel.NEUTRAL;
137 limit = RepLevel.VENGEFUL;
138 }
139
140 ReputationAdjustmentResult result = Misc.adjustRep(Factions.PERSEAN,
141 (float)repLoss * -0.01f, limit, null, false, false);
142
143 repLoss = Math.min(repLoss, (int)Math.abs(Math.round(result.delta * 100f)));
144
145 if (repLoss > 0) {
146 repDamageRemaining -= Math.abs(repLoss);
147 recent = result;
149 recentIsBountyHunter = false;
150
152 }
153
154 if (repDamageRemaining <= 0f) {
155 setImportant(false);
157 }
158 }
159
160 protected void sendBountyHunter() {
161 recent = new ReputationAdjustmentResult(0);
164
165 DelayedFleetEncounter e = new DelayedFleetEncounter(random, "GensHannanMachinations");
166 e.setDelayShort();
167 //e.setDelayNone();
168 //e.setLocationCoreOnly(true, market.getFactionId());
170 e.beginCreate();
171 e.triggerCreateFleet(FleetSize.HUGE, FleetQuality.SMOD_1, Factions.PERSEAN, FleetTypes.MERC_BOUNTY_HUNTER, new Vector2f());
172 e.triggerSetFleetOfficers(OfficerNum.MORE, OfficerQuality.HIGHER);
177 e.triggerSetFleetGenericHailPermanent("GensHannanMachinationsHail");
178 e.endCreate();
179
181 }
182
183 @Override
184 protected void notifyEnding() {
185 super.notifyEnding();
186
189 //Global.getSector().getListenerManager().removeListener(this);
190 }
191
192 @Override
193 protected void notifyEnded() {
195 super.notifyEnded();
196 }
197
198 protected Object readResolve() {
199 return this;
200 }
201
202 public String getBaseName() {
203 return "Gens Hannan Machinations";
204 }
205
206 public String getName() {
207 String postfix = "";
208 return getBaseName() + postfix;
209 }
210
211 @Override
213 return faction;
214 }
215
216 public String getSmallDescriptionTitle() {
217 return getName();
218 }
219
220 protected void addBulletPoints(TooltipMakerAPI info, ListInfoMode mode) {
221 Color h = Misc.getHighlightColor();
222 Color g = Misc.getGrayColor();
223 float pad = 3f;
224 float opad = 10f;
225
226 float initPad = pad;
227 if (mode == ListInfoMode.IN_DESC) initPad = opad;
228
229 Color tc = getBulletColorForMode(mode);
230
231 bullet(info);
232 boolean isUpdate = getListInfoParam() != null;
233
234 if (recent != null) {
236 if (days > 60f) {
237 recentTimestamp = 0;
238 recent = null;
239 recentIsBountyHunter = false;
240 } else {
242 info.addPara("A bounty hunter was recently hired to eliminate you", tc, initPad);
243 } else {
245 null, null, info, tc, isUpdate, initPad);
246 if (!isUpdate) {
247 String daysStr = days == 1 ? "day" : "days";
248 info.addPara("%s " + daysStr + " ago", 0f, tc, h, "" + days);
249 }
250 }
251 }
252 }
253
254
255 unindent(info);
256 }
257
258 public void createSmallDescription(TooltipMakerAPI info, float width, float height) {
259 Color h = Misc.getHighlightColor();
260 Color g = Misc.getGrayColor();
261 Color tc = Misc.getTextColor();
262 float pad = 3f;
263 float opad = 10f;
264
265 info.addImage(getFaction().getLogo(), width, 128, opad);
266
267 info.addPara("You've gone back on a deal with Gens Hannan, and they work behind the scenes"
268 + "to damage your standing with the Persean League, and worse.", opad,
269 getFaction().getBaseUIColor(), "Persean League");
270
271 if (isEnding() || isEnded()) {
272 info.addPara("You sources indicate that the further action by Gens Hannan "
273 + "is unlikely at this time.", opad);
274 } else {
275 info.addPara("It's likely that at some point this work will become less of a priority, but "
276 + "for now, their agents go about ruining your reputation with commendable "
277 + "vigor and discretion.", opad);
278
280 info.addPara("There is no hope of reconciliation, and the gloves are off. There is a possibility "
281 + "of your being brought into active hostility with the League, and of bounty hunters "
282 + "being hired and equipped for the job.", opad, Misc.getNegativeHighlightColor(),
283 "active hostility with the League", "bounty hunters");
284 } else {
286 info.addPara("You are not considered trustworthy enough for Gens Hannan to deal with again, and "
287 + "these actions are in the way of setting an example for others.", opad);
288 } else {
289 if (getMapLocation(null) != null) {
291 if (person != null) {
292 TooltipMakerAPI sub = info.beginImageWithText(person.getPortraitSprite(), 64f);
293 sub.addPara("You may be able to negotiate an end to this by going to Kazeron and speaking with "
294 + "Reynard Hannan.", 0f, h,
295 "speaking with Reynard Hannan");
296 info.addImageWithText(opad);
297 }
298 }
299 }
300 }
301 }
302
303 if (recent != null) {
304 info.addSectionHeading("Recent events",
305 getFaction().getBaseUIColor(), getFaction().getDarkUIColor(),
306 Alignment.MID, opad);
307 addBulletPoints(info, ListInfoMode.IN_DESC);
308 }
309 }
310
311
312 public String getIcon() {
313 return faction.getCrest();
314 }
315
316 public Set<String> getIntelTags(SectorMapAPI map) {
317 Set<String> tags = super.getIntelTags(map);
318 //tags.add(Tags.INTEL_AGREEMENTS);
319 tags.add(faction.getId());
320 return tags;
321 }
322
323 @Override
326 if (kazeron != null) {
327 return kazeron.getPrimaryEntity();
328 }
329 return null;
330 }
331
332
334 return faction;
335 }
336
337 public void endMachinations(TextPanelAPI text) {
338 if (!isEnded() && !isEnding()) {
339 setImportant(false);
341 //sendUpdate(new Object(), text);
342 }
343 }
344
345}
346
347
348
349
350
351
static SectorAPI getSector()
Definition Global.java:65
static void addAdjustmentMessage(float delta, FactionAPI faction, PersonAPI person, TextPanelAPI panel, TooltipMakerAPI info, Color tc, boolean withCurrent, float pad)
static PersonAPI getPerson(String id)
Definition People.java:107
void sendUpdateIfPlayerHasIntel(Object listInfoParam, TextPanelAPI textPanel)
void createSmallDescription(TooltipMakerAPI info, float width, float height)
void triggerCreateFleet(FleetSize size, FleetQuality quality, String factionId, String type, SectorEntityToken roughlyWhere)
void setLocationInnerSector(boolean allowInsidePopulatedSystems, String requireLargestMarketNotHostileToFaction)
static Color getTextColor()
Definition Misc.java:839
static Color getNegativeHighlightColor()
Definition Misc.java:802
static Color getGrayColor()
Definition Misc.java:826
static void adjustRep(float repChangeFaction, RepLevel limit, String factionId, float repChangePerson, RepLevel personLimit, PersonAPI person, TextPanelAPI text)
Definition Misc.java:3884
static float getDays(float amount)
Definition Misc.java:4663
static Color getHighlightColor()
Definition Misc.java:792
void addScript(EveryFrameScript script)
void removeScript(EveryFrameScript script)
FactionAPI getFaction(String factionId)
void set(String key, Object value)
void addImage(String spriteName, float pad)
LabelAPI addPara(String format, float pad, Color hl, String... highlights)
TooltipMakerAPI beginImageWithText(String spriteName, float imageHeight)
LabelAPI addSectionHeading(String str, Alignment align, float pad)
UIPanelAPI addImageWithText(float pad)