![]() |
SCP - Containment Breach
|
Hooks allow your scripts to define functions that are called at various points throughout the game.
Some hooks allow returning a bool in order to completely override the behavior of the base game, as well as any mods that are loaded before your mod.
Called when the launcher is initialized. Only called when the launcher is enabled.
Custom resources used in the launcher should be loaded here.
Called when the game is initialized.
This is where custom image, font, shader and audio resources, as well as custom options can be loaded.
Called when your mod is unloaded.
Resources loaded in Hook_Initialize should be freed here.
Called when the game's options are being serialized to the options.ini file, allowing your mod to serialize its own options with it as well.
Called once per frame after the game has finished its processing and rendering, but before the rendered image is displayed to the screen.
Called before the HUD is drawn.
Called before the player character is moved according to the current game states and the player's inputs.
Called before the player's mouse input is translated to the player camera's pitch and yaw.
Called before the player character would be killed. The player is not killed when overridden.
Called when a console command is being executed by the player. Used to implement custom console commands or modify the behavior of existing ones.
Called when the game transitions from the main menu to loading a save. Can be both an existing or new save. Can be used to load static resources like textures, entities and brushes that are needed in-game.
Called after Map::Width and Map::Height have been initialized from Data/map.ini. Should only be overridden when the map dimensions are configured dynamically in-game.
Called before the map's layout is initialized in Map::Temporary. Can be overridden to replace the vanilla generation. Regular rooms are initialized to 1, while checkpoints are initialized to 255.
Called before the minimum number of rooms per type as specified in Data/map.ini is attempted to be forced onto the map grid. When hooking into this, care must be taken to maintain the correct values within Map::Temporary and Map::RoomAmounts.
Called before the hardcoded rooms, as well as the rooms with a set room property from Data/rooms.ini are being added to Map::Room. Map::MinPositions and Map::MaxPositions delimit the array by room type and zone (in that order).
Called before rooms are instantiated from Map::Temporary, Map::Room and Data/rooms.ini. The arguments are intended to be used to convey the method progress via DrawLoading.
Called before room overlaps are detected amd attempted to be resolved.
Called before doors between rooms are instantiated.
Called before adjacent rooms are connected to each other and the doors that connect them via Room::Adjacent and Room::AdjacentDoor.
Called before the events for a newly created save are initialized. Allows initializing custom events via CB.Event.Create.
Called for every event every frame. Used to add behavior to custom events or modify the behavior of existing events.
Called when a room is created, before it is filled with doors, items and other entities. Used to add entities to custom rooms or modify the entities found in existing rooms.
Example:
Called when a room is created, after it has been filled with doors, items and other entities. Used to manipulate the entities the room has been filled with.
Called before a map entity is loaded from an .rmesh file. Can be used to implement custom map entity types or override how existing entity types are loaded.
Called when loading is finished and control is about to be handed to the player. Called after the player has pressed any key to continue.
Called when an item is created. Handles initialization of inventories for inventory items like wallet and clipboard unless overridden.
Called for every item every frame. Can be used for custom item logic. Handles gravity, reachability calculations for being picked up by the player and item-push behavior unless overridden.
Called when an item is removed from the world and freed.
Called when the player tries to pick up an item with sufficient inventory space remaining. The item is not added to the player's inventory when this function is overridden.
Called after the player dropped an item from their inventory.
Called when the player uses an item from their inventory.
Called when the player tries to combine two items.
Called before an NPC is initialized according to its CB::NPC::Type.
Called after an NPC is initialized.
Called before an NPC is about to be removed. Can be used to prevent an NPC from being removed. There is no danger of persisting NPCs when transitioning to the main menu, as they are deleted separately then.
Called for every NPC every frame. Used to add behavior to custom NPCs or modify the behavior of existing NPCs.
Called when an NPC's name is to be parsed from console input. Returning -1 will delegate responsibility to lower-priority mods and the base game.
Called when an NPC's name is to be printed to the console. Returning "" will delegate responsibility to lower-priority mods and the base game.
Called when an NPC is to be spawned from the console. Returning -1 will delegate responsibility to lower-priority mods and the base game. Returning 0 will disallow the NPC from being spawned via the console. Should only be overridden for custom NPCs when specific changes are necessary to make the NPC function correctly upon creation, in which case 1 must be returned. By default, NPCs are created 0.2 units above the player collider's position.
Called when an NPC's speed is about to be changed via the console. Returning -1 will delegate responsibility to lower-priority mods and the base game. Should only be overridden for custom NPCs to indicate that it is unaffected by the NPC::Speed value by returning 0. Returning 1 will indicate that the NPCs speed can be changed (the default for custom NPCs). Can also be overridden to indicate that a script modification to a base game NPC will allow it to be affected by the NPC::Speed value.
Called when an NPC is about to be enabled/disabled. Returning -1 will delegate responsibility to lower-priority mods and the base game. Must only be overridden when implementations for Hook_EnableNPC and Hook_DisableNPC are provided for an NPC type, which is supported in the base game, in which case 1 must be returned. Returning 0 will indicate that the NPC cannot be enabled/disabled (the default for custom NPCs).
Called when an NPC is to be enabled.
Called when an NPC is to be disabled.