Assembly Editing and Reflexil Instruction

[You may want to sticky this in the mods forum as this is purely a resource thread for modifying the Assembly-CSharp.dll]

ASSEMBLY-CSHARP.DLL

The amount of modding now taking place in the Assembly-CSharp.dll is increasing. Over the last month, my mod, which normally involved changing some random variables, started to become getting more complex, with several new functions being created. As we're currently using ILSPY and REFLEXIL, changing code isn't as simple as writing some C#, but rather altering the 'instructions' and 'opcode' in the dll, altering the code indirectly.

I was talking to Hudson (who many of you may remember did the original blue-flag fix) who taught me how to use these tools, and we talked about storing our changed codes somewhere, mostly for reference, but may benefit some other modders who wish to change their own dlls - or maybe get some more people into modding the game in general.

EDITING THE ASSEMBLY
To edit the Assembly-CSharp.dll you will need:
ILSPY (http://ilspy.net/)
REFLEXIL pluggin for ilspy (http://reflexil.net/)

I'll post below examples of modified code and what they do (I won't show simple number changes, as that would not really be showing anything at all). I'll focus on the areas of the game I have modded as part of my Balance Mod where changes to code has taken place. I won't do them all at once, but when I find time I'll share the code and some insights here.

Others who are modifying this file, please share your work also so we can get a decent database of changes.

UPDATE:

New Editing Techniques

So, when I first started modifying the code, we could really only go one level - via an Injector, I could change some values. Then, one day, we leveled up! Level 2 let us use Relfexil/ILSpy to edit more of the code and begin really making some changes.

This weekend we upgraded to Level 3! We have a new tool provided to us (and thanks to Robery Eady who provided the link). Now we have DNSpy. https://github.com/0xd4d/dnSpy/releases

What's so special about DNSpy? Well, this:

R49IbZLdo.png

Yes! We can now edit the code directly using normal coding methods!

As an example, in just a few minutes, I created that so during a collision, the part chosen is more random.

Original ILSpy
R3vUJgqc4.png


Edited with DNspy
R439hjgha.png


Checking with ILspy that everything is fine!
R436ZRmNY.png


And it works fine!
Race 1:

R3Y7Tcz52.png

R3Y5dvH8Y.png

R3Y3xX60S.png

Race 2:

R42396clE.png

(obviously, damange to these parts isn't going to be added to the mod, but I could have collisions to the rear mean its Rear Wing Damage 20% of the time, and Suspension 50% of the time, and no damage the last 30% of the time)

What this means for the mod

So, now I can edit the code, this means that:

  • I can make far more complex changes.
  • I can make them faster
  • As I am literally changing code, I can copy all my changes into a .txt document. This means that when I have to update the mod to a new dev patch, I can use CTRL+C and CRTL+V to update an entire class, instead of spending an hour having to remake the opcodes!
This means that I can now add as many features as I desire, and I am nearly unrestricted. Because, though I have not began to test it yet, DNSPY has this:

R4myWUclO.png

If I can add classes, I can create entirely new features from scratch. Define new variables, craft new systems. I can make as many rules and manipulate variables however I wish to craft them. This means I can probably make new 'Season Rules', extend the amount of tiers, bascially anything I want.

I still cannot make new "Game Objects", or make new UI, but the scope of watch's acheiveable has probably increased 10-fold. Which is why I asked for wishlists... Anything Code Related is probably now possible. Some things will be simpler then others, but now almost anything is possible.

All this means is that we have New Powers. And more importantly, it means more people are probably going to be able to edit the code themselves (learning opcodes is was a new and long process, but as a mathematician, I can IF and For anything with ease just from seeing examples). This may mean I can get some more collaborators and help making new features!

 
Last edited:
Hello everyone, I'm trying to make a skip button in race both in practice or qualification.
Class - PreSessionHUBState, method - OnContinueButton()

xsqL6XW.png


I change OnTakeSessionConfirmed () on OnStartSessionButton ()

In the game, a race skip dialog appears. After pressing the button "Instant Result", the skip screen appears, but the starting countdown does not start
Has anyone tried the same?)
 
Is it possible to alter the lower limit of tyre wear for AI? On most of the tracks, they don't pit until their tyres worn until 16-17% and their in lap is almost 10 sec. slower which ruins the race. I'd like to alter this. I looked for this, but I couldn't found anything obvious about this in .dll.
 
Hey. Can someone give me some pointers?
I am trying to add the PerfectSetupMod onto the SpeedAndZoom mod.
I picked up dnSpy and opened the Assembly-CSharp.dll from SpeedAndZoom mod but I get compilations errors even when I make no changes, Edit Method(C#)... and Compile.

Ex.
Error CS0518 Predefined type 'System.Single' is not defined or imported main.g.cs 351

Thanks.

LE. I was trying to edit a stand-alone DLL. In order to work you need to edit the DLL from the game installation.
 
Last edited:
Hello all,

@TheFlamingRed , I'm trying to make the " Play and Fast Forward Speeds " thing work for me. I'm using DNSpy, and after copying the code you've written and hitting 'Compile' at the bottom, I get this:

DNSPY.PNG

I'm trying to figure out what I'm doing wrong, but I just can't seem to find it. I've already tried inserting the 'Global' thing as well, but that doesn't do any good neither...

Have to say this is one of my first attempts at coding though, so I'm probably missing something basic along the way...

Thanks for any pointers you can give me!

Kind regards,

Stefan
 
@TheFlamingRed

Has anyone tried to update the ingame mouse cursor yet? I can't stand that tiny thing. Is there a way to just set it to use the System Cursor?

I have a basic understanding of dnSpy. When i search the Assembly-CSharp for "cursor", I get quite a few responses... I just have no idea what I should or could change...

Thanks.
 

Attachments

  • Cursors.PNG
    Cursors.PNG
    14.3 KB · Views: 474
Last edited:
Hello im i bit noob in modding. i try the zoom mod but this not work for me, the game crash. so i try Dnspy to modify my file. but adding the value manualy ( - 130f dont work)
probably it's dummed to just try to add value manualy. pls help me to understand this part. i realy realy want a zoom for the game. Tks for your help.
https://ibb.co/kdpeNw
https://ibb.co/dR4caG

It's possible the mod not work bcs the game now call the camera (This.cameraMinzoom) and not anymore (This.minZoom) ??
kdpeNw

dR4caG
 
GameTimer
GetSimulationTimeScale


kXtdwZyKW.png

I wanted to change the gamespeeds as I felt the fastest 'fast-forward' option was far too slow/ Particularly as I spend a lot of time testing my mod, and I really want to get through these races quicker.

However, the original game speeds are fixed, can cannot be edited simply by changing a number. This is because the number is part of an Array, and by default in this dll, the numbers stored in the arrays are set to Private, and thus, cannot be modified. So with a simple option not available, I gutted this section of code with new IF statements. (Big thanks to Hudson here as he led me through the process of converting my desired IF statements into the Instructions and OpCode. I have been able to use this example to modify various other areas of the game)


kWQBbUeIW.png

Something strange has happened to this code since editing it. It's gone all 'Global' on me, which I assume is some sort of reference issue. However in this case, the code does what it's intended so if it isn't broke, don't fix it.

I once tried a x50 speed, and while it theoretically works, the game struggles to keep up on my system and is very choppy. You can get away with an x20 though.

For those wanting an x1... while its possible I don't recommend it. The Physics of the cars are simplified, and watching races at x1 speed doesn't look good.


Hey can you send the pictures of this to me? They wont show up and i cant figure this out without them.
 

Latest News

How long have you been simracing

  • < 1 year

    Votes: 133 13.1%
  • < 2 years

    Votes: 103 10.1%
  • < 3 years

    Votes: 95 9.3%
  • < 4 years

    Votes: 71 7.0%
  • < 5 years

    Votes: 141 13.9%
  • < 10 years

    Votes: 134 13.2%
  • < 15 years

    Votes: 85 8.3%
  • < 20 years

    Votes: 63 6.2%
  • < 25 years

    Votes: 49 4.8%
  • Ok, I am a dinosaur

    Votes: 144 14.1%
Back
Top