Make the detector AI compatible

This commit is contained in:
esteldunedain 2016-07-07 12:38:53 -03:00
parent 6160fe076d
commit 2a36fec793
6 changed files with 28 additions and 13 deletions

View File

@ -5,6 +5,6 @@ class Extended_PreInit_EventHandlers {
};
class Extended_PostInit_EventHandlers {
class ADDON {
clientInit = QUOTE( call COMPILE_FILE(XEH_clientInit) );
init = QUOTE( call COMPILE_FILE(XEH_postInit) );
};
};

View File

@ -16,13 +16,8 @@ GVAR(detectableClasses) = call CBA_fnc_createNamespace;
};
} forEach (configProperties [configFile >> "CfgAmmo", "isClass _x", true]);
[QGVAR(detectorEnabled), {
params ["_unit", "_type"];
private _config = [_type] call FUNC(getDetectorConfig);
[FUNC(detectorLoop), 0.05, [_unit, _type, _config, CBA_missionTime - 0.25]] call CBA_fnc_addPerFrameHandler;
}] call CBA_fnc_addEventHandler;
[QGVAR(enableDetector), FUNC(enableDetector)] call CBA_fnc_addEventHandler;
[QGVAR(disableDetector), FUNC(disableDetector)] call CBA_fnc_addEventHandler;
// Shows detector and mine posistions in 3d when debug is on
#ifdef DEBUG_MODE_FULL

View File

@ -17,6 +17,12 @@
params ["_args", "_idPFH"];
_args params ["_unit", "_type", "_detectorConfig", "_lastPlayed"];
// If locality switched just turn off the detector
if !(local _unit) exitWith {
[QGVAR(disableDetector), [_unit, _type], _unit] call CBA_fnc_targetEvent;
[_idPFH] call CBA_fnc_removePerFrameHandler;
};
if !([_unit, _type] call FUNC(hasDetector)) exitWith {
// disable detector type
[_unit, _type] call FUNC(disableDetector);
@ -32,7 +38,10 @@ if !([_unit, _type] call FUNC(isDetectorEnabled)) exitWith {
[_idPFH] call CBA_fnc_removePerFrameHandler;
};
if (ACE_player != _unit || {currentWeapon _unit != _type}) exitWith {};
if (currentWeapon _unit != _type) exitWith {
[_unit, _type] call FUNC(disableDetector);
[_idPFH] call CBA_fnc_removePerFrameHandler;
};
private _detected = [[_unit, _detectorConfig], FUNC(getDetectedObject), _unit, QGVAR(detectedObjects), 0.15] call EFUNC(common,cachedCall);
_detected params ["_hasDetected", "_mine", "_distance"];

View File

@ -19,9 +19,13 @@
params ["_unit", "_detectorType"];
_unit setVariable [format[QGVAR(enable_%1), _detectorType], false];
if !(local _unit) then {
[QGVAR(disableDetector), [_unit, _detectorType], _unit] call CBA_fnc_targetEvent;
};
if (_unit == ACE_player) then {
_unit setVariable [format[QGVAR(enable_%1), _detectorType], false, true];
if (_unit == ACE_player && {alive _unit}) then {
playSound "ACE_Sound_Click";
};

View File

@ -19,10 +19,17 @@
params ["_unit", "_detectorType"];
_unit setVariable [format[QGVAR(enable_%1), _detectorType], true];
if !(local _unit) then {
[QGVAR(enableDetector), [_unit, _detectorType], _unit] call CBA_fnc_targetEvent;
};
_unit setVariable [format[QGVAR(enable_%1), _detectorType], true, true];
if (_unit == ACE_player) then {
playSound "ACE_Sound_Click";
};
[QGVAR(detectorEnabled), [_unit, _detectorType]] call CBA_fnc_localEvent;
private _config = [_detectorType] call FUNC(getDetectorConfig);
[FUNC(detectorLoop), 0.05, [_unit, _detectorType, _config, CBA_missionTime - 0.25]] call CBA_fnc_addPerFrameHandler;

View File

@ -26,7 +26,7 @@ if (!alive _unit) exitWith {
ACE_LOGERROR_1("unit is not alive [%1]",_unit);
};
if (_unit getVariable [QGVAR(isUsingHeadphones), false]) then {
if (_unit getVariable [QGVAR(isUsingHeadphones), false] && {_unit == ACE_player}) then {
playSound _soundClass;
} else {
private _posASL = AGLtoASL (_unit modelToWorld (_unit selectionPosition "granat"));