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

New Submarket Implementation #22

Merged
merged 23 commits into from Jan 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion .vscode/settings.json
Expand Up @@ -2,5 +2,5 @@
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnSave": true,
"java.configuration.updateBuildConfiguration": "automatic",
"cSpell.words": ["Luddic", "modspecs", "Nanoforge", "Nexerelin"]
"cSpell.words": ["Dmods", "Luddic", "modspecs", "Nanoforge", "Nexerelin"]
}
8 changes: 4 additions & 4 deletions assets/data/campaign/submarkets.csv
Expand Up @@ -2,19 +2,19 @@ id,name,faction,desc,script,icon,order
regulated_open_market,"Open
Market",,"The open market. Only legal goods may be traded here, and transactions are subject to tariffs. More goods are available when stability is high.

Selling enough of a commodity will temporarily resolve a shortage.",starpocalypse.submarket.plugin.RegulatedOpenMarket,,0
Selling enough of a commodity will temporarily resolve a shortage.",starpocalypse.submarket.RegulatedOpenMarket,,0
regulated_black_market,"Black
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.

Selling a commodity will not resolve a shortage.

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.

Engaging in legitimate trade as a ""cover"" also reduces the probability of attracting the attention of authorities.",starpocalypse.submarket.plugin.RegulatedBlackMarket,graphics/factions/black_market.png,999
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
regulated_generic_military,,,"Trade with $theFaction military base.

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.

Will buy locally illegal goods as part of a no-questions-asked buyback program.
Will buy locally illegal goods as part of a no-questions-asked buyback program. Will also sell normally illegal items while stability is low.

Selling enough of a commodity will temporarily resolve a shortage.",starpocalypse.submarket.plugin.RegulatedMilitaryMarket,,100
Selling enough of a commodity will temporarily resolve a shortage.",starpocalypse.submarket.RegulatedMilitaryMarket,,100
2 changes: 1 addition & 1 deletion assets/mod_info.json
Expand Up @@ -3,7 +3,7 @@
"name": "Starpocalypse",
"author": "Jaghaimo",
"utility": true,
"version": "2.1.1",
"version": "2.2.0",
"description": "More apocalyptic settings for Starsector",
"gameVersion": "0.95.1a-RC6",
"modPlugin": "starpocalypse.StarpocalypseMod",
Expand Down
3 changes: 0 additions & 3 deletions assets/settings/militaryContrabandBlacklist.csv

This file was deleted.

@@ -1,4 +1,6 @@
name
supplies
fuel
Mining Laser
Mining Blaster
PD Laser
Expand Down
@@ -1,4 +1,4 @@
stability,ship,cargo
stability,ship,item
9,20000,251
8,30000,501
7,40000,1001
Expand Down
2 changes: 0 additions & 2 deletions assets/settings/militaryRegulationSubmarket.csv

This file was deleted.

