So, maybe a dumb question, but... I don't understand EventPlugins.
I've created a copy of part of the NearbyEventPlugin thingy. How do I go about adding it to the EventManager? I only see options to start or prime an event, but I just want to add it on a new game so it stays there and spawns distress calls.
EDIT: Actually, what are the advantages of using an EventPlugin over an EveryFrameScript? It looks like the NearbyEventPlugin distress call bit in particular tracks its own timeout, etc, in an IntervalUtil and the advance() method, just like it would as an EveryFrameScript, so...
Yeah, just use an EFS - the NearbyEventsEvent is an event only for historical reasons. It used to be required/handy to send out reports, but since the intel system is completely different, "Events" have lost their purpose, code-wise.
EDIT EDIT: While I'm here and asking questions: How would I go about getting the actual ShipAPI/FleetMemberAPI created as a CustomCampaignEntityAPI derelict? I need to add a custom hullmod to it, no matter what hull it is - so i can't just use a custom variant/hull that always has it - is my goal here. I have a sinking feeling it's not actually created until the player interacts with it, but I'm sure there's a way around that.
DerelictShipEntityPlugin plugin = (DerelictShipEntityPlugin) entity.getCustomPlugin();
plugin.getData().ship <- this is a com.fs.starfarer.api.impl.campaign.rulecmd.salvage.special.ShipRecoverySpecial.
PerShipData
It could be based on a variantId (i.e. ship.variantId != null), or it may be based on a variant (i.e. ship.variant != null). If there's a variant, you can change it however you like.
If it's based on a variantId, you'll need to set the variant first (to... whatever variant you want, really), but that should also work.
@Varya: I'm afraid I don't have much experience with all that. I might get the chance to look into it later though.
(Thank you for helping out here, btw! Much appreciated.)
@MrHoon:
That should be as simple as this:
@Override
public void applyEffectsToFighterSpawnedByShip(ShipAPI fighter, ShipAPI ship, String id) {
fighter.getMutableStats().getArmorBonus().modifyPercent(id, 25);
}
Possibly worth noting: the hullmod needs to be on the carrier, *not* on the fighter.