Valheim

TameLeash

Keeps your following tames close in combat.

In vanilla Valheim, a tame that follows you attacks any enemy it notices and chases it as far as it likes. It only goes back to following you once it has no target left. In quiet biomes that's fine. In busy ones like the Ashlands there is always another enemy, so your tames scatter across the map instead of staying with you.

TameLeash gives every tame that follows you a guard radius around you:

  • It only picks enemies that are within the Guard Radius of you (default 20 m).
  • It fights those enemies freely and is never called back mid-fight.
  • It only gives up a target once the target moves beyond the Release Radius (default 28 m), for example an enemy running away. Then it comes back to you.

The two radii are different on purpose. Archers and other ranged enemies often stand right at the edge of the guard radius. With a single radius, a tame would grab them and let go again over and over.

Out of combat, TameLeash also lets you choose how close tames stay. In vanilla, a following tame stops 3 m from you, right under your feet. With TameLeash it stops at the Follow Distance (default 9 m). It still walks first and only starts running once it falls 7 m further behind, just like vanilla.

With Keep Away (on by default), a tame that stays closer than 4 m to you for more than 3 seconds walks away until it is back near the follow distance. This mostly happens when a portal or teleport drops it at your feet. The delay gives you time to mount, pet or feed it. Keep Away never runs during combat.

Keep Away needs room to work. The tame walks back to 1 m inside the follow distance, so that spot must be farther than Keep Away Distance. In other words, Follow Distance − 1 must be greater than Keep Away Distance, otherwise Keep Away turns itself off and a warning is written to the log. For example, with Follow Distance 9 (default), any Keep Away Distance below 8 works. With Follow Distance 5, use a Keep Away Distance of 3 or less.

Tames that are set to stay and wild creatures are not affected by the guard radius or the follow settings.

Defense. In vanilla, tames keep the same health and resistances for the whole game, while enemy damage keeps going up. From the Plains onwards, wolves die almost instantly. TameLeash gives all tamed creatures (following or not) a damage reduction that grows with the world's progress: each of Moder, Yagluth, The Queen and Fader defeated adds a quarter of Max Reduction. With the default of 50%, that is −12.5% after Moder, −25% after Yagluth, −37.5% after The Queen and −50% after Fader. Before Moder, tames take normal damage. The reduction applies to every damage type, on top of the creature's own resistances.

Assist (experimental). When you hit an enemy (melee, arrows, magic), the tames following you attack that enemy, even if they were fighting another one or had not noticed it yet. They keep focusing it for Assist Duration (default 10 s) after your last hit, then go back to picking enemies on their own. Only enemies within Release Radius of you count.

Nameplates. The name and health bar of the tames following you stay visible up to Show Distance (default 30 m). In vanilla, they disappear shortly after you stop looking at a creature and never show beyond 10 m. A sleeping tame gets [zZz] next to its name. With BetterTames, a downed (recovering) tame is asleep, so you can see at a glance which of your tames is down.

Pass through tames. Players walk through tamed creatures instead of bumping into them, so a wolf in a doorway or a lox on a bridge no longer blocks you, and a tame teleported onto you doesn't push you around. Tames still collide with enemies, walls and each other, and you can still hit, pet, feed and ride them. You can choose All tames (default), only the ones Following you, or Off. With big tames like the lox you may end up briefly inside the model: that's only visual.

Multiplayer hand-over (experimental). In multiplayer, a creature is run by one player's game at a time, often not the player it follows (see Multiplayer below). TameLeash hands every following tame over to the game of the player it follows. Your tames then use your settings, Assist works for them, and they react without network lag. Ridden tames are never handed over.

About the experimental features. Assist and Multiplayer hand-over are new and have had little testing so far, especially in multiplayer. They are on by default and each one can be turned off in the config. If something looks wrong, turn the feature off and please report it, with BepInEx/LogOutput.log and Debug Log on if possible.

Recommended companion: BetterTames

