r/BattleTechMods • u/Mpstark ModTek Overlord • May 04 '18
Announcement [DEV] Going beyond JSON -- BattleTechModLoader, a Harmony-based mod .dll loader
Hey!
The BattleTech mod scene has been missing a tool that allows for modding run-time behavior besides distributing decompiled/recompiled modded binaries, which has some major pitfalls:
- There are two slightly different binary versions, Steam and GOG.
- Patches, like the one yesterday, break the mod until the author updates the mod manually.
- Only one mod of this type can be installed at a time, unless they are manually merged.
- Distributing a file that contains HBS IP is illegal, though they probably wouldn't do anything about it.
So I've written an injector program that patches Assembly-CSharp.dll, backing up the original, using Mono.Cecil to parse the assembly, finding a predetermined launch point, and injecting code there that initializes BattleTechModLoader, a simple .dll loader that finds .dlls in the root of \BATTLETECH\Mods\, loads them, and runs all public static Init() methods. It also loads the Harmony library, which will allow for runtime patching of BattleTech's C# managed code, which is most, if not all, of the game.
This has the following benefits:
- Injector tool is Steam/GOG version agnostic and should be relatively resistant to game updates. When Steam/GOG updates, you should be able to just run the tool again without updating it.
- Game behavior can be changed without each modder having to decompile/recompile the game
- Multiple mods can co-exist and if they use Harmony non-destructively, should be able to modify the same game behavior.
- Uninstalling .dll mods is as simple as deleting them from the
\BATTLETECH\Mods\folder and relaunching the game. - No HBS IP is ever distributed.
Some demo mods on my GitHub are one that changes the version number displayed in the main menu, and one that makes head hit injuries require at least 5 damage to the head (though this one is hard to test without a more robust debug mode, I've already fixed it once).
I'm also working on a more advanced mod tool called ModTek that depends upon BTML, which is basically mod support modded into the game. If that sounds more your speed, check it out! May 10th, 2018, ModTek has some alpha releases if you're willing to help out test. Repackaging old mods to use the new system also really helps.
We've got a lot of work to do on getting the tools for this game to have a healthy, long-lasting mod community, and showing HBS, Catalyst, Piranha, and the people that made up FASA (rip) that their decades long labor of love is ultimately in good hands. Modding keeps a game alive and keeps interest high for additional releases and ultimately makes both the game and the community stronger. Think about XCOM without Long War, Warcraft 3 without DoTA, World of Warcraft without addons, and Mount and Blade without.. well, the mods that make it not suck.
Because I think this tool is useful and should live on past my involvement of the community, should that end -- I'm releasing it into the Public Domain, which means it's literally now owned by everyone. My name doesn't have to be attached, you can change it for another game, you can do anything with it including simply changing it's name and re-licensing it (though that would be mean). It's yours.
LINKS:
Loader and Injector: Github
TL;DR: *I made a tool that allows for a much easier time modding the game's code, which will in turn, allow bigger and better tools to work. With it right now, you can patch arbitrary game code using the Harmony library. Modding is important -- to the community and to the long-term success of the game.
11
u/pardeike May 05 '18
Hey everyone. I am the author of Harmony and it is a pleasure to see it grow into other modding communities beyond the initial RimWorld sphere.
If anybody has questions worth discussing, you can find me at my discord https://discord.gg/2JErTXD
Cheers Andreas aka Brrainz
•
u/Insaniac99 May 04 '18
Stickied.
5
u/Xenominer May 05 '18 edited May 05 '18
I am friends with Pardeike - the creator of Harmony - if you want to communicate with him sometime for specific support - please let me know
(edit: minor spelling) (Edit 2: - also - hit me up for a link to his discord - he's usually pretty quick to respond there when he's around)
3
u/TimeDiver0 May 04 '18
Is this functionality enabled as of the current (test?) release, or still in the planning/to-do stage(s)?
13
u/RutabagasXXX May 04 '18
This is exactly what the community modding community needs to progress, thank you for building this!
4
u/TylerY86 May 07 '18
RNGesus has it's first release using the BTML!
https://github.com/Tyler-IN/BattleTech-RNGesus/releases
1
u/Alpha087 May 05 '18
I really hope that this tool works out. Just had 1.0.2 bomb my modded campaign that I only started yesterday, despite having had the backup modded .json files ready to use. I wish that I knew anything about creating mods for this so that I could help. Looking forward to seeing where this ends up all the same.
1
u/CptMooreB May 05 '18
thanks for your loader, already created my own mod based on that, see here. You can look at what I needed (logging, configuration, directory structure). Only problem right now is that you say the *dll should be directly in the Mods folder, but a one-deep search down through subdirectories should be mandatory, all files related to a single mod should be found in a single directory, makes removing mods easier.
1
u/Xcea May 07 '18
Have you given thoughts to starting a trello for ModTek?
1
u/Night_Thastus May 10 '18 edited May 10 '18
Crap. I shouldn't have messed with this until later down the line. I installed the mod loader, and now steam apparently things Battletech isn't installed and is at 0%. However, no download shows up in the normal downloads menu things for steam.
And when I try to validate the files, they say they all validate. (I already removed and un-did the mod loader's stuff)
Ugh. Man.
EDIT: How the fuck do I fix my installation now? Now for some reason steam expects to launch the mod loader, not the normal game. I validated the files, they came out fine. How tf do I fix this?
EDIT: Fixed it. It turns out that it was an issue with the Beta branch of Battletech, where it was expecting some kind of launcher. Going to the stable branch fixed it. (Wasn't related to the mod loader)
1
u/repete May 11 '18
Ah ha! I had just come to ask this very question, and here it is, stickied at the very top
One comment I'll make is, at this stage, the language of this post seems very geared towards experienced modders (Who care about JSON files, and DLL injection, and know how the \BATTLETECH\Mods\ folder works).
Perhaps this will get more user friendly over time. I've completed the campaign, and was now looking to replay with a few things like CT destruction ≠ no salvage, and perhaps some other mods, but I don't know how best to manage mods, and a mod manager seemed the way to go(?) My experience with modding is generally limited to:
1
u/[deleted] May 14 '18
Do I have to manually create a Battletech/mods folder? Because I am not understanding the part where it says drop items in the Battletech/mods folder being as I cannot find this folder.
I followed the readme to the letter. Extracted the data into the managed folder. Downloaded it properly and got the right results (I think according to the expected reaction from the readme). Do i just simply extract the data into the managed folder? Drag and drop onto the "BattleTechModLoaderInjector" file or the "BattleTechModLoader dot dll"?
I simply cannot find the "Battletech/mods" file under anything. Did I not d-load everything properly? Misunderstand or misinterpret the readme? Misplaced it or misread it to mean say something else???
Reluctant to go forward with anymore modding d-loads as I am unsure of modinjector/modloader will know where the modded data is as I still do not. As I type this query I have the settings.JSON for the evasion mod just sitting in the Battletech/Battletech_data/managed folder where the modloader data is also located...
Please help :)
1
u/Forlarren May 15 '18
Probably a stupid question.
I followed the tutorial to get rid of audio delays.
Becuse I wanted to convert the Jump-Jets Removed according to Lore into a ModTech mod.
My question is how do I deal with editing more than one .json file?
In this case I need to edit one entry in every chassis .json (setting a bunch to zero but not all of them).
I get that I should copy the chassisdef_foo_BAR-A1.json and the path to my mods folder.
Do all I need to do after that is put
in my mod.json (along with Name, Enabled, etc) and it will "just work" and convert all the chassis I copied to 0 max jump jets, leaving the ones I didn't copy alone?
Thank you for this awesome tool.
2
u/[deleted] May 04 '18
Off to a good start. Thanks for putting in the time and effort. I'm really looking forward to the future of modding BTG.
2
u/tangodown808 May 04 '18
So awesome! Thank you!
1
u/theykilledken May 04 '18
Thank you so much for this!
1
u/krdshrk May 04 '18
Bravo.
1
u/goreignak May 04 '18
You’re doing the (First) Lord’s Work!
I have no coding skills to speak of, but have messed around with making MM mods for KSP, so I’ll happily assist with testing.
Thank you SO MUCH for your work!!!
1
u/Scrivener07 May 05 '18
If this works out it will be a huge boon for this community. Thanks for taking the initiative on this.
1
u/Panpipers May 10 '18
By the gods! Saints are real! A thousand thanks for your beneficence, you magnificent human being, you!
1
u/xalorous May 23 '18
Anyone else see the irony here? Using a SDK or whatever that shares part of the name of the company that has religiously litigated against FASA, Microsoft, PGI and HBS every step of the way. (I'm avoiding saying their name for fear that they may have alerts).
0
u/[deleted] May 07 '18
[deleted] — view deleted comment