|
@@ -4,21 +4,39 @@ _args params ["_target"];
|
|
|
systemChat format["Evaluating PFH %1",_handle];
|
|
|
|
|
|
if(isNil "_target") exitWith {
|
|
|
- systemChat format["Removing PFH %1 due to null target",_handle];
|
|
|
+ LOGF_1("Removing PFH %1, Reason: Null Target",_handle);
|
|
|
+ [_handle] call CBA_fnc_removePerFrameHandler;
|
|
|
};
|
|
|
|
|
|
-if(!isServer || ! alive _target) exitWith {
|
|
|
- systemChat format["Removing PFH %1",_handle];
|
|
|
+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));
|
|
|
-systemChat format["%1 :: %2",_target,_aliveUnits];
|
|
|
+LOGF_2("Alive units for spawner %1 :: %2",_target,_aliveUnits);
|
|
|
if(_aliveUnits < _target getVariable QGVAR(maxUnits)) exitWith
|
|
|
{
|
|
|
- _selectedUnit = selectRandom (_target getVariable QGVAR(possibleUnits));
|
|
|
- systemChat format["%1 spawning in %2",_target,_selectedUnit];
|
|
|
+ _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"];
|
|
|
};
|
|
|
-systemChat format["%1 not spawning anything"];
|
|
|
+LOGF_1("%1 not spawning anything",_target);
|