0-beta Play Red Dead Redemption 2 as a Garry's Mod player.
Play Red Dead Redemption 2 as a Garry's Mod player: GMod's movement, HUD, weapons, physgun, toolgun and Q menu inside RDR2's world, with RDR2's people, horses, wagons and props reacting to GMod's physics.
It is a passthrough mod. Neither game is rewritten: Garry's Mod runs hidden next to RDR2 and owns the player and the sandbox, RDR2 owns its world, AI and rendering, and two plugins exchange state through shared memory every frame. CLAUDE.md has the architecture, docs/DESIGN.md the decisions and measurements, and docs/NATIVES.md every RDR2 native used with its hash.
Status: beta. All nine planned milestones are built and have been played on one machine (Windows 11, an NVIDIA card, RDR2 on Vulkan). It has not yet been installed on another PC. See Known issues.
| | |
|---|---|
| Red Dead Redemption 2 | Story mode, a version Script Hook RDR2 supports (tested: 1.0.1491.x) |
| Script Hook RDR2 | From http://www.dev-c.com/rdr2/scripthookrdr2/. Copy ScriptHookRDR2.dll and dinput8.dll (the ASI loader) next to RDR2.exe. It may not be redistributed, so it is not included here |
| Garry's Mod | The x86-64 branch (Steam, Properties, Betas), run as gmod_win64.exe |
| To build | Visual Studio 2022 or newer (or the Build Tools) with the C++ workload, and Python 3 |
ScriptHookRDR2.dll and dinput8.dll (the ASI loader) next to RDR2.exe. Then copy
RDR2\GarrysRedemption.asi from the zip to the same folder.GarrysMod folder over your Garry's Mod folder (the one that holds gmod_win64.exe). It
adds garrysmod\lua\bin\gmcl_gr_win64.dll, garrysmod\addons\garrys_redemption and
play_gmod.bat.GarrysRedemptionPassthrough.exe in the release folder does the steps above and below for
you. Keep it beside the release's RDR2 and GarrysMod folders and run it:
It needs nothing installed (it is built with the C# compiler that is part of Windows:
powershell -File launcher\build.ps1).
play_gmod.bat in the Garry's Mod folder (the launcher's PLAY does both). Click RDR2's
window again while GMod loads.Your own GMod binds work: move, jump, crouch, noclip, Q menu, C menu, weapons with the wheel
or number keys, undo, toolgun, numpad keys, thirdperson / firstperson. RDR2 keeps:
| Key | | |---|---| | Esc, P | RDR2's pause menu | | M | RDR2's map | | F9 | Hand the player to RDR2 (to ride, shop or play a mission) and back |
The list is in rdr2/src/input_passthrough.h. When RDR2 runs a scene, or you mount a horse
or a wagon, RDR2 takes the player until it ends.
Your health is GMod's, and it carries over to Arthur when RDR2 takes the player and back; each session starts at full health. When you die you hear GMod's death beep and come back a few seconds later where you fell.
As Arthur, stay out of New Austin (Armadillo, Tumbleweed, Benedict Point and around): the game has him shot on sight there until the epilogue. The Q menu's teleport refuses those towns for him.
GMod console variables (all start with gr_; the defaults are what was tested):
| Variable | Default | |
|---|---|---|
| gr_damage_scale | 3 | RDR2 health taken per point of GMod damage |
| gr_weapons | 1 | GMod's hits and explosions happen in RDR2, and RDR2 hurts the GMod player |
| gr_bullet_impacts | 1 | GMod's bullets hit RDR2's trees, walls and rocks |
| gr_surfaces | 1 | Grenades, balls, rockets and thrown things bounce off RDR2's trees and houses |
| gr_gmod_shots_in_rdr2 | 0 | RDR2's people also hear GMod's own guns |
| gr_rdr2_gun_gmod_sound | 0 | RDR2's guns also play a Half-Life 2 gunshot |
| gr_physgun_range | 16384 | Physgun reach in units while linked (GMod's own: 4096) |
| gr_noclip_fast_speed | 4000 | Noclip speed with Shift held |
| gr_respawn_delay | 3 | Seconds after death before you come back by yourself |
| gr_thirdperson_distance | 110 | Third-person camera distance |
| gr_collide, gr_near_collide, gr_terrain | 1 | RDR2's walls, nearby trees and objects, and ground are solid in GMod |
| gr_tools | 1 | Toolgun tools act on RDR2's entities |
| gr_world, gr_world_shadow, gr_world_veil, gr_world_occlude | 1 | GMod's props in RDR2's world: drawn, with shadows, behind RDR2's trees, behind RDR2's ground and walls |
| gr_viewmodel_light, gr_light_match | 1, 2.2 | The viewmodel and props lit by RDR2's light; brightness match |
| gr_view_lock, gr_view_hold_frames, gr_look_predict | 1, 0, 1 | GMod draws with the camera RDR2 shows; extra frames of hold if GMod's picture trails |
| gr_overlay, gr_cursor_speed | 1, 1 | GMod's picture over RDR2; menu cursor speed |
| gr_hide_window, gr_match_resolution, gr_quit_with_rdr2 | 1 | GMod's window hidden, at RDR2's resolution, and closed with RDR2 |
| gr_input, gr_keep_active | 1 | RDR2's keyboard and mouse drive GMod; GMod keeps full speed in the background |
Commands: gr_status, gr_proxies, gr_terrain_status, gr_weapons_status,
gr_tools_status, gr_surfaces_status, gr_near_status, gr_overlay_status, gr_spawn NAME,
gr_teleport NAME, gr_god, gr_heal, gr_clear_wanted, gr_possess, gr_unpossess,
gr_thirdperson, gr_firstperson, gr_vehicle_view.
The RDR2 plugin reads an optional GarrysRedemption.ini next to the .asi (or in %TEMP%):
[GarrysRedemption]
status_text=1 ; 0 = no status line on screen
hide_hud=1 ; 0 = RDR2's minimap and health cores stay while GMod has the player
collide=1 ; 0 = RDR2's walls and objects do not stop the player
hold_rigid=0 ; 1 = people held by the physgun stay stiff instead of ragdolls
terrain_budget_us=1000 ; time per frame for sampling RDR2's ground
smooth=1 ; 0 = no extrapolation of the GMod player by frame age
verbose=0 ; 1 = log frame statistics
GarrysRedemption.log next to the .asi, or in %TEMP% when the game folder
is not writable (it is not under C:\Program Files).GarrysRedemption_gmod.log in garrysmod/lua/bin/ (same fallback), and GMod's
console (garrysmod/console.log with -condebug)..asi and the GMod module are from
different builds. Install both from the same release.gr_proxies should list the people around you; if it says
0, the plugin log's world: line says what RDR2 answered.ScriptHookRDR2.dev file is next to
RDR2.exe.Not yet checked by hand: grenades, rockets and bolts against trees; wheels and thrusters on wagons; hoists; ropes on people; possessing horses and animals; RDR2's long guns in view. docs/TESTING.md has the in-game test steps for every feature.
powershell -File tools\build.ps1
This builds protocol/ (tests and tools), rdr2/ (GarrysRedemption.asi) and
gmod/module/ (gmcl_gr_win64.dll), then runs the C++ and Python tests. CMake does not
need to be on PATH: the copy bundled with Visual Studio is found automatically.
The GMod module needs Facepunch's module headers, which are fetched once per machine:
git clone --depth 1 --branch development https://github.com/Facepunch/gmod-module-base gmod/module/third_party/gmod-module-base
The RDR2 plugin links without the Script Hook SDK (its import library is generated from
rdr2/scripthook_imports.def). If you unpack the SDK into rdr2/sdk, its own library is
used instead.
To build one project by hand, run CMake from inside its folder:
cd rdr2
cmake --preset default
cmake --build --preset release
Set the two game folders once, then package:
setx GR_RDR2_DIR "<folder that holds RDR2.exe>"
setx GR_GMOD_DIR "<folder that holds gmod.exe and the garrysmod folder>"
powershell -File tools\package.ps1
| File | Goes to |
|---|---|
| GarrysRedemption.asi | next to RDR2.exe |
| gmcl_gr_win64.dll | garrysmod/lua/bin/ (GMod only loads binary modules from there) |
| gmod/addon/ | garrysmod/addons/garrys_redemption/ |
Without the variables, package.ps1 only fills dist/ and writes dist/GarrysRedemption.zip.
If RDR2 is under C:\Program Files (where the Rockstar launcher puts it), Windows asks for
administrator rights for the one copy into that folder.
| | |
|---|---|
| tools/fake_rdr2.py | Stands in for the RDR2 plugin: lets the GMod side be tested alone |
| tools/fake_gmod.py | Stands in for the GMod module: lets the RDR2 side be tested alone |
| tools/memdump.py | Read-only dump of the shared memory (--watch, --json, --all) |
| protocol/build/Release/gr_probe.exe | Console host or guest running the real C++ link code |
| rdr2/build/harness/Release/asi_runner.exe | Runs the real GarrysRedemption.asi without RDR2, against a stand-in for Script Hook (tools/fake_scripthook) |
| tools/gmod_restart.sh | Restarts GMod with the freshly built module and addon |
| protocol/build/Release/gr_screen.exe | Saves what the primary monitor really shows (half size BMP). tools/rdr2_grab.py reads the screen through GDI, which can return a stale picture of a full-screen RDR2 |
| tools/overlay_dump.py | Turns a gr_overlay_dump file into PNGs (colour and alpha) |
| tools/gmod_live_test.py | Starts GMod and tests the module in the real game against fake_rdr2.py, with nobody at the keyboard |
| | |
|---|---|
| protocol/ | gr_protocol.h (the shared memory layout both sides include), units, the link and seqlock, C++ tests |
| common/, cmake/ | The logger and compiler settings both C++ sides share |
| rdr2/ | The RDR2 plugin (GarrysRedemption.asi), C++20 |
| gmod/module/ | The GMod binary module (gmcl_gr_win64.dll), C++20 |
| gmod/addon/ | The GMod addon (Lua): lua/gr/ one file per feature, lua/entities/ |
| launcher/ | The release's launcher (Launcher.cs) |
| tools/ | Build, package and test scripts, stand-ins for each game |
| docs/ | Design notes, the natives used, in-game test steps |
Issues and pull requests are welcome. Read CLAUDE.md first: it has the rules (story mode only, no game assets, every native verified, one protocol header) and the code style. Test a change in the real games and put the steps in the commit message.
Fan project. Not affiliated with or endorsed by Rockstar Games, Take-Two Interactive, Valve or Facepunch Studios. Red Dead Redemption and Garry's Mod are trademarks of their owners. No game assets are included; you must own both games. Code under the MIT licence: see LICENSE.
The Q menu's list of RDR2 model names is not in this repository: tools/gen_models.py
generates it at build time from rdr3_discoveries.