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:
Maybe im missing something here guys, hopefully you can help.
But how do I launch/run ILSpy or Reflexil? I cant see any .exe for them, for ILSpy i just see a .sln file which opens the project up in Visual Studio

EDIT: Ok, I've got it now, I stupidly downloaded the source and not the binaries.
 
Last edited:
Help please :

Im trying to adjust game sim speeds. as a base im using TFR's Assembly-CSharp.dll
I've adjusted the values in the reflexil plugin window, but i'm unable to work out or apply these changes to the code.
upload_2017-3-18_17-32-16.png

As you can see the changed values below and the code above showing the old values and when i update the object model i get this error.

Any ideas what i should be doing or am doing wrong?
 
Since you changed 15 to 8, you need to edit line 27
Select line 27, right mouse - Edit
Edit.jpg

Choose Operand drop down menu and select (30)ldc.r4 8 and click update.
Operant.jpg

At the end select Assembly-CSharp.dll right click and select update.
 
Hey guys and gals.
I have no experience from editing .dlls' whatsoever. However I have followed the instruction on this forums on how to edit things like the camera and speed and have been successful in doing so.

I am trying to edit the picture attached and have no Idea how to about it. Help please?
 

Attachments

  • how to edit.png
    how to edit.png
    85.6 KB · Views: 281
I am not sure where to post..so try here...beacuse i dont know here file that was about reliabilty.

are there any chance to modding a bit higher reliabilty from 40% to 60% when get a new season after first season.
Because i am so tired with always low reliabilty at 40% and all AI cars always crash or pitstop a lots ever time new season..not "realisme"... so any chance to modding so ever new season on 60% instead of 40%?
 
I have a theory which might work as a workaround, assuming the AI uses the same rules and logic as player for part improvements: The easiest way might be to just move the season start a couple of weeks later, thus giving AI more time to improve the reliability (if it does so). That can be done simply by modifying the championships.txt.

I used this trick to extend the time available for making new contracts when creating own team, but have not played through a full season to see if it works with reliability, too.

Season beginning and end seem to be fixed though, so be careful not mess up that.
 
It is possible that there is another way with maybe make Design Car Chasis finish very early...short time build time?
in vanilla/enzoli mod. design chassis finish first at ever season 5 march...any change move that to januar or febuary so all teams can work on reliability or whatever teams want to.
 
Managed to get 24 cars running together on track with some minor changes, but as mentioned before the ui hasn't been made with this in mind, which is a shame because it works from a functional point of view, the cars even have the empty pit garages and boxes assigned to them, I just searched for all the references I could to 20 (cars) and 10 (teams) and made the necessary changes to up them, starting with extending the gridbox number from 20 to 24.
 
Managed to get 24 cars running together on track with some minor changes, but as mentioned before the ui hasn't been made with this in mind, which is a shame because it works from a functional point of view, the cars even have the empty pit garages and boxes assigned to them, I just searched for all the references I could to 20 (cars) and 10 (teams) and made the necessary changes to up them, starting with extending the gridbox number from 20 to 24.
Thats very interesting.

In terms of selecting 12 teams, the game is very much optimised for 10 teams on that particular display... but other then that, most things are scroll boxes once you get into the actual game...

Which could be interesting...you must have added new teams to the teams.txt, suppliers and other areas in the asset file too.

So what's actually missing from making this functional?
 

Latest News

How long have you been simracing

  • < 1 year

    Votes: 351 15.6%
  • < 2 years

    Votes: 244 10.8%
  • < 3 years

    Votes: 241 10.7%
  • < 4 years

    Votes: 177 7.9%
  • < 5 years

    Votes: 299 13.3%
  • < 10 years

    Votes: 258 11.5%
  • < 15 years

    Votes: 166 7.4%
  • < 20 years

    Votes: 125 5.6%
  • < 25 years

    Votes: 99 4.4%
  • Ok, I am a dinosaur

    Votes: 291 12.9%
Back
Top