Jump to content

StayClear (No Sleeper Respawn) [A19 tested]


ExtremeLurker

Recommended Posts

namespace StayClear
{

    [HarmonyLib.HarmonyPatch(typeof(SleeperVolume))]
    [HarmonyLib.HarmonyPatch("UpdatePlayerTouched")]
    public class StayClear_SleeperVolume_UpdatePlayerTouched
    {
        static bool Prefix(ref ulong ___respawnTime, World _world)
        {
            ___respawnTime = _world.worldTime + 120000UL;
            return true;
        }
    }

    public class StayClear : IModApi
    {
        void IModApi.InitMod(Mod _modInstance)
        {
            var harmony = new HarmonyLib.Harmony("io.stealthbit.7dtdmods.StayClear");
            harmony.PatchAll();
        }
    }
}

 

 

Something like that should work after adding the relevant dll references. (Untested)

Link to comment
Share on other sites

1 hour ago, Pointy said:
namespace StayClear
{

    [HarmonyLib.HarmonyPatch(typeof(SleeperVolume))]
    [HarmonyLib.HarmonyPatch("UpdatePlayerTouched")]
    public class StayClear_SleeperVolume_UpdatePlayerTouched
    {
        static bool Prefix(ref ulong ___respawnTime, World _world)
        {
            ___respawnTime = _world.worldTime + 120000UL;
            return true;
        }
    }

    public class StayClear : IModApi
    {
        void IModApi.InitMod(Mod _modInstance)
        {
            var harmony = new HarmonyLib.Harmony("io.stealthbit.7dtdmods.StayClear");
            harmony.PatchAll();
        }
    }
}

 

 

Something like that should work after adding the relevant dll references. (Untested)

 

Hey, thanks. I received something similar from another user of the mod. The prefix method appears unaltered from v1.2.0 of my mod, the key difference here is the usage of IModApi instead of IHarmony. The thing is, using the built in Modding API only works on dedicated servers and not on single player or p2p multiplayer sessions, and I'd prefer not to distribute a version that's only for dedicated servers. In the past I've used my mod on dedicated servers provided the server has DMT enabled (the above code also requires DMT), and I'm going to see if I'm able to verify the same here. I need to download A20, check the updates to SleeperVolume, and ensure that nothing that's changed impacts my mod. Then I will test in game to ensure it works, and if so I will test on a dedicated server to ensure it works there as well, and then I'll share the result.

If anyone is wanting to use the mod right away, you can use the existing download link and apply it with DMT and maybe it will work as is.

Link to comment
Share on other sites

I'm not the most knowledgeable person (like, at all) about this stuff, but would something like this help at all? Its what OCBmaurice has been using to get many of his DMT based mods working. Also, I know that Spherii has most of his DMT mods in a useable form over on his github here. It even has his core mod that a lot of things relied on. I don't know if any of that is even remotely useful but I thought I'd at least attempt to be helpful. I'm not trying to rush you or anything either, just sharing some info of an undetermined relevance or usefulness:)

Link to comment
Share on other sites

4 hours ago, ExtremeLurker said:

The thing is, using the built in Modding API only works on dedicated servers and not on single player or p2p multiplayer sessions, and I'd prefer not to distribute a version that's only for dedicated servers.

 

 

Some of the c# stuff I was messing about with using the built in API worked in SP, but that was before it went stable, so I don't know if they changed something. Some mods were required client side and server side to work.

Link to comment
Share on other sites

16 minutes ago, Pointy said:

 

 

Some of the c# stuff I was messing about with using the built in API worked in SP, but that was before it went stable, so I don't know if they changed something. Some mods were required client side and server side to work.


IModApi is used to run C# on the server, and it only works on dedicated servers. You can find more information here:
https://7daystodie.fandom.com/wiki/ModAPI

You are right that some mods are required on the client side and the server side, I'd say that's most mods that do anything of substance, but DMT mods work on the server side as long as the server is DMT-enabled and the mod is placed in the "Mods" folder on the server. I know this because I regularly ran my mod on a dedicated server and only became aware of the IModApi method recently. While IModApi is a great method for mods that are strictly for dedicated servers, it's not the best option for this, where I'd prefer a solution that works for everyone :)

 

