Blitzen88 16 Posted July 14, 2022 Having some issues getting this check to work. I want to delete vehicles and crew members if a vehicle’s weapon/turrent is damaged and cant fire. The canFire command seems to do a good job of checking if a unit’s weapon/turrent can fire but I cant use that command by itself because it would delete unarmed vehicles. Im also trying to avoid a scenario where a unit gets deleted because it might have a weapon/turrent that is incapable of firing (i.e. it’s a just a turrent with a scope). This is the framework I’ve got: If ( ( cantfire ) && ( has weapon turrent) ) then { Deletevehicle} Any input would be awesome Share this post Link to post Share on other sites
Ibragim A 148 Posted July 14, 2022 Maybe you should try a combination of (does vehicle have some magazines) AND (can vehicle fire)? Like: if (magazines [_vehicle, true] isNotEqualTo [] && !(canFire _vehicle)) then { deleteVehicle _vehicle; }; 1 Share this post Link to post Share on other sites
Blitzen88 16 Posted July 14, 2022 26 minutes ago, Ibragim A said: Maybe you should try a combination of (does vehicle have some magazines) AND (can vehicle fire)? Like: if (magazines [_vehicle, true] isNotEqualTo [] && !(canFire _vehicle)) then { deleteVehicle _vehicle; }; It will need to be some combination of the two. I will try that but I think laser designator weapons, which require batteries…I think, as magazines might mess it up..? Share this post Link to post Share on other sites
sarogahtyp 1105 Posted July 14, 2022 46 minutes ago, Blitzen88 said: laser designator weapons, which require batteries…I think, as magazines might mess it up..? You could just test what is returned for a laser and then remove that classname from the array before u check if the array is empty. Share this post Link to post Share on other sites
Blitzen88 16 Posted July 14, 2022 10 minutes ago, sarogahtyp said: You could just test what is returned for a laser and then remove that classname from the array before u check if the array is empty. How can I “test what is returned for x”? Seems like a really cool thing to know. Share this post Link to post Share on other sites
pierremgi 4739 Posted July 15, 2022 canFire : not destroyed turret + at least one crew (driver!) someAmmo: needs some ammo for one of the vehicle's turrets. Apply on vehicle Share this post Link to post Share on other sites
Blitzen88 16 Posted July 15, 2022 5 hours ago, pierremgi said: canFire : not destroyed turret + at least one crew (driver!) someAmmo: needs some ammo for one of the vehicle's turrets. Apply on vehicle Reading up on canFire, I dont think I can accomplish what I want. Per the notes, It seems canFire will return true as long as the weapon can fire - even if it is completely damaged and can’t rotate. Share this post Link to post Share on other sites
Harzach 2507 Posted July 15, 2022 19 minutes ago, Blitzen88 said: I dont think I can accomplish what I want You need to check for the conditions @pierremgi included in his post - turret destruction, available crew, available ammo. There is no single command that will give you what you want. Share this post Link to post Share on other sites
Blitzen88 16 Posted July 15, 2022 This is what I came up with Quote //Define Variables _Time = _this select 0; //Check to see if the Loadout Init file has run - Need unit class designations to clear AI vehicle crew groups If (isNil "LoadOutInitLoaded") then { _LoadoutInitCheck = [] execVM "Scripts\Loadouts\Loadout_Init.sqf"; WaitUntil { scriptDone _LoadoutInitCheck }; }; _Warning = False; // Set this to False so warning text will not be displayed on first loop/Init //Create a list of vehicles that are empty at the start of the mission - Script will not delete those vehicles _EmptyStartingVehicles = Vehicles select { ( (count crew _x) == 0 ) }; //Start the Loop While {True} do { If (_Warning) then { Systemchat "Empty & Disabled Vehicles will be Deleted in Thirty Seconds"; Sleep 30; }; //Vehicle Check //Remove empty starting vehicles _AllVehicles = Vehicles - _EmptyStartingVehicles; //Remove static weapons and containers _AllVehicles = _AllVehicles select { !(_x isKindOf "staticWeapon") && (_x isKindOf "AllVehicles") }; _AllVehicles = _AllVehicles select { (!canMove _x) || (!alive driver _x) || ( (count crew _x) == 0) || ( (!isNull gunner _x) && (!alive gunner _x) ) || ( (!isNull gunner _x) && (!canFire _x) ) }; _PlayerGroupVehicles = [Group Player, true] call BIS_fnc_groupVehicles; _AllVehicles = _AllVehicles - _PlayerGroupVehicles; { {deletevehicle _x} foreach crew _x; deletevehicle _x; } foreach _AllVehicles; //Crew Check _AllCrewUnits = Allunits select { (typeOf _x in Loadouts_AllCrew) && (vehicle _x == _x) && !(group _x == group player) }; { deletevehicle _x; } foreach _AllCrewUnits; //Refuel and Rearm Vehicles {_x setfuel 1; _x setVehicleAmmo 1} foreach Vehicles; Systemchat "AI Vehicle & Crew Monitor Loaded"; _Warning = True; // Set this to True so warning text will be displayed sleep _Time; //End Loop }; Share this post Link to post Share on other sites