Jump to content
target_practice

Return groups using a vehicle?

Recommended Posts

For vehicles that have been assigned to groups (such as with the addVehicle command) is there a way to return a list of the groups to whom a vehicle has been assigned?

I'm trying to get AI groups to use their vehicle after it has been destroyed and respawned, as I have found that the respawned vehicle is no longer assigned to the group that operated it.

Share this post


Link to post
Share on other sites

_grps = crew myVehicle apply {group _x};
_result = _grps arrayIntersect _grps;

Share this post


Link to post
Share on other sites

Apologies for being dense, but I'm not sure what that's supposed to do.

 

Well, I see that the first line gets the group of each crew member and applies it to a local variable (I think?) but I don't get what the second line does.

Share this post


Link to post
Share on other sites

I'm not sure there is a command to retrieve all groups assigned to a vehicle.

@pierremgi's solution does not necessarily return the correct information, as an assigned group (addVehicle) does not have to be part of the crew and instead just flags the vehicle as usable by the group.

About the only way I can think of doing this is to check all members of a group are assigned to the same vehicle. As assigning an individual unit to a vehicle _unit assignAsDriver _veh would return true if queried for its assignedVehicle assignedVehicle _unit == _veh. Yet if you addVehicle all units of the group will return true for said vehicle.

_assignedGroups = allGroups select { { assignedVehicle _x == _theVehicle }count units _x isEqualTo count units _x }

The other way would be to manually store on the vehicle an array of groups when you use addVehicle.

TAG_fnc_addGroupVehicle = {
	params[ "_group", "_vehicle" ];
	
	_assignedGroups = _vehicle getVariable[ "assignedGroups", [] ];
	_group addVehicle _vehicle;
	_vehicle setVariable [ "assignedGroups", _assignedGroups + [ _group ] ];
};

TAG_fnc_getVehicleGroups = {
	params[ "_vehicle" ];
	
	_vehicle getVariable[ "assignedGroups", [] ];
};

 

  • Like 3

Share this post


Link to post
Share on other sites

The existence of the assignedVehicle command certainly makes things easier.

 

I'd prefer to make use of the init field in the scripted vehicle respawn module; given this, I would imagine I could reassign vehicles by first getting all assigned groups and their respective vehicles and then when each vehicle respawns, a script in the init field checks if the leader of each listed group is assigned to the old vehicle and would assign the new vehicle to groups of leaders that return true.

 

I'm not entirely sure how I would script this though. Would simply checking if one unit from a group is assigned to a vehicle be sufficient for instance?

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

×