diff --git a/addons/scopes/functions/fnc_adjustScope.sqf b/addons/scopes/functions/fnc_adjustScope.sqf index ac03046803..42e0f17818 100644 --- a/addons/scopes/functions/fnc_adjustScope.sqf +++ b/addons/scopes/functions/fnc_adjustScope.sqf @@ -10,23 +10,26 @@ * Return value: * Did we adjust anything? * + * Example: + * [player, ELEVATION_UP, false] call ace_scopes_fnc_adjustScope + * * Public: No */ #include "script_component.hpp" -PARAMS_3(_unit,_turretAndDirection,_majorStep); +private ["_weaponIndex", "_zeroing", "_optic", "_opticConfig", "_verticalIncrement", "_horizontalIncrement", "_maxVertical", "_maxHorizontal", "_adjustment"]; + +params ["_unit", "_turretAndDirection", "_majorStep"]; if (!(_unit isKindOf "Man")) exitWith {false}; if (currentMuzzle _unit != currentWeapon _unit) exitWith {false}; -private ["_weaponIndex", "_zeroing", "_optic", "_verticalIncrement", "_horizontalIncrement", "_maxVertical", "_maxHorizontal", "_elevation", "_windage", "_zero", "_adjustment"]; - _weaponIndex = [_unit, currentWeapon _unit] call EFUNC(common,getWeaponIndex); if (_weaponIndex < 0) exitWith {false}; _adjustment = _unit getVariable QGVAR(Adjustment); if (isNil "_adjustment") then { - _adjustment = [[0,0,0], [0,0,0], [0,0,0]]; // [Windage, Elevation, Zero] + _adjustment = [[0, 0, 0], [0, 0, 0], [0, 0, 0]]; // [Windage, Elevation, Zero] }; if (isNil QGVAR(Optics)) then { @@ -34,18 +37,17 @@ if (isNil QGVAR(Optics)) then { }; _optic = GVAR(Optics) select _weaponIndex; -_verticalIncrement = getNumber (configFile >> "CfgWeapons" >> _optic >> "ACE_ScopeAdjust_VerticalIncrement"); -_horizontalIncrement = getNumber (configFile >> "CfgWeapons" >> _optic >> "ACE_ScopeAdjust_HorizontalIncrement"); -_maxVertical = getArray (configFile >> "CfgWeapons" >> _optic >> "ACE_ScopeAdjust_Vertical"); -_maxHorizontal = getArray (configFile >> "CfgWeapons" >> _optic >> "ACE_ScopeAdjust_Horizontal"); +_opticConfig = configFile >> "CfgWeapons" >> _optic; +_verticalIncrement = getNumber (_opticConfig >> "ACE_ScopeAdjust_VerticalIncrement"); +_horizontalIncrement = getNumber (_opticConfig >> "ACE_ScopeAdjust_HorizontalIncrement"); +_maxVertical = getArray (_opticConfig >> "ACE_ScopeAdjust_Vertical"); +_maxHorizontal = getArray (_opticConfig >> "ACE_ScopeAdjust_Horizontal"); if ((count _maxHorizontal < 2) || (count _maxVertical < 2)) exitWith {false}; if ((_verticalIncrement == 0) && (_horizontalIncrement == 0)) exitWith {false}; _zeroing = _adjustment select _weaponIndex; -_elevation = _zeroing select 0; -_windage = _zeroing select 1; -_zero = _zeroing select 2; +_zeroing params ["_elevation", "_windage", "_zero"]; switch (_turretAndDirection) do { case ELEVATION_UP: { _elevation = _elevation + _verticalIncrement }; diff --git a/addons/scopes/functions/fnc_adjustZero.sqf b/addons/scopes/functions/fnc_adjustZero.sqf index 12e911b537..363407e090 100644 --- a/addons/scopes/functions/fnc_adjustZero.sqf +++ b/addons/scopes/functions/fnc_adjustZero.sqf @@ -8,29 +8,30 @@ * Return value: * true * + * Example: + * [player] call ace_scopes_fnc_adjustZero + * * Public: No */ #include "script_component.hpp" -PARAMS_1(_unit); +private ["_weaponIndex", "_adjustment", "_zeroing"]; + +params ["_unit"]; if (vehicle _unit != _unit) exitWith {false}; -private ["_weaponIndex", "_adjustment", "_zeroing", "_elevation", "_windage", "_zero"]; - _weaponIndex = [_unit, currentWeapon _unit] call EFUNC(common,getWeaponIndex); if (_weaponIndex < 0) exitWith {false}; _adjustment = _unit getVariable QGVAR(Adjustment); if (isNil "_adjustment") then { // [Windage, Elevation, Zero] - _adjustment = [[0,0,0], [0,0,0], [0,0,0]]; + _adjustment = [[0, 0, 0], [0, 0, 0], [0, 0, 0]]; }; -_zeroing = _adjustment select _weaponIndex; -_elevation = _zeroing select 0; -_windage = _zeroing select 1; -_zero = _zeroing select 2; +_zeroing = _adjustment select _weaponIndex; +_zeroing params ["_elevation", "_windage", "_zero"]; _zero = round((_zero + _elevation) * 10) / 10; _elevation = 0; diff --git a/addons/scopes/functions/fnc_applyScopeAdjustment.sqf b/addons/scopes/functions/fnc_applyScopeAdjustment.sqf index 4950fe9ece..fbd3e1b636 100644 --- a/addons/scopes/functions/fnc_applyScopeAdjustment.sqf +++ b/addons/scopes/functions/fnc_applyScopeAdjustment.sqf @@ -11,20 +11,23 @@ * Return value: * True * + * Example: + * [player, 1.3, 0.3, 0.1] call ace_scopes_fnc_applyScopeAdjustment + * * Public: No */ #include "script_component.hpp" -EXPLODE_4_PVT(_this,_unit,_elevation,_windage,_zero); +private ["_adjustmentDifference", "_pitchBankYaw", "_adjustment", "_weaponIndex"]; -private ["_adjustmentDifference", "_pitchbankyaw", "_pitch", "_bank", "_yaw", "_adjustment", "_weaponIndex"]; +params ["_unit", "_elevation", "_windage", "_zero"]; _weaponIndex = [_unit, currentWeapon _unit] call EFUNC(common,getWeaponIndex); _adjustment = _unit getVariable QGVAR(Adjustment); if (isNil "_adjustment") then { // [Windage, Elevation, Zero] - _adjustment = [[0,0,0], [0,0,0], [0,0,0]]; + _adjustment = [[0, 0, 0], [0, 0, 0], [0, 0, 0]]; _unit setVariable [QGVAR(Adjustment), _adjustment]; }; @@ -39,10 +42,11 @@ playSound (["ACE_Scopes_Click_1", "ACE_Scopes_Click_2", "ACE_Scopes_Click_3"] se if (cameraView == "GUNNER") then { // Convert adjustmentDifference from mils to degrees _adjustmentDifference = [_adjustmentDifference, {_this * 0.05625}] call EFUNC(common,map); - _pitchbankyaw = [_unit] call EFUNC(common,getPitchBankYaw); - _pitch = (_pitchbankyaw select 0) + (_adjustmentDifference select 0); - _bank = (_pitchbankyaw select 1); - _yaw = (_pitchbankyaw select 2) + (_adjustmentDifference select 1); + _adjustmentDifference params ["_elevationDifference", "_windageDifference"]; + _pitchBankYaw = [_unit] call EFUNC(common,getPitchBankYaw); + _pitchBankYaw params ["_pitch", "_bank", "_yaw"]; + _pitch = _pitch + _elevationDifference; + _yaw = _yaw + _windageDifference; [_unit, _pitch, _bank, _yaw] call EFUNC(common,setPitchBankYaw); } else { [] call FUNC(showZeroing); diff --git a/addons/scopes/functions/fnc_canAdjustZero.sqf b/addons/scopes/functions/fnc_canAdjustZero.sqf index 619d82cf6e..36ea4ac793 100644 --- a/addons/scopes/functions/fnc_canAdjustZero.sqf +++ b/addons/scopes/functions/fnc_canAdjustZero.sqf @@ -8,17 +8,20 @@ * Return value: * Can we update the zero reference? * + * Example: + * [player] call ace_scopes_fnc_canAdjustZero + * * Public: No */ #include "script_component.hpp" -PARAMS_1(_unit); - private ["_weaponIndex", "_adjustment", "_elevation"]; +params ["_unit"]; + if (cameraView == "GUNNER") exitWith {false}; -if !(vehicle _unit == _unit) exitWith {false}; -if !(missionNamespace getVariable [QEGVAR(advanced_ballistics,enabled), false]) exitWith {false}; +if (vehicle _unit != _unit) exitWith {false}; +if (!(missionNamespace getVariable [QEGVAR(advanced_ballistics,enabled), false])) exitWith {false}; _weaponIndex = [_unit, currentWeapon _unit] call EFUNC(common,getWeaponIndex); if (_weaponIndex < 0) exitWith {false}; @@ -26,7 +29,7 @@ if (_weaponIndex < 0) exitWith {false}; _adjustment = _unit getVariable QGVAR(Adjustment); if (isNil "_adjustment") then { // [Windage, Elevation, Zero] - _adjustment = [[0,0,0], [0,0,0], [0,0,0]]; + _adjustment = [[0, 0, 0], [0, 0, 0], [0, 0, 0]]; }; _elevation = (_adjustment select _weaponIndex) select 0; diff --git a/addons/scopes/functions/fnc_firedEH.sqf b/addons/scopes/functions/fnc_firedEH.sqf index 020431c27b..b4441df839 100644 --- a/addons/scopes/functions/fnc_firedEH.sqf +++ b/addons/scopes/functions/fnc_firedEH.sqf @@ -1,5 +1,5 @@ /* - * Author: KoffeinFlummi and esteldunedain + * Author: KoffeinFlummi, esteldunedain * Adjusts the flight path of the bullet according to the zeroing * * Argument: @@ -18,11 +18,11 @@ */ #include "script_component.hpp" -private ["_unit", "_adjustment", "_projectile", "_weaponIndex", "_zeroing", "_adjustment"]; -_unit = _this select 0; -_projectile = _this select 6; +private ["_adjustment", "_weaponIndex", "_zeroing", "_adjustment"]; -if !([_unit] call EFUNC(common,isPlayer)) exitWith {}; +prams ["_unit", "", "", "", "", "", "_projectile"]; + +if (!([_unit] call EFUNC(common,isPlayer))) exitWith {}; _adjustment = _unit getVariable [QGVAR(Adjustment), []]; if (_adjustment isEqualTo []) exitWith {}; @@ -32,9 +32,10 @@ if (_weaponIndex < 0) exitWith {}; _zeroing = _adjustment select _weaponIndex; -if (_zeroing isEqualTo [0,0,0]) exitWith {}; +if (_zeroing isEqualTo [0, 0, 0]) exitWith {}; // Convert zeroing from mils to degrees _zeroing = _zeroing vectorMultiply 0.05625; +_zeroing params ["_elevation", "_windage", "_zero"] -[_projectile, (_zeroing select 1), (_zeroing select 0) + (_zeroing select 2), 0] call EFUNC(common,changeProjectileDirection); +[_projectile, _elevation, _elevation + _zero, 0] call EFUNC(common,changeProjectileDirection); diff --git a/addons/scopes/functions/fnc_getOptics.sqf b/addons/scopes/functions/fnc_getOptics.sqf index 289ed5e7bd..fbd1d135f4 100644 --- a/addons/scopes/functions/fnc_getOptics.sqf +++ b/addons/scopes/functions/fnc_getOptics.sqf @@ -10,21 +10,25 @@ * 1: Optic of secondary * 2: Optic of handgun * + * Example: + * [player] call ace_scopes_fnc_getOptics + * * Public: No */ #include "script_component.hpp" -EXPLODE_1_PVT(_this,_unit); +private "_optics"; -private ["_array"]; -_array = ["", "", ""]; +params ["_unit"]; -if !(_unit isKindOf "CAManBase") exitWith {_array}; +_optics = ["", "", ""]; + +if (!(_unit isKindOf "CAManBase")) exitWith {_optics}; { if (count _x >= 2) then { - _array set [_forEachIndex, _x select 2]; + _optics set [_forEachIndex, _x select 2]; }; -} forEach [primaryWeaponItems _unit, secondaryWeaponItems _unit, handgunItems _unit]; +} count [primaryWeaponItems _unit, secondaryWeaponItems _unit, handgunItems _unit]; -_array +_optics diff --git a/addons/scopes/functions/fnc_inventoryCheck.sqf b/addons/scopes/functions/fnc_inventoryCheck.sqf index af4b347124..562bf731b4 100644 --- a/addons/scopes/functions/fnc_inventoryCheck.sqf +++ b/addons/scopes/functions/fnc_inventoryCheck.sqf @@ -1,5 +1,5 @@ /* - * Author: KoffeinFlummi and Commy2 + * Author: KoffeinFlummi, Commy2 * Check if weapon optics changed and reset zeroing if needed * * Arguments: @@ -8,18 +8,21 @@ * Return Value: * None * + * Example: + * [player] call ace_scopes_fnc_inventoryCheck + * * Public: No */ #include "script_component.hpp" -EXPLODE_1_PVT(_this,_player); - private ["_newOptics", "_adjustment"]; +params ["_player"]; + _adjustment = ACE_player getVariable QGVAR(Adjustment); if (isNil "_adjustment") then { // [Windage, Elevation, Zero] - _adjustment = [[0,0,0], [0,0,0], [0,0,0]]; + _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); }; @@ -32,8 +35,8 @@ _newOptics = [_player] call FUNC(getOptics); { if (_newOptics select _forEachIndex != _x) then { // The optic for this weapon changed, set adjustment to zero - if !((_adjustment select _foreachindex) isEqualTo [0,0,0]) then { - _adjustment set [_forEachIndex, [0,0,0]]; + if (!((_adjustment select _foreachindex) isEqualTo [0, 0, 0])) then { + _adjustment set [_forEachIndex, [0, 0, 0]]; [ACE_player, QGVAR(Adjustment), _adjustment, 0.5] call EFUNC(common,setVariablePublic); }; }; diff --git a/addons/scopes/functions/fnc_showZeroing.sqf b/addons/scopes/functions/fnc_showZeroing.sqf index 7cefc68563..d3d4a38a9d 100644 --- a/addons/scopes/functions/fnc_showZeroing.sqf +++ b/addons/scopes/functions/fnc_showZeroing.sqf @@ -1,5 +1,5 @@ /* - * Author: KoffeinFlummi and esteldunedain + * Author: KoffeinFlummi, esteldunedain * Display the adjustment knobs, update their value and fade them out later * * Arguments: @@ -8,13 +8,16 @@ * Return Value: * None * + * Example: + * [] call ace_scopes_fnc_showZeroing + * * Public: No */ #include "script_component.hpp" -disableSerialization; +private ["_weaponIndex", "_adjustment", "_layer", "_display", "_zeroing", "_vertical", "_horizontal"]; -private ["_weaponIndex","_adjustment","_layer","_display","_zeroing","_vertical","_horizontal"]; +disableSerialization; _weaponIndex = [ACE_player, currentWeapon ACE_player] call EFUNC(common,getWeaponIndex); if (_weaponIndex < 0) exitWith {}; @@ -22,7 +25,7 @@ if (_weaponIndex < 0) exitWith {}; _adjustment = ACE_player getVariable QGVAR(Adjustment); if (isNil "_adjustment") then { // [Windage, Elevation, Zero] - _adjustment = [[0,0,0], [0,0,0], [0,0,0]]; + _adjustment = [[0, 0, 0], [0, 0, 0], [0, 0, 0]]; }; // Display the adjustment knobs @@ -35,10 +38,11 @@ if (isNull _display) exitWith {}; // Update values _zeroing = _adjustment select _weaponIndex; +_zeroing params ["_elevation", "_windage"]; _vertical = _display displayCtrl 12; _horizontal = _display displayCtrl 13; -_vertical ctrlSetText (str (_zeroing select 0)); -_horizontal ctrlSetText (str (_zeroing select 1)); +_vertical ctrlSetText (str _elevation); +_horizontal ctrlSetText (str _windage); // Set the ACE_time when to hide the knobs GVAR(timeToHide) = ACE_diagTime + 3.0; @@ -47,14 +51,13 @@ if !(isNil QGVAR(fadePFH)) exitWith {}; // Launch a PFH to wait and fade out the knobs GVAR(fadePFH) = [{ - if (ACE_diagTime >= GVAR(timeToHide)) exitWith { private "_layer"; + params ["", "_pfhId"]; _layer = [QGVAR(Zeroing)] call BIS_fnc_rscLayer; _layer cutFadeOut 2; GVAR(fadePFH) = nil; - [_this select 1] call cba_fnc_removePerFrameHandler; + [_pfhId] call cba_fnc_removePerFrameHandler; }; - }, 0.1, []] call CBA_fnc_addPerFrameHandler