Skip to content

Toolkit for working with scripts used by REDengine in Cyberpunk 2077.

License

Notifications You must be signed in to change notification settings

TarekJor/redscript

 
 

Repository files navigation

redscript

Toolkit for working with scripts used by REDengine in Cyberpunk 2077. Currently includes a compiler, a decompiler and a disassembler.

usage

Usage:
  decompile [opts]
  compile [opts]
Compiler options:
  -s, --src SRC        source file or directory
  -b, --bundle BUNDLE  redscript bundle file to read
  -o, --output OUTPUT  redscript bundle file to write
Decompiler options:
  -i  --input INPUT    input redscripts bundle file
  -o, --output OUTPUT  output file or directory
  -m, --mode MODE      dump mode (one of: 'ast', 'bytecode' or 'code')
  -f, --dump-files     split into individual files (doesn't work for everything yet)
  -v, --verbose        verbose output (include implicit conversions)
Lint options:
  -s, --src SRC        source file or directory
  -b, --bundle BUNDLE  redscript bundle file to use, optional

You can build the project and decompile all scripts in one command:

cargo run --bin redscript-cli --release -- decompile -i '/mnt/d/games/Cyberpunk 2077/r6/cache/final.redscript' -o classes.redscript

note: current version requires nightly version of rust (rustup default nightly)

language

The scripts use a Swift-like language:

public final const func GetReprimandPerformer(opt target: EntityID) -> ref<GameObject> {
  let agent: Agent;
  let performer: ref<GameObject>;
  let ps: ref<DeviceComponentPS>;
  if !EntityID.IsDefined(target) {
    target = GetPlayer(this.GetGameInstance()).GetEntityID();
  };
  if this.m_agentsRegistry.GetReprimandPerformer(target, agent) {
    ps = this.GetPS(agent.link);
    return ps.GetOwnerEntityWeak() as GameObject;
  };
  return null;
}

integrating with the game

You can integrate this compiler with the game and make it compile your scripts on startup. To set that up, you need to follow these steps:

  • Create Cyberpunk 2077\engine\config\base\scripts.ini file with the contents below
[Scripts]
EnableCompilation = "true"
  • Place the scc.exe tool in the following location:
    Cyberpunk 2077\engine\tools\scc.exe
    (The scc executable can be found in Releases)

  • Now you need to add some scripts. The compiler will look for scripts in Cyberpunk 2077\r6\scripts\
    You can copy the script below to Cyberpunk 2077\r6\scripts\lights.reds as an example:

@replaceMethod(CrossingLight)
protected final func PlayTrafficNotificationSound(status: worldTrafficLightColor) {
  return;
}

this mod will disable the walk don't walk crosswalk audio

You can find more script examples in resources/patches.reds in this repository.

About

Toolkit for working with scripts used by REDengine in Cyberpunk 2077.

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Languages

  • Rust 97.8%
  • Red 2.2%