EDIT: For BattleTech 1.4+, use ModTek 0.6.0+, which integrates and improves BTML.
A simple mod loader and injector for HBS's BattleTech PC game.
A step-by-step guide to installing BTML + ModTek + ModTek mods.
Download the zip, and extract the entire contents (the .exe
and all of the .dll
s) into your \BATTLETECH\BattleTech_Data\Managed\
folder. Run BattleTechModLoaderInjector.exe
, it'll pop open a console window and run through the process of modifying Assembly-CSharp.dll
, including making a backup into Assembly-CSharp.dll.orig
. Don't worry if the assembly is slightly smaller than it started, it will still work, unless the console window shows an exception during the writing process. If this happens, just delete it and rename the backup to have your original file back.
Download the zip, and extract the entire contents (the .exe
and all of the .dll
s) into your \BATTLETECH\BattleTech_Data\Mods\
folder. Then from a command line, run:
mono BattleTechModLoaderInjector.exe /install /manageddir=../BattleTech_Data/Managed/
You can also put it in a different folder and alter the values passed to /manageddir
.
If the game patches or somehow replaces Assembly-CSharp.dll
, running the injector will patch it again. Since the mod loader and the injector are very simple, it should be pretty resistant to updates changing the assembly.
Updates to BattleTechModLoader itself will almost certainly not require you to re-inject an already injected assembly. Simply replace all of the included files.
Note: Running the injector on an already injected game won't bork anything, as it checks to see if the assembly has already been injected.
Because of its extremely simple nature, you should be careful about basing your mod on BTML itself -- if you're developing a tool or mod that won't any need additional files (or advanced features, such as dependancies, load order, etc.), this might be a good fit. ModTek, which depends on BTML provides a better all around experience for users and modders alike.
BTML uses Mono.Cecil to parse Assembly-CSharp.dll
and find a predetermined point (BattleTech.GameInstance
's constructor) in code to inject a single method call into BattleTechModLoader.dll
, which will load 0Harmony.dll
, and then any .dll
file contained within the root of \BATTLETECH\Mods\
. After loading each assembly, the loader will look for any public static Init()
functions on any of the classes defined in the assembly and will invoke all of them.
A log is generated at \Mods\BTModLoader.log
overwriting any previous log. This log additionally contains a record all of the Harmony hooks that happen at mod loading time.
In each project folder there is an example project user file (e.g. BattleTechModLoaderInjector.csproj.user.example
). You can copy that file and rename it without the .example
ending and then update it to point to your managed DLL folder. The Injector user file is also setup to run the injector in the managed folder, so you can test the injector without leaving VStudio.
BTML is provided under the "Unlicence", which releases the work into the public domain.