Skip to content

Latest commit

 

History

History
66 lines (59 loc) · 2.24 KB

File metadata and controls

66 lines (59 loc) · 2.24 KB

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:
  -i, --input INPUT    input source file
  -b, --bundle BUNDLE  redscript bundle file to read
  -o, --output OUTPUT  redscript bundle file to write
Decompiler options:
  -i, --input INPUT    input 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)

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

cargo run --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 Java-like language:

  public final const ref<GameObject> GetReprimandPerformer(EntityID target?) {
    Agent agent;
    ref<GameObject> performer;
    ref<DeviceComponentPS> ps;
    if(!EntityID.IsDefined(target)) {
      target = GetPlayer(this.GetGameInstance()).GetEntityID();
    };
    if(this.m_agentsRegistry.GetReprimandPerformer(target, agent)) {
      ps = this.GetPS(agent.link);
      return cast<GameObject>(WeakRefToRef(ps.GetOwnerEntityWeak()));
    };
    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:

@insert(CrossingLight)
protected final void PlayTrafficNotificationSound(worldTrafficLightColor status) {
  return;
}

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