ACE3/addons/scopes/XEH_postInit.sqf

147 lines
6.0 KiB
Plaintext
Raw Normal View History

#include "script_component.hpp"
/*
* Author: KoffeinFlummi, esteldunedain, Ruthberg
*
2015-01-18 20:01:07 +00:00
* Watches for scope changes.
* Defines key bindings
*
*/
if (!hasInterface) exitWith {};
2016-11-07 11:01:36 +00:00
GVAR(Optics) = ["", "", ""];
GVAR(Guns) = ["", "", ""];
GVAR(canAdjustElevation) = [false, false, false];
GVAR(canAdjustWindage) = [false, false, false];
GVAR(scopeAdjust) = [[[0,0],0,[0,0],0], [[0,0],0,[0,0],0], [[0,0],0,[0,0],0]];
2016-11-07 11:01:36 +00:00
["CBA_settingsInitialized", {
if (!GVAR(enabled)) exitWith {};
if (GVAR(deduceBarometricPressureFromTerrainAltitude)) then {
GVAR(zeroReferenceBarometricPressure) = 1013.25 * (1 - (0.0065 * EGVAR(common,mapAltitude)) / 288.15) ^ 5.255754495;
};
// Check inventory when it changes
["loadout", LINKFUNC(inventoryCheck), true] call CBA_fnc_addPlayerEventHandler;
// Instantly hide knobs when scoping in
["cameraView", {
params ["_player", "_newCameraView"];
if (_newCameraView == "GUNNER") then {
private _layer = [QGVAR(Zeroing)] call BIS_fnc_rscLayer;
_layer cutText ["", "PLAIN", 0];
2020-02-11 22:46:39 +00:00
if (!isNil QGVAR(fadePFH)) then {
[GVAR(fadePFH)] call CBA_fnc_removePerFrameHandler;
GVAR(fadePFH) = nil;
};
};
}] call CBA_fnc_addPlayerEventHandler;
2015-01-18 20:01:07 +00:00
// Add keybinds
["ACE3 Scope Adjustment", QGVAR(AdjustUpMinor), localize LSTRING(AdjustUpMinor), {
// Conditions: canInteract
if !([ACE_player, objNull, ["isNotInside", "isNotSwimming"]] call EFUNC(common,canInteractWith)) exitWith {false};
// Conditions: specific
if (!([ACE_player] call CBA_fnc_canUseWeapon)) exitWith {false};
2016-05-20 02:39:15 +00:00
[ACE_player] call FUNC(inventoryCheck);
2015-04-30 20:02:20 +00:00
// Statement
[ACE_player, ELEVATION_UP, MINOR_INCREMENT] call FUNC(adjustScope);
}, {false}, [201, [false, false, false]], true] call CBA_fnc_addKeybind;
2015-01-18 20:01:07 +00:00
["ACE3 Scope Adjustment", QGVAR(AdjustDownMinor), localize LSTRING(AdjustDownMinor), {
// Conditions: canInteract
if !([ACE_player, objNull, ["isNotInside", "isNotSwimming"]] call EFUNC(common,canInteractWith)) exitWith {false};
// Conditions: specific
if (!([ACE_player] call CBA_fnc_canUseWeapon)) exitWith {false};
2016-05-20 02:39:15 +00:00
[ACE_player] call FUNC(inventoryCheck);
2015-01-18 20:01:07 +00:00
// Statement
[ACE_player, ELEVATION_DOWN, MINOR_INCREMENT] call FUNC(adjustScope);
}, {false}, [209, [false, false, false]], true] call CBA_fnc_addKeybind;
2015-01-18 20:01:07 +00:00
["ACE3 Scope Adjustment", QGVAR(AdjustLeftMinor), localize LSTRING(AdjustLeftMinor), {
// Conditions: canInteract
if !([ACE_player, objNull, ["isNotInside", "isNotSwimming"]] call EFUNC(common,canInteractWith)) exitWith {false};
// Conditions: specific
if (!([ACE_player] call CBA_fnc_canUseWeapon)) exitWith {false};
2016-05-20 02:39:15 +00:00
[ACE_player] call FUNC(inventoryCheck);
2015-01-18 20:01:07 +00:00
// Statement
[ACE_player, WINDAGE_LEFT, MINOR_INCREMENT] call FUNC(adjustScope);
}, {false}, [209, [false, true, false]], true] call CBA_fnc_addKeybind;
2015-01-18 20:01:07 +00:00
["ACE3 Scope Adjustment", QGVAR(AdjustRightMinor), localize LSTRING(AdjustRightMinor), {
// Conditions: canInteract
if !([ACE_player, objNull, ["isNotInside", "isNotSwimming"]] call EFUNC(common,canInteractWith)) exitWith {false};
// Conditions: specific
if (!([ACE_player] call CBA_fnc_canUseWeapon)) exitWith {false};
2016-05-20 02:39:15 +00:00
[ACE_player] call FUNC(inventoryCheck);
2015-01-18 20:01:07 +00:00
// Statement
[ACE_player, WINDAGE_RIGHT, MINOR_INCREMENT] call FUNC(adjustScope);
}, {false}, [201, [false, true, false]], true] call CBA_fnc_addKeybind;
2015-04-02 20:40:21 +00:00
["ACE3 Scope Adjustment", QGVAR(AdjustUpMajor), localize LSTRING(AdjustUpMajor), {
// Conditions: canInteract
if !([ACE_player, objNull, ["isNotInside", "isNotSwimming"]] call EFUNC(common,canInteractWith)) exitWith {false};
// Conditions: specific
if (!([ACE_player] call CBA_fnc_canUseWeapon)) exitWith {false};
2016-05-20 02:39:15 +00:00
[ACE_player] call FUNC(inventoryCheck);
2015-04-10 17:41:34 +00:00
// Statement
[ACE_player, ELEVATION_UP, MAJOR_INCREMENT] call FUNC(adjustScope);
}, {false}, [201, [true, false, false]], true] call CBA_fnc_addKeybind;
2015-04-10 17:41:34 +00:00
["ACE3 Scope Adjustment", QGVAR(AdjustDownMajor), localize LSTRING(AdjustDownMajor), {
// Conditions: canInteract
if !([ACE_player, objNull, ["isNotInside", "isNotSwimming"]] call EFUNC(common,canInteractWith)) exitWith {false};
// Conditions: specific
if (!([ACE_player] call CBA_fnc_canUseWeapon)) exitWith {false};
2016-05-20 02:39:15 +00:00
[ACE_player] call FUNC(inventoryCheck);
2015-04-10 17:41:34 +00:00
// Statement
[ACE_player, ELEVATION_DOWN, MAJOR_INCREMENT] call FUNC(adjustScope);
}, {false}, [209, [true, false, false]], true] call CBA_fnc_addKeybind;
2015-04-10 17:41:34 +00:00
["ACE3 Scope Adjustment", QGVAR(AdjustLeftMajor), localize LSTRING(AdjustLeftMajor), {
// Conditions: canInteract
if !([ACE_player, objNull, ["isNotInside", "isNotSwimming"]] call EFUNC(common,canInteractWith)) exitWith {false};
// Conditions: specific
if (!([ACE_player] call CBA_fnc_canUseWeapon)) exitWith {false};
2016-05-20 02:39:15 +00:00
[ACE_player] call FUNC(inventoryCheck);
2015-04-10 17:41:34 +00:00
// Statement
[ACE_player, WINDAGE_LEFT, MAJOR_INCREMENT] call FUNC(adjustScope);
}, {false}, [209, [true, true, false]], true] call CBA_fnc_addKeybind;
2015-04-10 17:41:34 +00:00
["ACE3 Scope Adjustment", QGVAR(AdjustRightMajor), localize LSTRING(AdjustRightMajor), {
// Conditions: canInteract
if !([ACE_player, objNull, ["isNotInside", "isNotSwimming"]] call EFUNC(common,canInteractWith)) exitWith {false};
// Conditions: specific
if (!([ACE_player] call CBA_fnc_canUseWeapon)) exitWith {false};
2016-05-20 02:39:15 +00:00
[ACE_player] call FUNC(inventoryCheck);
2015-04-10 17:41:34 +00:00
// Statement
[ACE_player, WINDAGE_RIGHT, MAJOR_INCREMENT] call FUNC(adjustScope);
}, {false}, [201, [true, true, false]], true] call CBA_fnc_addKeybind;
2016-02-06 21:24:48 +00:00
// Register fire event handler
["ace_firedPlayer", LINKFUNC(firedEH)] call CBA_fnc_addEventHandler;
["ace_firedPlayerNonLocal", LINKFUNC(firedEH)] call CBA_fnc_addEventHandler;
}] call CBA_fnc_addEventHandler;