- C# 100%
| Filename | Latest commit message | Latest commit date |
|---|---|---|
BepInEx plugin fixing Valheim 1.0's ice-slipping layer check, which uses (s_slipperyStuffMask & layer) instead of (s_slipperyStuffMask & (1 << layer)) in Character.UpdateWalking and ApplySlippery. Creatures count as ice, so standing on a moving one compounds its velocity and flings the player off. Includes the Thunderstore manifest, icon and README. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> |
||
| src | ||
| thunderstore | ||
| .gitignore | ||
| DeathsquitoSurfingFix.csproj | ||
| README.md | ||
Deathsquito Surfing Fix
Fixes a Valheim 1.0 bug that makes the game treat creatures as ice. Standing on a moving creature, such as a deathsquito, flings you off at high speed. With this fix, deathsquito surfing works again.
Despite the name, the fix isn't specific to deathsquitos: it applies to standing on any creature.
The bug
Valheim 1.0 added ice slipping. The game decides whether the ground is slippery like this, in Character.UpdateWalking and Character.ApplySlippery:
// what the game does
slipping = friction <= 0 && (s_slipperyStuffMask & layer) != 0;
// what it should do
slipping = friction <= 0 && (s_slipperyStuffMask & (1 << layer)) != 0;
It uses the layer number as if it were a bitmask. The Default layer is bit 0 of the mask, so every frictionless collider on an odd-numbered layer counts as ice. Creatures are on the character layer and use a frictionless physics material, so they count as ice.
While you're on ice, the game keeps your velocity from the previous frame for momentum, then adds the velocity of whatever you're standing on. On normal ground your velocity is rebuilt every frame, so that addition is harmless. On ice it stacks: every physics frame adds the creature's speed again. Slipping also skips the usual 20 m/s speed cap. In testing, a ride on a deathsquito went from matching its speed to 74 m/s in about 0.3 seconds.
What this mod does
It patches both checks to use 1 << layer, nothing else. Ice still works on the layers the game intends (static_solid and Default).
One side effect: the bug also stopped frictionless surfaces on the Default layer from being slippery, even though the game's mask includes that layer. With the fix, they slip as intended.
Installation
Install with r2modman or the Thunderstore Mod Manager, or copy DeathsquitoSurfingFix.dll into BepInEx/plugins.
The mod is client-side. Only players who want the fix need it, and the server doesn't. You can add or remove it at any time.
On startup, BepInEx/LogOutput.log should show:
Fixed slippery layer check in Character.UpdateWalking.
Fixed slippery layer check in Character.ApplySlippery.
If Iron Gate fixes the bug or changes this code, the mod logs a warning and does nothing.
Configuration
BepInEx/config/alari.valheim.deathsquitosurfingfix.cfg:
General.Enabled(defaulttrue): turns the fix on or off. Changes need a game restart.
Compatibility
Tested on Valheim 1.0.20 with BepInExPack_Valheim 5.4.2351. It only changes the two layer checks above, so it should work alongside other mods unless they replace Character.UpdateWalking or Character.ApplySlippery.
Building
Requires Windows, a .NET SDK with .NET Framework 4.7.2 targeting support, a local Valheim install, and a BepInEx profile (for BepInEx.dll and 0Harmony.dll):
dotnet build -c Release '-p:ValheimPath=C:\Program Files (x86)\Steam\steamapps\common\Valheim' '-p:BepInExPath=C:\path o\profile\BepInEx'
The Thunderstore package is the contents of thunderstore/ plus bin/Release/net472/DeathsquitoSurfingFix.dll, zipped with all files at the root.
Changelog
- 1.0.0: First release.