How to make AI spawn buildings correctly? (I have my own solution but its just bad)

EQS would be good for this