Skip to content

Add an "On Ship Damage" script hook - #7894

Open
BTawaifi wants to merge 1 commit into
scp-fs2open:masterfrom
BTawaifi:feature/on-ship-damage-hook
Open

BTawaifi wants to merge 1 commit into
scp-fs2open:masterfrom
BTawaifi:feature/on-ship-damage-hook

Conversation

@BTawaifi

Copy link
Copy Markdown

Split out of #7874.

Adds On Ship Damage, called after resolved damage has been applied to a ship. It reports what the ship actually lost, after shields, armor and difficulty scaling, which the existing collision hooks (called before damage is resolved) cannot. Lethal hits run before the ship's death processing.

Hook variables: Target, Source (nil if none), Attacker (the firing ship or parent, nil if none), WeaponClass, WeaponSubtype, SourceKind (PROJECTILE, BEAM, SHOCKWAVE, COLLISION, OTHER), DamageType, ShieldDamage, HullDamage, Quadrant, Ballistic, BeamWeapon, LethalHit. Conditions can filter on the target ship.

Use case: balancing scripted missions and mods (e.g. tuning how much damage a given beam or turret does to a base) from logged traces rather than by eye.

Cost when unused: one isActive() check per damage event; nothing else is computed unless a script registers the hook.

For review: WeaponClass is passed as the class name string (NON_WEAPON when there is none). If a weaponclass handle is preferred, that is easy to change before this is merged.

Testing: a 240-second retail mission with a script tallying the hook: 324 events, 5 lethal, none with zero damage or an invalid target. A no-source explosion (explosion-effect with no shockwave) arrives with Source == nil (in #7874's version it was an invalid handle). Builds alone on this branch.

Runs after resolved damage has been applied to a ship (lethal hits run before
the destruction callback). Hook variables: Target, Source, Attacker,
WeaponClass, WeaponSubtype, SourceKind (PROJECTILE, BEAM, SHOCKWAVE, COLLISION,
OTHER), DamageType, ShieldDamage, HullDamage, Quadrant, Ballistic, BeamWeapon
and LethalHit. Conditions can filter on the target ship. Nothing is computed
unless a script has registered the hook.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant