Counter-Strike 2’s Map Scripting Update Adds Hostage, Console And GameRules APIs

0
1
Five Counter-Strike 2 characters standing in a sunlit stone courtyard holding rifles, each marked with a coloured player tag reading CS2, Green, Purple, Blue and Orange, with the CS2 logo in the corner.

Hero image: Counter-Strike 2. Image: Valve

Valve’s latest Counter-Strike 2 update is a changelog for map scripting and nothing else. The post is headed “MAP SCRIPTING” and went up at 22:56 UTC on 22 October, which is 9:56am AEDT on 23 October by our conversion.

The biggest addition is a new top-level export called Console. It brings six convar readers — GetConvarBoolean, Number, String, Vector, QAngle and Color — plus SetConvar, which the post says “is not restricted by sv_cheats and executes synchronously”. Instance.Msg has been renamed Console.Log, and Instance.ClientCommand, ServerCommand and RegisterCheatCommand have moved to Console.

A second new export, GameRules, adds StartWarmup, EndWarmup, GetTeamScore, AddTeamScore and TerminateRound. Seven existing Instance methods move into it: IsWarmupPeriod, IsFreezePeriod, IsTeamIntroPeriod, GetRoundsPlayed, GetRoundRemainingTime, SetRoundRemainingTime and AddTeamMoney. The post says moved and renamed methods “are still available in their original location, deprecated”.

Five armed Counter-Strike 2 operators in tactical gear, including one in an FBI jacket and one in a gas mask, standing together in a stone courtyard with a chicken at the edge of the frame.
Counter-Strike 2. Image: Valve

Hostages get their own class. CSHostage has six methods, from IsBeingPickedUp and IsBeingCarried to GetPickUpStartTime, and CSPlayerPawn gains GetHostage. Six new Instance events cover the whole rescue — OnHostagePickUpStart, OnHostagePickUpAbort, OnHostagePickUp, OnHostageDrop, OnHostageRescue and OnHostageKill.

Instance.Precache is new and returns a CSPrecache object, with IsServerLoading, IsServerLoaded, IsClientLoading, IsClientLoaded, IsLoadedForAll and Release.

The rest is smaller. The post adds two top-level custom_hud_layout classes, HUD_TEAMMENU_VISIBLE and HUD_CHAT_VISIBLE, and says radar_element can now appear on the radar in every game mode, “not just Rush”. GameRules.AddTeamMoney now supports CSTeamMoneyReason.NONE with an amount, and a crash with that combination is fixed.

Four fixes tidy up type mismatches. The CSTeamMoneyReason and CSWeaponAttackType enum values now match point_script.d.ts, and CSRadarPoint.IsVisibleToTeam and CSObservablePoint.IsObservableForTeam return a boolean rather than a number.

Logged warnings now include the JS call stack and details about bad argument values, and they count arguments from 0 instead of 1. The map_workshop command also has improved auto complete.

It follows the 15 October Counter-Strike 2 update that added a demo download progress bar, which we reported in our earlier article. The game is free on Steam, where its store page was first on the most-played chart when we read it on 24 October.

The post carries no version number, so the changes cannot be matched to a build from it.

Source: Valve (Steam) – Counter-Strike 2 Update, Steam – Counter-Strike 2