Jump to content
EddiePrice

Defensive AI Patrol

Recommended Posts

Hi,

 

Does anyone know if there's any way to simulate a defensive AI patrol? I'd like to achieve the following:

  • Whenever the patrol stops, everyone takes a knee
  • On contact with the enemy the patrol holds position and draws the enemy in (rather then starting bounds and moving on the enemy)
  • As soon as the area is clear, the patrol continues in its original state 

At the moment I cant seem to interfere with the behaviour when in contact. Setcombatmode doesn't seem to make any difference as the AI seems to overwrite it.

 

Any ideas?

 

Thanks.

 

 

Share this post


Link to post
Share on other sites

Thanks. Was hoping for a less script heavy/more simple solution but I will look into FSMs.

Share this post


Link to post
Share on other sites

By 'patrol stops', you mean its leader stops upon encountering an obstacle in his way or reaching waypoint X and preparing to go for another?

 

By 'lures the enemy in instead of attacking it in straight', you mean a situation, fe., a patrol spots an enemy squad nearby a village, suppresses them while the patrol advances into the village for cover, then ambushes it in case the enemy squad exposes themselves in the village?

 

For situations like these, lots of complex (over-complex) scripting and even more testing / bugfixing is required. Sorry to shatter your dreams, but it's damn near impossible to recreate such complex and "self-aware" routines.

Share this post


Link to post
Share on other sites

The main problem is the AIs reaction to contact. On the BIKI it states that group in combatmode "YELLOW" will keep formation. However, my AI group starts doing bounds soon after contact.

 

I guess all I'm trying to achieve is a patrol that holds its ground when being fired on, rather than advancing, then continues the patrol post contact rather than switching to combat mode for the next 10-15 minutes while searching for enemy.

 

The stops are an added extra I can find other ways to simulate this.

Share this post


Link to post
Share on other sites

Patrol stops don't necesaarily mean anything special happened, a lot of times (in real life), they stop to assess themselves, take a break, check their bearings, observe their area, then move on.

You won't be able to achieve anything your're looking for with what is provided inherently.

Share this post


Link to post
Share on other sites

Patrol stops don't necesaarily mean anything special happened, a lot of times (in real life), they stop to assess themselves, take a break, check their bearings, observe their area, then move on.

You won't be able to achieve anything your're looking for with what is provided inherently.

But there has to be a simulated reason to stop. Of course, depending in the mission's weather conditions, you can sim a squad to stop periodically when most of their members are too tired to go on. Fe, depending on the exposure to sun and the type of terrain (forest, open field, desert, etc.), you can add a different coef to the whole variable and do stuff when it reaches a value of x.

Share this post


Link to post
Share on other sites

But there has to be a simulated reason to stop. Of course, depending in the mission's weather conditions, you can sim a squad to stop periodically when most of their members are too tired to go on. Fe, depending on the exposure to sun and the type of terrain (forest, open field, desert, etc.), you can add a different coef to the whole variable and do stuff when it reaches a value of x.

That's assuming you need to go that in-depth, a simple "random time" between stops could do, with at least "x" time between each stop, but no more than "y" time between stops. And if you wanted them to stop at particular obstacles (like provided defined obstacles that could be IEDs, or similar) then do so, but in the most basic sense, it's relatively simple conceptually.

Share this post


Link to post
Share on other sites

Give your men orders.

Split your squad into 2 teams, team red and team blue. Give orders to teams instead of individual men.

Share this post


Link to post
Share on other sites

That's assuming you need to go that in-depth, a simple "random time" between stops could do, with at least "x" time between each stop, but no more than "y" time between stops. And if you wanted them to stop at particular obstacles (like provided defined obstacles that could be IEDs, or similar) then do so, but in the most basic sense, it's relatively simple conceptually.

I suppose some simplification is very good for a working prototype, yeah :) In case the timeout ceases when a squad is in an open area, they should go to a safer location, rest, proceed further. I assume it's not that hard to achieve once you sit down on the task at hand and take it seriously.

Share this post


Link to post
Share on other sites
/*
    Author: Revo

    Description:
    Orders units in player's group to set up a perimeter defense

    Parameter(s):
    -
    Returns:
    -
*/

if(count units group player == 1) exitWith {};
_units = units group player;
_count = (count _units) - 1;                                 //All units except the player will build a perimeter
_angle = 360/_count;                                         //incremental angle

player groupChat "Quick, set up a perimeter";                //Short group message

for "_i" from 1 to _count do                                 //starts at 1 in order to ignore the player
{
    _distance = [5,15] call BIS_fnc_randomNum;                 //small distance variations for the visual appearance
    _dir = _i * _angle;                                     //direction the unit should watch
    _pos = [player, _distance, _dir] call BIS_fnc_relPos;    //waypoint position
    _posWatch = [player, 50, _dir] call BIS_fnc_relPos;     //workaround, position to make unit watch proper direction
    _units select _i doMove _pos;
    _units select _i doWatch _posWatch;
    _units select _i setUnitPos "MIDDLE";
};

For the stop, maybe you find this usefull. It gives the player the ability to set up a perimeter defense, however, you can easily change it to work with AI groups.

  • Like 1

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×