@tankenabard unfortunately no. The best advice I can give you is to look at others code.
Get a couple of simple mods, the simpler the better, then see what it takes to get a simple mod going.
Then find a mod or map that disables certain units - that will show you how it's done.
Then all you need is to apply and tweak the code to your needs and wants <-- that's the part nobody can help you with 😕
This could be done with a mod & could be done with a check of the player type to determine if the player is human or AI, so there would be no restriction on human players & AIs having the same faction, only humans having access to all the structures & units that the AI has access to.
I would suggest making a mod request thread in the Modding & Tools sub-forum.
@vmkcom We can't reproduce it through the replay - it is therefore likely local to your system. Update your drivers and anything else related to the stability of your system.