Loading...
Loading...
BepInEx-based cooperative multiplayer mod for Subnautica 2 with synchronized sessions, shared inventory, and AI-enhanced narrative generation
npx skill4agent add aradotso/devtools-skills subnautica-2-deep-synergy-coop-modSkill by ara.so — Devtools Skills collection.
<game_root>/BepInEx/plugins/Subnautica2/
├── BepInEx/
│ ├── plugins/
│ │ ├── DeepSynergyCore.dll
│ │ ├── SessionManager.dll
│ │ ├── StateSynchronizer.dll
│ │ └── ConflictResolver.dll
│ ├── config/
│ │ ├── synergy_profile.json
│ │ └── session_config.xml
│ └── LogOutput.log
└── Subnautica2.exe# Launch via Steam or direct executable
# BepInEx will patch the game on first run
# Check BepInEx/LogOutput.log for successful mod loading[Info : BepInEx] BepInEx 6.0.0 - Subnautica2 (5/14/2026)
[Info :DeepSynergy] Deep Synergy Multiplayer Mod v1.0.0 loaded
[Info :DeepSynergy] Session Manager initialized
[Info :DeepSynergy] WebRTC transport layer readyBepInEx/config/synergy_profile.json{
"session_name": "Deep Exploration Team",
"max_players": 4,
"difficulty_scale": "adaptive",
"resource_multiplier": 1.5,
"oxygen_consumption": 0.85,
"creature_spawn_divider": 1.5,
"enable_pvp": false,
"friendly_fire": false,
"shared_blueprints": true,
"ping_locations_shared": true,
"time_of_day_sync": "host",
"voice_chat_integration": "discord_rpc",
"locale": "en_US",
"api_integration": {
"openai": {
"enabled": false,
"api_key_env": "OPENAI_API_KEY",
"model": "gpt-4",
"role": "narrator"
},
"claude": {
"enabled": false,
"api_key_env": "ANTHROPIC_API_KEY",
"model": "claude-3-opus-20240229",
"role": "lore_engine"
}
},
"network": {
"nat_traversal": true,
"max_latency_ms": 250,
"sync_interval_ms": 50,
"inventory_hash_algorithm": "sha256"
}
}difficulty_scale"static""adaptive""linear"resource_multiplieroxygen_consumptioncreature_spawn_dividertime_of_day_sync"host""all""independent"api_key_envBepInEx/config/session_config.xml<?xml version="1.0" encoding="utf-8"?>
<SynergyConfig>
<Session>
<DefaultPort>25565</DefaultPort>
<EnableUPnP>true</EnableUPnP>
<MaxConnectionAttempts>5</MaxConnectionAttempts>
<ConnectionTimeoutSeconds>30</ConnectionTimeoutSeconds>
</Session>
<Synchronization>
<InventoryHashInterval>1000</InventoryHashInterval>
<CreatureStateInterval>200</CreatureStateInterval>
<BaseStructureInterval>500</BaseStructureInterval>
</Synchronization>
<Logging>
<Level>Info</Level>
<EnableNetworkDebug>false</EnableNetworkDebug>
</Logging>
</SynergyConfig>F12# Start hosting a session
/start_server
# Output: Server created: session code = 9B2A-4C7D-E8F1
# Join existing session
/join_session 9B2A-4C7D-E8F1
# Check connection status
/synergy_status
# Output:
# Connected peers: 3/4
# State sync: 100% complete
# Inventory hash: 0xFA342B1E
# Avg latency: 45ms
# Leave session gracefully
/disconnect_session# Temporarily adjust difficulty multiplier
/synergy_scale 1.5
# Reset to config defaults
/synergy_reset
# Force world seed sync (host only)
/seed_override 8251# Trigger OpenAI narrative generation
/api_narrate "discovered alien artifact in lost river"
# Generate species biology log with Claude
/api_lore_generate "ghost leviathan juvenile"
# Show last 5 AI-generated journal entries
/api_journal_history 5# Enable verbose network logging
/debug_network true
# Dump current inventory Merkle tree
/debug_inventory_tree
# Force state resync
/force_resync
# Show desync detection results
/debug_conflictsusing BepInEx;
using BepInEx.IL2CPP;
using HarmonyLib;
using DeepSynergy.Core;
namespace DeepSynergy.CustomExtension
{
[BepInPlugin(PluginGUID, PluginName, PluginVersion)]
[BepInDependency("com.deepsynergy.core")]
public class CustomExtensionPlugin : BasePlugin
{
public const string PluginGUID = "com.yourname.customextension";
public const string PluginName = "Custom Deep Synergy Extension";
public const string PluginVersion = "1.0.0";
private Harmony _harmony;
public override void Load()
{
_harmony = new Harmony(PluginGUID);
_harmony.PatchAll();
// Hook into session events
SessionManager.OnPlayerJoined += OnPlayerJoinedHandler;
SessionManager.OnInventorySynced += OnInventorySyncedHandler;
Log.LogInfo($"{PluginName} loaded successfully");
}
private void OnPlayerJoinedHandler(string playerId)
{
Log.LogInfo($"Player joined: {playerId}");
// Custom logic here
}
private void OnInventorySyncedHandler(InventorySyncData data)
{
Log.LogInfo($"Inventory synced - hash: {data.MerkleRootHash}");
}
}
}using HarmonyLib;
using DeepSynergy.Core;
namespace DeepSynergy.CustomExtension
{
[HarmonyPatch(typeof(Player), "ConsumeOxygen")]
public static class OxygenConsumptionPatch
{
static void Prefix(ref float amount)
{
// Apply session multiplier from config
float multiplier = SynergyConfig.Current.OxygenConsumption;
amount *= multiplier;
// Sync to other clients
if (SessionManager.IsHost)
{
NetworkSync.BroadcastOxygenEvent(amount);
}
}
}
}using DeepSynergy.API;
using System.Threading.Tasks;
public class CustomNarrativeGenerator
{
private readonly OpenAIClient _openai;
public CustomNarrativeGenerator()
{
string apiKey = Environment.GetEnvironmentVariable("OPENAI_API_KEY");
_openai = new OpenAIClient(apiKey);
}
public async Task<string> GenerateBaseDescription(BaseStructure baseData)
{
string prompt = $@"Generate a brief narrative description for an underwater base:
- Location: {baseData.Biome}
- Depth: {baseData.DepthMeters}m
- Components: {string.Join(", ", baseData.Modules)}
- Players: {baseData.PlayerCount}
Keep it under 100 words, immersive tone.";
var response = await _openai.GenerateCompletion(prompt, maxTokens: 150);
return response.Text;
}
}{
"session_name": "Resource Run",
"max_players": 2,
"difficulty_scale": "static",
"resource_multiplier": 1.3,
"oxygen_consumption": 0.9,
"creature_spawn_divider": 1.2,
"shared_blueprints": true,
"time_of_day_sync": "host"
}# Player 1 (Host)
/start_server
# Share code 4A7B-9C2D-E5F3 with Player 2
# Player 2 (Client)
/join_session 4A7B-9C2D-E5F3
# Both players check sync
/synergy_status{
"session_name": "Mega Base Construction",
"max_players": 4,
"difficulty_scale": "adaptive",
"resource_multiplier": 2.0,
"oxygen_consumption": 0.7,
"creature_spawn_divider": 2.0,
"shared_blueprints": true,
"ping_locations_shared": true,
"time_of_day_sync": "all"
}{
"session_name": "Lore Expedition",
"max_players": 2,
"api_integration": {
"openai": {
"enabled": true,
"api_key_env": "OPENAI_API_KEY",
"model": "gpt-4",
"role": "narrator"
},
"claude": {
"enabled": true,
"api_key_env": "ANTHROPIC_API_KEY",
"model": "claude-3-opus-20240229",
"role": "lore_engine"
}
}
}/api_narrate "entering the blood kelp zone at 300m depth"
# Output: "The crimson fronds pulse with bioluminescent life as the team descends..."
/api_lore_generate "crabsquid behavior patterns"
# Output: "Species: Crabsquid (Elektrus Crustacea)..."# Check NAT configuration
/debug_network true
# Look for "NAT type: Symmetric" in logs (problematic)
# Enable UPnP in session_config.xml
<EnableUPnP>true</EnableUPnP>
# Alternative: Port forward 25565 on router# Check current sync status
/debug_conflicts
# Force full resync
/force_resync
# Adjust sync interval in config
"sync_interval_ms": 100 # Increase from 50msBepInEx/LogOutput.log.dllBepInEx/plugins/BepInEx/cache/# Verify environment variable is set
# Windows PowerShell
echo $env:OPENAI_API_KEY
# Linux/macOS
echo $OPENAI_API_KEY
# Set if missing (do NOT commit to code)
# Windows
setx OPENAI_API_KEY "your-key-here"
# Linux/macOS
export OPENAI_API_KEY="your-key-here""api_integration": {
"openai": {
"api_key_env": "OPENAI_API_KEY" // Must match env var name
}
}# Check current latency
/synergy_status
# If avg latency > 150ms, adjust config
# Increase sync intervals in session_config.xml
<InventoryHashInterval>2000</InventoryHashInterval> # From 1000
<CreatureStateInterval>400</CreatureStateInterval> # From 200
# Reduce max players
"max_players": 2 # From 4# Enable creature debug logging
/debug_network true
# Check creature sync interval
<CreatureStateInterval>200</CreatureStateInterval>
# Force creature state resync (host only)
/force_resync creaturessynergy_profile.json{
"biome_overrides": {
"safe_shallows": {
"resource_multiplier": 1.0,
"creature_spawn_divider": 1.0
},
"kelp_forest": {
"resource_multiplier": 1.2,
"creature_spawn_divider": 1.3
},
"blood_kelp_zone": {
"resource_multiplier": 1.5,
"creature_spawn_divider": 2.0
},
"lost_river": {
"resource_multiplier": 2.0,
"creature_spawn_divider": 2.5
}
}
}{
"session_persistence": {
"enabled": true,
"autosave_interval_minutes": 10,
"save_directory": "BepInEx/saves/",
"compress_saves": true
}
}/load_session "Deep_Exploration_2026-05-14"BepInEx/config/localizations/custom_en.json{
"ui.session.created": "Session established: {0}",
"ui.player.joined": "{0} has entered the abyss",
"ui.inventory.synced": "Inventory synchronized",
"console.help.start_server": "Create a new multiplayer session"
}string message = LocalizationManager.Get("ui.player.joined", playerName);{
"network": {
"compression": "lz4",
"delta_encoding": true,
"sync_radius_meters": 500, // Only sync entities within 500m
"inventory_batch_updates": true
}
}{
"performance": {
"reduce_sync_precision": true, // Reduce float precision for position sync
"skip_inactive_entities": true, // Don't sync entities outside render distance
"lazy_merkle_updates": true // Update inventory tree only on change
}
}