Skip to content
This repository was archived by the owner on May 6, 2023. It is now read-only.

Commit 0fbae0c

Browse files
authored
More bugfixes (#28)
- Fix Black Market suspicion resetting at each dock. - Fix incorrect Black Market description (was not matching its new behaviour). - Fix illegal commodities (usually drugs and organs) always being legal on Open Market. - Add missing HMI factions to reputation change blacklist (`mess` and `mess_remnants`). - Add support for negation in legal list (`item` will be always legal and !item will be always illegal). - New configuration: max tier and fleet points at which items and combat ships are considered legal. - New feature: remove endgame ships (capitals) and cargo (tier3) from Military Markets.
1 parent 37b3b2f commit 0fbae0c

17 files changed

+252
-115
lines changed

README.md

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,14 @@ This mod makes the following changes to the campaign layer of Starsector:
88
1. Lawless factions (e.g. pirates and pathers) and independents do not submit to this rule of law. You can still find
99
high tier weapons and combat ships at their bases (both core and raider).
1010
1. There are no pristine ships any more, everything is d-modded. Including your starting fleet.
11-
1. Contraband can happen, and when stability is low, some weapons and ships "disappear" from Military Market and
12-
"magically" show up in the Black Market instead.
11+
1. Contraband can happen, and when stability is low, some weapons and ships from Military Market can become "legal".
1312
1. Access to most Black Markets is impossible while legally docked at the station. Speaking of access, you will need to
1413
use a fence who will ask for a cut (displayed as tariff for now).
1514
1. Factions are armed to the teeth. Any non-hidden market has at least an orbiting station, ground defences, and patrol
1615
HQ. Hidden bases (pirates and pathers raider bases) only get ground defences.
1716
1. Your actions have consequences. When defeating a fleet, your reputation with seemingly unrelated factions changes as
1817
well. Enemies of your enemy start to like you a bit, while their friends, less.
19-
1. Similarly, targetting a any colony item will be deemed as an act of war.
18+
1. Similarly, targetting any colony item will be deemed as an act of war.
2019

2120
All changes are optional, and can be disabled via `starpocalypse.json`.
2221

@@ -57,10 +56,10 @@ The list of raid-protected items (special item ids) is present in `raidProtector
5756

5857
### Submarket changes
5958

60-
1. Remove larger combat ships (>5 FP), and high tier (>0) weapons, LPCs, and modspecs from open markets if it is not a
61-
pirate or Luddic Path market.
59+
1. Remove combat ships, and high tier weapons, LPCs, and modspecs from open markets if it is not a pirate or Luddic
60+
Path market.
6261
1. When the stability is low, some of the initially illegal items and ships on Military Market will become legal.
63-
1. Finally, damage all pristine ships by putting a random number of d-mods.
62+
1. Finally, damage all pristine ships by putting a random number of d-mods on them.
6463

6564
Decision which factions have their Open Market regulated regulated is made via `militaryRegulationFaction.csv` file.
6665
Same submarkets and factions can additionally have contraband applied to their Military Market in

assets/data/campaign/submarkets.csv

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@ Market",,"The open market. Only legal goods may be traded here, and transactions
44

55
Selling enough of a commodity will temporarily resolve a shortage.",starpocalypse.submarket.RegulatedOpenMarket,,0
66
black_market,"Black
7-
Market",pirates,"The black market. Anything and everything can be bought or sold, and there are no tariffs. More goods are available when stability is low.
7+
Market",pirates,"The black market. Anything and everything can be bought or sold. More goods are available when stability is low.
88

99
Selling a commodity will not resolve a shortage.
1010

11-
Black market transactions may catch the eye of authorities, resulting in cargo scans and reduced faction standing, unless the trades are carried out with the transponder turned off.
11+
Black market transactions will catch the eye of authorities, resulting in cargo scans and reduced faction standing.
1212

13-
Engaging in legitimate trade as a ""cover"" also reduces the probability of attracting the attention of authorities.",starpocalypse.submarket.RegulatedBlackMarket,graphics/factions/black_market.png,999
13+
Engaging in legitimate trade as a ""cover"" reduces the probability of attracting the attention of authorities.",starpocalypse.submarket.RegulatedBlackMarket,graphics/factions/black_market.png,999
1414
generic_military,,,"Trade with $theFaction military base.
1515

1616
Weapons and other military hardware can be bought and sold here even if they're illegal on the open market. A commission and better standing with $theFaction results in higher-grade hardware being available.

assets/data/starpocalypse/reputationBlacklist.csv

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,6 @@ blade_breakers
1717
cabal
1818
domres
1919
hmi_nightmare
20+
mess
21+
mess_remnant
2022
plague

assets/mod_info.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"name": " Starpocalypse",
44
"author": "Jaghaimo",
55
"utility": true,
6-
"version": "2.2.1",
6+
"version": "2.2.2",
77
"description": "More apocalyptic settings",
88
"gameVersion": "0.95.1a-RC6",
99
"modPlugin": "starpocalypse.StarpocalypseMod",

assets/starpocalypse.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,15 @@
1212
## MILITARY REGULATIONS
1313
# Buying or selling military wares Open Market is illegal unless you are commissioned with the owner of the market.
1414
# Uses same logic as Military market with the addition of:
15-
# - Legal list is applied to make item or ship always legal,
15+
# - Legal list is applied to make item or ship always legal (or illegal, if !negated),
1616
# - All civ-grade or civ-hint ships are always legal.
1717
"militaryRegulations": true,
18+
# LPC, weapon, and modspec tier and combat ship FP at which they are still legal.
19+
"regulationMaxLegalTier": 0, # easy mode: 1
20+
"regulationMaxLegalFP": 0, # easy mode: 5
21+
# Remove endgame ships (all capitals) and items (tier3 LPC, modspecs, and weapons) from Military Markets.
22+
"removeMilitaryEndgameCargo": true,
23+
"removeMilitaryEndgameShips": true,
1824
# Suspicion level will grow even with transponder off. It is still useful to sell illegal wares.
1925
"transparentMarket": true,
2026
# Setting this to 0 essentially disabled the feature. Setting this to 1 makes it behave as if the transponder was on

assets/starpocalypse.version

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"modVersion": {
66
"major": 2,
77
"minor": 2,
8-
"patch": 1
8+
"patch": 2
99
},
10-
"directDownloadURL": "https://github.com/jaghaimo/starpocalypse/releases/download/2.2.1/starpocalypse-2.2.1.zip"
10+
"directDownloadURL": "https://github.com/jaghaimo/starpocalypse/releases/download/2.2.2/starpocalypse-2.2.2.zip"
1111
}

src/starpocalypse/StarpocalypseMod.java

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,14 @@
22

33
import com.fs.starfarer.api.BaseModPlugin;
44
import com.fs.starfarer.api.Global;
5+
import com.fs.starfarer.api.campaign.CampaignUIAPI;
56
import com.fs.starfarer.api.fleet.FleetMemberAPI;
67
import com.fs.starfarer.api.impl.campaign.ids.Industries;
78
import com.fs.starfarer.api.impl.campaign.shared.SharedData;
89
import java.util.List;
910
import lombok.extern.log4j.Log4j;
1011
import org.json.JSONObject;
11-
import starpocalypse.helper.ConfigUtils;
12+
import starpocalypse.helper.ConfigHelper;
1213
import starpocalypse.market.IndustryAdder;
1314
import starpocalypse.market.MarketListener;
1415
import starpocalypse.market.StationAdder;
@@ -25,7 +26,7 @@ public class StarpocalypseMod extends BaseModPlugin {
2526
@Override
2627
public void onApplicationLoad() throws Exception {
2728
settings = Global.getSettings().loadJSON("starpocalypse.json");
28-
ConfigUtils.init(settings, log);
29+
ConfigHelper.init(settings, log);
2930
}
3031

3132
@Override
@@ -46,17 +47,9 @@ public void onGameLoad(boolean newGame) {
4647

4748
@Override
4849
public void afterGameSave() {
49-
JSONObject globalSettings = Global.getSettings().getSettingsJSON();
50-
if (!globalSettings.optBoolean("hasStarpocalypse", false)) {
50+
if (ConfigHelper.isUninstall()) {
5151
SharedData.getData().getPlayerActivityTracker().advance(0);
52-
Global
53-
.getSector()
54-
.getCampaignUI()
55-
.showMessageDialog(
56-
"Starpocalypse has been removed from this save. You can now quit the game and disable this mod." +
57-
"\n\nThank you for playing with Starpocalypse. I hope you had a bad day." +
58-
"\n\nYours, Jaghaimo."
59-
);
52+
showUninstalledDialog();
6053
}
6154
}
6255

@@ -134,4 +127,16 @@ private void militaryRegulations() {
134127
SubmarketSwapper.register();
135128
}
136129
}
130+
131+
private void showUninstalledDialog() {
132+
CampaignUIAPI campaignUi = Global.getSector().getCampaignUI();
133+
if (campaignUi == null) {
134+
return;
135+
}
136+
campaignUi.showMessageDialog(
137+
"Starpocalypse has been removed from this save. You can now quit the game and disable this mod." +
138+
"\n\nThank you for playing with Starpocalypse. I hope you had a bad day." +
139+
"\n\nYours, Jaghaimo."
140+
);
141+
}
137142
}

src/starpocalypse/config/SimpleSet.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,23 @@ public boolean has(String value) {
2727
if (set.contains(value)) {
2828
return true;
2929
}
30-
if (set.contains(NOT + value)) {
30+
if (hasNot(value)) {
3131
return false;
3232
}
33-
if (set.contains(ALL)) {
33+
if (hasAll()) {
3434
return true;
3535
}
3636
return false;
3737
}
3838

39+
public boolean hasAll() {
40+
return set.contains(ALL);
41+
}
42+
43+
public boolean hasNot(String value) {
44+
return set.contains(NOT + value);
45+
}
46+
3947
@Override
4048
protected void loadData(String column, String file) throws JSONException, IOException {
4149
JSONArray data = readCsv(column, file);
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
package starpocalypse.helper;
2+
3+
import com.fs.starfarer.api.campaign.CargoStackAPI;
4+
import com.fs.starfarer.api.combat.ShipVariantAPI;
5+
import com.fs.starfarer.api.fleet.FleetMemberAPI;
6+
import com.fs.starfarer.api.impl.campaign.DModManager;
7+
import com.fs.starfarer.api.loading.FighterWingSpecAPI;
8+
import com.fs.starfarer.api.loading.HullModSpecAPI;
9+
import com.fs.starfarer.api.loading.WeaponSpecAPI;
10+
import java.util.Random;
11+
import lombok.extern.log4j.Log4j;
12+
13+
/**
14+
* Cargo as defined by Starsector - cargo stacks and mothballed fleet
15+
*/
16+
@Log4j
17+
public class CargoUtils {
18+
19+
public static void damageShip(String location, FleetMemberAPI ship, int minDmods, int maxDmods) {
20+
String hullName = ship.getHullSpec().getHullName();
21+
ShipVariantAPI variant = ship.getVariant();
22+
Random random = new Random();
23+
if (DModManager.setDHull(variant)) {
24+
log.info(location + ": Damaging " + hullName);
25+
int numberOfDmods = random.nextInt(maxDmods - minDmods) + minDmods;
26+
DModManager.addDMods(variant, true, numberOfDmods, random);
27+
}
28+
}
29+
30+
public static int getTier(CargoStackAPI stack) {
31+
int tier = 0;
32+
if (stack.isWeaponStack()) {
33+
WeaponSpecAPI spec = stack.getWeaponSpecIfWeapon();
34+
tier = spec.getTier();
35+
} else if (stack.isModSpecStack()) {
36+
HullModSpecAPI spec = stack.getHullModSpecIfHullMod();
37+
tier = spec.getTier();
38+
} else if (stack.isFighterWingStack()) {
39+
FighterWingSpecAPI spec = stack.getFighterWingSpecIfWing();
40+
tier = spec.getTier();
41+
}
42+
return tier;
43+
}
44+
}

src/starpocalypse/helper/ConfigUtils.java renamed to src/starpocalypse/helper/ConfigHelper.java

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import starpocalypse.config.SimpleMap;
88
import starpocalypse.config.SimpleSet;
99

10-
public class ConfigUtils {
10+
public class ConfigHelper {
1111

1212
@Getter
1313
private static float blackMarketFenceCut = 0.5f;
@@ -20,6 +20,12 @@ public class ConfigUtils {
2020

2121
private static boolean regulation = true;
2222

23+
@Getter
24+
private static float regulationMaxTier = 0;
25+
26+
@Getter
27+
private static float regulationMaxFP = 0;
28+
2329
private static final SimpleSet regulationFaction = new SimpleSet("faction", "militaryRegulationFaction.csv");
2430

2531
@Getter
@@ -39,6 +45,12 @@ public class ConfigUtils {
3945
"militaryRegulationStability.csv"
4046
);
4147

48+
@Getter
49+
private static boolean removeEndgameCargo = true;
50+
51+
@Getter
52+
private static boolean removeEndgameShips = true;
53+
4254
@Getter
4355
private static boolean shyBlackMarket = false;
4456

@@ -56,6 +68,11 @@ public static void init(JSONObject settings, Logger log) {
5668
transparentMarket(settings, log);
5769
}
5870

71+
public static boolean isUninstall() {
72+
JSONObject settings = Global.getSettings().getSettingsJSON();
73+
return !settings.optBoolean("hasStarpocalypse", false);
74+
}
75+
5976
public static boolean wantsRegulation(String factionId) {
6077
return regulation && regulationFaction.has(factionId);
6178
}
@@ -72,7 +89,11 @@ private static void loadConfig(JSONObject settings) {
7289
minDmods = clamp(settings.optInt("minimumDmods", 2), 1, 5);
7390
maxDmods = clamp(settings.optInt("maximumDmods", 4), minDmods, 5);
7491
regulation = settings.optBoolean("militaryRegulations", true);
75-
shyBlackMarket = settings.optBoolean("shyBlackMarket", false);
92+
regulationMaxFP = settings.optInt("regulationMaxLegalFP", 0);
93+
regulationMaxTier = settings.optInt("regulationMaxLegalTier", 0);
94+
removeEndgameCargo = settings.optBoolean("removeMilitaryEndgameCargo", true);
95+
removeEndgameShips = settings.optBoolean("removeMilitaryEndgameShips", true);
96+
shyBlackMarket = settings.optBoolean("shyBlackMarket", true);
7697
}
7798

7899
private static void transparentMarket(JSONObject settings, Logger log) {

0 commit comments

Comments
 (0)