modiki.civfanatics.com
Or Google search "Civ V Lua Reference"
This website is very helpful. Look under GameEvents, and you will find all the event hooks you need. These are all the objects, methods and events available for you to use.
You need to detect when a building is completed in a city. You will notice the event hooks you need is not present in the game.
DLL - Various Mod Components. Contribute to whoward69/DLL-VMC development by creating an account on GitHub.
github.com
Or Google "DLL - Various Mod Components"
This is a modded dll by whoward69, of civ modding fame. This fills in the many, many gaps left by the games developers. I've been modding this game for about a year, I refer to this mod more than the base game's resources.
If you look in the City.cpp file, and use Ctrl F to search for "GAMEEVENTINVOKE_HOOK", you will find all the added event hooks related to cities. One of them is "CityConstructed". This is the one you need.
Install this mod and configure the custommodoptions file to activate what features you need, then you will be able to detect when a building is built and then spawn any unit you like.
DLL mods do make it more obnoxious for you to do multiplayer with your mods, but it is still possible.
Do you know how to write the Lua code yourself and how to use event hooks?