DMS_Exile/@ExileServer/addons/a3_dms/scripts/AILocalityManager.sqf

49 lines
1023 B
Plaintext
Raw Normal View History

2015-09-01 23:23:32 +00:00
/*
DMS_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 {};
{
// Exile already has a group cleanup system, so we'll leave empty groups for it
if ((count (units _x))>1) then
{
private ["_leader", "_group", "_owner"];
_leader = leader _x;
_group = _x;
if ((!isNull _leader) && {(alive _leader) && {!isPlayer _leader}}) then
{
2015-09-02 17:16:22 +00:00
if (isNull DMS_HC_Object) then
2015-09-01 23:23:32 +00:00
{
2015-09-02 17:16:22 +00:00
_owner = objNull;
2015-09-01 23:23:32 +00:00
{
2015-09-02 17:16:22 +00:00
if ((groupOwner _group) isEqualTo (owner _x)) exitWith
{
_owner = _x;
};
2015-09-01 23:23:32 +00:00
2015-09-02 17:16:22 +00:00
false;
} count allPlayers;
2015-09-01 23:23:32 +00:00
2015-09-02 17:16:22 +00:00
if ((isNull _owner) || {(_owner distance2D _leader)>3500}) then
{
[_group,_leader] call DMS_SetAILocality;
};
}
else
2015-09-01 23:23:32 +00:00
{
2015-09-02 17:16:22 +00:00
if (DMS_DEBUG) then
{
2015-09-02 17:18:48 +00:00
diag_log format ["Setting ownership of group %1 to HC (%2)",_group,DMS_HC_Object];
2015-09-02 17:16:22 +00:00
};
_group setGroupOwner (owner DMS_HC_Object);
2015-09-01 23:23:32 +00:00
};
};
};
false;
} count allGroups;