mirror of
https://github.com/Defent/DMS_Exile.git
synced 2024-08-30 16:52:12 +00:00
Better locality management
This commit is contained in:
parent
7f6178c811
commit
6c9a12cd56
@ -34,6 +34,7 @@ DMS_CreateMarker = compileFinal preprocessFileLineNumbers "\x\addons\dms\sc
|
||||
DMS_FindSuppressor = compileFinal preprocessFileLineNumbers "\x\addons\dms\scripts\FindSuppressor.sqf";
|
||||
DMS_SpawnCrate = compileFinal preprocessFileLineNumbers "\x\addons\dms\scripts\SpawnCrate.sqf";
|
||||
DMS_SetAILocality = compileFinal preprocessFileLineNumbers "\x\addons\dms\scripts\SetAILocality.sqf";
|
||||
DMS_AILocalityManager = compileFinal preprocessFileLineNumbers "\x\addons\dms\scripts\AILocalityManager.sqf";
|
||||
|
||||
//Load config
|
||||
call compileFinal preprocessFileLineNumbers "\x\addons\dms\config.sqf";
|
38
@ExileServer/addons/a3_dms/scripts/AILocalityManager.sqf
Normal file
38
@ExileServer/addons/a3_dms/scripts/AILocalityManager.sqf
Normal file
@ -0,0 +1,38 @@
|
||||
/*
|
||||
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
|
||||
{
|
||||
_owner = objNull;
|
||||
|
||||
{
|
||||
if ((groupOwner _group) isEqualTo (owner _x)) exitWith
|
||||
{
|
||||
_owner = _x;
|
||||
};
|
||||
|
||||
false;
|
||||
} count allPlayers;
|
||||
|
||||
if ((isNull _owner) || {(_owner distance2D _leader)>3500}) then
|
||||
{
|
||||
[_group,_leader] call DMS_SetAILocality;
|
||||
};
|
||||
};
|
||||
};
|
||||
false;
|
||||
} count allGroups;
|
@ -1,28 +1,62 @@
|
||||
/*
|
||||
Makes a random player within 3 KM of the AI the owner.
|
||||
DMS_SetAILocality
|
||||
Created by Defent and eraser1
|
||||
|
||||
Usage:
|
||||
[
|
||||
_groupOrUnit,
|
||||
_posOrObject // Does not have to be defined if element 1 is a unit
|
||||
] call DMS_SetAILocality;
|
||||
|
||||
Makes a random player within 3 KM of the AI unit or group the owner.
|
||||
Offloading AI can increase server performance.
|
||||
Could however have negative effects if target player has a potato PC.
|
||||
|
||||
How To Use:
|
||||
[_pos, _group] call DMS_SetAILocality;
|
||||
Posistion of the player and the group that the AIs are in.
|
||||
|
||||
*/
|
||||
private ["_group","_position","_exit","_randomPlayer"];
|
||||
private ["_AI", "_pos", "_exit", "_client"];
|
||||
|
||||
_group = _this select 0;
|
||||
_position = _this select 1;
|
||||
_exit = false;
|
||||
_AI = param [0,objNull,[objNull,grpNull]];
|
||||
|
||||
while {!_exit} do
|
||||
if (isNull _AI) exitWith
|
||||
{
|
||||
_randomPlayer = call ExileServer_system_session_getRandomPlayer;
|
||||
if((_randomPlayer distance2D _position) < 3000)then
|
||||
{
|
||||
_exit = true;
|
||||
};
|
||||
diag_log format ["DMS ERROR :: Calling DMS_SetAILocality with null parameter; _this: %1",_this];
|
||||
};
|
||||
|
||||
ExileServerOwnershipSwapQueue pushBack [_group,_randomPlayer];
|
||||
if ((typeName _AI)=="OBJECT") then
|
||||
{
|
||||
_pos = _AI;
|
||||
}
|
||||
else
|
||||
{
|
||||
_pos = param [1,"",[objNull,[]],[2,3]];
|
||||
};
|
||||
|
||||
true
|
||||
if (_pos isEqualTo "") exitWith
|
||||
{
|
||||
diag_log format ["DMS ERROR :: Calling DMS_SetAILocality with invalid position; this: %1",_this];
|
||||
};
|
||||
|
||||
_client = objNull;
|
||||
|
||||
{
|
||||
if ((alive _x) && {(_x distance2D _pos)<=3000}) exitWith
|
||||
{
|
||||
_client = _x;
|
||||
};
|
||||
false;
|
||||
} count allPlayers;
|
||||
|
||||
if (!isNull _client) then{
|
||||
ExileServerOwnershipSwapQueue pushBack [_AI,_client];
|
||||
if (DMS_DEBUG) then
|
||||
{
|
||||
diag_log format ["DMS_DEBUG SetAILocality :: Ownership swap of %1 (%4) to %2 (%3) is added to ExileServerOwnershipSwapQueue.",_AI,name _client,getPlayerUID _client,typeName _AI];
|
||||
};
|
||||
}
|
||||
else
|
||||
{
|
||||
if (DMS_DEBUG) then
|
||||
{
|
||||
diag_log format ["DMS_DEBUG SetAILocality :: No viable client found for the ownership of %1!",_AI];
|
||||
};
|
||||
};
|
@ -111,13 +111,6 @@ if(_pos_z == 0) then
|
||||
|
||||
if (DMS_ai_offload_to_client) then
|
||||
{
|
||||
/*
|
||||
_client = (allPlayers call BIS_fnc_selectRandom);
|
||||
ExileServerOwnershipSwapQueue pushBack [_group,_client];
|
||||
*/
|
||||
|
||||
[_group,_pos] call DMS_SetAILocality;
|
||||
|
||||
if(DMS_DEBUG) then
|
||||
{
|
||||
diag_log format["DMS_DEBUG SpawnAIGroup :: Swapping group ownership of %1 to clients.",_group];
|
||||
|
Loading…
Reference in New Issue
Block a user