40 changes: 29 additions & 11 deletions assets/starpocalypse.json
@@ -1,4 +1,17 @@
{
## UTILITY MOD - READ THIS BEFORE ENABLING!
# Traditionally, Starpocalypse has been a utility mod, meaning you can disable the mod at will without breaking
# your save. Unfortunately, the new implementation requires additional API methods to be added in order to correctly
# persist progress while still being a utility mod. As such, I have decided to temporarily BREAK the utility
# aspect of the mod. To enable utility aspect of the mod, set below to true. The consequence of playing with
# `isUtility` enabled is:
# 1. Suspicion level will reset each time you save. Trade on black market and get suspicion level to say `extreme`,
# leave the market, save the game, dock and notice suspicion level dropping to `none`.
# 2. Delayed reputation change due to legal or illegal trade will not happen if you save too early after the trade.
# This option will be removed (and mod becomes a true utility mod again) once new API calls are released.
# For details see: https://fractalsoftworks.com/forum/index.php?topic=23826
"isUtility": false,

## D-MODS FOR ALL
# Damage pristine ships that the player can buy.
"addDmodsToShipsInSubmarkets": true,
Expand All @@ -9,25 +22,30 @@
"minimumDmods": 2,
"maximumDmods": 4,

## MILITARY REGULATIONS AND CONTRABAND
# Buying or selling marines, weapons, LPCs, or combat ships is illegal unless you are commissioned with the owner
# of the market. All affected items and ships are moved to Military Market (if present) or removed.
"militaryRegulation": true,
# Depending on the stability, some regulated items "magically" appear in the Black Market. The lower the stability
# the bigger pool of items and ships gets leaked. Requires military regulations to work.
"militaryContraband": true,

## MILITARY REGULATIONS
# Buying or selling military wares Open Market is illegal unless you are commissioned with the owner of the market.
# Uses same logic as Military market with the addition of:
# - Legal list is applied to make item or ship always legal,
# - All civ-grade or civ-hint ships are always legal.
"militaryRegulations": true,
# Suspicion level will grow even with transponder off. It is still useful to sell illegal wares.
"transparentMarket": true,
# Setting this to 0 essentially disabled the feature. Setting this to 1 makes it behave as if the transponder was on
# for suspicion calculations. Setting it above 1 will cause a penalty for trading with transponder off.
"transparentMarketMult": 0.5,
# Accessing black market is only possible with transponder turned off.
"shyBlackMarket": false,

## BETTER MARKET DEFENCES
# Adds a tier 1 station to all non-hidden markets that do not have a station.
"addStations": true,
# Add extra structures to eligible markets (Ground Defenses to all markets and Patrol HQ to core markets).
"addGroundDefenses": true,
"addPatrolHq": true,
"addPatrolHqs": true,

## OTHER
## REPUTATION CHANGES
# After winning an engagement, the enemies of the beaten fleet will have a slightly better reputation of you.
# Their allies will dislike you slightly more though.
# Their allies will dislike you slightly more, though.
"combatAdjustedReputation": true,
# Raiding for special items instantly ruins player reputation with the owner of the item.
"hostilityForSpecialItemRaid": true,
Expand Down
6 changes: 3 additions & 3 deletions assets/starpocalypse.version
Expand Up @@ -4,8 +4,8 @@
"modThreadId": 21812,
"modVersion": {
"major": 2,
"minor": 1,
"patch": 1
"minor": 2,
"patch": 0
},
"directDownloadURL": "https://github.com/jaghaimo/starpocalypse/releases/download/2.1.1/starpocalypse-2.1.1.zip"
"directDownloadURL": "https://github.com/jaghaimo/starpocalypse/releases/download/2.2.0/starpocalypse-2.2.0.zip"
}
28 changes: 14 additions & 14 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

96 changes: 56 additions & 40 deletions src/starpocalypse/StarpocalypseMod.java
Expand Up @@ -2,53 +2,90 @@

import com.fs.starfarer.api.BaseModPlugin;
import com.fs.starfarer.api.Global;
import com.fs.starfarer.api.fleet.FleetMemberAPI;
import com.fs.starfarer.api.impl.campaign.ids.Industries;
import com.fs.starfarer.api.impl.campaign.shared.SharedData;
import java.util.List;
import lombok.extern.log4j.Log4j;
import org.json.JSONObject;
import starpocalypse.helper.ConfigUtils;
import starpocalypse.market.IndustryAdder;
import starpocalypse.market.MarketListener;
import starpocalypse.market.StationAdder;
import starpocalypse.reputation.EngagementListener;
import starpocalypse.reputation.RaidListener;
import starpocalypse.submarket.MilitaryContraband;
import starpocalypse.submarket.MilitaryRegulation;
import starpocalypse.submarket.ShipDamager;
import starpocalypse.submarket.SubmarketListener;
import starpocalypse.submarket.SubmarketSwapper;

