# Cyberpunk 2077 Source Code Guide ## Version 1.1 (2021.06.10) WARNING! Be aware that building and running the engine requires a system with good hardware (minimum 16GB of memory and SSD). ## Installing the requirements To be able to run the editor and engine, you first need to compile it. To do that you will need: - Cyberpunk 2077 source code (cp.7z) - Visual Studio 2017 with `Game development with C++` in `Workloads` and Visual C++ ATL/MFC for x86/x64 in `Individual components` (get it on microsoft website or here: https://gofile.io/d/q6qdZt). - The Xbox One SDK (get it from xbox.7z or here: https://gofile.io/d/QEnly7). (This is required for a clean release build but an alternate method is available below). You can also use Visual Studio 2019 with `Game development with C++` in `Workloads` and `MSCV v141 - VS 2017 C++ x64/86` and associated ATL/MFC in `Individual components`. You should also not retarget when prompted. If you don't want to install the Xbox One SDK, you can remove that requirement by patching some files. Patched source files are available here: `https://gofile.io/d/PdzDcm`. If you're lazy and don't want to compile the editor yourself or have trouble doing so, you can download a pre-compiled version here: https://gofile.io/d/mgG5kC. Telemetry is also disabled. Just dump the `bin` folder in the `Mainline` folder. ## Compiling the Editor First, extract the archive and install all of the requirements. Once you have installed VS2017 and the Xbox One SDK, you will need to prepare the VS2017 solution by going into the `Mainline` directory then executing the following command in your cmd or powershell: ``` .\tools\buildsystem\premake5.exe vs2017 --file=.\dev\src\premake5.lua --no-editandcontinue --no-incrementallink --mp-compilation ``` You can also use `r6_open_solution.bat` in `Mainline\dev\src` to prepare the solution. This will take a few minutes, and once completed will generate a new folder at `Mainline\dev\temp\vs2017`. Next, you can open the R6.sln file in ``Mainline\dev\temp\vs2017` using Visual Studio 2017 and change the target at the top from `Debug` to `Release` (for performance). To start the compilation process, right click on `Solution 'R6'` on the right panel then `Build Solution`. The compilation process can take between a few minutes to half an hour depending on your CPU and IO performance. If you have done everything correctly, the compilation should complete without any errors. ## Removing telemetry By default, the editor and engine have telemetry enabled trough `Galaxy64.dll`. You can disable it with one of the following method: Open `Mainline\dev\src\common\telemetry\src\telemetry.cpp` and comment line 31: `m_gogInsightsBackend = TryRegisterBackend( appType, RED_NEW( GOGInsightsBackend )( useAnonymousGalaxyMode ) );` with `//` in front of the line. This file is read-only, so you will need the remove that paremeter from windows file properties before editing. You can then recompile the engine. Editing `Galaxy64.dll` in `Mainline\bin\x64_DLL.Release` with an hex editor and edit the "galaxy-log.gog.com" calls. A pre-patched Galaxy64.dll with telemetry disabled is also available here: https://gofile.io/d/lnpb41 Blackhole the `galaxy-log.gog.com` domain at the host level by adding in `c:\windows\system32\drivers\etc\hosts` the following: ```0.0.0.0 galaxy-log.gog.com``` You can also block it at the DNS or firewall level. Block the following executables in your firewall or disconnect your internet connection: `editorLauncher.exe` `launcher.exe` `REDEngineErrorReporter.exe` in `Mainline\bin\x64_DLL.Release` ## Running the Editor To Launch the editor, simply execute `editorLauncher.exe` in `Mainline\bin\x64_DLL.Release`. Once launched, you should get a splash screen and a few minutes later the asset explorer. Some people report the editor not launching properly, if that's' the case for you, block the `editorLauncher.exe` executable in your firewall. ## Exploring content With the editor, you can explore the game assets and open them. Six main directories in the depot will be available to you: - `base` (contains all the game current assets) - `engine` (contains all the engine specific assets) - `gyms` (contains all the test maps developer uses to test the game features and logic) - `temp` (should be empty by default) - `test` (contains test map and content, mostly beta/alpha) - `user` (contains user made maps and content, some dev learning how to use the editor and beta/alpha stuff) ## Using the editor In the Asset viewer, you can search a specific file with its name and type using the search bar and filter. You can get any file real location by right clicking and `Show in explorer`. You can also copy the depot/absolute path. When opening a world or prefab, you can navigate in the viewport using `WASDQE` and go faster with `SHIFT`. You can also adjust the moving speed with the scrolling weel (really useful in big maps). Another useful thing to know is, you can use `F` while selecting a structure on the right tab to focus on it in the viewport. Finally, you can show the in-game render by selecting `Predefine: Game` in top bar. You can show the debug ui with `SHIFT` and `ALT` and enable the debug windows you want. Use `SHIFT` and `MMB` to enable the mouse overlay. You can find some future content by searching for "ep1" (Expansion Pack 1) in the test and user folder. Quest IDs start with a 0 for prologue, 1 for part 1, 2 for epilogue and 3 for ep1. A lot of old maps won't load properly because referenced prefabs are missing or are not at the same location they used to. Most of the E3 2018 (e318) doesn't work properly (crash or won't load). You can't save by default because most files have a read-only flag, to remove it use the following command in the `Mainline` directory: `attrib -r r6\depot\*.* /s` ## Interesting files and directories `base\worlds\03_night_city\03_night_city.world`: if you want to have a look at retail night city (warning heavy load and low fps). `test\test_worlds\01_night_city\`: early night city (won't load properly without fixing the refs). `test\level_design\cp2077_blockouts\`: early night city prefabs. `test\test_worlds\02_moon\`: the cut moon world and minimap (won't load properly without fixing the refs). `test\level_design\02_moon\`: a bunch of cut moon prefabs. `test\ep1\_combat_zone\combat_zone.world`: the main ep1 map (expansion of pacifica) ## Building and cooking the game To be able to play the game, you first need to build it and if you want to have good performances, cook the assets. To load any content in game, you must use a gamedef (Game definition) file. Game definition files allows you to build, cook and load maps with attached quests. The retail main game definition file is located at `base\quest\cyberpunk2077.gamedef`. When you open a gamedef file, you can change the world and main quest in the middle panel. Game options and settings can be changed in the right panel. Bellow is most important options that can impact the building process or the launch mode: - `Launch Mode`: `Dev` have all the debug ui, `Profiling` is used to test performance and `Final` is used for the final retail game. - `Script Version`: same as above but for the internal scripting system. - `PC Client`: can be used to build for specific windows client, you should use `Null`. - `Target Platform`: `PC Raw` doesn't cook any assets, so the performance are very bad. `PC Cooked` takes more time to build but all the assets are cooked (optimized for gameplay). `PC + Archive` is the same as cooked but cooked files are bundled into archive files like in the retail game. You should use `PC Cooked` or `PC + Archive` To start building, click on the `build` button on the top bar. Depending of the world and assets being built and your configuration, this process can takes between a few minutes to multiple hours. It's important to know that once assets are cooked, they don't need to be recooked again and as a result, future building can be much faster. All the cooked content will be stored at `Mainline\temp\cooked`, you can use the clean button to remove them. Archive files will be stored in `Mainline\archive`. The editor can also use to cooked content and that will make the viewport significantly faster, so you should cook the heavy maps you want to edit. ## Running the game Once the build process is completed, you can hit the `Play` button in the top bar to start the engine. You can also use `Play from save` to load a savefile. In the game engine, you can use `F3` to enable the freecam, `˜` for the console, `+` and `-` from the numpad to change the time dilation. You can show the debug ui with `SHIFT` and `ALT` and enable the debug windows you want. Use `SHIFT` and `MMB` to enable the mouse overlay. Some useful commands for the console: - `player.god()` to enable god mode. - `player.invisible()` to become invisible. - `player.infiniteAmmo()` to get infinite ammunition. - `player.teleport(x,y,z)` to teleport the player to a specific location. - `timeSystem.GetTime() to get the current time in the console. - `timeSystem.SetTime(d,h,m,s) to set a custom time for the world. You can see all of the available commands using `TAB` to autocomplete the console. You access the debug web interface from `http://127.0.0.1:PORT`. the `PORT` number is showned on the bottom right of screen in green. ## Automating the building and cooking Without needing modification, you can build and cook maps (with assets) by using the BuildForPlay.bat or CookForPlay.bat batch files in `Mainline\bin\x64_DLL.Release`. - `BuildForPlay.bat` will Compile TweakDB, Assemble Data and Make Archives for playing. This is the same as choosing "PC + Archives" in the General settings in the editor when a .gamedef has been opened. - `CookForPlay.bat` will only Compile TweakDB and Assemble Data for playing. This is the same as choosing "PC (Cooked)" in the General settings in the editor when a gamedef has been opened. ## Fixing the missing image spinner Navigate to Mainline\engine\editor\icons folder and scroll down to find the files spinner16_16.png, spinner32_32.png, spinner64_64.png, and open them with your favourite Image Editor (Paint.NET, Photoshop, etc). Resave them as PNG, overwriting the old ones, and save with sRGB (if possible, not required). You can then restart the editor, the spinner should work properly. ## Credits - Jenkins87 for fixing the image spinner and making the the automation process part. - hogsy for patching the source code that remove the requirements for the xbox sdk. - wpjero for finding how to remove telemetry from `Galaxy64.dll` - dogecore for finding how to disable telemetry in the engine code. ## Coming soon - Compile and run the Redtoolkit. - How to fix missing refs and prefabs. - How to fix the english localization. Still looking how to fix the sound system.