Blocks of Doom II
Library Documentation

Written by Carlcyber, Jimmy, and Lord_Z.

Version: 0.3 Alpha 7






Preface

Welcome to Blocks of Doom II library documentation. This file is a reference designed to help levelmakers get familiar with the many features provided by the ACS library. Any parts of the library not mentioned in this documentation are not for design use and might lead to unexpected behavior if you use them yourself.

There are currently three files in the Blocks II library. The first file is BoD2Library.acs, the main library file. The second is BoD2_MSInitializer.acs, the map script initializer. The third is ExtLib.acs, the extended library, which it currently not used and might be discarded in the future.

Every map script must #import BoD2Library.acs and #include BoD2_MSInitializer.acs. The correct location for these lines in the map scripts can be seen in the template map, where lots of examples and comments are provided for levelmakers.






Index






Block Flags

Block flags are the key features applied to blocks to make them interactive with the players. Tileset designers can combine block flags by using the OR "|" operator to give a tile several features. Most of the flags can be combined as you please, but incorrect or conflicting combinations will be reported as errors when the library loads the tiles.

Block flags are used in the array Local_BlockTypes, where all the tile definitions for that tileset are stored.

All the flags are grouped into three categories, as listed below:

Base flags

Sector specific flags
For BF_S_ENTERACS, BF_S_STAYACS, and BF_S_LEAVEACS, the library will pass two arguments to the script, which are (int tile, int blockIndex).
These scripts serves different purposes in compare with Run ACS. They serves as external tile functions binded to a script which are not available in the library, so they are also called tile events. If Run ACS and tile events were both going to be called, the library will call tile events first.

Line specific flags
BF_L_LOCKDOOR flags can be used on top of each other to make locked doors that require more than one kind of key.
BF_L_BUMPACS is one of the tile events. Please read the comments for sector specific flags for the information about tile events. But the library passes three arguments instead of two, which are (int tile, int blockIndex, int side). "side" represents the line on the block that triggers the script, which can be LINESIDE_EAST, LINESIDE_WEST, LINESIDE_NORTH, and LINESIDE_SOUTH.





Library Variables

All the variables here are read only. Setting values to them is strictly forbidden.

ColorString
Defines a list of color strings using escape code. (Reference)
Currently this is only used for the color of custom key messages. All the available colors are listed below: To pose an example, using ColorString[COLOR_BRIGHTGREEN] will get the appropriate color string for 'bright green'.

CurrentLevel
The current level in this world. (1-20)

TimeLeft
Time left, in seconds. (0-999)

Spheres
Number of spheres left in the current level. (0-256)

PlayerScore
Player's score.

GlobalSphere
Information about spheres throughout the entire game.

MapSphere
Information about spheres in the current world.

LevelSphere
Information about spheres in the current level.

SkillLevel
The current game difficulty, as chosen by the player.

LevelCount
Number of levels in the current world. (20 for the first 4 episodes, 15 for the latter 4 episodes.)

LevelEnemies
Number of enemies in the current level. (1-256)

CanPressUse
Removed from 0.3 alpha 7.

BoulderTID
TID currently applied to all boulders. The value of this variable is valid only after the first boulder is spawned by T_SpawnBoulder in a level.

TrapActorTID
After a trap thing is spawned by T_SpawnTrap function, its TID can be acquired by using TrapActorTID[trapIndex].





Block Functions

Functions documented in this section:

BoD2Library.Block

Function int B_GetIndex(int row, int column)

Returns the index (a number between 1 and 256) of the block at the specified row and column.

row
Row of the block. (1-16)
column
Column of the block. (1-16)

BackĄ¶


BoD2Library.Block

Function int B_GetRow(int index)

Returns the number of the row on which the specified block lies.

index
Index of the block. (1-256)

BackĄ¶


BoD2Library.Block

Function int B_GetColumn(int index)

Returns the number of the column on which the specified block lies.

index
Index of the block. (1-256)

BackĄ¶


BoD2Library.Block

Function int B_GetR(int index)

Returns the array index of the block row on which the specified block lies. Essentially this is equivalent to doing B_GetRow(index) - 1.

index
Index of the block. (1-256)
This function is generally of no use outside of the library itself, so don't use it or unexpected behavior may occur.

BackĄ¶


BoD2Library.Block

Function int B_GetC(int index)

Returns the array index of the block row on which the specified block lies. Essentially this is equivalent to doing B_GetColumn(index) - 1.

