Here's an updated copy of my code:
package data.hullmods;
import com.fs.starfarer.api.combat.MutableShipStatsAPI;
import com.fs.starfarer.api.combat.ShipAPI.HullSize;
import com.fs.starfarer.api.impl.campaign.ids.Commodities;
import com.fs.starfarer.api.impl.campaign.ids.Stats;
import com.fs.starfarer.api.impl.hullmods.BaseLogisticsHullMod;
public class AutoSurvey extends BaseLogisticsHullMod {
public void applyEffectsBeforeShipCreation(HullSize hullSize, MutableShipStatsAPI stats, String id) {
stats.getDynamic().getMod(Stats.getSurveyCostReductionId(Commodities.CREW)).modifyFlat(id, 200f);
}
public String getDescriptionParam(int index, HullSize hullSize) {
return "" + (200f);
}
}
It is regrettably still nonfunctional.
EDIT:
Ok, I've narrowed down the issue a bit more. It looks like SurveyPluginImpl.java contains code which counts up the number of ships in the fleet with hullmods (like the basic Surveying Equipment) that reduce the machinery and supply requirements of a survey, and then factors in that number when calculating the final requirement. The code I've written above associates a certain id- the survey cost reduction id- with the ship that has the hullmod; it is this id that is counted by the code in SurveyPluginImpl. The survey cost reduction id is a string constructed from the id of the provided commodity variable appended to "survey_cost_reduction_".
My problem is that SurveyPluginImpl counts occurrences of "survey_cost_reduction_supplies" and "survey_cost_reduction_heavy_machinery", but not "survey_cost_reduction_crew". So, if I want to get the hullmod working, I need to find some way to modify SurveyPluginImpl and add a clause which counts "survey_cost_reduction_crew" occurrences and adds them to the calculation. I'm stumped on how to do that, though, short of manually editing the base game's original SurveyPluginImpl.java file.
Any advice?
EDIT 2, IN THE POSSIBLY VAIN HOPE THAT SOMEONE WILL BE IMPRESSED BY MY INDEPENDENT EFFORTS AND THROW ME A BONE:
So, I created a new script by the name of SurveyPluginImplEx.java and put it in my jar directory at data.scripts.plugins. I also created a settings.json file in my ordinary mod directory at data/config, and pointed to my new script as follows:
{
"plugins":{
"SurveyPluginImplEx":"data.scripts.plugins.SurveyPluginImplEx",
}
}
The code in SurveyPluginImplEx.java is identical to that of the original SurveyPluginImpl.java, save for a few lines I added into the getRequired function.
Here's the original:
public Map<String, Integer> getRequired() {
Map<String, Integer> result = new LinkedHashMap<String, Integer>();
float mult = getCostMult().getModifiedValue();
int machinery = (int)Math.round(BASE_MACHINERY * mult);
machinery -= (int) Misc.getFleetwideTotalMod(fleet, Stats.getSurveyCostReductionId(Commodities.HEAVY_MACHINERY), 0);
machinery = Math.round(machinery / 10f) * 10;
if (machinery < MIN_SUPPLIES_OR_MACHINERY) machinery = MIN_SUPPLIES_OR_MACHINERY;
result.put(Commodities.HEAVY_MACHINERY, machinery);
result.put(Commodities.CREW, (int)Math.round((int)(BASE_CREW * mult) / 10f) * 10);
return result;
}
And here's my new version:
public Map<String, Integer> getRequired() {
Map<String, Integer> result = new LinkedHashMap<String, Integer>();
float mult = getCostMult().getModifiedValue();
int machinery = (int)Math.round(BASE_MACHINERY * mult);
machinery -= (int) Misc.getFleetwideTotalMod(fleet, Stats.getSurveyCostReductionId(Commodities.HEAVY_MACHINERY), 0);
machinery = Math.round(machinery / 10f) * 10;
if (machinery < MIN_SUPPLIES_OR_MACHINERY) machinery = MIN_SUPPLIES_OR_MACHINERY;
result.put(Commodities.HEAVY_MACHINERY, machinery);
int crew = (int)Math.round(BASE_CREW * mult);
crew = Math.round(crew / 10f) * 10;
crew -= (int) Misc.getFleetwideTotalMod(fleet, Stats.getSurveyCostReductionId(Commodities.CREW), 0);
if (crew < MIN_CREW) crew = MIN_CREW;
result.put(Commodities.CREW, crew);
return result;
}
Finally, I created the MIN_CREW static variable near the top of the file and set it to 0, then compiled the whole thing.
The game is running still, so I know that I didn't mess anything up too badly at least, but as the astute reader can likely surmise, I'm still not seeing any effects in-game. Surveys require just as much
crew as they used to. It feels like the further I try to progress on my own, the more points of potential failure I'm adding, so I'd really appreciate it if someone would take a look over what I have so far and point out where I've gone wrong.
My current suspicion is that I need to do something to get the script running besides just linking to it in the settings file, probably something related to its modPlugin class. However, I have no earthly idea what exactly I'm supposed to do. Any help would be appreciated.
Thank you all so much for your help!