diff --git a/addons/apl/data/default.rvmat b/addons/apl/data/default.rvmat new file mode 100644 index 0000000000..4baaa0f649 --- /dev/null +++ b/addons/apl/data/default.rvmat @@ -0,0 +1,8 @@ +ambient[]={1,1,1,1}; +diffuse[]={1,1,1,1}; +forcedDiffuse[]={0,0,0,0}; +emmisive[]={0,0,0,1}; +specular[]={0,0,0,0}; +specularPower=0; +PixelShaderID="Normal"; +VertexShaderID="Basic"; \ No newline at end of file diff --git a/addons/yardage450/$PBOPREFIX$ b/addons/yardage450/$PBOPREFIX$ new file mode 100644 index 0000000000..7efb31f23f --- /dev/null +++ b/addons/yardage450/$PBOPREFIX$ @@ -0,0 +1 @@ +z\ace\addons\yardage450 \ No newline at end of file diff --git a/addons/yardage450/CfgEventHandlers.hpp b/addons/yardage450/CfgEventHandlers.hpp new file mode 100644 index 0000000000..2a05b72298 --- /dev/null +++ b/addons/yardage450/CfgEventHandlers.hpp @@ -0,0 +1,11 @@ +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) ); + }; +}; \ No newline at end of file diff --git a/addons/yardage450/CfgVehicles.hpp b/addons/yardage450/CfgVehicles.hpp new file mode 100644 index 0000000000..ef5de319aa --- /dev/null +++ b/addons/yardage450/CfgVehicles.hpp @@ -0,0 +1,20 @@ +class CfgVehicles { + class Item_Base_F; + class ACE_Item_Yardage450: Item_Base_F { + author[] = {"Spooner", "tcp"}; + scope = 2; + scopeCurator = 2; + displayName = "$STR_ACE_Yardage450_DisplayName"; + vehicleClass = "Items"; + class TransportWeapons { + MACRO_ADDWEAPON(ACE_Yardage450,1); + }; + }; + + class Box_NATO_Support_F; + class ACE_Box_Misc: Box_NATO_Support_F { + class TransportWeapons { + MACRO_ADDWEAPON(ACE_Yardage450,4); + }; + }; +}; diff --git a/addons/yardage450/CfgWeapons.hpp b/addons/yardage450/CfgWeapons.hpp new file mode 100644 index 0000000000..2133100780 --- /dev/null +++ b/addons/yardage450/CfgWeapons.hpp @@ -0,0 +1,23 @@ + +class CfgWeapons { + class Binocular; + class ACE_Yardage450: Binocular { + author = "$STR_ACE_Common_ACETeam"; + displayName = "$STR_ACE_Yardage450_DisplayName"; + descriptionShort = "$STR_ACE_Yardage450_Description"; + model = PATHTOF(data\ace_yardage_pro_450.p3d); + modelOptics = PATHTOF(data\bushnell_optic.p3d); + picture = PATHTOF(UI\w_bushnell_ca.paa); + opticsZoomMin = 0.33333/4; + opticsZoomMax = 0.33333/4; + opticsZoomInit = 0.33333/4; + distanceZoomMin = 400; + distanceZoomMax = 400; + discretefov[] = {0.33333/4}; + discreteInitIndex = 0; + visionMode[] = {"Normal"}; + class WeaponSlotsInfo { + mass = 12; + }; + }; +}; diff --git a/addons/yardage450/README.md b/addons/yardage450/README.md new file mode 100644 index 0000000000..6301233fe4 --- /dev/null +++ b/addons/yardage450/README.md @@ -0,0 +1,10 @@ +ace_yardage450 +========== + +Adds the Bushnell Yardage Pro Sport 450 Laser Rangefinder. + +## Maintainers + +The people responsible for merging changes to this component or answering potential questions. + +- [Ruthberg] (http://github.com/Ulteq) diff --git a/addons/yardage450/RscTitles.hpp b/addons/yardage450/RscTitles.hpp new file mode 100644 index 0000000000..28fd7735e9 --- /dev/null +++ b/addons/yardage450/RscTitles.hpp @@ -0,0 +1,75 @@ +#define ST_LEFT 0 +#define ST_RIGHT 1 +#define ST_CENTER 2 + +class ACE_Yardage450_RscText { + type = 0; + idc = -1; + style = ST_CENTER; + font = "EtelkaMonospacePro"; + sizeEx = "0.027 * SafeZoneH"; + colorText[] = {0, 0, 0, 1}; + colorBackground[] = {0, 0, 0, 0}; +}; + +class RscTitles { + class ACE_RscYardage450 { + idd = -1; + movingEnable = 0; + duration = 100000; + fadein = 0; + fadeout = 0; + name = "ACE_RscYardage450"; + onLoad = "with uiNameSpace do { ACE_RscYardage450 = _this select 0; };"; + onUnload = "with uiNameSpace do { ACE_RscYardage450 = displayNull; };"; + + class Controls { + class ACE_Yardage450_RscTarget : ACE_Yardage450_RscText { + idc = 720041; + style = ST_CENTER; + x = "0.5 - (0.18 * SafeZoneH)"; + y = "0.5 - (0.25 * SafeZoneH)"; + w = "0.4 * SafeZoneH"; + h = "0.05 * SafeZoneH"; + sizeEx = "0.05 * SafeZoneH"; + text = "TARGET ACQUIRED"; + }; + class ACE_Yardage450_RscLaser : ACE_Yardage450_RscTarget { + idc = 720042; + x = "0.5 - (0.14 * SafeZoneH)"; + y = "0.5 - (0.18 * SafeZoneH)"; + w = "0.045 * SafeZoneH"; + h = "0.02 * SafeZoneH"; + sizeEx = "0.02 * SafeZoneH"; + colorText[] = {1, 1, 1, 1}; + colorBackground[] = {0, 0, 0, 1}; + text = "LASER"; + }; + class ACE_Yardage450_RscRange : ACE_Yardage450_RscTarget { + idc = 720043; + style = ST_RIGHT; + x = "0.5 - (0.02 * SafeZoneH)"; + y = "0.5 + (0.18 * SafeZoneH)"; + w = "0.08 * SafeZoneH"; + h = "0.06 * SafeZoneH"; + sizeEx = "0.06 * SafeZoneH"; + text = "---"; + }; + class ACE_Yardage450_RscMeters : ACE_Yardage450_RscLaser { + idc = 720044; + x = "0.5 + (0.06 * SafeZoneH)"; + y = "0.5 + (0.19 * SafeZoneH)"; + w = "0.05 * SafeZoneH"; + h = "0.018 * SafeZoneH"; + sizeEx = "0.018 * SafeZoneH"; + text = "METERS"; + }; + class ACE_Yardage450_RscYards : ACE_Yardage450_RscMeters { + idc = 720045; + y = "0.5 + (0.21 * SafeZoneH)"; + w = "0.0417 * SafeZoneH"; + text = "YARDS"; + }; + }; + }; +}; diff --git a/addons/yardage450/UI/w_bushnell_ca.paa b/addons/yardage450/UI/w_bushnell_ca.paa new file mode 100644 index 0000000000..85a6aca23f Binary files /dev/null and b/addons/yardage450/UI/w_bushnell_ca.paa differ diff --git a/addons/yardage450/XEH_postInit.sqf b/addons/yardage450/XEH_postInit.sqf new file mode 100644 index 0000000000..2d4ef89968 --- /dev/null +++ b/addons/yardage450/XEH_postInit.sqf @@ -0,0 +1,14 @@ +#include "script_component.hpp" + +#include "initKeybinds.sqf" + +GVAR(active) = false; + +GVAR(useYards) = false; + +GVAR(powerButtonPressed) = false; +GVAR(powerOnTime) = 0; + +GVAR(lasing) = false; +GVAR(targetAcquired) = false; +GVAR(targetRangeText) = "---"; diff --git a/addons/yardage450/XEH_preInit.sqf b/addons/yardage450/XEH_preInit.sqf new file mode 100644 index 0000000000..ad84432e0d --- /dev/null +++ b/addons/yardage450/XEH_preInit.sqf @@ -0,0 +1,8 @@ +#include "script_component.hpp" + +ADDON = false; + +PREP(acquireTarget); +PREP(turnOn); + +ADDON = true; diff --git a/addons/yardage450/config.cpp b/addons/yardage450/config.cpp new file mode 100644 index 0000000000..4d0f820aed --- /dev/null +++ b/addons/yardage450/config.cpp @@ -0,0 +1,17 @@ +#include "script_component.hpp" + +class CfgPatches { + class ADDON { + units[] = {"ACE_Item_Yardage450"}; + weapons[] = {"ACE_Yardage450"}; + requiredVersion = REQUIRED_VERSION; + requiredAddons[] = {"ace_apl", "ace_laser"}; + author[] = {"Spooner", "tcp", "Ruthberg"}; + VERSION_CONFIG; + }; +}; + +#include "CfgEventHandlers.hpp" +#include "CfgVehicles.hpp" +#include "CfgWeapons.hpp" +#include "RscTitles.hpp" diff --git a/addons/yardage450/data/Bushnell.rvmat b/addons/yardage450/data/Bushnell.rvmat new file mode 100644 index 0000000000..9f8cf9835d --- /dev/null +++ b/addons/yardage450/data/Bushnell.rvmat @@ -0,0 +1,66 @@ +ambient[]={1.000000,1.000000,1.000000,1.000000}; +diffuse[]={1.000000,1.000000,1.000000,1.000000}; +forcedDiffuse[]={0.000000,0.000000,0.000000,0.000000}; +emmisive[]={0.000000,0.000000,0.000000,1.000000}; +specular[]={0.7000000,0.700000,0.700000,1.000000}; +specularPower=20.000000; +PixelShaderID="Super"; +VertexShaderID="Super"; +class Stage1 { + texture="z\ace\addons\yardage450\data\bushnell_nohq.paa"; + uvSource="tex"; + class uvTransform { + aside[]={1.000000,0.000000,0.000000}; + up[]={0.000000,1.000000,0.000000}; + dir[]={0.000000,0.000000,0.000000}; + pos[]={0.000000,0.000000,0.000000}; + }; +}; +class Stage2 { + texture="a3\weapons_f\data\detailmaps\plast_dt.paa"; + uvSource="tex"; + class uvTransform { + aside[]={3.0000,0.000000,0.000000}; + up[]={0.000000,3.0000,0.000000}; + dir[]={0.000000,0.000000,0.000000}; + pos[]={0.000000,0.000000,0.000000}; + }; +}; +class Stage3 { + texture="#(argb,8,8,3)color(0,0,0,0)"; + uvSource="tex"; + class uvTransform { + aside[]={1.000000,0.000000,0.000000}; + up[]={0.000000,1.000000,0.000000}; + dir[]={0.000000,0.000000,0.000000}; + pos[]={0.000000,0.000000,0.000000}; + }; +}; +class Stage4 { + texture="z\ace\addons\yardage450\data\bushnell_as.paa"; + uvSource="tex"; + class uvTransform { + aside[]={1.000000,0.000000,0.000000}; + up[]={0.000000,1.000000,0.000000}; + dir[]={0.000000,0.000000,0.000000}; + pos[]={0.000000,0.000000,0.000000}; + }; +}; +class Stage5 { + texture="z\ace\addons\yardage450\data\bushnell_smdi.paa"; + uvSource="tex"; + class uvTransform { + aside[]={1.000000,0.000000,0.000000}; + up[]={0.000000,1.000000,0.000000}; + dir[]={0.000000,0.000000,0.000000}; + pos[]={0.000000,0.000000,0.000000}; + }; +}; +class Stage6 { + texture="#(ai,64,64,1)fresnel(2,2)"; + uvSource="none"; +}; +class Stage7 { + texture="a3\data_f\env_land_co.paa"; + uvSource="none"; +}; diff --git a/addons/yardage450/data/ace_yardage_pro_450.p3d b/addons/yardage450/data/ace_yardage_pro_450.p3d new file mode 100644 index 0000000000..e63b5021da Binary files /dev/null and b/addons/yardage450/data/ace_yardage_pro_450.p3d differ diff --git a/addons/yardage450/data/bushnell_as.paa b/addons/yardage450/data/bushnell_as.paa new file mode 100644 index 0000000000..44d605d59c Binary files /dev/null and b/addons/yardage450/data/bushnell_as.paa differ diff --git a/addons/yardage450/data/bushnell_co.paa b/addons/yardage450/data/bushnell_co.paa new file mode 100644 index 0000000000..9d2738ca6f Binary files /dev/null and b/addons/yardage450/data/bushnell_co.paa differ diff --git a/addons/yardage450/data/bushnell_nohq.paa b/addons/yardage450/data/bushnell_nohq.paa new file mode 100644 index 0000000000..4500e4b6cf Binary files /dev/null and b/addons/yardage450/data/bushnell_nohq.paa differ diff --git a/addons/yardage450/data/bushnell_optic.p3d b/addons/yardage450/data/bushnell_optic.p3d new file mode 100644 index 0000000000..653a25ec3c Binary files /dev/null and b/addons/yardage450/data/bushnell_optic.p3d differ diff --git a/addons/yardage450/data/bushnell_optic_ca.paa b/addons/yardage450/data/bushnell_optic_ca.paa new file mode 100644 index 0000000000..b9cfa9d1b4 Binary files /dev/null and b/addons/yardage450/data/bushnell_optic_ca.paa differ diff --git a/addons/yardage450/data/bushnell_smdi.paa b/addons/yardage450/data/bushnell_smdi.paa new file mode 100644 index 0000000000..285c120dbe Binary files /dev/null and b/addons/yardage450/data/bushnell_smdi.paa differ diff --git a/addons/yardage450/data/scope_view.paa b/addons/yardage450/data/scope_view.paa new file mode 100644 index 0000000000..626b1caaa0 Binary files /dev/null and b/addons/yardage450/data/scope_view.paa differ diff --git a/addons/yardage450/functions/fnc_acquireTarget.sqf b/addons/yardage450/functions/fnc_acquireTarget.sqf new file mode 100644 index 0000000000..1d89bf5971 --- /dev/null +++ b/addons/yardage450/functions/fnc_acquireTarget.sqf @@ -0,0 +1,60 @@ +/* + * Author: Ruthberg + * Fires the laser to acquire the target + * + * Arguments: + * Nothing + * + * Return Value: + * Nothing + * + * Example: + * + * Public: No + */ +#include "script_component.hpp" + +// Reference: http://www.optcorp.com/pdf/Bushnell/YardageProSport.pdf +#define MIN_DISTANCE ([9, 10] select GVAR(useYards)) +#define MAX_DISTANCE ([732, 800] select GVAR(useYards)) +#define METERING_POINT_NUMBER 8 + +private ["_result", "_distance", "_min", "_max", "_range"]; + +GVAR(lasing) = true; +GVAR(targetAcquired) = false; + +GVAR(distances) = []; +GVAR(distanceIndex) = -1; + +[{ + if (GVAR(targetAcquired) || !GVAR(powerButtonPressed)) exitWith { + GVAR(lasing) = false; + [_this select 1] call CBA_fnc_removePerFrameHandler; + }; + + _result = [eyePos ACE_player, ACE_player weaponDirection (currentWeapon ACE_player)] call EFUNC(laser,shootRay); + _distance = _result select 1; + + _distance = _distance - 1 + (random 2); + + GVAR(distanceIndex) = (GVAR(distanceIndex) + 1) % METERING_POINT_NUMBER; + GVAR(distances) set [GVAR(distanceIndex), _distance]; + + if (count GVAR(distances) == METERING_POINT_NUMBER) then { + _min = MAX_DISTANCE; + _max = MIN_DISTANCE; + { + _min = _x min _min; + _max = _max max _x; + } forEach GVAR(distances); + + if (abs(_max - _min) < 5) then { + _range = (_min + _max) / 2; + if (_range >= MIN_DISTANCE && _range <= MAX_DISTANCE) then { + GVAR(targetAcquired) = true; + GVAR(targetRangeText) = Str(round(_range)); + }; + }; + }; +}, 0.1, []] call CBA_fnc_addPerFrameHandler; diff --git a/addons/yardage450/functions/fnc_turnOn.sqf b/addons/yardage450/functions/fnc_turnOn.sqf new file mode 100644 index 0000000000..5f123b8cb2 --- /dev/null +++ b/addons/yardage450/functions/fnc_turnOn.sqf @@ -0,0 +1,56 @@ +/* + * Author: Ruthberg + * Shows the Yardage 450 screen elements + * + * Arguments: + * Nothing + * + * Return Value: + * Nothing + * + * Example: + * + * Public: No + */ +#include "script_component.hpp" + +#define __dsp (uiNamespace getVariable "ACE_RscYardage450") +#define __ctrlTarget (__dsp displayCtrl 720041) +#define __ctrlLaser (__dsp displayCtrl 720042) +#define __ctrlRange (__dsp displayCtrl 720043) +#define __ctrlMeters (__dsp displayCtrl 720044) +#define __ctrlYards (__dsp displayCtrl 720045) + +if (currentWeapon ACE_player != "ACE_Yardage450" || cameraView != "GUNNER") exitWith {}; + +GVAR(powerOnTime) = ACE_time; + +if (GVAR(active)) exitWith {}; + +GVAR(active) = true; + +[{ + if (ACE_time - GVAR(powerOnTime) > 30) exitWith { + GVAR(active) = false; + 74210 cutText ["", "PLAIN"]; + [_this select 1] call CBA_fnc_removePerFrameHandler; + }; + + if (currentWeapon ACE_player == "ACE_Yardage450" && cameraView == "GUNNER") then { + 74210 cutRsc ["ACE_RscYardage450", "PLAIN", 1, false]; + + __ctrlLaser ctrlShow GVAR(lasing); + if (GVAR(targetAcquired)) then { + __ctrlTarget ctrlSetText "Target Acquired"; + __ctrlRange ctrlSetText GVAR(targetRangeText); + } else { + __ctrlTarget ctrlSetText ""; + __ctrlRange ctrlSetText "---"; + }; + __ctrlMeters ctrlShow !GVAR(useYards); + __ctrlYards ctrlShow GVAR(useYards); + } else { + 74210 cutText ["", "PLAIN"]; + }; + +}, 0, []] call CBA_fnc_addPerFrameHandler; diff --git a/addons/yardage450/functions/script_component.hpp b/addons/yardage450/functions/script_component.hpp new file mode 100644 index 0000000000..ed5cf1b7c7 --- /dev/null +++ b/addons/yardage450/functions/script_component.hpp @@ -0,0 +1 @@ +#include "\z\ace\addons\yardage450\script_component.hpp" \ No newline at end of file diff --git a/addons/yardage450/initKeybinds.sqf b/addons/yardage450/initKeybinds.sqf new file mode 100644 index 0000000000..578f55ee40 --- /dev/null +++ b/addons/yardage450/initKeybinds.sqf @@ -0,0 +1,28 @@ + +["ACE3 Equipment", QGVAR(DistanceKey), localize "STR_ACE_Yardage450_PowerButtonKey", +{ + // Conditions: canInteract + if !([ACE_player, objNull, ["isNotInside"]] call EFUNC(common,canInteractWith)) exitWith {false}; + // Conditions: specific + if !(GVAR(active)) exitWith {false}; + if (currentWeapon ACE_player != "ACE_Yardage450" || cameraView != "GUNNER") exitWith {false}; + + // Statement + if !(GVAR(powerButtonPressed)) then { + GVAR(powerButtonPressed) = true; + call FUNC(acquireTarget); + }; + true +}, +{ + // Conditions: canInteract + if !([ACE_player, objNull, ["isNotInside"]] call EFUNC(common,canInteractWith)) exitWith {false}; + // Conditions: specific + if (currentWeapon ACE_player != "ACE_Yardage450" || cameraView != "GUNNER") exitWith {false}; + + // Statement + GVAR(powerButtonPressed) = false; + call FUNC(turnOn); + true +}, +[19, [false, false, false]], false] call CBA_fnc_addKeybind; //R Key diff --git a/addons/yardage450/script_component.hpp b/addons/yardage450/script_component.hpp new file mode 100644 index 0000000000..abff262efc --- /dev/null +++ b/addons/yardage450/script_component.hpp @@ -0,0 +1,12 @@ +#define COMPONENT yardage450 +#include "\z\ace\addons\main\script_mod.hpp" + +#ifdef DEBUG_ENABLED_YARDAGE450 + #define DEBUG_MODE_FULL +#endif + +#ifdef DEBUG_SETTINGS_YARDAGE450 + #define DEBUG_SETTINGS DEBUG_SETTINGS_YARDAGE450 +#endif + +#include "\z\ace\addons\main\script_macros.hpp" \ No newline at end of file diff --git a/addons/yardage450/stringtable.xml b/addons/yardage450/stringtable.xml new file mode 100644 index 0000000000..a0799bf2f5 --- /dev/null +++ b/addons/yardage450/stringtable.xml @@ -0,0 +1,16 @@ + + + + + Yardage 450 + + + Laser Rangefinder + Laserentfernungsmesser + + + Yardage 450 - Power Button + Yardage 450 - Einschalt-Taste + + +