-
Notifications
You must be signed in to change notification settings - Fork 7
BSP Parser
The BSP Parser offers a lot of map-functions and data.
You can always get the current map from: NikNaks.CurrentMap
local ents = NikNaks.CurrentMap:GetEntities()
Returns | Functions | Description |
---|---|---|
BSPObject?, BSP_ERROR_CODE | NikNaks.Map( String? fileName ) | Reads the BSP file and returns it as an object. If no fileName given, will read the current map. |
BSP_ERROR_CODE enums:
NikNaks.BSP_ERROR_FILECANTOPEN
NikNaks.BSP_ERROR_NOT_BSP
NikNaks.BSP_ERROR_TOO_NEW
NikNaks.BSP_ERROR_FILENOTFOUND
Returns | Functions | Description |
---|---|---|
String | BSPObject:GetMapName() | Returns the mapname. |
String | BSPObject:GetMapFile() | Returns the mapfile. |
Number | BSPObject:GetVersion() | Returns the map-version. |
Number | BSPObject:GetSize() | Returns the map-size in bytes. |
String | BSPObject:GetDetailMaterial() | Returns the detail-metail the map uses. |
Boolean | BSPObject:IsColdWorld() | Returns true if the map has the coldworld-flag. |
Vector | BSPObject:WorldMin() | Returns the min-positions where brushes are within the map. |
Vector | BSPObject:WorldMax() | Returns the max-positions where brushes are within the map. |
Vector, Vector | BSPObject:GetBrushBounds() | Returns the min-/max-positions where brushes are within the map. |
Boolean | BSPObject:IsOutsideMap( Vector position ) | Returns true if the position is outside of the map. |
Boolean | BSPObject:HasTexture( String texture ) | Returns true if the texture is used by the map. |
Boolean | BSPObject:HasMaterial( IMaterial material ) | Returns true if the material is used by the map. |
Table | BSPObject:GetTextures() | Returns a table of all texturesused by the map. |
Table | BSPObject:GetMaterials() | Returns a table of all materials used by the map. |
BSPs are build out of 64 lumps. Each lump hold a type of data. For example, the first lump (Lump 0) is always the BSP file's entity data.
Note: Use GetLumpString if you're going to parse a string. It is much faster than GetLump.
Returns | Functions | Description |
---|---|---|
BitBuffer | BSPObject:GetLump( Number lump_id ) | Returns the data lump as a bytebuffer. This will also be cached onto the BSP object. |
Number | BSPObject:GetLumpVersion( Number lump_id ) | Returns the lump version |
String | BSPObject:GetLumpString( Number lump_id ) | Returns the data lump as a datastring. |
BSPObject:ClearLump( Number lump_id ) | Deletes cached lummp_data. | |
Table | BSPObject:FindGameLump( Number GameLumpID ) | Returns gamelump number, matching the gLumpID. |
Table | BSPObject:GetGameLumpHeaders() | Returns a list of gamelumps. |
BitBuffer, version, flags | BSPObject:GetGameLump( Number gameLumpID ) | Returns the game lump as a bytebuffer. This will also be cached on the BSP object. |
Map-creators can store any type of data onto these entities.
*Note: I think BSPObject:FindInX functions are slower, than ents.FindInX as the engine use a grid system.
Returns | Functions | Description |
---|---|---|
Table | BSPObject:GetEntity( Number index ) | Returns the raw entity data said entity. |
Table | BSPObject:GetEntities() | Returns a list of all entity data for the map. |
Table | BSPObject:FindInSphere( Vector origin, Number radius ) | Returns a list of entity data, within the specified sphere. |
Table | BSPObject:FindInBox( Vector boxMins, Vector boxMaxs ) | Returns a list of entity data, within the specified box. |
Table | BSPObject:FindByName( String name ) | Returns a list of entity data, matching the name ( targetname ). |
Table | BSPObject:FindByModel( String model ) | Returns a list of entity data, matching the model. |
Table | BSPObject:FindByClass( String class ) | Returns a list of entity data, matching the class. |
Static Props are models baked into the map. These objects can't move, animate or be edited by other means.
Returns | Functions | Description |
---|---|---|
StaticProp? | BSPObject:GetStaticProp( Number index ) | Returns the Static Prop with said index. |
Table | BSPObject:GetStaticProps() | Returns a list of all Static Props. |
Table | BSPObject:GetStaticPropModels() | Returns a list of all Static Props models used by the map. |
Table | BSPObject:FindStaticByModel( String model ) | Returns a list of all Static Props matching the model. |
Table | BSPObject:FindStaticInBox( Vector boxMins, Vector boxMaxs ) | Returns a list of all Static Props, within the specified box. |
Table | BSPObject:FindStaticInSphere( Vector origin, Number radius ) | Returns a list of all Static Props, within the specified sphere. |
See: StaticProp for more functions and details.
Returns | Functions | Description |
---|---|---|
Boolean | BSPObject:HasSkyBox() | Returns true if the map has a 3D skybox. |
Vector | BSPObject:GetSkyBoxPos() | Returns the skybox position. Returns [0,0,0] if none are found. |
Number | BSPObject:GetSkyBoxScale() | Returns the skybox scale. Returns 1 if none are found. |
Vector | BSPObject:WorldToSkyBox( Vector vec ) | Returns a position in the skybox that matches the one in the world. |
Vector | BSPObject:SkyBoxToWorld( Vector vec ) | Returns a position in the world that matches the one in the skybox. |
Boolean | BSPObject:IsRenderingSkyboxAtPosition( Vector position ) | Returns true if the skybox is rendering at this position. Note: Seems to be true in EP2 and beyond regardless of position. |
Vector, Vector | BSPObject:GetSkyboxSize() | Returns the min-/max size of the skybox. |
A Cubemap is a texture that represents a three-dimensional rendering of an area. Used for reflections. Note that the engine control what Cubemap-texture is being used. See more here: https://developer.valvesoftware.com/wiki/Cubemaps
Returns | Functions | Description |
---|---|---|
Table | BSPObject:GetCubemaps() | Returns a list of Cubemap objects within the map. |
CubeMap? | BSPObject:FindNearestCubemap( Vector position ) | Returns the nearest Cubemap. This can be nil as the engine only changes nearby the object. |
Returns | Functions | Description |
---|---|---|
Vector position | CubeMap:GetPos() | Returns the position of the Cubemap. |
Number index | CubeMap:GetIndex() | Returns the index of the Cubemap. |
String texture | CubeMap:GetTexture() | Returns the texture the Cubemap use. |
Number size | CubeMap:GetSize() | Returns the size of the Cubemap. |
BSP maps (and older games) separate the map volume into a branch of "clusters" of visible surfaces. These clusters are made from Nodes
and VisLeafs
(Also known as Leafs
).
VisLeafs are used primarily by the Rendering Engine to determine (before rendering each frame) which areas of the map might need to be rendered on screen. See more: https://developer.valvesoftware.com/wiki/Visleaf
Returns | Functions | Description |
---|---|---|
Table | BSPObject:GetNodes() | Returns a list of Node-Data. |
Table | BSPObject:GetLeafs() | Returns a list of VisLeaf objects. |
Table | BSPObject:GetLeafWaterData() | Returns a list of VisLeafs-Waterdata. |
Number | BSPObject:GetLeafsNumClusters() | Returns the number of VisLeafs-Clusters. |
VisLeaf | BSPObject:PointInLeaf(Number iNode, Vector point) | Returns the leaf the point is within. Use 0 If unsure about iNode. |
VisLeaf,Boolean | BSPObject:PointInLeafCache(Number iNode, Vector point, VisLeaf? lastVisLeaf) | Returns the leaf the point is within, but allows caching by feeding the old VisLeaf. Will also return true if the VisLeaf is different from the old. |
Number | BSPObject:ClusterFromPoint( Vector point ) | Returns the cluster the point is within. |
Number | BSPObject:ComputeDetailLeaf( Vector point ) | Computes the leaf-id the detail is within. -1 for none. |
Returns | Functions | Description |
---|---|---|
Number | VisLeaf:GetIndex() | Returns the index of the VisLeaf. |
Number | VisLeaf:GetArea() | Returns the area of the VisLeaf. |
Number | VisLeaf:GetContents() | Returns the Contents Flags of the VisLeaf. |
Boolean | VisLeaf:HasContents(Number ContentsFlag) | Returns true if the VisLeaf has said Contents Flags. |
Boolean | VisLeaf:HasSkyboxInPVS() | Returns true if the VisLeaf's PVS will render a 3D skybox within it. |
Boolean | VisLeaf:Has2DSkyboxInPVS() | Returns true if the VisLeaf's PVS will render a 2D skybox within it.HasSkyboxInPVS() instead! |
Boolean | VisLeaf:HasWater() | Returns true if the VisLeaf's has water within it. |
Table? | VisLeaf:GetWaterData() | Returns the waterdata for the Leaf, if it has any. |
Number? | VisLeaf:GetWaterMaxZ() | Returns the max-height of the water the leaf is in. |
Number? | VisLeaf:GetWaterMinZ() | Returns the min-height of the water the leaf is in. |
Boolean | VisLeaf:IsOutsideMap() | Returns true if the VisLeaf's is outside the map. |
Number | VisLeaf:GetCluster() | Returns the VisLeaf's cluster-number. |
VisLeaf:DebugRender() | Debug-renders the area of the VisLeaf. ( |
PVS (Potentially Visible Set) and PAS (Potentially Audible Set) is a set of collection of VisLeaf's, which might be visible from a given location. Thanks to them being pre-compiled by hammer, it is a very fast method of checking areas.
PVS is mostly used for render-checks, while NPC's are known to use PAS to react to sounds.
Returns | Functions | Description |
---|---|---|
PVS | BSPObject:CreatePVS() | Creates an empty PVS |
PVS | BSPObject:PVSForOrigin( Vector position, PVS?) | Creates a new or adds a position to a given PVS. |
Boolean | BSPObject:PVSCheck( Vector position, Vector position2 ) | Returns true if the two positions is in same PVS. |
Returns | Functions | Description |
---|---|---|
PAS | BSPObject:CreatePAS() | Creates an empty PAS |
PAS | BSPObject:PASForOrigin( Vector position, PAS?) | Creates a new or adds a position to a given PAS. |
Boolean | BSPObject:PASCheck( Vector position, Vector position2 ) | Returns true if the two positions is in same PAS. |
For more info and functions, see PVS and PAS
- BitBuffer
- BSP Parser
- DateTime and Date-Functions
- TimeDelta
-
PathFinding (Coming soon)
- LPathFollower (Coming soon)
- NodeGraph (Coming soon)
- NikNav ( NikNaks Navigation ) on ToDo
- Extended functions (Coming soon)