Skip to content

Commit 20f2b17

Browse files
committed
Document new map generation hooks
1 parent 5d042c1 commit 20f2b17

1 file changed

Lines changed: 50 additions & 12 deletions

File tree

Articles/Hooks.md

Lines changed: 50 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ Called before the player's mouse input is translated to the player camera's pitc
5757

5858
## bool Hook_KillPlayer()
5959

60-
Called before the player character would be killed. The player is not killed when overriden.
60+
Called before the player character would be killed. The player is not killed when overridden.
6161

6262
## bool Hook_ExecuteConsoleCommand(@ref string cmd)
6363

@@ -67,6 +67,44 @@ Called when a console command is being executed by the player. Used to implement
6767

6868
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.
6969

70+
## bool Hook_MapInitializeDimensions()
71+
72+
Called after @ref Map::Width and @ref Map::Height have been initialized from `Data/map.ini`.
73+
Should only be overridden when the map dimensions are configured dynamically in-game.
74+
75+
## bool Hook_MapCreateLayout()
76+
77+
Called before the map's layout is initialized in @ref Map::Temporary.
78+
Can be overridden to replace the vanilla generation.
79+
Regular rooms are initialized to 1, while checkpoints are initialized to 255.
80+
81+
## bool Hook_MapForceRooms()
82+
83+
Called before the minimum number of rooms per type as specified in `Data/map.ini` is attempted to be forced onto the map grid.
84+
When hooking into this, care must be taken to maintain the correct values within @ref Map::Temporary and @ref Map::RoomAmounts.
85+
86+
## bool Hook_MapSetRooms()
87+
88+
Called before the hardcoded rooms, as well as the rooms with a `set room` property from `Data/rooms.ini` are being added to @ref Map::Room.
89+
@ref Map::MinPositions and @ref Map::MaxPositions delimit the array by room type and zone (in that order).
90+
91+
## bool Hook_MapCreateRooms(int loadingStart, float loadingCount)
92+
93+
Called before rooms are instantiated from @ref Map::Temporary, @ref Map::Room and `Data/rooms.ini`.
94+
The arguments are intended to be used to convey the method progress via @ref DrawLoading.
95+
96+
## bool Hook_MapPreventRoomOverlaps()
97+
98+
Called before room overlaps are detected amd attempted to be resolved.
99+
100+
## bool Hook_MapCreateDoors()
101+
102+
Called before doors between rooms are instantiated.
103+
104+
## bool Hook_MapConnectAdjacentRooms()
105+
106+
Called before adjacent rooms are connected to each other and the doors that connect them via @ref Room::Adjacent and @ref Room::AdjacentDoor.
107+
70108
## bool Hook_InitializeEvents()
71109

72110
Called before the events for a newly created save are initialized. Allows initializing custom events via @ref CB::Event::Create.
@@ -120,19 +158,19 @@ Called when loading is finished and control is about to be handed to the player.
120158

121159
## bool Hook_CreateItem(@ref CB::Item)
122160

123-
Called when an item is created. Handles initialization of inventories for inventory items like wallet and clipboard unless overriden.
161+
Called when an item is created. Handles initialization of inventories for inventory items like wallet and clipboard unless overridden.
124162

125163
## bool Hook_UpdateItem(@ref CB::Item)
126164

127-
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 overriden.
165+
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.
128166

129167
## void Hook_RemoveItem(@ref CB::Item)
130168

131169
Called when an item is removed from the world and freed.
132170

133171
## bool Hook_PickItem(@ref CB::Item)
134172

135-
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 overriden.
173+
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.
136174

137175
## bool Hook_DropItem(@ref CB::Item)
138176

@@ -177,22 +215,22 @@ Returning `""` will delegate responsibility to lower-priority mods and the base
177215
Called when an NPC is to be spawned from the console.
178216
Returning `-1` will delegate responsibility to lower-priority mods and the base game.
179217
Returning `0` will disallow the NPC from being spawned via the console.
180-
Should only be overriden for custom NPCs when specific changes are necessary to make the NPC function correctly upon creation, in which case `1` must be returned.
218+
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.
181219
By default, NPCs are created 0.2 units above the player collider's position.
182220

183221
## int Hook_ConsoleCheckCanChangeNPCSpeed(CB::NPC::Type type)
184222

185223
Called when an NPC's speed is about to be changed via the console.
186224
Returning `-1` will delegate responsibility to lower-priority mods and the base game.
187-
Should only be overriden for custom NPCs to indicate that it is unaffected by the @ref NPC::Speed value by returning `0`.
225+
Should only be overridden for custom NPCs to indicate that it is unaffected by the @ref NPC::Speed value by returning `0`.
188226
Returning `1` will indicate that the NPCs speed can be changed (the default for custom NPCs).
189-
Can also be overriden to indicate that a script modification to a base game NPC will allow it to be affected by the @ref NPC::Speed value.
227+
Can also be overridden to indicate that a script modification to a base game NPC will allow it to be affected by the @ref NPC::Speed value.
190228

191229
## int Hook_ConsoleCheckCanToggleNPC(CB::NPC::Type type)
192230

193231
Called when an NPC is about to be enabled/disabled.
194232
Returning `-1` will delegate responsibility to lower-priority mods and the base game.
195-
Must only be overriden 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.
233+
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.
196234
Returning `0` will indicate that the NPC cannot be enabled/disabled (the default for custom NPCs).
197235

198236
## bool Hook_EnableNPC(@ref CB::NPC)
@@ -204,8 +242,8 @@ Called when an NPC is to be enabled.
204242
> This hook may be called on already enabled NPCs.
205243
206244
> [!IMPORTANT]
207-
> `Hook_ConsoleCheckCanToggleNPC` must be overriden to allow for this hook to be called.
208-
> `Hook_DisableNPC` must also be overriden to actually do the disabling, which this hook undoes.
245+
> `Hook_ConsoleCheckCanToggleNPC` must be overridden to allow for this hook to be called.
246+
> `Hook_DisableNPC` must also be overridden to actually do the disabling, which this hook undoes.
209247
210248
## bool Hook_DisableNPC(@ref CB::NPC)
211249

@@ -216,5 +254,5 @@ Called when an NPC is to be disabled.
216254
> This hook may be called on already disabled NPCs.
217255
218256
> [!IMPORTANT]
219-
> `Hook_ConsoleCheckCanToggleNPC` must be overriden to allow for this hook to be called.
220-
> `Hook_EnableNPC` must also be overriden to undo the disabling.
257+
> `Hook_ConsoleCheckCanToggleNPC` must be overridden to allow for this hook to be called.
258+
> `Hook_EnableNPC` must also be overridden to undo the disabling.

0 commit comments

Comments
 (0)