Files
CTI34-KPLIB-Ruha/src/scripts/server/patrols/manage_one_patrol.sqf
MrFastwind 4ff3e5107f fix: prevent group_diag from prematurely marking patrol groups for deletion
Tags patrol groups (KPLIB_patrol_group) so group_diag skips them, and
cleans up the tag + enables deleteGroupWhenEmpty only once the patrol
lifecycle is complete. Prevents the '_grp was nil' log spam by fixing
the root cause rather than just silencin the symptom.
2026-07-03 16:37:05 +02:00

102 lines
3.3 KiB
Plaintext

params [ "_minimum_readiness", "_is_infantry" ];
private [ "_headless_client", "_grp", "_spawn_marker", "_sector_spawn_pos", "_started_time", "_patrol_continue" ];
waitUntil { !isNil "blufor_sectors" };
waitUntil { !isNil "combat_readiness" };
while { GRLIB_endgame == 0 } do {
waitUntil { sleep 0.3; count blufor_sectors >= 3; };
waitUntil { sleep 0.3; combat_readiness >= (_minimum_readiness / GRLIB_difficulty_modifier); };
sleep (random 30);
while { [] call KPLIB_fnc_getOpforCap > GRLIB_patrol_cap } do {
sleep (random 30);
};
_grp = grpNull;
_spawn_marker = "";
while { _spawn_marker == "" } do {
_spawn_marker = [2000,5000,true] call KPLIB_fnc_getOpforSpawnPoint;
if ( _spawn_marker == "" ) then {
sleep (150 + (random 150));
};
};
_sector_spawn_pos = [(((markerpos _spawn_marker) select 0) - 500) + (random 1000),(((markerpos _spawn_marker) select 1) - 500) + (random 1000),0];
if (_is_infantry) then {
_grp = createGroup [GRLIB_side_enemy, true];
_squad = [] call KPLIB_fnc_getSquadComp;
{
[_x, _sector_spawn_pos, _grp, "PRIVATE", 0.5] call KPLIB_fnc_createManagedUnit;
} foreach _squad;
} else {
private [ "_vehicle_object" ];
if ((combat_readiness > 75) && ((random 100) > 85) && !(opfor_choppers isEqualTo [])) then {
_vehicle_object = [_sector_spawn_pos, selectRandom opfor_choppers] call KPLIB_fnc_spawnVehicle;
} else {
_vehicle_object = [_sector_spawn_pos, [] call KPLIB_fnc_getAdaptiveVehicle] call KPLIB_fnc_spawnVehicle;
};
sleep 0.5;
_grp = group ((crew _vehicle_object) select 0);
};
if (!isNull _grp) then {
_grp setVariable ["KPLIB_patrol_group", true, true];
};
[_grp] spawn patrol_ai;
_started_time = time;
_patrol_continue = true;
if ( local _grp ) then {
_headless_client = [] call KPLIB_fnc_getLessLoadedHC;
if ( !isNull _headless_client ) then {
_grp setGroupOwner ( owner _headless_client );
};
};
while { _patrol_continue } do {
if (isNil "_grp") then {
_patrol_continue = false;
["_grp was nil, but patrol was expected", "MANAGE_ONE_PATROL"] call KPLIB_fnc_log;
break;
};
sleep 60;
if ( count (units _grp) == 0 ) then {
_patrol_continue = false;
} else {
if ( time - _started_time > 900 ) then {
if ( [ getpos (leader _grp) , 4000 , GRLIB_side_friendly ] call KPLIB_fnc_getUnitsCount == 0 ) then {
_patrol_continue = false;
{
if ( vehicle _x != _x ) then {
[(vehicle _x)] call KPLIB_fnc_cleanOpforVehicle;
};
deleteVehicle _x;
} foreach (units _grp);
};
};
};
};
if (!isNull _grp) then {
_grp setVariable ["KPLIB_patrol_group", nil, true];
if (local _grp) then {
_grp deleteGroupWhenEmpty true;
} else {
[_grp, true] remoteExecCall ["deleteGroupWhenEmpty", groupOwner _grp];
};
};
if ( !([] call KPLIB_fnc_isBigtownActive) ) then {
sleep (600.0 / GRLIB_difficulty_modifier);
};
};