Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Create UAV crew for specific side
// @file Name: fn_createCrewUAV.sqf
// @file Author: AgentRev
params [["_uav",objNull,[objNull]], ["_side",sideUnknown,[sideUnknown]]];
if (!unitIsUAV _uav) exitWith { grpNull };
private _vehCfg = configFile >> "CfgVehicles" >> typeOf _uav;
private _crewCount = {round getNumber (_x >> "dontCreateAI") < 1 &&
((_x == _vehCfg && {round getNumber (_x >> "hasDriver") > 0}) ||
(_x != _vehCfg && {round getNumber (_x >> "hasGunner") > 0}))} count ([_uav, configNull] call BIS_fnc_getTurrets);
private _crewNotReady = {alive _uav && {alive _x && !isPlayer _x} count crew _uav < _crewCount};
private "_time";
while _crewNotReady do // bruteforce that shit up because createVehicleCrew is slow and unreliable
{
createVehicleCrew _uav;
_time = time;
waitUntil {!(time - _time < 1 && _crewNotReady)};
};
if (!alive _uav) exitWith { grpNull };
private _grp = group _uav;
if (_side != sideUnknown && side _uav != _side) then
{
_grp = createGroup _side;
(crew _uav) joinSilent _grp;
};
// <optional>
//if (_uav isKindOf "StaticWeapon") then { _uav setAutonomous false } else { _grp setCombatMode "BLUE" }; // hold fire
(crew _uav) doWatch objNull; // stop aiming turret at owner
_uav addRating 1e11; // forgive friendly fire
// </optional>
_grp
@SlammanDan

This comment has been minimized.

Copy link

@SlammanDan SlammanDan commented Oct 18, 2020

HeyAgentRev, Im trying to get something like this to work for me. I have a supply drop script where players can call for vehicles including drones. Of course they come with no crew so i was trying to implement your script, with no success at all. Wondering if you had any suggestions.
This is what I have, it is a script by Sceptre:
` call CBA_fnc_addEventHandler;
logi_shit = [];
private _factions = configFile >> "CfgFactionClasses";
{
private _className = configName _x;
if (_className != "" && {getNumber (_x >> "scope") >= 2 && {getNumber (_x >> "side") isEqualTo 1}}) then
{
if (toLower (getText (_x >> "vehicleClass")) in ["car","armored","ship","autonomous","support"]) then
{
logi_shit pushBack [getText (_x >> "displayName") + " - " + getText (_factions >> getText (_x >> "faction") >> "displayName"),_className];
};
};
} forEach configProperties [configFile >> "CfgVehicles","isClass _x",true];

logi_shit sort true;
logi_shit = logi_shit apply {[_x # 1,_x # 0]};`

@AgentRev

This comment has been minimized.

Copy link
Owner Author

@AgentRev AgentRev commented Oct 19, 2020

Your script doesn't do anything other than building an array of strings... This is definitely not the location where you are supposed to use my code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment