ACE3/addons/scopes/functions/fnc_inventoryCheck.sqf

42 lines
1.2 KiB
Plaintext
Raw Normal View History

/*
2015-08-07 14:43:06 +00:00
* Author: KoffeinFlummi, Commy2
* Check if weapon optics changed and reset zeroing if needed
*
* Arguments:
* 0: Player <OBJECT>
*
* Return Value:
* None
*
2015-08-07 14:43:06 +00:00
* Example:
* [player] call ace_scopes_fnc_inventoryCheck
*
* Public: No
*/
#include "script_component.hpp"
2015-08-07 14:43:06 +00:00
params ["_player"];
2016-07-24 04:08:40 +00:00
private _adjustment = ACE_player getVariable QGVAR(Adjustment);
if (isNil "_adjustment") then {
// [Windage, Elevation, Zero]
2015-08-07 14:43:06 +00:00
_adjustment = [[0, 0, 0], [0, 0, 0], [0, 0, 0]];
ACE_player setVariable [QGVAR(Adjustment), _adjustment];
[ACE_player, QGVAR(Adjustment), _adjustment, 0.5] call EFUNC(common,setVariablePublic);
};
2016-07-24 04:08:40 +00:00
private _newOptics = [_player] call FUNC(getOptics);
{
if (_newOptics select _forEachIndex != _x) then {
// The optic for this weapon changed, set adjustment to zero
2015-11-30 16:25:16 +00:00
if (!((_adjustment select _forEachIndex) isEqualTo [0, 0, 0])) then {
2015-08-07 14:43:06 +00:00
_adjustment set [_forEachIndex, [0, 0, 0]];
[ACE_player, QGVAR(Adjustment), _adjustment, 0.5] call EFUNC(common,setVariablePublic);
};
};
} forEach GVAR(Optics);
_adjustment = ACE_player getVariable QGVAR(Adjustment);
GVAR(Optics) = _newOptics;