ACE3/addons/common/functions/fnc_disableAI.sqf
johnb432 ee0e947611
General - Use ace_common_fnc_isAwake where possible (#10098)
* Use `ace_common_fnc_isAwake` where possible

* Revert bad change
2024-07-02 12:38:14 -07:00

43 lines
1.0 KiB
Plaintext

#include "..\script_component.hpp"
/*
* Author: Glowbal, KoffeinFlummi
* Disables/Enables AI
*
* Arguments:
* 0: Unit <OBJECT>
* 1: Disable AI <BOOL>
*
* Return Value:
* None
*
* Example:
* [bob, true] call ace_common_fnc_disableAI
*
* Public: No
*/
params [["_unit", objNull, [objNull]], ["_disable", true, [false]]];
if (!local _unit) exitWith {};
if !([_unit] call EFUNC(common,isPlayer)) then {
if (_disable) then {
_unit disableAI "MOVE";
_unit disableAI "TARGET";
_unit disableAI "AUTOTARGET";
_unit disableAI "FSM";
_unit disableConversation true;
} else {
//Sanity check to make sure we don't enable unconsious AI
if (_unit getVariable ["ACE_isUnconscious", false] && alive _unit) exitWith {
ERROR("Enabling AI for unconsious unit");
};
_unit enableAI "MOVE";
_unit enableAI "TARGET";
_unit enableAI "AUTOTARGET";
_unit enableAI "FSM";
_unit disableConversation false;
};
};