Closed mclang closed 5 years ago
In your file structure of your mods folder I see no mention of the modtekassetbundle. Is that in there too as it should be.
Also, what version of BattleTech Game are you on?
Battletech version is 1.2.200-367R
Or that is at least shown in the lower left corner of the main screen. In addition, when I put Mpstark's BTMLVersionMod directly in the steamapps/common/BATTLETECH/Mods
directory, there is W/BTML after the version number, not W/MODTEK as the installation instructions say.
So that one mod in Mod
directory is workin, but the mods insubdirectories are not loaded.
What is modtekassetbundle? The installation instructions does not say anything about it - or I'm blind.
In the modtek release zip there's a file called modtekassetbundle
. It's required in the same location as the ModTek.dll
(in the Mods
folder).
Okay, missed that... Or maybe I downloaded old version from Mpstark's repo because the links point to there :(
After redownlaoding ModTek I have these in Mods
directory:
/.../steamapps/common/BATTLETECH/Mods
├── BTMLColorLOSMod
│ ├── BTMLColorLOSMod.dll
│ └── mod.json
├── BTModLoader.log
├── CrystalClear
│ ├── CrystalClear.dll
│ └── mod.json
├── ExtendedInformation
│ └── ExtendedInformation.dll
├── modtekassetbundle
├── ModTek.dll
└── PilotHealthPopup
├── mod.json
└── PilotHealthPopup.dll
Now I got ModTek version popup when starting the game and the W/MODTEK version string after the game version in main screen. In addition now BTModLoader seems to find the rest of the mods, but an exception is thrown:
BTModLoader -- BTML v0.4.2.28104 -- 10/7/2018 3:55:27 PM
3:55:27 PM - ModTek.dll (v0.3.1.21097): Found and called entry point "Void Init()" in type "ModTek.ModTek"
3:55:27 PM - ModTek.dll: While loading a dll, an exception occured:
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.TypeLoadException: Could not load type 'Language'.
at (wrapper managed-to-native) System.Reflection.MonoMethodInfo:get_method_info (intptr,System.Reflection.MonoMethodInfo&)
at System.Reflection.MonoMethodInfo.GetMethodInfo (IntPtr handle) [0x00000] in <filename unknown>:0
at System.Reflection.MonoMethod.GetPseudoCustomAttributes () [0x00000] in <filename unknown>:0
at System.MonoCustomAttrs.GetPseudoCustomAttributes (ICustomAttributeProvider obj, System.Type attributeType) [0x00000] in <filename unknown>:0
at System.MonoCustomAttrs.GetCustomAttributesBase (ICustomAttributeProvider obj, System.Type attributeType) [0x00000] in <filename unknown>:0
at System.MonoCustomAttrs.GetCustomAttributes (ICustomAttributeProvider obj, System.Type attributeType, Boolean inherit) [0x00000] in <filename unknown>:0
at System.Reflection.MonoMethod.GetCustomAttributes (System.Type attributeType, Boolean inherit) [0x00000] in <filename unknown>:0
at Harmony.PatchTools+<>c__2`1[Harmony.HarmonyPrepare].<GetPatchMethod>b__2_0 (System.Reflection.MethodInfo m) [0x00000] in <filename unknown>:0
at System.Linq.Enumerable.First[MethodInfo] (IEnumerable`1 source, System.Func`2 predicate, Fallback fallback) [0x00000] in <filename unknown>:0
at System.Linq.Enumerable.FirstOrDefault[MethodInfo] (IEnumerable`1 source, System.Func`2 predicate) [0x00000] in <filename unknown>:0
at Harmony.PatchTools.GetPatchMethod[HarmonyPrepare] (System.Type patchType, System.String name, System.Type[] parameters) [0x00000] in <filename unknown>:0
at Harmony.PatchProcessor.RunMethod[HarmonyPrepare,Boolean] (Boolean defaultIfNotExisting, System.Object[] parameters) [0x00000] in <filename unknown>:0
at Harmony.PatchProcessor.PrepareType () [0x00000] in <filename unknown>:0
at Harmony.PatchProcessor..ctor (Harmony.HarmonyInstance instance, System.Type type, Harmony.HarmonyMethod attributes) [0x00000] in <filename unknown>:0
at Harmony.HarmonyInstance.<PatchAll>b__9_0 (System.Type type) [0x00000] in <filename unknown>:0
at Harmony.CollectionExtensions.Do[Type] (IEnumerable`1 sequence, System.Action`1 action) [0x00000] in <filename unknown>:0
at Harmony.HarmonyInstance.PatchAll (System.Reflection.Assembly assembly) [0x00000] in <filename unknown>:0
at ModTek.ModTek.Init () [0x00000] in <filename unknown>:0
at (wrapper managed-to-native) System.Reflection.MonoMethod:InternalInvoke (object,object[],System.Exception&)
at System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00000] in <filename unknown>:0
--- End of inner exception stack trace ---
at System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00000] in <filename unknown>:0
at System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) [0x00000] in <filename unknown>:0
at BattleTechModLoader.BTModLoader.LoadDLL (System.String path, System.String methodName, System.String typeName, System.Object[] prms, BindingFlags bFlags) [0x00000] in <filename unknown>:0
Took 0.2224487 seconds to load mods
I try later each of the four mods, if one of them is the one to blame.
Okay, I tried every of the four mods I was planning to use and the exception happens with all of them. Somehow strange that Mpstark's BTMLVersionMod works though!
Is there README somewhere how to build BTML and ModTek using mono with debug flags, so that Exception stacktrace would be more usefull? I tried but got various errors about missing references and I don't have windows so that I could try building using e.g Visual Studio Community.
Or could somebody build a debug version of those libraries so that I could try them?
Also one thing to try is building the libs using .NET 3.5 framework.
1.2.200-367R
is not a version I've even seen so I assume that is the linux preview build, so hard to guess exactly what is going on. ModTek and BTML are both built by me right now using Visual Studio Community on macOS. I believe there are some notes on building and running the project in the branch here https://github.com/janxious/BattleTechModLoader/tree/factional That is also the latest version of BTML that I have distributed to anyone and it has been in "production use" in RogueTech for a month.
For ModTek, the project is still very tied to the version of the game because of the way the project is built. Given you're on a version I (think I) can't get, I would suggest pulling down the project, opening it in visual studio, and changing the DLL references to your local file system DLLs in the BTech Managed folder, where the injector lives. Improving the build aspect of ModTek is my next project to tackle for BTech, but I hvaen't gotten to it yet.
Mayne I should wait proper Linux release because I got similar Could not load type 'Language' error ingame.
And yes, like I said in the first message, I'm using Battletech Linux Beta.
Thanks for the build instructions, I try them if I have time.
Yeah, I just hadn't seen the version number on the Linux beta. Makes sense it is different, and unfortunate that it's also the translation beta as well. It looks like it's available in macOS, so I will test, and if it matches your version I'll build you a ModTek bundle. Did you happen to try the 0.5x version of BTML?
The version of BTG that downloads on the linux beta is 1.2.1-345. So I guess I will need to coerce another modder to do it for me. I'll let you know if I turn anything up.
I guess BattleTech works with Proton on Steam Play. Here's something from another player:
"Performance is the same as on Windows, but the game will only work with two workarounds:
1) It must be launched with the '-force-glcore' parameter
2) The CCCP codec pack must be installed in the Proton prefix as follows.
a) Download the CCCP latest 32 and 64 bit codecs from cccp-project.net
b) Navigate to the folder where the .exes are located and open a terminal
c) Run the following commands. An installer will appear for each of them.
WINEPREFIX=""$HOME/.steam/steam/steamapps/compatdata/637090/pfx"" wine Combined-Community-Codec-Pack-2015-10-18.exe
WINEPREFIX=""$HOME/.steam/steam/steamapps/compatdata/637090/pfx"" wine Combined-Community-Codec-Pack-64bit-2015-10-18.exe
d) Enjoy BATTLETECH
So far the game has been tested vanilla and with the latest RogueTech. I am not sure if the mod injector itself works, since I copied the files over from Windows, but after the modified Assembly-CSharp.dll has been created everything runs as expected.
BUGS: Sound distortion while loading missions, but only on the loading screen. After the 'BEGIN MISSION' button is pressed the sound is normal."
Additionally, the primary modder for RogueTech plays BTG via wine on linux, so that may be a good option as well.
I have no idea why the version number shown in the main screen is 1.2.200-367R
and not 1.2.1-345
.
I though about trying proton as well but didn't want to mess around with installing additional things. As this has become a mess in itself, I might try proton after all, after I have tried 0,5x versions. Or I play vanilla, the mods are not yet so important for me.
Thanks, I report if 0.5x works when I have time to try it.
For me this happens without any mods, upon loading the modtek.dll itself (i.e. only files in the Mods folder are modtek.dll and the modtekassetbundle plus the BTModLoader.log.
ModTek itself may have to be rebuilt against the linux assembly which I alluded to. I don't have (easy) access to that.
My last joust with C# is a good 15 years in the past, and I've never developed with mono and not on Linux, but I'll grab the sources and see if I can do a native build. Since I'm using Arch Linux, this is not guaranteed to help anybody else even if it works up working for me, given probably different versions and all, but perhaps it can shed some more light on the issue.
I guess this hints at the fact that the Linux version is actually different from the Windows version (AVPVideoPlayer is shown as being of class Battletech.UI.AVPVideoPlayer.
For whatever reason, in the Linux version, that doesn't appear to have a "Language" property.
For what it's worth, I removed the parameter and commented out the subtitle function call that used the language parameter. The modified modtek.dll works (i.e. mods now get loaded), but I tried it with the InnerSphereMap mod, and of course, at the point where it wants to start playing its video, BT shows a black screen (and the "ESC to skip" line, which doesn't work) and appears to stop there.
It could be possible to override the base AVPVideoPlayer class, add a Language property there, and pass that on to the base class if it has one and also wrap the LoadSubtitle calls somehow - as I said, it's been a pretty long while that I did any C# development work.
I don't have time to dig further at this moment, either, but I hope my information is helpful, and if I can be of further assistance, let me know.
For any Linux users who want to try it out, this is the "dirty hacked" modtek.dll (0.3.1). Again, it will hang the game as soon as a mod wants to play a video, but if you don't have a mod like that you want to use, please share whether it works for you.
Yes, it happens without any mods also with me, i.e when only ModTek is installed.
I just tried the modified ModTek.dll with PilotHealthPopup and BTMLColorLOSMod and at least they seems to work without errors.
I hope the thing you found gets fixed when proper Linux version arrives with 1.3 update.
Thanks a lot @EddyBuhler !
I've tried a few more things, but while I don't get the exception anymore, video playback with the modified function call still only leads to a black screen with the "ESC to skip" message, and nothing happening, i.e. I have to then quit the game with ALT-F4.
Could be because InnerSphereMap uses an mp4 video file and it's possible that format isn't supported in the current Linux build of the game/engine, or maybe I'm still doing something wrong.
A few pointers regarding other mods: Some don't work, even with this modified dll, like the Basic Panic System. This is probably an issue with the Linux beta game version. Some mods may also not be aware that on Linux, capitalization matters, and "Mods" and "mods" are two different folders to the OS. BTML creates a "Mods" folder, and some mods look for their files in "mods", so the easiest fix is to create a symlink ("ln -s Mods mods" inside the BATTLETECH directory).
A good number of mods appear to work flawlessly even on Linux, so I'm keeping my hopes up for the official 1.3 Linux release of the game.
@janxious:
What I've done is this:
[HarmonyPatch(typeof(AVPVideoPlayer), "PlayVideo")]
public static class AVPVideoPlayer_PlayVideo_Patch
{
public class AVPDerivedPlayer : AVPVideoPlayer
{
public enum Language
{
English
}
}
public static bool Prefix(AVPVideoPlayer __instance, string video, AVPDerivedPlayer.Language language, Action<string> onComplete = null)
{
which, as I mentioned, gets rid of the Exception, but doesn't solve the playback issue when a mod tries to play its own video cutscene.
I also tried CrystalClear and it loads without errors, but ExtendedInformation does not - not even after creating the symbolic link. It doesn't give errors or anything, so the problem with it might lie elsewhere.
Errors will probably be in the player.log ("~/.config/unity3d/Harebrained Schemes/BATTLETECH/player.log") if there are any.
ExtendedInfo doesn't work after version 1.1.2 IIRC. It would need to be recompiled and possibly altered to work with changes in the base game.
Another thing to keep in mind is a lot of mods also target the mods folder differently than you've describved above, as the windows install has a different structure relative to the root battletech folder, at least in macOS. I have a symlink setup as well for just such issues. :)
I have cut a new release of BTML that may help with linux in the future: https://github.com/janxious/BattleTechModLoader/releases/tag/v0.6.3
If the instructions there don't work or are unclear let me know.
Another thing to keep in mind is a lot of mods also target the mods folder differently than you've describved above, as the windows install has a different structure relative to the root battletech folder, at least in macOS. I have a symlink setup as well for just such issues. :)
I haven't observed any big differences at first glance, i.e. on Linux, too, the data folder is "BATTLETECH/Battletech_Data".
I did this:
mono BattleTechModLoaderInjector.exe /manageddir ../BattleTech_Data/Managed/
It patched fine, and BATTLETECH still launches and shows the ModTek progress screen and its version number on the main menu screen.
This is probably unrelated to the modtek.dll issue above, though, right?
Nice on the folder setup. I wish the macOS one wasn't so different. :)
Re: installation, that is what is intended as before one had to sometimes move DLLs around to get the patcher to work, though maybe that is also a macOS only thing. Anyway, will have no effect on the ModTek issues reported above, though I plan to look into fixing those next.
No, with the injector .exe inside the Managed, you have to move some of the System.* namespace dlls (System.Threading.dll in particular) out of the Managed folder in order to be able to run the injector. That's the same as on Mac, unfortunately.
Running the Injector from another folder as described above works much better and gets rid of that necessity. I simply gave the full process because, as mentioned, on Linux the data folder is the same as on win, and other users might have an easier time of it with a "proven working" example.
Alright, glad I wasn't mis-remembering the DLL issue being *nix. And I appreciate the thorough writeup!
No problem. Let me know if you need help with testing or bugtracking on Linux.
Just to wrap this up, I have released a new version of ModTek that should work without new compilation by users in any environment. That is here: https://github.com/janxious/ModTek/releases/tag/v0.4.0. I am going to close this issue as I think I've addressed all the problems in it. If you try that ModTek version and it doesn't work or you feel like there are still open issues you want addressed let me know! Thanks for the patience!
Nope, not working for Linux. Media playback seems to work differently here. I'm getting this exception again:
BTModLoader -- BTML v0.6.4.17757 -- 11/09/2018 10:29:37
10:29:37 - ModTek.dll (v0.4.0.2070): Found and called entry point "Void Init()" in type "ModTek.ModTek"
10:29:38 - ModTek.dll: While loading a dll, an exception occured:
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.TypeLoadException: Could not load type 'Language'.
at (wrapper managed-to-native) System.Reflection.MonoMethodInfo:get_method_info (intptr,System.Reflection.MonoMethodInfo&)
at System.Reflection.MonoMethodInfo.GetMethodInfo (IntPtr handle) [0x00000] in <filename unknown>:0
at System.Reflection.MonoMethod.GetPseudoCustomAttributes () [0x00000] in <filename unknown>:0
at System.MonoCustomAttrs.GetPseudoCustomAttributes (ICustomAttributeProvider obj, System.Type attributeType) [0x00000] in <filename unknown>:0
at System.MonoCustomAttrs.GetCustomAttributesBase (ICustomAttributeProvider obj, System.Type attributeType) [0x00000] in <filename unknown>:0
at System.MonoCustomAttrs.GetCustomAttributes (ICustomAttributeProvider obj, System.Type attributeType, Boolean inherit) [0x00000] in <filename unknown>:0
at System.Reflection.MonoMethod.GetCustomAttributes (System.Type attributeType, Boolean inherit) [0x00000] in <filename unknown>:0
at Harmony.PatchTools+<>c__2`1[Harmony.HarmonyPrepare].<GetPatchMethod>b__2_0 (System.Reflection.MethodInfo m) [0x00000] in <filename unknown>:0
at System.Linq.Enumerable.First[MethodInfo] (IEnumerable`1 source, System.Func`2 predicate, Fallback fallback) [0x00000] in <filename unknown>:0
at System.Linq.Enumerable.FirstOrDefault[MethodInfo] (IEnumerable`1 source, System.Func`2 predicate) [0x00000] in <filename unknown>:0
at Harmony.PatchTools.GetPatchMethod[HarmonyPrepare] (System.Type patchType, System.String name, System.Type[] parameters) [0x00000] in <filename unknown>:0
at Harmony.PatchProcessor.RunMethod[HarmonyPrepare,Boolean] (Boolean defaultIfNotExisting, System.Object[] parameters) [0x00000] in <filename unknown>:0
at Harmony.PatchProcessor.PrepareType () [0x00000] in <filename unknown>:0
at Harmony.PatchProcessor..ctor (Harmony.HarmonyInstance instance, System.Type type, Harmony.HarmonyMethod attributes) [0x00000] in <filename unknown>:0
at Harmony.HarmonyInstance.<PatchAll>b__9_0 (System.Type type) [0x00000] in <filename unknown>:0
at Harmony.CollectionExtensions.Do[Type] (IEnumerable`1 sequence, System.Action`1 action) [0x00000] in <filename unknown>:0
at Harmony.HarmonyInstance.PatchAll (System.Reflection.Assembly assembly) [0x00000] in <filename unknown>:0
at ModTek.ModTek.Init () [0x00000] in <filename unknown>:0
at (wrapper managed-to-native) System.Reflection.MonoMethod:InternalInvoke (object,object[],System.Exception&)
at System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00000] in <filename unknown>:0
--- End of inner exception stack trace ---
at System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00000] in <filename unknown>:0
at System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) [0x00000] in <filename unknown>:0
at BattleTechModLoader.BTModLoader.LoadDLL (System.String path, System.String methodName, System.String typeName, System.Object[] prms, BindingFlags bFlags) [0x00000] in <filename unknown>:0
Took 0.3785608 seconds to load mods
The following change to Patches.cs:90ff resolves this exception:
[HarmonyPatch(typeof(AVPVideoPlayer), "PlayVideo")]
public static class AVPVideoPlayer_PlayVideo_Patch
{
public class AVPDerivedPlayer : AVPVideoPlayer
{
public enum Language
{
English
}
}
public static bool Prefix(AVPVideoPlayer __instance, string video, AVPDerivedPlayer.Language language, Action<string> onComplete = null)
{
It looks like the Linux version does media playback differently than the windows version since the built-in cutscenes play fine but mod videos do not; so there may be a different function/method to override for playing mod videos on Linux.
Until then, the above fix at least makes modtek.dll work on Linux.
Here's a modified modtek.dll that works on my Linux box (Version 0.40): ModTek.zip
As with the previous modified dll, you still need the 'modtekassetbundle' file from janxious' original release zip.
Thanks, I will try it out
@janxious btw. the above-mentioned fix for the Linux version should not break the Windows version, basically because all the language parameter is used for is casting it to a string to set the subtitle language.
So it should be a "safe" fix.
The mods I use work with the version provided by @EddyBuhler
BTModLoader -- BTML v0.4.2.28104 -- 11/13/2018 13:00:35
13:00:35 - ModTek.dll (v0.4.0.19926): Found and called entry point "Void Init()" in type "ModTek.ModTek"
13:00:35 - RM_LessHeadInjuries.dll (v1.0.0.0): Found and called entry point "Void Init()" in type "LessHeadInjuries.LessHeadInjuries"
Took 0.6695205 seconds to load mods
13:00:36 - BTMLColorLOSMod.dll (v0.1.6729.2085): Found and called entry point "Void Init(System.String, System.String)" in type "BTMLColorLOSMod.BTMLColorLOSMod"
13:00:36 - PilotHealthPopup.dll (v0.1.1.38099): Found and called entry point "Void Init()" in type "PilotHealthPopup.Patches"
13:00:36 - CrystalClear.dll (v2.0.1.0): Found and called entry point "Void Init(System.String, System.String)" in type "CrystalClear.CrystalClear"
13:00:36 - MeleeMover.dll (v1.0.0.0): Found and called entry point "Void Init(System.String, System.String)" in type "MeleeMover.MeleeMover"
13:00:36 - PermanentEvasion.dll (v1.0.0.0): Found and called entry point "Void Init()" in type "PermanentEvasion.PermanentEvasion"
Tried again with Battletech v1.3.0-413R (linux)
Still the same problem, the official ModTek v0,4,0 does NOT work but gives the usual System.TypeLoadException: Could not load type 'Language' error, whereas the patched version from @EddyBuhler runs without problems.
Could you @janxious maybe check if the fix could be incorporated into the official version?
Please try https://github.com/janxious/ModTek/releases/tag/v0.4.2, as that is the latest.
0.4.2 shows in game as 0.4.0.19688 - but it works for me. Thank you!
Works for me also, except that my old campaign save games will not load.
HBS just released a hotfix (1.3.1). You might have to reinstall BTML (i.e. patch the Assembly-CSharp.dll again). Check the modtek.log on whether it's actually loading any mods - without all of your mods active, your old savegames may be missing stuff they need to load properly. Had the same issue this morning when I couldn't enter the mech bay because my JK_Variants mod didn't get loaded.
Thanks, I will try again
I'd like to use some Quality of Life mods like Firing Line Improvements.
I skimmed through some MacOS issues at original Mpstark repo, and found this: https://github.com/Mpstark/BattleTechModLoader/issues/9#issuecomment-392360999
I tried those steps with BTML v0.4.2 and ModTek v0.3.1 and it seems to work, but I thing none of the mods I have put in
steamapps/common/BATTLETECH/Mods
are loaded.Here is the output of
BTModLoader.log
log:The mod directory structure I have is following:
Is there something wrong in my directory structure or what could be the problem?
I'm using Steam on Solus, Battletech Linux Beta v1.2.200-367R, Mono JIT compiler version 5.14.0.177.