Skip to content

Instantly share code, notes, and snippets.

@AgentRev
Last active October 19, 2020 01:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AgentRev/cb25d30e464f2239b6cee51fa0110c78 to your computer and use it in GitHub Desktop.
Save AgentRev/cb25d30e464f2239b6cee51fa0110c78 to your computer and use it in GitHub Desktop.
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
Copy link

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
Copy link
Author

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