|
VoltMod
C++23 framework for CS2 server plugins
|
Entity::SetRender writes m_nRenderMode and m_clrRender and dirties both for replication. It works on any model entity: a prop, a weapon, a pawn. The mode is the generated Schema::RenderMode_t, CS2's own numbering: kRenderNormal, kRenderTransAlpha (the color's alpha applies) and kRenderNone.
VoltMod::Color holds the RGBA bytes in the engine's order. Render tricks reach only the pawn body: held weapons, wearables and gloves are separate networked entities that CS2 routes through systems a server plugin cannot touch. For real invisibility use the visibility filter.
VoltMod::Visibility filters ISource2GameEntities::CheckTransmit, so a hidden pawn and the entities that follow it are never sent to other clients.
The hidden player still receives their own entities, and a client actively observing the hidden pawn keeps receiving it so the spectator camera does not break. Sounds are networked separately and are not filtered. State clears when the slot changes hands.
Any entity can also be networked to a single client or a single team, which is what per-viewer effects are built on, or kept from one team:
Entries are keyed by VoltMod::EntityRef, so an entry whose entity is gone drops itself and removing the entity is enough. ScreenManager::ForPlayer is built on the same mechanism.
Available() fails when the CheckTransmitPlayerSlot gamedata offset - the recipient slot inside the partially reversed CCheckTransmitInfo - did not bind. Every call above is then accepted but inert, which for a hide means the player stays visible.
VoltMod::GlowVision builds outlines on the visibility filter: one client, or one team, sees live players as team-colored glows through walls, and no other client or GOTV ever receives the helper entities. Each glowing player costs two prop_dynamic clones per glow, so when a whole team sees the same players, one team glow costs a twelfth of twelve per-viewer ones.
Refresh tracks spawns, deaths and team or model changes, and rebuilds clones the engine destroyed on a round restart. It skips the viewer, dead and spectating players, and pawns hidden by the visibility filter, since a ghosted pawn never transmits and its clone would follow nothing. Destroy clears the filter entries and removes any surviving clones.
Colors and the optional per-slot veto run on top of the built-in checks:
Without the CheckTransmitPlayerSlot offset the clones would be visible to everyone, so do not use glow when the filter is inert.