index
Index of the block. (1-256)
This function is generally of no use outside of the library itself, so don't use it or unexpected behavior may occur.

BackĄ¶


BoD2Library.Block.Parameters

Function void B_SetTeleporter(int row, int column, int destRow, int destColumn)

row
Row of teleporter block. (1-16)
column
Column of teleporter block. (1-16)
destRow
Row of teleport destination block. (1-16)
destColumn
Column of teleport destination block. (1-16)

Creates a teleport between two blocks. Will override any other teleports that are already there.

BackĄ¶


BoD2Library.Block.Parameters

Function void B_SetTrap(int row, int column, int trapType)

row
Row of the block to set the trap button at. (1-16)
column
Column of the block to set the trap button at. (1-16)
trapType

Creates a trap button at the specified block with a certain trigger mode. Will override any other trap buttons that are already there.

BackĄ¶


BoD2Library.Block.Parameters

Function void B_SetRunACS(int row, int column, int scriptNumber, int triggerType, bool keepTriggering)

row
Row of the block to apply the script to. (1-16)
column
Column of the block to apply the script to. (1-16)
scriptNumber
The number of the script to activate. (900-931)
triggerType
keepTriggering
If 'true', the script can be triggered repeatedly if player keeps bumping into the line or standing in the sector, depending on trigger type.

Runs an ACS script on the specified block under the specified conditions. Any scripts already set to that block will be overridden if they are already there.

BackĄ¶


BoD2Library.Block.Parameters

[0.3 alpha 7]

Function void B_SetPlayerBlocking(int row, int column)

row
Row of the block. (1-16)
column
Column of the block. (1-16)

Sets the specified block's lines to block the player.

BackĄ¶


BoD2Library.Block.Parameters

Function void B_SetMonsterBlocking(int row, int column)

row
Row of the block. (1-16)
column
Column of the block. (1-16)

Sets the specified block's lines to block monsters.

BackĄ¶


BoD2Library.Block.Parameters

Function void B_SetImpassible(int row, int column)

row
Row of the block. (1-16)
column
Column of the block. (1-16)

Sets the specified block's lines to be impassible to player and monsters.

BackĄ¶


BoD2Library.Block.Parameters

[0.3 alpha 7]

Function void B_SetProjectileBlocking(int row, int column)

row
Row of the block. (1-16)
column
Column of the block. (1-16)

Sets the specified block's lines to block projectiles.

BackĄ¶


BoD2Library.Block.Parameters

[0.3 alpha 7]

Function void B_SetAllBlocking(int row, int column)

row
Row of the block. (1-16)
column
Column of the block. (1-16)

Sets the specified block's lines to block everything, including the player, monsters, and projectiles.

BackĄ¶


BoD2Library.Block.Parameters

Function void B_RemoveTeleporter(int row, int column)

row
Row of teleporter block. (1-16)
column
Column of teleporter block. (1-16)

Removes the teleporter on the specified block.

BackĄ¶


BoD2Library.Block.Parameters

Function void B_RemoveTrap(int row, int column)

row
Block row to remove the trap. (1-16)
column
Block column to remove the trap. (1-16)

Removes the trap button behavior at the specified block.

BackĄ¶


BoD2Library.Block.Parameters

Function void B_RemoveRunACS(int row, int column)

row
Row of the block. (1-16)
column
Column of the block. (1-16)

Removes any scripts applied to the specified block.

BackĄ¶


BoD2Library.Block.Parameters

[0.3 alpha 7]

Function void B_RemovePlayerBlocking(int row, int column)

row
Row of the block. (1-16)
column
Column of the block. (1-16)

Removes player blocking on the specified block.

BackĄ¶


BoD2Library.Block.Parameters

Function void B_RemoveMonsterBlocking(int row, int column)

row
Row of the block. (1-16)
column
Column of the block. (1-16)

Removes monster blocking on the specified block.

BackĄ¶


BoD2Library.Block.Parameters

Function void B_RemoveImpassible(int row, int column)

row
Row of the block. (1-16)
column
Column of the block. (1-16)

Removes player and monster blocking on the specified block.

BackĄ¶


BoD2Library.Block.Parameters

[0.3 alpha 7]

Function void B_RemoveProjectileBlocking(int row, int column)

row
Row of the block. (1-16)
column
Column of the block. (1-16)

Removes projectile blocking on the specified block.

BackĄ¶


BoD2Library.Block.Parameters

[0.3 alpha 7]

Function void B_RemoveAllBlocking(int row, int column)

