Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/twhl-community/halflife-unified-sdk/llms.txt

Use this file to discover all available pages before exploring further.

Opposing Force introduces two new entity classifications on top of the ones present in the base Half-Life game. Because these additions change the NPC relationship matrix, the corresponding relationship table entries need to be extracted from the Opposing Force server library and incorporated into the Unified SDK’s entity classification system. This tutorial walks through the extraction process using GDB on Linux, which allows you to read the relationship table directly from memory at runtime.

Prerequisites

  • A Linux system with GDB installed
  • The Half-Life dedicated server or client installed, including the gearbox mod directory
  • Familiarity with running commands in a terminal

Extracting the table

1

Set up the library path and launch GDB

Open a terminal and navigate to your Half-Life installation directory. Set the LD_LIBRARY_PATH environment variable so the game’s shared libraries can be found, then start GDB:
cd <path_to_Half-Life_directory>
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:<path_to_Half-Life_directory>
export LD_LIBRARY_PATH

gdb
2

Load the Half-Life executable and set the game arguments

Inside GDB, load the Linux Half-Life executable and configure it to run with the Opposing Force (gearbox) mod:
file hl_linux
set args -game gearbox
3

Run the game and load a map

Start the game with the run command. Once it is running, start a map inside the game so that the server DLL is fully loaded into memory. The relationship table only becomes accessible after the DLL is initialised:
run
Start a map from the in-game console or through the game menu before proceeding.
4

Enable GDB logging

Configure GDB to write its output to a log file, then enable logging:
set logging file log.txt
set logging on
5

Create and run the GDB extraction script

Create a file named gdb_script.gs with the following GDB script. It iterates over the 16×16 relationship matrix and prints each entry:
set $i = 0
while($i < 16)
	set $j = 0
	while($j < 16)
		printf "\t%d, ", *( &'CBaseMonster::IRelationship(CBaseEntity*)::iEnemy' + $i * 16 + $j )
		set $j = $j + 1
	end
	printf "\n"
	set $i = $i + 1
end
Then source the script from within GDB to run it:
source gdb_script.gs
The output will be written to log.txt in your working directory.
6

Integrate the extracted data

Open log.txt and locate the printed matrix. The Opposing Force additions correspond to the last 2 columns and rows of the 16×16 table. Take those entries and add them to the existing relationship table in the Unified SDK’s entity classification system.Once added, verify that the pre-existing entries in the table still match the values extracted from the matrix to ensure nothing has been inadvertently altered.
The extraction must be performed on the Linux version of Half-Life and Opposing Force because GDB is used to inspect memory at runtime. The Windows debugging workflow does not provide the same straightforward access to the symbol CBaseMonster::IRelationship(CBaseEntity*)::iEnemy needed for this script.
If GDB cannot find the symbol CBaseMonster::IRelationship(CBaseEntity*)::iEnemy, confirm that the server DLL has been loaded by verifying you have started a map before running the script. The DLL is loaded on demand and the symbol will not be present in memory until then.

Build docs developers (and LLMs) love