LegacyShell WikiLegacyShell Wiki
Back to LegacyShell
Home
Wiki
Plugins
Docs
Back to LegacyShell
Home
Wiki
Plugins
Docs
  • Plugins

    • Plugin Docs

      • Default

        • Crackshot
        • Auto Restart Notifications
        • Auto Shop Notifications
        • Block Viewer
        • Burnt Block Sets
        • Christmas Event
        • Classic Skybox
        • DeadInternet
        • Debug F3
        • Discord Playtest
        • dynamicmapblocks
        • FancyGraphics
        • Francium
        • Health Pack Item
        • Item ToolTips
        • LagCompensation
        • LegacyAchievements
        • LegacyAdmin
        • LegacyAnalytics
        • LegacyLightmaps
        • LegacyProfiles
        • LegacyReplay
        • LegacySettings
        • LegacyShellCore
        • LegacyThemes
        • LegacyWeather
        • Map Editor Saving
        • Modern Map Blocks
        • Modern Shell Guns
        • Modern Shell Hats
        • Modern Shell Stamps
        • Minerva
        • ParkourMode
        • Player Count Notifications
        • TimeMachine
        • Vaporwave Map Blocks
        • WhatsAppTheme
        • Wiki Only Mode
        • Zaxonius Custom Guns
        • ZombiesMode
      • Examples

        • Modern Shell Maps
    • List of plugins

Canonical source: plugins_default/lagcompensation/README.md - edit that file, not this page (this page is built live from it, nothing here is a tracked copy).

LagCompensation

Shots are checked against where the target was on the shooter's screen when they fired, not where the server has them now. Someone on 100ms ping hits what they aimed at.

How it works

  • Every tick the room records each player's real position into a ~1s ring (lagcomp.js's History).
  • Each human's ping is worked out from how far apart their one-a-second ping packets arrive (minus the 1000ms the client waits), taking the smallest of the last few so a laggy tab can't inflate it.
  • When a bullet (or rocket) leaves the gun it is stamped with how many ticks to rewind: ping, plus the ticks of their input batch not yet sent.
  • While that projectile is being tested against players, the targets are swapped for their recorded position at that time. The hit point is moved back to where the target really is so damage falloff still works out.

Respawns and teleports are never interpolated across, and a shot can't land on someone's previous life. With no history (just joined), no ping estimate yet, or a bot shooting, the old test is used.

What it doesn't cover

Grenades, rocket splash and contact damage still use current positions. Direct rocket hits are compensated.

Settings

Per room, under gameOptions.plugins.lagcomp:

KeyDefault
enabledtrue
maxRttMs100pings above this count as this
maxRewindMs150hard cap on reach
extraMs0added on top of the ping
rocketsfalsecompensate direct rocket hits
pingSamples5pings the estimate looks at
minSamples4pings measured before anything is rewound

The defaults are tight on purpose: the ping is read from when the client's own packets arrive, so a modified client can fake some of it. The cap is how much that is worth. | teleportDist | 2 | a jump this big in one tick is a teleport | | minRewindTicks | 0.5 | less than this and nothing is rewound |

Testing

node plugins_default/lagcompensation/test.js - headless, no game server needed.


This plugin was vibecoded.

Prev
Item ToolTips
Next
LegacyAchievements