row
Row of the block. (1-16)
column
Column of the block. (1-16)

Removes player, monster, and projectile blocking on the specified block.

BackĄ¶


BoD2Library.Block.Parameters

[0.3 alpha 7]

Function void B_SetBlocking(int row, int column, bool playerBlocking, bool monsterBlocking, bool projectileBlocking)

row
Row of the block. (1-16)
column
Column of the block. (1-16)
playerBlocking
Blocks the player or not.
monsterBlocking
Blocks monsters or not.
projectileBlocking
Block projectiles or not

A generalized function that sets the block lines' passability for the player, monsters, and projectiles.

BackĄ¶


BoD2Library.Block.Structuring

Function void B_SetBlockTile(int row, int column, int tile, int heightFactor)

row
Row of the block. (1-16)
column
Column of the block. (1-16)
tile
Number of the desired tile defined in the Local_BlockTypes array. (It is recommended that you use one of the BT_ constants.)
heightFactor
Height factor of the block - the in-game height of the block will be this value multiplied by the specified tile's base height, which is defined in the Local_BlockTypes array.

Changes the specified block's tile and height. This function will not remove block parameters.

BackĄ¶


BoD2Library.Block.Structuring

Function void B_BuildBlock(int row, int column, int tile, int heightFactor)

row
Row of the block. (1-16)
column
Column of the block. (1-16)
tile
Number of the desired tile defined in the Local_BlockTypes array. (It is recommended that you use one of the BT_ constants.)
heightFactor
Height factor of the block - the in-game height of the block will be this value multiplied by the specified tile's base height, which is defined in the Local_BlockTypes array.

Changes the specified block's tile and height and resets its parameters.

BackĄ¶


BoD2Library.Block.Structuring

Function void B_BuildHorBlockLine(int row, int column1, int column2, int tile, int heightFactor)

row
Desired row on which to build the blocks. (1-16)
column1
The column to start building at. (1-16)
column2
The column to stop building at. (1-16) Whether or not this value is greater than column1 doesn't matter - the game will simply build blocks between these two points.
tile
Number of the desired tile defined in the Local_BlockTypes array. (It is recommended that you use one of the BT_ constants.)
heightFactor
Height factor of the blocks - the in-game height of the blocks will be this value multiplied by the specified tile's base height, which is defined in the Local_BlockTypes array.

Builds a horizontal line of blocks with the specified tile and height factor. This function calls B_BuildBlock, so parameters will be reset.

BackĄ¶


BoD2Library.Block.Structuring

Function void B_BuildVerBlockLine(int column, int row1, int row2, int tile, int heightFactor)

column
Desired column on which to build the blocks. (1-16)
row1
The row to start building at. (1-16)
row2
The row to stop building at. (1-16) Whether or not this value is greater than row1 doesn't matter - the game will simply build blocks between these two points.
tile
Number of the desired tile defined in the Local_BlockTypes array. (It is recommended that you use one of the BT_ constants.)
heightFactor
Height factor of the blocks - the in-game height of the blocks will be this value multiplied by the specified tile's base height, which is defined in the Local_BlockTypes array.

Builds a vertical line of blocks with the specified tile and height factor. This function calls B_BuildBlock, so parameters will be reset.

BackĄ¶


BoD2Library.Block.Structuring

Function void B_BuildBlockSquare(int row1, int row2, int column1, int column2, int tile, int heightFactor)

row1
The row to start building at. (1-16)
row2
The row to stop building at. (1-16) Whether or not this value is greater than row1 doesn't matter - the game will simply build blocks between these two points.
column1
The column to start building at. (1-16)
column2
The column to stop building at. (1-16) Whether or not this value is greater than column1 doesn't matter - the game will simply build blocks between these two points.
tile
Number of the desired tile defined in the Local_BlockTypes array. (It is recommended that you use one of the BT_ constants.)
heightFactor
Height factor of the blocks - the in-game height of the blocks will be this value multiplied by the specified tile's base height, which is defined in the Local_BlockTypes array.

Builds a rectangle of blocks of the same specified tile and height factor. This function calls B_BuildBlock, so parameters will be reset.

BackĄ¶


BoD2Library.Block.Structuring

Function void B_RemoveBlock(int row, int column)

row
Row of the block. (1-16)
column
Column of the block. (1-16)

Sets the specified block's tile and floor height to 0 and resets all parameters.

BackĄ¶


BoD2Library.Block.Structuring

