Skip to content

Replace some gamedata lookups with VScript function bindings - #459

Draft
komashchenko wants to merge 2 commits into
Source2ZE:mainfrom
komashchenko:script_function
Draft

Replace some gamedata lookups with VScript function bindings#459
komashchenko wants to merge 2 commits into
Source2ZE:mainfrom
komashchenko:script_function

Conversation

@komashchenko

Copy link
Copy Markdown
Contributor

Although VScript itself is disabled, its function bindings are still registered and can be accessed through CGameEntitySystem.

This PR replaces several gamedata signatures and offsets with runtime lookups for the following function bindings:

  • SetGravity
  • SetEntityName
  • EmitSoundParams
  • SetTeam (ChangeTeam)
  • IsPlayerPawn
  • IsPlayerController

SetModel could also be resolved this way, but it is currently hooked, so it is intentionally left unchanged. Teleport could potentially be obtained through SetOrigin.

Since the function bindings cannot be resolved before StartupServer is called, the appropriate failure behavior still needs to be determined. For now, lookup failures are reported through Panic, although it may be better to simply use Plat_FatalError instead.

@Vauff

Vauff commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

I would've had concerns about VScript (or even just the CS2 bindings) being cleaned up from the game in the past. But given we're 3 years in to CS2 now, and it's all still there. I don't see any reason why we can't abuse them if they're sticking around, this would've been more stable than relying on signatures/offsets, anyway. Worst case we just revert back to signatures/offsets if Valve does ever go ahead with VScript cleanup.

I would suggest sticking with "VScript" naming to avoid any confusion with cs_script though. I'll do a more thorough review once this is no longer marked as draft.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants