Jump to content
HAL9000

DMT Modding Tool

Recommended Posts

Those two errors are from building the mod against 18.3. they will need a patch before they'll work with that experimental

 

what a patch?

Share this post


Link to post
Share on other sites

Solved: Harmony doesn't seem able to patch static methods.

Besides, my requirement meant checking the instance type, which isn't possible in a static method.

 

I solved this by patching a different, non-static method to achieve what I wanted to do

 


 

Is there something special I need to do to patch static methods?

 

Take this example

 

 

 

class Tim_Test {
   public class Tim_Test_Init : IHarmony {
       public void Start () {
           Debug.Log (" Loading Patch: " + this.GetType ().ToString ());
           var harmony = HarmonyInstance.Create (GetType ().ToString ());
           harmony.PatchAll (Assembly.GetExecutingAssembly ());
       }
   }

   [HarmonyPatch (typeof (BlockPoweredDoor))]
   [HarmonyPatch ("Init")]
   public class Tim_BlockPoweredDoor_Init {
       public static bool Prefix (BlockPoweredDoor __instance) {
           Debug.Log ("Type: " + __instance.GetType ().Name);
           return true;
       }
   }

   [HarmonyPatch (typeof (BlockPoweredDoor))]
   [HarmonyPatch ("IsDoorOpen")]
   public class Tim_BlockPoweredDoor_IsDoorOpen {
       public static bool Prefix (BlockPoweredDoor __instance) {
           Debug.Log ("Type: " + __instance.GetType ().Name);
           return true;
       }
   }
}

 

In this case, the patch for "Init" works, as the log can be seen in the console, however the patch for "IsDoorOpen", does not, as under no circumstance does a log appear in the console (placing, turning on power, etc).

 

The only difference between the two methods is vanilla "Init" is:

public override void Init()

whereas vanilla "IsDoorOpen" is:

public static bool IsDoorOpen(byte _metadata)

 

 

Any help pointing me in the right direction would be greatly appreciated

Edited by timbeswick
Solved (see edit history)

Share this post


Link to post
Share on other sites

This is the Discord forum is where most of the C# modders hangout and will answer your questions much faster than on these forums: https://discord.gg/gKdwBmH

Share this post


Link to post
Share on other sites

Hello,

 

In "MyMod/Script/some_folder/", I have a VScode project executing some Main() (for testing purpose). When I build using DMT, some dll (produced by me running test) in "MyMod/Script/some_folder/obj/" are written to the root folder of 7D, causing the game to crash (probable cause: different c# version between the 2 dll).

Is there a way to prevent such files to be moved (or maybe better practice for me when running test) ?

 

 

Also a random suggestion: could the tool manage the order of mods by renaming them (eg "0_", 1_" ...) before applying them ? There would be some config file storing order for the build. (I did not run into order issue myself yet though)

Share this post


Link to post
Share on other sites

hey guys been having a problem with DMT not working I don't know what to do the error message is this

 

Running BackupFiles

Backup dll found: D:\DMT/Backups/SP/18.3b4/Assembly-CSharp.dll

Running DeployDlls

Deploying DLLs

Running LocalisationPatch

PatchFile: D:\DMT\DMT Mods\0-SphereIICore/Config/Localization.txt

D:\DMT\DMT Mods\0-SphereIICore/Config/Localization.txt detected BOM in file

 

Unhandled Exception: System.ArgumentException: An item with the same key has already been added.

at System.ThrowHelper.ThrowArgumentException(ExceptionResource resource)

at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add)

at LocalisationTable.ReadFromStream(BinaryReader br, String path)

at LocalisationTable.Load(String path)

at DMT.Tasks.LocalisationPatch.PatchTextFile(PatchData data, String sourcePath, String destPath, String patchFilePath)

at DMT.Tasks.LocalisationPatch.Patch(PatchData data)

at DMT.PatchData.Patch()

at DMTViewer.Program.Main(String[] args)

 

process exited with error code -532462766

 

please help

Share this post


Link to post
Share on other sites
hey guys been having a problem with DMT not working I don't know what to do the error message is this

 

Running BackupFiles

Backup dll found: D:\DMT/Backups/SP/18.3b4/Assembly-CSharp.dll

Running DeployDlls

Deploying DLLs

Running LocalisationPatch

PatchFile: D:\DMT\DMT Mods\0-SphereIICore/Config/Localization.txt

D:\DMT\DMT Mods\0-SphereIICore/Config/Localization.txt detected BOM in file

 

Unhandled Exception: System.ArgumentException: An item with the same key has already been added.

at System.ThrowHelper.ThrowArgumentException(ExceptionResource resource)

at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add)