Function void B_RemoveHorBlockLine(int row, int column1, int column2, int type)

row
Desired row to remove the blocks from. (1-16)
column1
The column to start removing at. (1-16)
column2
The column to stop removng at. (1-16) Whether or not this value is greater than column1 doesn't matter - the game will simply remove all blocks between these two points.
tile
Only blocks with tiles of this type will be removed. (Tile numbers are defined in Local_BlockTypes array.)
Use REMOVE_ALL_BLOCK_TYPES to remove all blocks regardless of tile.

Removes a horizontal line of blocks. This function also resets all blocks' parameters.

BackĄ¶


BoD2Library.Block.Structuring

Function void B_RemoveVerBlockLine(int column, int row1, int row2, int type)

column
Desired column to remove the blocks from. (1-16)
row1
The row to start removing at. (1-16)
row2
The row to stop removng at. (1-16) Whether or not this value is greater than row1 doesn't matter - the game will simply remove all blocks between these two points.
tile
Only blocks with tiles of this type will be removed. (Tile numbers are defined in Local_BlockTypes array.)
Use REMOVE_ALL_BLOCK_TYPES to remove all blocks regardless of tile.

Removes a vertical line of blocks. This function also resets all blocks' parameters.

BackĄ¶


BoD2Library.Block.Structuring

Function void B_RemoveBlockSquare(int row1, int row2, int column1, int column2, int tile)

row1
The row to start removing at. (1-16)
row2
The row to stop removing at. (1-16)
column1
The column to start removing at. (1-16)
column2
The column to stop removing at. (1-16)
tile
Only blocks with tiles of this type will be removed. (Tile numbers are defined in Local_BlockTypes array.)
Use REMOVE_ALL_BLOCK_TYPES to remove all blocks regardless of tile.

Removes a rectangle of blocks of the specified tile. This function also resets all blocks' parameters.

BackĄ¶


BoD2Library.Block.Structuring

Function void B_RemoveAllBlocks(int tile)

tile
Only blocks with tiles of this type will be removed. (Tile numbers are defined in Local_BlockTypes array.)
Use REMOVE_ALL_BLOCK_TYPES to remove all blocks regardless of tile.

Clears the entire grid of blocks and resets all blocks' parameters.

BackĄ¶


BoD2Library.Block.Structuring

Function bool B_MoveBlockByValue(int index, int tile, int heightUnit, int speed, bool lateChangeTile)

Returns true if the block can be moved, or false if not.

index
Index of the block. (1-256)
This can also be obtained automatically by using the function B_GetIndex.
tile
Tile type to be changed to.
heightUnit
Height, relative to current height, to move block to (in positive or negative mapunits).
speed
How quickly the block moves.
lateChangeTile

Moves the block upwards or downwards and changes its tile. A block will refuse to move if heightUnit is not a factor of its original tile's base height. (Base height is defined in Local_BlockTypes array.)

BackĄ¶


BoD2Library.Block.Structuring

Function bool B_MoveBlockToValue(int index, int tile, int heightUnit, int speed, bool lateChangeTile)

Returns true if the block can be moved, or false if not.

index
Index of the block. (1-256)
This can also be obtained automatically by using the function B_GetIndex.
tile
Tile type to be changed to.
heightUnit
Absolute height to move block to (in mapunits).
speed
How quickly the block moves.
lateChangeTile

Moves the block upwards or downwards and changes its tile. A block will refuse to move if heightUnit is not a factor of its original tile's base height. (Base height is defined in Local_BlockTypes array.)

BackĄ¶


BoD2Library.Block

Function int B_GetActorBlockIndex(int tid)

Returns the index of the block that the actor with the specified tid is currently in. A return value of zero means that the actor is outside the grid.

tid
Thing ID.

BackĄ¶


BoD2Library.Block.Trap

Function bool B_ActivateTrap(int row, int column)

Returns whether or not the trap button was successfully activated.

row
Row of the block at which to activate the trap button.
column
Column of the block at which to activate the trap button.

Activates a trap button at the specified block row and column.

BackĄ¶


BoD2Library.Block.Trap

Function bool B_TrapActivated(int row, int column)

Returns true if the trap button at the specified block is currently activated or not.

row
Row of the block at which to check for activation.
column
Column of the block at which to check for activation.

BackĄ¶


BoD2Library.Block.Trap

Function bool B_DeactivateTrap(int row, int column)

Returns whether or not the trap button was successfully deactivated.

