2015-01-17 22:38:13 +00:00
|
|
|
// by commy2
|
|
|
|
#include "script_component.hpp"
|
|
|
|
|
2015-06-13 08:41:19 +00:00
|
|
|
// fixes laser when being captured. Needed, because the selectionPosition of the right hand is used
|
2017-02-25 16:16:40 +00:00
|
|
|
[QEGVAR(captives,setHandcuffed), {if (_this select 1) then {(_this select 0) action ["GunLightOff", _this select 0]};}] call CBA_fnc_addEventHandler;
|
2015-04-07 17:38:19 +00:00
|
|
|
|
2015-09-11 14:58:26 +00:00
|
|
|
if (!hasInterface) exitWith {};
|
2015-01-18 02:48:44 +00:00
|
|
|
|
2015-01-17 22:38:13 +00:00
|
|
|
GVAR(nearUnits) = [];
|
2017-02-10 18:47:08 +00:00
|
|
|
GVAR(index) = -1;
|
|
|
|
GVAR(laserClassesCache) = [] call CBA_fnc_createNamespace;
|
|
|
|
GVAR(redLaserUnits) = [];
|
|
|
|
GVAR(greenLaserUnits) = [];
|
2015-01-17 22:38:13 +00:00
|
|
|
|
2021-10-11 20:48:30 +00:00
|
|
|
["CBA_settingsInitialized", {
|
2017-02-25 16:16:40 +00:00
|
|
|
// If not enabled, dont't add draw eventhandler or PFEH (for performance)
|
|
|
|
if (!GVAR(enabled)) exitWith {
|
|
|
|
["CBA_attachmentSwitched", {
|
|
|
|
params ["_unit", "_prevItem", "_newItem", "_currWeaponType"];
|
|
|
|
TRACE_4("CBA_attachmentSwitched eh",_unit,_prevItem,_newItem,_currWeaponType);
|
|
|
|
if ((getNumber (configFile >> "CfgWeapons" >> _newItem >> "ACE_laserpointer")) > 0) then {
|
|
|
|
TRACE_1("removing ACE_laserpointer",getNumber (configFile >> "CfgWeapons" >> _newItem >> "ACE_laserpointer"));
|
|
|
|
[1, "prev"] call CBA_accessory_fnc_switchAttachment;
|
|
|
|
};
|
|
|
|
}] call CBA_fnc_addEventHandler;
|
|
|
|
};
|
2015-06-12 05:58:04 +00:00
|
|
|
|
|
|
|
[{
|
2017-02-10 18:47:08 +00:00
|
|
|
private _oldNearUnits = GVAR(nearUnits);
|
|
|
|
GVAR(nearUnits) = call FUNC(getNearUnits);
|
2016-10-08 10:45:40 +00:00
|
|
|
|
2017-02-10 18:47:08 +00:00
|
|
|
// remove units that moved away
|
2015-06-12 05:58:04 +00:00
|
|
|
{
|
2017-02-10 18:47:08 +00:00
|
|
|
GVAR(redLaserUnits) deleteAt (GVAR(redLaserUnits) find _x);
|
|
|
|
GVAR(greenLaserUnits) deleteAt (GVAR(greenLaserUnits) find _x);
|
|
|
|
} forEach (_oldNearUnits - GVAR(nearUnits));
|
|
|
|
}, 5, []] call CBA_fnc_addPerFrameHandler;
|
|
|
|
|
|
|
|
|
|
|
|
private _fnc_processUnit = {
|
|
|
|
params ["_unit"];
|
|
|
|
|
|
|
|
private _weapon = currentWeapon _unit;
|
2017-05-31 16:31:10 +00:00
|
|
|
if (!(_unit isFlashlightOn _weapon)) exitWith {
|
|
|
|
GVAR(redLaserUnits) deleteAt (GVAR(redLaserUnits) find _unit);
|
|
|
|
GVAR(greenLaserUnits) deleteAt (GVAR(greenLaserUnits) find _unit);
|
|
|
|
};
|
2021-10-11 20:48:30 +00:00
|
|
|
|
2017-02-10 18:47:08 +00:00
|
|
|
private _laser = [(_unit weaponAccessories _weapon) select 1] param [0, ""];
|
2017-05-31 16:31:10 +00:00
|
|
|
if (_laser isEqualTo "") exitWith {
|
|
|
|
GVAR(redLaserUnits) deleteAt (GVAR(redLaserUnits) find _unit);
|
|
|
|
GVAR(greenLaserUnits) deleteAt (GVAR(greenLaserUnits) find _unit);
|
|
|
|
};
|
2017-02-10 18:47:08 +00:00
|
|
|
|
|
|
|
private _laserID = GVAR(laserClassesCache) getVariable _laser;
|
|
|
|
|
|
|
|
if (isNil "_laserID") then {
|
|
|
|
_laserID = getNumber (configFile >> "CfgWeapons" >> _laser >> "ACE_laserpointer");
|
|
|
|
GVAR(laserClassesCache) setVariable [_laser, _laserID];
|
|
|
|
};
|
2017-05-31 16:31:10 +00:00
|
|
|
TRACE_3("",_weapon,_laser,_laserID);
|
2017-02-10 18:47:08 +00:00
|
|
|
|
2017-05-31 16:31:10 +00:00
|
|
|
if (_laserID isEqualTo 1) exitWith {
|
|
|
|
GVAR(redLaserUnits) pushBackUnique _unit;
|
|
|
|
GVAR(greenLaserUnits) deleteAt (GVAR(greenLaserUnits) find _unit);
|
|
|
|
};
|
2015-06-12 05:58:04 +00:00
|
|
|
|
2017-05-31 16:31:10 +00:00
|
|
|
if (_laserID isEqualTo 2) exitWith {
|
|
|
|
GVAR(greenLaserUnits) pushBackUnique _unit;
|
2017-02-10 18:47:08 +00:00
|
|
|
GVAR(redLaserUnits) deleteAt (GVAR(redLaserUnits) find _unit);
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
// custom scheduler
|
|
|
|
[{
|
|
|
|
params ["_fnc_processUnit"];
|
|
|
|
|
|
|
|
ACE_player call _fnc_processUnit;
|
|
|
|
|
|
|
|
GVAR(index) = GVAR(index) + 1;
|
|
|
|
private _unit = GVAR(nearUnits) param [GVAR(index), objNull];
|
|
|
|
|
|
|
|
if (isNull _unit) exitWith {
|
|
|
|
GVAR(index) = -1;
|
|
|
|
};
|
2015-08-16 11:15:01 +00:00
|
|
|
|
2017-02-10 18:47:08 +00:00
|
|
|
_unit call _fnc_processUnit;
|
|
|
|
}, 0.1, _fnc_processUnit] call CBA_fnc_addPerFrameHandler;
|
2015-06-12 05:58:04 +00:00
|
|
|
|
2017-02-14 16:54:37 +00:00
|
|
|
addMissionEventHandler ["Draw3D", {call FUNC(onDraw)}];
|
2016-05-22 15:29:05 +00:00
|
|
|
}] call CBA_fnc_addEventHandler;
|