at LocalisationTable.ReadFromStream(BinaryReader br, String path)

at LocalisationTable.Load(String path)

at DMT.Tasks.LocalisationPatch.PatchTextFile(PatchData data, String sourcePath, String destPath, String patchFilePath)

at DMT.Tasks.LocalisationPatch.Patch(PatchData data)

at DMT.PatchData.Patch()

at DMTViewer.Program.Main(String[] args)

 

process exited with error code -532462766

 

please help

 

Are you using the latest version of DMT, available in the first post?

Share this post


Link to post
Share on other sites

I've had a decent amount of time to play around with DMT and Alpha 18.1 through 18.3, and I just wanted to thank whoever made DMT, Harmony, SDX, and the tutorials for all three. They're excellent tools. It's been challenging but fun to create the few little mods I'd been wanting, and I'd never have been able to get anywhere if it weren't for the documentation that was written, so thanks a lot for all the work that's been put in.

Share this post


Link to post
Share on other sites
Are you using the latest version of DMT, available in the first post?

 

i'll give this a test now I think I have been but haven't tried for a week so will check now

Share this post


Link to post
Share on other sites
Are you using the latest version of DMT, available in the first post?

 

i'll give this a try now I think I have used the latest but i'm quite noobish at setting this up is there a tutorial for using it because i'd love to get the npc's in there

Share this post


Link to post
Share on other sites

Ask for help.How shoule I use System.IO.File.Exists to search the Dedicated Server rather than search my local game save folder? The same about File.WriteAllText and File.Delete.I host My server on a server .But when I Use file opration,It did on my own personal PC. Help Thanks

Share this post


Link to post
Share on other sites
Posted (edited)

I seem to be having some problems getting DMT to work. I followed the video overview tutorial to the T, made a separate DMT mods folder inside of my 7D2D directory and put just SphereII-Core inside of it. I copied the DMT files into a subdirectory inside my 7D2D root called DMT, started the program and successfully compiled a build with just SphereII-Core selected. However, whenever I start the game with this build, I get a red error in console about a missing Mono.Cecil.dll. I saw the earlier post in this thread about that issue and tried copying the 4 mono.cecil dlls into the 7D2D Managed folder, as well as newtonsoft.dll as it would throw that as a missing dll error as well. With those dlls inside of Managed, the game loads without a red error, however upon starting a new game, I get spammed with "There are no graphs on the scene" in console, all creatures do not move, I have a weird health bar that shows up when I look at enemies.

 

I don't understand what the problem is here. In the video tutorial he does not copy any dll files to managed and it works just fine.

 

Edit: I am using the most recent version of DMT, 1.5.7239.23150, and I tried both the SphereII-Core in the root github as well as the "patch version" for 18.3 under the 18.3 subdirectory.

 

Edit 2: After emptying my mods folder and re-patching so that JUST SphereII-Core is inside of my mods folder (making it the only mod that is loading), this issue continues happening. It definitely seems to be some issue with DMT. I am just baffled as to what it is as I did everything exactly like the video in OP.

 

Edit 3 with more details: The game also doesn't save output logs when I have the patch applied, so I can't copy-paste the output log. But I noticed two lines above the line complaining about mono.cecil, saying "Skipping missing assembly: mscorlib" and "Skipping missing assembly: System.Core". Not sure if that's related but it's the only other thing in the console that seems abnormal to me.

 

Edit 4: Now wondering if it has something to do with the .NET framework version installed on the machine. However, I initially ran into the problem while playing on my personal server, which is also having the same exact issue.

 

Edit 5: I can confirm that this behavior is happening on two separate machines. Some help would be greatly appreciated...

 

Edit 6: In edit 3 I mentioned that the console was complaining about missing assemblies, system.core and mscorlib. They are both present inside of the 7D2D managed folder, on both machines. This is very weird behaviour and very frustrating as well, I've literally spent hours trying to get this to work so I could use the NPC mod. I give up. Hopefully my save is okay. Also, I'm not sure if the root of this issue is DMT or SphereII-Core, hopefully this was the right place to post this.