row
Row of the block at which to deactivate the trap button.
column
Column of the block at which to deactivate the trap button.

Deactivates a trap button at the specified block row and column.

BackĄ¶


BoD2Library.Block.Trap

Function bool B_TrapDeactivated(int row, int column)

Returns true if the trap button at the specified block is currently deactivated or not.

row
Row of the block at which to check for deactivation.
column
Column of the block at which to check for deactivation.

BackĄ¶







Map Control Functions

Functions documented in this section:

BoD2Library.MapControl

Function void MC_ExitAvailable(bool silent)

silent

'Opens' any exit gates on the level (exit tiles created after this function is called will also be opened).

BackĄ¶


BoD2Library.MapControl

Function bool MC_ExitLevel(bool forceExit)

Returns whether or not the level can yet be exited.

forceExit
If true, forces an exit, regardless of whether or not MC_ExitAvailable was called.

Exits the level.

BackĄ¶


BoD2Library.MapControl

Function void MC_SetWorldFinishScript(int scriptNumber, int arg1, int arg2, int arg3)

scriptNumber
Script number for custom world finish script. Do not use script numbers 900 and above, they are reserved for the library.
arg1
First argument passed to the script.
arg2
Second argument passed to the script.
arg3
Third argument passed to the script.

Calls a user-defined script when the world is finished instead of the standard script.

BackĄ¶


BoD2Library.MapControl

Function void MC_WorldFinish(void)

Ends the current world and calls the world finish script.

BackĄ¶


BoD2Library.MapControl

Function void MC_GotoNextWorld(bool secret)

secret
If true, takes the player to the secret world (to play one level) instead.

Takes the player to the next world. By default, the player is taken to the secret level as a reward for collecting every sphere.

BackĄ¶


BoD2Library.MapControl

Script S_OPTIONALTIMER(void)

Starts a timer which counts the number of seconds it takes a player to complete the level. This script can be called at the start of a level by levelmakers who wish to set a better timelimit for their level.

BackĄ¶







Thing Control Functions

Functions documented in this section:

BoD2Library.Thing

Function int T_GetUnusedTID(void)

Returns a TID that is not already applied to a thing.

Every actor that is spawned in-game should call this function to give it a unique TID. Please do not give it any old number, otherwise the library might throw up errors and lead to unexpected behavior.

BackĄ¶


BoD2Library.Thing.Spawn

Function bool T_Spawn(int row, int column, str className, int spawnSkill, bool fog, int tid, int angle, bool hate, int removeFlags, int thingSpecial, int arg0, int arg1, int arg2, int arg3, int arg4)

Returns whether the thing was spawned successfully or not.

row
Row of the block to spawn the thing at. (1-16)
column
Column of the block to spawn the thing at. (1-16)
className
Name of the actor class to be spawned.
fog
If true, spawn a TeleportFog with the thing.
tid
TID of the spawned thing. Must be obtained from T_GetUnusedTID.
angle
Byte angle which the thing will face when spawned. All eight possible angles are listed below.
hate
If true, the spawned thing will target the player immediately.
removeFlags
Flags for the action upon removal. See more information in T_Remove.
thingSpecial
The action special to give the thing once it spawns.
arg0
First argument of the thing's special.
arg1
Second argument of the thing's special.
arg2
Third argument of the thing's special.
arg3
Fourth argument of the thing's special.
arg4
Fifth argument of the thing's special.
There are some built-in functions in the library to spawn special types of things, such as: These functions are designed for very specific purposes and should always be used to spawn these things. If something very specific is needed to be spawned, use this function.

BackĄ¶


BoD2Library.Thing.Spawn

Function bool T_SpawnNoSpecial(int row, int column, str className, int spawnSkill, bool fog, int tid, int angle, bool hate, int removeFlags)

Works exactly the same as T_Spawn, except this function will not apply an action special to the thing.

BackĄ¶


BoD2Library.Thing.Spawn

Function int T_SpawnEnemy(int row, int column, str className, int spawnSkill, int angle, bool hate)

Returns the TID of the spawned enemy. Zero for not spawning.

row
Row of the block to spawn the enemy at. (1-16)
column
Column of the block to spawn the enemy at. (1-16)
className
Name of the actor class to be spawned.
spawnSkill
The skill levels on which this enemy will spawn. Use the OR "|" operator to spawn it on several skill levels.
angle
Byte angle which the enemy will face when spawned. All eight possible angles are listed below.
hate
If true, the spawned enemy will target the player immediately.

