hugocowan / OxygenWarningInHardcoreMode

Play Subnautica as if in Survival mode (you still get Oxygen warnings) but with permadeath
0 stars 0 forks source link

BepInEx migration #1

Open Cat-Lady opened 1 year ago

Cat-Lady commented 1 year ago

Hello hugocowan, Would there be a possibility of you ugprading the mod to work with latest API for modding Subnautica? Past version 2.0, qmod is depreciated, and your mod is no longer working.

As I understand it, all that is needed to accomplish that, is to convert your mod entry point from (example):

using QModManager.Utility;
using HarmonyLib;

[QModCore]
public static class QPatch
{
  [QModPatch]
  public static void Load()
  {
    var harmony = new Harmony("Your unique mod identifier");
    harmony.PatchAll();
  }
}

...to:

using HarmonyLib;

[BepInPlugin(GUID, MODNAME, VERSION)]
public class MyPlugin : BaseUnityPlugin
{
  // You may also use Awake(), Update(), LateUpdate() etc..
  // as BepInEx plugins are MonoBehaviours.
  private void Start()
  {
    var harmony = new Harmony(GUID);
    harmony.PatchAll();
  }
}

After that, it should be a matter of uploading the resulting, updated .dll to the Nexus page of your mod. Thanks in advance!

hugocowan commented 1 year ago

Hey there Cat-Lady,

I have done as you suggested. I tried to quickly test my changes in-game but couldn't get it working. It's been a long time since I played/modded Subnautica, would you be able to help test this by installing the attached updated mod and trying it out?

Check with DnsSpy if you like, it's the same as the current code aside from the changes you requested and a version bump. I also pushed the update to github, so you could build it yourself if you wanted.

OxygenWarningInHardcoreMode.zip

Cat-Lady commented 1 year ago

Hello Hugo, Thank you for trying to update it, either way. I am currently traveling, so I will test the file ASAP - probably no latter than tomorrow. I will let you know how it went. I am not Subnautica modding guru either, but I will try to grab some log output, if it fails.

Cheers, /CatLady

Cat-Lady commented 1 year ago

Good news! I have tested your updated plugin (sorry for the delay), and it seems to be working fine - I was getting the "oxygen - swim to surface!" warning (but not the "30 seconds remaining" and such ones, fine by me, as it is the critical one that was important).

As a minor (non-critical) side effect, I am also seeing the separate "save" option in menu - instead of the usual (for hardcore mode) "save and quit" only. But, it is not really important - if character dies, the "game over" message is shown properly, and save gets deleted.

I think that you can safely upload this version as BepInEx compatible one. Small suggestion - the "mod.json" file is no longer needed, as per BepInEx documentation (I was testing just the plugin .dll file). Unless you are sure that the current .dll works both with Legacy versions of Subnautica (and qmod), you might want to delete it, as it will confuse migrating users (usually, the file presence is an indication it is qmod only modification).

Cheers and thank you, /CatLady

Cat-Lady commented 1 year ago

Hello, I have tested your updated file. I can confirm that the behavior re saving is same as vanilla, now - only option to exit to menu exist, and if used, game is automatically saved.

Hoever, I would consider keeping the old behavior as feature, honestly. It still can't be used to bypass hardcore (dying still deletes save), but the ability to put manual save helps with preventing long gameplay loses like crashes, power interruption etc.

Sure, same could be made by just entering main menu and returning to game - but, it is less convenient than just hitting save button (or quicksave one, with mods). Frankly, I don't know why it isn't like that in vanilla - most games with permadeath still allow to trigger saving on demand (using just one save file), just not allowing to load.

On a different note - I am curious why you're unable to load your own mod. If you are having Subnautica's edition of BepInEx setup properly and you're 100% positive that other BepInEx mods are working fine, it is strange, indeed. All I needed to do was dropping your .dll file into /plugins folder of the BepInEx. Only thing I can think of, is that I am also using a few helper submods for BepInEx itself:

BepInEx Tweaks https://www.nexusmods.com/subnautica/mods/1104

SMLHelper (BepInEx version) https://www.nexusmods.com/subnautica/mods/113

Configuration Manager for BepInEx https://www.nexusmods.com/subnautica/mods/1112

...in addition to this package of main BepInEx for Subnautica: https://www.nexusmods.com/subnautica/mods/1108

As I understand it, none of those should affect your mod, but if you're willing to test it, I would try dropping them in, especially the first two. I hope you will be able to crack this one... Either way, the "no oxygen warning" is working fine, no matter which version (re the save files) - or, maybe, two alternatives? - you decide to publish.

Cheers, /CatLady

2023-02-27 15:39 GMT+01:00, Hugo @.***>:

OxygenWarningInHardcoreMode.zip

Hi again,

Thanks for testing. I've added a couple checks that should hopefully help with the save option thing, if you could try this out that would be fantastic. I've been trying to get my mod to load with no success - even though I've gotten other mods to load, so I seem to be at the mercy of your testing here.

-- Reply to this email directly or view it on GitHub: https://github.com/hugocowan/OxygenWarningInHardcoreMode/issues/1#issuecomment-1446447731 You are receiving this because you authored the thread.

Message ID: @.***>

hugocowan commented 1 year ago

Thanks for the links, I actually deleted my comment as I just got it working hah..

I see what you're saying, I'll just upload a working version of the mod as it used to work before. I'll have a think about the save thing and how I might add a different version of the mod too.

Cat-Lady commented 1 year ago

Glad you got it working, and thanks again for picking up the conversion and not giving up when you had problems with loading it :) Glad I could be of help!

2023-02-27 16:30 GMT+01:00, Hugo @.***>:

Thanks for the links, I actually deleted my comment as I just got it working hah..

I see what you're saying, I'll just upload a working version of the mod as it used to work before. I'll have a think about the save thing and how I might add a different version of the mod too.

-- Reply to this email directly or view it on GitHub: https://github.com/hugocowan/OxygenWarningInHardcoreMode/issues/1#issuecomment-1446543045 You are receiving this because you authored the thread.

Message ID: @.***>

Kalmorph commented 1 week ago

Sorry to revive the topic; how is that supposed to be installed? I added the OxygenWarningInHardcoreMode.dll file inside the BepInEx\plugins folder and didn't worked. The author didn't updated the Nexus page and none of the posts there says it either. Am I doing something wrong?