This script will allow you to have a unit patrol a house, randomly.
All you need to do is place a unit close to a building and init the script on it.
The script will then check how many available building positions there are in
the closest building of the unit, and place him randomly at one.
Then he will start patrolling the building.
Every time the unit reaches it's waypoint inside the house it will stay and
wait for a short while, before moving to the next point. The amount of time
the unit waits is random. So you'll never really know how long the unit will
stand still.
It works in Multiplayer as well as Singleplayer.
This script will allow you to have a unit patrol a house, randomly.
All you need to do is place a unit close to a building and init the script on it.
The script will then check how many available building positions there are in
the closest building of the unit, and place him randomly at one.
Then he will start patrolling the building.
Every time the unit reaches it's waypoint inside the house it will stay and
wait for a short while, before moving to the next point. The amount of time
the unit waits is random. So you'll never really know how long the unit will
stand still.
It works in Multiplayer as well as Singleplayer.
HOW TO USE:
Just put this: guard = [this] execVM "HousePatrol.sqf"
in the init field of a unit and put it next to or on a house.
OPTIONAL SETTINGS:
* You may also set the behaviour of the unit by putting the
preferred behaviour in the array.
Like this: guard = [this,"COMBAT"] execVM "HousePatrol.sqf"
You may put any of these five:
* "CARELESS"
* "SAFE"
* "AWARE"
* "COMBAT"
* "STEALTH".
If you don't put anything the default "SAFE" will be set.
* There is also an option to set the maximum amount of time (in seconds)
that the unit will wait before moving to the next waypoint.
To use this option the behaviour option must be set too.
Example: guard = [this,"SAFE",50] execVM "HousePatrol.sqf"
If you don't put anything the default value of 30 will be set
Use 0 as value if you want the guard to patrol continuesly.
VERSION HISTORY:
v1.1:
* Optimized the code for better performance and no error codes.
* Added a workaround for a game bug where some buildings are missing data.
v1.0
* First release for Arma 2
KNOWN ISSUES:
Sometimes ArmA2 has some problems with pathfinding and getting units to
report if they have finished or failed a task. To get around any such
problems the guard will be given a new command if it takes more than 90
seconds to finish the last command. Some houses seem to be more difficult
for the AI to sort out.
Some buildings are not able to be identified, due to a bug in ArmA 2.
A unit placed close to such a house will be put in the nearest identified house.
Some buildings are missing building positions, this is a game bug.
When a unit it place close to a building it can not patrol, it will stay where you put it in the editor and a chat message will tell you about the problem.
If the unit is given a name you will be told which unit that can't patrol the given house.
/// Tophe of Östgöta Ops [OOPS], Sweden
Forums.bohemia.net