Jump to content
Game-Labs Forum

Modding guide?


parmenio

Recommended Posts

Hi, is there a modding guide available somewhere that I've missed? There are some old threads around Hex editing but that is not what I'm looking for.

I'm most interested in having the Historical sub-mod as a baseline and I'm aware that any mods I might want to add will need to be merged into that.

With that in mind, I've been using dnSpy (not a tool I've used before) to decompile the Assembly-CSharp.dll file. As an exercise, I decided to make a simple amendment to read in a new dummy config setting. Editing the Config class and recompiling gave me errors on the following lines:

			Config.gameSettings.officer.corpsExperience[0] *= Config.GameSettings.corpsOfficerExperienceMultiplier;
			Config.gameSettings.officer.corpsExperience[1] *= Config.GameSettings.corpsOfficerExperienceMultiplier;
			Config.gameSettings.officer.divisionExperience[0] *= Config.GameSettings.divisionOfficerExperienceMultiplier;
			Config.gameSettings.officer.divisionExperience[1] *= Config.GameSettings.divisionOfficerExperienceMultiplier;

I then decided to take a look at it with ILSpy (something I have used before) and examine the Config class that it produced:

	global::Config.gameSettings.officer.corpsExperience[0] *= GameSettings.corpsOfficerExperienceMultiplier;
	global::Config.gameSettings.officer.corpsExperience[1] *= GameSettings.corpsOfficerExperienceMultiplier;
	global::Config.gameSettings.officer.divisionExperience[0] *= GameSettings.divisionOfficerExperienceMultiplier;
	global::Config.gameSettings.officer.divisionExperience[1] *= GameSettings.divisionOfficerExperienceMultiplier;

By replacing the dnSpy code with the ILSpy version, it compiles correctly and UGCW starts up without falling over in a heap but I'm wondering if that is a process that the experienced modders here have to follow or if I just don't have dnSpy configured correctly.

Any help appreciated... 🙂

Link to comment
Share on other sites

The hex editing is still used for various changes that are prohibitively difficult or currently impossible to change through the dll. So depending on what changes you are trying to make keep them in mind.

There is no guide available on dll modding currently. The general starting advice is to use the export to solution functionality in dnspy on an existing mod and the base game dll. Then use a directory compare program to see what changes the mod is making. A lot of the work is learning the code well enough to know what to change where.

The issue you ran into above is one of the limitations of the dnspy decompiler. I just add the global:: back onto those variables if I need to make a change in there. You'll see it in the existing dnspy code but if you edit it, the global:: is dropped for some reason. I think I figured out how to make that change in a different location that will remove this issue, but haven't gotten around to changing it yet. There will be other classes that also have decompile issues, which ones seems to vary a bit by user. I haven't used ILspy so I don't know if it'll help you get around those other issues.

Some of the decompile errors can be fixed by putting in a more complete path to an object, but it's basically a case by case basis. Editing method instead of editing class will get you past some of them, but some classes just won't recompile properly as far as anyone has found so far. Also be aware that sometimes a method will recompile but it will break functionality or saves in game. In some cases the only way to resolve this has been reverting to an earlier version of the dll that has not had a specific method/class recompiled, so regular backups are highly recommended.

Hope this helps a bit. Adishee and I are usually around semi-regularly if you have more questions.

Link to comment
Share on other sites

12 hours ago, pandakraut said:

The hex editing is still used for various changes that are prohibitively difficult or currently impossible to change through the dll. So depending on what changes you are trying to make keep them in mind.

Noted.

Quote

The general starting advice is to use the export to solution functionality in dnspy on an existing mod and the base game dll. Then use a directory compare program to see what changes the mod is making. A lot of the work is learning the code well enough to know what to change where.

I've been using Visual Studio 2019 and Beyond Compare.

Quote

I haven't used ILspy so I don't know if it'll help you get around those other issues.

dnSpy uses a fork of ILSpy for its decompilation (but that looks to be about 5 years old). I believe IlSpy is now built into Visual Studio 2019 16.5 for debugging .NET assemblies for which you do not have the source - it was (and still is) a VS extension before. There is also a plug-in for it called Reflexil which does code injection and assembly saving. I've not used it but I've downloaded it so I might take a look at that as an backup. 

Quote

Hope this helps a bit. Adishee and I are usually around semi-regularly if you have more questions.

Appreciate the help so far and the offer.

  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...