Skip to content

Instantly share code, notes, and snippets.

@veteran29
Last active August 9, 2020 00:36
Show Gist options
  • Save veteran29/feba2f5408c570734900df0ea67422dd to your computer and use it in GitHub Desktop.
Save veteran29/feba2f5408c570734900df0ea67422dd to your computer and use it in GitHub Desktop.
ACE AI Unconscious Drop weapon
// https://cdn.discordapp.com/attachments/396276036762992640/741802620078915664/Replay_2020-08-09_01-35-35_Trim.mp4
["ace_unconscious", {
params ["_unit", "_unconscious"];
if (!local _unit || {isPlayer _unit}) exitWith {};
if (_unconscious) then {
private _weaponGh = _unit call ACE_hitreactions_fnc_throwWeapon;
_unit setVariable ["my_weaponGh", _weaponGh];
} else {
private _weaponGh = _unit getVariable ["my_weaponGh", objNull];
// exit if no weapon to pick up or too far from it
if (isNull _weaponGh || {_unit distance _weaponGh > 15}) exitWith {};
systemChat "moving";
_unit doMove getPos _weaponGh;
[{
params ["_unit"];
unitReady _unit
}, {
params ["_unit", "_weaponGh"];
systemChat "taking";
// if unit is ready but too far from GH it propably can't reach it
if (_unit distance _weaponGh > 5) exitWith {};
// pickup the weapon
private _weapon = weaponCargo _weaponGh select 0;
_unit action ["TakeWeapon", _weaponGh, _weapon];
}, [_unit, _weaponGh], 60, {
systemChat "timeout";
}] call CBA_fnc_waitUntilAndExecute
};
}] call CBA_fnc_addEventHandler;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment