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

74 lines
1.8 KiB
Plaintext
Raw Normal View History

/*
DMS_fnc_TargetsKilled
Created by eraser1
Usage:
[
_unit,
_group,
_object
] call DMS_fnc_TargetsKilled;
Will accept non-array argument of group, unit, or object.
*/
if ((typeName _this) in ["GROUP","OBJECT"]) then
{
_this = [_this];
};
if (_this isEqualTo []) exitWith
{
diag_log "DMS ERROR :: Calling DMS_TargetsKilled with empty array!";
};
private "_killed";
_killed = false;
try
{
{
if (((typeName _x) == "OBJECT") && {!isNull _x && {alive _x}}) then
{
2015-09-17 03:37:17 +00:00
// It only seems long... but it's only evaluating 3 conditions.
if ((DMS_MaxAIDistance>0) && {((time - (_x getVariable ["DMS_LastAIDistanceCheck",time]))>DMS_AIDistanceCheckFrequency) && {((getPosWorld _x) distance2D (_x getVariable ["DMS_AISpawnPos",getPosWorld _x]))>DMS_MaxAIDistance}}) then
{
_x setDamage 1;
diag_log format ["Killed a runaway unit! |%1| was more than %2m away from its spawn position %3!",_x,DMS_MaxAIDistance,_x getVariable "DMS_AISpawnPos"];
}
else
{
throw _x;
};
}
else
{
2015-09-17 03:37:17 +00:00
if ((typeName _x) != "GROUP") exitWith
{
diag_log format ["DMS ERROR :: %1 is neither OBJECT nor GROUP!",_x];
};
{
2015-09-17 03:37:17 +00:00
if ((DMS_MaxAIDistance>0) && {((time - (_x getVariable ["DMS_LastAIDistanceCheck",time]))>DMS_AIDistanceCheckFrequency) && {((getPosWorld _x) distance2D (_x getVariable ["DMS_AISpawnPos",getPosWorld _x]))>DMS_MaxAIDistance}}) then
{
_x setDamage 1;
diag_log format ["Killed a runaway unit! |%1| was more than %2m away from its spawn position %3!",_x,DMS_MaxAIDistance,_x getVariable "DMS_AISpawnPos"];
}
else
{
throw _x;
};
2015-09-04 16:35:19 +00:00
} forEach (units _x);
};
2015-09-04 16:35:19 +00:00
} forEach _this;
_killed = true;
}
catch
{
if (DMS_DEBUG) then {
diag_log format ["DMS_DEBUG TargetsKilled :: %1 is still alive! All of %2 are not yet killed!",_exception,_this];
};
};
_killed;