Stin-AFK_Skill_Trainer icon

AFK Skill Trainer

Client-side only: the server doesn't need it. Trains your skills on a T.W.I.G. while you're away: attacks, blocks, parries or rolls, eats your best stamina food, drinks stamina potions or rests when stamina runs out, and stops at skill 100.

By Stin
Last updated a week ago
Total downloads 310
Total rating 1 
Categories Tweaks Misc Tools Client-side Utility NPCs
Dependency string Stin-AFK_Skill_Trainer-1.0.0
Dependants 0 other packages depend on this package

This mod requires the following mods to function

denikson-BepInExPack_Valheim-5.4.2351 icon
denikson-BepInExPack_Valheim

BepInEx pack for Valheim. Preconfigured with the correct entry point for mods and preferred defaults for the community.

Preferred version: 5.4.2351

README

AFK Skill Trainer

A Valheim BepInEx plugin that trains your skills on a T.W.I.G. while you're away from the keyboard. Stand near the dummy and press '. Your character walks in close enough for the mode, then keeps attacking, blocking, parrying or rolling. It drinks a stamina potion or rests when stamina runs out, eats when it can, stays on the spot and stops when the skill reaches 100. Dodge mode needs much less: it rests instead of drinking and only eats when it has to.

Client-side only: only you install it. The server and other players don't need it.

Controls

Key Does
' Start or stop training
; Switch the training mode: attack, block, parry, dodge, then back to attack (works mid-training)

Training modes

  • Attack swings whatever weapon is in your hands and trains that weapon's skill. Unarmed trains Unarmed. It walks you in until the T.W.I.G. is inside three quarters of the weapon's reach, read from the game, so every swing lands.
  • Block holds your shield up against the T.W.I.G.'s swings to train Blocking. The mod drives the block directly, so your block hold/toggle setting doesn't matter. Blocking the T.W.I.G.'s 1-damage swings costs well under 1 stamina each and a parry costs none (Valheim Wiki), so block and parry mode hardly ever rest.
  • Parry raises the shield just before each swing or rock lands, so every block is a parry, which earns more Blocking experience than a plain block. Each kind of T.W.I.G. swing is timed separately, and each T.W.I.G.'s rock for where you stand, since a rock takes longer to fly from further away: the first of each is held with a plain block while the mod measures it. Tower shields can't parry, so with one this mode holds block and says so when it starts.
  • Dodge rolls just before each swing or rock lands, so the hit lands while you're invulnerable, which trains Dodge. It rolls into the T.W.I.G. and walks you back to the start spot between swings. You can't roll while over-encumbered, so if the rolls aren't happening it stops and says why. It only eats when it has to and rests instead of drinking potions (Food and potions in dodge mode).

Block, parry and dodge walk you in to about 1.3 m from the T.W.I.G., inside the range all of its swings come from, so it swings at you.

Parry and dodge need to see the T.W.I.G.'s swings. If they can't, for example because another player's game runs the T.W.I.G., parry mode holds block and dodge mode rolls on a steady 3 s beat, and the mod says so in the corner of the screen.

Rocks

A T.W.I.G. throws rocks at you when you're out of reach of its swings, up to 12 m away. Parry and dodge mode watch every T.W.I.G. that close, not just the one you train on, so a second T.W.I.G. nearby gets its rocks parried or rolled through too. A shield only stops hits from your front half (players on the Steam forum), so parry mode doesn't raise it for a T.W.I.G. behind you; dodge mode rolls for those as well, since a roll works against attacks from any direction (Valheim Wiki: Dodging). When training starts, the log lists each other T.W.I.G. it watches and whether it's in front of you, so you can move one that's behind you.

Parry and dodge can also train against rocks on purpose: start 4 to 12 m from a T.W.I.G. and training stays where you stand instead of walking you in. A rock comes every 6 s at most, so this is slower than training up close. If no rock comes in the first 12 s, parry mode holds block and dodge mode rolls on a beat until one does; if none ever comes, start closer. Block and attack mode always walk you in, and switching to one of them while training at range does too.

Walking in

Training only ever walks you closer: if you're already close enough, it starts where you stand. Switching mode with ; walks you in again if the new mode needs you closer. If something is in the way, it trains from as close as it got, as long as that's within 0.4 m of the spot. If it can't get that close, it gives up after 5 s, or 2 s for each metre of a longer walk, and training stops and says so.

Bows and other ranged weapons

