Jump to content
Luft08

Trailing escort vehicle just sits there

Recommended Posts

I wrote a method that creates a convoy with a leading and trailing escort vehicle but depending on the trailing escort vehicle type it sometimes just sits there.

init.sqf:

if(!isServer) exitWith {};

activeVehicleArray = [];
maxConvoyLeadSpeed = 15;
private _vehicleTypeArray = ["O_Truck_03_device_F", "O_Truck_03_ammo_F", "O_Truck_03_fuel_F", "O_Truck_03_medical_F", "O_Truck_03_covered_F"];
private _startEscortType = "O_MRAP_02_hmg_F";


//private _endEscortType = "O_MRAP_02_F"; // <<<<<<< This works okay.
private _endEscortType = "O_MRAP_02_hmg_F"; // <<<<<<< End vehicle just sits there.
private _convoyStartPos = [26867.5,24474.3];
private _convoyEndPos = [25798.8,21449.1];
private _convoyVehicleCount = 3;
private _convoyStartDir = 221.218;
private _side = east;
[_startEscortType, _endEscortType, _vehicleTypeArray, _convoyStartPos, _convoyEndPos, _convoyVehicleCount, _convoyStartDir, _side] execVM "launchConvoy.sqf";

launchConvoy.sqf:

if(!isServer) exitWith {};

params["_leadVehicleType", "_endVehicleType", "_vehicleTypeArray", "_convoyStartPos", "_convoyEndPos", "_vehicleCount", "_startDir", "_side"];

// create lead escort vehicle
private _vehArray = [_convoyStartPos, _startDir, _leadVehicleType, _side] call BIS_fnc_spawnVehicle;
activeVehicleArray pushBack _vehArray;

private _veh = _vehArray select 0;
private _crewArray = _vehArray select 1;
private _group = _vehArray select 2;
private _leader = _crewArray select 0;

_group setFormation "COLUMN";

_veh limitSpeed maxConvoyLeadSpeed;

private _wp = _group addWaypoint [_convoyEndPos, 0];
_wp setWaypointBehaviour "SAFE";
_wp setWaypointType "MOVE";

// Create convoy vehicles
for "_x" from 1 to _vehicleCount do {
	sleep 10; // Give time for current vehicle to get out of way before spawning next vehicle.

	private _vehType = selectRandom _vehicleTypeArray;
//	private _vehType = _vehicleTypeArray call BIS_fnc_selectRandom;

	_vehArray = [_convoyStartPos, _startDir, _vehType, _side] call BIS_fnc_spawnVehicle;

	activeVehicleArray pushBack _vehArray;

	_veh = _vehArray select 0;	
	_veh limitSpeed maxConvoyLeadSpeed + 5;

	_crewArray = _vehArray select 1;

	private _vehLeader = _crewArray select 0;
	[_vehLeader] joinSilent _leader;
};

sleep 10;

_vehArray = [_convoyStartPos, _startDir, _endVehicleType, _side] call BIS_fnc_spawnVehicle;
activeVehicleArray pushBack _vehArray;

_veh = _vehArray select 0;
_veh limitSpeed maxConvoyLeadSpeed + 5;
_crewArray = _vehArray select 1;
_vehLeader = _crewArray select 0;
[_vehLeader] joinSilent _leader;

 

Share this post


Link to post
Share on other sites

This may or may not work, but try forcing move on the driver.

At the end of the script:

private _driver = driver _veh;
private _formpos = formationPosition _driver;
_driver commandMove _formpos;
_driver moveTo _formpos;

Also, every time you overwrite a variable, I would add a private to it.

(_veh, _vehArray, _crewArray, _vehLeader,...)

Share this post


Link to post
Share on other sites

Thanks RCA3 but no joy. The vehicle still spawns and just sits there.

 

Adding private to the variables already defined causes my editor to throw an error message (variable already defined in scope).

 

I though that maybe the commander was in a different place in the array based on the vehicle type so I changed my code to use the "effectiveCommander" command but no joy there either.

 

 

