You can do that with the help of indexed positions, which are special positions in some buildings (enterable). Not all enterable buildings have them.
First you need to know the number of indexed positions in the building. You can use a function I wrote the other day:
buildingPosCountBuildingPosCount gives you the absolute number of indexed positions in a building.
The next step might be to order (
setPos or make them walk there like in this example) some AI soldiers to the positions. You can do it with the
buildingPos function:
_unit move (_building buildingPos _rpos)
This code is from a script which is not complete, so I can't show all to you. But it gives you an example how you can use the
buildingPos function. In the code above, _unit is of course the soldier you want to order to the building, _building is the building
and _rpos is the index number of the position in the building.
You can pick the index number randomly so AI goes to some other position the next time you play your mission. Take a random integer between 0...(n-1) where n is the total number of indexed positions which
buildingPosCount gives to you. And then order your AI to go to that position.
Important: If a building has for example 8 indexed positions, you can use them as 0...7 with the
buildingPos function (because arrays in OFP start from 0, not from 1).
Note: AI has a lot of trouble when they are inside buildings. They might go through walls or go to the basement so that you can't see them anymore and they get stuck there. So it's not perfect but it's what we have.
After you have entered a house and the AI sees you, you can make the AI move to another position outside the house so he runs away from you, if possible. Commands you might need in this situation might be
knowsAbout and
move.