Edited by Sykriss (see edit history)

Share this post


Link to post
Share on other sites

Hi, I had the same issues as Sykriss and gone through all his/her steps before too. But somehow after several re-installations through steam it worked with A18.3 exp eventually.

 

Today I tried to update to A18.4 exp. I installed DMT and unfortunately the Mono.Cecil.dll error is now back and I can not get rid of it anymore too. Same as before, see Sykriss post above and my earlier posts.

 

I tried so many things again and verified the game files through steam 10 times now. I even deleted all my saves and config folders. Only one time I was able to get DMT running and I don't even know why it worked in A18.3 once.

 

I have Windows 7 (malware 10 is not an option for me). Maybe this is the culprit? For most people DMT works I suppose, but I seem to be not the only one having this problem. I do not know what to do anymore. Maybe something comes to light in the future. Never had any problems with SDX in the past.

 

Share this post


Link to post
Share on other sites

This is my method for a good install. Been loading this way for SDX and DMT for over 2 years and it always works.

 

Step 1: Load and validate a 7Daytodie Steam install. If you already have the game installed, make sure the Mods folder is empty. If no Mods folder is there, that is ok too.

Step 2: Make a copy of the game install folder which is usually at C:\Program Files (x86)\Steam\steamapps\common\7 Days To Die

Step 3: Paste that copy to a new location, such as F:\ resulting in a folder location of F:\7 Days To Die

Step 4: Make a new directory folder for DMT with a name such as named C:\DMT and off that add a Mods folder C:\DMT\Mods

Step 5: Download the DMT .zip file and copy all its contents into the C:\DMT folder

Step 6: Run DMTViewer.exe and click on the settings tab

Step 7: Set the path to the Mods folder by clicking on the 3 dot button and point to C:\DMT\Mods

Step 8: Set the path to you copy of the game by clicking on the 3 dot button in the Game Loactions window and point to F:\7 Days To Die

Step 9: Click the build button with no modlets in the mod folder yet. Verify the build completed with no errors

Step X: Add a modlet to the c:\DMT\Mods folder and build again. Verify the build completed with no errors

 

Let me know if you still have issues.

Share this post


Link to post
Share on other sites

Hi, thanks for your reply.

Your installation steps are identical to my usual routines. However, most of the time, I had already mods installed on the first build with DMT (I am sure I tried without mods sometime ago).

Just to be sure, I downloaded everything again and fresh. I tried this time just to build DMT without any mods, but the issues remain the same. Starting the game resulting in the Mono.Cecil.dll error. There are no errors in the build progress itself. Everything should be working, but the game is unusable after patching. I even tried my original steam folder for patching, but this does not work either.

 

Share this post


Link to post
Share on other sites
Posted (edited)

Try building on 18.3 and see if that works. And to be clear, you are executing the game from the F:7 Days to Die folder assuming the paths in my post above? If so perhaps its a rights issue on that game copy install folder.

Edited by xyth (see edit history)

Share this post


Link to post
Share on other sites

Same with A18.3 stable. Not working anymore. I have admin rights and UAC is set to low. My work directory is on my physical F: drive. The DMTViewer.exe is allowed in my firewall and anti-virus softwares.

 

So... I tried something else. I copied a freshly downloaded A18.4 exp b4 to my second computer in the cellar and used it with DMT to patch it (without mods). Now I copied everything back to my online PC and run it... with success. Now the game works fine after patching. After that I installed some mods for DMT and build/patched them again on my second computer. Still working. I can not say if this is just a coincidence (it worked in the past with 18.3 exp once), but I think the problem has to do with my online computer.

 

I do not know why, but as long as the patch and build process is working on my second system, I can live with that.

If this happen again, even on my other systems, I will report back.

 

Thank you very much for your help and time.

 

Share this post


Link to post
Share on other sites
Posted (edited)