Spawns an enemy with desired settings.

Do not use T_Spawn or T_SpawnNoSpecial to spawn enemies.

BackĄ¶


BoD2Library.Thing.Spawn

Function int T_SpawnSphere(int row, int column)

Returns the TID of the spawned sphere. If the sphere fails to spawn, zero will be returned.

row
Row of the block to spawn the sphere at. (1-16)
column
Column of the block to spawn the sphere at. (1-16)

Spawns a sphere at the specified block.

Do not use T_Spawn or T_SpawnNoSpecial to spawn spheres.

BackĄ¶


BoD2Library.Thing.Spawn

Function int T_SpawnItem(int row, int column, str className)

Returns the TID of the spawned item. If the item fails to spawn, zero will be returned.

row
Row of the block to spawn the item at. (1-16)
column
Column of the block to spawn the item at. (1-16)
className
Name of the actor class to be spawned.

Spawns an important pickup (keys, boots, etc.) at the specified block, without fog.

Do not use T_Spawn or T_SpawnNoSpecial to spawn items.

BackĄ¶


BoD2Library.Thing.Spawn

Function int T_SpawnItemFog(int row, int column, str className)

Works exactly the same as T_SpawnItem, but with fog.

Spawning items with fog is not the default behavior, which is why a fog argument is not included in T_SpawnItem.

BackĄ¶


BoD2Library.Thing.Spawn

Function int T_SpawnDecoration(int row, int column, str className)

Returns the TID of the spawned decoration. If the decoration fails to spawn, zero will be returned.

row
Row of the block to spawn the decoration at. (1-16)
column
Column of the block to spawn the decoration at. (1-16)
className
Name of the actor class to be spawned.

Spawns a static decoration at the specified block, without fog.

Do not use T_Spawn or T_SpawnNoSpecial to spawn decorations.

BackĄ¶


BoD2Library.Thing.Spawn

Function int T_SpawnDecorationFog(int row, int column, str className)

Works exactly the same as T_SpawnDecoration, but with fog.

Spawning decorations with fog is not the default behavior, which is why a fog argument is not included in T_SpawnDecoration.

BackĄ¶


BoD2Library.Thing.Spawn

Function int T_SpawnSwitch(int row, int column, str className, int switchIndex)

Returns the TID of the spawned switch. If the switch fails to spawn, zero will be returned.

row
Row of the block to spawn the switch at. (1-16)
column
Column of the block to spawn the switch at. (1-16)
classname
Name of the actor class to be spawned. (Usually "FloatingSwitch".)
switchIndex
The unique 'index' of this switch. Level designers must use this number to identify what happens in the S_SWITCHES script when the switch is triggered. Multiples switches with the same index in a level will perform the same action.

Spawns a switch 'pickup' at the specified block, without fog.

Do not use T_Spawn or T_SpawnNoSpecial to spawn switches.

BackĄ¶


BoD2Library.Thing.Spawn

Function int T_SpawnSwitchFog(int row, int column, str className, int switchIndex)

Works exactly the same as T_SpawnSwitch, but with fog.

Spawning switches with fog is not the default behavior, which is why a fog argument is not included in T_SpawnSwitch.

BackĄ¶


BoD2Library.Thing.Spawn

Function void T_SpawnBoulder(int row, int column, int angle)

row
Row of the block to spawn the boulder at. (1-16)
column
Column of the block to spawn the boulder at. (1-16)
angle
Byte angle which the boulder will face when spawned. All eight possible angles are listed below.

Spawns a boulder at specified block. BE CAREFUL! If a boulder is spawned immediately in front of a wall which it is facing, it will bounce around the level hectically. Place your boulders carefully.

Noted that this function does not have a return value. This is because all boulders share the same TID, which is controlled by the variable BoulderTID and is reset at the end of every level. BoulderTID will be initialized once the first boulder is spawned.

Do not use T_Spawn or T_SpawnNoSpecial to spawn boulders.

BackĄ¶


BoD2Library.Thing.Spawn

Function int T_SpawnProjectile(int row, int column, str className, int zAboveFloor, int angle, int speed, int vSpeed, bool gravity)

Returns the TID of the spawned projectile. If the projectile fails to spawn, zero will be returned.