TameLeash works on its own, but it pairs well with BetterTames (optional, not a dependency):

  • With its protection, tames go down instead of dying. TameLeash's nameplates show [zZz] on a downed tame, so you see at a glance who is down.
  • Its catch-up teleport brings back tames that fell behind. If it drops them at your feet, you can walk through them, and TameLeash's Keep Away walks them back out.
  • In multiplayer, its teleport also moves tames to the followed player's game, the same thing TameLeash's hand-over does.

Configuration

The config is created on first launch at BepInEx/config/dupo.TameLeash.cfg.

Setting Default Description
Follow / Follow Distance 9 Out of combat, a following tame stops this far (m) from you. Vanilla is 3. Range 2–30. Applies immediately, no restart needed.
Follow / Keep Away true Out of combat, a tame that stays too close to you walks away until it is 1 m inside the follow distance. Only works if Follow Distance − 1 is greater than Keep Away Distance.
Follow / Keep Away Distance 4 Closer than this (m) counts as too close. Must be less than Follow Distance − 1, or Keep Away is off. Range 1–20.
Follow / Keep Away Delay 3 Seconds a tame must stay too close before it walks away. Range 0–30.
General / Enabled true Turns the guard radius on or off. The Follow settings are not affected by this setting.
General / Guard Radius 20 A following tame only picks enemies within this distance (m) of you. Range 10–50.
General / Release Radius 28 A tame drops its target once the target is farther than this (m) from you. Range 10–60.
Defense / Enabled true Turns the tame damage reduction on or off.
Defense / Base Reduction 0 Damage reduction (%) before Moder is defeated. Range 0–90.
Defense / Max Reduction 50 Damage reduction (%) once Moder, Yagluth, The Queen and Fader are all defeated. Each of them adds a quarter of the gap between Base Reduction and this value. Range 0–90.
Assist / Enabled true Experimental. When you hit an enemy, the tames following you attack it.
Assist / Assist Duration 10 Seconds after your last hit during which tames keep focusing that enemy. Range 2–60.
Nameplates / Always Show true Keeps the nameplates of the tames following you visible.
Nameplates / Show Distance 30 Up to this distance (m) from you. Vanilla is 10. Range 10–60.
Nameplates / Sleeping Label [zZz] Text next to the name of a sleeping (downed) tame. Empty = nothing.
Nameplates / Sleeping Label Color #7FE0FF Color of the label (#RRGGBB). The default light blue stands out from BetterTames' yellow and blue names.
Collision / Pass Through Tames All Players walk through tamed creatures. All = every tame, Following = only tames following that player, Off = vanilla.
Multiplayer / Hand Over To Followed Player true Experimental. Hands each following tame over to the game of the player it follows.
Debug / Debug Log false Every 2 s, logs what each following tame sees and decides. Also logs every hit a tame takes and how much the defense reduced it, assist targets and hand-overs. For troubleshooting only.

Tuning tips

  • Tames ignore ranged enemies that are shooting at you: raise Guard Radius (e.g. 25–30).
  • Tames still wander too far: lower Guard Radius and Release Radius.
  • Tames crowd you when idle: raise Follow Distance. Set it to 3 for vanilla behaviour.
  • A tame walks off before you can mount it: raise Keep Away Delay, or turn Keep Away off.
  • Tames are still too fragile late game: raise Max Reduction; every step scales with it. A pack of several tames is already strong, so raise it a little at a time.

Compatibility

  • FollowDistance (blacks7ar): no longer needed, because TameLeash includes the same feature. If both are installed, TameLeash's Follow Distance wins and a warning is written to the log. You can safely remove FollowDistance.
  • BetterTames: compatible.
    • Options such as Tames Fight Their Own Kind keep working, also for Assist, because TameLeash still uses the game's own enemy check.
    • Its catch-up teleport also moves tames to the followed player's game, the same direction as TameLeash's hand-over.
    • Downed (recovering) tames are asleep: they get the Sleeping Label on their nameplate and are ignored by Assist.
  • Any mod that patches BaseAI.FindEnemy, BaseAI.Follow or MonsterAI.UpdateTarget for tamed creatures, or changes who owns tamed creatures, may conflict.

