Git Product home page Git Product logo

redscript's Introduction

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]
  lint [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 dump.reds

language

The scripts use a Swift-like language. You can find a brief overview of it's features in the official wiki.

You can also try it out in your browser.

For more examples, you can have a look at some projects using redscript:

editor support

There's a dedicated language server for redscript, with support for code editors:

integrating with the game

You can integrate this compiler with the game and make it compile your scripts on startup.

To set it up, you can download the redscript-mod-{version}.zip archive from the latest release and extract it in the main game directory. You should end up with the following files:

  • Cyberpunk 2077/engine/tools/scc.exe
  • Cyberpunk 2077/engine/config/base/scripts.ini

If the compiler is set up correctly it will save logs to Cyberpunk 2077/r6/cache/redscript.log whenever you start the game.

redscript's People

Contributors

alternaut avatar flibdev avatar forserx avatar fre-sch avatar jac3km4 avatar jackhumbert avatar striderxfossility avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

redscript's Issues

Nexus Version is (possibly) out of date

Simple issue, I don't think the Nexus version of this mod is broken. It crashes to desktop when using the Nexus version but the git hub version is fine

Not too important but still needs to be addressed

Error: CompileError("Function Size not found")

During startup the compilation error popup displays Error: CompileError("Function Size not found")

Script causing the error, copied and modified from decompiled final.redscripts:

@insert(FullscreenVendorGameController)
private final array<wref<gameItemData>> GetSellableJunk() {
    Int32 i;
    array<wref<gameItemData>> result;
    array<ref<gameItemData>> sellableItems;
    sellableItems = this.m_VendorDataManager.GetItemsPlayerCanSell();
    i = 0;
    while(i < Size(sellableItems)) {
        if(
            WeakRefToRef(
                RPGManager.GetItemRecord(sellableItems[i].GetID()).ItemType()
            ).Type() == gamedataItemType.Gen_Junk
            || WeakRefToRef(
                RPGManager.GetItemRecord(sellableItems[i].GetID()).ItemType()
            ).Type() == gamedataItemType.Con_Edible
        ) {
            Push(result, RefToWeakRef(sellableItems[i]));
        };
        i += 1;
    };
    return result;
}

Compiler source map fails if file doesn't end with newline

Ran across this edge case while I was digging through a monolithic classes.redscript and documenting things as comments in the new script file I was creating. I was using single line comments and hadn't put a newline at the end, it was commenting out the function annotation in the next file in the folder alphabetically.

Looks like it's because Files.add(...) in compiler/src/source_map.rs only splits on the newline character and just concatenates the source files together.

Easily avoided, but a possible issue. Perhaps fix with just forcing a newline at the end of every source file?

Crash when unregistering callback Input/Key

As I learned yesterday, the game will crash when I try unregistering my Input/Key callback:

class ExampleEnv extends ScriptableEnv {
  private let m_callbackSystem: wref<CallbackSystem>;

  private func OnLoad() {
    this.m_callbackSystem = GameInstance.GetCallbackSystem();
    this.m_callbackSystem.RegisterCallback(n"Input/Key", this, n"OnKeyInput", true);
  }

  private cb func OnKeyInput(event: ref<KeyInputEvent>) {
    // this crashes
    this.m_callbackSystem.UnregisterCallback(n"Input/Key", this, n"OnKeyInput");    
  }
}

Is there a list of callback-able events anywhere that I haven't found? I'm especially interested in HUD initialized

Decompiler output doesn't respect precedence

for instance on AIQuickHackAction method SetRegenBehavior generates:
regenMod.valuePerSec = 100.00 / multiplier * activationTime * statValue;
which should be
regenMod.valuePerSec = 100.00 / (multiplier * activationTime * statValue);

0.5.17.zip "can't be opened as an archive"

When trying to unpack redscript-v0.5.17.zip ( https://github.com/jac3km4/redscript/releases/tag/v0.5.17 ) I get said error message from 7zip. When opening it in the Windows Explorer it's empty. When using the built-in Windows11 extraction prompt an error shows saying "The ZIP folder is empty".

Edit:
I've been downloading over a dozen mods and it worked fine so far, but whether I download the redscript from github or nexusmods, the file is 0kb and empty. Downloaded it again via Microsoft Edge browser and it works fine. Not sure what Firefox was doing there.

Allow addField to struct and add new struct

addField to struct returns error: Can't find class <struct_name>
trying to add new struct returns error: expected one of "@"

I want to add fields to GameInstance struct so I can pass values among classes.

@replaceMethod on OnInitialize doesn't trigger on script load

As the title suggests, if I use replaceMethod on any of the OnInitialize functions it doesn't seem to trigger or run any of the code within the replaced method. Included some examples below:

Using native decompiled BackpackMainGameController code (no changes):

@replaceMethod(BackpackMainGameController)
protected cb func OnInitialize() -> Bool {
    let playerPuppet: wref<GameObject>;
    this.m_backpackInventoryListenerCallback = new BackpackInventoryListenerCallback();
    this.m_backpackInventoryListenerCallback.Setup(this);
    this.m_buttonHintsController = (this.SpawnFromExternal(inkWidgetRef.Get(this.m_buttonHintsManagerRef), r"base\gameplay\gui\common\buttonhints.inkwidget", n"Root").GetController() as ButtonHints);
    this.m_buttonHintsController.AddButtonHint(n"back", "Common-Access-Close");
    this.m_itemTypeSorting = InventoryDataManagerV2.GetItemTypesForSorting();
    this.m_TooltipsManager = (inkWidgetRef.GetControllerByType(this.m_TooltipsManagerRef, n"gameuiTooltipsManager") as gameuiTooltipsManager);
    this.m_TooltipsManager.Setup(ETooltipsStyle.Menus);
    this.RegisterToBB();
    this.SpawnFromExternal(inkWidgetRef.Get(this.m_itemNotificationRoot), r"base\gameplay\gui\widgets\activity_log\activity_log_panels.inkwidget", n"RootVert");
    this.PlayLibraryAnimation(n"backpack_intro");
    this.RegisterToGlobalInputCallback(n"OnPostOnRelease", this, n"OnPostOnRelease");
    playerPuppet = (this.GetOwnerEntity() as PlayerPuppet);
    this.m_psmBlackboard = this.GetPSMBlackboard(playerPuppet);
    this.playerState = IntEnum(this.m_psmBlackboard.GetInt(GetAllBlackboardDefs().PlayerStateMachine.Vehicle));
    this.OnInitialize();
}

Attempting to trigger Log statements:

@replaceMethod(BackpackMainGameController)
protected cb func OnInitialize() -> Bool {
    Log("Hello Backpack");
}
@replaceMethod(CraftingMainGameController)
protected cb func OnInitialize() -> Bool {
    Log("Hello Crafting");
}
@replaceMethod(FullscreenVendorGameController)
protected cb func OnInitialize() -> Bool {
    Log("Hello Vendor");
}

[Issue] redscript doesn't seem to work with 1.61 DLSS3 patch

[Issue] redscript doesn't seem to work with 1.61 DLSS3 patch

Pretty much just the title.
New patch dropped, which seemingly broke redscript.

Game at least doesn't want to run, with anything related to redscript enabled.

I'm not smart enough for a PR, but would be nice if you had the time to take a look at it ๐Ÿ‘

Kind regards,
VP-EN

Components

Greetings,

Do you have any idea how to get components scripts?

for example FppCameraComponet exist ingame, and there is also a class/function for it.

But, for example vehicleTPPCameraComponent, wich you call by FindComponent("vehicleTPPCameraComponent"), does not have any script ingame, but Cyber Engine Tweaks can Dump it, so there must be something.

Decompiled code not compiling

Copy pasting decompiled code and compiling again doesn't work for:

@replaceMethod(InventoryDataManagerV2)
private final func GetPlayerPartsInventoryData(slotID: TweakDBID) -> array<InventoryItemData> {

copying the vanilla function and compiling with redscript doesn't compile.

[ERROR - Tue, 24 Oct 2023 07:45:02 +0200] [NO_MATCHING_OVERLOAD] At F:\games\Cyberpunk 2077\r6\scripts\moremonowirehacks\moremonowirehacks.reds:21:35:
      ArrayPush(this.m_PartsData, new InventoryPartsData());
                                  ^^^^^^^^^^^^^^^^^^^^^^^^
expected 3 arguments for InventoryPartsData

it expects struct args, works if you give them.

Arithmetic operations possibly broken?

There's something weird going on with arithmetic operations. At first I tried something like this, because I noticed weird results in something I injected:

let a = 2.0;
let b = 3.0;
let c = 4.0;
let d = a * b + c; /* expect 10, not 14 */

Log("debug num: " + FloatToString(d));

However logs (in CET) showed neither 10.000000 or 14.000000, but 0.000000 instead.

Then I simplified it to:

let a: Float = 2.0;
let b: Float = 3.0;
let d: Float = a * b;
Log("debug num: " + FloatToString(d));

But it still logged 0.000000.

Immutability/strange behavior in user-defined classes

I'm noticing some odd behavior when I attempt to use my own custom classes in Redscript. It seems like either the class is not being initialized/instantiated properly or that the variables are immutable somehow.

Example:

class MyTestClass123 {
    public let myTestVar: String;
}
let testClass: ref<MyTestClass123>;
testClass = new MyTestClass123();
testClass.myTestVar = "Hello World!";
Log("My Test Var: " + testClass.myTestVar);

There are no compilation errors here, but I would expect to log My Test Var: Hello World! to the console. The above Log statement always returns comes back with a blank value for my the field in my class:
My Test Var:

If I use a pre-existing class it returns as expected:

public class GameAttachedEvent extends Event {
  public let isGameplayRelevant: Bool;
  public let displayName: String;
  public let contentScale: TweakDBID;
}
let evt: ref<GameAttachedEvent>;
evt = new GameAttachedEvent();
evt.displayName = "Hello World!";
Log("Display Name: " + evt.displayName);

Output:
Display Name: Hello World!

User-defined classes referenced in other classes out of declaration order return an error

I'm getting the following error when attempting to use my own classes. Note that this error does not occur during initial compilation (using redscript-vscode), only when running the game.

01:44:23 [ERROR] Unexpected error during compilation: PoolError("153166 is not a class")
Error: PoolError("153166 is not a class")

This error seems to be triggered when a class is used in another class before it has been declared. If I restructure the class to be declared before it's usage this error goes away. Additionally, if I add 1 in front of the file (so that the file is first in alphabetical order) it seems to get processed before any usage in another file and the error also goes away.

I would expect declaration/load order not to matter in this case.

Here's an example of something that's not working:

public class MyTestClass456 {
    public let myOtherTestClass: ref<MyTestClass123>;
}

public class MyTestClass123 {
    public let myTestVar: String;
}

However everything works fine if I restructure it like this:

public class MyTestClass123 {
    public let myTestVar: String;
}

public class MyTestClass456 {
    public let myOtherTestClass: ref<MyTestClass123>;
}

Member Undefined not found on EGameplayRole

Can't get access to Undefined member of EGameplayRole enum.
I guess it's also affects decompiler because there is a lot of missed references in dumped sources, like:

if Equals(this.GetCurrentGameplayRole(), EGameplayRole.) {
  // do something
};

V0.5.15 vs v0.5.16 Atelier reds Issue

I noticed when i installed the unreleased v0.5.16 version the atelier reds files that all previous versions have been ok with were suddenly an issue. It caused the all scripts to not load but game will launch anyway issue. I thought i should say something.

A device which does not exist was specified. (os error 433)

Firstly the reason I am posting this here it because it caused by redscript. My drives and OS arent the issue, being I've completely replaced my drives with brand new ones to test again.

This error happens at random, sometimes it is at launch, sometimes its while playing, it happens at random points. Normally you could just say okay and restart the game, or verify the game cache, etc. With this error specifically it locks the steamapps folder and makes all games on the drive where cyberpunk is located completely inaccessible. It entirely locks the steam apps folder, so you cannot open it via file manager either as you get the same error, but through windows.

image

Rebooting the pc makes the problem go away but the error will still occur again. Ive tried this with and without mods installed and get the same thing over and over again. Ive never had this problem before and after a week of trying to find a fix myself im making this post. Any help is appreciated.

Crash when replacing certain methods with v0.2.0-M1

I'm getting crashes when replacing some methods (so far only found 2 in the same class) that work fine with v0.1.11. GetCost() in BaseScriptableAction is an example. This replaced version (with changes only to swap RefToBool() with "blah != null") results in a crash when you scan something hackable in v0.2.0-M1:

@replaceMethod(BaseScriptableAction)
public func GetCost() -> Int32 {
  let costComponents: array<wref<ObjectActionCost_Record>>;
  let costMods: array<wref<StatModifier_Record>>;
  let targetID: EntityID;
  let statPoolCost: wref<StatPoolCost_Record>;
  let cost: Float;
  let extraCost: Float;
  let device: ref<ScriptableDeviceComponentPS>;
  let hackCategory: wref<HackCategory_Record>;
  if this.GetExecutor() != null && this.GetObjectActionRecord().GetCostsCount() > 0 {
    device = (this.GetOwnerPS(this.GetExecutor().GetGame()) as ScriptableDeviceComponentPS);
    if device != null && this.GetObjectActionID() == t"DeviceAction.TakeControlCameraClassHack" && device.WasActionPerformed(this.GetActionID(), EActionContext.QHack) {
      return 0;
    };
    this.GetObjectActionRecord().Costs(costComponents);
    if costComponents[0] != null {
      BaseScriptableAction.GetCostMods(AsRef(costComponents), costMods);
      if EntityID.IsDefined(this.GetRequesterID()) {
        targetID = this.GetRequesterID();
      } else {
        targetID = PersistentID.ExtractEntityID(this.GetPersistentID());
      };
      cost = RPGManager.CalculateStatModifiers(costMods, this.GetExecutor().GetGame(), this.GetExecutor(), Cast(targetID), Cast(this.GetExecutor().GetEntityID()));
      statPoolCost = (costComponents[0] as StatPoolCost_Record);
      if Equals(statPoolCost.StatPool().StatPoolType(), gamedataStatPoolType.Memory) {
        hackCategory = this.GetObjectActionRecord().HackCategory();
        extraCost = GameInstance.GetStatsDataSystem(this.GetExecutor().GetGame()).GetValueFromCurve(n"puppet_dynamic_scaling", this.GetPowerLevelDiff(), n"pl_diff_to_memory_cost_modifier");
        cost += extraCost;
        if hackCategory != null && Equals(hackCategory.EnumName(), n"UltimateHack") {
          cost += extraCost;
        };
      };
      if ArraySize(costMods) > 0 {
        return Max(1, CeilF(cost));
      };
      return Max(0, CeilF(cost));
    };
  };
  return 0;
}

Private visibility of method not honored in subclass

I accidentally left a private modifier on a method that is added to an existing CP77 class, this method is then called by its subclasses. To my surprise this works, although the visibility should be at least protected (at least by my assumption).

Try to apply PGO and/or BOLT

Hi! Thanks for the project.

Did you try to apply Profile-Guided Optimization (PGO) to Redscript toolkit? I guess it could improve the performance of the tooling even further (since it's in Rust so "blazing fast" you know). Applying BOLT could be more difficult since it's less stable.

Especially for Rust, I can recommend this blog: https://kobzol.github.io/rust/rustc/2022/10/27/speeding-rustc-without-changing-its-code.html More materials about PGO itself (showcases, useful links, etc): https://github.com/ZaMaZaN4iK/awesome-pgo

Crashing issues on latest release

the latest release of redscript is causing crashes in the game (im running on 2.01) have debugged with

other files being on latest releases
removing each and every single dependencies and testing them one by one turns out this one is causing issues.

Allow importing native structs/defining new structs

Currently we are unable to define custom/native structs, making a select few functions in the game's codebase unusable.

One example is the inkText widget which should allow the definition of a word-wrap policy:
myInkTextWidget.SetWrappingInfo(new textWrappingInfo(true, 1000000.0, textWrappingPolicy.Default));

Since the native struct textWrappingInfo is not exposed by default (and not able to be imported into Redscript currently) and we cannot define a custom struct we cannot actually pass in the required parameters. This makes defining custom widgets created in Redscript that also rely on text wrapping difficulty.

There may be other similar examples in the codebase as well.

Lint hangs when @wrapMethod is used with an incorrect header

This is similar to the block I had in my code, which caused lint to hang and grow in size until memory limits were reached:

@wrapMethod(hudCarController)
protected cb func OnRpmValueChanged()  -> Void {
  wrappedMethod();
}

Just for reference, this is the correct header that returns as normal;

@wrapMethod(hudCarController)
protected cb func OnRpmValueChanged(rpmValue: Float)  -> Void {
  wrappedMethod(rpmValue);
}

Thanks for all your work on this!

Allow classes to be enabled/disabled depending on if a module exists

@if(ModuleExists("ModuleName"))
public class ClassName {
// some code
}

This would be great for enabling or disabling settings options in-game depending if certain files have been downloaded. This would allow me to break up my mod into pieces so people can pick and choose which parts they want. This could be helpful if some parts of the mod wrap or replace certain methods that other mods also touch.

0.5.8 - constant pool error on launch

Consistently getting a constant pool error on launch - redscript.log is showing:

2022-11-19T17:51:15.628868Z [ERROR] Unexpected error during compilation: constant pool error: definition not found: 164498

How to make old version scripts compatible for v0.3.0-RC1

Thanks for your great work!
I'm trying to use some older-version scripts with redscript v0.3.0-RC1 but encountered errors such as:
Member HasStatFlag not found on DefaultTransition
Is there any easy hack for older-version scripts being compatible with v0.3.0-RC1?
Many thanks

Ability to add new members for enums

Is there any chance for a way we can extend enums with Redscript in the future?

I'm talking about syntax very similar to addField annotation for enums?
It should not break any existing enum dependent code blocks if im not mistaking, right?

One of the requests on Discord:

They're used a lot in handling events. Basically my use-case is wanting to potentially add another state to one of the existing enums so that the components listening to it can respond accordingly.

My use-case is actually same:
For example, I cannot add new sorting options to the game because to achieve this I have to update every place where ItemSortMode is used. Event handlers like OnDropdownItemClickedEvent use enums like this.

It's a shame we can't add new members to enums. But I'm not sure about feasibility of this.

Please Setup NexusMods page for RedScript

As the title says, please set up a Mod page for RedScript on NexusMods. It would only need to contain the release files and the scripts.ini within the appropriate folder structure.

The main purpose of this is for ModManager integration so that the user does not have to search for & apply changes manually.

If you do not want to then with your permission I would like to set it up, with full credit going to you & your team obviously.

0.5.9 - CLI does not run without optional arguments

There are no required arguments listed.
Everything under compiler options is optional.
My view is, without any arguments, it should run the same as if it was invoked during game launch.

d:\GAMES\Cyberpunk\r6\scripts>redscript-cli.exe compile
[INFO] missing required option `--src`
Usage:
  decompile  [opts]
  compile    [opts]
  lint       [opts]
Compiler options:
Optional arguments:
  -s, --src SRC        source file or directory
  -b, --bundle BUNDLE  redscript bundle file to use
  -o, --output OUTPUT  redscript bundle file to write
Decompiler options:
Optional arguments:
  -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 output into individual files
  -v, --verbose        verbose output (include implicit conversions)
Lint options
Optional arguments:
  -s, --src SRC        source file or directory
  -b, --bundle BUNDLE  redscript bundle file to use, optional

Thanks for checking!

Needs fix for 1.62-hotfix

Today's hotfix broke this. Causes this error when launching the game now.

image

There is nothing of value in the logs.

[INFO - Thu, 20 Apr 2023 13:45:10 -0400] Using defaults for the script manifest (manifest not present) [INFO - Thu, 20 Apr 2023 13:45:10 -0400] Compiling files: E:\SteamLibrary\steamapps\common\Cyberpunk 2077\r6\scripts\ArchiveXL\ArchiveXL.reds, E:\SteamLibrary\steamapps\common\Cyberpunk 2077\r6\scripts\CyberArms Collection Male Store-atelier-store.reds, E:\SteamLibrary\steamapps\common\Cyberpunk 2077\r6\scripts\food-atelier\Bar-atelier-store.reds, E:\SteamLibrary\steamapps\common\Cyberpunk 2077\r6\scripts\food-atelier\DrinkVendor-atelier-store.reds, E:\SteamLibrary\steamapps\common\Cyberpunk 2077\r6\scripts\food-atelier\FoodVendor-atelier-store.reds, E:\SteamLibrary\steamapps\common\Cyberpunk 2077\r6\scripts\infJump.reds, E:\SteamLibrary\steamapps\common\Cyberpunk 2077\r6\scripts\legendary-weapons-mods-eshop\WeaponsMods-atelier-store.reds, E:\SteamLibrary\steamapps\common\Cyberpunk 2077\r6\scripts\legendary-weapons-mods-eshop\WeaponsMuzzleScope-atelier-store.reds, E:\SteamLibrary\steamapps\common\Cyberpunk 2077\r6\scripts\LegendaryWeapons-atelier-store.reds, E:\SteamLibrary\steamapps\common\Cyberpunk 2077\r6\scripts\RecipeStore-atelier-store.reds, E:\SteamLibrary\steamapps\common\Cyberpunk 2077\r6\scripts\TweakXL\TweakXL.reds, E:\SteamLibrary\steamapps\common\Cyberpunk 2077\r6\scripts\virtual-atelier\atelier\AtelierTextButton.reds, E:\SteamLibrary\steamapps\common\Cyberpunk 2077\r6\scripts\virtual-atelier\atelier\Browser.reds, E:\SteamLibrary\steamapps\common\Cyberpunk 2077\r6\scripts\virtual-atelier\atelier\codeware\inkCharacterEvent.reds, E:\SteamLibrary\steamapps\common\Cyberpunk 2077\r6\scripts\virtual-atelier\atelier\codeware\inkCharacterEventType.reds, E:\SteamLibrary\steamapps\common\Cyberpunk 2077\r6\scripts\virtual-atelier\atelier\codeware\inkCustomController.reds, E:\SteamLibrary\steamapps\common\Cyberpunk 2077\r6\scripts\virtual-atelier\atelier\codeware\inkFitToContentDirection.reds, E:\SteamLibrary\steamapps\common\Cyberpunk 2077\r6\scripts\virtual-atelier\atelier\codeware\inkImage.reds, E:\SteamLibrary\steamapps\common\Cyberpunk 2077\r6\scripts\virtual-atelier\atelier\codeware\inkScrollArea.reds, E:\SteamLibrary\steamapps\common\Cyberpunk 2077\r6\scripts\virtual-atelier\atelier\codeware\inkWidget.reds, E:\SteamLibrary\steamapps\common\Cyberpunk 2077\r6\scripts\virtual-atelier\atelier\codeware\inkWidgetHelper.reds, E:\SteamLibrary\steamapps\common\Cyberpunk 2077\r6\scripts\virtual-atelier\atelier\codeware\TextInput\HubTextInput.reds, E:\SteamLibrary\steamapps\common\Cyberpunk 2077\r6\scripts\virtual-atelier\atelier\codeware\TextInput\Parts\Caret.reds, E:\SteamLibrary\steamapps\common\Cyberpunk 2077\r6\scripts\virtual-atelier\atelier\codeware\TextInput\Parts\Selection.reds, E:\SteamLibrary\steamapps\common\Cyberpunk 2077\r6\scripts\virtual-atelier\atelier\codeware\TextInput\Parts\TextFlow.reds, E:\SteamLibrary\steamapps\common\Cyberpunk 2077\r6\scripts\virtual-atelier\atelier\codeware\TextInput\Parts\TextMeasurer.reds, E:\SteamLibrary\steamapps\common\Cyberpunk 2077\r6\scripts\virtual-atelier\atelier\codeware\TextInput\Parts\Viewport.reds, E:\SteamLibrary\steamapps\common\Cyberpunk 2077\r6\scripts\virtual-atelier\atelier\codeware\TextInput\TextInput.reds, E:\SteamLibrary\steamapps\common\Cyberpunk 2077\r6\scripts\virtual-atelier\atelier\Computer.reds, E:\SteamLibrary\steamapps\common\Cyberpunk 2077\r6\scripts\virtual-atelier\atelier\ItemTooltips.reds, E:\SteamLibrary\steamapps\common\Cyberpunk 2077\r6\scripts\virtual-atelier\atelier\WebPage.reds, E:\SteamLibrary\steamapps\common\Cyberpunk 2077\r6\scripts\virtual-atelier\compat.reds, E:\SteamLibrary\steamapps\common\Cyberpunk 2077\r6\scripts\virtual-atelier\config.reds, E:\SteamLibrary\steamapps\common\Cyberpunk 2077\r6\scripts\virtual-atelier\constants.reds, E:\SteamLibrary\steamapps\common\Cyberpunk 2077\r6\scripts\virtual-atelier\declarations.reds, E:\SteamLibrary\steamapps\common\Cyberpunk 2077\r6\scripts\virtual-atelier\fields.reds, E:\SteamLibrary\steamapps\common\Cyberpunk 2077\r6\scripts\virtual-atelier\helpers\ButtonHintsHelper.reds, E:\SteamLibrary\steamapps\common\Cyberpunk 2077\r6\scripts\virtual-atelier\helpers\InputHelper.reds, E:\SteamLibrary\steamapps\common\Cyberpunk 2077\r6\scripts\virtual-atelier\helpers\NotificationHelper.reds, E:\SteamLibrary\steamapps\common\Cyberpunk 2077\r6\scripts\virtual-atelier\helpers\WidgetsHelper.reds, E:\SteamLibrary\steamapps\common\Cyberpunk 2077\r6\scripts\virtual-atelier\items-preview\Backpack.reds, E:\SteamLibrary\steamapps\common\Cyberpunk 2077\r6\scripts\virtual-atelier\items-preview\ItemPreview.reds, E:\SteamLibrary\steamapps\common\Cyberpunk 2077\r6\scripts\virtual-atelier\managers\CurrentPlayerZoneManager.reds, E:\SteamLibrary\steamapps\common\Cyberpunk 2077\r6\scripts\virtual-atelier\managers\ItemPreviewManager.reds, E:\SteamLibrary\steamapps\common\Cyberpunk 2077\r6\scripts\virtual-atelier\managers\StoresManager.reds, E:\SteamLibrary\steamapps\common\Cyberpunk 2077\r6\scripts\virtual-atelier\texts.reds, E:\SteamLibrary\steamapps\common\Cyberpunk 2077\r6\scripts\virtual-atelier\utils.reds, E:\SteamLibrary\steamapps\common\Cyberpunk 2077\r6\scripts\virtual-atelier\vendor-preview\ButtonHints.reds, E:\SteamLibrary\steamapps\common\Cyberpunk 2077\r6\scripts\virtual-atelier\vendor-preview\FullscreenVendor.reds, E:\SteamLibrary\steamapps\common\Cyberpunk 2077\r6\scripts\virtual-atelier\vendor-preview\FullscreenVendorHelpers.reds, E:\SteamLibrary\steamapps\common\Cyberpunk 2077\r6\scripts\virtual-atelier\vendor-preview\FullscreenVendorVirtual.reds, E:\SteamLibrary\steamapps\common\Cyberpunk 2077\r6\scripts\virtual-atelier\vendor-preview\GarmentItemPreview.reds [INFO - Thu, 20 Apr 2023 13:45:10 -0400] Compilation complete [INFO - Thu, 20 Apr 2023 13:45:10 -0400] Output successfully saved in E:\SteamLibrary\steamapps\common\Cyberpunk 2077\r6\cache

There was a mistake before entering the game

[ERROR - Wed, 25 Oct 2023 20:12:20 +0800] [SYM_REDEFINITION] At E:\DownLoad\ZhongZi\Cyberpunk 2077\Cyberpunk.2077.GOG.Rip-InsaneRamZes\Cyberpunk 2077\r6\scripts\player_underwear_removal_extended\native_definitions_incompatible_with_codeware.reds.reds:14:1: public native struct gameFppRepDetachedObjectInfo { symbol with this name is already defined [ERROR - Wed, 25 Oct 2023 20:12:20 +0800] [SYM_REDEFINITION] At E:\DownLoad\ZhongZi\Cyberpunk 2077\Cyberpunk.2077.GOG.Rip-InsaneRamZes\Cyberpunk 2077\r6\scripts\player_underwear_removal_extended\native_definitions_incompatible_with_codeware.reds.reds:19:1: public native struct gameTppRepAttachedObj^ectInfo { symbol with this name is already defined [ERROR - Wed, 25 Oct 2023 20:12:20 +0800] [SYM_REDEFINITION] At E:\DownLoad\ZhongZi\Cyberpunk 2077\Cyberpunk.2077.GOG.Rip-InsaneRamZes\Cyberpunk 2077\r6\scripts\player_underwear_removal_extended\native_definitions_incompatible_with_codeware.reds.reds:24:1: public native class gameTPPRepresentationComponent extends IComponent { symbol with this name is already defined [ERROR - Wed, 25 Oct 2023 20:12:20 +0800] [SYM_REDEFINITION] At E:\DownLoad\ZhongZi\Cyberpunk 2077\Cyberpunk.2077.GOG.Rip-InsaneRamZes\Cyberpunk 2077\r6\scripts\player_underwear_removal_extended\native_definitions_incompatible_with_codeware.reds.reds:30:1: public abstract native class gameuiICharacterCustomizationComponent extends IComponent {} symbol with this name is already defined
There was an error before entering the game, the following issues conflict with other pre-mods? What about other mo bugs that depend on this mod? Or is redscript itself wrong?

Cannot extend classes defined in modules

Presumably due to the name mangling that makes modules work.
Fixable with a pass over all the classes in the pool and update their base class name?

Example:
If I define a module:

module BaseModule

public class BaseClass {
  public func Foo() -> Void { Log("Base!"); }
}

and then in another script attempt to extend it:

import BaseModule.BaseClass

public class DerivedClass extends BaseClass {
  public func Foo() -> Void { Log("Derived!");  }
}

redscript is happy to compile it but Cyberpunk throws an error:
Cyberpunk2077_Error

wrapMethod causes issues with callbacks

  • @wrapMethod creates one method for every wrapper, but it looks like the game invokes every cb method on a class, so all of the wrappers get invoked
  • cb methods should take exactly one argument and it's type should extend Event, this could be enforced by the compiler

CTD on v1.63

I am experiencing crashes to desktop on patch 1.63.

Decompiler sometimes outputs 'this' instead 'super'

For example, try adding the following code:

@replaceMethod(MeleeDeflectAttackEvents)
  public func OnUpdate(timeDelta: Float, stateContext: ref<StateContext>, scriptInterface: ref<StateGameScriptInterface>) -> Void {
    let slowMoStart: Float = this.GetStaticFloatParameterDefault("slowMoStart", 0.10);
    if !this.m_slowMoSet && this.GetInStateTime() > slowMoStart && !this.IsTimeDilationActive(stateContext, scriptInterface, n"") {
      scriptInterface.GetTimeSystem().SetTimeDilation(n"deflect", this.GetStaticFloatParameterDefault("slowMoAmount", 0.10), this.GetStaticFloatParameterDefault("slowDuration", 0.10), this.GetStaticCNameParameterDefault("slowMoEaseIn", n"Linear"), this.GetStaticCNameParameterDefault("slowMoEaseOut", n"Linear"));
      this.m_slowMoSet = true;
    };
    this.OnUpdate(timeDelta, stateContext, scriptInterface);
  }

This results in a crash when doing a perfect block/parry on a melee attack. However, this code was copied directly from the dump created by redscript-cli - it's theoretically what the game script is already doing.

It seems like the game script is calling the parent class implementation when it calls this.OnUpdate(), but doing the same thing from a redscript file seems to cause the function to call itself instead. Which... then causes it to call itself... and then call itself... and then call itself... and then call itself... until the game crashes, with a stack trace that reports a stack overflow.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.