row
Row of the block to spawn the projectile at. (1-16)
column
Column of the block to spawn the projectile at. (1-16)
className
Name of the actor class to be spawned.
zAboveFloor
Height (in mapunits) at which the projectile will spawn. If zero, the projectile will look like it is crawling on the floor.
angle
Byte angle which the projectile will face when spawned. All eight possible angles are listed below.
speed
Horizontal speed of the projectile (in units per 8 tics).
vSpeed
Vertical speed of the projectile (in units per 8 tics - up is positive).
gravity
Projectile is subjected to the map's gravity.

Spawns a projectile at the specified block.

Do not use T_Spawn or T_SpawnNoSpecial to spawn switches.

BackĄ¶


BoD2Library.Thing.Spawn

Function int T_SpawnTrap(int row, int column, str className, int angle, int trapIndex)

Returns the TID of the spawned trap thing. If the trap thing fails to spawn, zero will be returned.

row
Row of the block to spawn the trap thing at. (1-16)
column
Column of the block to spawn the trap thing at. (1-16)
className
Name of the actor class to be spawned.
angle
Byte angle which the trap thing will face when spawned. All eight possible angles are listed below.
trapIndex
Trap index. (0-63)

Spawns a trap thing at specified block.

Another way to get the TID of the trap thing is with its trap index - simply use TrapActorTID[trapIndex].

Never use T_Spawn or T_SpawnNoSpecial to spawn traps.

BackĄ¶


BoD2Library.Thing.Removal

Function void T_Remove(int tid, int forceWipeFlags)

tid
TID of the thing to be removed.
forceWipeFlags

Removes a thing by TID.

There are some built-in functions in the library to remove special types of "ALL" things like the following... These functions are designed for very specific purposes and should always be used to remove these things. If something very specific is needed to be removed, use this function.

BackĄ¶


BoD2Library.Thing.Removal

Function void T_RemoveEnemy(void)

Removes all enemies.

BackĄ¶


BoD2Library.Thing.Removal

Function void T_RemoveSphere(void)

Removes all spheres.

BackĄ¶


BoD2Library.Thing.Removal

Function void T_RemoveDecoration(void)

Removes all decorations.

BackĄ¶


BoD2Library.Thing.Removal

Function void T_RemoveItem(void)

Removes all items.

BackĄ¶


BoD2Library.Thing.Removal

Function void T_RemoveSwitch(void)

Removes all switches.

BackĄ¶


BoD2Library.Thing.Removal

Function void T_RemoveBoulder(void)

Removes all boulders, and resets BoulderTID.

BackĄ¶


BoD2Library.Thing.Removal

Function void T_RemoveTrap(int trapIndex)

trapIndex
Index of the trap.

Removes a trap by trap index.

Note that this function is named very similarly to the B_RemoveTrap, which deals with removing the behavior of trap buttons. This function deals with removing trap things, like barrels, stone heads, etc.

BackĄ¶


BoD2Library.Thing.Trap

Function void T_RegisterTrapTrigger(int tid)

tid
TID to register.

Registers a thing with the specified TID into the list of things that can trigger trap buttons. Things without prior registration cannot trigger trap buttons.

The thing to be registered needs to be spawned by T_SpawnTrap.

BackĄ¶


BoD2Library.Thing.Counting

Function bool T_SpheresLeft(int left)

Returns true if the number of spheres left in the level is lower than or equal to the specified amount, and updates the 'spheres left' display on the status bar accordingly.

left
Maximum amount that can be left.

BackĄ¶


BoD2Library.Thing.Counting

Function bool T_EnemiesLeft(int left)

Returns true if the number of enemies left in the level is lower than or equal to the specified amount.

left
Maximum amount that can be left.

BackĄ¶


BoD2Library.Thing.Counting

Function bool T_ItemsLeft(int left)

Returns true if the number of items left in the level is lower than or equal to the specified amount.

left
Maximum amount that can be left.

BackĄ¶


BoD2Library.Thing.Counting

Function bool T_DecorationsLeft(int left)

Returns true if the number of decorations left in the level is lower than or equal to the specified amount.

left
Maximum amount that can be left.

BackĄ¶


BoD2Library.Thing.Counting

Function bool T_SwitchesLeft(int left)

Returns true if the number of switches left in the level is lower than or equal to the specified amount.

left
Maximum amount that can be left.

BackĄ¶







Player Functions

Functions documented in this section:

BoD2Library.Player

Script S_ADDPOINT(int points)

points
Points to add. (A negative value will subtract points.)

Adds points to the player's score.

BackĄ¶


BoD2Library.Player

[0.3 alpha 7]

Function int P_GetBlockIndex(void)

Returns the block index from the player's current position. A return value of zero means that the player is outside the grid.

