DMS_Exile/@ExileServer/addons/a3_dms/scripts/fn_SetAILocality.sqf
eraser1 0544cfe9e7 Readme changes, new debug fnc, fixes, tweaks
Created disclaimer for DMS. Now mentioning that HC for DMS isn't that
good.
Some structure stuff in readme (let's see if it works lol)

* **NEW CONFIG VALUE: DMS_Use_Map_Config**
* You can now overwrite "main config values" with map-specific config
values located in the new "map_configs" folder. This should allow you to
use one DMS PBO if you have multiple servers with different maps.
Included examples for Altis, Bornholm, Esseker, and Tavi (Taviana).
* Because of the above implementation, DMS by default will not include
the salt flats blacklist for findSafePos. In addition, it is
preconfigured to the hilly terrains in Esseker and Taviana, as well as
reducing all of the blacklist distances due to the smaller map size in
Esseker.
* Created new function "DMS_fnc_DebugLog". All DMS files (that produced
debug logs) have been changed, including mission files. However,
updating them is not important (and completely pointless if you don't
even use DMS_DEBUG).
* Fixed a few locations where it said "sized" instead of "seized".
Thanks to [icomrade](https://github.com/icomrade) for pointing them out.
* DMS now utilizes the "ARMA_LOG" DLL (if it exists) by infiSTAR to
produce debug logs (if enabled). All debug logs now also include server
uptime (in seconds) and server FPS.
* The FSM no longer produces debug logs.
* AI Locality manager will now run every minute.
* Debug logs for "DMS_fnc_MissionsMonitor" will only output the mission
name and the position, instead of all of the parameters.
* "DMS_fnc_IsNearWater" will now check the provided position itself for
water.
* "DMS_fnc_IsValidPosition" will now do a surfaceNormal check within a 5
meter radius of the provided position as well.
* "_customGearSet" should now actually work for
"DMS_fnc_SpawnAISoldier", and the function title comment has been
updated for the slightly tweaked syntax.
2015-10-09 20:35:07 -05:00

56 lines
1.3 KiB
Plaintext

/*
DMS_fnc_SetAILocality
Created by Defent and eraser1
Usage:
[
_groupOrUnit,
_posOrObject // Does not have to be defined if element 1 is a unit
] call DMS_fnc_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.
*/
private ["_AI", "_pos", "_exit", "_client"];
_AI = param [0,objNull,[objNull,grpNull]];
if (isNull _AI) exitWith
{
diag_log format ["DMS ERROR :: Calling DMS_SetAILocality with null parameter; _this: %1",_this];
};
if ((typeName _AI)=="OBJECT") then
{
_pos = _AI;
}
else
{
_pos = param [1,"",[objNull,[]],[2,3]];
};
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;
};
} forEach allPlayers;
if (!isNull _client) then
{
ExileServerOwnershipSwapQueue pushBack [_AI,_client];
(format ["SetAILocality :: Ownership swap of %1 (%4) to %2 (%3) is added to ExileServerOwnershipSwapQueue.",_AI,name _client,getPlayerUID _client,typeName _AI]) call DMS_fnc_DebugLog;
}
else
{
(format ["SetAILocality :: No viable client found for the ownership of %1!",_AI]) call DMS_fnc_DebugLog;
};