Multiplayer

Valheim runs a creature's AI on the machine of the player who currently "owns" it: whoever loaded the area first, until that player leaves the area. TameLeash only affects creatures whose AI runs on a machine that has the mod installed. With Hand Over To Followed Player (on by default), following tames move to the game of the player they follow, so each player's tames run with that player's settings.

  • Every player should install the same version.
  • It does not need to be installed on a dedicated server. The server only runs creatures when no player is nearby, so there it has no effect.
  • The config is not synced: each player uses their own values. Tames that are not following anyone (set to stay) still run on whoever owns them, so for Defense it is best to use the same values on every machine.

What happens if a player doesn't have TameLeash. While that player's game runs one of your tames, for example because they reached the area before you:

  • Their game can't hand the tame over to you, so it keeps running it.
  • Until that changes, your tame behaves like vanilla: it chases enemies across the map, stops 3 m from you, ignores Keep Away and Assist, and takes full damage (no Defense).
  • It goes back to normal once that player moves away and the tame comes to your game. With BetterTames, a catch-up teleport also brings it back to your game.

Their own tames behave like vanilla for them, and nameplates only show on screens that have the mod. The same applies to a player with an older version for the features that version lacks. For example, 1.5.0 has no Defense, Assist, hand-over or nameplates.

How it works (for modders)

  • A prefix on BaseAI.FindEnemy applies only to tamed MonsterAI creatures that are following someone. It does the same search as the game (closest enemy that the tame can sense and that is not asleep), but only among enemies within the guard radius of the followed player.
  • A postfix on MonsterAI.UpdateTarget clears the current target once it is beyond the release radius. UpdateAI then falls back to Follow().
  • A prefix on BaseAI.Follow applies only to tamed creatures. It runs the game's own logic, but the stop distance comes from the config. The run threshold is the stop distance + 7 m, which matches vanilla's 3 m stop / 10 m run. Keep Away lives in the same prefix. It walks the tame to a point 1 m inside the follow distance, on the line from you to the tame. If no path is found, it waits for another delay before trying again.
  • Assist: a prefix on Character.Damage (which runs on the attacker's machine) records the enemy the local player hit. The MonsterAI.UpdateTarget postfix then makes it the target of the tames following that player, and marks it as heard so they go straight for it.
  • Nameplates: a postfix on EnemyHud.TestShow widens the show distance for the local player's following tames (read from ZDOVars.s_follow, so it works on non-owner machines too). A prefix on EnemyHud.UpdateHuds keeps their hover timer at 0, and a postfix appends the sleeping label when ZDOVars.s_sleeping is set.
  • Pass through tames: every 0.2 s, Physics.IgnoreCollision is set between each player's capsule collider and the solid colliders of each tamed creature, the same call the game uses between a rider and the mount. Layers are not changed. Pairs that no longer apply are restored. Attacks, interaction and projectiles use raycasts and overlap queries, which are not affected. Each machine simulates its own player's movement, so the local player passes through any tame, whoever runs it.
  • Hand-over: in the same postfix, the machine that owns a following tame gives its ZDO to the followed player's peer with ZDO.SetOwner, which is what the game's own Sadle does for riders. The server only reassigns ZDOs whose owner has left the area, and the followed player is always nearby, so the tame stays there.
  • A prefix on Character.RPC_Damage (which runs on the creature's owner) scales HitData.m_damage for tamed creatures. The number of bosses defeated is read from the global keys defeated_dragon, defeated_goblinking, defeated_queen and defeated_fader.

Credits

The Follow Distance option was inspired by the FollowDistance mod by blacks7ar. Thanks!

Thunderstore development is made possible with ads. Please consider making an exception to your adblock.