AlexRUS 4 Posted April 19, 2023 Hi, guys! I'd like to find simple solution to check if some specific unit in the group is alive or not? For example I have convoy with some vehicles in _convGroup: private _conv_leader = selectRandom ["rhsusf_m113_usarmy", "rhsusf_m113_usarmy_MK19", "rhsusf_m113_usarmy_M240"]; private _conv_rearguard = selectRandom ["rhsusf_M1220_M153_M2_usarmy_wd", "rhsusf_M1220_M153_MK19_usarmy_wd", "rhsusf_M1230_M2_usarmy_wd", "rhsusf_M1237_M2_usarmy_wd", "rhsusf_m1240a1_m2_usarmy_wd", "rhsusf_m1240a1_m2_uik_usarmy_wd","rhsusf_m1240a1_m2_uik_usarmy_wd", "rhsusf_m1240a1_mk19_uik_usarmy_wd", "rhsusf_m1240a1_m240_uik_usarmy_wd"]; private _conv_veh = [_conv_leader,"rhsusf_M977A4_AMMO_BKIT_M2_usarmy_wd", "rhsusf_M142_usarmy_WD", "rhsusf_M978A4_usarmy_wd","rhsusf_M142_usarmy_WD" ,"rhsusf_M1078A1P2_B_WD_CP_fmtv_usarmy", _conv_rearguard]; { _convGroup setBehaviour "SAVE"; _convGroup setFormation "FILE"; _convUnit = [_pos, _dir, _x, _convGroup] call BIS_fnc_spawnVehicle; } forEach _conv_veh; Now, the task to destroy some priority targets in group: two "rhsusf_M142_usarmy_WD" for example. How to check it in setTriggerStatements to complete mission if that units destroyed? This is MP (dedicated) task. Thanks! Share this post Link to post Share on other sites
Ibragim A 163 Posted April 19, 2023 Make the convoy group variable global so that it can be used in the trigger activation code. {typeOf _x == "rhsusf_m113_usarmy" && !alive _x} count units convoyGroup == 0 Share this post Link to post Share on other sites
AlexRUS 4 Posted April 19, 2023 2 hours ago, Ibragim A said: Make the convoy group variable global so that it can be used in the trigger activation code. {typeOf _x == "rhsusf_m113_usarmy" && !alive _x} count units convoyGroup == 0 Sorry, but it doesn't work. I found another solution _trig_destroy_complete setTriggerStatements [ " _vehs = []; _vehstypes = []; {_veh = vehicle _x; _inArray = _veh in _vehs; if (!_inArray && _veh != _x && side _x == west) then { _vehs set [count _vehs, _veh];}; } forEach units convoyGroup; {_vehstypes pushBack typeOf _x} forEach _vehs; !('rhsusf_M142_usarmy_WD' in _vehstypes) && count units convoyGroup > 0; ", _task_destroy_complete,""]; It's ugly like hell, but it works... Share this post Link to post Share on other sites
Ibragim A 163 Posted April 20, 2023 Yes, there was a mistake in my code there: {typeOf _x == "rhsusf_m113_usarmy" && alive _x} count units convoyGroup == 0 Share this post Link to post Share on other sites
pierremgi 4893 Posted April 22, 2023 If I'm right, "rhsusf_M142_usarmy_WD" is a vehicle , not a unit. Vehicles in a group can be found by BIS_fnc_groupVehicles (which is similar as AlexRUS 's code). This will take into account abandoned alive vehicles belonging to the group. but you can simply check: !("rhsusf_M142_usarmy_WD" in (units convoyGroup apply {typeOf assignedVehicle _x})) No need to specify if alive. If you want to do that in a trigger statement, setTriggerStatement is fine. NOTE: disabled vehicles (which can't move) stay assigned in group. If you don't want them just: !("rhsusf_M142_usarmy_WD" in (units convoyGroup apply {typeOf ([objNull,assignedVehicle _x] select (canMove assignedVehicle _x)) })) Same for canFire if that help. 1 Share this post Link to post Share on other sites
AlexRUS 4 Posted April 24, 2023 On 4/22/2023 at 7:34 AM, pierremgi said: !("rhsusf_M142_usarmy_WD" in (units convoyGroup apply {typeOf ([objNull,assignedVehicle _x] select (canMove assignedVehicle _x)) })) thanks, Its better then my, I'll use this one there is it _task_destroy_complete = "['task_destroy','SUCCEEDED'] call BIS_fnc_taskSetState; hint 'M142 destroyed';"; _trig_destroy_complete = createTrigger ["EmptyDetector", [0,0,0]]; _trig_destroy_complete setTriggerStatements [ " !('rhsusf_M142_usarmy_WD' in (units convoyGroup apply {typeOf assignedVehicle _x})) && count units convoyGroup > 0; ", _task_destroy_complete,""]; Share this post Link to post Share on other sites