Last time, I had a new reload animation along with some sounds. Since then I’ve implemented jump and landing sounds, so it was time to set up targets for my shooting gallery map. I went to add support for func_guntarget… and decided that it would be easier if I refactored my engine. You know, reasonable thoughts.
The reason was that the engine and game code were very intertwined, which made adding new features/entities a bit painful. I decided that since I was going to be adding new entities specific to my game, it was time to untangle the whole thing. That refactor took quite some time…
… But it was worth it! The Half-Life recreation (nmdist-hl) has its own project, where it depends on the engine (nmdist). This new shooting gallery demo has its own project (shooting-gallery) that depends on the engine as well. Both depend on a crate that contains shared code between the two, goldsrc-entities. There’s still quite a bit of copy-paste between the Half-Life recreation and the shooting gallery, but that will be sorted out in due time.
Another perk of the refactor is that I added a code generation system for entities. Previously I had a macro system for parsing, which worked fine. But I also wanted to generate FGD files so that I could use Trenchbroom as my editor. The new system generates both the parsing code and the FGD file based on a series of .ron files (an engine file, one from goldsrc-entities, and then each game has its own as well).
After finishing the refactoring, I was finally able to return to the task that set me down this rabbit hole: func_guntarget. I added the basics to the game, the ability for it to be activated, and for it to travel along a series of path_track entities, just like a func_tracktrain.
Here it is in Half-Life’s t0a0b2, the shooting gallery in the Hazard Course.
The next steps are to fix the decal system and hook up the health system. Today, decals are stuck in space, even if the surfaces they’re a part of move. Decals need to stick to faces appropriately. Additionally, there isn’t really a health system in the game today. This will be the first thing to be hooked up, which will allow the target to activate a designated entity when killed (as well as stop moving).