Modding Introduction #66
HJHughJanus
started this conversation in
General
Replies: 3 comments 3 replies
-
Apparently Cyberdoc moved: https://cyberdoc.surge.sh/ |
Beta Was this translation helpful? Give feedback.
3 replies
-
Just a reminder, the directory has been changed to "C:\Games\Cyberpunk 2077\r6\cache\modded\final.redscripts.bk" |
Beta Was this translation helpful? Give feedback.
0 replies
-
Hey, |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Cyberpunk 2077 Modding Introduction (redscript)
This is a short introduction on how to get started with modding Cyberpunk 2077 using redscript.
It will help you set up your game (so you are able to load redscript mods) as well as your Visual Studio Code (so you are able to create them).
Setting up your Cyberpunk 2077 installation
Setting up VS Code
References
Red Modding Wiki
Source: https://wiki.redmodding.org/redscript/language/intro
How to use: Self-Explanatory :)
Cyberdoc
Source: https://jac3km4.github.io/cyberdoc
How to use: This is a searchable compendium including native functions, classes, etc..
Example: If you wanted to know which ragdolling functions there are, you could search for the keyword „ragdoll“ and check the results.
Decompiled Game Scripts
Source: https://codeberg.org/adamsmasher/cyberpunk/src/branch/master/
How to use: Download the whole bunch of data as a zip-file and either use Notepad++ or VS Code to search it.
Example: If you wanted to know how the ragdolling functions you found with Cyberdoc are actually used, you search the function name in the decompiled game scripts and can find lots of examples of how the function is used in game.
Native Database
Source: https://nativedb.red4ext.com/
How to use: This is a searchable compendium of native classes, enums and bitfields. It also includes native functions and fields, but they do not show up in the search, unfortunately. If you know in which class to look for, you can find the fields and functions there.
Example: If you didn‘t find something in Cyberdoc or want to check if there is more information on it, use the Native Database.
How to create a hook (with code snippets)
How to overwrite or extend game functions is explained in the Red Modding Wiki.
Injecting your code without altering anything existing works via wrapping.
Once you‘re sure what you want to do, you need to find out which system and which function within that system handles something close to your goal and then use this function as a wrapper function for your code.
Example
Goal: Ragdoll any NPC hit by a bullet.
System: I need to find out how Cyberpunk 2077 handles bullets and damage → a look through the decompiled game scripts shows there is a class called „DamageSystem“. This class looked up on Cyberdoc shows there is a function wihtin that class called „ProcessLocalizedDamage“. Back in the decompiled game scripts the code of this function seems to handle a „hit event“ and checking if the bullet hit the head or any weak spots. That is very close to my goal, so I will use this function for the hook.
Functions: I want to ragdoll an NPC, so I will need a function to do that. I search on Cyberdoc for „ragdoll“ and find something called „ApplyRagdollImpulseEvent“. I search this function in the decompiled game scripts to find out how it is used.
Code: First, I need to specify which system I want to use for injection, then specify the function.
In this function I must now call the vanilla function first, so I don‘t overwrite any of the vanilla action – you can do this via the function wrappedMethod(params) (this one automatically calls the vanilla function).
Then I copy some code from the vanilla function to handle some errors and set up my variables.
Now my actual code can take effect. Since I found the „ApplyRagdollImpulseEvent“ and looked up how it is used, I know this will not be done in one line. So, to keep the code in the wrapper function simple, I will write a separate function below which sets up the ragdolling for me.
This function I will now use above to ragdoll the hit NPCs.
The whole file now looks like this:
This file I save and then put into _D:\PATH\TO\CYBERPUNK2077\r6\scripts_ so the game will load it.
When I start the game, every NPC hit by a bullet should be ragdolled with a push.
Beta Was this translation helpful? Give feedback.
All reactions