* Add an "On Ship Damage" script hook
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.
* Move the On Ship Damage hook call out of a lambda
ship_do_damage() now calls a file-level static function, ship_run_damage_hook(), that takes the values it needs as arguments instead of capturing the function state. Hook behaviour is unchanged.
* Report subsystem damage in the On Ship Damage hook
Adds SubsystemDamage, the total subsystem strength a damage application removed, so a hit absorbed by subsystems no longer looks like a small hull hit. The hook description now says it only runs where damage is applied, which excludes multiplayer clients.
* Address On Ship Damage review comments
- Remove WeaponClass, WeaponSubtype, Ballistic and BeamWeapon from the
hook. Scripts read these from Source when it is a weapon.
- Add a "Weapon class" condition for the On Ship Damage hook. It matches
only when the damage source is a weapon of that class; a weapon name
that does not exist never matches.
- SubsystemDamage is now a table keyed by subsystem handle that lists only
the subsystems that lost strength. The total is removed.
- Rename PROJECTILE to NON_BEAM_WEAPON.
- Classify SourceKind by damage source: COLLISION for ship, debris and
asteroid collisions; EXPLOSION for ship-death and docked-ship blasts and
asteroid blasts; WASH for engine wash; SELF for kills where the ship
damages itself; OTHER for other ship-sourced damage.
- Reword the hook description.
* Key On Ship Damage SubsystemDamage by canonical name
Lua tables cannot use subsystem handles as keys in a usable way, so key
the SubsystemDamage table by each subsystem's CanonicalName instead.
* Tag ship-vs-prop damage as a collision and use in_bounds
The ship-vs-prop collision call didn't pass DamageSource::Collision, so
the On Ship Damage hook reported those hits as OTHER. Every other
collision path was already tagged.
Also use SCP_vector::in_bounds() for the Weapon_info and Damage_types
index checks in ship_run_damage_hook().
* framework for support ship rearm pool and flags
* scripting api
* FRED support
* QtFRED support
* do not save non-player-allowed weapons
* tvt and mission versioning
* fix variable name
* minor fixes and clarity
* oops
* add qtfred help docs
* fixes and cleanup
* clang and readability
* address feedback
* address feedback
* new mine weapon type
* some fixes and cleanup
* fix some parsing issues
* make sure mines get plotted
* make mine spawned objects can get a correct target
* some cleanup and additional features
* chasing mines
* some Lua tweaks
* generalize proximity detonations
* minor tweaks
* collapse namespace
* address feedback
* Implement Photo Mode
* fix gr string errors
* return raw char array
* control conflict groups and better photo param defines
* better param identification in real time
* make photo mode hude dynamically sized
* fix xstrs after all changes
* missed a few
* use modern loop
* First draft of prop object type
* Add prop editor dialog in FRED
* prop sexps
* lua table prop support
* lab support
* lua mission access to props
* prop collision support
* use std::optional so the object->instance id is always valid
* allow props to block suns
* minor cleanup and remove arbitrary limit. Still limited to 500 objects.
* Sort props by category
* cleanup
* implement collision hooks
* parse prop flags and further ensure props are inited and closed correctly
* Add Cyborg's multi suggestions
* fix missing header
* add props to empty slots if available
* add multi signature
* fix rebase issues and match collisions to the new multithread style
* appease Clang the Conquerer
* save/parse mission prop classes by name
* Clean up comments and finish TODOs
* fix string errors
* clang wants this to be static now
* address feedback
* address feedback
* Use model num from prop info instead
* merge prop and ship collision group sexps together
* fix rebase bug
* address feedback
* fix name shadowing
* ship heavy submodel
* clang
---------
Co-authored-by: Asteroth <[email protected]>
The object and ship indexes held by the ship registry do not actually need to be cleared until `ship_cleanup` completes. This will allow the ship to be referenced in any functions (via script hooks or otherwise) that are called during cleanup.
Tweak related script documentation while we're at it.
Follow-up to #7120. Fixes#7122.
* lua access to the comm board menu
* On Order Issued Lua Hook
* Some cleanup and safety checks
* Add mn.sendBuiltinMessage and perform more cleanup
* Send the correct ship to the hook for Sender
* clang cleanup
* address feedback
* fix build errors introduced from upstream
* basic hook conditions
* properly link the condition and the oswpt struct
* some requested cleanup
* allow for sending custom built-in messages
* address more feedback
* more prefix
* Create scripting hook: 'On Options Menu Closed'
Complements #6591. This PR creates a hook, 'On Options Menu Closed' that provides a hook variable of `hv.OptionsAccepted` which is true if the options are accepted/saved, false if the options are discarded and not accepted/saved.
* Create scripting hook: 'On Options Menu Tab Changed'
It would be very useful to know which options tab is active (IE Options, Multi, Detail) but it's all under one single Game State `GS_STATE_OPTIONS_MENU`.
This PR creates a hook, 'On Options Menu Tab Changed' that returns the value of the newly switched to options tab. Lafiel and I both discussed making this an ENUM, but the ENUM list is already quite bloated and this integer value seems like the cleanest solution.
Tested and works as expected.
* fix description typo
Add an `$On Movie About To Play:` hook to match `$On Intro About To Play:`. Also make the two hooks overridable, since that might be useful.
Additionally, change a few (nonexhaustive) `name` parameters to `filename` to make it clearer that the string is a filename.
* Clean unneeded properties
* properly queue-ify keys
* Refactor key checking to use functions instead of globals
* Update hooks and cache checked-against key
* Documentation and Naming
* match tilde
* only remove control not debug
Since the On Ship Collision hook can potentially be called twice, with the ships reversed, it is necessary for both parameters to have submodels specified. Otherwise +Override would not be able to handle both cases.
Followup to #6035.
* Add the submodel that was hit to the On Ship Collision scripting hook. (This will only be non-nil if the ship was the "heavy object".)
* Add a `getModel()` function to the scripted submodel object.
* Fix some incorrect documentation in `OnShipCollision`.
1. Add a `vanish()` function for beam objects, to be consistent with other object types
2. Add a `BeamFree` virtvar, analogous to `TurretLocked`
3. Add timestamp variants of TurretLocked and BeamFree to be consistent with sexps
4. Add `BeamLife`, `BeamWarmup`, and `BeamWarmdown` virtvars so scripts can access table properties
5. Add "On Beam Death", "On Beam Warmup", and "On Beam Warmdown" hooks
6. Clarify some existing documentation and patch a couple things
* Add SpawnShipCheat and convert Bravos spawning to it
* Clean-up and add canUseCheat() check
* Move some stuff to parent CustomCheat class
* Add cheat-used SEXP and On Cheat scripting hook
* Add cheat tbls and tbms, fix custom cheat detection, move cheat hooks to global hooks
* Add a default virtual destructor to CustomCheats for its derived classes to use
* Initialize buffers with memset so clang will calm down, also move cheat check a bit to keep old cheats
* Attempt to appease MSVC
* Clean-up and formatting
* Ensure custom cheats fit in the cheat code buffer
* Fix a merge mistake
* Move pre-set cheat to embedded cheats table
* Use appropriate types for stuff_string
* Remove unnecessary copying of the cheat buffer
* Explicit nullchecking
* Avoid copying values for initializing CustomCheat
* move cheat checking function to cheats_table.h, fix a typo
* Clarify OP_USED_CHEAT sexp description
* Remove unnecessary casting
* Use list initalization for Ship Cheats
* Move a few method definitions from the .h to .cpp
* Change buffer to const char*
Splits the existing On Death hook into independent hooks for each relevant type. Adds On Ship Death, On Missile Death, etc. Also adds On Missile Death Started to complement On Ship Death Started.
This takes a few of the existing hooks and converts them to the new style of hook definition which can include more extensive documentation and enumeration of supported hook variables.
This is an updated version of #3151 to work with the latest codebase.
NOTE: Before this can be integrated into the codebase, it needs an implementation for `bool script_state::IsActiveAction(int hookId)` which apparently only has support for old-style script hooks.