1package com.fs.starfarer.api.impl.campaign.missions.hub;
4import java.util.ArrayList;
5import java.util.Arrays;
6import java.util.HashSet;
7import java.util.Iterator;
8import java.util.LinkedHashMap;
9import java.util.LinkedHashSet;
12import java.util.Random;
15import org.lwjgl.input.Keyboard;
16import org.lwjgl.util.vector.Vector2f;
18import com.fs.starfarer.api.Global;
19import com.fs.starfarer.api.campaign.CampaignFleetAPI;
20import com.fs.starfarer.api.campaign.CampaignTerrainAPI;
21import com.fs.starfarer.api.campaign.CampaignTerrainPlugin;
22import com.fs.starfarer.api.campaign.CargoAPI;
23import com.fs.starfarer.api.campaign.CargoStackAPI;
24import com.fs.starfarer.api.campaign.CustomEntitySpecAPI;
25import com.fs.starfarer.api.campaign.FactionAPI;
26import com.fs.starfarer.api.campaign.InteractionDialogAPI;
27import com.fs.starfarer.api.campaign.LocationAPI;
28import com.fs.starfarer.api.campaign.PersonImportance;
29import com.fs.starfarer.api.campaign.PlanetAPI;
30import com.fs.starfarer.api.campaign.RepLevel;
31import com.fs.starfarer.api.campaign.ReputationActionResponsePlugin.ReputationAdjustmentResult;
32import com.fs.starfarer.api.campaign.SectorEntityToken;
33import com.fs.starfarer.api.campaign.SpecialItemData;
34import com.fs.starfarer.api.campaign.StarSystemAPI;
35import com.fs.starfarer.api.campaign.TextPanelAPI;
36import com.fs.starfarer.api.campaign.econ.Industry;
37import com.fs.starfarer.api.campaign.econ.MarketAPI;
38import com.fs.starfarer.api.campaign.rules.HasMemory;
39import com.fs.starfarer.api.campaign.rules.MemKeys;
40import com.fs.starfarer.api.campaign.rules.MemoryAPI;
41import com.fs.starfarer.api.characters.FullName.Gender;
42import com.fs.starfarer.api.characters.ImportantPeopleAPI;
43import com.fs.starfarer.api.characters.ImportantPeopleAPI.PersonDataAPI;
44import com.fs.starfarer.api.characters.PersonAPI;
45import com.fs.starfarer.api.combat.StatBonus;
46import com.fs.starfarer.api.fleet.FleetMemberAPI;
47import com.fs.starfarer.api.impl.campaign.CoreReputationPlugin;
48import com.fs.starfarer.api.impl.campaign.CoreReputationPlugin.MissionCompletionRep;
49import com.fs.starfarer.api.impl.campaign.CoreReputationPlugin.RepActionEnvelope;
50import com.fs.starfarer.api.impl.campaign.CoreReputationPlugin.RepActions;
51import com.fs.starfarer.api.impl.campaign.CoreReputationPlugin.RepRewards;
52import com.fs.starfarer.api.impl.campaign.DerelictShipEntityPlugin;
53import com.fs.starfarer.api.impl.campaign.DerelictShipEntityPlugin.DerelictShipData;
54import com.fs.starfarer.api.impl.campaign.DerelictShipEntityPlugin.DerelictType;
55import com.fs.starfarer.api.impl.campaign.ids.Entities;
56import com.fs.starfarer.api.impl.campaign.ids.Factions;
57import com.fs.starfarer.api.impl.campaign.ids.Ranks;
58import com.fs.starfarer.api.impl.campaign.ids.Stats;
59import com.fs.starfarer.api.impl.campaign.ids.Tags;
60import com.fs.starfarer.api.impl.campaign.intel.BaseIntelPlugin;
61import com.fs.starfarer.api.impl.campaign.intel.contacts.ContactIntel;
62import com.fs.starfarer.api.impl.campaign.missions.CheapCommodityMission;
63import com.fs.starfarer.api.impl.campaign.missions.hub.MissionTrigger.TriggerAction;
64import com.fs.starfarer.api.impl.campaign.missions.hub.MissionTrigger.TriggerActionContext;
65import com.fs.starfarer.api.impl.campaign.plog.PlaythroughLog;
66import com.fs.starfarer.api.impl.campaign.procgen.Constellation;
67import com.fs.starfarer.api.impl.campaign.procgen.themes.BaseThemeGenerator;
68import com.fs.starfarer.api.impl.campaign.procgen.themes.BaseThemeGenerator.AddedEntity;
69import com.fs.starfarer.api.impl.campaign.procgen.themes.BaseThemeGenerator.EntityLocation;
70import com.fs.starfarer.api.impl.campaign.procgen.themes.BaseThemeGenerator.LocationType;
71import com.fs.starfarer.api.impl.campaign.procgen.themes.SalvageSpecialAssigner;
72import com.fs.starfarer.api.impl.campaign.rulecmd.AddRemoveCommodity;
73import com.fs.starfarer.api.impl.campaign.rulecmd.salvage.MarketCMD;
74import com.fs.starfarer.api.impl.campaign.rulecmd.salvage.MarketCMD.RaidDangerLevel;
75import com.fs.starfarer.api.impl.campaign.rulecmd.salvage.special.BaseSalvageSpecial;
76import com.fs.starfarer.api.impl.campaign.rulecmd.salvage.special.BreadcrumbSpecial;
77import com.fs.starfarer.api.impl.campaign.terrain.BaseRingTerrain;
78import com.fs.starfarer.api.impl.campaign.terrain.BaseTiledTerrain;
79import com.fs.starfarer.api.impl.campaign.terrain.DebrisFieldTerrainPlugin.DebrisFieldParams;
80import com.fs.starfarer.api.impl.campaign.terrain.DebrisFieldTerrainPlugin.DebrisFieldSource;
81import com.fs.starfarer.api.ui.ButtonAPI;
82import com.fs.starfarer.api.ui.IntelUIAPI;
83import com.fs.starfarer.api.ui.LabelAPI;
84import com.fs.starfarer.api.ui.SectorMapAPI;
85import com.fs.starfarer.api.ui.TooltipMakerAPI;
86import com.fs.starfarer.api.util.IntervalUtil;
87import com.fs.starfarer.api.util.Misc;
88import com.fs.starfarer.api.util.Misc.Token;
89import com.fs.starfarer.api.util.Pair;
90import com.fs.starfarer.api.util.WeightedRandomPicker;
106 public static enum CreditReward {
107 VERY_LOW(20000, 25000, 2000),
108 LOW(30000, 40000, 5000),
109 AVERAGE(50000, 60000, 10000),
110 HIGH(70000, 80000, 15000),
111 VERY_HIGH(90000, 100000, 20000),
120 public int perMarketSize;
121 private CreditReward(
int min,
int max,
int perMarketSize) {
151 public static enum Abandon {
155 public static enum EntityLocationType {
157 HIDDEN_NOT_NEAR_STAR,
159 ORBITING_PLANET_OR_STAR,
165 public static class LocData {
166 public CampaignTerrainAPI terrain;
167 public EntityLocation loc;
168 public EntityLocationType type;
169 public SectorEntityToken centerOn;
170 public LocationAPI system;
171 public boolean removeOnMissionOver;
176 public LocData(EntityLocation loc, LocationAPI system,
boolean removeOnMissionOver) {
178 this.removeOnMissionOver = removeOnMissionOver;
179 this.system = system;
185 public LocData(EntityLocationType type, SectorEntityToken centerOn, LocationAPI system,
186 boolean removeOnMissionOver) {
188 this.centerOn = centerOn;
189 this.system = system;
190 this.removeOnMissionOver = removeOnMissionOver;
196 public LocData(SectorEntityToken centerOn,
boolean removeOnMissionOver) {
197 if (centerOn instanceof CampaignTerrainAPI) {
198 this.centerOn = centerOn;
200 loc =
new EntityLocation();
201 loc.type = LocationType.OUTER_SYSTEM;
204 system = centerOn.getContainingLocation();
205 this.removeOnMissionOver = removeOnMissionOver;
211 public LocData(Vector2f loc, LocationAPI system,
boolean removeOnMissionOver) {
212 this.loc =
new EntityLocation();
213 this.loc.type = LocationType.OUTER_SYSTEM;
214 this.loc.location = loc;
215 this.system = system;
216 this.removeOnMissionOver = removeOnMissionOver;
222 public LocData(EntityLocation loc, LocationAPI system) {
223 this(loc, system,
true);
229 public LocData(EntityLocationType type, SectorEntityToken centerOn, LocationAPI system) {
230 this(type, centerOn, system,
true);
236 public LocData(SectorEntityToken centerOn) {
237 this(centerOn,
true);
243 public LocData(Vector2f loc, LocationAPI system) {
244 this(loc, system,
true);
247 public boolean updateLocIfNeeded(
BaseHubMission mission, String entityId) {
248 if (centerOn instanceof CampaignTerrainAPI) {
249 CampaignTerrainAPI terrain = (CampaignTerrainAPI) centerOn;
250 loc = mission.generateLocationInsideTerrain(terrain);
251 if (loc ==
null)
return false;
252 }
else if (type !=
null) {
253 loc = mission.generateLocation(entityId, type, centerOn, system);
254 if (loc ==
null)
return false;
259 public void placeEntity(SectorEntityToken entity) {
262 if (loc.orbit !=
null) {
263 entity.setOrbit(loc.orbit);
264 loc.orbit.setEntity(entity);
266 entity.setOrbit(
null);
267 entity.getLocation().set(loc.location);
270 if (removeOnMissionOver) {
279 public static class HubMissionResult {
280 public boolean success;
283 public ReputationAdjustmentResult repPerson;
284 public ReputationAdjustmentResult repFaction;
285 public Object custom;
288 public static enum MapLocationType {
292 public static class ImportanceData {
293 public MemoryAPI memory;
295 public MapLocationType locType =
null;
296 public SectorEntityToken entity;
297 public MarketAPI market;
298 public PersonAPI person;
300 public ImportanceData() {
304 public static class FlagData {
305 public MemoryAPI memory;
307 public LinkedHashSet<Object> stages =
new LinkedHashSet<Object>();
310 public static class StageData {
312 public float elapsed = 0f;
314 public List<ImportanceData> important =
new ArrayList<ImportanceData>();
317 public static interface ConditionChecker {
318 boolean conditionsMet();
321 public static class GlobalBooleanChecker
implements ConditionChecker {
323 public GlobalBooleanChecker(String flag) {
326 public boolean conditionsMet() {
327 return Global.getSector().getMemoryWithoutUpdate().getBoolean(flag);
331 public static class MemoryBooleanChecker
implements ConditionChecker {
333 public MemoryAPI memory;
334 public MemoryBooleanChecker(MemoryAPI memory, String flag) {
335 this.memory = memory;
338 public boolean conditionsMet() {
339 return memory.getBoolean(flag);
343 public static class EntityNotAliveChecker
implements ConditionChecker {
344 public SectorEntityToken entity;
345 public EntityNotAliveChecker(SectorEntityToken entity) {
346 this.entity = entity;
348 public boolean conditionsMet() {
349 return !entity.isAlive();
353 public static class MarketDecivChecker
implements ConditionChecker {
354 public MarketAPI market;
355 public MarketDecivChecker(MarketAPI market) {
356 this.market = market;
358 public boolean conditionsMet() {
359 return market.isPlanetConditionMarketOnly() ||
360 (market.getPrimaryEntity() !=
null && !market.getPrimaryEntity().isAlive());
364 public static class HostilitiesEndedChecker
implements ConditionChecker {
365 public PersonAPI person;
366 public MarketAPI market;
367 public HostilitiesEndedChecker(PersonAPI person, MarketAPI market) {
368 this.person = person;
369 this.market = market;
371 public boolean conditionsMet() {
372 return !person.getFaction().isHostileTo(market.getFaction());
376 public static class HostilitiesStartedChecker
implements ConditionChecker {
377 public PersonAPI person;
378 public MarketAPI market;
379 public HostilitiesStartedChecker(PersonAPI person, MarketAPI market) {
380 this.person = person;
381 this.market = market;
383 public boolean conditionsMet() {
384 return person.getFaction().isHostileTo(market.getFaction());
388 public static class DaysElapsedChecker
implements ConditionChecker {
390 public StageData stage;
392 public DaysElapsedChecker(
float days, StageData stage) {
399 this.mission = mission;
402 public boolean conditionsMet() {
403 if (mission !=
null) {
404 return mission.elapsed >= days;
406 return stage.elapsed >= days;
410 public static class InCommRelayRangeChecker
implements ConditionChecker {
411 public boolean conditionsMet() {
412 return Global.getSector().getIntelManager().isPlayerInRangeOfCommRelay();
416 public static class InRangeOfEntityChecker
implements ConditionChecker {
417 public SectorEntityToken entity;
419 public InRangeOfEntityChecker(SectorEntityToken entity,
float range) {
420 this.entity = entity;
423 public boolean conditionsMet() {
424 return Global.getSector().getCurrentLocation() == entity.getContainingLocation() &&
425 Misc.getDistance(Global.getSector().getPlayerFleet(), entity) < range;
429 public static class InHyperRangeOfEntityChecker
implements ConditionChecker {
430 public SectorEntityToken entity;
431 public float rangeLY;
432 public boolean requirePlayerInHyperspace;
433 public InHyperRangeOfEntityChecker(SectorEntityToken entity,
float rangeLY,
boolean requirePlayerInHyperspace) {
434 this.entity = entity;
435 this.rangeLY = rangeLY;
436 this.requirePlayerInHyperspace = requirePlayerInHyperspace;
438 public boolean conditionsMet() {
439 if (requirePlayerInHyperspace && !Global.getSector().getPlayerFleet().isInHyperspace())
return false;
440 return Misc.getDistanceLY(Global.getSector().getPlayerFleet(), entity) < rangeLY;
444 public static class EnteredLocationChecker
implements ConditionChecker {
445 public LocationAPI location;
446 public EnteredLocationChecker(LocationAPI location) {
447 this.location = location;
449 public boolean conditionsMet() {
450 return Global.getSector().getCurrentLocation() == location;
454 public static class AlwaysTrueChecker
implements ConditionChecker {
455 public boolean conditionsMet() {
460 public static class StageConnection {
463 public ConditionChecker checker;
464 public StageConnection(Object from, Object to, ConditionChecker checker) {
467 this.checker = checker;
471 public static class TimeLimitData {
473 public Object failStage;
474 public LinkedHashSet<Object> endLimitStages =
new LinkedHashSet<Object>();
475 public StarSystemAPI noLimitWhileInSystem;
478 public static interface Abortable {
479 void abort(HubMission mission,
boolean missionOver);
482 public static class VariableSet
implements Abortable {
483 public MemoryAPI memory;
485 public boolean removeOnMissionOver;
486 public VariableSet(MemoryAPI memory, String key,
boolean removeOnMissionOver) {
487 this.memory = memory;
489 this.removeOnMissionOver = removeOnMissionOver;
492 public void abort(HubMission mission,
boolean missionOver) {
493 if (!removeOnMissionOver && missionOver)
return;
498 public static class MadeImportant
implements Abortable {
499 public MemoryAPI memory;
500 public String reason;
501 public MadeImportant(MemoryAPI memory, String reason) {
502 this.memory = memory;
503 this.reason = reason;
505 public void abort(HubMission mission,
boolean missionOver) {
506 Misc.makeUnimportant(memory, reason);
510 public static class DefeatTriggerAdded
implements Abortable {
511 protected CampaignFleetAPI fleet;
512 protected String trigger;
513 protected boolean permanent;
514 public DefeatTriggerAdded(CampaignFleetAPI fleet, String trigger,
boolean permanent) {
516 this.trigger = trigger;
517 this.permanent = permanent;
519 public void abort(HubMission mission,
boolean missionOver) {
520 if (!(permanent && missionOver)) {
521 Misc.removeDefeatTrigger(fleet, trigger);
527 public static class EntityAdded
implements Abortable {
528 public SectorEntityToken entity;
529 public EntityAdded(SectorEntityToken entity) {
530 this.entity = entity;
536 if (entity.hasTag(Tags.FADING_OUT_AND_EXPIRING))
return;
538 if (entity.getContainingLocation() !=
null) {
539 entity.getContainingLocation().removeEntity(entity);
544 public static class PersonAdded
implements Abortable {
545 public MarketAPI market;
546 public PersonAPI person;
547 public boolean wasOnlyAddedToCommDirectory;
549 public PersonAdded(MarketAPI market, PersonAPI person,
boolean wasOnlyAddedToCommDirectory) {
550 this.market = market;
551 this.person = person;
552 this.wasOnlyAddedToCommDirectory = wasOnlyAddedToCommDirectory;
555 public void abort(HubMission mission,
boolean missionOver) {
560 if (Misc.setFlagWithReason(person.getMemoryWithoutUpdate(),
561 "$requiredForMissions", bhm.getReason(),
false, -1f)) {
566 if (!wasOnlyAddedToCommDirectory) {
567 if (market !=
null) market.removePerson(person);
570 if (market !=
null) market.getCommDirectory().removePerson(person);
574 public static class PersonMadeRequired
implements Abortable {
575 public PersonAPI person;
577 public PersonMadeRequired(PersonAPI person) {
578 this.person = person;
581 public void abort(HubMission mission,
boolean missionOver) {
584 if (Misc.setFlagWithReason(person.getMemoryWithoutUpdate(),
585 "$requiredForMissions", bhm.getReason(),
false, -1f)) {
593 protected LinkedHashMap<Object, StageData>
stages =
new LinkedHashMap<Object, StageData>();
599 protected List<StageConnection>
connections =
new ArrayList<StageConnection>();
600 protected List<MissionTrigger>
triggers =
new ArrayList<MissionTrigger>();
601 protected List<Abortable>
changes =
new ArrayList<Abortable>();
602 protected List<FlagData>
flags =
new ArrayList<FlagData>();
619 protected IntervalUtil
tracker =
new IntervalUtil(0.09f, 0.11f);
642 public static class PotentialContactData {
643 public PersonAPI contact;
644 public float probability = -1f;
658 this.doNotAutoAddPotentialContactsOnSuccess =
true;
673 if (person ==
null)
return;
678 if (data.contact == person)
return;
680 PotentialContactData data =
new PotentialContactData();
681 data.contact = person;
682 data.probability = probability;
707 if (!
create(market, barEvent)) {
711 protected abstract boolean create(MarketAPI createdAt,
boolean barEvent);
719 return "Call setName(<name>) to set mission name";
735 info.addPara(text, tc, pad);
747 info.addPara(text, opad);
752 info.addPara(
"You have successfully " + verb +
" this " + noun +
".", opad);
754 info.addPara(
"You have failed this " + noun +
".", opad);
756 info.addPara(
"You have abandoned this " + noun +
".", opad);
774 stage.elapsed += days;
782 (
timeLimit.noLimitWhileInSystem ==
null ||
790 if (
tracker.intervalElapsed()) {
798 return stage.elapsed;
809 public void accept(InteractionDialogAPI dialog, Map<String, MemoryAPI> memoryMap) {
813 throw new RuntimeException(
"startingStage can not be null. Use setStartingStage()");
822 TextPanelAPI text = dialog !=
null ? dialog.getTextPanel() :
null;
827 Global.
getSector().getPlayerFleet().getCargo().addItems(stack.getType(), stack.getData(), stack.getSize());
829 AddRemoveCommodity.addStackGainText(stack, text);
843 public void acceptImpl(InteractionDialogAPI dialog, Map<String, MemoryAPI> memoryMap) {
850 for (Abortable curr :
changes) {
851 curr.abort(
this, missionWasAccepted);
856 if (!missionWasAccepted) {
882 protected boolean callAction(String action, String ruleId, InteractionDialogAPI dialog, List<Token> params, Map<String, MemoryAPI> memoryMap) {
889 PersonAPI p = curr.contact;
890 MarketAPI m = curr.contact.getMarket();
891 if (m ==
null) m =
getPerson().getMarket();
893 if (curr.probability < 0) {
894 ContactIntel.addPotentialContact(p, m, dialog !=
null ? dialog.getTextPanel() :
null);
896 ContactIntel.addPotentialContact(curr.probability, p, m, dialog !=
null ? dialog.getTextPanel() :
null);
904 @SuppressWarnings(
"rawtypes")
906 public boolean callEvent(String ruleId, InteractionDialogAPI dialog, List<Token> params, Map<String, MemoryAPI> memoryMap) {
907 String action = params.get(0).getString(memoryMap);
909 if (
"endFailure".equals(action)) {
924 if (
"makeUnimportant".equals(action)) {
925 SectorEntityToken target = dialog.getInteractionTarget();
926 if (target !=
null) {
928 if (target.getMarket() !=
null) {
931 if (target.getActivePerson() !=
null) {
938 if (
"showMap".equals(action)) {
940 if (mapLoc !=
null) {
941 String title = params.get(1).getStringWithTokenReplacement(ruleId, dialog, memoryMap);
944 tags.remove(Tags.INTEL_ACCEPTED);
949 if (mapLoc !=
null && mapLoc.getFaction() !=
null && !mapLoc.getFaction().isNeutralFaction()) {
950 color = mapLoc.getFaction().getBaseUIColor();
952 }
else if (mapLoc instanceof PlanetAPI) {
953 PlanetAPI planet = (PlanetAPI) mapLoc;
954 if (planet.getStarSystem() !=
null && planet.getFaction().isNeutralFaction()) {
955 StarSystemAPI system = planet.getStarSystem();
956 if (system.getStar() == planet || system.getCenter() == planet) {
957 if (planet.getMarket() !=
null) {
958 color = planet.getMarket().getTextColorForFactionOrPlanet();
960 color = Misc.setAlpha(planet.getSpec().getIconColor(), 255);
961 color = Misc.setBrightness(color, 235);
964 color = Misc.setAlpha(planet.getSpec().getIconColor(), 255);
965 color = Misc.setBrightness(color, 235);
973 dialog.getVisualPanel().showMapMarker(mapLoc,
975 true, icon, text, tags);
980 if (
"hideMap".equals(action)) {
981 dialog.getVisualPanel().removeMapMarkerFromPersonInfo();
996 if (action.equals(
"updateStage")) {
998 }
else if (action.equals(
"updateData")) {
1001 }
else if (action.equals(
"addContacts")) {
1003 }
else if (action.equals(
"repSuccess")) {
1004 adjustRep(dialog.getTextPanel(),
null, RepActions.MISSION_SUCCESS);
1005 }
else if (action.equals(
"repFailure")) {
1006 adjustRep(dialog.getTextPanel(),
null, RepActions.MISSION_FAILURE);
1008 if (!
callAction(action, ruleId, dialog, params, memoryMap)) {
1009 throw new RuntimeException(
"Unhandled action [" + action +
"] in " + getClass().getSimpleName() +
1010 " for rule [" + ruleId +
"], params:[" + params +
"]");
1016 protected void showPersonInfo(PersonAPI person, InteractionDialogAPI dialog,
boolean withFaction,
boolean withRelBar) {
1017 dialog.getInteractionTarget().setActivePerson(person);
1018 dialog.getVisualPanel().showPersonInfo(person, !withFaction, withRelBar);
1025 if (dialog.getInteractionTarget().getActivePerson() !=
null) {
1026 interactionMemory = dialog.getInteractionTarget().getActivePerson().getMemoryWithoutUpdate();
1036 if (
isBarEvent() || !memoryMap.containsKey(MemKeys.ENTITY)) {
1054 if (person ==
null)
return;
1056 if (person.isMale()) {
1057 mem.set(
"$hisOrHer",
"his", 0);
1058 mem.set(
"$HisOrHer",
"His", 0);
1059 mem.set(
"$himOrHer",
"him", 0);
1060 mem.set(
"$HimOrHer",
"Him", 0);
1061 mem.set(
"$heOrShe",
"he", 0);
1062 mem.set(
"$HeOrShe",
"He", 0);
1063 mem.set(
"$himOrHerself",
"himself", 0);
1064 mem.set(
"$HimOrHerself",
"Himself", 0);
1065 mem.set(
"$manOrWoman",
"man", 0);
1066 mem.set(
"$ManOrWoman",
"Man", 0);
1068 mem.set(
"$hisOrHer",
"her", 0);
1069 mem.set(
"$HisOrHer",
"Her", 0);
1070 mem.set(
"$himOrHer",
"her", 0);
1071 mem.set(
"$HimOrHer",
"Her", 0);
1072 mem.set(
"$heOrShe",
"she", 0);
1073 mem.set(
"$HeOrShe",
"She", 0);
1074 mem.set(
"$himOrHerself",
"herself", 0);
1075 mem.set(
"$HimOrHerself",
"Herself", 0);
1076 mem.set(
"$manOrWoman",
"woman", 0);
1077 mem.set(
"$ManOrWoman",
"Woman", 0);
1080 if (person.getRank() !=
null) {
1081 mem.set(
"$personRankAOrAn", person.getRankArticle(), 0);
1082 mem.set(
"$personRank", person.getRank().toLowerCase(), 0);
1083 mem.set(
"$PersonRank", Misc.ucFirst(person.getRank()), 0);
1086 if (person.getPost() !=
null) {
1087 mem.set(
"$personPostAOrAn", person.getPostArticle().toLowerCase(), 0);
1088 mem.set(
"$personPost", person.getPost().toLowerCase(), 0);
1089 mem.set(
"$PersonPost", Misc.ucFirst(person.getPost()), 0);
1092 mem.set(
"$PersonName", person.getName().getFullName(), 0);
1093 mem.set(
"$personName", person.getName().getFullName(), 0);
1094 mem.set(
"$personFirstName", person.getName().getFirst(), 0);
1095 mem.set(
"$personLastName", person.getName().getLast(), 0);
1097 if (person.getVoice() !=
null) {
1098 mem.set(
"$voice", person.getVoice());
1100 if (person.getImportance() !=
null) {
1101 mem.set(
"$importance", person.getImportance().name());
1106 public void set(String key, Object value) {
1107 if (value instanceof Enum) value = ((Enum)value).name();
1117 if (
id ==
null)
return null;
1118 StageData data =
stages.get(
id);
1120 data =
new StageData();
1132 if (isEnding())
return;
1133 boolean changed =
false;
1137 if (conn.from !=
currentStage && conn.from !=
null)
continue;
1140 if (conn.checker.conditionsMet()) {
1158 Iterator<MissionTrigger> iter =
triggers.iterator();
1159 while (iter.hasNext()) {
1163 TriggerActionContext context =
new TriggerActionContext(
this);
1164 for (TriggerAction curr : trigger.
getActions()) {
1165 curr.doAction(context);
1173 List<CampaignFleetAPI>
result =
new ArrayList<CampaignFleetAPI>();
1174 Iterator<MissionTrigger> iter =
triggers.iterator();
1175 while (iter.hasNext()) {
1177 if (!trigger.
getStages().contains(stage))
continue;
1179 TriggerActionContext context =
new TriggerActionContext(
this);
1180 for (TriggerAction curr : trigger.
getActions()) {
1181 curr.doAction(context);
1184 result.addAll(context.allFleets);
1191 public void setCurrentStage(Object next, InteractionDialogAPI dialog, Map<String, MemoryAPI> memoryMap) {
1198 for (ImportanceData curr : data.important) {
1199 Misc.makeUnimportant(curr.memory,
getReason());
1202 if (curr.flag !=
null) {
1203 curr.memory.unset(curr.flag);
1217 for (ImportanceData curr : data.important) {
1220 Misc.makeImportant(curr.memory,
getReason());
1222 if (curr.flag !=
null) {
1223 curr.memory.set(curr.flag,
true);
1224 changes.add(
new VariableSet(curr.memory, curr.flag,
true));
1228 for (FlagData fd :
flags) {
1231 fd.memory.set(fd.flag,
true);
1232 changes.add(
new VariableSet(fd.memory, fd.flag,
true));
1234 fd.memory.unset(fd.flag);
1256 protected void endSuccess(InteractionDialogAPI dialog, Map<String, MemoryAPI> memoryMap) {
1257 setImportant(
false);
1259 result =
new HubMissionResult();
1260 result.success =
true;
1262 TextPanelAPI textPanel =
null;
1263 if (dialog !=
null) textPanel = dialog.getTextPanel();
1272 Global.
getSector().getPlayerFleet().getCargo().getCredits().add(reward);
1275 if (textPanel !=
null && reward > 0) {
1276 AddRemoveCommodity.addCreditsGainText(reward, dialog.getTextPanel());
1280 result.reward = reward;
1291 Global.
getSector().getPlayerFleet().getCargo().addItems(stack.getType(), stack.getData(), stack.getSize());
1292 if (textPanel !=
null) {
1293 AddRemoveCommodity.addStackGainText(stack, textPanel);
1312 PersonAPI p = curr.contact;
1313 MarketAPI m = curr.contact.getMarket();
1314 if (m ==
null) m =
getPerson().getMarket();
1315 if (curr.probability < 0) {
1316 ContactIntel.addPotentialContact(p, m, dialog !=
null ? dialog.getTextPanel() :
null);
1318 ContactIntel.addPotentialContact(curr.probability, p, m, dialog !=
null ? dialog.getTextPanel() :
null);
1333 protected void endFailure(InteractionDialogAPI dialog, Map<String, MemoryAPI> memoryMap) {
1334 setImportant(
false);
1336 result =
new HubMissionResult();
1337 result.success =
false;
1339 TextPanelAPI textPanel =
null;
1340 if (dialog !=
null) textPanel = dialog.getTextPanel();
1359 result =
new HubMissionResult();
1360 result.success =
false;
1375 protected void endSuccessImpl(InteractionDialogAPI dialog, Map<String, MemoryAPI> memoryMap) {
1377 protected void endFailureImpl(InteractionDialogAPI dialog, Map<String, MemoryAPI> memoryMap) {
1384 protected void adjustRep(TextPanelAPI textPanel, HubMissionResult
result, RepActions action) {
1388 MissionCompletionRep completionRepPerson =
new MissionCompletionRep(
1391 MissionCompletionRep completionRepFaction =
new MissionCompletionRep(
1395 boolean withMessage = textPanel !=
null;
1397 boolean adjustPersonRep = (action == RepActions.MISSION_SUCCESS && completionRepPerson.successDelta != 0) ||
1398 (action == RepActions.MISSION_FAILURE && completionRepPerson.failureDelta != 0);
1399 if (adjustPersonRep &&
getPerson() !=
null) {
1400 ReputationAdjustmentResult rep =
Global.
getSector().adjustPlayerReputation(
1401 new RepActionEnvelope(action, completionRepPerson,
1402 textPanel,
true, withMessage),
1404 if (
result !=
null) result.repPerson = rep;
1405 completionRepPerson.successDelta = 0;
1408 boolean adjustFactionRep = (action == RepActions.MISSION_SUCCESS && completionRepFaction.successDelta != 0) ||
1409 (action == RepActions.MISSION_FAILURE && completionRepFaction.failureDelta != 0);
1410 if (adjustFactionRep &&
getPerson() !=
null) {
1411 ReputationAdjustmentResult rep =
Global.
getSector().adjustPlayerReputation(
1412 new RepActionEnvelope(action, completionRepFaction,
1413 textPanel,
true, withMessage),
1415 if (
result !=
null) result.repFaction = rep;
1416 completionRepFaction.successDelta = 0f;
1425 for (Object
id : ids) {
1434 for (Object
id : ids) {
1444 for (Object
id : ids) {
1450 Iterator<Abortable> iter =
changes.iterator();
1451 while (iter.hasNext()) {
1452 Abortable curr = iter.next();
1453 if (curr instanceof MadeImportant) {
1454 MadeImportant mi = (MadeImportant) curr;
1455 if (mi.memory == memory) {
1463 Iterator<Abortable> iter =
changes.iterator();
1464 while (iter.hasNext()) {
1465 Abortable curr = iter.next();
1466 if (curr instanceof VariableSet) {
1467 VariableSet vs = (VariableSet) curr;
1468 if (vs.memory == memory && flag.equals(vs.key)) {
1491 return RepRewards.HIGH;
1496 return RepRewards.SMALL;
1501 return RepRewards.MEDIUM;
1506 return RepRewards.TINY;
1535 if (
hub ==
null)
return null;
1552 if (person.getMemoryWithoutUpdate().getBoolean(
"$doGenericPortAuthorityCheck"))
return;
1553 setFlag(person,
"$doGenericPortAuthorityCheck",
false);
1561 setFlag(entity.getMemoryWithoutUpdate(), flag,
null, permanent, (Object[])
null);
1564 Misc.setFlagWithReason(entity.getMemoryWithoutUpdate(), flag, reason,
true, -1f);
1567 String requiredKey = flag +
"_" + reason;
1568 changes.add(
new VariableSet(entity.getMemoryWithoutUpdate(), requiredKey,
true));
1572 public void setFlag(SectorEntityToken entity, String flag,
boolean permanent) {
1573 setFlag(entity.getMemoryWithoutUpdate(), flag,
null, permanent, (Object[])
null);
1575 public void setFlag(PersonAPI person, String flag,
boolean permanent) {
1576 setFlag(person.getMemoryWithoutUpdate(), flag,
null, permanent, (Object[])
null);
1579 public void setFlag(SectorEntityToken entity, String flag,
boolean permanent, Object ...
stages) {
1580 setFlag(entity.getMemoryWithoutUpdate(), flag,
null, permanent,
stages);
1582 public void setFlag(PersonAPI person, String flag,
boolean permanent, Object ...
stages) {
1583 setFlag(person.getMemoryWithoutUpdate(), flag,
null, permanent,
stages);
1590 public void setFlag(MemoryAPI memory, String flag, Object value,
boolean permanent) {
1591 setFlag(memory, flag, value, permanent, (Object [])
null);
1593 public void setFlag(MemoryAPI memory, String flag, Object value,
boolean permanent, Object ...
stages) {
1595 FlagData fd =
new FlagData();
1598 fd.stages.addAll(Arrays.asList(
stages));
1602 fd.memory.set(fd.flag,
true);
1603 changes.add(
new VariableSet(fd.memory, fd.flag,
true));
1606 if (value ==
null) {
1607 memory.set(flag,
true);
1609 memory.set(flag, value);
1611 changes.add(
new VariableSet(memory, flag, !permanent));
1631 if (inProgressFlag !=
null) {
1639 if (person ==
null)
return false;
1640 if (person.getMemoryWithoutUpdate().contains(key)) {
1643 person.getMemoryWithoutUpdate().set(key,
this);
1644 changes.add(
new VariableSet(person.getMemoryWithoutUpdate(), key,
true));
1649 if (faction ==
null)
return false;
1650 if (faction.getMemoryWithoutUpdate().contains(key)) {
1653 faction.getMemoryWithoutUpdate().set(key,
this);
1654 changes.add(
new VariableSet(faction.getMemoryWithoutUpdate(), key,
true));
1659 if (market ==
null)
return false;
1660 if (market.getMemoryWithoutUpdate().contains(key)) {
1663 market.getMemoryWithoutUpdate().set(key,
this);
1664 changes.add(
new VariableSet(market.getMemoryWithoutUpdate(), key,
true));
1669 if (entity ==
null)
return false;
1670 if (entity.getMemoryWithoutUpdate().contains(key)) {
1673 entity.getMemoryWithoutUpdate().set(key,
this);
1674 changes.add(
new VariableSet(entity.getMemoryWithoutUpdate(), key,
true));
1692 makeImportant(person.getMemoryWithoutUpdate(), flag, MapLocationType.NORMAL, person,
stages);
1695 makeImportant(entity.getMemoryWithoutUpdate(), flag, MapLocationType.NORMAL, entity,
stages);
1698 makeImportant(market.getMemoryWithoutUpdate(), flag, MapLocationType.NORMAL, market,
stages);
1700 public void makeImportant(MemoryAPI memory, String flag, MapLocationType type, Object personOrEntityOrMarket, Enum ...
stages) {
1701 boolean inCurrentStage =
false;
1703 for (Object
id :
stages) {
1705 ImportanceData data =
new ImportanceData();
1706 data.memory = memory;
1708 data.locType = type;
1709 if (personOrEntityOrMarket instanceof PersonAPI) {
1710 data.person = (PersonAPI) personOrEntityOrMarket;
1711 }
else if (personOrEntityOrMarket instanceof SectorEntityToken) {
1712 data.entity = (SectorEntityToken) personOrEntityOrMarket;
1713 }
else if (personOrEntityOrMarket instanceof MarketAPI) {
1714 data.market = (MarketAPI) personOrEntityOrMarket;
1716 getData(
id).important.add(data);
1719 inCurrentStage =
true;
1722 if (inCurrentStage) {
1723 Misc.makeImportant(memory,
getReason());
1728 memory.set(flag,
true);
1730 changes.add(
new VariableSet(memory, flag,
true));
1737 if (person ==
null)
return;
1741 if (entity ==
null)
return;
1745 if (market ==
null)
return;
1749 if (person ==
null)
return;
1750 makeUnimportant(person.getMemoryWithoutUpdate(), person, (Enum [])
null);
1753 if (entity ==
null)
return;
1754 makeUnimportant(entity.getMemoryWithoutUpdate(), entity, (Enum [])
null);
1757 if (market ==
null)
return;
1758 makeUnimportant(market.getMemoryWithoutUpdate(), market, (Enum [])
null);
1766 for (Object
id :
stages) {
1767 StageData stageData =
getData(
id);
1768 list.add(stageData);
1771 list.addAll(this.stages.values());
1774 for (StageData stageData : list) {
1775 Iterator<ImportanceData> iter = stageData.important.iterator();
1776 while (iter.hasNext()) {
1777 ImportanceData data = iter.next();
1778 if (data.memory == memory ||
1779 data.person == personOrEntityOrMarket ||
1780 data.entity == personOrEntityOrMarket ||
1781 data.market == personOrEntityOrMarket) {
1786 Misc.makeUnimportant(memory,
getReason());
1794 public void setTimeLimit(Object failStage,
float days, StarSystemAPI noLimitWhileInSystem, Object ... noLimitAfterStages) {
1796 timeLimit.days = days;
1797 timeLimit.failStage = failStage;
1798 timeLimit.noLimitWhileInSystem = noLimitWhileInSystem;
1799 if (noLimitAfterStages !=
null) {
1800 for (Object stage : noLimitAfterStages) {
1817 int num2 = (int) num;
1818 for (
int i = 1; i < 10; i++) {
1819 int threshold = (int) Math.pow(10, i);
1820 int base = threshold / 10;
1821 if (num2 > threshold) {
1822 num2 = num2 / base * base;
1831 int reward = min +
genRandom.nextInt(max - min + 1);
1835 reward = reward / 1000 * 1000;
1836 if (reward > 100000) {
1837 reward = reward / 10000 * 10000;
1855 setCreditReward(reward.min / 2 + reward.perMarketSize * Math.max(0, marketSize - 3),
1856 reward.max / 2 + reward.perMarketSize * Math.max(0, marketSize - 3));
1883 if (this.xpReward <= 0) this.xpReward =
null;
2006 Set<String> tags = super.getIntelTags(map);
2007 tags.add(Tags.INTEL_MISSIONS);
2008 tags.add(Tags.INTEL_ACCEPTED);
2019 if ((entity.isDiscoverable() ||
2020 (entity instanceof CampaignFleetAPI && !((CampaignFleetAPI)entity).isVisibleToPlayerFleet())) && entity.getStarSystem() !=
null) {
2021 return entity.getStarSystem().getCenter();
2035 ImportanceData data =
null;
2036 for (ImportanceData curr : stage.important) {
2037 if (curr.locType ==
null)
continue;
2038 if (curr.entity == personOrMarketOrEntity ||
2039 curr.market == personOrMarketOrEntity ||
2040 curr.person == personOrMarketOrEntity) {
2046 stage.important.remove(data);
2047 stage.important.add(0, data);
2056 ImportanceData data =
null;
2057 for (ImportanceData curr : stage.important) {
2058 if (curr.locType ==
null)
continue;
2059 if (curr.entity !=
null && !curr.entity.isAlive())
continue;
2063 if (data ==
null || data.locType ==
null)
return null;
2065 SectorEntityToken entity = data.entity;
2066 if (entity ==
null && data.person !=
null && data.person.getMarket() !=
null) {
2067 entity = data.person.getMarket().getPrimaryEntity();
2069 if (entity ==
null && data.market!=
null) {
2070 entity = data.market.getPrimaryEntity();
2072 if (entity ==
null)
return null;
2074 if (data.locType == MapLocationType.NORMAL) {
2075 if ((entity.isDiscoverable() ||
2076 (entity instanceof CampaignFleetAPI && !((CampaignFleetAPI)entity).isVisibleToPlayerFleet())) && entity.getStarSystem() !=
null) {
2077 return entity.getStarSystem().getCenter();
2080 }
else if (data.locType == MapLocationType.CONSTELLATION) {
2081 Constellation c = entity.getConstellation();
2082 SectorEntityToken
result =
null;
2083 if (c !=
null && map !=
null) {
2084 result = map.getConstellationLabelEntity(c);
2107 return " - Completed";
2111 return " - Abandoned";
2116 return " - Accepted";
2152 if (!isEnding() && !isEnded()) {
2155 return super.getImportantIcon();
2159 if (
result ==
null)
return;
2160 if (mode == ListInfoMode.INTEL)
return;
2162 Color h = Misc.getHighlightColor();
2163 Color tc = getBulletColorForMode(mode);
2166 boolean isUpdate = getListInfoParam() !=
null;
2168 if (mode == ListInfoMode.IN_DESC) initPad = 10f;
2171 info.addPara(
"%s received", initPad, tc, h, Misc.getDGSCredits(
result.reward));
2175 if (
result.repPerson !=
null) {
2177 null, info, tc, isUpdate, initPad);
2180 if (
result.repFaction !=
null) {
2182 null, info, tc, isUpdate, initPad);
2190 if (textPanel ==
null) {
2191 sendUpdateIfPlayerHasIntel(listInfoParam,
false);
2193 this.listInfoParam = listInfoParam;
2194 Global.
getSector().getIntelManager().addIntelToTextPanel(
this, textPanel);
2195 this.listInfoParam =
null;
2200 this.listInfoParam = listInfoParam;
2201 Global.
getSector().getIntelManager().addIntelToTextPanel(
this, textPanel);
2202 this.listInfoParam =
null;
2213 return "to complete";
2218 Color h = Misc.getHighlightColor();
2219 Color g = Misc.getGrayColor();
2223 float initPad = pad;
2224 if (mode == ListInfoMode.IN_DESC) initPad = opad;
2226 Color tc = getBulletColorForMode(mode);
2232 boolean isUpdate = getListInfoParam() !=
null;
2255 if (mode == ListInfoMode.IN_DESC) {
2259 if (mode == ListInfoMode.IN_DESC) {
2266 info.addPara(
"%s reward", initPad, tc, h, Misc.getDGSCredits(reward));
2298 if (
sortTier ==
null || isEnding() || isEnded())
return super.getSortTier();
2310 Color c = getTitleColor(mode);
2312 if (large) info.setParaSmallInsignia();
2313 info.addPara(
getName(), c, 0f);
2314 if (large) info.setParaFontDefault();
2321 Color h = Misc.getHighlightColor();
2322 Color g = Misc.getGrayColor();
2329 if (person !=
null) {
2330 info.addImages(width, 128, opad, opad, person.getPortraitSprite(), faction.getCrest());
2332 String post =
"one";
2333 if (person.getPost() !=
null) post = person.getPost().toLowerCase();
2334 if (post ==
null && person.getRank() !=
null) post = person.getRank().toLowerCase();
2335 info.addPara(Misc.ucFirst(
getMissionTypeNoun()) +
" given by " + post +
" " + person.getNameString() +
", affiliated with " +
2336 faction.getDisplayNameWithArticle() +
".",
2337 opad, faction.getBaseUIColor(), faction.getDisplayNameWithArticleWithoutArticle());
2361 this.abandonStage =
null;
2369 return super.doesButtonHaveConfirmDialog(buttonId);
2379 (
int)(width), 20f, opad * 2f);
2380 button.setShortcut(Keyboard.KEY_U,
true);
2394 setImportant(
false);
2400 super.buttonPressConfirmed(buttonId, ui);
2411 if (!loseRepFaction && !loseRepPerson) {
2412 prompt.addPara(
"You can abandon this " +
getMissionTypeNoun() +
" without a penalty.", 0f);
2414 prompt.addPara(
"It's been less than a day, and you can still abandon this " +
getMissionTypeNoun() +
" without a penalty.", 0f);
2416 if (loseRepFaction && !loseRepPerson) {
2417 prompt.addPara(
"You can abandon this " +
getMissionTypeNoun() +
", but will suffer " +
2418 "a reputation penalty with " + faction.getDisplayNameWithArticle() +
".", 0f,
2419 Misc.getTextColor(), faction.getBaseUIColor(), faction.getDisplayNameWithArticleWithoutArticle());
2420 }
else if (!loseRepFaction && loseRepPerson) {
2421 prompt.addPara(
"You can abandon this " +
getMissionTypeNoun() +
", but will suffer " +
2422 "a reputation penalty with " +
getPerson().getNameString() +
".",
2423 Misc.getTextColor(), 0f);
2425 prompt.addPara(
"You can abandon this " +
getMissionTypeNoun() +
", but will suffer " +
2426 "a reputation penalty with both " +
getPerson().getNameString() +
" and " +
2427 faction.getDisplayNameWithArticle() +
".", 0f,
2428 Misc.getTextColor(), faction.getBaseUIColor(), faction.getDisplayNameWithArticleWithoutArticle());
2432 super.createConfirmationPrompt(buttonId, prompt);
2451 dist = (int) Math.round(Misc.getDistanceLY(
getPerson().
getMarket().getLocationInHyperspace(), entity.getLocationInHyperspace()));
2459 dist = (int) Math.round(Misc.getDistanceLY(
getPerson().
getMarket().getLocationInHyperspace(), system.getLocation()));
2464 public int getFuel(SectorEntityToken entity,
boolean bothWays) {
2467 float fuel =
Global.
getSector().getPlayerFleet().getLogistics().getFuelCostPerLightYear();
2469 if (bothWays) fuel *= 2f;
2470 return (
int) Math.round(fuel);
2474 WeightedRandomPicker<Object> picker =
new WeightedRandomPicker<Object>(
genRandom);
2475 for (Object option : options) {
2478 return picker.pick();
2482 return pickOne(options.toArray(
new String[0]));
2485 WeightedRandomPicker<String> picker =
new WeightedRandomPicker<String>(
genRandom);
2486 for (String option : options) {
2489 return picker.pick();
2493 if (item.startsWith(
"a ")) {
2494 return item.replaceFirst(
"a ",
"");
2496 if (item.startsWith(
"an ")) {
2497 return item.replaceFirst(
"an ",
"");
2499 if (item.startsWith(
"the ")) {
2500 return item.replaceFirst(
"the ",
"");
2527 connections.add(
new StageConnection(
null, to, custom));
2531 connections.add(
new StageConnection(from, to,
new GlobalBooleanChecker(flag)));
2548 connections.add(
new StageConnection(from, to,
new MemoryBooleanChecker(memory, flag)));
2550 changes.add(
new VariableSet(memory, flag,
true));
2554 connections.add(
new StageConnection(from, to,
new EntityNotAliveChecker(entity)));
2558 connections.add(
new StageConnection(from, to,
new MarketDecivChecker(market)));
2561 connections.add(
new StageConnection(
null, to,
new MarketDecivChecker(market)));
2565 connections.add(
new StageConnection(from, to,
new HostilitiesEndedChecker(person, market)));
2568 connections.add(
new StageConnection(
null, to,
new HostilitiesEndedChecker(person, market)));
2571 connections.add(
new StageConnection(from, to,
new HostilitiesStartedChecker(person, market)));
2574 connections.add(
new StageConnection(
null, to,
new HostilitiesStartedChecker(person, market)));
2578 connections.add(
new StageConnection(from, to,
new DaysElapsedChecker(days,
getData(from))));
2582 connections.add(
new StageConnection(from, to,
new InCommRelayRangeChecker()));
2586 connections.add(
new StageConnection(from, to,
new EnteredLocationChecker(location)));
2589 connections.add(
new StageConnection(from, to,
new InRangeOfEntityChecker(entity, range)));
2595 boolean requirePlayerInHyperspace) {
2596 connections.add(
new StageConnection(from, to,
new InHyperRangeOfEntityChecker(entity, rangeLY, requirePlayerInHyperspace)));
2600 connections.add(
new StageConnection(from, to, custom));
2609 DebrisFieldParams params =
new DebrisFieldParams(
2614 params.source = DebrisFieldSource.MIXED;
2615 params.baseSalvageXP = (long) radius;
2617 if (!data.updateLocIfNeeded(
this,
null))
return null;
2619 SectorEntityToken debris = Misc.addDebrisField(data.system, params,
genRandom);
2620 data.placeEntity(debris);
2621 changes.add(
new EntityAdded(debris));
2627 return spawnEntity(Entities.MISSION_LOCATION, data);
2634 entity.setDiscoveryXP(xp);
2635 entity.setSensorProfile(1f);
2636 entity.setDiscoverable(
true);
2637 entity.getDetectedRangeMod().modifyFlat(
"gen", range);
2640 public EntityLocation
generateLocation(String entityId, EntityLocationType locType, SectorEntityToken param, LocationAPI system) {
2641 EntityLocation loc =
null;
2643 if (system instanceof StarSystemAPI) {
2644 if (locType == EntityLocationType.HIDDEN) {
2645 loc = BaseThemeGenerator.pickHiddenLocation(
genRandom, (StarSystemAPI)system, gap,
null);
2646 }
else if (locType == EntityLocationType.HIDDEN_NOT_NEAR_STAR) {
2647 loc = BaseThemeGenerator.pickHiddenLocationNotNearStar(
genRandom, (StarSystemAPI)system, gap,
null);
2648 }
else if (locType == EntityLocationType.ORBITING_PLANET) {
2649 loc = BaseThemeGenerator.pickCommonLocation(
genRandom, (StarSystemAPI)system, gap,
false,
null);
2650 }
else if (locType == EntityLocationType.ORBITING_PLANET_OR_STAR) {
2651 loc = BaseThemeGenerator.pickCommonLocation(
genRandom, (StarSystemAPI)system, gap,
true,
null);
2652 }
else if (locType == EntityLocationType.UNCOMMON) {
2653 loc = BaseThemeGenerator.pickUncommonLocation(
genRandom, (StarSystemAPI)system, gap,
null);
2654 }
else if (locType == EntityLocationType.ANY) {
2655 loc = BaseThemeGenerator.pickAnyLocation(
genRandom, (StarSystemAPI)system, gap,
null);
2659 if (locType == EntityLocationType.ORBITING_PARAM) {
2660 loc = BaseThemeGenerator.createLocationAtRandomGap(
genRandom, param, gap);
2663 if (entityId !=
null) {
2665 radius = spec.getDefaultRadius();
2667 loc =
new EntityLocation();
2668 loc.type = LocationType.PLANET_ORBIT;
2670 genRandom.nextFloat() * 360f, param.getRadius() + radius + 100f,
2676 if (system instanceof StarSystemAPI) {
2677 loc =
new EntityLocation();
2678 loc.type = LocationType.STAR_ORBIT;
2683 loc =
new EntityLocation();
2684 loc.type = LocationType.OUTER_SYSTEM;
2685 loc.location =
new Vector2f();
2693 if (!data.updateLocIfNeeded(
this, entityId))
return null;
2695 AddedEntity added = BaseThemeGenerator.addEntityAutoDetermineType(
genRandom, data.system, data.loc, entityId, Factions.NEUTRAL);
2696 if (added ==
null)
return null;
2698 if (data.removeOnMissionOver) {
2702 added.entity.addTag(Tags.NOT_RANDOM_MISSION_TARGET);
2704 changes.add(
new EntityAdded(added.entity));
2705 return added.entity;
2709 if (!data.updateLocIfNeeded(
this,
null))
return null;
2711 SectorEntityToken token = data.system.createToken(0, 0);
2712 data.system.addEntity(token);
2713 data.placeEntity(token);
2714 changes.add(
new EntityAdded(token));
2721 if (hullId ==
null) {
2728 public SectorEntityToken
spawnDerelict(String factionId, DerelictType type, LocData data) {
2729 if (factionId ==
null) {
2736 WeightedRandomPicker<String> factions = SalvageSpecialAssigner.getNearbyFactions(
genRandom, data.system.getLocation(),
2742 public SectorEntityToken
spawnDerelict(DerelictShipData shipData, LocData data) {
2743 if (shipData ==
null)
return null;
2745 if (!data.updateLocIfNeeded(
this, Entities.WRECK))
return null;
2747 SectorEntityToken entity = BaseThemeGenerator.addSalvageEntity(
genRandom, data.system, Entities.WRECK, Factions.NEUTRAL, shipData);
2748 entity.setDiscoverable(
true);
2749 data.placeEntity(entity);
2751 changes.add(
new EntityAdded(entity));
2758 int numShips = minShips +
genRandom.nextInt(maxShips - minShips + 1);
2760 WeightedRandomPicker<Float> bands =
new WeightedRandomPicker<Float>(
genRandom);
2761 for (
int i = 0; i < numShips + 5; i++) {
2762 bands.add(
new Float(120f + i * 20f), (i + 1f) * (i + 1f));
2765 for (
int i = 0; i < numShips; i++) {
2766 float r = bands.pickAndRemove();
2768 EntityLocation loc =
new EntityLocation();
2769 loc.type = LocationType.OUTER_SYSTEM;
2770 float orbitDays = r / (5f +
genRandom.nextFloat() * 10f);
2773 LocData curr =
new LocData(loc, data.system, data.removeOnMissionOver);
2780 protected PersonAPI
findOrCreateTrader(String factionId, MarketAPI market,
boolean cleanUpOnMissionOverIfWasNewPerson) {
2784 Ranks.POST_MERCHANT);
2788 Ranks.POST_MERCHANT,
2789 Ranks.POST_COMMODITIES_AGENT,
2790 Ranks.POST_INVESTOR,
2796 return findOrCreatePerson(Factions.PIRATES, market, cleanUpOnMissionOverIfWasNewPerson,
2798 Ranks.POST_GANGSTER,
2799 Ranks.POST_SMUGGLER,
2805 return findOrCreatePerson(Factions.PIRATES, market, cleanUpOnMissionOverIfWasNewPerson,
2807 Ranks.POST_SMUGGLER,
2812 protected PersonAPI
findOrCreatePerson(String factionId, MarketAPI market,
boolean cleanUpOnMissionOverIfWasNewPerson, String defaultRank, String ... posts) {
2814 PersonAPI person =
null;
2818 FactionAPI faction =
null;
2819 if (market !=
null) faction = market.getFaction();
2820 if (factionId !=
null) {
2824 person = ip.getPerson(
genRandom, faction, market, reason, defaultRank, posts).getPerson();
2826 boolean createdNewPerson = !ip.isLastGetPersonResultWasExistingPerson();
2828 if (person !=
null && !createdNewPerson &&
2829 Misc.flagHasReason(person.getMemoryWithoutUpdate(),
"$requiredForMissions",
getReason())) {
2839 if (person ==
null) {
2840 person = faction.createRandomPerson(
genRandom);
2841 WeightedRandomPicker<String> postPicker =
new WeightedRandomPicker<String>(
genRandom);
2842 for (String post : posts) {
2843 postPicker.add(post);
2845 person.setPostId(postPicker.pick());
2846 person.setRankId(defaultRank);
2847 person.setMarket(market);
2848 if (market !=
null) market.addPerson(person);
2849 ip.addPerson(person);
2850 ip.getData(person).getLocation().setMarket(market);
2854 ip.excludeFromGetPerson(person);
2857 boolean addedToComms =
false;
2858 if (market !=
null && market.getCommDirectory().getEntryForPerson(person) ==
null) {
2859 market.getCommDirectory().addPerson(person);
2860 addedToComms =
true;
2863 boolean willBeRemoved =
false;
2864 if (createdNewPerson || addedToComms) {
2865 if (cleanUpOnMissionOverIfWasNewPerson) {
2868 PersonAdded added =
new PersonAdded(market, person, !createdNewPerson);
2870 willBeRemoved =
true;
2875 PersonAdded added =
new PersonAdded(market, person,
false);
2879 person.setMarket(market);
2885 PersonMadeRequired req =
new PersonMadeRequired(person);
2888 Misc.setFlagWithReason(person.getMemoryWithoutUpdate(),
"$requiredForMissions",
getReason(),
true, -1f);
2892 boolean addedToComms =
false;
2893 if (market !=
null && market.getCommDirectory().getEntryForPerson(person) ==
null) {
2894 market.getCommDirectory().addPerson(person);
2895 addedToComms =
true;
2899 PersonAdded added =
new PersonAdded(market, person,
true);
2947 public void findOrCreateGiver(MarketAPI market,
boolean addToCommDirectory,
boolean cleanUpOnMissionOverIfWasNewPerson) {
2949 if (factionId ==
null) factionId = market.getFactionId();
2953 boolean createdNewPerson = !ip.isLastGetPersonResultWasExistingPerson();
2955 if (person !=
null) {
2956 if (createdNewPerson) {
2973 if (createdNewPerson && !addToCommDirectory) {
2974 market.getCommDirectory().removePerson(person);
2976 person.setMarket(market);
2990 WeightedRandomPicker<PersonImportance> picker =
new WeightedRandomPicker<PersonImportance>(
genRandom);
2991 picker.add(PersonImportance.VERY_LOW, 1f);
2992 picker.add(PersonImportance.LOW, 5f);
2993 picker.add(PersonImportance.MEDIUM, 10f);
2994 picker.add(PersonImportance.HIGH, 5f);
2995 picker.add(PersonImportance.VERY_HIGH, 1f);
2996 return picker.pick();
2999 WeightedRandomPicker<PersonImportance> picker =
new WeightedRandomPicker<PersonImportance>(
genRandom);
3000 picker.add(PersonImportance.LOW, 5f);
3001 picker.add(PersonImportance.MEDIUM, 10f);
3002 picker.add(PersonImportance.HIGH, 5f);
3003 return picker.pick();
3006 WeightedRandomPicker<PersonImportance> picker =
new WeightedRandomPicker<PersonImportance>(
genRandom);
3007 picker.add(PersonImportance.MEDIUM, 10f);
3008 picker.add(PersonImportance.HIGH, 5f);
3009 picker.add(PersonImportance.VERY_HIGH, 1f);
3010 return picker.pick();
3013 WeightedRandomPicker<PersonImportance> picker =
new WeightedRandomPicker<PersonImportance>(
genRandom);
3014 picker.add(PersonImportance.VERY_LOW, 10f);
3015 picker.add(PersonImportance.LOW, 5f);
3016 picker.add(PersonImportance.MEDIUM, 1f);
3017 return picker.pick();
3020 public void createGiver(MarketAPI market,
boolean addToCommDirectory,
boolean removeOnMissionOver) {
3022 if (factionId ==
null) factionId = market.getFactionId();
3042 market.addPerson(person);
3043 ip.addPerson(person);
3044 ip.getData(person).getLocation().setMarket(market);
3046 if (addToCommDirectory) {
3047 market.getCommDirectory().addPerson(person);
3049 if (removeOnMissionOver) {
3052 PersonAdded added =
new PersonAdded(market, person,
false);
3065 if (person ==
null)
return;
3066 float rel = person.getRelToPlayer().getRel();
3070 }
else if (rel < 0) {
3074 float importance = person.getImportance().getValue();
3079 quality = Math.min(Math.max(0, rel), importance);
3080 if (rel > importance && importance < 1f) {
3081 quality += (rel - importance) / (1f - importance) * maxRelBonus;
3094 if (person ==
null)
return 0.5f;
3095 float importance = person.getImportance().getValue();
3100 if (person ==
null)
return 0f;
3102 float importance = person.getImportance().getValue();
3103 return Math.min(1f, importance + maxRelBonus);
3107 if (person ==
null)
return 0f;
3108 float importance = person.getImportance().getValue();
3110 if (min < 0) min = 0;
3128 return Math.min(1f, Math.max(0f, (
rewardMult - 1f) / (max - 1f)));
3140 Misc.addDefeatTrigger(fleet, trigger);
3141 changes.add(
new DefeatTriggerAdded(fleet, trigger, permanent));
3145 return BreadcrumbSpecial.getLocatedString(entity,
true);
3148 return BreadcrumbSpecial.getLocatedString(entity,
false);
3153 return "Get within range of a functional comm relay to complete the mission and receive " +
3158 return "Get within comms range to complete the mission";
3162 return "Go to the " + system.getNameWithLowercaseTypeShort();
3166 if (planet.getStarSystem() !=
null) {
3167 return "Go to " + planet.getName() +
" in the " + planet.getStarSystem().getNameWithLowercaseTypeShort();
3169 return "Go to " + planet.getName();
3174 String a = planet.getSpec().getAOrAn();
3175 String world = planet.getTypeNameWithWorld().toLowerCase();
3176 if (planet.getStarSystem() !=
null) {
3177 return "Go to " + planet.getName() +
", " + a +
" " + world +
" in the " + planet.getStarSystem().getNameWithLowercaseType();
3179 return "Go to " + planet.getName() +
", " + a +
" " + world +
" in hyperspace";
3184 if (market.getStarSystem() !=
null) {
3185 return "Go to " + market.getName() +
" in the " + market.getStarSystem().getNameWithLowercaseTypeShort();
3187 return "Go to " + market.getName();
3192 MarketAPI market = person.getMarket();
3193 if (market !=
null) {
3196 return "Talk to " + person.getNameString();
3205 return "Return to " + locationName +
" and talk to " +
3206 getPerson().getNameString() +
" to receive your reward";
3212 return "Return to " + locationName +
" and talk to " +
3220 CampaignTerrainPlugin plugin = terrain.getPlugin();
3221 boolean found =
false;
3222 float orbitAngle = 0f;
3223 float orbitRadius = 0f;
3224 float orbitPeriod = 0f;
3225 SectorEntityToken orbitFocus = terrain;
3226 Vector2f forceLoc =
null;
3228 if (plugin instanceof BaseTiledTerrain) {
3229 BaseTiledTerrain tiles = (BaseTiledTerrain) plugin;
3231 float maxRadius = plugin.getRenderRange();
3232 if (maxRadius < 100f) maxRadius = 100f;
3233 WeightedRandomPicker<Pair<Integer, Integer>> picker =
new WeightedRandomPicker<Pair<Integer,Integer>>(
genRandom);
3234 WeightedRandomPicker<Pair<Integer, Integer>> pickerPref =
new WeightedRandomPicker<Pair<Integer,Integer>>(
genRandom);
3236 for (
int i = 0; i < tiles.getTiles().length; i++) {
3237 for (
int j = 0; j < tiles.getTiles()[0].length; j++) {
3238 if (tiles.getTiles()[i][j] >= 0) {
3239 float [] f = tiles.getTileCenter(i, j);
3240 Vector2f loc =
new Vector2f(f[0], f[1]);
3241 float dist = Misc.getDistance(terrain.getLocation(), loc);
3242 float weight = (float) Math.pow(dist / maxRadius, 3);
3244 pickerPref.add(
new Pair<Integer, Integer>(i, j), weight);
3245 }
else if (pickerPref.isEmpty()) {
3246 picker.add(
new Pair<Integer, Integer>(i, j), weight);
3252 Pair<Integer, Integer> pick = pickerPref.pick();
3253 if (pick ==
null) pick = picker.pick();
3256 float [] f = tiles.getTileCenter(pick.one, pick.two);
3257 Vector2f loc =
new Vector2f(f[0], f[1]);
3259 if (terrain.getOrbit() ==
null || terrain.getCircularOrbitRadius() <= 0 || terrain.getOrbitFocus() ==
null) {
3262 orbitFocus = terrain.getOrbitFocus();
3263 orbitAngle = Misc.getAngleInDegrees(orbitFocus.getLocation(), loc);
3264 orbitRadius = Misc.getDistance(orbitFocus.getLocation(), loc);
3265 orbitPeriod = terrain.getCircularOrbitPeriod();
3270 }
else if (plugin instanceof BaseRingTerrain) {
3271 BaseRingTerrain ring = (BaseRingTerrain) plugin;
3272 SectorEntityToken atCenter = ring.getRingParams().relatedEntity;
3274 float centerRadius = 0f;
3275 if (atCenter !=
null) centerRadius = atCenter.getRadius();
3276 float ringMiddle = ring.getRingParams().middleRadius;
3277 float ringMin = ring.getRingParams().middleRadius - ring.getRingParams().bandWidthInEngine / 2f;
3278 float ringMax = ring.getRingParams().middleRadius + ring.getRingParams().bandWidthInEngine / 2f;
3280 float min = Math.max(centerRadius, ringMin);
3281 orbitRadius = min + (ringMax - min) * (0.1f + 0.8f *
genRandom.nextFloat());
3282 orbitAngle =
genRandom.nextFloat() * 360f;
3287 orbitRadius = 100f + 100f *
genRandom.nextFloat();
3288 orbitAngle = 360f *
genRandom.nextFloat();
3291 EntityLocation eLoc =
new EntityLocation();
3292 eLoc.type = LocationType.OUTER_SYSTEM;
3293 if (forceLoc !=
null) {
3294 eLoc.location = forceLoc;
3296 if (orbitPeriod <= 0f) {
3297 orbitPeriod = orbitRadius / (5f + 5f *
genRandom.nextFloat());
3300 orbitAngle, orbitRadius, orbitPeriod);
3307 String name = terrain.getPlugin().getTerrainName();
3308 if (name ==
null) name =
"";
3309 if (name.contains(
" L4") || name.contains(
" L5")) {
3320 return Misc.getAOrAnFor(name);
3322 return terrain.getPlugin().getNameAOrAn();
3328 return Misc.getAOrAnFor(type);
3330 return terrain.getPlugin().getNameAOrAn();
3334 return terrain.getPlugin().getNameForTooltip().toLowerCase();
3359 return lightYears * Misc.getUnitsPerLightYear();
3363 return Global.
getSector().getPlayerFleet().getCargo().getCommodityQuantity(comId) >= quantity;
3368 fleet.getFleetData().setShipNameRandom(
genRandom);
3369 fleet.getFleetData().addFleetMember(member);
3370 fleet.getFleetData().removeFleetMember(member);
3374 int d = (int) Math.round(days);
3375 String daysStr =
"days";
3417 cargoOnAccept.addSpecial(
new SpecialItemData(itemId, data), 1);
3442 int daysPerToken = MarketCMD.getDisruptDaysPerToken(market, industry);
3443 daysRequired -= (int) industry.getDisruptedDays();
3444 int tokens = (int) Math.ceil((
float) daysRequired / (float) daysPerToken);
3445 if (tokens < 1) tokens = 1;
3447 int marinesRequired = MarketCMD.getMarinesFor(market, tokens);
3449 return marinesRequired;
3452 public void addDisruptRaidInfo(MarketAPI market, Industry industry,
int daysRequired, TooltipMakerAPI info,
float pad) {
3455 RaidDangerLevel danger = industry.getSpec().getDisruptDanger();
3457 Color h = Misc.getHighlightColor();
3458 LabelAPI label = info.addPara(industry.getCurrentName() +
" must be disrupted for at least %s days. The operation " +
3459 "will require around %s marines, and the " +
3460 "danger level is %s.",
3463 Misc.getWithDGS(marinesRequired),
3464 danger.name.toLowerCase());
3465 label.setHighlightColors(h, h, danger.color);
3469 int marinesRequired = MarketCMD.getMarinesFor(market, Math.max(1, danger.marineTokens));
3471 return marinesRequired;
3475 int marinesRequired = MarketCMD.getMarinesFor(defenderStrength, Math.max(1, danger.marineTokens));
3477 return marinesRequired;
3480 public void addCustomRaidInfo(MarketAPI market, RaidDangerLevel danger, TooltipMakerAPI info,
float pad) {
3483 Color h = Misc.getHighlightColor();
3484 LabelAPI label = info.addPara(
"The operation " +
3485 "will require around %s marines, and the " +
3486 "danger level is %s.",
3488 Misc.getWithDGS(marinesRequired),
3489 danger.name.toLowerCase());
3490 label.setHighlightColors(h, danger.color);
3493 public void addCustomRaidInfo(
int defenderStrength, RaidDangerLevel danger, TooltipMakerAPI info,
float pad) {
3494 int marinesRequired = MarketCMD.getMarinesFor(defenderStrength, Math.max(1, danger.marineTokens));
3497 Color h = Misc.getHighlightColor();
3498 LabelAPI label = info.addPara(
"The operation " +
3499 "will require around %s marines, and the " +
3500 "danger level is %s.",
3502 Misc.getWithDGS(marinesRequired),
3503 danger.name.toLowerCase());
3504 label.setHighlightColors(h, danger.color);
3509 float support = Misc.getFleetwideTotalMod(playerFleet, Stats.FLEET_GROUND_SUPPORT, 0f);
3510 StatBonus stat = playerFleet.getStats().getDynamic().getMod(Stats.PLANETARY_OPERATIONS_MOD);
3515 for (
int i = 1; i < marinesRequired * 2; i *= 2) {
3516 float currSupport = (int) Math.round(Math.min(support, i));
3517 float strength = i + currSupport;
3518 strength = stat.computeEffective(strength);
3519 if (strength >= marinesRequired) {
3526 int iter = Math.max(1, (max - min) / 100);
3528 for (
int i = min; i <= max; i += iter) {
3529 float currSupport = (int) Math.min(support, i);
3530 float strength = i + currSupport;
3531 strength = stat.computeEffective(strength);
3532 if (strength >= marinesRequired) {
3533 marinesRequired = (int) Math.round(strength);
3542 if (marinesRequired > 100) base = 50;
3543 if (marinesRequired > 500) base = 100;
3544 if (marinesRequired > 1000) base = 250;
3545 if (marinesRequired > 2000) base = 500;
3546 if (marinesRequired > 5000) base = 1000;
3547 for (
int i = 0; i < 10; i++) {
3548 if (marinesRequired <= (i + 1) * base) {
3549 marinesRequired = (i + 1) * base;
3554 return marinesRequired;
3559 Color h = Misc.getHighlightColor();
3560 FactionAPI f = market.getFaction();
3562 if (Misc.isHiddenBase(market)) {
3563 String a = f.getPersonNamePrefixAOrAn();
3564 if (prefix ==
null || prefix.isEmpty()) {
3565 if (market.isInHyperspace()) {
3566 LabelAPI label = info.addPara(market.getName() +
"is " + a +
" " + f.getPersonNamePrefix() +
3567 " base located in hyperspace.",
3569 label.setHighlight(market.getName(), f.getPersonNamePrefix());
3570 label.setHighlightColors(f.getBaseUIColor(), f.getBaseUIColor());
3572 LabelAPI label = info.addPara(market.getName() +
"is " + a +
" " + f.getPersonNamePrefix() +
3573 " base in the " + market.getStarSystem().getNameWithLowercaseTypeShort() +
".",
3575 label.setHighlight(market.getName(), f.getPersonNamePrefix());
3576 label.setHighlightColors(f.getBaseUIColor(), f.getBaseUIColor());
3579 if (market.isInHyperspace()) {
3580 LabelAPI label = info.addPara(prefix +
" " + market.getName() +
", " + a +
" " + f.getPersonNamePrefix() +
3581 " base located in hyperspace.",
3583 label.setHighlight(market.getName(), f.getDisplayNameWithArticleWithoutArticle());
3584 label.setHighlightColors(f.getBaseUIColor(), f.getBaseUIColor());
3586 LabelAPI label = info.addPara(prefix +
" " + market.getName() +
", " + a +
" " + f.getPersonNamePrefix() +
3587 " base in the " + market.getStarSystem().getNameWithLowercaseTypeShort() +
".",
3589 label.setHighlight(market.getName(), f.getPersonNamePrefix());
3590 label.setHighlightColors(f.getBaseUIColor(), f.getBaseUIColor());
3598 if (prefix ==
null || prefix.isEmpty()) {
3599 if (market.isInHyperspace()) {
3600 LabelAPI label = info.addPara(market.getName() +
"is a size %s " +
3601 "colony in hyperspace controlled by " + f.getDisplayNameWithArticle() +
".",
3602 pad, f.getBaseUIColor(),
3603 "" + market.getSize(), f.getDisplayNameWithArticleWithoutArticle());
3604 label.setHighlight(market.getName(),
"" + market.getSize(), f.getDisplayNameWithArticleWithoutArticle());
3605 label.setHighlightColors(f.getBaseUIColor(), h, f.getBaseUIColor());
3607 LabelAPI label = info.addPara(market.getName() +
"is a size %s " +
3608 "colony in the " + market.getStarSystem().getNameWithLowercaseTypeShort() +
" controlled by " + f.getDisplayNameWithArticle() +
".",
3609 pad, f.getBaseUIColor(),
3610 "" + market.getSize(), f.getDisplayNameWithArticleWithoutArticle());
3611 label.setHighlight(market.getName(),
"" + market.getSize(), f.getDisplayNameWithArticleWithoutArticle());
3612 label.setHighlightColors(f.getBaseUIColor(), h, f.getBaseUIColor());
3615 if (market.isInHyperspace()) {
3616 LabelAPI label = info.addPara(prefix +
" " + market.getName() +
", a size %s " +
3617 "colony in hyperspace controlled by " + f.getDisplayNameWithArticle() +
".",
3618 pad, f.getBaseUIColor(),
3619 "" + market.getSize(), f.getDisplayNameWithArticleWithoutArticle());
3620 label.setHighlight(market.getName(),
"" + market.getSize(), f.getDisplayNameWithArticleWithoutArticle());
3621 label.setHighlightColors(f.getBaseUIColor(), h, f.getBaseUIColor());
3623 LabelAPI label = info.addPara(prefix +
" " + market.getName() +
", a size %s " +
3624 "colony in the " + market.getStarSystem().getNameWithLowercaseTypeShort() +
" controlled by " + f.getDisplayNameWithArticle() +
".",
3625 pad, f.getBaseUIColor(),
3626 "" + market.getSize(), f.getDisplayNameWithArticleWithoutArticle());
3627 label.setHighlight(market.getName(),
"" + market.getSize(), f.getDisplayNameWithArticleWithoutArticle());
3628 label.setHighlightColors(f.getBaseUIColor(), h, f.getBaseUIColor());
3636 int fuel = MarketCMD.getBombardmentCost(market,
Global.
getSector().getPlayerFleet());
3644 Color h = Misc.getHighlightColor();
3645 info.addPara(
"Effectively bombarding the target will require approximately %s units of fuel.",
3647 Misc.getWithDGS(fuel));
3652 cargo.addSpecial(data, 1);
3653 BaseSalvageSpecial.addExtraSalvage(entity, cargo);
3658 return Global.
getSector().getImportantPeople().getData(
id).getPerson();
3665 withMemory.getMemoryWithoutUpdate().set(key, value);
3671 addTag(Tags.INTEL_STORY);
3681 PlaythroughLog log = PlaythroughLog.getInstance();
3682 long crew = log.getPrevValue(
"crew");
3683 long credits = log.getPrevValue(
"credits");
3684 return crew > marines * 2 || credits > marines * 400;
3693 for (String postId : postIds) {
3694 for (PersonAPI person : market.getPeopleCopy()) {
3695 if (postId.equals(person.getPostId())) {
3709 this.mapMarkerNameColor = mapMarkerColor;
3713 if (system.getCenter() instanceof PlanetAPI) {
3714 Color color = Misc.setAlpha(((PlanetAPI)system.getCenter()).getSpec().getIconColor(), 255);
3715 color = Misc.setBrightness(color, 235);
static SettingsAPI getSettings()
static FactoryAPI getFactory()
static SectorAPI getSector()
static void addAdjustmentMessage(float delta, FactionAPI faction, PersonAPI person, TextPanelAPI panel, TooltipMakerAPI info, Color tc, boolean withCurrent, float pad)
static float getDefaultSModProb()
static DerelictShipData createRandom(String factionId, DerelictType type, Random random)
static DerelictShipData createHull(String hullId, Random random, float sModProb)
static boolean SAME_CONTACT_DEBUG
String getGoTalkToPersonText(PersonAPI person)
void connectWithGlobalFlag(Object from, Object to, String flag)
void addOnAcceptWeaponDrop(final String weaponId, final int quantity)
void makePrimaryObjective(Object personOrMarketOrEntity)
void setGiverVoice(String giverVoice)
void setRepFactionChangesVeryHigh()
String getLocated(SectorEntityToken entity)
void setRepPenaltyPerson(Float repPenaltyPerson)
String getToCompleteText()
transient boolean aborted
float getRewardMultFraction()
void showPersonInfo(PersonAPI person, InteractionDialogAPI dialog, boolean withFaction, boolean withRelBar)
String getLocatedUnclear(SectorEntityToken entity)
void addSuccessStages(Object ... ids)
void setGiverPortrait(String giverPortrait)
void setTimeLimit(Object failStage, float days, StarSystemAPI noLimitWhileInSystem, Object ... noLimitAfterStages)
void setHub(MissionHub hub)
boolean setGlobalReference(String key)
PersonImportance pickLowImportance()
void removeMemoryFlagChanges(MemoryAPI memory, String flag)
List< PotentialContactData > potentialContactsOnMissionSuccess
void makeImportantDoNotShowAsIntelMapLocation(MarketAPI market, String flag, Enum ... stages)
SectorEntityToken getMapLocationFor(SectorEntityToken entity)
boolean callEvent(String ruleId, InteractionDialogAPI dialog, List< Token > params, Map< String, MemoryAPI > memoryMap)
String getGoToPlanetTextPre(PlanetAPI planet)
void connectWithMemoryFlag(Object from, Object to, HasMemory withMemory, String flag)
void setRepPersonChangesMedium()
String getGoToPlanetTextShort(PlanetAPI planet)
void setStageOnMemoryFlag(Object to, MemoryAPI memory, String flag)
boolean rollProbability(float p)
void connectWithEntityNotAlive(Object from, Object to, SectorEntityToken entity)
void setStageOnHostilitiesStarted(Object to, PersonAPI person, MarketAPI market)
void setCurrentStage(Object next, InteractionDialogAPI dialog, Map< String, MemoryAPI > memoryMap)
void setPersonIsPotentialContactOnSuccess(PersonAPI person)
Object getStartingStage()
void updateInteractionDataImpl()
void setStageOnCustomCondition(Object to, ConditionChecker custom)
static boolean playerHasEnough(String comId, int quantity)
String getPostfixForState()
void adjustRep(TextPanelAPI textPanel, HubMissionResult result, RepActions action)
void makeUnimportant(MemoryAPI memory, Object personOrEntityOrMarket)
void makeImportant(MarketAPI market, String flag, Enum ... stages)
void makeUnimportant(MarketAPI market)
String getImportantIcon()
void setMissionId(String missionId)
void setCreditRewardWithBonus(CreditReward reward, int bonus)
void makeDiscoverable(SectorEntityToken entity, float range, float xp)
int getMarinesRequiredForCustomObjective(MarketAPI market, RaidDangerLevel danger)
void addOnSuccessWeaponDrop(final String weaponId, final int quantity)
void setStageOnHostilitiesEnded(Object to, PersonAPI person, MarketAPI market)
List< MissionTrigger > getTriggers()
void setRepRewardFaction(Float repRewardFaction)
static float getUnits(float lightYears)
int genRoundNumber(int min, int max)
transient String giverFactionId
boolean setPersonMissionRef(PersonAPI person, String key)
void addCustomRaidInfo(MarketAPI market, RaidDangerLevel danger, TooltipMakerAPI info, float pad)
float getNoPenaltyAbandonDays()
void createIntelInfo(TooltipMakerAPI info, ListInfoMode mode)
void makeUnimportant(SectorEntityToken entity, Enum ... stages)
SectorEntityToken spawnDerelictHull(String hullId, LocData data)
boolean addNextStepText(TooltipMakerAPI info, Color tc, float pad)
static float DEBRIS_LARGE
int getDistanceLY(SectorEntityToken entity)
transient String giverPortrait
SectorEntityToken spawnDebrisField(float radius, float density, LocData data)
void setStageOnEntityNotAlive(Object to, SectorEntityToken entity)
void setStageTransitionsRepeatable()
List< StageConnection > connections
PersonImportance pickImportance()
void addOnSuccessFighterLPCDrop(final String wingId, final int quantity)
void setRepPersonChangesTiny()
void addCustomRaidInfo(int defenderStrength, RaidDangerLevel danger, TooltipMakerAPI info, float pad)
int getRewardBonusForMarines(int marines)
PersonAPI findOrCreatePerson(String factionId, MarketAPI market, boolean cleanUpOnMissionOverIfWasNewPerson, String defaultRank, String ... posts)
void addOnSuccessHullmodDrop(final String hullmodId)
void makeUnimportant(SectorEntityToken entity)
void addOnAcceptHullmodDrop(final String hullmodId)
void makeImportant(MemoryAPI memory, String flag, MapLocationType type, Object personOrEntityOrMarket, Enum ... stages)
void setIconName(String iconName)
String getGetWithinCommsRangeTextShort()
void makeImportantDoNotShowAsIntelMapLocation(SectorEntityToken entity, String flag, Enum ... stages)
List< MissionTrigger > triggers
RepLevel getRewardLimitFaction()
void setGiverPost(String giverPost)
static boolean playerLevelIsAtLeast(int level)
void createSmallDescription(TooltipMakerAPI info, float width, float height)
void buttonPressConfirmed(Object buttonId, IntelUIAPI ui)
void createGiver(MarketAPI market, boolean addToCommDirectory, boolean removeOnMissionOver)
SectorEntityToken spawnDerelict(String factionId, DerelictType type, LocData data)
void setRepFactionChangesHigh()
static String REMOVE_ON_MISSION_OVER
void connectWithCustomCondition(Object from, Object to, ConditionChecker custom)
void setFlag(PersonAPI person, String flag, boolean permanent)
static String getTerrainName(CampaignTerrainAPI terrain)
MarketAPI getMarket(String id)
SectorEntityToken spawnDerelictOfType(DerelictType type, LocData data)
static float DEBRIS_SMALL
static float DEBRIS_MEDIUM
void makeImportant(SectorEntityToken entity, String flag, Enum ... stages)
HubMissionCreator getCreator()
EntityLocation generateLocationInsideTerrain(CampaignTerrainAPI terrain)
void setRepRewardPerson(Float repRewardPerson)
SectorEntityToken spawnMissionNode(LocData data)
String getReturnText(String locationName)
String getMissionTypeNoun()
String getMissionCompletionVerb()
transient PersonImportance giverImportance
static float DEBRIS_AVERAGE
List< Abortable > changes
void setRepPenaltyFaction(Float repPenaltyFaction)
RepLevel rewardLimitPerson
int getDistanceLY(MarketAPI market)
boolean setGlobalReference(String refKey, String inProgressFlag)
static float DEBRIS_DENSE
List< Object > failStages
String pickOne(String ... options)
PersonAPI findOrCreateTrader(String factionId, MarketAPI market, boolean cleanUpOnMissionOverIfWasNewPerson)
SectorEntityToken spawnEntity(String entityId, LocData data)
void addOnAcceptSpecialItemDrop(final String itemId, final String data)
static int getRoundNumber(float num)
static boolean isDevMode()
void makeImportant(PersonAPI person, String flag, Enum ... stages)
void makeUnimportant(MemoryAPI memory, Object personOrEntityOrMarket, Enum ... stages)
void createAndAbortIfFailed(MarketAPI market, boolean barEvent)
Boolean doNotAutoAddPotentialContactsOnSuccess
Set< String > getIntelTags(SectorMapAPI map)
void setSuccessStage(Object id)
void setGiverRank(String giverRank)
void setRepPersonChangesVeryHigh()
void setFlag(MemoryAPI memory, String flag, Object value, boolean permanent, Object ... stages)
PersonAPI getPersonOverride()
void makeUnimportant(PersonAPI person)
void setFlagWithReason(SectorEntityToken entity, String flag, boolean permanent)
void setStageOnMemoryFlag(Object to, HasMemory withMemory, String flag)
void makeImportantDoNotShowAsIntelMapLocation(PersonAPI person, String flag, Enum ... stages)
void setCreditRewardApplyRelMult(Integer creditReward)
void sendUpdateForNextStep(String listInfoParam, TextPanelAPI textPanel)
static String getTerrainNameAOrAn(CampaignTerrainAPI terrain)
float getRepRewardSuccessFaction()
void setAbandonStage(Object abandonStage)
void setGiverImportance(PersonImportance giverImportance)
PersonAPI findOrCreateCriminal(MarketAPI market, boolean cleanUpOnMissionOverIfWasNewPerson)
void connectWithHostilitiesEnded(Object from, Object to, PersonAPI person, MarketAPI market)
void connectWithMemoryFlag(Object from, Object to, MemoryAPI memory, String flag)
PersonImportance pickMediumImportance()
void setGiverIsPotentialContactOnSuccess(float probability)
void setCreditReward(int min, int max, boolean withMult)
String getReturnTextShort(String locationName)
SectorEntityToken spawnDerelict(DerelictShipData shipData, LocData data)
void setFailureStage(Object id)
PersonDataAPI getImportantPersonData(String id)
void setGiverTags(String ... giverTags)
void addBulletPointsPost(TooltipMakerAPI info, Color tc, float initPad, ListInfoMode mode)
PersonAPI getImportantPerson(String id)
void setStageOnEnteredLocation(Object to, LocationAPI location)
Boolean stageTransitionsRepeatable
void setPersonIsPotentialContactOnSuccess(PersonAPI person, float probability)
static String getTerrainType(CampaignTerrainAPI terrain)
void setRepFactionChangesTiny()
void endFailureImpl(InteractionDialogAPI dialog, Map< String, MemoryAPI > memoryMap)
void checkStageChangesAndTriggers(InteractionDialogAPI dialog, Map< String, MemoryAPI > memoryMap)
void addAbandonButton(TooltipMakerAPI info, float width)
static String NEXT_STEP_UPDATE
void setFlag(SectorEntityToken entity, String flag, boolean permanent, Object ... stages)
RepLevel rewardLimitFaction
transient MemoryAPI interactionMemory
void setRepPersonChangesLow()
transient String[] giverTags
void connectWithInRangeOfCommRelay(Object from, Object to)
void connectWithWithinHyperspaceRange(Object from, Object to, SectorEntityToken entity, float rangeLY, boolean requirePlayerInHyperspace)
SectorEntityToken spawnEntityToken(LocData data)
void addResultBulletsAssumingAlreadyIndented(TooltipMakerAPI info, ListInfoMode mode)
boolean isMissionCreationAborted()
EntityLocation generateLocation(String entityId, EntityLocationType locType, SectorEntityToken param, LocationAPI system)
void setRepFactionChangesLow()
SectorEntityToken getMapLocation(SectorMapAPI map)
static boolean hasSpecialName(CampaignTerrainAPI terrain)
void setPenaltyLimitFaction(RepLevel penaltyLimitFaction)
String getReturnText(MarketAPI market)
void connectWithHostilitiesStarted(Object from, Object to, PersonAPI person, MarketAPI market)
PersonAPI getPersonAtMarketPost(MarketAPI market, String ... postIds)
void addBulletPoints(TooltipMakerAPI info, ListInfoMode mode)
transient String giverRank
boolean setFactionMissionRef(FactionAPI faction, String key)
void setRepChanges(float repRewardPerson, float repPenaltyPerson, float repRewardFaction, float repPenaltyFaction)
void setStageOnGlobalFlag(Object to, String flag)
void findOrCreateGiver(MarketAPI market, boolean addToCommDirectory, boolean cleanUpOnMissionOverIfWasNewPerson)
abstract boolean create(MarketAPI createdAt, boolean barEvent)
void setCreditReward(CreditReward reward, int marketSize)
void makePersonRequired(PersonAPI person)
int getMarinesRequiredToDisrupt(MarketAPI market, Industry industry, int daysRequired)
String getReturnTextShort(MarketAPI market)
void setRepPersonChangesHigh()
void removeImportanceChanges(MemoryAPI memory)
void makeMissionNodeDiscoverable(SectorEntityToken node)
transient String giverPost
void addBulletPointsPre(TooltipMakerAPI info, Color tc, float initPad, ListInfoMode mode)
String getSmallDescriptionTitle()
void advanceImpl(float amount)
static int EXTRA_REWARD_PER_MARINE
boolean doesButtonHaveConfirmDialog(Object buttonId)
transient boolean doNotEndMission
MemoryAPI getGlobalMemory()
float getRepRewardSuccessPerson()
void setCreditReward(Integer creditReward)
SectorEntityToken getMapLocation(SectorMapAPI map, Object currentStage)
void connectWithEnteredLocation(Object from, Object to, LocationAPI location)
void setPersonTokens(MemoryAPI mem)
void setPersonOverride(PersonAPI personOverride)
String getGoToSystemTextShort(StarSystemAPI system)
void addDescriptionForCurrentStage(TooltipMakerAPI info, float width, float height)
List< Abortable > getChanges()
List< CampaignFleetAPI > runStageTriggersReturnFleets(Object stage)
Object pickOneObject(List options)
void genMissionRewardMultAndQuality()
PersonImportance pickHighImportance()
RepLevel getPenaltyLimitFaction()
void addSpecialItemDropOnlyUseInAcceptImplNotUndoneOnAbort(SectorEntityToken entity, SpecialItemData data)
void endSuccess(InteractionDialogAPI dialog, Map< String, MemoryAPI > memoryMap)
boolean shouldSendUpdateForStage(Object id)
void addFailureStages(Object ... ids)
void setStageOnInRangeOfCommRelay(Object to)
void setGiverFaction(String factionId)
void setGlobalFlag(String flag, Object value, Object ... stages)
static int getAdjustedMarinesRequired(int marinesRequired)
int getMarinesRequiredForCustomDefenderStrength(int defenderStrength, RaidDangerLevel danger)
LinkedHashMap< Object, StageData > stages
void addOnAcceptFighterLPCDrop(final String wingId, final int quantity)
static String getTerrainTypeAOrAn(CampaignTerrainAPI terrain)
void setStageOnDaysElapsed(Object to, float days)
RepLevel penaltyLimitFaction
String pickOne(List< String > options)
static void addStandardMarketDesc(String prefix, MarketAPI market, TooltipMakerAPI info, float pad)
String getTriggerPrefix()
boolean canAbandonWithoutPenalty()
void setUseLargeFontInMissionList()
void setMapMarkerNameColor(Color mapMarkerColor)
float getElapsedInCurrentStage()
void setRepFactionChangesMedium()
List< Object > successStages
static int getMaxPlayerLevel()
void updateInteractionData(InteractionDialogAPI dialog, Map< String, MemoryAPI > memoryMap)
void createConfirmationPrompt(Object buttonId, TooltipMakerAPI prompt)
void setStageOnWithinHyperspaceRange(Object to, SectorEntityToken entity, float rangeLY)
int getFuel(SectorEntityToken entity, boolean bothWays)
StageData getData(Object id)
static float GLOBAL_MISSION_REWARD_MULT
int getDistanceLY(StarSystemAPI system)
transient CargoAPI cargoOnAccept
String getWithoutArticle(String item)
String getStageDescriptionText()
void accept(InteractionDialogAPI dialog, Map< String, MemoryAPI > memoryMap)
boolean setMarketMissionRef(MarketAPI market, String key)
boolean setEntityMissionRef(SectorEntityToken entity, String key)
transient Object startingStage
void addDisruptRaidInfo(MarketAPI market, Industry industry, int daysRequired, TooltipMakerAPI info, float pad)
void setPersonDoGenericPortAuthorityCheck(PersonAPI person)
void setMapMarkerNameColorBasedOnStar(StarSystemAPI system)
void setStartingStage(Object startingStage)
void addOnSuccessCommodity(String commodityId, int quantity)
void setQuality(float quality)
void addBombardmentInfo(MarketAPI market, TooltipMakerAPI info, float pad)
void setGenRandom(Random random)
void addAbandonButton(TooltipMakerAPI info, float width, String abandon)
void addFleetDefeatTrigger(CampaignFleetAPI fleet, String trigger, boolean permanent)
void connectWithInRangeOfEntity(Object from, Object to, SectorEntityToken entity, float range)
FactionAPI getFactionForUIColors()
void setGiverIsPotentialContactOnSuccess()
void setStageInRangeOfEntity(Object to, SectorEntityToken entity, float range)
void makeUnimportant(PersonAPI person, Enum ... stages)
void addPotentialContacts(InteractionDialogAPI dialog)
void setRepFactionChangesVeryLow()
HubMissionCreator creator
void setNoPenaltyFailureStage(Object id)
void setFlag(MemoryAPI memory, String flag, Object value, boolean permanent)
float getRepPenaltyFailureFaction()
void setPenaltyLimitPerson(RepLevel penaltyLimitPerson)
void assignShipName(FleetMemberAPI member, String factionId)
int getBombardmentFuel(MarketAPI market)
RepLevel getPenaltyLimitPerson()
List< Object > noPenaltyFailStages
void setFlag(PersonAPI person, String flag, boolean permanent, Object ... stages)
void addOnAcceptCommodity(String commodityId, int quantity)
RepLevel getRewardLimitPerson()
static float DEBRIS_SPARSE
void setRepFactionChangesNone()
void sendUpdateToTextPanel(String listInfoParam, TextPanelAPI textPanel)
void setRewardMult(float rewardMult)
void addOnSuccessSpecialItemDrop(final String itemId, final String data)
boolean isOkToOfferMissionRequiringMarines(int marines)
void setStageOnMarketDecivilized(Object to, MarketAPI market)
transient String giverVoice
void endFailure(InteractionDialogAPI dialog, Map< String, MemoryAPI > memoryMap)
void endSuccessImpl(InteractionDialogAPI dialog, Map< String, MemoryAPI > memoryMap)
static String BUTTON_ABANDON
void setName(String name)
void connectWithWithinHyperspaceRange(Object from, Object to, SectorEntityToken entity, float rangeLY)
void acceptImpl(InteractionDialogAPI dialog, Map< String, MemoryAPI > memoryMap)
String getDayOrDays(float days)
void connectWithMarketDecivilized(Object from, Object to, MarketAPI market)
void setCreator(HubMissionCreator creator)
void setCreditReward(CreditReward reward)
void addDescriptionForNonEndStage(TooltipMakerAPI info, float width, float height)
void addNoPenaltyFailureStages(Object ... ids)
void setCreditReward(int min, int max)
void makeUnimportant(MarketAPI market, Enum ... stages)
static boolean playerLevelIsMaxed()
boolean callAction(String action, String ruleId, InteractionDialogAPI dialog, List< Token > params, Map< String, MemoryAPI > memoryMap)
void setDoNotAutoAddPotentialContactsOnSuccess()
float getRepPenaltyFailurePerson()
IntelSortTier getSortTier()
RepLevel penaltyLimitPerson
void setRepPersonChangesVeryLow()
void spawnShipGraveyard(String factionId, int minShips, int maxShips, LocData data)
static String END_MISSION_UPDATE
String getGoToMarketText(MarketAPI market)
void setMemoryValuePermanent(HasMemory withMemory, String key, Object value)
void connectWithDaysElapsed(Object from, Object to, float days)
String getGetWithinCommsRangeText()
void setRepPersonChangesNone()
PersonAPI findOrCreateCriminalTrader(MarketAPI market, boolean cleanUpOnMissionOverIfWasNewPerson)
void setFlag(SectorEntityToken entity, String flag, boolean permanent)
void setIconName(String category, String id)
transient Gender giverGender
HubMissionResult getResult()
void ensurePersonIsInCommDirectory(MarketAPI market, PersonAPI person)
void setXPReward(int xpReward)
static String MISSION_QUALITY_BONUS
ConditionChecker getCondition()
List< TriggerAction > getActions()
LinkedHashSet< Object > getStages()
CargoAPI createCargo(boolean unlimitedStacks)
CampaignFleetAPI createEmptyFleet(String factionId, String name, boolean aiMode)
OrbitAPI createCircularOrbitWithSpin(SectorEntityToken focus, float angle, float orbitRadius, float orbitDays, float spin)
OrbitAPI createCircularOrbit(SectorEntityToken focus, float angle, float orbitRadius, float orbitDays)
String getSpriteName(String category, String id)
CustomEntitySpecAPI getCustomEntitySpec(String id)
float getFloat(String key)
LevelupPlugin getLevelupPlugin()