Jump to content
Sign in to follow this  
genesis92x

[AI BUG - VIDEO] Dancing AI

Recommended Posts

Hey everyone! I have ran into a rather interesting bug(?) when utilizing Vanilla AI and boats...

 

Skip to ~3:00 to see the exact bug. I started recording from the beginning of the video to show context.

 

 

 

 

 

 

 

 

 

As you can see, the AI seem to start dancing due to the "SAFE" waypoint. Even when deleting their waypoints, switching them to "AWARE" or "COMBAT" does not seem to resolve the issue. Using a command like {_x setbehaviour "AWARE"} foreach allgroups; did not seem to resolve the issue either. 

 

I will be digging into this a little more...but I was curious if anyone else has ran into this and knew what I was doing wrong?

 

Important bits of code I use that might be interacting oddly below:

 

 

First chunk of the function that detects if boat transport is needed

*SNIP*
	_WpArrayCheck = [];
	
	_Unit = _this select 0;
	_Group = group _Unit;
	_WayPointPosition = _this select 1;
	

	_UnitPos = getpos (leader _Unit);
	
	_direction = [_UnitPos,_WayPointPosition] call BIS_fnc_dirTo;
	
	_MovementDistance = 15;
	
	_LetsCount = true;


	//Lets collect many points along the waypoint route.
	While {_LetsCount && {{alive _x} count (units _Group) > 0}} do
	{
		_NewPosition = [_UnitPos,_MovementDistance,_direction] call BIS_fnc_relPos;	
		if (surfaceIsWater _NewPosition) then {_WpArrayCheck pushback [true,_NewPosition]} else {_WpArrayCheck pushback [false,_NewPosition]};
		_MovementDistance = _MovementDistance + 50;
		if (_NewPosition distance _WaypointPosition < 100) then {_LetsCount = false};
	};
	
	
    //Now lets check to see if at least 2 of those points are in water.
	_WaterCount = 0;
	_WaterArray = [];
	_BoatNeeded = false;
	{
		_WaterCheck = _x select 0;
		_Pos = _x select 1;
		
		if (_WaterCheck) then {_WaterCount = _WaterCount + 1;_WaterArray pushback (_x select 1);};
		if (_WaterCount >= 2) exitWith {_BoatNeeded = true;};
		
	} foreach _WpArrayCheck;

	//If a boat is needed then lets add a waypoint next to the shore
	if (_BoatNeeded) then
	{
		_group setVariable ["DIS_BoatN",true];
		_FirstWaterPos = _WaterArray select 0;
		_MoveToPosition = [_FirstWaterPos, 0, 250, 1, 0, 1, 1] call BIS_fnc_findSafePos;
		//(leader _group) doMove _MoveToPosition;
		_waypoint = _Group addwaypoint[_MoveToPosition,50,1];
		_waypoint setwaypointtype "MOVE";
		_waypoint setWaypointSpeed "NORMAL";
		_waypoint setWaypointBehaviour "SAFE";	
          
          *SNIP*

 

 

To disembark and throw the crew to the closest land location

 {unassignVehicle _x; doGetOut _x;_x setpos _positions;} forEach units (_group);

 

 

Edit:

Of course after posting this I find a solution - which I did not expect:

 

Code for spawning and putting units in EMPTY vehicle

			_veh = "B_Boat_Armed_01_minigun_F" createVehicle [0,0,0];
			_veh spawn dis_UnitStuck;				
			_veh allowdamage false;
			_LeaderPos = getpos (leader _Group);
			_Leaderdir = getdir (leader _Group);
			{
				_x moveInAny _veh;
			} foreach (units _Group);
			_veh setBehaviour "AWARE";


What resolved the issue for me, was to add the line _veh setBehaviour "AWARE"; 

I was unaware, but even though the boat spawns empty the group still takes their Behaviour from the vehicle. Then deleting the vehicle so quickly was probably causing some interesting confusion for the AI.

Share this post


Link to post
Share on other sites
1 hour ago, 1212PDMCDMPPM said:

It is such a funny bug. The best I could find is that it has something to do with the "SAFE" waypoint and being moved to and from vehicles willy nilly via scripting.

Share this post


Link to post
Share on other sites

That could be a good guess: in the second link, the AIs are moved inside the vehicule via script. I can't tell for the first link (not my mission).

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
Sign in to follow this  

×