Modding hullmods
Hullmods need an entry in hull_mods.csv which defines it's basic information as well as where it's script is. Hullmod scripts usually extend BaseHullMod (which itself extends HullModEffect). The notes here regarding methods are directly cribbed from code comments in HullModEffect (v0.8.1a-RC8)
Static variables
VERY IMPORTANT The game engine generates a single hullmod script and then re-uses the same script for all ships with that hullmod, unlike shipsystems, weapons and other scripts. This effective means a hullmod cannot have an "instance" variable: all variables are shared by all ship instances concurrently. Please ensure you are familiar with static variables before proceeding to mod hullmods that use any variables.
There are some different ways to circumvent the issue, such as mapping all ship specific variables based on script+ship ID and storing them in the CombatEngineAPI's CustomData (if it's an in-combat effect)
BaseHullMod Methods
applyEffectsBeforeShipCreation
Ship stat changes should go here. Details under Hullmod code call-order
applyEffectsAfterShipCreation
Effects applied here should NOT affect ship stats as this does not get called from the campaign. Apply stat changes in applyEffectsBeforeShipCreation() instead, as that does affect the campaign. Details under Hullmod code call-order
getUnapplicableReason
advanceInCampaign
Not called while paused. But, called when the fleet data needs to be re-synced, with amount=0 (such as if, say, a fleet member is moved around in the fleet screen.)
advanceInCombat
Not called while paused.
affectsOPCosts
Hullmods that return true here should only ever be built-in, as cost changes aren't handled when these mods can be added or removed to/from the variant.
Other
getDescriptionParam string
isApplicableToShip boolean
---
Return to Modding