To be clear though, have you had success getting the mod to work on a dedicated server with the code you posted? Because if so, it likely means that I won't have to do much if anything to get it to work besides just testing and verifying it for everyone, and posting a guide for how to get it working.

 

1 hour ago, ate0ate said:

I'm not the most knowledgeable person (like, at all) about this stuff, but would something like this help at all? Its what OCBmaurice has been using to get many of his DMT based mods working. Also, I know that Spherii has most of his DMT mods in a useable form over on his github here. It even has his core mod that a lot of things relied on. I don't know if any of that is even remotely useful but I thought I'd at least attempt to be helpful. I'm not trying to rush you or anything either, just sharing some info of an undetermined relevance or usefulness:)

 

Thank you for linking me to this tool. I wasn't aware of it. I don't think it will be necessary, but it appears to be a way of loading DMT mods without modifying the actual client files themselves in the way that the DMT patcher tool does. This is not very relevant to this project specifically, as it is a tool to be used by people using mods, not people trying to create them, as it gives users another avenue for applying their mod, one which would appear to be less prone to being affected by game updates that require you to re-patch your client each time. Even so, I'm happy you shared it with me because it's a very cool thing to be aware of. I didn't know there was another way to use DMT mods. I wonder if this would also work for p2p and dedicated servers. I'll need to try it out sometime in the future.

Also, I'm aware of Spherii's github, I do check it out sometimes and it has helped me learn a few things on my journey of learning about modding! I'll certainly give it a look if I run into serious issues as you say that he's been getting DMT stuff working on A20. Thanks for all the info.

Edited by ExtremeLurker (see edit history)
Link to comment
Share on other sites

6 hours ago, ExtremeLurker said:

The thing is, using the built in Modding API only works on dedicated servers and not on single player or p2p multiplayer sessions, and I'd prefer not to distribute a version that's only for dedicated servers.


I've recently adapted WalkerSim for A20 and IModApi + Harmony is working fine in SP.
https://github.com/RagnarHbUa/7d2dWalkerSim/blob/master/src/API.cs#L31
https://github.com/RagnarHbUa/7d2dWalkerSim/blob/master/src/Hooks.cs#L16

Another mod I've been using fine in SP, that is created in vanilla A20 dll mod way
https://github.com/ZehMatt/7dtd-HeadshotTime/blob/master/HeadshotTime/Mod.cs#L76

IModAPi is for the game to see your dll mod at all. And still you can use Harmony to mutate the insides of original game. No problem.

Edited by Ragnar (see edit history)
Link to comment
Share on other sites

53 minutes ago, Ragnar said:


I've recently adapted WalkerSim for A20 and IModApi + Harmony is working fine in SP.
https://github.com/RagnarHbUa/7d2dWalkerSim/blob/master/src/API.cs#L31
https://github.com/RagnarHbUa/7d2dWalkerSim/blob/master/src/Hooks.cs#L16

Another mod I've been using fine in SP, that is created in vanilla A20 dll mod way
https://github.com/ZehMatt/7dtd-HeadshotTime/blob/master/HeadshotTime/Mod.cs#L76

IModAPi is for the game to see your dll mod at all. And still you can use Harmony to mutate the insides of original game. No problem.


I'm not sure I understand. IModApi was created specifically for adding functionality to dedicated servers, such as slash commands. Did they change this with A20? (yes they did, see edit) If so, are you aware of any information I can read documenting the change (seeing as the current wiki is outdated)? Harmony is not something that works out of the box. Are they including Harmony as a part of the game? (yes they are, see edit)

DMT uses Harmony, which uses the IHarmony interface for classes exposing a Start method that gets executed when your mod is being loaded. I have looked at many DMT mods from the community and they all tend to work that way. This is the first time I'm seeing the IModApi interface being used outside of dedicated servers, I've just not come across it before personally because that's not what it was intended for, though I don't know when that changed 🤔

Looking at SphereII's github, it looks like when moving from A19 to A20, he switched from using DMT's IHarmony hook to the IModApi method. I'm going to search for more information about this change.

