#include "function_macros.hpp" params ["_args", "_handle"]; _args params ["_target"]; systemChat format["Evaluating PFH %1",_handle]; if(isNil "_target") exitWith { LOGF_1("Removing PFH %1, Reason: Null Target",_handle); [_handle] call CBA_fnc_removePerFrameHandler; }; if(!isServer) exitWith { LOGF_1("Removing PFH %1, Reason: Not Server",_handle); [_handle] call CBA_fnc_removePerFrameHandler; }; if(!alive _target) exitWith { LOGF_1("Removing PFH %1, Reason: Spawner Dead",_handle); [_handle] call CBA_fnc_removePerFrameHandler; }; _group = _target getVariable QGVAR(group); if(isNil "_group") then { LOGF_1("PFH %1 Group empty, creating new",_handle); _target setVariable [QGVAR(group), createGroup [opfor, true]]; _group = _target getVariable QGVAR(group); }; _aliveUnits = ({alive _x} count (units _group)); LOGF_2("Alive units for spawner %1 :: %2",_target,_aliveUnits); if(_aliveUnits < _target getVariable QGVAR(maxUnits)) exitWith { _possibleUnits = _target getVariable QGVAR(possibleUnits); _selectedUnit = selectRandom _possibleUnits; if(_selectedUnit == _possibleUnits select 0) then { _selectedUnit = selectRandom _possibleUnits; // if its a b2, (first be default atm) random again (requires 2 rolls on b2 to spawn one) }; LOGF_2("%1 spawning in %2",_target,_selectedUnit); _group createUnit [_selectedUnit, position _target, [], 0, "NONE"]; }; LOGF_1("%1 not spawning anything",_target);