@Log4j
public class StarpocalypseMod extends BaseModPlugin {

private JSONObject settings;
private static JSONObject settings;

@Override
public void onApplicationLoad() throws Exception {
settings = Global.getSettings().loadJSON("starpocalypse.json");
ConfigUtils.init(settings, log);
}

@Override
public void onNewGameAfterTimePass() {
MarketListener listener = new MarketListener();
addDmodsToStartingFleet();
}

@Override
public void onGameLoad(boolean newGame) {
addDmodsToShipsInSubmarkets();
militaryRegulations();
industryChanges();
combatAdjustedReputation();
hostilityForSpecialItemRaid();
}

@Override
public void beforeGameSave() {
if (ConfigUtils.isUtility()) {
log.info("Replacing regulated submarkets with vanilla variants");
SubmarketSwapper.uninstall();
SharedData.getData().getPlayerActivityTracker().advance(0);
}
}

private void industryChanges() {
MarketListener listener = new MarketListener();
addGroundDefenses(listener);
addPatrolHq(listener);
addPatrolHqs(listener);
addStations(listener);
listener.register();
}

private void addDmodsToShipsInSubmarkets() {
if (settings.optBoolean("addDmodsToShipsInSubmarkets", true)) {
log.info("Enabling ship damager in submarkets");
ShipDamager.register();
}
}

private void addDmodsToStartingFleet() {
if (settings.optBoolean("addDmodsToStartingFleet", true)) {
StartingFleetDamager.apply(settings);
log.info("Damaging starting fleet");
List<FleetMemberAPI> members = Global.getSector().getPlayerFleet().getFleetData().getMembersListCopy();
ShipDamager.apply("player fleet", members);
}
}

private void addGroundDefenses(MarketListener listener) {
if (settings.optBoolean("addGroundDefenses", true)) {
log.info("Enabling ground defenses adder");
listener.add(
new IndustryAdder(Industries.GROUNDDEFENSES, true, Industries.GROUNDDEFENSES, Industries.HEAVYBATTERIES)
);
}
}

private void addPatrolHq(MarketListener listener) {
if (settings.optBoolean("addPatrolHq", true)) {
private void addPatrolHqs(MarketListener listener) {
if (settings.optBoolean("addPatrolHqs", true)) {
log.info("Enabling patrol hq adder");
listener.add(
new IndustryAdder(
Industries.PATROLHQ,
Expand All @@ -63,50 +100,29 @@ private void addPatrolHq(MarketListener listener) {

private void addStations(MarketListener listener) {
if (settings.optBoolean("addStations", true)) {
log.info("Enabling station adder");
listener.add(new StationAdder());
}
}

@Override
public void onGameLoad(boolean newGame) {
SubmarketListener listener = new SubmarketListener();
addDmodsToShipsInSubmarkets(listener);
militaryRegulation(listener);
militaryContraband(listener);
combatAdjustedReputation();
hostilityForSpecialItemRaid();
listener.register();
}

private void hostilityForSpecialItemRaid() {
if (settings.optBoolean("hostilityForSpecialItemRaid", true)) {
RaidListener.register();
}
}

private void combatAdjustedReputation() {
if (settings.optBoolean("combatAdjustedReputation", true)) {
log.info("Enabling combat adjusted reputation");
EngagementListener.register();
}
}

private void addDmodsToShipsInSubmarkets(SubmarketListener listener) {
if (settings.optBoolean("addDmodsToShipsInSubmarkets", true)) {
int minDmods = settings.optInt("minimumDmods", 2);
int maxDmods = settings.optInt("maximumDmods", 4);
listener.add(new ShipDamager(minDmods, maxDmods));
}
}

private void militaryRegulation(SubmarketListener listener) {
if (settings.optBoolean("militaryRegulation", true)) {
listener.add(new MilitaryRegulation());
private void hostilityForSpecialItemRaid() {
if (settings.optBoolean("hostilityForSpecialItemRaid", true)) {
log.info("Enabling hostility for special item raid");
RaidListener.register();
}
}

private void militaryContraband(SubmarketListener listener) {
if (settings.optBoolean("militaryContraband", true)) {
listener.add(new MilitaryContraband());
private void militaryRegulations() {
if (settings.optBoolean("militaryRegulations", true)) {
log.info("Enabling military regulations");
SubmarketSwapper.register();
}
}
}
27 changes: 0 additions & 27 deletions src/starpocalypse/StartingFleetDamager.java

This file was deleted.