I think this needs some better explanation.
I made the enemies work with waypoints. Always when the enemy has reached the waypoint, a new waypoint gets added in the map.
The event would be:
If Enemy stopped moving
->Add waypoint at x=random(640), y=random(480).
Now the problem would be, sometimes the waypoint would be added in the wall. Making the Enemy run in circles trying to go to the waypoint in the wall.
Here's a little animation showing my problem:
<img src="http://i41.tinypic.com/296c2ro.gif">