Place a wall piece (or any building/unit that can be attacked) for an enemy player on the map somewhere not accessible. Now set the following trigger:
Trigger start on, loop yes.
Condition: Object has target, set object the villager(hero), and set next object the villager again.
Effect: Task object, task the villager to the wall
Effect: Stop unit, select the villager
Effect: Change object name (the villager/hero)
You can also add effects to correct HP and attack if you wish. Now every time the villager is clicked on a tree, or stone etc he will retain the idle villager graphics, his name, and simply stop moving. You could also use change ownership, or task without a location set to stop the unit, its up to you.
If you need the villager to be able to attack, or board a transport etc then you can’t use the above trigger. Instead you have to unhide all the villager types with genied and use a series of “own object” triggers, EG
Trigger start on, loop yes
Condition: own object wood chopper
Effect: Task object, task the villager to the wall
Effect: Stop unit, select the villager
Effect: Change object name (the villager/hero)Trigger start on, loop yes
Condition: own object stone miner
Effect: Task object, task the villager to the wall
Effect: Stop unit, select the villager
Effect: Change object name (the villager/hero)And add further triggers for gold miner, farmer, Shepard etc etc.
An amusing thing you can add to this is a message “Do I look like a lumber jack!” for when he’s a wood chopper, or “I don’t have a pick to be able to mine stone!” for the stone miner and so on.