Jump to content
Fiddi

Advice needed regarding a dynamic convoy.

Recommended Posts

Hello, I would like some advice on how to make a convoy.

 

So the idea is to have a position for a mission in which I spawn some buildings and some crap, essentially a little outpost.

I then want to create a convoy, say, 10 km away in a random direction on a road, or at least make them find a road and drive on it, preferrably away from my main base, call it HQ.

Said convoy would then make the journey from their spawn point to the spawned outpost, keeping their formation if possible. 

The convoy would be set to captive and not engage enemies in the area until a player (in multiplayer) comes within 1-2 Km, to have them not being blown up by whatever units may be in the area and keep the player in the center of the action.

 

(A cool detail would be that the convoy is accompanied by a helicopter that follows, but that's not essential.) Otherwise the convoy would comprise of:

A truck, like an Ammotruck/Repairtruck to 'simulate' valuable supplies,

an APC, for combat support

and a car, with a machinegun.

That's three, maybe four, vehicles that would ideally keep together on a road driving towards the outpost.

 

So the big question is, how would I generally go about doing this?

 

I know about the function findSafePos but I'm not really sure how to utilize it in this particular situation.

 

The random outpost is easy enough, just to put down a predetermined set of buildings and objects, that I can probably figure out myself. But the hard thing is the convoy itself.

 

Thanks in advance, and hopefully later aswell!

Share this post


Link to post
Share on other sites

Thanks for the answer!

I, preferrably, want to do this without involving other scripts, but I will see what at least the second is doing. How stupid is the AI at low speed? The convoy will be moving with limited speed, and not fast.

So is the VCom essential or just handy if there are many obstacles, I'm a little worried about the performance impact?

 

Also, the first problem remains, how to find a suitable place to spawn the convoy. On a road, 10 km away, in a random direction (not within 5km of players), without them blowing up due to spawning inside each other.

Share this post


Link to post
Share on other sites

vcom ai has not much impact because its just tweaking some fsm scripts.

u should test urself if its essential. just set some waypoints through a town with some turns and test it with one car only.

test it vanilla and with vcom. after that decide urself.

Share this post


Link to post
Share on other sites

Since I play, edit and program Arma 3 I wasn´t able to use AI driving in a mission. It ends in exploding cars, in cars that are stuck in a wall, in cars with damaged tyres etc. etc. Even with VCom Driving  I wan´t able to create a reliable driving AI. So, if it needs to be reliable drive yourself.

  • Like 1

Share this post


Link to post
Share on other sites

I did some testing, made a convoy containing three vehicles in a group, A hunter, A HEMTT and an AMV Marshall.

The went from Camp Rogain to Stratis Airbase, passing through Agia Marina with a single MOVE waypoint in the airbase. They were in Limited speed and Column formation. I tried a couple of times on both Vcom and Vanilla.

 

VANILLA:

   To Agia Marina: 4.00 min, no damage or issues, other than a little but reversing in the middle of the road without obstacles.

   Outside Agia Marina: 1.40 min, didn't use the bridge (drove beside), and got caught on a telephone pole, but quickly returned to the road.

   Airbase, finish: 1.20 min, perfect run. Total of ca. 7 minutes.

 

VCom:

  To Agia Marina: 4.50 min, not much to say about the way there, pretty much the same as vanilla except a bit slower to get out of rogain.

   They got stuck on the bridge in agia marina everytime and never finished the waypoint, also they didn't actually use the bridge, they too drove beside it and got permanently stuck on the pole which the vanilla managed to drive past.

 

Okay, so the convoy part is good, now to just find a good spot to spawn them.

 

I've been wondering about the blacklist parameter in FindSafePos,  how do I use that?

Share this post


Link to post
Share on other sites

Weird, I usually get convoy vehicles crashing into each other on a perfectly straight road.

Most of the time the vehicles in the rear can't keep up with the leader despite being the faster vehicles,

this results in the leader slowing down and the rest of the vehicles bumping into the vehicle in front of them.

 

If there's any intersection on the route that forces the convoy to take a turn nearing anywhere to 90° it's a recipe for disaster.

 

Cheers

Share this post


Link to post
Share on other sites

Here's what I do to make a convoy starting formation.

Using nearroads, get all the roads within a given distance near where you want them to start. Choose a road that has only 1 roadconnectedto (a dead-end). Place a vehicle there. Get a connected Road and place another vehicle there. Setdir them so they face the next one in line. Rinse repeat until you have enough vehicles, but I don't like to have more than 6 or they get all confuzzled.

Share this post


Link to post
Share on other sites

Here's what I do to make a convoy starting formation.

Using nearroads, get all the roads within a given distance near where you want them to start. Choose a road that has only 1 roadconnectedto (a dead-end). Place a vehicle there. Get a connected Road and place another vehicle there. Setdir them so they face the next one in line. Rinse repeat until you have enough vehicles, but I don't like to have more than 6 or they get all confuzzled.

 

Okay, I'm not exactly sure what you mean, I'm with you on the nearRoads part. But connecting roads, how would I filter out a road that has only 1 connecting road?

 

I'm just gonna have 3 vehicles, but I can't figure out how you mean.. :confused_o:

Share this post


Link to post
Share on other sites

roadsConnectedTo

 

this command gives u an array of all connected road segments of one specific road segment which u got with nearRoads.

if u count the returned array and that count is equal to 1 then u have a dead end.

Share this post


Link to post
Share on other sites

So far I have this:

private ["_spawnRoadSegment", "_spawnRoad","_roads"];
_spawnPos = [getPos HQ_dropOff, 5000, 7500, 10, 0, 0.3, 0] call BIS_fnc_findSafePos;

waitUntil {Sleep 1; !isNil "_spawnPos"};

_roadRadius = 50;
_roads = [];
While {count _roads < 5} do {
	Sleep 0.05;
	_roads = _spawnPos nearRoads _roadRadius;
	_roadRadius = _roadRadius + 50;
};


hint format["%1", _roads];

_roadSelectArray = 0;
while {_spawnRoad isEqualTo ObjNull} do {
		_spawnRoadSegment = _roads select _roadSelectArray;
		_connectedRoads = roadsConnectedTo _spawnRoadSegment;
		if(count _connectedRoads isEqualTo 1) exitWith {_spawnRoad = _connectedRoads select 0;};
		_roadSelectArray = _roadSelectArray + 1;
};

_spawnPos = getPos _spawnRoad;

_markerName = "jasf";
_markerStr = createMarker [str(_markerName), _spawnPos];
_markerStr setMarkerShape "ELLIPSE";
str(_markerName) setMarkerBrush "SolidBorder";
str(_markerName) setMarkerColor "ColorOrange";
str(_markerName) setMarkerSize [100, 100];
str(_markerName) setMarkerAlpha 1;

This part works, I think, but not the other:

_roadRadius = 50;
_roads = [];
While {count _roads < 5} do {
	Sleep 0.05;
	_roads = _spawnPos nearRoads _roadRadius;
	_roadRadius = _roadRadius + 50;
};

Share this post


Link to post
Share on other sites

spawnRoad isEqualTo ObjNull

nothing is equal to objNull even not itself. use isNull instead.

Share this post


Link to post
Share on other sites

spawnRoad isEqualTo ObjNull

nothing is equal to objNull even not itself. use isNull instead.

 

Okay, changed that, now I get an undefined variable in _spawnRoad.

Share this post


Link to post
Share on other sites

just define it with objNull

_spawnRoad = objNull

or test with isNil

Share this post


Link to post
Share on other sites

Okay, so now it finds positions but if it doesn't get a dead-end from those roads found earlier it returns with an error Zero divisor when it tries to access an array number that doesn't exist.

I'm having a brain-fart, I can't figure out how to make a foolproof way to find dead-ends.

Share this post


Link to post
Share on other sites

i ve no time today to give further help. if u r not geting help from someone else then i ll look into it tomorrow...

Share this post


Link to post
Share on other sites

i ve no time today to give further help. if u r not geting help from someone else then i ll look into it tomorrow...

 

Well, thanks for all the help, I'll continue and try to figure out and will post updates here. 

Share this post


Link to post
Share on other sites

This works:

While {true} do {
	Sleep 0.1;
	_roads = _spawnPos nearRoads _roadRadius;
	_roadRadius = _roadRadius + 50;

	hint format["%1", _roads];

	for "_i" from 0 to (count _roads -1) do {
		_connectedRoads = roadsConnectedTo (_roads select _i);
		if(count _connectedRoads isEqualTo 1) exitWith {_spawnRoad = _connectedRoads select 0;};
	};
	if (!isNull _spawnRoad) exitWith{};
};

Now to actually spawn the convoy, how do I get the convoy to face in the direction they should, ie. face the roads direction and the waypoints direction, so that they avoid 180o turns? Also to spawn them after one another instead of on the same position. 

  • Like 1

Share this post


Link to post
Share on other sites

Do yourself a favor and don't waste your time on AI-controlled convoys :)

 

There are some workarounds and band-aids, but that road leads only to pain and suffering (pun intended).

Share this post


Link to post
Share on other sites

Do yourself a favor and don't waste your time on AI-controlled convoys :)

 

There are some workarounds and band-aids, but that road leads only to pain and suffering (pun intended).

 

Actually, what I have so far works pretty well.

 

Only 1/20 was unsuccessful, but that convoy spawned blown up for some reason, so not actually because of AI driving. The others while they braked for no reason some times, all arrived at their destination without damage.

Share this post


Link to post
Share on other sites

nice that is encouraging to hear

 

 

 

this vid sums up my past experience with programming vehicle AI behaviors:

 

 

 

If things have improved with driving then thats fantastic

Share this post


Link to post
Share on other sites

In the video, the car was set to full speed. My convoy moves in limited, I'm actually quite surprised on how well they drive. Sometimes they have problems with <90turns and the two behind the leader gets stuck, but after a little while they wriggle out of it and continue on their way, and catches up to the leader which have been snail-driving since they fell behind.

 

If relevant, I'm on dev-branch, the fps is 60-70 and the skill of the units driving is 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

×