1package com.fs.starfarer.api.impl.campaign.missions.hub;
3import java.util.ArrayList;
4import java.util.Arrays;
5import java.util.HashSet;
6import java.util.Iterator;
7import java.util.LinkedHashMap;
8import java.util.LinkedHashSet;
11import java.util.Random;
16import org.lwjgl.input.Keyboard;
17import org.lwjgl.util.vector.Vector2f;
19import com.fs.starfarer.api.Global;
20import com.fs.starfarer.api.campaign.CampaignFleetAPI;
21import com.fs.starfarer.api.campaign.CampaignTerrainAPI;
22import com.fs.starfarer.api.campaign.CampaignTerrainPlugin;
23import com.fs.starfarer.api.campaign.CargoAPI;
24import com.fs.starfarer.api.campaign.CargoStackAPI;
25import com.fs.starfarer.api.campaign.CustomEntitySpecAPI;
26import com.fs.starfarer.api.campaign.FactionAPI;
27import com.fs.starfarer.api.campaign.InteractionDialogAPI;
28import com.fs.starfarer.api.campaign.LocationAPI;
29import com.fs.starfarer.api.campaign.PersonImportance;
30import com.fs.starfarer.api.campaign.PlanetAPI;
31import com.fs.starfarer.api.campaign.RepLevel;
32import com.fs.starfarer.api.campaign.ReputationActionResponsePlugin.ReputationAdjustmentResult;
33import com.fs.starfarer.api.campaign.SectorEntityToken;
34import com.fs.starfarer.api.campaign.SpecialItemData;
35import com.fs.starfarer.api.campaign.StarSystemAPI;
36import com.fs.starfarer.api.campaign.TextPanelAPI;
37import com.fs.starfarer.api.campaign.econ.Industry;
38import com.fs.starfarer.api.campaign.econ.MarketAPI;
39import com.fs.starfarer.api.campaign.rules.HasMemory;
40import com.fs.starfarer.api.campaign.rules.MemKeys;
41import com.fs.starfarer.api.campaign.rules.MemoryAPI;
42import com.fs.starfarer.api.characters.FullName.Gender;
43import com.fs.starfarer.api.characters.ImportantPeopleAPI;
44import com.fs.starfarer.api.characters.ImportantPeopleAPI.PersonDataAPI;
45import com.fs.starfarer.api.characters.PersonAPI;
46import com.fs.starfarer.api.combat.StatBonus;
47import com.fs.starfarer.api.fleet.FleetMemberAPI;
48import com.fs.starfarer.api.impl.MusicPlayerPluginImpl;
49import com.fs.starfarer.api.impl.campaign.CoreReputationPlugin;
50import com.fs.starfarer.api.impl.campaign.CoreReputationPlugin.MissionCompletionRep;
51import com.fs.starfarer.api.impl.campaign.CoreReputationPlugin.RepActionEnvelope;
52import com.fs.starfarer.api.impl.campaign.CoreReputationPlugin.RepActions;
53import com.fs.starfarer.api.impl.campaign.CoreReputationPlugin.RepRewards;
54import com.fs.starfarer.api.impl.campaign.DerelictShipEntityPlugin;
55import com.fs.starfarer.api.impl.campaign.DerelictShipEntityPlugin.DerelictShipData;
56import com.fs.starfarer.api.impl.campaign.DerelictShipEntityPlugin.DerelictType;
57import com.fs.starfarer.api.impl.campaign.ids.Entities;
58import com.fs.starfarer.api.impl.campaign.ids.Factions;
59import com.fs.starfarer.api.impl.campaign.ids.Ranks;
60import com.fs.starfarer.api.impl.campaign.ids.Stats;
61import com.fs.starfarer.api.impl.campaign.ids.Tags;
62import com.fs.starfarer.api.impl.campaign.intel.BaseIntelPlugin;
63import com.fs.starfarer.api.impl.campaign.intel.contacts.ContactIntel;
64import com.fs.starfarer.api.impl.campaign.missions.CheapCommodityMission;
65import com.fs.starfarer.api.impl.campaign.missions.hub.MissionTrigger.TriggerAction;
66import com.fs.starfarer.api.impl.campaign.missions.hub.MissionTrigger.TriggerActionContext;
67import com.fs.starfarer.api.impl.campaign.plog.PlaythroughLog;
68import com.fs.starfarer.api.impl.campaign.procgen.Constellation;
69import com.fs.starfarer.api.impl.campaign.procgen.themes.BaseThemeGenerator;
70import com.fs.starfarer.api.impl.campaign.procgen.themes.BaseThemeGenerator.AddedEntity;
71import com.fs.starfarer.api.impl.campaign.procgen.themes.BaseThemeGenerator.EntityLocation;
72import com.fs.starfarer.api.impl.campaign.procgen.themes.BaseThemeGenerator.LocationType;
73import com.fs.starfarer.api.impl.campaign.procgen.themes.SalvageSpecialAssigner;
74import com.fs.starfarer.api.impl.campaign.rulecmd.AddRemoveCommodity;
75import com.fs.starfarer.api.impl.campaign.rulecmd.salvage.MarketCMD;
76import com.fs.starfarer.api.impl.campaign.rulecmd.salvage.MarketCMD.RaidDangerLevel;
77import com.fs.starfarer.api.impl.campaign.rulecmd.salvage.special.BaseSalvageSpecial;
78import com.fs.starfarer.api.impl.campaign.rulecmd.salvage.special.BreadcrumbSpecial;
79import com.fs.starfarer.api.impl.campaign.terrain.BaseRingTerrain;
80import com.fs.starfarer.api.impl.campaign.terrain.BaseTiledTerrain;
81import com.fs.starfarer.api.impl.campaign.terrain.DebrisFieldTerrainPlugin.DebrisFieldParams;
82import com.fs.starfarer.api.impl.campaign.terrain.DebrisFieldTerrainPlugin.DebrisFieldSource;
83import com.fs.starfarer.api.ui.ButtonAPI;
84import com.fs.starfarer.api.ui.IntelUIAPI;
85import com.fs.starfarer.api.ui.LabelAPI;
86import com.fs.starfarer.api.ui.SectorMapAPI;
87import com.fs.starfarer.api.ui.TooltipMakerAPI;
88import com.fs.starfarer.api.util.IntervalUtil;
89import com.fs.starfarer.api.util.Misc;
90import com.fs.starfarer.api.util.Misc.Token;
91import com.fs.starfarer.api.util.Pair;
92import com.fs.starfarer.api.util.WeightedRandomPicker;
108 public static enum CreditReward {
109 VERY_LOW(20000, 25000, 2000),
110 LOW(30000, 40000, 5000),
111 AVERAGE(50000, 60000, 10000),
112 HIGH(70000, 80000, 15000),
113 VERY_HIGH(90000, 100000, 20000),
122 public int perMarketSize;
123 private CreditReward(
int min,
int max,
int perMarketSize) {
153 public static enum Abandon {
157 public static enum EntityLocationType {
159 HIDDEN_NOT_NEAR_STAR,
161 ORBITING_PLANET_OR_STAR,
167 public static class LocData {
169 public EntityLocation loc;
170 public EntityLocationType type;
173 public boolean removeOnMissionOver;
178 public LocData(EntityLocation loc,
LocationAPI system,
boolean removeOnMissionOver) {
180 this.removeOnMissionOver = removeOnMissionOver;
181 this.system = system;
188 boolean removeOnMissionOver) {
190 this.centerOn = centerOn;
191 this.system = system;
192 this.removeOnMissionOver = removeOnMissionOver;
199 if (centerOn instanceof CampaignTerrainAPI) {
200 this.centerOn = centerOn;
202 loc =
new EntityLocation();
203 loc.type = LocationType.OUTER_SYSTEM;
207 this.removeOnMissionOver = removeOnMissionOver;
213 public LocData(Vector2f loc, LocationAPI system,
boolean removeOnMissionOver) {
214 this.loc =
new EntityLocation();
215 this.loc.type = LocationType.OUTER_SYSTEM;
216 this.loc.location = loc;
217 this.system = system;
218 this.removeOnMissionOver = removeOnMissionOver;
224 public LocData(EntityLocation loc, LocationAPI system) {
225 this(loc, system,
true);
231 public LocData(EntityLocationType type, SectorEntityToken centerOn, LocationAPI system) {
232 this(type, centerOn, system,
true);
238 public LocData(SectorEntityToken centerOn) {
239 this(centerOn,
true);
245 public LocData(Vector2f loc, LocationAPI system) {
246 this(loc, system,
true);
249 public boolean updateLocIfNeeded(
BaseHubMission mission, String entityId) {
250 if (centerOn instanceof CampaignTerrainAPI) {
251 CampaignTerrainAPI terrain = (CampaignTerrainAPI) centerOn;
252 loc = mission.generateLocationInsideTerrain(terrain);
253 if (loc ==
null)
return false;
254 }
else if (type !=
null) {
255 loc = mission.generateLocation(entityId, type, centerOn, system);
256 if (loc ==
null)
return false;
261 public void placeEntity(SectorEntityToken entity) {
264 if (loc.orbit !=
null) {
265 entity.setOrbit(loc.orbit);
266 loc.orbit.setEntity(entity);
268 entity.setOrbit(
null);
269 entity.getLocation().set(loc.location);
272 if (removeOnMissionOver) {
281 public static class HubMissionResult {
282 public boolean success;
285 public ReputationAdjustmentResult repPerson;
286 public ReputationAdjustmentResult repFaction;
287 public Object custom;
290 public static enum MapLocationType {
294 public static class ImportanceData {
295 public MemoryAPI memory;
297 public MapLocationType locType =
null;
298 public SectorEntityToken entity;
299 public MarketAPI market;
300 public PersonAPI person;
302 public ImportanceData() {
306 public static class FlagData {
307 public MemoryAPI memory;
310 public LinkedHashSet<Object> stages =
new LinkedHashSet<Object>();
313 public static class StageData {
315 public float elapsed = 0f;
317 public List<ImportanceData> important =
new ArrayList<ImportanceData>();
320 public static interface ConditionChecker {
321 boolean conditionsMet();
324 public static class GlobalBooleanChecker
implements ConditionChecker {
326 public GlobalBooleanChecker(String flag) {
329 public boolean conditionsMet() {
330 return Global.getSector().getMemoryWithoutUpdate().getBoolean(flag);
334 public static class MemoryBooleanChecker
implements ConditionChecker {
336 public MemoryAPI memory;
337 public MemoryBooleanChecker(MemoryAPI memory, String flag) {
338 this.memory = memory;
341 public boolean conditionsMet() {
342 return memory.getBoolean(flag);
346 public static class EntityNotAliveChecker
implements ConditionChecker {
347 public SectorEntityToken entity;
348 public EntityNotAliveChecker(SectorEntityToken entity) {
349 this.entity = entity;
351 public boolean conditionsMet() {
352 return !entity.isAlive();
356 public static class MarketDecivChecker
implements ConditionChecker {
357 public MarketAPI market;
358 public MarketDecivChecker(MarketAPI market) {
359 this.market = market;
361 public boolean conditionsMet() {
362 return market.isPlanetConditionMarketOnly() ||
363 (market.getPrimaryEntity() !=
null && !market.getPrimaryEntity().isAlive());
367 public static class HostilitiesEndedChecker
implements ConditionChecker {
368 public PersonAPI person;
369 public MarketAPI market;
370 public HostilitiesEndedChecker(PersonAPI person, MarketAPI market) {
371 this.person = person;
372 this.market = market;
374 public boolean conditionsMet() {
375 return !person.getFaction().isHostileTo(market.getFaction());
379 public static class HostilitiesStartedChecker
implements ConditionChecker {
380 public PersonAPI person;
381 public MarketAPI market;
382 public HostilitiesStartedChecker(PersonAPI person, MarketAPI market) {
383 this.person = person;
384 this.market = market;
386 public boolean conditionsMet() {
387 return person.getFaction().isHostileTo(market.getFaction());
391 public static class DaysElapsedChecker
implements ConditionChecker {
393 public StageData stage;
395 public DaysElapsedChecker(
float days, StageData stage) {
402 this.mission = mission;
405 public boolean conditionsMet() {
406 if (mission !=
null) {
407 return mission.elapsed >= days;
409 return stage.elapsed >= days;
413 public static class InCommRelayRangeChecker
implements ConditionChecker {
414 public boolean conditionsMet() {
415 return Global.getSector().getIntelManager().isPlayerInRangeOfCommRelay();
419 public static class InRangeOfEntityChecker
implements ConditionChecker {
420 public SectorEntityToken entity;
422 public InRangeOfEntityChecker(SectorEntityToken entity,
float range) {
423 this.entity = entity;
426 public boolean conditionsMet() {
427 return Global.getSector().getCurrentLocation() == entity.getContainingLocation() &&
428 Misc.getDistance(Global.getSector().getPlayerFleet(), entity) < range;
432 public static class InHyperRangeOfEntityChecker
implements ConditionChecker {
433 public SectorEntityToken entity;
434 public float rangeLY;
435 public boolean requirePlayerInHyperspace;
436 public InHyperRangeOfEntityChecker(SectorEntityToken entity,
float rangeLY,
boolean requirePlayerInHyperspace) {
437 this.entity = entity;
438 this.rangeLY = rangeLY;
439 this.requirePlayerInHyperspace = requirePlayerInHyperspace;
441 public boolean conditionsMet() {
442 if (requirePlayerInHyperspace && !Global.getSector().getPlayerFleet().isInHyperspace())
return false;
443 return Misc.getDistanceLY(Global.getSector().getPlayerFleet(), entity) < rangeLY;
447 public static class EnteredLocationChecker
implements ConditionChecker {
448 public LocationAPI location;
449 public EnteredLocationChecker(LocationAPI location) {
450 this.location = location;
452 public boolean conditionsMet() {
453 return Global.getSector().getCurrentLocation() == location;
457 public static class AlwaysTrueChecker
implements ConditionChecker {
458 public boolean conditionsMet() {
463 public static class StageConnection {
466 public ConditionChecker checker;
467 public StageConnection(Object from, Object to, ConditionChecker checker) {
470 this.checker = checker;
474 public static class TimeLimitData {
476 public Object failStage;
477 public LinkedHashSet<Object> endLimitStages =
new LinkedHashSet<Object>();
478 public StarSystemAPI noLimitWhileInSystem;
481 public static interface Abortable {
482 void abort(HubMission mission,
boolean missionOver);
485 public static class VariableSet
implements Abortable {
486 public MemoryAPI memory;
488 public boolean removeOnMissionOver;
489 public VariableSet(MemoryAPI memory, String key,
boolean removeOnMissionOver) {
490 this.memory = memory;
492 this.removeOnMissionOver = removeOnMissionOver;
495 public void abort(HubMission mission,
boolean missionOver) {
496 if (!removeOnMissionOver && missionOver)
return;
501 public static class MadeImportant
implements Abortable {
502 public MemoryAPI memory;
503 public String reason;
504 public MadeImportant(MemoryAPI memory, String reason) {
505 this.memory = memory;
506 this.reason = reason;
508 public void abort(HubMission mission,
boolean missionOver) {
509 Misc.makeUnimportant(memory, reason);
513 public static class DefeatTriggerAdded
implements Abortable {
514 protected CampaignFleetAPI fleet;
515 protected String trigger;
516 protected boolean permanent;
517 public DefeatTriggerAdded(CampaignFleetAPI fleet, String trigger,
boolean permanent) {
519 this.trigger = trigger;
520 this.permanent = permanent;
522 public void abort(HubMission mission,
boolean missionOver) {
523 if (!(permanent && missionOver)) {
524 Misc.removeDefeatTrigger(fleet, trigger);
530 public static class EntityAdded
implements Abortable {
533 this.entity = entity;
547 public static class PersonAdded
implements Abortable {
550 public boolean wasOnlyAddedToCommDirectory;
552 public PersonAdded(
MarketAPI market,
PersonAPI person,
boolean wasOnlyAddedToCommDirectory) {
553 this.market = market;
554 this.person = person;
555 this.wasOnlyAddedToCommDirectory = wasOnlyAddedToCommDirectory;
558 public void abort(HubMission mission,
boolean missionOver) {
564 "$requiredForMissions", bhm.
getReason(),
false, -1f)) {
569 if (!wasOnlyAddedToCommDirectory) {
577 public static class PersonMadeRequired
implements Abortable {
578 public PersonAPI person;
580 public PersonMadeRequired(PersonAPI person) {
581 this.person = person;
584 public void abort(HubMission mission,
boolean missionOver) {
587 if (Misc.setFlagWithReason(person.getMemoryWithoutUpdate(),
588 "$requiredForMissions", bhm.getReason(),
false, -1f)) {
596 protected LinkedHashMap<Object, StageData>
stages =
new LinkedHashMap<Object, StageData>();
602 protected List<StageConnection>
connections =
new ArrayList<StageConnection>();
603 protected List<MissionTrigger>
triggers =
new ArrayList<MissionTrigger>();
604 protected List<Abortable>
changes =
new ArrayList<Abortable>();
605 protected List<FlagData>
flags =
new ArrayList<FlagData>();
645 public static class PotentialContactData {
647 public float probability = -1f;
661 this.doNotAutoAddPotentialContactsOnSuccess =
true;
676 if (person ==
null)
return;
681 if (data.contact == person)
return;
683 PotentialContactData data =
new PotentialContactData();
684 data.contact = person;
685 data.probability = probability;
710 if (!
create(market, barEvent)) {
722 return "Call setName(<name>) to set mission name";
755 info.
addPara(
"You have successfully " + verb +
" this " + noun +
".", opad);
757 info.
addPara(
"You have failed this " + noun +
".", opad);
759 info.
addPara(
"You have abandoned this " + noun +
".", opad);
777 stage.elapsed += days;
785 (
timeLimit.noLimitWhileInSystem ==
null ||
793 if (
tracker.intervalElapsed()) {
801 return stage.elapsed;
816 throw new RuntimeException(
"startingStage can not be null. Use setStartingStage()");
853 for (Abortable curr :
changes) {
854 curr.abort(
this, missionWasAccepted);
859 if (!missionWasAccepted) {
896 if (curr.probability < 0) {
907 @SuppressWarnings(
"rawtypes")
910 String action = params.get(0).getString(memoryMap);
912 if (
"endFailure".equals(action)) {
927 if (
"makeUnimportant".equals(action)) {
929 if (target !=
null) {
941 if (
"showMap".equals(action)) {
943 if (mapLoc !=
null) {
944 String title = params.get(1).getStringWithTokenReplacement(ruleId, dialog, memoryMap);
955 }
else if (mapLoc instanceof
PlanetAPI) {
978 true, icon, text, tags);
983 if (
"hideMap".equals(action)) {
999 if (action.equals(
"updateStage")) {
1001 }
else if (action.equals(
"updateData")) {
1004 }
else if (action.equals(
"addContacts")) {
1006 }
else if (action.equals(
"repSuccess")) {
1008 }
else if (action.equals(
"repFailure")) {
1011 if (!
callAction(action, ruleId, dialog, params, memoryMap)) {
1012 throw new RuntimeException(
"Unhandled action [" + action +
"] in " + getClass().getSimpleName() +
1013 " for rule [" + ruleId +
"], params:[" + params +
"]");
1057 if (person ==
null)
return;
1060 mem.
set(
"$hisOrHer",
"his", 0);
1061 mem.
set(
"$HisOrHer",
"His", 0);
1062 mem.
set(
"$himOrHer",
"him", 0);
1063 mem.
set(
"$HimOrHer",
"Him", 0);
1064 mem.
set(
"$heOrShe",
"he", 0);
1065 mem.
set(
"$HeOrShe",
"He", 0);
1066 mem.
set(
"$himOrHerself",
"himself", 0);
1067 mem.
set(
"$HimOrHerself",
"Himself", 0);
1068 mem.
set(
"$manOrWoman",
"man", 0);
1069 mem.
set(
"$ManOrWoman",
"Man", 0);
1071 mem.
set(
"$hisOrHer",
"her", 0);
1072 mem.
set(
"$HisOrHer",
"Her", 0);
1073 mem.
set(
"$himOrHer",
"her", 0);
1074 mem.
set(
"$HimOrHer",
"Her", 0);
1075 mem.
set(
"$heOrShe",
"she", 0);
1076 mem.
set(
"$HeOrShe",
"She", 0);
1077 mem.
set(
"$himOrHerself",
"herself", 0);
1078 mem.
set(
"$HimOrHerself",
"Herself", 0);
1079 mem.
set(
"$manOrWoman",
"woman", 0);
1080 mem.
set(
"$ManOrWoman",
"Woman", 0);
1083 if (person.
getRank() !=
null) {
1085 mem.
set(
"$personRank", person.
getRank().toLowerCase(), 0);
1089 if (person.
getPost() !=
null) {
1091 mem.
set(
"$personPost", person.
getPost().toLowerCase(), 0);
1109 public void set(String key, Object value) {
1110 if (value instanceof Enum) value = ((Enum)value).name();
1120 if (
id ==
null)
return null;
1121 StageData data =
stages.get(
id);
1123 data =
new StageData();
1136 boolean changed =
false;
1140 if (conn.from !=
currentStage && conn.from !=
null)
continue;
1143 if (conn.checker.conditionsMet()) {
1161 Iterator<MissionTrigger> iter =
triggers.iterator();
1162 while (iter.hasNext()) {
1166 TriggerActionContext context =
new TriggerActionContext(
this);
1167 for (TriggerAction curr : trigger.
getActions()) {
1168 curr.doAction(context);
1176 List<CampaignFleetAPI>
result =
new ArrayList<CampaignFleetAPI>();
1177 Iterator<MissionTrigger> iter =
triggers.iterator();
1178 while (iter.hasNext()) {
1180 if (!trigger.
getStages().contains(stage))
continue;
1182 TriggerActionContext context =
new TriggerActionContext(
this);
1183 for (TriggerAction curr : trigger.
getActions()) {
1184 curr.doAction(context);
1187 result.addAll(context.allFleets);
1201 for (ImportanceData curr : data.important) {
1205 if (curr.flag !=
null) {
1206 curr.memory.unset(curr.flag);
1220 for (ImportanceData curr : data.important) {
1225 if (curr.flag !=
null) {
1226 curr.memory.set(curr.flag,
true);
1227 changes.add(
new VariableSet(curr.memory, curr.flag,
true));
1231 for (FlagData fd :
flags) {
1234 if (fd.value ==
null) {
1235 fd.memory.set(fd.flag,
true);
1237 fd.memory.set(fd.flag, fd.value);
1239 changes.add(
new VariableSet(fd.memory, fd.flag,
true));
1241 fd.memory.unset(fd.flag);
1266 result =
new HubMissionResult();
1267 result.success =
true;
1282 if (textPanel !=
null && reward > 0) {
1287 result.reward = reward;
1299 if (textPanel !=
null) {
1322 if (curr.probability < 0) {
1343 result =
new HubMissionResult();
1344 result.success =
false;
1366 result =
new HubMissionResult();
1367 result.success =
false;
1395 MissionCompletionRep completionRepPerson =
new MissionCompletionRep(
1398 MissionCompletionRep completionRepFaction =
new MissionCompletionRep(
1402 boolean withMessage = textPanel !=
null;
1404 boolean adjustPersonRep = (action == RepActions.MISSION_SUCCESS && completionRepPerson.successDelta != 0) ||
1405 (action == RepActions.MISSION_FAILURE && completionRepPerson.failureDelta != 0);
1406 if (adjustPersonRep &&
getPerson() !=
null) {
1408 new RepActionEnvelope(action, completionRepPerson,
1409 textPanel,
true, withMessage),
1411 if (
result !=
null) result.repPerson = rep;
1412 completionRepPerson.successDelta = 0;
1415 boolean adjustFactionRep = (action == RepActions.MISSION_SUCCESS && completionRepFaction.successDelta != 0) ||
1416 (action == RepActions.MISSION_FAILURE && completionRepFaction.failureDelta != 0);
1417 if (adjustFactionRep &&
getPerson() !=
null) {
1419 new RepActionEnvelope(action, completionRepFaction,
1420 textPanel,
true, withMessage),
1422 if (
result !=
null) result.repFaction = rep;
1423 completionRepFaction.successDelta = 0f;
1432 for (Object
id : ids) {
1441 for (Object
id : ids) {
1451 for (Object
id : ids) {
1457 Iterator<Abortable> iter =
changes.iterator();
1458 while (iter.hasNext()) {
1459 Abortable curr = iter.next();
1460 if (curr instanceof MadeImportant) {
1461 MadeImportant mi = (MadeImportant) curr;
1462 if (mi.memory == memory) {
1470 Iterator<Abortable> iter =
changes.iterator();
1471 while (iter.hasNext()) {
1472 Abortable curr = iter.next();
1473 if (curr instanceof VariableSet) {
1474 VariableSet vs = (VariableSet) curr;
1475 if (vs.memory == memory && flag.equals(vs.key)) {
1498 return RepRewards.HIGH;
1503 return RepRewards.SMALL;
1508 return RepRewards.MEDIUM;
1513 return RepRewards.TINY;
1542 if (
hub ==
null)
return null;
1560 setFlag(person,
"$doGenericPortAuthorityCheck",
false);
1574 String requiredKey = flag +
"_" + reason;
1598 setFlag(memory, flag, value, permanent, (Object [])
null);
1604 FlagData fd =
new FlagData();
1608 fd.stages.addAll(Arrays.asList(
stages));
1612 if (fd.value ==
null) {
1613 fd.memory.set(fd.flag,
true);
1615 fd.memory.set(fd.flag, fd.value);
1617 changes.add(
new VariableSet(fd.memory, fd.flag,
true));
1620 if (value ==
null) {
1621 memory.
set(flag,
true);
1623 memory.
set(flag, value);
1625 changes.add(
new VariableSet(memory, flag, !permanent));
1658 if (inProgressFlag !=
null) {
1666 if (person ==
null)
return false;
1676 if (faction ==
null)
return false;
1686 if (market ==
null)
return false;
1696 if (entity ==
null)
return false;
1728 boolean inCurrentStage =
false;
1730 for (Object
id :
stages) {
1732 ImportanceData data =
new ImportanceData();
1733 data.memory = memory;
1735 data.locType = type;
1736 if (personOrEntityOrMarket instanceof
PersonAPI) {
1737 data.person = (
PersonAPI) personOrEntityOrMarket;
1740 }
else if (personOrEntityOrMarket instanceof
MarketAPI) {
1741 data.market = (
MarketAPI) personOrEntityOrMarket;
1743 getData(
id).important.add(data);
1746 inCurrentStage =
true;
1749 if (inCurrentStage) {
1755 memory.
set(flag,
true);
1757 changes.add(
new VariableSet(memory, flag,
true));
1764 if (person ==
null)
return;
1768 if (entity ==
null)
return;
1772 if (market ==
null)
return;
1776 if (person ==
null)
return;
1780 if (entity ==
null)
return;
1784 if (market ==
null)
return;
1793 for (Object
id :
stages) {
1794 StageData stageData =
getData(
id);
1795 list.add(stageData);
1798 list.addAll(this.stages.values());
1801 for (StageData stageData : list) {
1802 Iterator<ImportanceData> iter = stageData.important.iterator();
1803 while (iter.hasNext()) {
1804 ImportanceData data = iter.next();
1805 if (data.memory == memory ||
1806 data.person == personOrEntityOrMarket ||
1807 data.entity == personOrEntityOrMarket ||
1808 data.market == personOrEntityOrMarket) {
1823 timeLimit.days = days;
1824 timeLimit.failStage = failStage;
1825 timeLimit.noLimitWhileInSystem = noLimitWhileInSystem;
1826 if (noLimitAfterStages !=
null) {
1827 for (Object stage : noLimitAfterStages) {
1844 int num2 = (int) num;
1845 for (
int i = 1; i < 10; i++) {
1846 int threshold = (int) Math.pow(10, i);
1847 int base = threshold / 10;
1848 if (num2 > threshold) {
1849 num2 = num2 / base * base;
1858 int reward = min +
genRandom.nextInt(max - min + 1);
1862 reward = reward / 1000 * 1000;
1863 if (reward > 100000) {
1864 reward = reward / 10000 * 10000;
1882 setCreditReward(reward.min / 2 + reward.perMarketSize * Math.max(0, marketSize - 3),
1883 reward.max / 2 + reward.perMarketSize * Math.max(0, marketSize - 3));
1910 if (this.xpReward <= 0) this.xpReward =
null;
2033 Set<String> tags = super.getIntelTags(map);
2062 ImportanceData data =
null;
2063 for (ImportanceData curr : stage.important) {
2064 if (curr.locType ==
null)
continue;
2065 if (curr.entity == personOrMarketOrEntity ||
2066 curr.market == personOrMarketOrEntity ||
2067 curr.person == personOrMarketOrEntity) {
2073 stage.important.remove(data);
2074 stage.important.add(0, data);
2083 ImportanceData data =
null;
2084 for (ImportanceData curr : stage.important) {
2085 if (curr.locType ==
null)
continue;
2086 if (curr.entity !=
null && !curr.entity.isAlive())
continue;
2090 if (data ==
null || data.locType ==
null)
return null;
2093 if (entity ==
null && data.person !=
null && data.person.getMarket() !=
null) {
2094 entity = data.person.getMarket().getPrimaryEntity();
2096 if (entity ==
null && data.market!=
null) {
2097 entity = data.market.getPrimaryEntity();
2099 if (entity ==
null)
return null;
2101 if (data.locType == MapLocationType.NORMAL) {
2107 }
else if (data.locType == MapLocationType.CONSTELLATION) {
2110 if (c !=
null && map !=
null) {
2137 return " - Completed";
2141 return " - Abandoned";
2146 return " - Accepted";
2185 return super.getImportantIcon();
2189 if (
result ==
null)
return;
2190 if (mode == ListInfoMode.INTEL)
return;
2198 if (mode == ListInfoMode.IN_DESC) initPad = 10f;
2205 if (
result.repPerson !=
null) {
2207 null, info, tc, isUpdate, initPad);
2210 if (
result.repFaction !=
null) {
2212 null, info, tc, isUpdate, initPad);
2220 if (textPanel ==
null) {
2225 this.listInfoParam =
null;
2232 this.listInfoParam =
null;
2243 return "to complete";
2253 float initPad = pad;
2254 if (mode == ListInfoMode.IN_DESC) initPad = opad;
2285 if (mode == ListInfoMode.IN_DESC) {
2289 if (mode == ListInfoMode.IN_DESC) {
2359 if (person !=
null) {
2362 String post =
"one";
2363 if (person.
getPost() !=
null) post = person.
getPost().toLowerCase();
2364 if (post ==
null && person.
getRank() !=
null) post = person.
getRank().toLowerCase();
2391 this.abandonStage =
null;
2399 return super.doesButtonHaveConfirmDialog(buttonId);
2409 (
int)(width), 20f, opad * 2f);
2430 super.buttonPressConfirmed(buttonId, ui);
2441 if (!loseRepFaction && !loseRepPerson) {
2444 prompt.
addPara(
"It's been less than a day, and you can still abandon this " +
getMissionTypeNoun() +
" without a penalty.", 0f);
2446 if (loseRepFaction && !loseRepPerson) {
2450 }
else if (!loseRepFaction && loseRepPerson) {
2452 "a reputation penalty with " +
getPerson().getNameString() +
".",
2456 "a reputation penalty with both " +
getPerson().getNameString() +
" and " +
2462 super.createConfirmationPrompt(buttonId, prompt);
2499 if (bothWays) fuel *= 2f;
2500 return (
int) Math.round(fuel);
2505 for (Object option : options) {
2508 return picker.
pick();
2512 return pickOne(options.toArray(
new String[0]));
2516 for (String option : options) {
2519 return picker.
pick();
2523 if (item.startsWith(
"a ")) {
2524 return item.replaceFirst(
"a ",
"");
2526 if (item.startsWith(
"an ")) {
2527 return item.replaceFirst(
"an ",
"");
2529 if (item.startsWith(
"the ")) {
2530 return item.replaceFirst(
"the ",
"");
2557 connections.add(
new StageConnection(
null, to, custom));
2561 connections.add(
new StageConnection(from, to,
new GlobalBooleanChecker(flag)));
2578 connections.add(
new StageConnection(from, to,
new MemoryBooleanChecker(memory, flag)));
2580 changes.add(
new VariableSet(memory, flag,
true));
2584 connections.add(
new StageConnection(from, to,
new EntityNotAliveChecker(entity)));
2588 connections.add(
new StageConnection(from, to,
new MarketDecivChecker(market)));
2591 connections.add(
new StageConnection(
null, to,
new MarketDecivChecker(market)));
2595 connections.add(
new StageConnection(from, to,
new HostilitiesEndedChecker(person, market)));
2598 connections.add(
new StageConnection(
null, to,
new HostilitiesEndedChecker(person, market)));
2601 connections.add(
new StageConnection(from, to,
new HostilitiesStartedChecker(person, market)));
2604 connections.add(
new StageConnection(
null, to,
new HostilitiesStartedChecker(person, market)));
2608 connections.add(
new StageConnection(from, to,
new DaysElapsedChecker(days,
getData(from))));
2612 connections.add(
new StageConnection(from, to,
new InCommRelayRangeChecker()));
2616 connections.add(
new StageConnection(from, to,
new EnteredLocationChecker(location)));
2619 connections.add(
new StageConnection(from, to,
new InRangeOfEntityChecker(entity, range)));
2625 boolean requirePlayerInHyperspace) {
2626 connections.add(
new StageConnection(from, to,
new InHyperRangeOfEntityChecker(entity, rangeLY, requirePlayerInHyperspace)));
2630 connections.add(
new StageConnection(from, to, custom));
2639 DebrisFieldParams params =
new DebrisFieldParams(
2644 params.source = DebrisFieldSource.MIXED;
2645 params.baseSalvageXP = (long) radius;
2647 if (!data.updateLocIfNeeded(
this,
null))
return null;
2650 data.placeEntity(debris);
2651 changes.add(
new EntityAdded(debris));
2671 EntityLocation loc =
null;
2674 if (locType == EntityLocationType.HIDDEN) {
2676 }
else if (locType == EntityLocationType.HIDDEN_NOT_NEAR_STAR) {
2678 }
else if (locType == EntityLocationType.ORBITING_PLANET) {
2680 }
else if (locType == EntityLocationType.ORBITING_PLANET_OR_STAR) {
2682 }
else if (locType == EntityLocationType.UNCOMMON) {
2684 }
else if (locType == EntityLocationType.ANY) {
2689 if (locType == EntityLocationType.ORBITING_PARAM) {
2693 if (entityId !=
null) {
2697 loc =
new EntityLocation();
2698 loc.type = LocationType.PLANET_ORBIT;
2707 loc =
new EntityLocation();
2708 loc.type = LocationType.STAR_ORBIT;
2713 loc =
new EntityLocation();
2714 loc.type = LocationType.OUTER_SYSTEM;
2715 loc.location =
new Vector2f();
2723 if (!data.updateLocIfNeeded(
this, entityId))
return null;
2726 if (added ==
null)
return null;
2728 if (data.removeOnMissionOver) {
2734 changes.add(
new EntityAdded(added.entity));
2735 return added.entity;
2739 if (!data.updateLocIfNeeded(
this,
null))
return null;
2742 data.system.addEntity(token);
2743 data.placeEntity(token);
2744 changes.add(
new EntityAdded(token));
2751 if (hullId ==
null) {
2759 if (factionId ==
null) {
2773 if (shipData ==
null)
return null;
2775 if (!data.updateLocIfNeeded(
this,
Entities.
WRECK))
return null;
2779 data.placeEntity(entity);
2781 changes.add(
new EntityAdded(entity));
2788 int numShips = minShips +
genRandom.nextInt(maxShips - minShips + 1);
2791 for (
int i = 0; i < numShips + 5; i++) {
2792 bands.
add(
new Float(120f + i * 20f), (i + 1f) * (i + 1f));
2795 for (
int i = 0; i < numShips; i++) {
2798 EntityLocation loc =
new EntityLocation();
2799 loc.type = LocationType.OUTER_SYSTEM;
2800 float orbitDays = r / (5f +
genRandom.nextFloat() * 10f);
2803 LocData curr =
new LocData(loc, data.system, data.removeOnMissionOver);
2849 if (market !=
null) faction = market.
getFaction();
2850 if (factionId !=
null) {
2854 person = ip.
getPerson(
genRandom, faction, market, reason, defaultRank, posts).getPerson();
2858 if (person !=
null && !createdNewPerson &&
2869 if (person ==
null) {
2872 for (String post : posts) {
2873 postPicker.
add(post);
2878 if (market !=
null) market.
addPerson(person);
2887 boolean addedToComms =
false;
2890 addedToComms =
true;
2893 boolean willBeRemoved =
false;
2894 if (createdNewPerson || addedToComms) {
2895 if (cleanUpOnMissionOverIfWasNewPerson) {
2898 PersonAdded added =
new PersonAdded(market, person, !createdNewPerson);
2900 willBeRemoved =
true;
2905 PersonAdded added =
new PersonAdded(market, person,
false);
2915 PersonMadeRequired req =
new PersonMadeRequired(person);
2922 boolean addedToComms =
false;
2925 addedToComms =
true;
2929 PersonAdded added =
new PersonAdded(market, person,
true);
2979 if (factionId ==
null) factionId = market.
getFactionId();
2985 if (person !=
null) {
2986 if (createdNewPerson) {
3003 if (createdNewPerson && !addToCommDirectory) {
3026 return picker.
pick();
3033 return picker.
pick();
3040 return picker.
pick();
3047 return picker.
pick();
3052 if (factionId ==
null) factionId = market.
getFactionId();
3076 if (addToCommDirectory) {
3079 if (removeOnMissionOver) {
3082 PersonAdded added =
new PersonAdded(market, person,
false);
3095 if (person ==
null)
return;
3100 }
else if (rel < 0) {
3109 quality = Math.min(Math.max(0, rel), importance);
3110 if (rel > importance && importance < 1f) {
3111 quality += (rel - importance) / (1f - importance) * maxRelBonus;
3124 if (person ==
null)
return 0.5f;
3130 if (person ==
null)
return 0f;
3133 return Math.min(1f, importance + maxRelBonus);
3137 if (person ==
null)
return 0f;
3140 if (min < 0) min = 0;
3158 return Math.min(1f, Math.max(0f, (
rewardMult - 1f) / (max - 1f)));
3171 changes.add(
new DefeatTriggerAdded(fleet, trigger, permanent));
3183 return "Get within range of a functional comm relay to complete the mission and receive " +
3188 return "Get within comms range to complete the mission";
3199 return "Go to " + planet.
getName();
3209 return "Go to " + planet.
getName() +
", " + a +
" " + world +
" in hyperspace";
3217 return "Go to " + market.
getName();
3223 if (market !=
null) {
3235 return "Return to " + locationName +
" and talk to " +
3242 return "Return to " + locationName +
" and talk to " +
3251 boolean found =
false;
3252 float orbitAngle = 0f;
3253 float orbitRadius = 0f;
3254 float orbitPeriod = 0f;
3256 Vector2f forceLoc =
null;
3262 if (maxRadius < 100f) maxRadius = 100f;
3266 for (
int i = 0; i < tiles.
getTiles().length; i++) {
3267 for (
int j = 0; j < tiles.
getTiles()[0].length; j++) {
3270 Vector2f loc =
new Vector2f(f[0], f[1]);
3272 float weight = (float) Math.pow(dist / maxRadius, 3);
3275 }
else if (pickerPref.
isEmpty()) {
3283 if (pick ==
null) pick = picker.
pick();
3287 Vector2f loc =
new Vector2f(f[0], f[1]);
3304 float centerRadius = 0f;
3305 if (atCenter !=
null) centerRadius = atCenter.
getRadius();
3310 float min = Math.max(centerRadius, ringMin);
3311 orbitRadius = min + (ringMax - min) * (0.1f + 0.8f *
genRandom.nextFloat());
3312 orbitAngle =
genRandom.nextFloat() * 360f;
3317 orbitRadius = 100f + 100f *
genRandom.nextFloat();
3318 orbitAngle = 360f *
genRandom.nextFloat();
3321 EntityLocation eLoc =
new EntityLocation();
3322 eLoc.type = LocationType.OUTER_SYSTEM;
3323 if (forceLoc !=
null) {
3324 eLoc.location = forceLoc;
3326 if (orbitPeriod <= 0f) {
3327 orbitPeriod = orbitRadius / (5f + 5f *
genRandom.nextFloat());
3330 orbitAngle, orbitRadius, orbitPeriod);
3338 if (name ==
null) name =
"";
3339 if (name.contains(
" L4") || name.contains(
" L5")) {
3404 int d = (int) Math.round(days);
3405 String daysStr =
"days";
3474 int tokens = (int) Math.ceil((
float) daysRequired / (
float) daysPerToken);
3475 if (tokens < 1) tokens = 1;
3479 return marinesRequired;
3489 "will require around %s marines, and the " +
3490 "danger level is %s.",
3494 danger.name.toLowerCase());
3501 return marinesRequired;
3507 return marinesRequired;
3515 "will require around %s marines, and the " +
3516 "danger level is %s.",
3519 danger.name.toLowerCase());
3529 "will require around %s marines, and the " +
3530 "danger level is %s.",
3533 danger.name.toLowerCase());
3545 for (
int i = 1; i < marinesRequired * 2; i *= 2) {
3546 float currSupport = (int) Math.round(Math.min(support, i));
3547 float strength = i + currSupport;
3549 if (strength >= marinesRequired) {
3556 int iter = Math.max(1, (max - min) / 100);
3558 for (
int i = min; i <= max; i += iter) {
3559 float currSupport = (int) Math.min(support, i);
3560 float strength = i + currSupport;
3562 if (strength >= marinesRequired) {
3563 marinesRequired = (int) Math.round(strength);
3572 if (marinesRequired > 100) base = 50;
3573 if (marinesRequired > 500) base = 100;
3574 if (marinesRequired > 1000) base = 250;
3575 if (marinesRequired > 2000) base = 500;
3576 if (marinesRequired > 5000) base = 1000;
3577 for (
int i = 0; i < 10; i++) {
3578 if (marinesRequired <= (i + 1) * base) {
3579 marinesRequired = (i + 1) * base;
3584 return marinesRequired;
3594 if (prefix ==
null || prefix.isEmpty()) {
3597 " base located in hyperspace.",
3611 " base located in hyperspace.",
3628 if (prefix ==
null || prefix.isEmpty()) {
3675 info.
addPara(
"Effectively bombarding the target will require approximately %s units of fuel.",
3714 return crew > marines * 2 || credits > marines * 400;
3723 for (String postId : postIds) {
3725 if (postId.equals(person.getPostId())) {
3739 this.mapMarkerNameColor = mapMarkerColor;
static SettingsAPI getSettings()
static FactoryAPI getFactory()
static SectorAPI getSector()
static final String LOCAL
static final String ENTITY
void modifyFlat(String source, float value)
float computeEffective(float baseValue)
static String MUSIC_SET_MEM_KEY_MISSION
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 final String WRECK
static final String MISSION_LOCATION
static final String NEUTRAL
static final String PIRATES
static String POST_CITIZEN
static String POST_GANGSTER
static String POST_TRADER
static String POST_INVESTOR
static String POST_COMMODITIES_AGENT
static String POST_SMUGGLER
static String POST_MERCHANT
static final String PLANETARY_OPERATIONS_MOD
static final String FLEET_GROUND_SUPPORT
Set< String > getTagsForSort()
String getSortStringNewestFirst()
void unindent(TooltipMakerAPI info)
void addDays(TooltipMakerAPI info, String after, float days)
transient Object listInfoParam
void sendUpdateIfPlayerHasIntel(Object listInfoParam, TextPanelAPI textPanel)
Object getListInfoParam()
Color getBulletColorForMode(ListInfoMode mode)
void setImportant(Boolean important)
void bullet(TooltipMakerAPI info)
Color getTitleColor(ListInfoMode mode)
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
void setMusic(StarSystemAPI system, String musicSetId, Object ... stages)
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 setMusic(SectorEntityToken entity, String musicSetId, Object ... stages)
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 setMusic(MarketAPI market, String musicSetId, Object ... stages)
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 setMusic(MemoryAPI memory, String musicSetId, Object ... stages)
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()
long getPrevValue(String key)
static PlaythroughLog getInstance()
static EntityLocation pickHiddenLocationNotNearStar(Random random, StarSystemAPI system, float gap, Set< SectorEntityToken > exclude)
static AddedEntity addEntityAutoDetermineType(Random random, LocationAPI system, EntityLocation loc, String type, String faction)
static EntityLocation pickHiddenLocation(Random random, StarSystemAPI system, float gap, Set< SectorEntityToken > exclude)
static EntityLocation pickCommonLocation(Random random, StarSystemAPI system, float gap, boolean allowStarOrbit, Set< SectorEntityToken > exclude)
static EntityLocation pickAnyLocation(Random random, StarSystemAPI system, float gap, Set< SectorEntityToken > exclude)
static EntityLocation pickUncommonLocation(Random random, StarSystemAPI system, float gap, Set< SectorEntityToken > exclude)
static EntityLocation createLocationAtRandomGap(Random random, SectorEntityToken center, float minGap)
static SectorEntityToken addSalvageEntity(LocationAPI location, String id, String faction)
static WeightedRandomPicker< String > getNearbyFactions(Random random, SectorEntityToken entity)
static void addCreditsGainText(int credits, TextPanelAPI text)
static void addStackGainText(CargoStackAPI stack, TextPanelAPI text)
static int getBombardmentCost(MarketAPI market, CampaignFleetAPI fleet)
static int getDisruptDaysPerToken(MarketAPI market, Industry industry)
static int getMarinesFor(MarketAPI market, int tokens)
static void addExtraSalvage(SectorEntityToken entity, CargoAPI cargo)
static String getLocatedString(SectorEntityToken target)
RingParams getRingParams()
float[] getTileCenter(int i, int j)
void advance(float amount)
static Color getTextColor()
static boolean isHiddenBase(MarketAPI market)
static String getDGSCredits(float num)
static String getWithDGS(float num)
static float getDistanceLY(SectorEntityToken from, SectorEntityToken to)
static SectorEntityToken addDebrisField(LocationAPI loc, DebrisFieldParams params, Random random)
static String ucFirst(String str)
static Color setAlpha(Color color, int alpha)
static void makeImportant(SectorEntityToken entity, String reason)
static float getFleetwideTotalMod(CampaignFleetAPI fleet, String dynamicMemberStatId, float base)
static Color getGrayColor()
static String getAOrAnFor(String word)
static void addDefeatTrigger(CampaignFleetAPI fleet, String trigger)
static Color setBrightness(Color color, int brightness)
static float getDistance(SectorEntityToken from, SectorEntityToken to)
static float getUnitsPerLightYear()
static boolean flagHasReason(MemoryAPI memory, String flagKey, String reason)
static void makeUnimportant(SectorEntityToken entity, String reason)
static Color getHighlightColor()
static boolean setFlagWithReason(MemoryAPI memory, String flagKey, String reason, boolean value, float expire)
static float getAngleInDegrees(Vector2f v)
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()
float convertToDays(float realSeconds)
FleetDataAPI getFleetData()
MutableFleetStatsAPI getStats()
FleetLogisticsAPI getLogistics()
CampaignTerrainPlugin getPlugin()
String getNameForTooltip()
void addHullmods(String id, int count)
void addWeapons(String id, int count)
float getCommodityQuantity(String id)
void addSpecial(SpecialItemData data, float quantity)
MutableValue getCredits()
List< CargoStackAPI > getStacksCopy()
void addItems(CargoAPI.CargoItemType itemType, Object data, float quantity)
void addCommodity(String commodityId, float quantity)
void addFighters(String id, int count)
void removePerson(PersonAPI person)
CommDirectoryEntryAPI getEntryForPerson(PersonAPI person)
String addPerson(PersonAPI person)
MemoryAPI getMemoryWithoutUpdate()
String getPersonNamePrefixAOrAn()
String getDisplayNameWithArticleWithoutArticle()
String getDisplayNameWithArticle()
String getPersonNamePrefix()
PersonAPI createRandomPerson()
boolean isNeutralFaction()
void setShipNameRandom(Random shipNameRandom)
void addFleetMember(FleetMemberAPI member)
void removeFleetMember(FleetMemberAPI member)
TextPanelAPI getTextPanel()
VisualPanelAPI getVisualPanel()
SectorEntityToken getInteractionTarget()
String getNameWithLowercaseType()
void removeEntity(SectorEntityToken entity)
MemoryAPI getMemoryWithoutUpdate()
String getNameWithLowercaseTypeShort()
String getTypeNameWithWorld()
CampaignFleetAPI getPlayerFleet()
void addScript(EveryFrameScript script)
ReputationAdjustmentResult adjustPlayerReputation(Object action, String factionId)
CampaignClockAPI getClock()
LocationAPI getCurrentLocation()
void removeScript(EveryFrameScript script)
FactionAPI getPlayerFaction()
IntelManagerAPI getIntelManager()
MutableCharacterStatsAPI getPlayerStats()
FactionAPI getFaction(String factionId)
MemoryAPI getMemoryWithoutUpdate()
ImportantPeopleAPI getImportantPeople()
LocationAPI getContainingLocation()
StatBonus getDetectedRangeMod()
boolean isVisibleToPlayerFleet()
void setSensorProfile(Float sensorProfile)
void setDiscoverable(Boolean discoverable)
StarSystemAPI getStarSystem()
PersonAPI getActivePerson()
void setActivePerson(PersonAPI activePerson)
SectorEntityToken getOrbitFocus()
Constellation getConstellation()
boolean hasTag(String tag)
Vector2f getLocationInHyperspace()
float getCircularOrbitRadius()
MemoryAPI getMemoryWithoutUpdate()
float getCircularOrbitPeriod()
void setDiscoveryXP(Float discoveryXP)
SectorEntityToken getCenter()
void showMapMarker(SectorEntityToken marker, String title, Color titleColor, boolean withIntel, String icon, String text, Set< String > intelTags)
void removeMapMarkerFromPersonInfo()
void showPersonInfo(PersonAPI person)
void addIntel(IntelInfoPlugin plugin)
void addIntelToTextPanel(IntelInfoPlugin plugin, TextPanelAPI textPanel)
MarketAPI getMarket(String id)
IndustrySpecAPI getSpec()
MemoryAPI getMemoryWithoutUpdate()
void addPerson(PersonAPI person)
CommDirectoryAPI getCommDirectory()
Color getTextColorForFactionOrPlanet()
List< PersonAPI > getPeopleCopy()
StarSystemAPI getStarSystem()
void removePerson(PersonAPI person)
SectorEntityToken getPrimaryEntity()
MemoryAPI getMemoryWithoutUpdate()
float getFloat(String key)
boolean contains(String key)
void set(String key, Object value)
boolean getBoolean(String key)
PersonLocationAPI getLocation()
void setMarket(MarketAPI market)
PersonDataAPI getData(PersonAPI person)
void removePerson(PersonAPI person)
void excludeFromGetPerson(PersonAPI person)
PersonAPI getPerson(String id)
void addPerson(PersonAPI person)
boolean isLastGetPersonResultWasExistingPerson()
void addXP(long xp, TextPanelAPI textPanel, boolean withMessage, boolean allowBonusXP, boolean withLevelUp)
String getPortraitSprite()
void setVoice(String voice)
RelationshipAPI getRelToPlayer()
void setPortraitSprite(String portraitSprite)
boolean hasTag(String tag)
void setImportanceAndVoice(PersonImportance importance, Random random)
void setRankId(String rank)
void setMarket(MarketAPI market)
PersonImportance getImportance()
MemoryAPI getMemoryWithoutUpdate()
void setPostId(String postId)
float getFuelCostPerLightYear()
DynamicStatsAPI getDynamic()
RaidDangerLevel getDisruptDanger()
void setHighlight(int start, int end)
void setHighlightColors(Color ... colors)
SectorEntityToken getConstellationLabelEntity(Constellation c)
StatBonus getMod(String id)