Bows, crossbows and staffs train from where you stand, and you can start attack mode with one up to 20 m from the T.W.I.G. (Target.RangedSearchRadius). The mod turns you to face the T.W.I.G. but leaves the height of your aim alone, so aim at it before you press '. A bow only shoots when attack is let go (Valheim Wiki), so attack mode draws each arrow fully, lets go, then draws the next. Crossbows and staffs fire while attack is held, so it keeps holding it for them.

Stopping at skill 100

Training stops when the skill it trains reaches 100, the most the game allows: your weapon's skill in attack mode, Blocking in block and parry mode, and Dodge in dodge mode. It goes by your own level, not what trinkets, armor sets or food add on top, so at 90 with a +15 trinket it keeps going until your own level is 100. It won't start in a mode whose skill is already 100, and switching to one stops training.

Food and potions in dodge mode

A roll costs about 15 stamina, less as your Dodge skill grows, and half of it comes back when a hit passes through the roll. Without food your stamina bar still holds 50 (Valheim Wiki: Dodging, Stamina), so dodge mode doesn't eat or drink for stamina. When stamina runs out it rests for a few seconds instead of drinking a potion. It only eats when your stamina bar can't hold a single roll, or when your health is under half with no food eaten, since food is what heals you: each food heals 1 to 6 health every 10 seconds (Valheim Wiki: Health). Then it eats one food.

Running out of food doesn't stop dodge mode. Standing still next to the T.W.I.G. would let every swing hit you, while rolling lets few through. Those few still cost health, and food is what heals it, so carry some food for long sessions.

What it does each frame

  1. Stops when you press ' again, press a movement key, die, your weapon breaks, the skill reaches 100, the T.W.I.G. is gone, or you end up more than 3 m from the start spot (6 m in dodge mode, since rolls carry you).
  2. Eats as soon as the game lets you (a free slot, or a food under half its time). It picks the food with the most stamina, then the most health, reading the stats from the game. If a food wears off and nothing in your bag can replace it, training stops: out of food. Carrying fewer than three kinds of food is fine. Dodge mode only eats when it has to and trains on without food.
  3. Stays in place: first it walks you in to the start spot for the mode. After that, if you drift more than 0.3 m from it, it walks you back before the next swing. In dodge mode it waits until it has rolled for the swing that's coming.
  4. Stamina: when stamina is empty (below 5%, or below one swing's or one roll's cost) it drinks the stamina potion worth the most stamina, as soon as the game's potion cooldown allows (dodge mode rests instead). It reads each potion's stats from the game: stamina given straight away or over time, plus faster regen while the potion lasts. Without a potion ready it stops and waits until stamina is back to 50%, and keeps checking for one while it waits. Regen is fastest in the bottom half of the bar, and the shield stays down while resting so regen isn't slowed. Potions that give no stamina, like healing meads, are left alone.
  5. Otherwise it faces the T.W.I.G. and attacks, blocks, parries or rolls.

Requirements

  • Valheim on PC.
  • BepInExPack_Valheim 5.4.2351 or newer. It brings BepInEx 5 and Harmony, which are all the mod needs. No other mods are required.
  • Nothing on the server. The mod is client-side only: it runs in your own game, so it works in single player and on servers, dedicated ones included, without other players or the server installing it.

Install

With a mod manager

Install AFK Skill Trainer from the Online tab in r2modman or the Thunderstore Mod Manager, or with Install with Mod Manager on its Thunderstore page. BepInExPack_Valheim comes with it. Then start the game with Start modded.

By hand (Windows)

  1. Install BepInExPack_Valheim: copy the contents of its BepInExPack_Valheim folder into your Valheim folder, then launch the game once and quit. The Valheim folder is C:\Program Files (x86)\Steam\steamapps\common\Valheim by default; in Steam, right-click Valheim and pick Manage > Browse local files to open it.
  2. Download the mod with Manual Download on its Thunderstore page, and put AfkTraining.dll from the zip in Valheim\BepInEx\plugins\.
  3. Launch the game and open Valheim\BepInEx\LogOutput.log. It should contain AFK Skill Trainer 1.0.0 loaded and Hooked Player.SetControls(...). Any warning or error from AFK Skill Trainer in that file says what didn't work.

Install BepInEx on a Mac

