Home   Help Search Login Register  

Author Topic: SQFhousepatrol script (AI patrolling randomly in buildings) BETA  (Read 2376 times)

0 Members and 1 Guest are viewing this topic.

Offline laggy

  • Members
  • *
  • "Behold a pale horse"
SQFhousepatrol script by Laggy.

This is my first attempt in script submission.  :scratch:
Hope nothing similar is allready out there, in that case.  :-[

0.9 BETA version

In many missions I've missed the tension of enemy AI patrolling randomly in buildings.
Waypoints are static and just placing units in a building usually doesn't do the trick either.
With this easy to use script you just have to place a group close to any building with AI paths.
It is important to know the max number of positions in the building you want to use. This is checked easily in editor with a waypoint.

Script is MP friendly as far as I know, tested on a dedicated server.
Feedback and "adjustment ideas" are allways welcome.

The script can be run from a leaders init line or a trigger.
To set the script parameters is also important.

EXAMPLE:

call { [leader groupname, 180, 0, 266] execVM "SQFhousepatrol.sqf"; };


- leader groupname: The script is designed to be put in leaders init, in which case you can change "leader groupname" to "this".
Or do like in the example above in case of running from a trigger.

- 180: This number is the max number of seconds that runs before the units are ordered to new positions. The time limit is random.
Any time can be set, but the shorter the time, the more unlikely the units will reach their positions before ordered elsewhere.
In smaller buildings with less positions a shorter time period might be wanted.
In my example the range will be 0-180 seconds.

- 0: This is the lowest buildingposnumber you want any unit to move to.
Let's say you want a squad to only patrol a rooftop, then you set the "lowest" position desirable as this parameter.
This number can not be a negative one. 0 is the lowest possible.
In my example the lowest position is the first position in the building.

- 266: The highest buildingposnumber you want any unit to move to.
You might want the units to only patrol the bottom floor.
This number can not exceed the highest buildingposnumber that exists in the building. Nor can it be a negative number.
In my example this maxnumber is set for the "Hotel" building which has 266 positions.


So in my example mission the squad members of the defined group will roam around in the hotel in Arcadia.
They will each be given a position to move to, randomly chosen from ALL (266) positions.
After between 0-180 seconds they will get a new move order.
If they reach their position before the time limit is out they will stay there until the time limit is out.


Known issues:

If the script doesn't seem to work it is because the leader of the group is not close enough to the building.
Try to move the leader closer and it will work. This is probably because the ArmA engine gets confused.
If number of units are too high and the passages too small, the building gets crowded and the AI has problems moving efficiently.

Example mission included. Just as user folder to be easily put in editor.
MovingRandomInBuildingScript.Sara


Thanks to: All active on the OFPEC forum.


Finally:

Use at your own risk. Author will not take responsibility for anything.

Laggy
« Last Edit: 25 Jan 2009, 18:01:24 by laggy »
And I looked and beheld a pale horse and his name that sat on him was Death and Hell followed with him.

Offline Mandoble

  • Former Staff
  • ****
    • Grunt ONE and MandoMissile suite
Nice small script  :good:
Now some suggestions:
1 - Before ordering a unit to move to a position, you might check its current orders status, in some cases you might dont want to interfere with what the unit is already doing with move commands. unitReady command might help you with this too, if already ready, then move, else, finish whatever you are currently doing. Or just to check the current assignedTarget and if none, then proceed with the movel command.


2 - You may modify the script a bit so that it might affect individual units and not only to the whole group. For example, in your mission you might want to have the sniper moving between some positions at the roof of the hotel, your group leader to keep in a safe position somewhere else and then the rest of the group moving to any position inside the hotel, also with different delay times for different units.


3 - Think about someway to cancel the script from outside or even from inside. In some cases you might want to have that group leaving the building and proceeding with their next waypoints. For example, you want a group to move to a building, check it, wait there 5 mins, then move to another building, check it, etc ...

Offline laggy

  • Members
  • *
  • "Behold a pale horse"
Thanks alot for the feedback Mandoble,

I'm a rookie in SQF but I'll try to implement the stuff you suggested.

Laggy
And I looked and beheld a pale horse and his name that sat on him was Death and Hell followed with him.

Offline Mandoble

  • Former Staff
  • ****
    • Grunt ONE and MandoMissile suite
Well, if you have SQF questions, you already know how to use our forums to get answers  ;)

What you have already works pretty well, just try to add more flexibility.

And something inportant, add a header to the script with the corresponding author, version, date and usage explanations and examples. Also dont forget to put there: run it there where the affected units are local, else the script will do nothing.

It would be good if you register also your own tag and use it to name your script and any further resource. I mean, instead of just SQFhousepatrol.sqf, lagg_housepatrol.sqf.