diff --git a/TO_MERGE/agm/Scopes/clientInit.sqf b/TO_MERGE/agm/Scopes/clientInit.sqf deleted file mode 100644 index 106121cc8b..0000000000 --- a/TO_MERGE/agm/Scopes/clientInit.sqf +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Author: KoffeinFlummi - * - * Initializes vars needed for scope adjustment and watches for scope changes. - * - * Arguments: - * None - * - * Return Value: - * None - */ -AGM_Scopes_fadeScript = scriptNull; - -// show overlay after changing weapon/optic -0 spawn { - _layer = ["AGM_Scope_Zeroing"] call BIS_fnc_rscLayer; - while {True} do { - waitUntil {[AGM_player, 0,0] call AGM_Scopes_fnc_canAdjustScope}; - _layer cutRsc ["AGM_Scope_Zeroing", "PLAIN", 0, false]; - sleep 3; - _layer cutFadeOut 2; - - _weapon = currentWeapon AGM_player; - _optics = [AGM_player] call AGM_Scopes_fnc_getOptics; - waitUntil {sleep 0.05; !(_optics isEqualTo ([AGM_player] call AGM_Scopes_fnc_getOptics)) or (currentWeapon AGM_player != _weapon)}; - }; -}; - -// instantly hide when scoping in -0 spawn { - _layer = ["AGM_Scope_Zeroing"] call BIS_fnc_rscLayer; - while {True} do { - waitUntil {sleep 0.05; cameraView == "GUNNER"}; - if !(isNull AGM_Scopes_fadeScript) then { - terminate AGM_Scopes_fadeScript; - }; - _layer cutText ["", "PLAIN", 0]; - }; -}; diff --git a/TO_MERGE/agm/Scopes/config.cpp b/TO_MERGE/agm/Scopes/config.cpp deleted file mode 100644 index c521d53df7..0000000000 --- a/TO_MERGE/agm/Scopes/config.cpp +++ /dev/null @@ -1,238 +0,0 @@ -class CfgPatches { - class AGM_Scopes { - units[] = {}; - weapons[] = {}; - requiredVersion = 0.60; - requiredAddons[] = {AGM_Core}; - version = "0.95"; - versionStr = "0.95"; - versionAr[] = {0,95,0}; - author[] = {"KoffeinFlummi"}; - authorUrl = "https://github.com/KoffeinFlummi"; - }; -}; - -class CfgFunctions { - class AGM_Scopes { - class AGM_Scopes { - file = "AGM_Scopes\functions"; - class adjustScope; - class canAdjustScope; - class firedEH; - class getOptics; - class hideZeroing; - class inventoryCheck; - }; - }; -}; - -class Extended_PostInit_EventHandlers { - class AGM_Scopes { - clientInit = "call compile preprocessFileLineNumbers '\AGM_Scopes\clientInit.sqf';"; - }; -}; - -class Extended_Fired_EventHandlers { - class CAManBase { - class AGM_Scopes { - clientFired = "if (_this select 0 == AGM_player) then {_this call AGM_Scopes_fnc_firedEH};"; - }; - }; -}; - -class Extended_Take_EventHandlers { - class CAManBase { - class AGM_Scopes { - clientTake = "if (_this select 0 == AGM_player) then {_this call AGM_Scopes_fnc_inventoryCheck};"; - }; - }; -}; - -class Extended_Put_EventHandlers { - class CAManBase { - class AGM_Scopes { - clientPut = "if (_this select 0 == AGM_player) then {_this call AGM_Scopes_fnc_inventoryCheck};"; - }; - }; -}; - -class Extended_InitPost_EventHandlers { - class CAManBase { - class AGM_Scopes { - init = "if (_this select 0 == call AGM_Core_fnc_player) then {_this call AGM_Scopes_fnc_inventoryCheck};"; - }; - }; -}; - -class Extended_Respawn_EventHandlers { - class CAManBase { - class AGM_Scopes { - respawn = "if (_this select 0 == call AGM_Core_fnc_player) then {_this call AGM_Scopes_fnc_inventoryCheck};"; - }; - }; -}; - -class AGM_Core_Default_Keys { - class adjustScopeUp { - displayName = "$STR_AGM_Scopes_AdjustUp"; - condition = "[_player] call AGM_Scopes_fnc_inventoryCheck; [_player, 0, 0.1] call AGM_Scopes_fnc_canAdjustScope"; - statement = "[_player, 0, 0.1] call AGM_Scopes_fnc_adjustScope;"; - allowHolding = 1; - key = 201; - shift = 0; - control = 0; - alt = 0; - }; - class adjustScopeDown: adjustScopeUp { - displayName = "$STR_AGM_Scopes_AdjustDown"; - condition = "[_player] call AGM_Scopes_fnc_inventoryCheck; [_player, 0, -0.1] call AGM_Scopes_fnc_canAdjustScope"; - statement = "[_player, 0, -0.1] call AGM_Scopes_fnc_adjustScope;"; - key = 209; - }; - class adjustScopeLeft: adjustScopeUp { - displayName = "$STR_AGM_Scopes_AdjustLeft"; - condition = "[_player] call AGM_Scopes_fnc_inventoryCheck; [_player, -0.1, 0] call AGM_Scopes_fnc_canAdjustScope"; - statement = "[_player, -0.1, 0] call AGM_Scopes_fnc_adjustScope;"; - key = 209; - control = 1; - }; - class adjustScopeRight: adjustScopeLeft { - displayName = "$STR_AGM_Scopes_AdjustRight"; - condition = "[_player] call AGM_Scopes_fnc_inventoryCheck; [_player, 0.1, 0] call AGM_Scopes_fnc_canAdjustScope"; - statement = "[_player, 0.1, 0] call AGM_Scopes_fnc_adjustScope;"; - key = 201; - }; -}; - -class CfgSounds { - class AGM_Sound_Click; - class AGM_Scopes_Click_1: AGM_Sound_Click { - sound[] = {"\AGM_Scopes\sounds\agm_scopes_click.wav", 3, 2, 200}; - }; - class AGM_Scopes_Click_2: AGM_Scopes_Click_1 { - sound[] = {"\AGM_Scopes\sounds\agm_scopes_click.wav", 3.3, 1.8, 200}; - }; - class AGM_Scopes_Click_3: AGM_Scopes_Click_1 { - sound[] = {"\AGM_Scopes\sounds\agm_scopes_click.wav", 2.8, 2.3, 200}; - }; -}; - -class CfgWeapons { - class ItemCore; - class InventoryOpticsItem_Base_F; - - class optic_LRPS: ItemCore { - AGM_ScopeAdjust_Horizontal[] = {-50,50}; - AGM_ScopeAdjust_Vertical[] = {-70,70}; - class ItemInfo: InventoryOpticsItem_Base_F { - class OpticsModes { - class Snip { - discreteDistance[] = {1}; - discreteDistanceInitIndex = 0; - }; - }; - }; - }; - - class optic_SOS: ItemCore { - AGM_ScopeAdjust_Horizontal[] = {-50,50}; - AGM_ScopeAdjust_Vertical[] = {-60,60}; - class ItemInfo: InventoryOpticsItem_Base_F { - class OpticsModes { - class Snip { - discreteDistance[] = {1}; - discreteDistanceInitIndex = 0; - }; - }; - }; - }; - - class optic_DMS: ItemCore { - AGM_ScopeAdjust_Horizontal[] = {-40,40}; - AGM_ScopeAdjust_Vertical[] = {-40,40}; - class ItemInfo: InventoryOpticsItem_Base_F { - class OpticsModes { - class Snip { - discreteDistance[] = {1}; - discreteDistanceInitIndex = 0; - }; - }; - }; - }; -}; - -class RscTitles { - class AGM_Scope_Zeroing { - idd = -1; - movingEnable = 0; - enableSimulation = 1; - enableDisplay = 1; - onLoad = "_this spawn compile preprocessFileLineNumbers '\AGM_Scopes\scripts\zeroingOnLoad.sqf'; uiNamespace setVariable ['AGM_Scope_Debug', _this];"; - duration = 1e+011; - fadein = 0; - fadeout = 0; - name = "AGM_Scope_Zeroing"; - class RscPicture; - class RscText; - class controls { - class AGM_Scope_Zeroing_BG: RscPicture { - idc = 925001; - type = 0; - text = "AGM_Scopes\UI\scopes_bg.paa"; - style = 48 + 0x800; - scale = 1; - sizeEx = 1; - font = "PuristaMedium"; - colorText[] = {1,1,1,1}; - colorBackground[] = {1,1,1,1}; - shadow = 1; - - x = (0.5-0.4/2) * safezoneW + safezoneX; - y = 0 * safezoneH + safezoneY; - w = 0.4 * safezoneW; - h = 0.3 * safezoneH; - }; - class AGM_Scope_Zeroing_Vertical: RscText { - idc = 925002; - type = 0; - style = 2; - sizeEx = 0.04; - lineSpacing = 1; - font = "PuristaMedium"; - text = ""; - colorText[] = {1,1,1, 0.9}; - colorBackground[] = {1,0,0, 0}; - shadow = 0; - - x = (0.5-0.4/2 + 0.45*0.4) * safezoneW + safezoneX; - y = (0 + 0.19*0.3) * safezoneH + safezoneY; - w = 0.04 * safezoneW; - h = 0.025 * safezoneH; - }; - class AGM_Scope_Zeroing_Horizontal: RscText { - idc = 925003; - type = 0; - style = 0; - sizeEx = 0.04; - lineSpacing = 1; - font = "PuristaMedium"; - text = ""; - colorText[] = {1,1,1, 0.9}; - colorBackground[] = {1,0,0, 0}; - shadow = 0; - - x = (0.5-0.4/2 + 0.6*0.4) * safezoneW + safezoneX; - y = (0 + 0.47*0.3) * safezoneH + safezoneY; - w = 0.04 * safezoneW; - h = 0.025 * safezoneH; - }; - }; - }; -}; - -class RscInGameUI { - class RscUnitInfo; - class RscWeaponZeroing: RscUnitInfo { - onLoad = "[""onLoad"",_this,""RscUnitInfo"",'IGUI'] call compile preprocessfilelinenumbers ""A3\ui_f\scripts\initDisplay.sqf""; uiNamespace setVariable ['AGM_dlgWeaponZeroing', _this select 0];"; - }; -}; diff --git a/TO_MERGE/agm/Scopes/functions/fn_adjustScope.sqf b/TO_MERGE/agm/Scopes/functions/fn_adjustScope.sqf deleted file mode 100644 index 0b70913365..0000000000 --- a/TO_MERGE/agm/Scopes/functions/fn_adjustScope.sqf +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Author: KoffeinFlummi - * - * Changes the adjustment for the current scope - * - * Arguments: - * 0: Horizontal adjustment - * 1: Vertical adjustment - * - * Return Value: - * True - */ - -private ["_unit", "_weapons", "_zeroing", "_pitchbankyaw", "_pitch", "_bank", "_yaw", "_hint"]; - -_unit = _this select 0; - -_weapons = [ - primaryWeapon _unit, - secondaryWeapon _unit, - handgunWeapon _unit -]; - -if (isNil "AGM_Scopes_Adjustment") then { - AGM_Scopes_Adjustment = [[0,0], [0,0], [0,0]]; -}; - -_zeroing = AGM_Scopes_Adjustment select (_weapons find (currentWeapon _unit)); -_zeroing set [0, (round (((_zeroing select 0) + (_this select 1)) * 10)) / 10]; -_zeroing set [1, (round (((_zeroing select 1) + (_this select 2)) * 10)) / 10]; - -AGM_Scopes_Adjustment set [_weapons find (currentWeapon _unit), _zeroing]; - -playSound (["AGM_Scopes_Click_1", "AGM_Scopes_Click_2", "AGM_Scopes_Click_3"] select floor random 3); - -// slightly rotate the player if looking through optic -if (cameraView == "GUNNER") then { - _pitchbankyaw = [_unit] call AGM_Core_fnc_getPitchBankYaw; - // these are not exact mil-to-degree conversions, but instead chosen - // to minimize the effect of rounding errors - _pitch = (_pitchbankyaw select 0) + ((_this select 2) * -0.04); - _bank = _pitchbankyaw select 1; - _yaw = (_pitchbankyaw select 2) + ((_this select 1) * -0.04); - [_unit, _pitch, _bank, _yaw] call AGM_Core_fnc_setPitchBankYaw; -}; - -_display = uiNamespace getVariable ["AGM_Scopes_ZeroingDisplay", displayNull]; -if !(isNull _display) then { - _vertical = _display displayCtrl 925002; - _horizontal = _display displayCtrl 925003; - _vertical ctrlSetText (str (_zeroing select 1)); - _horizontal ctrlSetText (str (_zeroing select 0)); -}; - -if (!isNull (missionNamespace getVariable ["AGM_Scopes_fadeScript", scriptNull])) then { - terminate AGM_Scopes_fadeScript; -}; -if (cameraView != "GUNNER") then { - AGM_Scopes_fadeScript = 0 spawn { - _layer = ["AGM_Scope_Zeroing"] call BIS_fnc_rscLayer; - _layer cutRsc ["AGM_Scope_Zeroing", "PLAIN", 0, false]; - sleep 3; - _layer cutFadeOut 2; - }; -}; - -true diff --git a/TO_MERGE/agm/Scopes/functions/fn_hideZeroing.sqf b/TO_MERGE/agm/Scopes/functions/fn_hideZeroing.sqf deleted file mode 100644 index 9013a4155c..0000000000 --- a/TO_MERGE/agm/Scopes/functions/fn_hideZeroing.sqf +++ /dev/null @@ -1,25 +0,0 @@ -// by commy2 - -private ["_state", "_ctrl"]; - -_state = _this select 0; - -disableSerialization; -_ctrl = (uiNamespace getVariable ['AGM_dlgWeaponZeroing', displayNull]) displayCtrl 168; - -if (_state) then { - _ctrl ctrlSetPosition [0,0,0,0]; -} else { - private "_config"; - - _config = configFile >> "RscInGameUI" >> "RscWeaponZeroing" >> "CA_Zeroing"; - - _ctrl ctrlSetPosition [ - getNumber (_config >> "x"), - getNumber (_config >> "y"), - getNumber (_config >> "w"), - getNumber (_config >> "h") - ]; -}; - -_ctrl ctrlCommit 0; diff --git a/TO_MERGE/agm/Scopes/functions/fn_inventoryCheck.sqf b/TO_MERGE/agm/Scopes/functions/fn_inventoryCheck.sqf deleted file mode 100644 index 008b204598..0000000000 --- a/TO_MERGE/agm/Scopes/functions/fn_inventoryCheck.sqf +++ /dev/null @@ -1,21 +0,0 @@ -// by KoffeinFlummi / commy2 - -private "_new"; - -_new = _this call AGM_Scopes_fnc_getOptics; - -if (isNil "AGM_Scopes_Optics") then { - AGM_Scopes_Optics = ["", "", ""]; -}; - -if (isNil "AGM_Scopes_Adjustment") then { - AGM_Scopes_Adjustment = [[0,0], [0,0], [0,0]]; -}; - -{ - if (_new select _forEachIndex != _x) then { - AGM_Scopes_Adjustment set [_forEachIndex, [0,0]]; - }; -} forEach AGM_Scopes_Optics; - -AGM_Scopes_Optics = _new; diff --git a/addons/scopes/$PBOPREFIX$ b/addons/scopes/$PBOPREFIX$ new file mode 100644 index 0000000000..48434ed1b1 --- /dev/null +++ b/addons/scopes/$PBOPREFIX$ @@ -0,0 +1 @@ +z\ace\addons\scopes \ No newline at end of file diff --git a/addons/scopes/CfgEventHandlers.hpp b/addons/scopes/CfgEventHandlers.hpp new file mode 100644 index 0000000000..be85fcc84d --- /dev/null +++ b/addons/scopes/CfgEventHandlers.hpp @@ -0,0 +1,51 @@ +class Extended_PreInit_EventHandlers { + class ADDON { + init = QUOTE(call COMPILE_FILE(XEH_preInit)); + }; +}; + +class Extended_PostInit_EventHandlers { + class ADDON { + init = QUOTE(call COMPILE_FILE(XEH_postInit)); + }; +}; + +class Extended_Fired_EventHandlers { + class CAManBase { + class ADDON { + clientFired = QUOTE(if (_this select 0 == ACE_player) then { _this call FUNC(firedEH) };); + }; + }; +}; + +class Extended_Take_EventHandlers { + class CAManBase { + class ADDON { + clientTake = QUOTE(if (_this select 0 == ACE_player) then{ _this call FUNC(inventoryCheck) };); + }; + }; +}; + +class Extended_Put_EventHandlers { + class CAManBase { + class ADDON { + clientPut = QUOTE(if (_this select 0 == ACE_player) then {_this call FUNC(inventoryCheck)};); + }; + }; +}; + +class Extended_InitPost_EventHandlers { + class CAManBase { + class ADDON { + init = QUOTE(if (_this select 0 == call EFUNC(common,player)) then{ _this call FUNC(inventoryCheck) };); + }; + }; +}; + +class Extended_Respawn_EventHandlers { + class CAManBase { + class ADDON { + respawn = QUOTE(if (_this select 0 == call EFUNC(common, player)) then{ _this call FUNC(inventoryCheck) };); + }; + }; +}; diff --git a/addons/scopes/CfgSounds.hpp b/addons/scopes/CfgSounds.hpp new file mode 100644 index 0000000000..9063c7f730 --- /dev/null +++ b/addons/scopes/CfgSounds.hpp @@ -0,0 +1,12 @@ +class CfgSounds { + class ACE_Sound_Click; + class ACE_Scopes_Click_1: ACE_Sound_Click { + sound[] = {QUOTE(PATHTOF(sounds\ACE_scopes_click.wav)),3, 2, 200}; + }; + class ACE_Scopes_Click_2: ACE_Scopes_Click_1 { + sound[] = {QUOTE(PATHTOF(sounds\ACE_scopes_click.wav)), 3.3, 1.8, 200}; + }; + class ACE_Scopes_Click_3: ACE_Scopes_Click_1 { + sound[] = {QUOTE(PATHTOF(sounds\ACE_scopes_click.wav)), 2.8, 2.3, 200}; + }; +}; diff --git a/addons/scopes/CfgWeapons.hpp b/addons/scopes/CfgWeapons.hpp new file mode 100644 index 0000000000..67898fb449 --- /dev/null +++ b/addons/scopes/CfgWeapons.hpp @@ -0,0 +1,43 @@ +class CfgWeapons { + class ItemCore; + class InventoryOpticsItem_Base_F; + + class optic_LRPS : ItemCore { + ACE_ScopeAdjust_Horizontal[] = { -50, 50 }; + ACE_ScopeAdjust_Vertical[] = { -70, 70 }; + class ItemInfo : InventoryOpticsItem_Base_F { + class OpticsModes { + class Snip { + discreteDistance[] = { 1 }; + discreteDistanceInitIndex = 0; + }; + }; + }; + }; + + class optic_SOS : ItemCore { + ACE_ScopeAdjust_Horizontal[] = { -50, 50 }; + ACE_ScopeAdjust_Vertical[] = { -60, 60 }; + class ItemInfo : InventoryOpticsItem_Base_F { + class OpticsModes { + class Snip { + discreteDistance[] = { 1 }; + discreteDistanceInitIndex = 0; + }; + }; + }; + }; + + class optic_DMS : ItemCore { + ACE_ScopeAdjust_Horizontal[] = { -40, 40 }; + ACE_ScopeAdjust_Vertical[] = { -40, 40 }; + class ItemInfo : InventoryOpticsItem_Base_F { + class OpticsModes { + class Snip { + discreteDistance[] = { 1 }; + discreteDistanceInitIndex = 0; + }; + }; + }; + }; +}; diff --git a/addons/scopes/RscTitles.hpp b/addons/scopes/RscTitles.hpp new file mode 100644 index 0000000000..f86f33e492 --- /dev/null +++ b/addons/scopes/RscTitles.hpp @@ -0,0 +1,75 @@ +class RscTitles { + class ACE_Scope_Zeroing { + idd = -1; + movingEnable = 0; + enableSimulation = 1; + enableDisplay = 1; + onLoad = QUOTE(_this spawn COMPILE_FILE(PATHTOF(scripts\zeroingOnLoad.sqf)); uiNamespace setVariable[QGVAR(Debug), _this];); + duration = 1e+011; + fadein = 0; + fadeout = 0; + name = QGVAR(Zeroing); + class RscPicture; + class RscText; + class controls { + class ACE_Scope_Zeroing_BG : RscPicture { + idc = 925001; + type = 0; + text = PATHTOF(UI\scopes_bg.paa); + style = 48 + 0x800; + scale = 1; + sizeEx = 1; + font = "PuristaMedium"; + colorText[] = { 1, 1, 1, 1 }; + colorBackground[] = { 1, 1, 1, 1 }; + shadow = 1; + + x = (0.5 - 0.4 / 2) * safezoneW + safezoneX; + y = 0 * safezoneH + safezoneY; + w = 0.4 * safezoneW; + h = 0.3 * safezoneH; + }; + class ACE_Scope_Zeroing_Vertical : RscText { + idc = 925002; + type = 0; + style = 2; + sizeEx = 0.04; + lineSpacing = 1; + font = "PuristaMedium"; + text = ""; + colorText[] = { 1, 1, 1, 0.9 }; + colorBackground[] = { 1, 0, 0, 0 }; + shadow = 0; + + x = (0.5 - 0.4 / 2 + 0.45*0.4) * safezoneW + safezoneX; + y = (0 + 0.19*0.3) * safezoneH + safezoneY; + w = 0.04 * safezoneW; + h = 0.025 * safezoneH; + }; + class ACE_Scope_Zeroing_Horizontal : RscText { + idc = 925003; + type = 0; + style = 0; + sizeEx = 0.04; + lineSpacing = 1; + font = "PuristaMedium"; + text = ""; + colorText[] = { 1, 1, 1, 0.9 }; + colorBackground[] = { 1, 0, 0, 0 }; + shadow = 0; + + x = (0.5 - 0.4 / 2 + 0.6*0.4) * safezoneW + safezoneX; + y = (0 + 0.47*0.3) * safezoneH + safezoneY; + w = 0.04 * safezoneW; + h = 0.025 * safezoneH; + }; + }; + }; +}; + +class RscInGameUI { + class RscUnitInfo; + class RscWeaponZeroing : RscUnitInfo { + onLoad = QUOTE(["onLoad", _this, "RscUnitInfo", "IGUI"] call COMPILE_FILE(PATHTOF(A3\ui_f\scripts\initDisplay.sqf)); uiNamespace setVariable["ACE_dlgWeaponZeroing", _this select 0];); + }; +}; diff --git a/TO_MERGE/agm/Scopes/UI/scopes_bg.paa b/addons/scopes/UI/scopes_bg.paa similarity index 100% rename from TO_MERGE/agm/Scopes/UI/scopes_bg.paa rename to addons/scopes/UI/scopes_bg.paa diff --git a/addons/scopes/XEH_postInit.sqf b/addons/scopes/XEH_postInit.sqf new file mode 100644 index 0000000000..2146c4741f --- /dev/null +++ b/addons/scopes/XEH_postInit.sqf @@ -0,0 +1,39 @@ +/* + * Author: KoffeinFlummi + * + * Initializes vars needed for scope adjustment and watches for scope changes. + * + * Arguments: + * None + * + * Return Value: + * None + */ +GVAR(fadeScript) = scriptNull; + +// show overlay after changing weapon/optic +0 spawn { + _layer = [QGVAR(Zeroing)] call BIS_fnc_rscLayer; + while {True} do { + waitUntil {[ACE_player, 0,0] call FUNC(canAdjustScope)}; + _layer cutRsc [QGVAR(Zeroing), "PLAIN", 0, false]; + sleep 3; + _layer cutFadeOut 2; + + _weapon = currentWeapon ACE_player; + _optics = [ACE_player] call FUNC(getOptics); + waitUntil {sleep 0.05; !(_optics isEqualTo ([ACE_player] call FUNC(getOptics))) or (currentWeapon ACE_player != _weapon)}; + }; +}; + +// instantly hide when scoping in +0 spawn { + _layer = [QGVAR(Zeroing)] call BIS_fnc_rscLayer; + while {True} do { + waitUntil {sleep 0.05; cameraView == "GUNNER"}; + if !(isNull GVAR(fadeScript)) then { + terminate GVAR(fadeScript); + }; + _layer cutText ["", "PLAIN", 0]; + }; +}; diff --git a/addons/scopes/XEH_preInit.sqf b/addons/scopes/XEH_preInit.sqf new file mode 100644 index 0000000000..7cd5d3ca1a --- /dev/null +++ b/addons/scopes/XEH_preInit.sqf @@ -0,0 +1,8 @@ +#include "script_component.hpp" + +PREP(adjustScope); +PREP(canAdjustScope); +PREP(firedEH); +PREP(getOptics); +PREP(hideZeroing); +PREP(inventoryCheck); diff --git a/addons/scopes/config.cpp b/addons/scopes/config.cpp new file mode 100644 index 0000000000..c4f8d43fa6 --- /dev/null +++ b/addons/scopes/config.cpp @@ -0,0 +1,54 @@ +#include "script_component.hpp" + +class CfgPatches { + class ADDON { + units[] = {}; + weapons[] = {}; + requiredVersion = 0.60; + requiredAddons[] = { "ace_main", "ace_common" }; + version = QUOTE(VERSION); + versionStr = QUOTE(VERSION); + versionAr[] = { VERSION_AR }; + author[] = {"KoffeinFlummi"}; + authorUrl = "https://github.com/KoffeinFlummi"; + }; +}; + +#include "CfgEventHandlers.hpp" +#include "CfgSounds.hpp" +#include "CfgWeapons.hpp" + +class ACE_Default_Keys { + class adjustScopeUp { + displayName = "$STR_ACE_Scopes_AdjustUp"; + condition = QUOTE([_player] call FUNC(inventoryCheck); [_player, 0, 0.1] call FUNC(canAdjustScope)); + statement = QUOTE([_player, 0, 0.1] call FUNC(adjustScope)); + allowHolding = 1; + key = 201; + shift = 0; + control = 0; + alt = 0; + }; + class adjustScopeDown: adjustScopeUp { + displayName = "$STR_ACE_Scopes_AdjustDown"; + condition = QUOTE([_player] call FUNC(inventoryCheck); [_player, 0, -0.1] call FUNC(canAdjustScope)); + statement = QUOTE([_player, 0, -0.1] call FUNC(adjustScope)); + key = 209; + }; + class adjustScopeLeft: adjustScopeUp { + displayName = "$STR_ACE_Scopes_AdjustLeft"; + condition = QUOTE([_player] call FUNC(inventoryCheck); [_player, -0.1, 0] call FUNC(canAdjustScope)); + statement = QUOTE([_player, -0.1, 0] call FUNC(adjustScope)); + key = 209; + control = 1; + }; + class adjustScopeRight: adjustScopeLeft { + displayName = "$STR_ACE_Scopes_AdjustRight"; + condition = QUOTE([_player] call FUNC(inventoryCheck); [_player, 0.1, 0] call FUNC(canAdjustScope)); + statement = QUOTE([_player, 0.1, 0] call FUNC(adjustScope)); + key = 201; + }; +}; + +#include "RscTitles.hpp" +#include "RscInGameUI.hpp" diff --git a/addons/scopes/functions/fnc_adjustScope.sqf b/addons/scopes/functions/fnc_adjustScope.sqf new file mode 100644 index 0000000000..7db640590a --- /dev/null +++ b/addons/scopes/functions/fnc_adjustScope.sqf @@ -0,0 +1,69 @@ +/* + * Author: KoffeinFlummi + * + * Changes the adjustment for the current scope + * + * Arguments: + * 0: Horizontal adjustment + * 1: Vertical adjustment + * + * Return Value: + * True + */ + +#include "script_component.hpp" + +private ["_unit", "_weapons", "_zeroing", "_pitchbankyaw", "_pitch", "_bank", "_yaw", "_hint"]; + +_unit = _this select 0; + +_weapons = [ + primaryWeapon _unit, + secondaryWeapon _unit, + handgunWeapon _unit +]; + +if (isNil QGVAR(Adjustment)) then { + GVAR(Adjustment) = [[0,0], [0,0], [0,0]]; +}; + +_zeroing = GVAR(Adjustment) select (_weapons find (currentWeapon _unit)); +_zeroing set [0, (round (((_zeroing select 0) + (_this select 1)) * 10)) / 10]; +_zeroing set [1, (round (((_zeroing select 1) + (_this select 2)) * 10)) / 10]; + +GVAR(Adjustment) set [_weapons find (currentWeapon _unit), _zeroing]; + +playSound (["ACE_Scopes_Click_1", "ACE_Scopes_Click_2", "ACE_Scopes_Click_3"] select floor random 3); + +// slightly rotate the player if looking through optic +if (cameraView == "GUNNER") then { + _pitchbankyaw = [_unit] call EFUNC(common,getPitchBankYaw); + // these are not exact mil-to-degree conversions, but instead chosen + // to minimize the effect of rounding errors + _pitch = (_pitchbankyaw select 0) + ((_this select 2) * -0.04); + _bank = _pitchbankyaw select 1; + _yaw = (_pitchbankyaw select 2) + ((_this select 1) * -0.04); + [_unit, _pitch, _bank, _yaw] call EFUNC(common,setPitchBankYaw) +}; + +_display = uiNamespace getVariable [QGVAR(ZeroingDisplay), displayNull]; +if !(isNull _display) then { + _vertical = _display displayCtrl 925002; + _horizontal = _display displayCtrl 925003; + _vertical ctrlSetText (str (_zeroing select 1)); + _horizontal ctrlSetText (str (_zeroing select 0)); +}; + +if (!isNull (missionNamespace getVariable [QGVAR(fadeScript), scriptNull])) then { + terminate GVAR(fadeScript); +}; +if (cameraView != "GUNNER") then { + GVAR(fadeScript) = 0 spawn { + _layer = [QGVAR(Zeroing)] call BIS_fnc_rscLayer; + _layer cutRsc [QGVAR(Zeroing), "PLAIN", 0, false]; + sleep 3; + _layer cutFadeOut 2; + }; +}; + +true diff --git a/TO_MERGE/agm/Scopes/functions/fn_canAdjustScope.sqf b/addons/scopes/functions/fnc_canAdjustScope.sqf similarity index 71% rename from TO_MERGE/agm/Scopes/functions/fn_canAdjustScope.sqf rename to addons/scopes/functions/fnc_canAdjustScope.sqf index 0096bd150f..883c14bb76 100644 --- a/TO_MERGE/agm/Scopes/functions/fn_canAdjustScope.sqf +++ b/addons/scopes/functions/fnc_canAdjustScope.sqf @@ -11,33 +11,35 @@ * Can adjustment be done? (Bool) */ +#include "script_component.hpp" + private ["_unit", "_weapons", "_zeroing", "_optic", "_maxHorizontal", "_maxVertical"]; _unit = _this select 0; _weapons = [ - primaryWeapon _unit, - secondaryWeapon _unit, - handgunWeapon _unit + primaryWeapon _unit, + secondaryWeapon _unit, + handgunWeapon _unit ]; if !(currentWeapon _unit in _weapons) exitWith {false}; -if (isNil "AGM_Scopes_Adjustment") then { - AGM_Scopes_Adjustment = [[0,0], [0,0], [0,0]]; +if (isNil QGVAR(Adjustment)) then { + GVAR(Adjustment) = [[0,0], [0,0], [0,0]]; }; if (isNil "AGM_Scopes_Optics") then { - AGM_Scopes_Optics = ["", "", ""]; + GVAR(Optics) = ["", "", ""]; }; -_zeroing = AGM_Scopes_Adjustment select (_weapons find (currentWeapon _unit)); +_zeroing = GVAR(Adjustment) select (_weapons find (currentWeapon _unit)); _zeroX = (_zeroing select 0) + (_this select 1); _zeroY = (_zeroing select 1) + (_this select 2); -_optic = AGM_Scopes_Optics select (_weapons find (currentWeapon _unit)); -_maxHorizontal = getArray (configFile >> "CfgWeapons" >> _optic >> "AGM_ScopeAdjust_Horizontal"); -_maxVertical = getArray (configFile >> "CfgWeapons" >> _optic >> "AGM_ScopeAdjust_Vertical"); +_optic = GVAR(Optics) select (_weapons find (currentWeapon _unit)); +_maxHorizontal = getArray (configFile >> "CfgWeapons" >> _optic >> "ACE_ScopeAdjust_Horizontal"); +_maxVertical = getArray (configFile >> "CfgWeapons" >> _optic >> "ACE_ScopeAdjust_Vertical"); if ((count _maxHorizontal < 2) or (count _maxVertical < 2)) exitWith {false}; if ((_maxHorizontal isEqualTo [0,0]) or (_maxVertical isEqualTo [0,0])) exitWith {false}; diff --git a/TO_MERGE/agm/Scopes/functions/fn_firedEH.sqf b/addons/scopes/functions/fnc_firedEH.sqf similarity index 62% rename from TO_MERGE/agm/Scopes/functions/fn_firedEH.sqf rename to addons/scopes/functions/fnc_firedEH.sqf index 925679ef98..be294aac54 100644 --- a/TO_MERGE/agm/Scopes/functions/fn_firedEH.sqf +++ b/addons/scopes/functions/fnc_firedEH.sqf @@ -10,6 +10,8 @@ * None */ +#include "script_component.hpp" + private ["_unit", "_weaponType", "_ammoType", "_magazineType", "_round", "_weapons", "_zeroing", "_direction", "_azimuth", "_altitude", "_velocity"]; _unit = _this select 0; @@ -19,15 +21,15 @@ _round = _this select 5; _magazineType = _this select 6; _weapons = [ - primaryWeapon _unit, - secondaryWeapon _unit, - handgunWeapon _unit + primaryWeapon _unit, + secondaryWeapon _unit, + handgunWeapon _unit ]; if !(_weaponType in _weapons) exitWith {}; -_zeroing = AGM_Scopes_Adjustment select (_weapons find _weaponType); +_zeroing = QGVAR(Adjustment) select (_weapons find _weaponType); // convert zeroing from mils to degrees -_zeroing = [_zeroing, {_this * 0.05625}] call AGM_Core_fnc_map; +_zeroing = [_zeroing, {_this * 0.05625}] call EFUNC(common,map); -[_round, _zeroing select 0, _zeroing select 1, 0] call AGM_Core_fnc_changeProjectileDirection; +[_round, _zeroing select 0, _zeroing select 1, 0] call EFUNC(common,changeProjectileDirection); diff --git a/TO_MERGE/agm/Scopes/functions/fn_getOptics.sqf b/addons/scopes/functions/fnc_getOptics.sqf similarity index 78% rename from TO_MERGE/agm/Scopes/functions/fn_getOptics.sqf rename to addons/scopes/functions/fnc_getOptics.sqf index 997b1dc442..7ff2c7ea1d 100644 --- a/TO_MERGE/agm/Scopes/functions/fn_getOptics.sqf +++ b/addons/scopes/functions/fnc_getOptics.sqf @@ -10,6 +10,8 @@ * [optic of primary, optic of secondary, optic of handgun] (Array) */ +#include "script_component.hpp" + private ["_unit", "_array"]; _unit = _this select 0; @@ -19,9 +21,9 @@ _array = ["", "", ""]; if !(_unit isKindOf "CAManBase") exitWith {_array}; { - if (count _x >= 2) then { - _array set [_forEachIndex, _x select 2]; - }; + if (count _x >= 2) then { + _array set [_forEachIndex, _x select 2]; + }; } forEach [primaryWeaponItems _unit, secondaryWeaponItems _unit, handgunItems _unit]; _array diff --git a/addons/scopes/functions/fnc_hideZeroing.sqf b/addons/scopes/functions/fnc_hideZeroing.sqf new file mode 100644 index 0000000000..b41fd1dab6 --- /dev/null +++ b/addons/scopes/functions/fnc_hideZeroing.sqf @@ -0,0 +1,27 @@ +// by commy2 + +#include "script_component.hpp" + +private ["_state", "_ctrl"]; + +_state = _this select 0; + +disableSerialization; +_ctrl = (uiNamespace getVariable ['ACE_dlgWeaponZeroing', displayNull]) displayCtrl 168; + +if (_state) then { + _ctrl ctrlSetPosition [0,0,0,0]; +} else { + private "_config"; + + _config = configFile >> "RscInGameUI" >> "RscWeaponZeroing" >> "CA_Zeroing"; + + _ctrl ctrlSetPosition [ + getNumber (_config >> "x"), + getNumber (_config >> "y"), + getNumber (_config >> "w"), + getNumber (_config >> "h") + ]; +}; + +_ctrl ctrlCommit 0; diff --git a/addons/scopes/functions/fnc_inventoryCheck.sqf b/addons/scopes/functions/fnc_inventoryCheck.sqf new file mode 100644 index 0000000000..23971098d6 --- /dev/null +++ b/addons/scopes/functions/fnc_inventoryCheck.sqf @@ -0,0 +1,23 @@ +// by KoffeinFlummi / commy2 + +#include "script_component.hpp" + +private "_new"; + +_new = _this call FUNC(getOptics); + +if (isNil QGVAR(Optics)) then { + GVAR(Optics) = ["", "", ""]; +}; + +if (isNil QGVAR(Adjustment)) then { + GVAR(Adjustment) = [[0,0], [0,0], [0,0]]; +}; + +{ + if (_new select _forEachIndex != _x) then { + GVAR(Adjustment) set [_forEachIndex, [0,0]]; + }; +} forEach GVAR(Optics); + +GVAR(Optics) = _new; diff --git a/addons/scopes/functions/script_component.hpp b/addons/scopes/functions/script_component.hpp new file mode 100644 index 0000000000..acca51b4b5 --- /dev/null +++ b/addons/scopes/functions/script_component.hpp @@ -0,0 +1 @@ +#include "\z\ace\addons\scopes\script_component.hpp" diff --git a/addons/scopes/script_component.hpp b/addons/scopes/script_component.hpp new file mode 100644 index 0000000000..8c4a2cb1cd --- /dev/null +++ b/addons/scopes/script_component.hpp @@ -0,0 +1,12 @@ +#define COMPONENT scopes +#include "\z\ace\addons\main\script_mod.hpp" + +#ifdef DEBUG_ENABLED_SCOPES + #define DEBUG_MODE_FULL +#endif + +#ifdef DEBUG_SETTINGS_SCOPES + #define DEBUG_SETTINGS DEBUG_SETTINGS_SCOPES +#endif + +#include "\z\ace\addons\main\script_macros.hpp" \ No newline at end of file diff --git a/TO_MERGE/agm/Scopes/scripts/zeroingOnLoad.sqf b/addons/scopes/scripts/zeroingOnLoad.sqf similarity index 100% rename from TO_MERGE/agm/Scopes/scripts/zeroingOnLoad.sqf rename to addons/scopes/scripts/zeroingOnLoad.sqf diff --git a/TO_MERGE/agm/Scopes/sounds/agm_scopes_click.wav b/addons/scopes/sounds/agm_scopes_click.wav similarity index 100% rename from TO_MERGE/agm/Scopes/sounds/agm_scopes_click.wav rename to addons/scopes/sounds/agm_scopes_click.wav diff --git a/TO_MERGE/agm/Scopes/stringtable.xml b/addons/scopes/stringtable.xml similarity index 90% rename from TO_MERGE/agm/Scopes/stringtable.xml rename to addons/scopes/stringtable.xml index 85d4b40994..04f777241a 100644 --- a/TO_MERGE/agm/Scopes/stringtable.xml +++ b/addons/scopes/stringtable.xml @@ -1,8 +1,8 @@  - + - + Adjust Elevation Up Magasság Állítása Felfelé Optik-Elevation erhöhen @@ -13,7 +13,7 @@ Ajustar elevación arriba Вверх по вертикали - + Adjust Elevation Down Magasság Állítása Lefelé Optik-Elevation verringern @@ -24,7 +24,7 @@ Ajustar elevación abajo Вниз по вертикали - + Adjust Windage Right Oldalirány Állítása Jobbra Optik-Azimuth erhöhen @@ -35,7 +35,7 @@ Ajustar deriva a la derecha Вправо на уровне - + Adjust Windage Left Oldalirány Állítása Balra Optik-Azimuth verringern