If you create a mission on the Altis map and put an observer at [3618.42,13130.4,0] then create the following files you will see that a blufor convoy is created but the end vehicle sits there but if you change the end escort vehicle type it will follow the convoy (It will or won't depending on the vehicle type):

 

init.sqf:

if(!isServer) exitWith {};

[] execVM "launchEastConvoy.sqf";
[] execVM "launchWestConvoy.sqf";

launchEastConvoy.sqf :

if(!isServer) exitWith {};

activeVehicleArray = [];
maxConvoyLeadSpeed = 15;
private _vehicleTypeArray = ["O_Truck_03_device_F", "O_Truck_03_ammo_F", "O_Truck_03_fuel_F", "O_Truck_03_medical_F", "O_Truck_03_covered_F"];
private _startEscortType = "O_MRAP_02_hmg_F";
private _endEscortType = "O_MRAP_02_F"; // <<<<<<< This works okay.
private _convoyStartPos = [26867.5,24474.3];
private _convoyEndPos = [14637.4,16771.7];
private _convoyVehicleCount = 3;
private _convoyStartDir = 221.218;
private _side = east;
[_startEscortType, _endEscortType, _vehicleTypeArray, _convoyStartPos, _convoyEndPos, _convoyVehicleCount, _convoyStartDir, _side] execVM "launchConvoy.sqf";

launchWestConvoy.sqf:

if(!isServer) exitWith {};

activeVehicleArray = [];
maxConvoyLeadSpeed = 15;
private _vehicleTypeArray = ["B_Truck_01_ammo_F", "B_Truck_01_box_F", "B_Truck_01_fuel_F", "B_Truck_01_medical_F", "B_Truck_01_Repair_F", "B_Truck_01_covered_F"];
private _startEscortType = "B_MRAP_01_gmg_F";


// private _endEscortType = "B_LSV_01_armed_F"; 
private _endEscortType = "B_MRAP_01_gmg_F";
private _convoyStartPos = [3626.53,13169.2];
private _convoyEndPos = [14637.4,16771.7];
private _convoyVehicleCount = 3;
private _convoyStartDir = 11.689;
private _side = west;
[_startEscortType, _endEscortType, _vehicleTypeArray, _convoyStartPos, _convoyEndPos, _convoyVehicleCount, _convoyStartDir, _side] execVM "launchConvoy.sqf";

And finally launchConvoy.sqf:

if(!isServer) exitWith {};

params["_leadVehicleType", "_endVehicleType", "_vehicleTypeArray", "_convoyStartPos", "_convoyEndPos", "_vehicleCount", "_startDir", "_side"];

// create lead escort vehicle
private _vehArray = [_convoyStartPos, _startDir, _leadVehicleType, _side] call BIS_fnc_spawnVehicle;
activeVehicleArray pushBack _vehArray;

private _veh = _vehArray select 0;
private _leader = effectiveCommander _veh;
private _group = _vehArray select 2;

_group setFormation "COLUMN";
_veh limitSpeed maxConvoyLeadSpeed;

private _wp = _group addWaypoint [_convoyEndPos, 0];
_wp setWaypointBehaviour "SAFE";
_wp setWaypointType "MOVE";

// Create convoy vehicles
for "_x" from 1 to _vehicleCount do {
	sleep 10; // Give time for current vehicle to get out of way before spawning next vehicle.

	private _vehType = selectRandom _vehicleTypeArray;
//	private _vehType = _vehicleTypeArray call BIS_fnc_selectRandom;

	private _vehArray = [_convoyStartPos, _startDir, _vehType, _side] call BIS_fnc_spawnVehicle;
	activeVehicleArray pushBack _vehArray;

	private _veh = _vehArray select 0;	
	private _vehLeader = effectiveCommander _veh;
	_veh limitSpeed maxConvoyLeadSpeed + 5;
	[_vehLeader] joinSilent _leader;
};

sleep 10;

_vehArray = [_convoyStartPos, _startDir, _endVehicleType, _side] call BIS_fnc_spawnVehicle;
activeVehicleArray pushBack _vehArray;

_veh = _vehArray select 0;
_veh limitSpeed maxConvoyLeadSpeed + 5;
private _vehLeader = effectiveCommander _veh;
[_vehLeader] joinSilent _leader;

 

Share this post


Link to post
Share on other sites

you should decrease your sleep. 10 is far too much! Test 1 sec or even 0.3 sec. There is no reason to collide as the BIS_fnc_spawnVehicle is using createVehicle command with "none" as parameter (not "can_collide").

I suggest you to create your convoy, then addWaypoint.

And you can use bis_fnc_spawnGroup, more direct than your script.

convoys are tricky but not impossible. There are some topics on subject (for example: setConvoySeparation is missing in your script).

 

  • Like 1

Share this post


Link to post
Share on other sites

I'm not at my PC right now so can only give general advice.

Cars with gunner turrets don't drive in convoy unless you specifically give the waypoint to the gunner of that vehicle.

 

  • Like 1

Share this post


Link to post
Share on other sites
9 hours ago, pierremgi said:

you should decrease your sleep. 10 is far too much! Test 1 sec or even 0.3 sec. There is no reason to collide as the BIS_fnc_spawnVehicle is using createVehicle command with "none" as parameter (not "can_collide").

I suggest you to create your convoy, then addWaypoint.

And you can use bis_fnc_spawnGroup, more direct than your script.

convoys are tricky but not impossible. There are some topics on subject (for example: setConvoySeparation is missing in your script).

 

Thanks pierremgi, I'll look at your suggestions. I started with the sleep command set to 5 seconds and vehicles started blowing up if the spawned vehicle didn't start moving right away. Maybe I was doing something wrong. 

 

The reason I spawn one vehicle at a time and start it moving is pure laziness. 🙂 This was the first solution that worked (not counting the trailing escort vehicle). Thanks again for your suggestions. I didn't even know about setConvoySeparation.  (So much to learn...)

Share this post


Link to post
Share on other sites
7 hours ago, Tankbuster said:

I'm not at my PC right now so can only give general advice.

Cars with gunner turrets don't drive in convoy unless you specifically give the waypoint to the gunner of that vehicle.

 

Ah-Hah!! This I did not know! I will try giving the gunner the waypoint. BTW did you really mean the gunner rather than the commander or driver? It will be interesting to see if the trailing vehicle stays in formation.

 

oops... I just remembered that the addwaypoint command takes a group name. Once the vehicle is added to the convoy wouldn't the group be the same as the original waypoint assignment? So I'm not sure how to add a waypoint to the gunner specifically.

Thanks.

Share this post


Link to post
Share on other sites

If vehicles are blowing up, that means there is no room to spawn them as group. the createVehicle (used in bis_fnc_spawnVehicle) can't do miracle.

Spoiler

The reason why I created my own function, checking for convenient room before spawning vehicles, and it's almost instantaneous, so far faster than your sleep/move.

 

Waypoints are always passed to a group. The behavior of drivers and gunners can be different (I always set drivers in careless mode and let gunner in safe one, so the gunner can shift on aware/combat). You need to create a temporary group for drivers... There are some topics on subject. You don't need to "disableAI" anything.

 

 

  • Like 1

Share this post


Link to post
Share on other sites

launchConvoy.sqf (replace last line):

//[_vehLeader] joinSilent _leader;
{[_x] joinSilent _leader}forEach _vehArray # 1;

You were joining the commander (gunner) with the lead group, but you were leaving the driver behind. 😁

  • Thanks 1

Share this post


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

launchConvoy.sqf (replace last line):


//[_vehLeader] joinSilent _leader;
{[_x] joinSilent _leader}forEach _vehArray # 1;

You were joining the commander (gunner) with the lead group, but you were leaving the driver behind. 😁

LOL! That sounds like something I would do! 😁

 

Just tested this and it works!! Thanks!

  • Like 1

Share this post


Link to post
Share on other sites
6 hours ago, Luft08 said:

Ah-Hah!! This I did not know! I will try giving the gunner the waypoint. BTW did you really mean the gunner rather than the commander or driver? It will be interesting to see if the trailing vehicle stays in formation.

 

oops... I just remembered that the addwaypoint command takes a group name. Once the vehicle is added to the convoy wouldn't the group be the same as the original waypoint assignment? So I'm not sure how to add a waypoint to the gunner specifically.

Thanks.

Yes, absolutely. Here's my list of classnames that are commanded by their gunners.

 

	if ((_x isKindOf "APC_Wheeled_02_base_F") or (_x isKindOf "MRAP_02_base_F") or (_x isKindOf "Offroad_01_AT_base_F") or (_x isKindOf "Offroad_02_unarmed_base_F") or (_x isKindOf "Offroad_02_LMG_base_F") or (_x isKindOf "LSV_02_armed_base_F") or (_x isKindOf "LSV_02_AT_base_F") or (_x isKindOf "Offroad_01_armed_base_F")) then

Not sure why there is an unarmed base in there.. also, might need to add the i_mrap too. Just did a few tests and that wouldnt convoy either. Will have another bash in a few days.

 

So what I've done is the drivers are in their own group from the rest of the guys. Originally, I had the gunners in another group, the idea being the drivers would drive through ambushes because they were set to careless and the gunners, in their own group, were set to enage.

But I found these vehicles refused to 'convoy. I fiddled with the effectiveCommander to see who was actually giving the orders to drive to the waypoint and it WAS the vehicle commander, which doesn't make any sense. When I added the gunners to the same group as the drivers, they all began to convoy again.

 

I'm not sure of the general order that you are doing things, but this is how I do it.... (note these are dynamic - the vehicles chosen, their start positiojns and their destination are all chosen in script)

 

Choose a start position - I choose a stretch of road on the outskirts of a town (less likely to get messed up with buyildings etc)

Choose a destination, again, usually a town.

Using the PathCalcuated event handler and the calcuatepath command, get the route the convoy is likely to take

Make a note of the road positions at the start of the returned route.

Spawn an empty vehicle on each of the road positions, turn them so they face the vehicle in front. The front vehicle must face away from the second. (or the destination)

Use FNC spawncrew to fill the vehicle with dudes.

Add the drivers of each vehicle to a drivers group. (the problem vehicles also have their gunner added to this group)

For each vehicle...

 

	_x setConvoySeparation 15;
	_x allowCrewInImmobile true;
	_x setUnloadInCombat [false, false];
	_x addEventHandler ["HandleDamage", {if (isNull (_this # 3)) then { 0; } else { _this # 2; }; }];// prevent any collision damage
	_x forceFollowRoad true;

Add the waypoint , waypointbehaviour is safe and waypointtype is move.

 

That's pretty much it.

 

This isn't very demonstrative, but this was made using my convoy scripts.

 

 

 

  • Like 1

Share this post


Link to post
Share on other sites

* waypoints are for group;

* leader is the unit leading the whole group

* effectiveCommander makes sense for a vehicle, especially for orders on crew. Since 1.96 you can set it (setEffectiveCommander)... But I'm not sure this "crew commander" changes things for full AIs vehicle. This behavior is much more for player(s) enabling orders to driver by keyboard keys. I didn't find too much info on the real need of an effective commander on AI unit.

* driver is the unit driving (🙄) the vehicle.

Spoiler

For MP: And the driven vehicle is always on PC which owns the driver (i.e. for Ais in non-played leader group >> on server)

* if you setWaypointSomething  , this command applies to the whole group (same for equivalent command, i.e. setWaypointBehaviour & setBehaviour applies both on group)

* if you set a group to SAFE, it will start as expected. But the safe units can shift on aware then combat mode, so in case of fight, the convoy reaction will be unpredictable. The setBehaviourStrong doesn't help (few interest here imho).

* if you set a convoy to CARELESS, the behavior will stay CARELESS even if WW3 started on map.

Spoiler

Just for fun, the infantry units continue to throw grenades on enemies, but... it's infantry isn't it?

The problem is the convoy never returns fire...

* So, the solution seems to be drivers safe/careless (the best chance to follow the roads btw) and gunners motivated for combat.

One way to do this is simple:  group driver veh1 setBehaviour "SAFE"; driver veh1 disableAI "AUTOCOMBAT";

This way the driver(s) (here for veh1) will stay as safe when all other crew will shift to aware/combat mode.

The 2nd way is using temporary group (see MulleDK13 note)

 

 

 

  • Thanks 1

Share this post


Link to post
Share on other sites
23 hours ago, pierremgi said:

* effectiveCommander makes sense for a vehicle, especially for orders on crew. Since 1.96 you can set it (setEffectiveCommander)... But I'm not sure this "crew commander" changes things for full AIs vehicle. This behavior is much more for player(s)

 

 

That command wasn't available when I wrote my convoy script and it does fix the gunner-needs-to-have-the-waypoint problem. That's excellent. This means I can give a different behaviour to the gunners and have them blazing away while the drivers just... drive.

So, @Luft08, you can disregard what I said earlier about gunners. If you make sure to set the driver of the vehicle as effectivecommander using the command above, it should work just fine.

  • Like 1

Share this post


Link to post
Share on other sites

74d70fc927.png

4 AI vehicle OPFOR convoy drove from Oumere to Vagalala.

I am testing a suite of helper scripts to try to make AI convoys usable and this was just after they'd driven over the wooden bridge, west of Vagalala.

Share this post


Link to post
Share on other sites

Same convoy route (I'm testing how they handle bridges) but this time, 6 vehicles.

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

×