Core Engine Events
n Plugin.cpp, you’ll find functions automatically triggered by engine events — their names typically indicate their purpose. The call order of some functions is explained in the comments at the end of the file. These hooks are enabled via CApplication, which synchronously runs them across all loaded plugins.
Extending Game Classes
To add methods or variables to classes across all four Gothic engines in one go, use the UserAPI catalog. Locate the target class using the filter, and add your members — although IntelliSense may show errors, that’s just a limitation of the tech. Implementations can be placed anywhere in your project.
Only non-virtual methods, static functions, and static variables are safe to add. Virtual methods or modifying class sizes can break the virtual table or game stability.
Function & Method Hooks
Union supports two main hooking strategies:
- HOOK + AS: Uses MS Detours.
- HOOK + PATCH: Alters the call by patching the instruction.
To call the original function:
- Use the hook object like a pointer to function.
- For class methods, use this->*HookName or simplify with the THISCALL macro.
✅ Hook signatures must match originals. Union validates this at startup and throws an error if mismatched — helping prevent crashes.
🔁 Multiple plugins can hook the same function. Union queues them to ensure compatibility and shared execution.
You can hook either by function
name or
address.
Method | AS | PATCH |
Guarantee of 100% hook | Yes | No, if the call address is passed implicitly |
Compatibility with other extenders and patches | No | Yes |
Hook scope | The whole process | Module Gothic.exe |
Conditional Hooks (AS_IF / PATCH_IF):
These versions accept a third argument as a condition. If False, the hook is deferred. You can later activate it by calling .Commit() on the hook object.