Split Hull and entity Health into components #2671
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Separate the presence of a Hull (a marker indicating ship-like integrity) from an entity's health by creating a new Health component. This allows the creation of entities that have health and can be weapons targeted, but otherwise aren't treated as having repairable ship hulls for the purposes of AI targeting or threat estimates, and aren't selectable by Science or Relay unless they also have the Hull component.
This remains backward compatible in scripting by translating set/getHull... Lua functions into respective set/getHealth... functions, and adding the Hull component if the set/getHull... functions are used.
This PR does not change the default behaviors of any entities. Existing mechanics and scenario behaviors should remain fully unchanged. The Hull component is retained to ensure that existing entities behave exactly as they did before in player-facing user interfaces, AI targeting, DockingBay repairs, and Relay/Science radars without also requiring arbitrary entities with trackable Health and damage/destruction callbacks to share those properties.
Targeting thus intentionally might not align with GM/scenario writer/player expectations. For example, entities lacking a Faction component and granted Health but no Hull components are Neutral by default faction relationship. This means they can be targeted by weapons and tracked by homing missiles, but can't be fired upon by beam weapons unless granted a hostile FactionRelation, which is consistent with existing behavior.
Such entities also can't be targeted by Science unless granted a Hull, scan description, or level, or targeted by Relay unless granted a Hull or scan state, or share short-range radar, which is consistent with existing behavior of non-Hull entities. If granted a scan state or short-range radar, Relay might present them as hackable but lacking any systems to hack, which is consistent with existing behavior.
With some difficulty, scenario writers and modders can use the Health component to address #2550, or to implement unticketed Discord requests to target and script events on damage and destruction of arbitrary entities, without also giving those entities unwanted ship-like properties via the Hull component. For example, firing beams at asteroids, whether to clear them or to script mining actions on them via callback, would require granting all asteroids a universally hostile faction.