LogicAndTrick / sledge-formats

C# parsers and formats for Half-Life 1 and related engines.
MIT License
71 stars 10 forks source link

More things to support in Source 2 fgd #16

Closed xPaw closed 1 year ago

xPaw commented 1 year ago

There can be dictionaries in properties: color(color255) { enabled={ variable="colormode" value="0" } } fade_size_start(float) { group="Render" min="0.0" max="1.0" enabled={ variable="directlight" values=["2", "3"] } }

Adding this code after Source 2 metadata for properties: works:

                /* Source 2 metadata for properties:
                color(color255) { enabled={ variable="colormode" value="0" } } : "Color" : "255 255 255"
                luminaire_shape(choices) { group="Luminaire" }: "Area Light" : "0" : "Shape of the area light"
                 */
                if (it.Current?.Is(TokenType.Symbol, Symbols.OpenBrace) == true)
                {
                    var dict = new GameDataDictionary(string.Empty);
                    ParseGameDataDictionary(it, dict);
                }

However ParseGameDataDictionary also needs to be updated to support arrays: values=["2", "3"].

Arrays can also appear in class metadata:

    metadata
    {
        model_archetypes = [ "generic_actor_model" ]
    }

There's also property type that has a slash and ampersand in it which fails to parse: light_style( vdata_choice:scripts/light_styles.vdata ) item_1( vdata_choice:scripts/grenades.vdata&scripts/misc.vdata&scripts/npc_abilities.vdata )

I don't know if you want to add / and & in Tokeniser.TokenName.

There's three new variable types:

        VDataChoice, // Source 2
        SubclassChoice, // Source 2
        NPCAbilityName, // Source 2
        PathNodeClass, // Source 2
        Color255Alpha, // Source 2
        ParticleCfg, // Source 2
        ModelClothVertexMap, // Source 2

Files: https://github.com/SteamDatabase/GameTracking-Dota2/blob/master/game/core/lights2.fgd https://github.com/SteamDatabase/GameTracking-Dota2/blob/master/game/core/ai_defaultnpc.fgd


There's also @VData and @VDataDerived commands here: https://github.com/SteamDatabase/GameTracking-Dota2/blob/master/game/core/vdata_base.fgd


There's @helpinfo command:

@helpinfo( "ai_basenpc", "tools/help/fgd/ai_basenpc.txt" )

LogicAndTrick commented 1 year ago

Thanks for the detailed info, I've added support for those and a few other things I found in the recent DOTA FGD files. I could only see helpinfo in the old DOTA test repo, so it doesn't seem to be used anymore. It will parse the helpinfo command, but the result will be ignored.

xPaw commented 1 year ago

I can confirm it parses Dota 2, Half-Life Alyx, SteamVR, and Destinations fgds now, thanks!

Destinations also defines @helpinfo (steamtours.fgd).

I made a dirty tool to parse iconsprites/editormodels (to draw in maps) and all the properties (entity keys are murmur hashed, so need a backwards lookup) for use in the VRF library: https://github.com/SteamDatabase/ValveResourceFormat/blob/master/Misc/VrfFgdParser/Program.cs