Skip to content

Instantly share code, notes, and snippets.

@jameslkingsley
Created March 8, 2016 00:41
Show Gist options
  • Save jameslkingsley/cbdbb35a0279e1723f37 to your computer and use it in GitHub Desktop.
Save jameslkingsley/cbdbb35a0279e1723f37 to your computer and use it in GitHub Desktop.
if (!isServer) exitWith {};
[] spawn {
_protected = [];
while {true} do {
{
_unit = _x;
if (!isPlayer _unit && !(_unit in _protected)) then {
_group = group _unit;
_isHandled = _unit getVariable ["ARC_aiHandled", false];
if (!_isHandled) then {
[_unit] joinSilent grpNull;
_unit setUnitPos "UP";
_unit disableAI "SUPPRESSION";
_unit disableAI "AUTOCOMBAT";
_unit setBehaviour "AWARE";
_unit setSpeedMode "FULL";
_unit allowFleeing 0;
{deleteWaypoint _x} forEach (waypoints _group);
};
_unit addPrimaryWeaponItem "rhs_acc_2dpZenit";
_unit enableGunLights "forceOn";
_unit unlinkItem "ItemMap";
_unit setVariable ["ARC_aiHandled", true, true];
_nTargets = _unit nearEntities ["CAManBase", 800];
_closestTarget = objNull;
_closestFloat = 5000;
{
_target = _x;
if (side _target != east && alive _target && !(_target getVariable ["ACE_isUnconscious", false])) then {
_distanceToTarget = _target distance _unit;
if (_distanceToTarget < _closestFloat) then {
_closestTarget = _target;
_closestFloat = _distanceToTarget;
};
};
} forEach _nTargets;
_targetPos = getPos _closestTarget;
if (([_closestTarget] call ace_common_fnc_isInBuilding) && (_unit distance _closestTarget) < 15) then {
{deleteWaypoint _x} forEach (waypoints _group);
_wp = _group addWaypoint [_targetPos, 0];
_wp setWaypointSpeed "FULL";
_wp setWaypointType "SAD";
_wp setWaypointBehaviour "AWARE";
_wp setWaypointCombatMode "GREEN";
} else {
_unit doMove _targetPos;
};
};
} forEach allUnits;
sleep 15;
};
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment