DMS_Exile/@ExileServer/addons/a3_dms/scripts/fn_AILocalityManager.sqf
eraser1 44955afb0c Tweaks + Minor Additions
* NEW CONFIG VALUE: "DMS_ai_offload_Only_DMS_AI"
* You can use "DMS_ai_offload_Only_DMS_AI" to offload only AI spawned by
DMS. This should resolve any issues with other mission systems from DMS.
* Increased "DMS_playerNearRadius" from 75 meters to 100 meters.
* You can now define "absolute" mission conditions. If this mission
condition is met, it immediately counts the mission as completed. Add
"true" after the completion argument to turn it into an "absolute" win
condition.
* Added compatibility with RS_VLS by [Rod
Serling](https://github.com/Rod-Serling).
2015-09-20 00:37:13 -05:00

52 lines
1.4 KiB
Plaintext

/*
DMS_fnc_AILocalityManager
Created by Defent and eraser1
Offloads AI groups to a nearby client in order to improve server performance.
*/
if !(DMS_ai_offload_to_client) exitWith {};
{
if (((count (units _x))>1) && {!((DMS_ai_offload_Only_DMS_AI && {!(_x getVariable ["DMS_SpawnedGroup",false])}) || {(_x getVariable ["DMS_LockLocality",false])})}) then
{
private ["_leader", "_group", "_owner"];
_leader = leader _x;
_group = _x;
if ((!isNull _leader) && {(alive _leader) && {!isPlayer _leader}}) then
{
if (isNull DMS_HC_Object) then
{
if (DMS_DEBUG) then
{
diag_log format ["DMS_DEBUG AILocalityManager :: DMS_HC_Object is null! Finding owner for group: %1",_group];
};
_owner = objNull;
{
if ((groupOwner _group) isEqualTo (owner _x)) exitWith
{
_owner = _x;
};
} forEach allPlayers;
if ((isNull _owner) || {(_owner distance2D _leader)>3500}) then
{
[_group,_leader] call DMS_fnc_SetAILocality;
};
}
else
{
if !((groupOwner _group) isEqualTo (owner DMS_HC_Object)) then
{
_transferSuccess = _group setGroupOwner (owner DMS_HC_Object);
if (DMS_DEBUG) then
{
diag_log format ["DMS_DEBUG AILocalityManager :: Setting ownership of group %1 to HC (%2). Success: %3",_group,DMS_HC_Object,_transferSuccess];
};
};
};
};
};
} forEach allGroups;