EDIT:
I've just read that Harmony is now included in the game? This is VERY exciting. DMT is now being phased out. When I'd read about the updates in A20, I've not yet seen anything about this, but this is very significant. Thank you very much for pointing this out to me.

 

I will still like to test and verify that it works on both SP and dedicated servers, but yes, it seems like C# modding support is now officially supported on the client using Harmony without needing any sort of patcher, which makes me very confused about what the necessity of something like BepInEx is, but excited all the same. Perhaps the need for BepInEx is now only for when you need to do something that requires more than Harmony is capable of.

Edited by ExtremeLurker (see edit history)
Link to comment
Share on other sites

I couldn't find any official info about how to make mods for A20, so I spent the whole day looking for fresh mods for A20 and experimenting myselft.
You now just need some class in your dll to implement IModApi, then the whole dll in the root of your mod's directory (same level with ModInfo.xml) would be loaded. I've created new console command this way: 
public class ConsoleCmdCompleteTrackedQuest : ConsoleCmdAbstract
{

// Actual usefull code of new cmd. Due to inheritace of ConsoleCmdAbstract, this command would be loaded on startup (game uses reflection to find heirs of ConsoleCmdAbstract).

}

public class CompleteTrackedQuest : IModApi
{
    void IModApi.InitMod(Mod _modInstance)
    {
        // Empty, just for the game to see the mod
    }
}

Link to comment
Share on other sites

47 minutes ago, Ragnar said:

I couldn't find any official info about how to make mods for A20, so I spent the whole day looking for fresh mods for A20 and experimenting myselft.
You now just need some class in your dll to implement IModApi, then the whole dll in the root of your mod's directory (same level with ModInfo.xml) would be loaded. I've created new console command this way: 
public class ConsoleCmdCompleteTrackedQuest : ConsoleCmdAbstract
{

// Actual usefull code of new cmd. Due to inheritace of ConsoleCmdAbstract, this command would be loaded on startup (game uses reflection to find heirs of ConsoleCmdAbstract).

}

public class CompleteTrackedQuest : IModApi
{
    void IModApi.InitMod(Mod _modInstance)
    {
        // Empty, just for the game to see the mod
    }
}

 

Before A20, this would have only worked for dedicated servers, and you'd still have had to use DMT to patch the dedicated server's assembly, should you be wanting to use Harmony. This is a much easier system now and now consumers don't have to use a patcher now that Harmony is shipped with the game and the InitMod hook works on the game client and not just the server. Definitely a big step forward! Thanks again for opening my eyes to this.

 

Now I just need to figure out how to get a project setup to be able to build. I'd prefer to use VSCode as opposed to Visual Studio. SphereII has put together an example project and a tutorial video, I should be able to use that in order to set something up, but I obviously will have no time for that today, as I won't be home, given the holiday.

Edited by ExtremeLurker (see edit history)
Link to comment
Share on other sites

1 hour ago, Madnesis said:

It looks like we might not need a Moddlet for A20 to disable sleepers respawn ONLY IF you play with loot disabled like I do, see here: https://steamcommunity.com/app/251570/discussions/0/3196990777799400614/?tscn=1640041856#c3196990777799923728

 

I had seen something like this talked about on these forums, and while it's cool that zombie respawn is now tied to loot respawn, you still cannot disable zombie respawn in the current version. If you set loot respawn to disabled, zombies will still respawn in a POI that has been cleared and not visited for 30 days. I have just finished testing to verify that. I have not yet reviewed the changes in the code for SleeperVolume, but I will try to do so tomorrow. Hoping to release something soon seeing as it would appear the mod is still necessary.

Link to comment
Share on other sites

I have reviewed the changes to SleeperVolume, and as I suspected, it does set the respawn time to whatever is set for loot respawn, and if loot respawn is disable, it sets it to 30 days.

 

Also, I got around to setting up the project for the new A20 system, updating the code, and testing it out as best as I can. I have only tested it out on singleplayer, however, but I I know someone who has tried it out on a server as well. I'll do some more testing when I get a chance, but I wanted to create a release as soon as I could. I've created a new thread for it here. Enjoy!

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...