Hmm - stats.getFleetMember().getFleetData().getFleet() or some such? Making sure to separate that out into steps and check that each return value is not null, otherwise this would be asking for a crash in some random circumstance (i.e. that hullmod being on a ship in a main-menu mission, or some such).
Thank you for the quick reply! I tried something like this to check if the fleet has the hullmod I need, but it seems my checks are failing:
Spoiler
private boolean doesFleetHaveGravEngines(ShipAPI ship) {
log.info("Check Fleet Member");
if(ship.getFleetMember() != null) {
log.info("Fleet member exist :: check fleet data");
if(ship.getFleetMember().getFleetData() != null) {
CampaignFleetAPI fleet = ship.getFleetMember().getFleetData().getFleet();
log.info("Fleet data exist :: check fleet");
if(fleet != null) {
log.info("Fleet exist :: check members");
List<FleetMemberAPI> members = fleet.getFleetData().getMembersListCopy();
log.info("Member count" + members.size() + ":: check individually");
for(FleetMemberAPI member : members) {
log.info("Member found" + member.getHullId() + ":: check if has Grav engines");
if(member.getVariant().hasHullMod("aria_GravEngines")) {
log.info("Found member with grav engines; returning");
return true;
}
}
}
}
}
return false;
}
The logs only get to this line,
log.info("Check Fleet Member");
...which means that the ship doesn't have a fleet member? I tried this both in the mission preparation screen and in the campaign, with the same behavior on both...
EDIT2: Oh, and in case it's relevant, I call the above function in this part of the hullmod API:
Spoiler
@Override
public boolean isApplicableToShip(ShipAPI ship) {
if(!doesFleetHaveGravEngines(ship)) return false;
if(ship.getVariant().hasHullMod("aria_GravEngines")) return false;
return true;
}
...and again in getUnapplicableReason()
I'd do an EveryFrameScript and query the sector clock for the date periodically. Or use a DelayedActionScript, if you know the exact number of days to wait.
Thank you for this too! I just tried this out now and it's just what I needed!