Jump to content
boriz

AI Units sometimes refuse to follow waypoints. Help please!

Recommended Posts

Edit: I've did some editing to the mission and it seems like the issue does not happen as much as it did before, or at least it occurs much less frequently. There is still a problem with helicopters not working at all, but that is being handled by a different script, so I am probably gonna open another thread with focus just on that.

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 destroyed by players' heavy fire. However, oftentimes (at ~25% chance) the unit just sits still after its spawn and does nothing at all.

 

So, this is my (almost) whole 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;
			};
		};
	};
        // ↑↑↑↑↑

};

This code is a 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.

Does anyone else have similar problem? Do you know how to fix this, or work around this issue?

Share this post


Link to post
Share on other sites

Try to disable certain unit behavior using disableAI, this should make them even more dumber and careless.

https://community.bistudio.com/wiki/disableAI

{
_x disableAI "FSM";
_x disableAI "SUPPRESSION";
_x disableAI "COVER";
_x disableAI "AUTOCOMBAT";
} forEach units group _group;
  • Like 1

Share this post


Link to post
Share on other sites

I've noticed that you only need to disable "CHECKVISIBLE" and "AUTOCOMBAT", to get AI to do what you want, regardless of how much they're being shot at.

 

So, this should suffice:

{
	_x disableAI "AUTOCOMBAT";
	_x disableAI "CHECKVISIBLE";
} forEach units group _group;
  • Like 2

Share this post


Link to post
Share on other sites

 

{

    _x disableAI "AUTOCOMBAT";

    _x disableAI "CHECKVISIBLE";

} forEach units group _group;

I wonder if that works on helping helis to land under fire.   I've disabled FSM, setbehaviour CARELESS, using helipads and LANDAT, etc., but still sometimes helis will hover over LZ instead of landing when under fire.  Will give it a try.

Share this post


Link to post
Share on other sites

 

Try to disable certain unit behavior using disableAI, this should make them even more dumber and careless.

https://community.bistudio.com/wiki/disableAI

{
_x disableAI "FSM";
_x disableAI "SUPPRESSION";
_x disableAI "COVER";
_x disableAI "AUTOCOMBAT";
} forEach units group _group;

 

Thank you for the effort! I appreciate it, but unfortunately it solved nothing. Actually, it made the situation even worse because with these lines of code, the enemy units just stop spawning after about 100 cycles of running my script. I have no idea why the game behaves like this. The AI is a complete mess. I've also checked the logs and I haven't found any errors which would explain why this happens.

Also I use vanilla ARMA 3 Stable branch, so this issue is not caused by some mod/addon.

I've been investigating this problem for dozens of hours now and I am going insane from the amount of frustration this causes to me. There is nothing else to do to finish my mission than fixing this issue.

Share this post


Link to post
Share on other sites

sometimes helis will hover over LZ instead of landing when under fire.

 

My friends Ghost's Enemy Assault mission has a spawned AI helicopter transport system where a Blackhawk will fly in under fire - it's door gunners engaging any threats - land and stay landed, blades spinning, till an addAction tells the pilot to RTB or fly to another selected destination.  I'll check the AI settings when I get home since I have no access to ArmA or PBO tools at work any more. :)

 

Well, oddly enough all that's in the script is a _group move _pos command instead of waypoints and _group setBehaviour "CARELESS" for the spawnVehicle'd helo.

  • Like 1

Share this post


Link to post
Share on other sites

Kylania's post encouraged me to experiment with this some more and I've found a possible cause! Thank you very much!

So this is what's happening...
Beside vehicles, I spawn dozens of soldiers. Because I want to have a good control over their behavior, I make each soldier a one man group which means dozens of groups are spawned. After a few minutes of playing, when about 100 units with 100 groups are spawned, the game simply stops creating groups and soldiers (this is something that happened in my previous post, but its cause was not understood yet). Vehicles are still spawned and manned for some reason, but because they belong to no group, they cannot have a waypoint assigned.

Now it seems to me like the problem is caused by the game running out of groups since I create so many of them. So, the question now is, how do I work around this issue?

I could spawn more than 1 unit in a group, which might solve this issue, but then another question is, how many soldiers I can have in one group?

Share this post


Link to post
Share on other sites

There's a limit of 144 groups per Side.  So it definitely founds like you're hitting that limit.  Not sure there's a units per group limit though.

 

You can use BIS_fnc_spawnVehicle to create a crewed vehicle.  The group that this creates it the select 2 from it's return value.

 

Per the example:

_vecarray = [getPos mySpawnPos, 180, "BMP3", EAST] call bis_fnc_spawnvehicle; 
_myvec = _vecarray select 0; // The vehicle object for things like 'is it alive' checks.
_myvecgroup = _vecarray select 2; // The vehicle group for things like waypoints.
  • Like 1

Share this post


Link to post
Share on other sites

 

There's a limit of 144 groups per Side.  So it definitely founds like you're hitting that limit.  Not sure there's a units per group limit though.

 

You can use BIS_fnc_spawnVehicle to create a crewed vehicle.  The group that this creates it the select 2 from it's return value.

 

Per the example:

_vecarray = [getPos mySpawnPos, 180, "BMP3", EAST] call bis_fnc_spawnvehicle; 
_myvec = _vecarray select 0; // The vehicle object for things like 'is it alive' checks.
_myvecgroup = _vecarray select 2; // The vehicle group for things like waypoints.

 

Thank you for the information! It helped me to solve my problem with units not being spawned:

Because I simply must have every solder in his own group, and also be able to spawn hundreds of them, I've worked around this issue by writing a "group manager" system. This script creates 100 empty groups at the start of the game, puts them in an array, and then assigns one group to one soldier each time he is spawned. When index of 100 is reached, it starts all over from 0, which so far works very well for the logic of my mission.

 

Unfortunately, this did nothing to help me with the problem stated in the original post.

Any ideas about how could I debug that issue with vehicles (including helicopters) refusing to go to their waypoint?

Share this post


Link to post
Share on other sites

I wouldn't even bother with waypoints at all.  Just use the doMove to whatever the current location of your target is.

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

×