Arma 3
Boriz May 12, 2016 @ 10:06am
AI Units sometimes refuse to follow waypoints
Hello!
I am having a problem with AI in Arma 3. It's simple, I want to spawn an enemy vehicle with AI in it and then send it on a death mission where it gets almost surely shot down by players' heavy fire. However, oftentimes (at ~25% chance) the unit just sits still after spawn and does nothing at all.

So, this is my code. The important part is marked between ↓↓↓↓↓ and ↑↑↑↑↑:
_group = createGroup east; _type = _usableUnits select floor random count _usableUnits; if (_type isKindOf "Car") then { _unit = objNull; if (_type == "B_G_Offroad_01_armed_F") then{ _unit = [_spawnLocation, random 360, _type, resistance] call bis_fnc_spawnvehicle; }else{ _unit = [_spawnLocation, random 360, _type, EAST] call bis_fnc_spawnvehicle; }; (_unit select 0) setdamage enemySpawnDamage; driver (_unit select 0) spawn scr_killWhenOnFoot; gunner (_unit select 0) spawn scr_killWhenOnFoot; _unit join _group; (_unit select 0) spawn scr_noFuelWhenCarIsStatis; AIunits = AIunits + (_unit select 1); // ↓↓↓↓↓ _wp = _group addWaypoint [posTarget, 0]; [_group, 1] setWaypointType "HOLD"; _group setCombatMode "YELLOW"; _group setBehaviour "CARELESS"; _group allowFleeing 0; driver (_unit select 0) spawn { while {alive _this} do { _startPos = Position _this; sleep 10; _currentPos = Position _this; if ( (_startPos distance _currentPos) < 1 ) then { _this DoMove posTarget; }; }; }; // ↑↑↑↑↑ };

So what does this code do? This is part of a larger script which spawns a vehicle, fills it with AI units and then sends it to position posTarget through a waypoint. The last part is the problem. The unit sometimes refuses to move, even if its path is not obstructed at all. I've tried to fix this by telling the unit to DoMove every 10 seconds if its detected to be still, but it still doesn't fix the problem.

What else can I do about this? Any ideas?
Last edited by Boriz; May 13, 2016 @ 1:04pm
< >
Showing 1-5 of 5 comments
tjl May 27, 2016 @ 12:43am 
I have been looking at a similar issue and hopefully the information below will help.

Luetin 09 has had this problem for well over a year on the occassions he does defence missions. On several recent missions he had units coded by Bacon (EU Ahoy world servers I believe) which behaved much better. A Youtube video of one of the missions is currently available at the following link (https://www.youtube.com/watch?v=A13yjLK0wss) and Luetin's channel is here (https://www.youtube.com/channel/UC8RfCCzWsMgNspTI-GTFenQ ). You can look at the code that is entered in.

Similar issues were also presented on another forum (https://www.reddit.com/r/arma/comments/34qfl8/making_ai_more_agressive/ )

I have recently been playing around in the editor using bits from both these sources. Using the local server execution commands through the ares mod in zeus I type in the following which seems to make the AI a lot more aggressive. They don't necessarily try to rush through everything but it is a lot better than vanilla AI units.

{if (side _x == east) then {_x allowFleeing 0; _x setCombatMode "RED"; {_x setskill ["courage",1]}foreach units _x;};}foreach allgroups;
{if (side _x == east) then { {_x disableAI "AUTOCOMBAT"}foreach units _x;};}foreach allgroups;
{if (side _x == east) then { {_x disableAI "PATH"}foreach units _x;};}foreach allgroups;
{if (side _x == east) then { {_x disableAI "SUPPRESSION"}foreach units _x;};}foreach allgroups;
{if (side _x == east) then { {_x setSpeedMode "FULL"}foreach units _x;};}foreach allgroups;
{if (side _x == east) then { {_x setskill ["aimingAccuracy",1]}foreach units _x;};}foreach allgroups;
{if (side _x == east) then { {_x setskill ["aimingShake",1]}foreach units _x;};}foreach allgroups;
{if (side _x == east) then { {_x setskill ["aimingSpeed",1]}foreach units _x;};}foreach allgroups;
{if (side _x == east) then { {_x setskill ["commanding",1]}foreach units _x;};}foreach allgroups;
{if (side _x == east) then { {_x setskill ["general",1]}foreach units _x;};}foreach allgroups;
{if (side _x == east) then { {_x setskill ["reloadSpeed",1]}foreach units _x;};}foreach allgroups;
{if (side _x == east) then { {_x setskill ["spotDistance",1]}foreach units _x;};}foreach allgroups;
{if (side _x == east) then { {_x setskill ["spotTime",1]}foreach units _x;};}foreach allgroups;

For your situation, it may be best to try typing into the init box something like the following (my syntax is probably not perfect):-

this allowFleeing 0; this setCombatMode "Red"; this setskill["courage",1]; this disableAI "AUTOCOMBAT"; this disableAI "PATH"; this disableAI "SUPPRESSION"; this setSpeedMode "FULL";

I hope this helps. If you get a good code then please let everyone know.
Boriz May 27, 2016 @ 12:58am 
Hey! Thank you very much for the reply! I am at work right now, so I'll try out this new information later when I get home. Then I'll let you know.
MATTXYO May 27, 2016 @ 5:52am 
Try using Move rather than doMove.
MATTXYO May 27, 2016 @ 1:41pm 
@TJL 9987612 would this not be a better way of doing the above, rather than all of the different if conditions use one.

if (side _x == east) then {
_x allowFleeing 0;
_x setCombatMode "RED";
_x setskill ["courage",1];
_x disableAI "AUTOCOMBAT";
_x disableAI "PATH";
_x disableAI "SUPPRESSION";
_x setSpeedMode "FULL";
_x setskill ["aimingAccuracy",1];
_x setskill ["aimingShake",1];
_x setskill ["aimingSpeed",1];
_x setskill ["commanding",1];
_x setskill ["general",1];
_x setskill ["reloadSpeed",1];
_x setskill ["spotDistance",1];
_x setskill ["spotTime",1];
}forEach units allgroups;

Untested!
Last edited by MATTXYO; May 27, 2016 @ 1:59pm
Boriz Jun 8, 2016 @ 1:11pm 
If it helps anyone, this is what I've eneded up using for soldiers. It's not perfect at all, but it's the best I have. If anyone needs some explanation then ask for it.

if (_type isKindOf "Man") then
{
_groupSoldier = (allEastGroups select AllEastGroupsIndex); // Solves issue with overflowing group count
AllEastGroupsIndex = + 1;
if (AllEastGroupsIndex > AllEastGroupsIndexMax) then
{
AllEastGroupsIndex = 0;
};

_unit = _groupSoldier createUnit [_type, _spawnLocation,[],random 3,"NONE"];
_unit setdir random 360;
_unit setskill ["courage", 1];
_unit setskill ["commanding", 1];
_unit disableAI "SUPPRESSION";
_unit disableAI "COVER";
_unit disableAI "FSM";
AIunits = AIunits + [_unit];

_wp = _groupSoldier addWaypoint [posTarget, 0];
[_groupSoldier, 1] setWaypointType "HOLD";
_groupSoldier setCombatMode "RED";
_groupSoldier setBehaviour "COMBAT";
_groupSoldier allowFleeing 0;
_groupSoldier setSpeedMode "FULL";

_unit spawn
{
sleep (random 10);
while {alive _this} do
{
_startPos = Position _this;
sleep 15;
_currentPos = Position _this;
if ( (_startPos distance _currentPos) < 1 ) then
{
_this DoMove posTarget;

if ( (_currentPos distance posTarget) > 30 ) then
{
_this setDamage ((damage _this) + 0.1);
};
};
};
};
};
< >
Showing 1-5 of 5 comments
Per page: 1530 50

Date Posted: May 12, 2016 @ 10:06am
Posts: 5