Skip to content

Extension for VS Code for GSC scripts used in Call of Duty games

License

Notifications You must be signed in to change notification settings

eyza-cod2/vscode-cod-gsc

Repository files navigation

CoD GSC extension for VS Code

This extension adds language support for the GSC scripts used in Call of Duty games.

⚠️ This extension is still under development and is not fully finished. Check the list of the available features in List of features.

Supported games

Game Code Modification Status Not working yet
CoD1 IW1 original âś… Supported
CoD2 IW2 original âś… Supported
CoD4 IW3 original âś… Supported
CoD5 T4 original âś… Supported
Plutonium T4 âť”
MW2 IW4 original âť— Tested, errors childthread, call
Alterware IW4x âť”
BO1 T5 original âś… Supported
Plutonium T5 âť”
MW3 IW5 original âť— Tested, errors childthread, call
Plutonium IW5 âť”
Alterware IW5-Mod âť”
BO2 T6 original âť— Tested, errors #insert, #define, param default value, autoexec, const, %xxx::yyy, /@ comments @/
Plutonium T6 âť— Tested, errors order of file references
Ghosts IW6 original âť”
Alterware IW6-Mod âť”
AW S1 original âť— Tested, errors childthread, call
Alterware S1-Mod âť”
BO3 T7 original đźš« Not supported #using, #namespace, function, .gscc, .csc, .cscc
IW IW7 original âť”
Aurora IW7-mod âť”
CoD4:MWR H1 original âť”
Aurora H1-mod âť— Tested, errors param default value, call, childthread
WWII S2 original âť”
BO4 T8 original âť”
MW IW8 original âť”
BOCW T9 original âť”
Vanguard S3 original âť”
MWII IW9 original âť”
MWIII S4 original âť”
BO6 T10 original âť”

Change log

View changes

Features

Syntax highlighting

Syntax highlight



Completion items

Completion items - local functions

Completion

Completion items - included functions via #include

Completion

Completion items - with CoD2 MP functions

Completion

Completion items - variables

Completion

Completion items - variables with recognized variable type

Completion

Completion items - variables from included workspace folders

Completion



Diagnostics

Diagnostics - error messages

Completion

Diagnostics - invalid file for #include

Completion

Diagnostics - possible missing semicolon indication

Completion



Functions

Function - go to definition

Function definition

Function - hover info

Function hover

Function - hover info over CoD2 MP function spawn:

Function hover

Function - hover over path

Function hover

Function - references

Function hover

Function - rename

Function hover



Workspace folders

VSCode multi-root workspace can be used to "join" your mod folders as they get loaded into the game.

The order of how files are being searched is now determined by how the workspace folder appears in explorer tab. The last folder is searched first.

Function hover

It can simulate your .IWD files - their file name determines which files gets loaded first in the game.

For example, this is typical setup:

  • raw
  • mod1
  • mappack

From game perspective, it could represents these files:

  • iw_00.iwd - iw15.iwd (original game files for CoD2)
  • z_mod1.iwd
  • zzz_mappack.iwd

The alphabetical order of .IWD is important to correctly replace original files. The order of the workspace folders must be the same!



Code actions

Code actions - include folder for file references

Function hover

Code actions - ignore missing files

Function hover



GSC Files

Visualization of replaced (unreachable) files.

When GSC file is replaced by another GSC file in multi-root workspace because of the same game path, the code in text editor is shown as semi-transparent (unreachable code)
Example:

Function hover



Other

Status bar

Allows quickly change the targeted game or open settings.

Function hover

Side panel

GSC side panel with "Workspace", "File" and "Other" views. It shows information about workspace setup, parsed GSC files and available commands to run. In future version it will allow to change settings more interactively.

Function hover

List of features

  • GSC file parser
    • Syntax parser
      • Comments (/*...*/, //...)
      • Developer blocks (/# ... #/)
      • Preprocessor (#include, #using_animtree, #animtree)
      • Keywords (return, if, else, for, foreach, while, do-while, switch, continue, break, case, default, thread, wait, waittillframeend, waittill, waittillmatch, endon, notify, breakpoint)
      • Operators (=, +=, -=, *=, /=, %=, |=, &=, ^=, ++, --, +, -, *, /, %, |, &, ^, <<, >>, ==, !=, <, >, <=, >=, &&, ||, !, ~)
      • Strings ("default", &"STRING_LOCALIZED", #"sv_cvar_string")
      • Ternary conditional operators (true ? "yes" : "no")
      • Anim string (%xanim_file_name)
      • Path (eg. maps\mp\gametypes\sd)
    • Detection of explicitly typed types of variables (string, localized string, cvar string, vector, integer, float, structure, array, function, entity, bool, xanim)
  • Completion item provider (auto-suggestion)
    • Variables (local to function, global level and game)
    • Constants
    • Keywords
    • File path
    • Function definitions
  • Diagnostics (errors and warnings)
    • Syntax error
      • Unexpected tokens
      • Missing semicolons
    • Extra semicolons
    • Invalid function parameters
    • Missing files
    • Invalid numbers of function parameters
  • Semantics token provider
    • Proper colorization of tokens
  • Definition and Reference provider
    • Local functions (funcName())
    • External functions (maps\mp\gametypes\file::funcName())
    • Included functions (via #include)
  • Hover provider
    • Function info
    • Path info
  • Code action provider
    • Adding missing files into ignored list
    • Adding undefined functions into ignored list
  • Rename provider
    • Function rename



TODO list

Priority

  • Add custom global include list of GSC function
  • Support for default function parameter value - supported in newer COD games
  • Support for 'chilthread' and 'call' keywords - supported in newer COD games
  • Improve auto-suggestion for files
  • When renaming GSC file, ask for reference update in other GSC files

Non priority

  • Code action - implement unknown function
  • Add .csc files (client side scripts)
  • Parser for .menu files
  • Integrate list of built-in functions for CoD4
  • Improve detection of variable types - now it's detected only by explicitly assigned constant value
  • Show available string constants for notify waittill waittillmatch endon in completion item provider
  • Check for unreachable code
  • Implement "Go to definition" for variables
  • Implement some kind of JSDoc comments to improve function and variable description
  • Implement rename variable functionality
  • Detection of undefined variables

Install

This extension is available through Visual Studio Marketplace.

Support

Please test this extension in vscode on your GSC files and report bugs / suggestions on the github page or on discord KILLTUBE #vscode-cod-gsc

Donate with PayPal

About

Extension for VS Code for GSC scripts used in Call of Duty games

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages