Skip to content

ThpsQScriptEd\Understanding qScript

DCxDemo edited this page Apr 6, 2024 · 7 revisions

Return to ThpsQScriptEd

qScript is a scripting language created by Neversoft for THPS game series. It was in use since the original release of THPS3 and was later used in most Neversoft games and derivatives of their engine (i.e. Disney's Skate Adventure, GUN, Guitar Hero, etc). The logic behind the script language was to let programmers change the game behaviour without changing actual low-level C++ code. Game parses compiled script files at runtime and calls various game functions corresponding to the scenario described in loaded scripts. This basically allows players to mod the game.

qScript was basically an advanced general-purpose replacement for ideas behind trigger files of Apocalypse engine, used for NodeArrays in early THPS games.

On the data level, qScript compiles to a binary bytecode file with a qb extension (probably stands for Q binary). There is a set of operations available, bound to specific opcodes. The basic structure of the file is as follows:

opcode_struct
{
    byte opcode
    [xx bytes optional opcode data defined by opcode type]
}
do { read opcode_struct }
while opcode != 0

For example, a new function is declared with a "script" keyword, which is converted into byte 0x23 and the end of function is declared with "endscript" keyword, converted into 0x24.

Clone this wiki locally