After reading all of the responses after my post, the mention of file permissions kind of rang a bell in my brain for some reason. What I did was made a copy of my 7DaysToDie_Data folder, trimmed it to only contain the Managed folder inside it, and placed it, along with DMT and my DMT mods folder, in the root of my C drive. Then I booted up DMTViewer, pointed it to C:/DMT Mods as my mods folder and the root of my C:/ drive as the install location. Built a patch with no mods enabled, then copied 0Harmony.dll, Assembly-CSharp.dll, DMT.dll, and Mods.dll along with the DMT-built Mods folder from the spoofed C:/ root install to my actual game install within steamapps/common. This worked, so I built a modded patch with the NPC mod and its dependencies and that also worked. I definitely think it has something to do with file permissions. It's somewhat interesting, too, now the console just says "Skipping missing assembly: Mono.Cecil" instead of saying it needs it (when it doesn't).

Edited by Sykriss (see edit history)

Share this post


Link to post
Share on other sites

Glad you guys sorted it.

Share this post


Link to post
Share on other sites
This is my method for a good install. Been loading this way for SDX and DMT for over 2 years and it always works.

 

Step 1: Load and validate a 7Daytodie Steam install. If you already have the game installed, make sure the Mods folder is empty. If no Mods folder is there, that is ok too.

Step 2: Make a copy of the game install folder which is usually at C:\Program Files (x86)\Steam\steamapps\common\7 Days To Die

Step 3: Paste that copy to a new location, such as F:\ resulting in a folder location of F:\7 Days To Die

Step 4: Make a new directory folder for DMT with a name such as named C:\DMT and off that add a Mods folder C:\DMT\Mods

Step 5: Download the DMT .zip file and copy all its contents into the C:\DMT folder

Step 6: Run DMTViewer.exe and click on the settings tab

Step 7: Set the path to the Mods folder by clicking on the 3 dot button and point to C:\DMT\Mods

Step 8: Set the path to you copy of the game by clicking on the 3 dot button in the Game Loactions window and point to F:\7 Days To Die

Step 9: Click the build button with no modlets in the mod folder yet. Verify the build completed with no errors

Step X: Add a modlet to the c:\DMT\Mods folder and build again. Verify the build completed with no errors

 

Let me know if you still have issues.

 

All I really want is to stop sleeper respawn on my server. Do I and the other players on the server all need to do this?

Share this post


Link to post
Share on other sites

 

All I really want is to stop sleeper respawn on my server. Do I and the other players on the server all need to do this?

 

As a general rule, yes, if the stop sleeper respawn in a DMT mod.

Share this post


Link to post
Share on other sites

Thanks sphereli. Yeah, the only viable method appears to be through DMT.

Share this post


Link to post
Share on other sites
Posted (edited)
Originally posted by xyth View Post

This is my method for a good install. Been loading this way for SDX and DMT for over 2 years and it always works.

 

Step 1: Load and validate a 7Daytodie Steam install. If you already have the game installed, make sure the Mods folder is empty. If no Mods folder is there, that is ok too.

Step 2: Make a copy of the game install folder which is usually at C:\Program Files (x86)\Steam\steamapps\common\7 Days To Die

Step 3: Paste that copy to a new location, such as F:\ resulting in a folder location of F:\7 Days To Die

Step 4: Make a new directory folder for DMT with a name such as named C:\DMT and off that add a Mods folder C:\DMT\Mods

Step 5: Download the DMT .zip file and copy all its contents into the C:\DMT folder

Step 6: Run DMTViewer.exe and click on the settings tab

Step 7: Set the path to the Mods folder by clicking on the 3 dot button and point to C:\DMT\Mods

Step 8: Set the path to you copy of the game by clicking on the 3 dot button in the Game Loactions window and point to F:\7 Days To Die

Step 9: Click the build button with no modlets in the mod folder yet. Verify the build completed with no errors

Step X: Add a modlet to the c:\DMT\Mods folder and build again. Verify the build completed with no errors

 

Let me know if you still have issues.

 

Just want to share experience for future beginers. I followed example above and still get errors even with empty mod folder. Solution was uninstall 7dtd from steam. Manualy delete directory 7dtd from steam library (because of very old files witch wont be deleted). Reinstall again and thats it. Compilation was greatly done. Validation files throught steam and simple reinstallation doesnt work for me, because of old garbage in steam 7dtd directory (i think that dmt try to be compatible with old version, because of old files, but its actualy new version).

Edited by melvik (see edit history)

Share this post


Link to post
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...