So I have the following file in my mod's root file:
{
###########
# General #
###########
# How much Aegis Collision Emitters reduces HE damage
"aceMult": 0.75,
# HAM
"HAM": {
"minArmourFraction": 100, # A percentage modifier, so at 100 a 5% min armour becomes a 10% min armour.
"maxDamageReduction": 10 # Also a percentage modifier.
},
# Ordinance Bay Conversion
"ordinanceBayAmmo": 50, # Percentage increase per bay removed
# PD Targeting Focus
"PDT": {
"PDInc": 50, # Percentage increase to PD weapon range
"NonPDReduction": 10, # Percentage reduction to other weapons
},
# Ramburn Engines
"ramburn": {
"charge": 50, # Max speed and acceleration percentage increase
"lumber": 30, # Max turn and turn acceleration percentage decrease
},
# Refined Propellant percentage increase
"rpSpeed": 25,
# Retuned LPCs
"RLPC": {
"speed": 50, # Flat increase to Max, Accel, and Decel
"range": 50, # Percentage increase to engangement range
"refit": 30, # Percentage increase to refit times
},
###########################
# Range:Damage converters #
###########################
# How much damage is equivalent to 1 range
"globalDamagePerRange": 2.5,
# How much percentage range Beam Shear removes
"beamShearReduction": 25,
# Extra Beam Shear damage % based on hull size
"beamShearBoost": {
"frigate": 25,
"destroyer": 25,
"cruiser": 25,
"capital": 25
},
# Percentage range alteration based on captain personality
"silvervaleConversion": {
"timid": 50,
"cautious": 25,
"steady": 0,
"aggressive": -25,
"reckless": -50
},
##########################
# Integrated AI Hullmods #
##########################
# ECM Core percentage bonus
"AIECM": {
"alpha": 5,
"beta": 2,
"gamma": 1
},
# Dynamic Shield Tuning modifiers, must be multiples of 3. Reach must be a multiple of 6.
"DST": {
"speedPercent": 100,
"reachFlat": 60,
"damagePercent": 15
},
# Automated Missile Racks, percentage increase to RoF.
"AMR": {
"alpha": 100,
"beta": 50,
"gamma": 25
},
# Quickstart Protocols, percentage reductions
"QSP": {
"alpha": 50,
"beta": 25,
"gamma": 10
},
# Remote Fighter Network
"RFN": {
"range": 50, # Percentage increase to operations range, acceleration, deceleration, and speed
"damage": 10 # Percentage increase to damage dealt.
}
}
And the following code for a plugin:
package data.plugin;
import com.fs.starfarer.api.Global;
import org.apache.log4j.Logger;
import data.scripts.overlord.SettingsYunru;
public class yunruSettingsLoad extends com.fs.starfarer.api.BaseModPlugin {
private static final Logger log = Global.getLogger(yunruSettingsLoad.class);
@Override
public void onGameLoad(boolean newGame) {
SettingsYunru.loadConstants("yunru_hullmods.json");
log.info("Yunru - onGameLoad ran.");
log.info("Yunru - Commencing checks.");
log.info("Float AIECM_ALPHA: " + SettingsYunru.yunruVariables.AIECM_ALPHA + ".");
log.info("Float AIECM_BETA: " + SettingsYunru.yunruVariables.AIECM_BETA + ".");
log.info("Float AIECM_GAMMA: " + SettingsYunru.yunruVariables.AIECM_GAMMA + ".");
log.info("Float DST_SPD: " + SettingsYunru.yunruVariables.DST_SPD + ".");
log.info("Float DST_REACH: " + SettingsYunru.yunruVariables.DST_REACH + ".");
log.info("Float DST_DMG: " + SettingsYunru.yunruVariables.DST_DMG + ".");
log.info("Float AMR_ALPHA: " + SettingsYunru.yunruVariables.AMR_ALPHA + ".");
log.info("Float AMR_BETA: " + SettingsYunru.yunruVariables.AMR_BETA + ".");
log.info("Float AMR_GAMMA: " + SettingsYunru.yunruVariables.AMR_GAMMA + ".");
log.info("Float HAM_MIN: " + SettingsYunru.yunruVariables.HAM_MIN + ".");
log.info("Float HAM_MAX: " + SettingsYunru.yunruVariables.HAM_MAX + ".");
log.info("Float OBC: " + SettingsYunru.yunruVariables.OBC + ".");
log.info("Float PD_INC: " + SettingsYunru.yunruVariables.PD_INC + ".");
log.info("Float PD_RDC: " + SettingsYunru.yunruVariables.PD_RDC + ".");
log.info("Float QS_ALPHA: " + SettingsYunru.yunruVariables.QS_ALPHA + ".");
log.info("Float QS_BETA: " + SettingsYunru.yunruVariables.QS_BETA + ".");
log.info("Float QS_GAMMA: " + SettingsYunru.yunruVariables.QS_GAMMA + ".");
log.info("Float RAM_INC: " + SettingsYunru.yunruVariables.RAM_INC + ".");
log.info("Float RAM_DEC: " + SettingsYunru.yunruVariables.RAM_DEC + ".");
log.info("Float RP_INC: " + SettingsYunru.yunruVariables.RP_INC + ".");
log.info("Float RFN_A: " + SettingsYunru.yunruVariables.RFN_A + ".");
log.info("Float RFN_B: " + SettingsYunru.yunruVariables.RFN_B + ".");
log.info("Float RLPC_SPD: " + SettingsYunru.yunruVariables.RLPC_SPD + ".");
log.info("Float RLPC_ENGAGE: " + SettingsYunru.yunruVariables.RLPC_ENGAGE + ".");
log.info("Float RLPC_REFIT: " + SettingsYunru.yunruVariables.RLPC_REFIT + ".");
log.info("Float DMG_RNG_RATIO: " + SettingsYunru.yunruVariables.DMG_RNG_RATIO + ".");
log.info("Float BS_RNG_REDUCTION: " + SettingsYunru.yunruVariables.BS_RNG_REDUCTION + ".");
log.info("Float BS_BOOST_FRIGATE: " + SettingsYunru.yunruVariables.BS_BOOST_FRIGATE + ".");
log.info("Float BS_BOOST_DESTROYER: " + SettingsYunru.yunruVariables.BS_BOOST_DESTROYER + ".");
log.info("Float BS_BOOST_CRUISER: " + SettingsYunru.yunruVariables.BS_BOOST_CRUISER + ".");
log.info("Float BS_BOOST_CAPITAL: " + SettingsYunru.yunruVariables.BS_BOOST_CAPITAL + ".");
log.info("Float SVC_TIMID: " + SettingsYunru.yunruVariables.SVC_TIMID + ".");
log.info("Float SVC_CAUTIOUS: " + SettingsYunru.yunruVariables.SVC_CAUTIOUS + ".");
log.info("Float SVC_STEADY: " + SettingsYunru.yunruVariables.SVC_STEADY + ".");
log.info("Float SVC_AGGRESSIVE: " + SettingsYunru.yunruVariables.SVC_AGGRESSIVE + ".");
log.info("Float SVC_RECKLESS: " + SettingsYunru.yunruVariables.SVC_RECKLESS + ".");
}
}
With SettingsYunru looking like this:
package data.scripts.overlord;
import java.io.IOException;
import com.fs.starfarer.api.Global;
import org.json.JSONException;
import org.json.JSONObject;
public class SettingsYunru {
public static class yunruVariables {
public static float ACE_MULT;
public static float AIECM_ALPHA;
public static float AIECM_BETA;
public static float AIECM_GAMMA;
public static float DST_SPD;
public static float DST_REACH;
public static float DST_DMG;
public static float AMR_ALPHA;
public static float AMR_BETA;
public static float AMR_GAMMA;
public static float HAM_MIN;
public static float HAM_MAX;
public static float OBC;
public static float PD_INC;
public static float PD_RDC;
public static float QS_ALPHA;
public static float QS_BETA;
public static float QS_GAMMA;
public static float RAM_INC;
public static float RAM_DEC;
public static float RP_INC;
public static float RFN_B;
public static float RFN_A;
public static float RLPC_SPD;
public static float RLPC_ENGAGE;
public static float RLPC_REFIT;
public static float DMG_RNG_RATIO;
public static float BS_RNG_REDUCTION;
public static float BS_BOOST_FRIGATE;
public static float BS_BOOST_DESTROYER;
public static float BS_BOOST_CRUISER;
public static float BS_BOOST_CAPITAL;
public static float SVC_TIMID;
public static float SVC_CAUTIOUS;
public static float SVC_STEADY;
public static float SVC_AGGRESSIVE;
public static float SVC_RECKLESS;
/** Load constants from a json file */
private static void load(String filePath) throws IOException, JSONException {
JSONObject json = Global.getSettings().loadJSON(filePath);
ACE_MULT = (float) json.getDouble("aceMult");
JSONObject aiecm = json.getJSONObject("AIECM");
AIECM_ALPHA = (float) aiecm.getDouble("alpha");
AIECM_BETA = (float) aiecm.getDouble("beta");
AIECM_GAMMA = (float) aiecm.getDouble("gamma");
JSONObject dst = json.getJSONObject("DST");
DST_SPD = (float) dst.getDouble("speedPercent");
DST_REACH = (float) dst.getDouble("reachFlat");
DST_DMG = (float) dst.getDouble("damagePercent");
JSONObject amr = json.getJSONObject("AMR");
AMR_ALPHA = (float) amr.getDouble("alpha");
AMR_BETA = (float) amr.getDouble("beta");
AMR_GAMMA = (float) amr.getDouble("gamma");
JSONObject ham = json.getJSONObject("HAM");
HAM_MAX = (float) ham.getDouble("maxDamageReduction");
HAM_MIN = (float) ham.getDouble("minArmourFraction");
OBC = (float) json.getDouble("ordinanceBayAmmo");
JSONObject pdf = json.getJSONObject("PDT");
PD_INC = (float) pdf.getDouble("PDInc");
PD_RDC = (float) pdf.getDouble("NonPDReduction");
JSONObject qsp = json.getJSONObject("QSP");
QS_ALPHA = (float) qsp.getDouble("alpha");
QS_BETA = (float) qsp.getDouble("beta");
QS_GAMMA = (float) qsp.getDouble("gamma");
JSONObject ram = json.getJSONObject("ramburn");
RAM_DEC = (float) ram.getDouble("lumber");
RAM_INC = (float) ram.getDouble("charge");
RP_INC = (float) json.getDouble("rpSpeed");
JSONObject rfn = json.getJSONObject("RFN");
RFN_A = (float) rfn.getDouble("damage");
RFN_B = (float) rfn.getDouble("range");
JSONObject rlpc = json.getJSONObject("RLPC");
RLPC_SPD = (float) rlpc.getDouble("speed");
RLPC_ENGAGE = (float) rlpc.getDouble("range");
RLPC_REFIT = (float) rlpc.getDouble("refit");
DMG_RNG_RATIO = (float) json.getDouble("globalDamagePerRange");
BS_RNG_REDUCTION = (float) json.getDouble("beamShearReduction");
JSONObject bsBoost = json.getJSONObject("beamShearBoost");
BS_BOOST_FRIGATE = (float) bsBoost.getDouble("Frigate");
BS_BOOST_DESTROYER = (float) bsBoost.getDouble("Destroyer");
BS_BOOST_CRUISER = (float) bsBoost.getDouble("Cruiser");
BS_BOOST_CAPITAL = (float) bsBoost.getDouble("Capital");
JSONObject svConversion = json.getJSONObject("silvervaleConversion");
SVC_TIMID = (float) svConversion.getDouble("Timid");
SVC_CAUTIOUS = (float) svConversion.getDouble("Cautious");
SVC_STEADY = (float) svConversion.getDouble("Steady");
SVC_AGGRESSIVE = (float) svConversion.getDouble("Aggressive");
SVC_RECKLESS = (float) svConversion.getDouble("Reckless");
}
}
public static void loadConstants(String filePath) {
try {
yunruVariables.load(filePath);
} catch (IOException | JSONException e) {
e.printStackTrace();
}
}
}
So what this
should be doing is reading the values from the file and assigning the to the variables. However, what's printed to the log makes things very, very confusing:
16557 [Thread-3] INFO data.plugin.yunruSettingsLoad - Yunru - onGameLoad ran.
16557 [Thread-3] INFO data.plugin.yunruSettingsLoad - Yunru - Commencing checks.
16557 [Thread-3] INFO data.plugin.yunruSettingsLoad - Float AIECM_ALPHA: 5.0.
16557 [Thread-3] INFO data.plugin.yunruSettingsLoad - Float AIECM_BETA: 2.0.
16557 [Thread-3] INFO data.plugin.yunruSettingsLoad - Float AIECM_GAMMA: 1.0.
16557 [Thread-3] INFO data.plugin.yunruSettingsLoad - Float DST_SPD: 100.0.
16557 [Thread-3] INFO data.plugin.yunruSettingsLoad - Float DST_REACH: 60.0.
16557 [Thread-3] INFO data.plugin.yunruSettingsLoad - Float DST_DMG: 15.0.
16557 [Thread-3] INFO data.plugin.yunruSettingsLoad - Float AMR_ALPHA: 100.0.
16557 [Thread-3] INFO data.plugin.yunruSettingsLoad - Float AMR_BETA: 50.0.
16557 [Thread-3] INFO data.plugin.yunruSettingsLoad - Float AMR_GAMMA: 25.0.
16558 [Thread-3] INFO data.plugin.yunruSettingsLoad - Float HAM_MIN: 100.0.
16558 [Thread-3] INFO data.plugin.yunruSettingsLoad - Float HAM_MAX: 10.0.
16558 [Thread-3] INFO data.plugin.yunruSettingsLoad - Float OBC: 50.0.
16558 [Thread-3] INFO data.plugin.yunruSettingsLoad - Float PD_INC: 50.0.
16558 [Thread-3] INFO data.plugin.yunruSettingsLoad - Float PD_RDC: 10.0.
16558 [Thread-3] INFO data.plugin.yunruSettingsLoad - Float QS_ALPHA: 50.0.
16558 [Thread-3] INFO data.plugin.yunruSettingsLoad - Float QS_BETA: 25.0.
16558 [Thread-3] INFO data.plugin.yunruSettingsLoad - Float QS_GAMMA: 10.0.
16558 [Thread-3] INFO data.plugin.yunruSettingsLoad - Float RAM_INC: 50.0.
16558 [Thread-3] INFO data.plugin.yunruSettingsLoad - Float RAM_DEC: 30.0.
16558 [Thread-3] INFO data.plugin.yunruSettingsLoad - Float RP_INC: 25.0.
16558 [Thread-3] INFO data.plugin.yunruSettingsLoad - Float RFN_A: 10.0.
16558 [Thread-3] INFO data.plugin.yunruSettingsLoad - Float RFN_B: 50.0.
16558 [Thread-3] INFO data.plugin.yunruSettingsLoad - Float RLPC_SPD: 50.0.
16558 [Thread-3] INFO data.plugin.yunruSettingsLoad - Float RLPC_ENGAGE: 50.0.
16558 [Thread-3] INFO data.plugin.yunruSettingsLoad - Float RLPC_REFIT: 30.0.
16558 [Thread-3] INFO data.plugin.yunruSettingsLoad - Float DMG_RNG_RATIO: 2.5.
16558 [Thread-3] INFO data.plugin.yunruSettingsLoad - Float BS_RNG_REDUCTION: 25.0.
16558 [Thread-3] INFO data.plugin.yunruSettingsLoad - Float BS_BOOST_FRIGATE: 0.0.
16558 [Thread-3] INFO data.plugin.yunruSettingsLoad - Float BS_BOOST_DESTROYER: 0.0.
16558 [Thread-3] INFO data.plugin.yunruSettingsLoad - Float BS_BOOST_CRUISER: 0.0.
16558 [Thread-3] INFO data.plugin.yunruSettingsLoad - Float BS_BOOST_CAPITAL: 0.0.
16558 [Thread-3] INFO data.plugin.yunruSettingsLoad - Float SVC_TIMID: 0.0.
16559 [Thread-3] INFO data.plugin.yunruSettingsLoad - Float SVC_CAUTIOUS: 0.0.
16559 [Thread-3] INFO data.plugin.yunruSettingsLoad - Float SVC_STEADY: 0.0.
16559 [Thread-3] INFO data.plugin.yunruSettingsLoad - Float SVC_AGGRESSIVE: 0.0.
16559 [Thread-3] INFO data.plugin.yunruSettingsLoad - Float SVC_RECKLESS: 0.0.
As you can see, it just... stops working, 8 from the bottom of the list. No crashes or anything, but obviously non-functional.
I am completely lost as to what could be going on, any ideas?