BackĄ¶


BoD2Library.Player

Function int P_GetAngleToBlock(void)

Returns the fixed point angle from the player to the center of the block field.

BackĄ¶


BoD2Library.Player

Function void P_Spawn(void)

Moves the player to the map's starting point. If there are multiple starting points, the library will randomly choose one.

BackĄ¶


BoD2Library.Player

Function bool P_Teleport(int index, int angle)

Returns player is successfully teleported or not.

index
Index of the block at the teleport destination. (1-256)
This can also be obtained automatically by using the function B_GetIndex.
angle
Fixed point angle. The player's angle will be set to this if teleportation is successful.

Teleports the player to the specified block.

BackĄ¶


BoD2Library.Player

Function void P_TakeAllEquipments(void)

Takes away all of the player's equipment, i.e. boots and suits.

BackĄ¶


BoD2Library.Player

Function void P_TakeAllKeys(void)

Takes away all of the player's keys.

BackĄ¶


BoD2Library.Player

[Changed in 0.3 alpha 7]

Function bool P_PressedUse(void)

Returns true if the player presses the use key.

BackĄ¶


BoD2Library.Player

Function void P_DrawHPBar(int initiate)

initiate

Starts or stops drawing the player's health bar.

BackĄ¶







Math Functions

Functions documented in this section:

BoD2Library.Math

[0.3 alpha 7]

Function int M_Abs(int number)

Returns the absolute value.

number
Number to be returned the absolute value.

BackĄ¶


BoD2Library.Math

[0.3 alpha 7]

Function int M_Min(int number1, int number2)

Returns the minimum value of the two.

number1
First number to be compared.
number2
Second number to be compared.

BackĄ¶


BoD2Library.Math

[0.3 alpha 7]

Function int M_Max(int number1, int number2)

Returns the maximum value of the two.

number1
First number to be compared.
number2
Second number to be compared.

BackĄ¶


BoD2Library.Math

[0.3 alpha 7]

Function int M_Sqrt(int number)

Returns the square root of an integer. If the input number is negative, zero will be returned.

number
Number of square root to be taken. Should be an integer, not fixed point value.

BackĄ¶


BoD2Library.Math

Function int M_Round(int number)

Returns a rounded fixed point number.

number
Number to be rounded.

BackĄ¶


BoD2Library.Math

[0.3 alpha 7]

Function int M_GCD(int number1, int number2)

Returns the greatest common divisor.

number1
First number.
number2
Second number.

BackĄ¶


BoD2Library.Math

[0.3 alpha 7]

Function int M_LCM(int number1, int number2)

Returns the least common multiple. Returns zero if the number cannot be found. (Usually caused by an overflowed number.)

number1
First number.
number2
Second number.

BackĄ¶


BoD2Library.Math

[0.3 alpha 7]

Function int M_IsPowerOf2(int number)

Returns the number is power of 2 or not.

number
Number to be checked.

BackĄ¶


BoD2Library.Math

Function int M_SplitAngle(int angle, int split)

Returns the fixed point angle that is closest to that of a circle divided into a certain amount of equal 'slices', specified by 'split'.

angle
Angle to be processed.
split
Amount of equal parts in which to divide a circle. Must be a power of 2.

BackĄ¶

BoD2Library.Math

Function int M_DistanceFixed(int tid1, int tid2)

Returns the distance (as a fixed point value) between two things.

tid1
Thing 1.
tid2
Thing 2.

BackĄ¶







Miscellaneous Functions

Functions documented in this section:

BoD2Library.Miscellaneous

Function void Misc_PlaySound(str sound)

sound
Sound name.

Plays the specified sound at full volume.

BackĄ¶


BoD2Library.Miscellaneous

Function void Misc_WarningSound(void)

Plays the warning sound. Usually for debug use.

BackĄ¶


BoD2Library.Miscellaneous

Function void Misc_ErrorSound(void)

Plays the error sound. Usually for debug use.

BackĄ¶


BoD2Library.Miscellaneous

Function void Misc_ClearHUDMessage(int hudID)

hudID
HUD ID.

Clears the HUD message with the specified ID.

BackĄ¶


BoD2Library.Miscellaneous

Function void Misc_ClearHUDMessageRange(int start, int end)

start
Starting HUD ID. Must be smaller than or equal to end.
end
Ending HUD ID. Must be greater than or equal to start.

Clears all HUD messages with IDs within the specified range.

BackĄ¶