Miscellaneousv0.1.0BepInEx

ValheimBotBridge

vaine
vaineValkyrie
·5·5.0·395.1 KB

valheim-ai-agent

An AI agent framework for controlling a Valheim character programmatically, using a BepInEx plugin as a game bridge and a Python agent powered by an LLM.

Inspired by Minecraft bot frameworks such as mineflayer, adapted to Valheim's closed binary via BepInEx modding.


Architecture

The system has three layers:

┌─────────────────────────────────────────────────────┐
│  Valheim Process                                    │
│  ┌───────────────────────────────────────────────┐  │
│  │  ValheimBotBridge (BepInEx C# plugin)         │  │
│  │  - Serializes game state to JSON              │  │
│  │  - Hosts WebSocket server on localhost:25500  │  │
│  │  - Executes action commands from agent        │  │
│  └───────────────────┬───────────────────────────┘  │
└──────────────────────│──────────────────────────────┘
                       │ WebSocket (ws://localhost:25500)
┌──────────────────────│──────────────────────────────┐
│  Python Agent        │                              │
│  ┌───────────────────▼───────────────────────────┐  │
│  │  valheim_agent.py                             │  │
│  │  - Receives game state                        │  │
│  │  - Calls LLM (Claude / GPT-4o)               │  │
│  │  - Sends action commands                      │  │
│  └───────────────────────────────────────────────┘  │
└─────────────────────────────────────────────────────┘

Data flow: Game state → WebSocket → Python agent → LLM → action command → WebSocket → game.


Repository Structure

valheim-ai-agent/
  README.md                  ← this file
  plugin/                    ← BepInEx C# plugin
    README.md                ← build & deployment guide
    ValheimBotBridge.csproj
    Plugin.cs
    WebSocketServer.cs
    StateSerializer.cs
    ActionHandler.cs
    Config.cs
    libs/                    ← local copies of reference DLLs (not committed)
  agent/                     ← Python AI agent
    README.md                ← setup & usage guide
    valheim_agent.py
    bridge.py
    state.py
    planner.py
    actions.py
    memory.py
    config.py
  docs/
    ARCHITECTURE.md          ← full technical architecture & implementation plan
  tests/
    test_bridge.py           ← Phase 1 tests (T01–T07)
    test_state.py            ← Phase 2 tests (T08–T16)
    test_llm.py              ← Phase 3 tests (T17–T22)

Prerequisites

System

  • Linux (tested on Pop!_OS 24.04)
  • .NET SDK 10 (dotnet --version to confirm)
  • Python 3.11+
  • Steam with Valheim installed

Valheim modding

  • r2modman installed
  • BepInEx installed via r2modman (denikson-BepInExPack_Valheim 5.4.2333)
  • An active r2modman profile for Valheim

API

  • An Anthropic or OpenAI API key (for the Python agent, Phase 3+)

Quick Start

These are the minimum steps to get from a fresh clone to a running plugin (Phase 1). See the per-module READMEs for full detail.

1. Populate the libs/ folder

Copy reference DLLs from your Valheim and BepInEx installations into plugin/libs/. Required files are listed in plugin/README.md.

2. Build the plugin

cd plugin
dotnet build -c Release

3. Deploy to r2modman

PROFILE="<your-profile-name>"
PLUGINS=~/.config/r2modmanPlus-local/Valheim/profiles/$PROFILE/BepInEx/plugins

cp plugin/bin/Release/netstandard2.1/ValheimBotBridge.dll $PLUGINS/
cp plugin/bin/Release/netstandard2.1/websocket-sharp.dll $PLUGINS/
cp plugin/bin/Release/netstandard2.1/Newtonsoft.Json.dll $PLUGINS/

4. Launch Valheim via r2modman (Start modded)

5. Verify the plugin loaded

tail -f ~/.config/r2modmanPlus-local/Valheim/profiles/$PROFILE/BepInEx/LogOutput.log

Expected output:

[Info   :   BepInEx] Loading [ValheimBotBridge 0.1.0]

6. Start the Python agent (Phase 3 — see agent/README.md)

cd agent
pip install -r requirements.txt
python valheim_agent.py

Release Flow

1. Build

cd plugin && dotnet build -c Release && cd ..

2. Stage DLLs into release/plugins/

bash scripts/prepare-release.sh

3. Update changelog, then commit

vim CHANGELOG.md git add release/plugins/ CHANGELOG.md git commit -m "Release v0.1.0"

4. Tag and push — this triggers the GitHub Action

git tag v0.1.0
git push origin main v0.1.0

Documentation Index

DocumentLocationDescription
This fileREADME.mdProject overview, architecture, quick start
Plugin guideplugin/README.mdBuilding, deploying, and testing the BepInEx plugin
Agent guideagent/README.mdSetting up and running the Python agent
Architecture & plandocs/ARCHITECTURE.mdFull technical design, phase plan, and test suite (T01–T27)

Implementation Status

PhaseDescriptionStatus
Phase 1WebSocket bridge foundation✅ Complete
Phase 2Full state schema & all actions✅ Complete
Phase 3LLM integration🔲 Not started
Phase 4Hardening & stability🔲 Not started

About

BepInEx plugin that exposes a WebSocket API for AI agent control of a Valheim character. Enables LLM-driven bots to observe game state and execute actions.

Rating

5.0(1 review)

Sign in to rate this mod.

Details

Mod LoaderBepInEx
Downloads5
Versionv0.1.0
Created23 days ago
Updated2 days ago

Dependencies1

  • BepInExPack_Valheimdenikson·v5.4.2333

Creator

vaine

vaineValkyrie

@vaine

5.0 creator rating

1

Mods

5

Downloads

1

Reviews

Versions

v0.1.0Latest
23 days ago·395.1 KB