Using SetRegionBlocked with a condition didn't work – the computer-controlled hero still passes through the blocked area.
SetRegionBlocked("region name", true, 2)
If the numbering starts from one, I thought that's how it should be. If it starts from zero, then accordingly:
SetRegionBlocked("region name", true, 1)