Valheim runs natively on macOS, but BepInEx doesn't run on Apple Silicon yet, so the game has to start through Rosetta.

  1. Copy the contents of the pack's BepInExPack_Valheim folder into your Valheim folder, next to valheim.app. By default that's ~/Library/Application Support/Steam/steamapps/common/Valheim.
  2. In Terminal, make the start script runnable:
    cd ~/Library/Application\ Support/Steam/steamapps/common/Valheim
    chmod u+x start_game_bepinex.sh
    
  3. In Steam, open Valheim's Properties and set Launch Options to:
    /usr/bin/arch -x86_64 /bin/bash ./start_game_bepinex.sh %command%
    
    Without the arch -x86_64 part, an M-series Mac launches the game without BepInEx and no mods load.
  4. Launch the game once from Steam, then put AfkTraining.dll in BepInEx/plugins/ in your Valheim folder.

If macOS blocks the BepInEx files because they were downloaded, clear the download flag from the same Terminal folder: xattr -dr com.apple.quarantine BepInEx doorstop_libs start_game_bepinex.sh.

Settings

Edit BepInEx/config/austin.valheim.afktraining.cfg after the first launch. In r2modman, open it from Config editor.

Setting Default What it does
Keys.ToggleKey ' (Quote) Start/stop key
Keys.ModeKey ; (Semicolon) Training mode switch key
Target.SearchRadius 4 How close the T.W.I.G. must be when you start (m). Training then walks you in. Parry and dodge can start up to 12 m away to train against its rocks
Target.RangedSearchRadius 20 The same with a bow, crossbow or staff in attack mode (m)
Target.DummyNameFilter trainingdummy,t.w.i.g Text used to recognise the T.W.I.G.
Stamina.EmptyStaminaPercent 5 Stamina counts as empty below this % (or one swing's cost)
Stamina.ResumeAtPercent 50 Rest until stamina is back to this %
Position.DriftDistance 0.3 Walk back past this distance (m)
Position.MaxDistance 3 Stop past this distance (m)
Position.DodgeMaxDistance 6 Stop past this distance in dodge mode (m)
Position.StopOnManualMove true Stop when you press a movement key
Food.FoodBlacklist (empty) Comma-separated foods never to eat, e.g. Honey
Potions.DrinkStaminaPotions true Drink stamina potions when stamina runs out (dodge mode rests instead)

Checking training in game

Walking in and the parry and dodge timing can only be checked in the real game, and BepInEx/LogOutput.log shows how it went. When the game loads, these lines say which game calls the mod found:

  • Timing the T.W.I.G.'s swings with ... (parry and dodge need it)
  • Seeing T.W.I.G. hits reach you with ... (times each swing to when it reaches you, and sees what it met)
  • Dodge mode rolls with ...

When training starts, it logs the T.W.I.G.'s swings (The T.W.I.G.'s swings: ...), where it trains from (Start spot: walking in from 3.5 m to 1.3 m from the T.W.I.G. ..., or Start spot: where you stand, 7.0 m from the T.W.I.G., training against its rocks ...), any other T.W.I.G. parry and dodge mode watch (Also watching a T.W.I.G. 3.4 m away, in front of you) and your own level in the skill (Your Blocking skill is 23.5 without gear or food. Training stops at 100.).

While training, it logs each kind of swing and each rock as it's measured (T.W.I.G. swing ... reaches you 1.00 s after it starts, T.W.I.G. rock ... from 7.0 m reaches you 1.46 s after it starts), what the first few swings and rocks met in parry mode (Swing ... was parried; the game's block timer read 0.12 s, and a parry needs under 0.25 s) and how the first few rolls for each went in dodge mode (Rock ... passed through your roll 0.12 s into it). If a swing catches you outside the invulnerable part of a roll, dodge mode moves its timing and logs the change. When dodge mode eats, it says why (Dodge mode ate because your health is 12 of 25 with no food eaten to heal it). When you stop or switch mode, it sums up, for example:

  • Attack mode, 5.0 min: 150 swings, 150 of them hit the T.W.I.G.
  • Parry mode, 5.0 min: 120 T.W.I.G. hits reached you: 118 parried, 2 blocked, 0 with the shield down. 20 of them were rocks: 19 parried, 1 blocked, 0 not stopped. Hits from a T.W.I.G. behind you are counted on their own.
  • Dodge mode, 5.0 min: 100 rolls. Of the swings rolled for (20 of them rocks), 96 reached you while you were invulnerable, ... It ends with how many hits came during a roll not made for them, and how many landed while it rested for stamina, if any did.

Building it yourself

BUILDING.md in the source code explains how to build the DLL and this package.