RedMod Script AKA "Cyberpunk 2077 Script" is a proprietary [[Domain Specific Programming Language]] written in [[C++]]. - [Website](https://www.cyberpunk.net/en/modding-support) > ??? # Notability The official scripting language used by [[CDProjekt Red]] for [[Cyberpunk 2077]]. Not to be confused with [[REDscript]], which is also used for [[Cyberpunk 2077]] by the modding community. # Philosophy ## Name This scripting language, which some call "RedMod script" is actually completely unnamed in the (exceedingly brief) RedMod documentation. Likely, [[CDProjekt Red]] did not call it "RedMod script" internally, as they used it to build the entire game with. I am tempted to call it "C2077 script" but no one else calls it that. ## Documentation There is *no* official (public) documentation of any kind on this language that I can find anywhere. However, it ships with around *half a million* lines of scripts extracted from the game itself, so presumably this is the same language and tool they use internally, or at least a version of it. Using [[WitcherScript]] as a starting point seems like the only route to understanding how it works, due to their similarity. ## WitcherScript It is clearly a descendant of [[WitcherScript]], but seems to have been considerably simplified. ### Function Specifiers The [[WitcherScript#Function Specifiers]] are now optional and quite rare in the main corpus aside from a few that seem to be more similar to [[C++]] and generic rather than game-specific. - `public` / `protected` / `private` - `static` / `const` / `constexpr` - `import` / `export` - `override` - `virtual` - `final` - `testonly` - `quest` There is only one example of a `quest function` in the corpus and 7 examples of `testonly`. On the other hand it seems that visibility must be tagged on every single function individually, with somewhere north of 27,000 examples of `public` and over 7,000 each of `private` and `protected`. There are no examples of `exec`, `timer`, `latent`, or `reward` in the corpus. # Platform Support # Features # Example Taken from the corpus: ```kotlin function IsFriendlyTowardsPlayer( object : weak< GameObject > ) : Bool { var player : weak< PlayerPuppet >; if( !( object ) ) { return false; } player = GetPlayer( object.GetGame() ); if( player && GameObject.GetAttitudeTowards( object, player ) == EAIAttitude.AIA_Friendly ) { return true; } return false; } ``` # Tips # Resources ## Editor Syntax Highlighting - https://github.com/alternaut/redmodscript-lang ## Tutorials These tutorials are *unlisted* and links to them can only be found from the website or forums. ```cardlink url: https://youtu.be/aq_4U5N-CP4 title: "Cyberpunk 2077 — REDmod Tutorials: Episode 2" description: "Take your first steps in Cyberpunk 2077 modding with Moritz, one of the REDmod developers! In the second episode of our REDmod Tutorials we’ll answer some of..." host: youtu.be favicon: https://www.youtube.com/s/desktop/f893a131/img/logos/favicon_32x32.png image: https://i.ytimg.com/vi/aq_4U5N-CP4/maxresdefault.jpg ``` ## Corpus The "corpus" is what I call the giant collection of raw [[RedMod Script]] that ships with the RedMod DLC. It contains a snapshot of the entire collection of scripts used by the core of the game, sans comments. The files can be found here, containing hundreds of thousands of lines of original game code: ```sh Cyberpunk 2077/tools/redmod/scripts ``` This is the source of the bytecode that was [[REDscript#Original Scripts Decompiled to REDscript|decompiled into REDscript]] by the community, (though likely from a different snapshot in time). # References [^1]: https://old.reddit.com/r/GamingLeaksAndRumours/comments/16rx7s5/cyberpunk_2077_20_source_code_leak_unnoticed/k588ksc/