mirror of
https://github.com/scp-fs2open/fs2open.github.com.git
synced 2026-11-10 17:46:53 -10:00
* 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*
131 lines
6.9 KiB
C++
131 lines
6.9 KiB
C++
|
|
#include "global_hooks.h"
|
|
|
|
namespace scripting {
|
|
namespace hooks {
|
|
|
|
const std::shared_ptr<Hook> OnGameInit = Hook::Factory("On Game Init",
|
|
"Executed at the start of the engine after all game data has been loaded.",
|
|
{},
|
|
CHA_GAMEINIT);
|
|
|
|
const std::shared_ptr<Hook> OnDebrisCreated = Hook::Factory(
|
|
"On Debris Created",
|
|
"Invoked when a piece of debris is created.",
|
|
{
|
|
{"Debris", "debris", "The newly created debris object"},
|
|
{"Source", "object", "The object (probably a ship) from which this debris piece was spawned."},
|
|
});
|
|
|
|
const std::shared_ptr<OverridableHook> OnShipCollision = OverridableHook::Factory("On Ship Collision",
|
|
"Invoked when a ship collides with another object. Note: When two ships collide this will be called twice, once "
|
|
"with each ship object as the \"Ship\" parameter.",
|
|
{{"Self", "object", "The \"other\" object that collided with the ship."},
|
|
{"Object",
|
|
"ship",
|
|
"The ship object with which the \"other\" object collided with. Provided for consistency with other "
|
|
"collision hooks."},
|
|
{"Ship", "ship", "Same as \"Object\""},
|
|
{"Hitpos", "vector", "The world position where the colission was detected"},
|
|
{"Debris", "object", "The debris object with which the ship collided (only set for debris collisions)"},
|
|
{"Asteroid", "object", "The asteroid object with which the ship collided (only set for asteroid collisions)"},
|
|
{"ShipB", "ship", "For ship on ship collisions, the \"other\" ship."},
|
|
{"Weapon", "weapon", "The weapon object with which the ship collided (only set for weapon collisions)"},
|
|
{"Beam", "weapon", "The beam object with which the ship collided (only set for beam collisions)"}});
|
|
|
|
const std::shared_ptr<Hook> OnShipDeathStarted = Hook::Factory(
|
|
"On Ship Death Started", "Called when a ship starts the death process.",
|
|
{
|
|
{"Ship", "ship", "The ship that has begun the death process."},
|
|
{"Killer", "object", "The object responsible for killing the ship. Always set but could be invalid if there is no killer."},
|
|
{"Hitpos", "vector", "The world coordinates of the killing blow. Could be nil."},
|
|
});
|
|
|
|
const std::shared_ptr<OverridableHook> OnShipDeath = OverridableHook::Factory(
|
|
"On Ship Death", "Called when a ship has been destroyed. Supersedes On Death for ships.",
|
|
{
|
|
{"Ship", "ship", "The ship that was destroyed."},
|
|
{"Killer", "object", "The object responsible for killing the ship. Always set but could be invalid if there is no killer."},
|
|
{"Hitpos", "vector", "The world coordinates of the killing blow. Could be nil."},
|
|
});
|
|
|
|
const std::shared_ptr<Hook> OnMissileDeathStarted = Hook::Factory(
|
|
"On Missile Death Started", "Called when a missile is about to be destroyed (whether by impact, interception, or expiration).",
|
|
{
|
|
{"Weapon", "weapon", "The weapon that was destroyed."},
|
|
{"Object", "object", "The object that the weapon hit - a ship, asteroid, or piece of debris. Always set but could be invalid if there is no other object. If this missile was destroyed by another weapon, the 'other object' will be invalid but the DestroyedByWeapon flag will be set."},
|
|
});
|
|
|
|
const std::shared_ptr<Hook> OnMissileDeath = Hook::Factory(
|
|
"On Missile Death", "Called when a missile has been destroyed (whether by impact, interception, or expiration).",
|
|
{
|
|
{"Weapon", "weapon", "The weapon that was destroyed."},
|
|
{"Object", "object", "The object that the weapon hit - a ship, asteroid, or piece of debris. Always set but could be invalid if there is no other object. If this missile was destroyed by another weapon, the 'other object' will be invalid but the DestroyedByWeapon flag will be set."},
|
|
});
|
|
|
|
const std::shared_ptr<Hook> OnAsteroidDeath = Hook::Factory(
|
|
"On Asteroid Death", "Called when an asteroid has been destroyed. Supersedes On Death for asteroids.",
|
|
{
|
|
{"Asteroid", "asteroid", "The asteroid that was destroyed."},
|
|
{"Hitpos", "vector", "The world coordinates of the killing blow."},
|
|
});
|
|
|
|
const std::shared_ptr<Hook> OnDebrisDeath = Hook::Factory(
|
|
"On Debris Death", "Called when a piece of debris has been destroyed.",
|
|
{
|
|
{"Debris", "debris", "The piece of debris that was destroyed."},
|
|
{"Hitpos", "vector", "The world coordinates of the killing blow. Could be nil."},
|
|
});
|
|
|
|
const std::shared_ptr<OverridableHook> OnDialogInit = OverridableHook::Factory("On Dialog Init",
|
|
"Invoked when a system dialog initalizes. Override to prevent the system dialog to load dialog-related resources (requires retail files)",
|
|
{
|
|
{"Choices",
|
|
"table",
|
|
"A table containing the different choices for this dialog. Contains subtables, each consisting of "
|
|
"Positivity (an int, 0 if neutral, 1 if positive, and -1 if negative) and "
|
|
"Text (a string, the text of the button)."},
|
|
{"Title", "string", "The title of the popup window. Nil for a death popup."},
|
|
{"Text", "string", "The text to be displayed in the popup window. Nil for a death popup."},
|
|
{"IsTimeStopped", "boolean", "True if mission time was interrupted for this popup."},
|
|
{"IsStateRunning", "boolean", "True if the underlying state is still being processed and rendered."},
|
|
{"IsInputPopup", "boolean", "True if this popup is for entering text."},
|
|
{"IsDeathPopup", "boolean", "True if this popup is an in-mission death popup and should be styled as such."},
|
|
{"AllowedInput", "string", "A string of characters allowed to be present in the input popup. Nil if not an input popup."}
|
|
});
|
|
|
|
const std::shared_ptr<OverridableHook> OnDialogFrame = OverridableHook::Factory("On Dialog Frame",
|
|
"Invoked each frame for a system dialog. Override to prevent the system dialog from rendering and evaluating.",
|
|
{
|
|
{"Submit", "function(number | string | nil result) -> nil", "A callback function that should be called if the popup resolves. Should be string only if it is an input popup. Pass nil to abort."},
|
|
{"IsDeathPopup", "boolean", "True if this popup is an in-mission death popup and should be styled as such."},
|
|
{"Freeze", "boolean", "If not nil and true, the popup should not process any inputs but just render."}
|
|
});
|
|
|
|
const std::shared_ptr<Hook> OnDialogClose = Hook::Factory("On Dialog Close",
|
|
"Invoked when a dialog closes.",
|
|
{
|
|
{"IsDeathPopup", "boolean", "True if this popup is an in-mission death popup and should be styled as such."}
|
|
});
|
|
|
|
// ========== DEPRECATED ==========
|
|
|
|
const std::shared_ptr<OverridableHook> OnDeath = OverridableHook::Factory("On Death",
|
|
"Invoked when an object (ship or asteroid) has been destroyed. Deprecated in favor of On Ship Destroyed and On Asteroid Destroyed.",
|
|
{
|
|
{"Self", "object", "The object that was killed"},
|
|
{"Ship", "ship", "The ship that was destroyed (only set for ships)"},
|
|
{"Killer", "object", "The object that caused the death (only set for ships)"},
|
|
{"Hitpos",
|
|
"vector",
|
|
"The position of the hit that caused the death (only set for ships and only if available)"},
|
|
});
|
|
|
|
std::shared_ptr<scripting::Hook> OnCheat = scripting::Hook::Factory(
|
|
"On Cheat", "Called when a cheat is used",
|
|
{
|
|
{ "Cheat", "string", "The cheat code the user typed" },
|
|
});
|
|
|
|
} // namespace hooks
|
|
} // namespace scripting
|