diff --git a/README.md b/README.md
index 8721a3f217..83950e8236 100644
--- a/README.md
+++ b/README.md
@@ -1,23 +1,23 @@
-
+
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
Requires the latest version of CBA A3 | BIF thread
-**ACE 3** is a joint effort by the teams behind **ACE2**, **AGM** and **CSE** to improve the realism and authenticity of Arma 3.
+**ACE3** is a joint effort by the teams behind **ACE2**, **AGM** and **CSE** to improve the realism and authenticity of Arma 3.
This mod is entirely **open-source**, and everyone is free to propose changes or maintain their own, customized version as long as they make their changes open to the public in accordance with the GNU General Public License (for more information check the license file attached to this project).
diff --git a/TO_MERGE/agm/Optics/agm_optics_pip.p3d b/TO_MERGE/agm/Optics/agm_optics_pip.p3d
new file mode 100644
index 0000000000..d331ce4acd
Binary files /dev/null and b/TO_MERGE/agm/Optics/agm_optics_pip.p3d differ
diff --git a/TO_MERGE/agm/Optics/clientInit.sqf b/TO_MERGE/agm/Optics/clientInit.sqf
new file mode 100644
index 0000000000..7dca46fdc4
--- /dev/null
+++ b/TO_MERGE/agm/Optics/clientInit.sqf
@@ -0,0 +1,25 @@
+// TMR: Optics initialization and functions
+// (C) 2013 Ryan Schultz. See LICENSE.
+
+// Request a resource layer from the game engine.
+AGM_Optics_scopeRSC = ["AGM_Optics_Scope"] call BIS_fnc_rscLayer;
+
+// Set global variables
+AGM_Optics_inScope = false; // Is the scope up?
+AGM_Optics_currentOptic = ""; // What optic is attached right now?
+
+0 = 0 spawn {
+ waituntil {!isNull (findDisplay 46)};
+
+ [] call AGM_Optics_fnc_initScope;
+
+ // PiP technique by BadBenson
+ AGM_Optics_Camera = "camera" camCreate (positioncameratoworld [0,0,0]);
+ AGM_Optics_Camera camSetFov 0.7;
+ AGM_Optics_Camera camSetTarget player;
+ AGM_Optics_Camera camCommit 1;
+ "agm_optics_rendertarget0" setPiPEffect [2, 1.0, 1.0, 1.0, 0.0, [0.0, 1.0, 0.0, 0.25], [1.0, 0.0, 1.0, 1.0], [0.199, 0.587, 0.114, 0.0]];
+ AGM_Optics_Camera cameraEffect ["INTERNAL", "BACK","agm_optics_rendertarget0"];
+
+ waitUntil {[] call AGM_Optics_fnc_mainLoop; False};
+};
diff --git a/TO_MERGE/agm/Optics/config.cpp b/TO_MERGE/agm/Optics/config.cpp
new file mode 100644
index 0000000000..429c57cbe2
--- /dev/null
+++ b/TO_MERGE/agm/Optics/config.cpp
@@ -0,0 +1,454 @@
+class CfgPatches {
+ class AGM_Optics {
+ units[] = {};
+ weapons[] = {};
+ requiredVersion = 0.60;
+ requiredAddons[] = {AGM_Core};
+ version = 0.1;
+ author[] = {"Taosenai"};
+ authorUrl = "http://www.ryanschultz.org/tmr/";
+ };
+};
+
+class CfgFunctions {
+ class AGM_Optics {
+ class AGM_Optics {
+ file = "AGM_Optics\functions";
+ class firedEH;
+ class hideScope;
+ class initScope;
+ class mainLoop;
+ };
+ };
+};
+
+class Extended_PostInit_EventHandlers {
+ class AGM_Optics {
+ clientInit = "call compile preProcessFileLineNumbers '\AGM_Optics\clientInit.sqf'";
+ };
+};
+
+class Extended_FiredBIS_EventHandlers {
+ class CAManBase {
+ class AGM_Optics {
+ clientFiredBIS = "_this call AGM_Optics_fnc_firedEH;";
+ };
+ };
+};
+
+class CfgOpticsEffect {
+ class AGM_OpticsRadBlur1 {
+ type = "radialblur";
+ params[] = {0.015, 0, 0.14, 0.2};
+ priority = 950;
+ };
+};
+
+
+class CfgWeapons {
+ class ItemCore;
+ class InventoryItem_Base_F;
+ class InventoryMuzzleItem_Base_F;
+ class InventoryOpticsItem_Base_F;
+
+ class optic_Hamr : ItemCore {
+ displayName = "HAMR 4x";
+ descriptionShort = "High Accuracy Multi-Range Optic
Magnification: 4x
Reticle: CM-RW 6.5mm";
+ scope = 2;
+ weaponInfoType = "AGM_RscWeapon";
+
+ AGM_Optics_enhanced = 1;
+ AGM_Optics_reticle = "\AGM_Optics\data\hamr\hamr-reticle65_ca.paa";
+ AGM_Optics_reticleIllum = "\AGM_Optics\data\hamr\hamr-reticle65Illum_ca.paa";
+ AGM_Optics_body = "\AGM_Optics\data\hamr\hamr-body_ca.paa";
+ AGM_Optics_bodyNight = "\AGM_Optics\data\hamr\hamr-bodyNight_ca.paa";
+
+ model = "\A3\weapons_f\acc\acco_hamr_F";
+
+ class ItemInfo : InventoryOpticsItem_Base_F {
+ mass = 4;
+ optics = 1;
+ optictype = 1;
+ rmbhint = "HAMR";
+ modeloptics = "\AGM_Optics\agm_optics_pip.p3d";
+
+ class OpticsModes {
+ class Hamr2Collimator {
+ AGM_Optics_enhanced = 0;
+ opticsID = 1;
+ useModelOptics = 0;
+ opticsppeffects[] = {};
+ opticsFlare = 0;
+ opticsDisablePeripherialVision = 0;
+ opticsZoomMin = 0.375;
+ opticsZoomMax = 1;
+ opticsZoomInit = 0.75;
+ memoryPointCamera = "eye";
+ visionMode[] = {};
+ distanceZoomMin = 300;
+ distanceZoomMax = 300;
+ };
+
+ class Hamr2Scope {
+ cameradir = "";
+ distanceZoomMin = 300;
+ distanceZoomMax = 300;
+ memorypointcamera = "opticView";
+ opticsdisableperipherialvision = 0;
+ opticsdisplayname = "IHAMR";
+ opticsflare = 1;
+ opticsid = 2;
+ opticsppeffects[] = {"OpticsCHAbera2", "OpticsBlur1", "AGM_OpticsRadBlur1"};
+ opticszoominit = 0.0872664626;
+ opticszoommax = 0.0872664626;
+ opticszoommin = 0.0872664626;
+ discretefov[] = {0.0872664626};
+ discreteinitindex = 0;
+ usemodeloptics = 1;
+ modeloptics = "\AGM_Optics\agm_optics_pip.p3d";
+ visionmode[] = {"Normal", "NVG"};
+ };
+ };
+ };
+ };
+
+ class optic_Arco : ItemCore {
+ descriptionshort = "Advanced Rifle Combat Optic
Magnification: 4x
Reticle: SpecterDR 6.5mm";
+ displayname = "ARCO 4x";
+ picture = "\A3\weapons_F\Data\UI\gear_acco_Arco_CA.paa";
+ scope = 2;
+ weaponInfoType = "AGM_RscWeapon";
+
+ model = "\A3\weapons_f\acc\acco_Arco_F";
+
+ AGM_Optics_enhanced = 1;
+ AGM_Optics_reticle = "\AGM_Optics\data\arco\arco-reticle65_ca.paa";
+ AGM_Optics_reticleIllum = "\AGM_Optics\data\arco\arco-reticle65Illum_ca.paa";
+ AGM_Optics_body = "\AGM_Optics\data\arco\arco-body_ca.paa";
+ AGM_Optics_bodyNight = "\AGM_Optics\data\arco\arco-bodyNight_ca.paa";
+
+ class ItemInfo: InventoryOpticsItem_Base_F {
+ mass = 4;
+ optics = 1;
+ optictype = 1;
+ rmbhint = "ARCO";
+
+ class OpticsModes {
+ class ARCO2collimator {
+ AGM_Optics_enhanced = 0;
+ cameradir = "";
+ distancezoommax = 300;
+ distancezoommin = 300;
+ memorypointcamera = "eye";
+ opticsdisableperipherialvision = 0;
+ opticsdisplayname = "CQB";
+ opticsflare = 0;
+ opticsid = 1;
+ opticsppeffects[] = {};
+ opticszoominit = 0.75;
+ opticszoommax = 1.1;
+ opticszoommin = 0.375;
+ usemodeloptics = 0;
+ visionmode[] = {};
+ };
+ class ARCO2scope: ARCO2collimator {
+ cameradir = "";
+ distanceZoomMin = 300;
+ distanceZoomMax = 300;
+ memorypointcamera = "opticView";
+ opticsdisableperipherialvision = 0;
+ opticsdisplayname = "ARCO";
+ opticsflare = 1;
+ opticsid = 2;
+ opticsppeffects[] = {"OpticsCHAbera2", "OpticsBlur1", "AGM_OpticsRadBlur1"};
+ opticszoominit = 0.0872664626; // 0.0872664626 rad = 5 degrees
+ opticszoommax = 0.0872664626; // SpecterDR 4x is 6 degrees
+ opticszoommin = 0.0872664626; // Scope graphic in game covers 1 degree
+ discretefov[] = {0.0872664626};
+ discreteinitindex = 0;
+ usemodeloptics = 1;
+ modeloptics = "\AGM_Optics\data\AGM_Optics_reticle90.p3d";
+ visionmode[] = {"Normal"};
+ };
+ };
+ };
+ };
+
+ class optic_MRCO : ItemCore {
+ displayName = "MRCO 1x/4x";
+ descriptionShort = "Medium Range Combat Optic
Magnification: 1x/4x
Reticle: Pitbull Gen II 5.56mm";
+ scope = 2;
+ weaponInfoType = "AGM_RscWeapon";
+
+ AGM_Optics_enhanced = 1;
+ AGM_Optics_reticle = "\AGM_Optics\data\mrco\mrco-reticle556_ca.paa";
+ AGM_Optics_reticleIllum = "\AGM_Optics\data\mrco\mrco-reticle556Illum_ca.paa";
+ AGM_Optics_body = "\AGM_Optics\data\mrco\mrco-body_ca.paa";
+ AGM_Optics_bodyNight = "\AGM_Optics\data\mrco\mrco-bodyNight_ca.paa";
+
+ class ItemInfo : InventoryOpticsItem_Base_F {
+ opticType = 1;
+ mass = 4;
+ optics = 1;
+ modelOptics = "\A3\Weapons_f_beta\acc\reticle_MRCO_F";
+
+ class OpticsModes {
+ class MRCOcq {
+ AGM_Optics_enhanced = 0;
+ opticsID = 1;
+ useModelOptics = 0;
+ opticsPPEffects[] = {};
+ opticsFlare = 0;
+ opticsDisablePeripherialVision = 0;
+ opticsZoomMin = 0.375;
+ opticsZoomMax = 1;
+ opticsZoomInit = 0.75;
+ memoryPointCamera = "eye";
+ visionMode[] = {};
+ distanceZoomMin = 100;
+ distanceZoomMax = 100;
+ };
+
+ class MRCOscope {
+ cameradir = "";
+ distanceZoomMin = 300;
+ distanceZoomMax = 300;
+ memorypointcamera = "eye";
+ opticsdisableperipherialvision = 0;
+ opticsdisplayname = "MRCO";
+ opticsflare = 1;
+ opticsid = 2;
+ opticsppeffects[] = {"OpticsCHAbera2", "OpticsBlur2", "AGM_OpticsRadBlur1"};
+ opticszoominit = 0.0872664626;
+ opticszoommax = 0.0872664626;
+ opticszoommin = 0.0872664626;
+ discretefov[] = {0.0872664626};
+ discreteinitindex = 0;
+ usemodeloptics = 1;
+ modeloptics = "\AGM_Optics\data\AGM_Optics_reticle90.p3d";
+ visionmode[] = {"Normal"};
+ };
+ };
+ };
+ };
+
+ class optic_Nightstalker : ItemCore {
+ class ItemInfo: InventoryOpticsItem_Base_F {
+ class OpticsModes {
+ class NCTALKEP {};
+ class Iron : NCTALKEP {
+ opticsppeffects[] = {}; // Fix Arma 3 bug
+ };
+ };
+ };
+ };
+
+ class optic_SOS: ItemCore {
+ class ItemInfo: InventoryOpticsItem_Base_F {
+ modelOptics = "\AGM_Optics\agm_optics_pip.p3d";
+ class OpticsModes {
+ class Snip {
+ visionMode[] = {"Normal","TI","NVG"};
+ thermalMode[] = {5,6};
+ opticsPPEffects[] = {"OpticsCHAbera1","radblur"};
+ modelOptics[] = {"\AGM_Optics\agm_optics_pip.p3d","\AGM_Optics\agm_optics_pip.p3d"};
+ };
+ };
+
+ };
+ };
+
+ class optic_DMS : ItemCore {
+ class ItemInfo: InventoryOpticsItem_Base_F {
+ class OpticsModes {
+ class Snip {};
+ class Iron : Snip {
+ opticsppeffects[] = {}; // Fix Arma 3 bug
+ };
+ };
+ };
+ };
+
+ class optic_LRPS : ItemCore {
+ descriptionshort = "Nightforce NXS Riflescope
Magnification: 5.5-22x";
+ displayname = "NXS 5.5-22x";
+ weaponinfotype = "AGM_RscWeapon";
+
+ AGM_Optics_enhanced = 1;
+ AGM_Optics_reticle = "\AGM_Optics\data\sos\sos-reticleMLR_ca.paa";
+ AGM_Optics_reticleIllum = "\AGM_Optics\data\sos\sos-reticleMLRIllum_ca.paa";
+ AGM_Optics_body = "\AGM_Optics\data\sos\sos-body_ca.paa";
+ AGM_Optics_bodyNight = "\AGM_Optics\data\sos\sos-bodyNight_ca.paa";
+
+ class ItemInfo: InventoryOpticsItem_Base_F {
+ modeloptics = "\AGM_Optics\data\AGM_Optics_reticle90.p3d";
+ weaponinfotype = "RscWeaponRangeZeroingFOV";
+ opticType = 2; // Sniper optics
+
+ class OpticsModes {
+ // Based on Nightforce NXS 5.5-22 scope
+ class Snip {
+ cameradir = "";
+ discretedistance[] = {100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500, 1600, 1700, 1800, 1900, 2000, 2100, 2200, 2300};
+ discretedistanceinitindex = 0;
+ discreteinitindex = 0;
+ distancezoommax = 2300;
+ distancezoommin = 100;
+ memorypointcamera = "opticView";
+ modeloptics = "\AGM_Optics\data\AGM_Optics_reticle90.p3d";
+ opticsdisableperipherialvision = 1;
+ opticsdisplayname = "SOS";
+ opticsflare = 1;
+ opticsid = 1;
+ opticsppeffects[] = {"OpticsCHAbera1", "OpticsBlur1", "AGM_OpticsRadBlur1"};
+ // How to determine opticszoom
+ // First do the basic math based on the listed FOV of the scope to
+ // get a baseline FOV
+ // 0.1 meter at 100 meters = 1 mrad
+ //
+ // 5.5x FOV -- 5.3 m at 100 m = 53 mrad
+ // = 0.053 rad = 3.037 deg FOV
+
+ // 22x FOV -- 1.4 m at 100m = 14 mrad
+ // = 0.014 rad = 0.802 deg
+
+ // The FOV you give the engine is based on a rather larger scope outline, so we
+ // have to do this extra work ourselves.
+
+ // At 1680x1050
+ // The width of a TMR optic viewfield is 864px
+ // The engine viewport width (which is what the below FOV is based on) is 980
+ // (864/980) = (FOV to give engine / true FOV of optic)
+ // 864/980 * 0.053 = 0.04673
+ // 864/980 * 0.014 = 0.01234
+
+ // Measured experimentally, these values seem quite right.
+ // Certainly they're close enough after you account for pixel density, etc.
+
+ opticszoominit = 0.01234;
+ opticszoommax = 0.04673;
+ opticszoommin = 0.01234;
+ discretefov[] = {};
+ usemodeloptics = 1;
+ visionmode[] = {"Normal"};
+ };
+ };
+ };
+ };
+
+ class optic_Yorris : ItemCore {
+ descriptionshort = "Burris FastFire II Red Dot Sight
Magnification: 1x";
+ displayname = "FastFire II";
+ };
+
+ class optic_MRD : ItemCore {
+ descriptionshort = "Eotech MRDS Red Dot Sight
Magnification: 1x";
+ displayname = "MRDS";
+ };
+
+ class optic_Holosight : ItemCore {
+ descriptionshort = "Eotech XPS3 Holographic Sight
Magnification: 1x";
+ displayname = "XPS3 Holo";
+ };
+};
+
+class RscOpticsText;
+class RscOpticsValue;
+class RscInGameUI {
+ class RscUnitInfo;
+ class RscWeaponZeroing;
+ class AGM_RscWeapon : RscWeaponZeroing {
+ idd = -1;
+ controls[] = {"CA_Zeroing", "CA_FOVMode"};
+
+ onLoad ="with uiNameSpace do { AGM_OpticsIGUI = _this select 0 }";
+
+ class CA_FOVMode : RscOpticsValue {
+ idc = 154;
+ style = 2;
+ colorText[] = {0, 0, 0, 0};
+ x = 0;
+ y = 0;
+ w = 0;
+ h = 0;
+ };
+ };
+};
+
+class RscTitles {
+ class AGM_Optics_Scope {
+ idd = -1;
+ onLoad = "with uiNameSpace do { AGM_Optics_Scope = _this select 0 };";
+ onUnload = "";
+ movingEnable = 1;
+ duration = 10000;
+ controls[] = {"Reticle", "ReticleNight", "BodyNight", "Body"};
+
+ class Reticle {
+ colorBackground[] = {0,0,0, 0};
+ colorText[] = {1,1,1, 1};
+ fade = 0;
+ font = "PuristaMedium";
+ h = SafeZoneH;
+ idc = 1;
+ lineSpacing = 1.0;
+ movingEnable = 1;
+ size = 0;
+ sizeEx = 1;
+ style = 48;
+ text = "";
+ type = 0;
+ w = SafeZoneWAbs / ((getResolution select 0) / (getResolution select 1));
+ x = (SafeZoneXAbs + SafeZoneWAbs/2 - (SafeZoneWAbs / ((getResolution select 0) / (getResolution select 1)))/2);
+ y = SafeZoneY;
+ };
+
+ class ReticleNight : Reticle {
+ idc = 2;
+ text = "";
+ };
+
+ class Body : Reticle {
+ idc = 6;
+ text = "";
+ x = (SafeZoneXAbs + SafeZoneWAbs/2 - (SafeZoneWAbs / ((getResolution select 0) / (getResolution select 1))));
+ y = SafeZoneY - (SafeZoneH/2);
+ w = SafeZoneWAbs / ((getResolution select 0) / (getResolution select 1)) * 2;
+ h = SafeZoneH * 2;
+ };
+
+ class BodyNight : Body {
+ idc = 5;
+ text = "";
+ };
+ };
+};
+
+class PreloadTextures {
+ class CfgWeapons {
+ class optic_hamr {
+ AGM_Optics_body= "*";
+ AGM_Optics_bodyNight = "*";
+ AGM_Optics_reticle = "*";
+ AGM_Optics_reticleIllum = "*";
+ };
+ class optic_arco {
+ AGM_Optics_body= "*";
+ AGM_Optics_bodyNight = "*";
+ AGM_Optics_reticle = "*";
+ AGM_Optics_reticleIllum = "*";
+ };
+ class optic_mrco {
+ AGM_Optics_body= "*";
+ AGM_Optics_bodyNight = "*";
+ AGM_Optics_reticle = "*";
+ AGM_Optics_reticleIllum = "*";
+ };
+ class optic_LRPS {
+ AGM_Optics_body= "*";
+ AGM_Optics_bodyNight = "*";
+ AGM_Optics_reticle = "*";
+ AGM_Optics_reticleIllum = "*";
+ };
+ };
+};
diff --git a/TO_MERGE/agm/Optics/data/arco/arco-bodyNight_ca.paa b/TO_MERGE/agm/Optics/data/arco/arco-bodyNight_ca.paa
new file mode 100644
index 0000000000..9b186b56f4
Binary files /dev/null and b/TO_MERGE/agm/Optics/data/arco/arco-bodyNight_ca.paa differ
diff --git a/TO_MERGE/agm/Optics/data/arco/arco-body_ca.paa b/TO_MERGE/agm/Optics/data/arco/arco-body_ca.paa
new file mode 100644
index 0000000000..193b14a92c
Binary files /dev/null and b/TO_MERGE/agm/Optics/data/arco/arco-body_ca.paa differ
diff --git a/TO_MERGE/agm/Optics/data/arco/arco-reticle65Illum_ca.paa b/TO_MERGE/agm/Optics/data/arco/arco-reticle65Illum_ca.paa
new file mode 100644
index 0000000000..d193051e81
Binary files /dev/null and b/TO_MERGE/agm/Optics/data/arco/arco-reticle65Illum_ca.paa differ
diff --git a/TO_MERGE/agm/Optics/data/arco/arco-reticle65_ca.paa b/TO_MERGE/agm/Optics/data/arco/arco-reticle65_ca.paa
new file mode 100644
index 0000000000..671417fd4b
Binary files /dev/null and b/TO_MERGE/agm/Optics/data/arco/arco-reticle65_ca.paa differ
diff --git a/TO_MERGE/agm/Optics/data/black.rvmat b/TO_MERGE/agm/Optics/data/black.rvmat
new file mode 100644
index 0000000000..431d76689f
--- /dev/null
+++ b/TO_MERGE/agm/Optics/data/black.rvmat
@@ -0,0 +1,8 @@
+ambient[]={0,0,0,0.89999998};
+diffuse[]={0,0,0,0.89999998};
+forcedDiffuse[]={0,0,0,1};
+emmisive[]={0,0,0,1};
+specular[]={0,0,0,0};
+specularPower=1;
+PixelShaderID="Normal";
+VertexShaderID="Basic";
diff --git a/TO_MERGE/agm/Optics/data/em.rvmat b/TO_MERGE/agm/Optics/data/em.rvmat
new file mode 100644
index 0000000000..a491df4b9a
--- /dev/null
+++ b/TO_MERGE/agm/Optics/data/em.rvmat
@@ -0,0 +1,20 @@
+ambient[]={1,1,1,1};
+diffuse[]={1,1,1,1};
+forcedDiffuse[]={0,0,0,0};
+emmisive[]={1,1,1,1};
+specular[]={1,0.99956858,1,1};
+specularPower=1;
+PixelShaderID="Normal";
+VertexShaderID="Basic";
+class Stage1
+{
+ texture="#(argb,8,8,3)color(0.5,0.5,0.5,0.5,DT)";
+ uvSource="tex";
+ class uvTransform
+ {
+ aside[]={1,0,0};
+ up[]={0,1,0};
+ dir[]={0,0,0};
+ pos[]={0,0,0};
+ };
+};
diff --git a/TO_MERGE/agm/Optics/data/hamr/hamr-bodyNight_ca.paa b/TO_MERGE/agm/Optics/data/hamr/hamr-bodyNight_ca.paa
new file mode 100644
index 0000000000..422b13f7f1
Binary files /dev/null and b/TO_MERGE/agm/Optics/data/hamr/hamr-bodyNight_ca.paa differ
diff --git a/TO_MERGE/agm/Optics/data/hamr/hamr-body_ca.paa b/TO_MERGE/agm/Optics/data/hamr/hamr-body_ca.paa
new file mode 100644
index 0000000000..6b55916c5f
Binary files /dev/null and b/TO_MERGE/agm/Optics/data/hamr/hamr-body_ca.paa differ
diff --git a/TO_MERGE/agm/Optics/data/hamr/hamr-reticle65Illum_ca.paa b/TO_MERGE/agm/Optics/data/hamr/hamr-reticle65Illum_ca.paa
new file mode 100644
index 0000000000..7af73234fc
Binary files /dev/null and b/TO_MERGE/agm/Optics/data/hamr/hamr-reticle65Illum_ca.paa differ
diff --git a/TO_MERGE/agm/Optics/data/hamr/hamr-reticle65_ca.paa b/TO_MERGE/agm/Optics/data/hamr/hamr-reticle65_ca.paa
new file mode 100644
index 0000000000..2cbf329c89
Binary files /dev/null and b/TO_MERGE/agm/Optics/data/hamr/hamr-reticle65_ca.paa differ
diff --git a/TO_MERGE/agm/Optics/data/mrco/mrco-bodyNight_ca.paa b/TO_MERGE/agm/Optics/data/mrco/mrco-bodyNight_ca.paa
new file mode 100644
index 0000000000..381fdd3e97
Binary files /dev/null and b/TO_MERGE/agm/Optics/data/mrco/mrco-bodyNight_ca.paa differ
diff --git a/TO_MERGE/agm/Optics/data/mrco/mrco-body_ca.paa b/TO_MERGE/agm/Optics/data/mrco/mrco-body_ca.paa
new file mode 100644
index 0000000000..bfcaa9828f
Binary files /dev/null and b/TO_MERGE/agm/Optics/data/mrco/mrco-body_ca.paa differ
diff --git a/TO_MERGE/agm/Optics/data/mrco/mrco-reticle556Illum_ca.paa b/TO_MERGE/agm/Optics/data/mrco/mrco-reticle556Illum_ca.paa
new file mode 100644
index 0000000000..5bf836d593
Binary files /dev/null and b/TO_MERGE/agm/Optics/data/mrco/mrco-reticle556Illum_ca.paa differ
diff --git a/TO_MERGE/agm/Optics/data/mrco/mrco-reticle556_ca.paa b/TO_MERGE/agm/Optics/data/mrco/mrco-reticle556_ca.paa
new file mode 100644
index 0000000000..e7b8599f83
Binary files /dev/null and b/TO_MERGE/agm/Optics/data/mrco/mrco-reticle556_ca.paa differ
diff --git a/TO_MERGE/agm/Optics/data/scopeblack-100_ca.paa b/TO_MERGE/agm/Optics/data/scopeblack-100_ca.paa
new file mode 100644
index 0000000000..d0232dc0cc
Binary files /dev/null and b/TO_MERGE/agm/Optics/data/scopeblack-100_ca.paa differ
diff --git a/TO_MERGE/agm/Optics/data/scopeblack-70_ca.paa b/TO_MERGE/agm/Optics/data/scopeblack-70_ca.paa
new file mode 100644
index 0000000000..62b06d7f84
Binary files /dev/null and b/TO_MERGE/agm/Optics/data/scopeblack-70_ca.paa differ
diff --git a/TO_MERGE/agm/Optics/data/scopeblack-80_ca.paa b/TO_MERGE/agm/Optics/data/scopeblack-80_ca.paa
new file mode 100644
index 0000000000..f74e3e41f1
Binary files /dev/null and b/TO_MERGE/agm/Optics/data/scopeblack-80_ca.paa differ
diff --git a/TO_MERGE/agm/Optics/data/scopeblack-90_ca.paa b/TO_MERGE/agm/Optics/data/scopeblack-90_ca.paa
new file mode 100644
index 0000000000..2240dcc5fe
Binary files /dev/null and b/TO_MERGE/agm/Optics/data/scopeblack-90_ca.paa differ
diff --git a/TO_MERGE/agm/Optics/data/sos/sos-bodyNight_ca.paa b/TO_MERGE/agm/Optics/data/sos/sos-bodyNight_ca.paa
new file mode 100644
index 0000000000..22f008b17a
Binary files /dev/null and b/TO_MERGE/agm/Optics/data/sos/sos-bodyNight_ca.paa differ
diff --git a/TO_MERGE/agm/Optics/data/sos/sos-body_ca.paa b/TO_MERGE/agm/Optics/data/sos/sos-body_ca.paa
new file mode 100644
index 0000000000..37c6d47d63
Binary files /dev/null and b/TO_MERGE/agm/Optics/data/sos/sos-body_ca.paa differ
diff --git a/TO_MERGE/agm/Optics/data/sos/sos-reticleMLRIllum_ca.paa b/TO_MERGE/agm/Optics/data/sos/sos-reticleMLRIllum_ca.paa
new file mode 100644
index 0000000000..65d0afb2e2
Binary files /dev/null and b/TO_MERGE/agm/Optics/data/sos/sos-reticleMLRIllum_ca.paa differ
diff --git a/TO_MERGE/agm/Optics/data/sos/sos-reticleMLR_ca.paa b/TO_MERGE/agm/Optics/data/sos/sos-reticleMLR_ca.paa
new file mode 100644
index 0000000000..48bc7f4e00
Binary files /dev/null and b/TO_MERGE/agm/Optics/data/sos/sos-reticleMLR_ca.paa differ
diff --git a/TO_MERGE/agm/Optics/data/tmr_optics_reticle100.p3d b/TO_MERGE/agm/Optics/data/tmr_optics_reticle100.p3d
new file mode 100644
index 0000000000..365c9d5555
Binary files /dev/null and b/TO_MERGE/agm/Optics/data/tmr_optics_reticle100.p3d differ
diff --git a/TO_MERGE/agm/Optics/data/tmr_optics_reticle70.p3d b/TO_MERGE/agm/Optics/data/tmr_optics_reticle70.p3d
new file mode 100644
index 0000000000..cbb0181a17
Binary files /dev/null and b/TO_MERGE/agm/Optics/data/tmr_optics_reticle70.p3d differ
diff --git a/TO_MERGE/agm/Optics/data/tmr_optics_reticle80.p3d b/TO_MERGE/agm/Optics/data/tmr_optics_reticle80.p3d
new file mode 100644
index 0000000000..cbb0181a17
Binary files /dev/null and b/TO_MERGE/agm/Optics/data/tmr_optics_reticle80.p3d differ
diff --git a/TO_MERGE/agm/Optics/data/tmr_optics_reticle90.p3d b/TO_MERGE/agm/Optics/data/tmr_optics_reticle90.p3d
new file mode 100644
index 0000000000..c2f1ae5ceb
Binary files /dev/null and b/TO_MERGE/agm/Optics/data/tmr_optics_reticle90.p3d differ
diff --git a/TO_MERGE/agm/Optics/data/tmr_reticle_clear.p3d b/TO_MERGE/agm/Optics/data/tmr_reticle_clear.p3d
new file mode 100644
index 0000000000..89a29d7d8c
Binary files /dev/null and b/TO_MERGE/agm/Optics/data/tmr_reticle_clear.p3d differ
diff --git a/TO_MERGE/agm/Optics/functions/fn_firedEH.sqf b/TO_MERGE/agm/Optics/functions/fn_firedEH.sqf
new file mode 100644
index 0000000000..1030fceefd
--- /dev/null
+++ b/TO_MERGE/agm/Optics/functions/fn_firedEH.sqf
@@ -0,0 +1,149 @@
+/*
+ * Original Author: Taosenai
+ * Adapted By: KoffeinFlummi
+ *
+ * Animates the scope when firing.
+ *
+ * Arguments:
+ * 0: Unit
+ * 1: Weapon
+ * 2: Muzzle
+ * 3: Mode
+ * 4: Ammo
+ * 5: Magazine
+ * 6: Projectile
+ *
+ * Return Value:
+ * None
+ */
+
+if (_this select 0 != AGM_player) exitwith {}; // Sanity check
+
+0 = _this spawn {
+ disableSerialization;
+
+ _weaponType = _this select 1;
+ _config = configFile >> "CfgWeapons" >> _weaponType;
+ _scope = uiNameSpace getVariable "AGM_Optics_Scope";
+
+ // @todo
+ _recoilMulti = getNumber (_config >> "tmr_smallarms_recoil_shakeMultiplier"); // Will be 0 if undefined
+
+ if (_recoilMulti == 0) then {
+ _recoilMulti = 1;
+ };
+ if (_recoilMulti > 2.6) then {
+ _recoilMulti = 2.6; // Don't get too high
+ };
+
+ // Reduce the reticle movement as the player drops into lower, supported stances.
+ _detectStance = (player selectionPosition "Neck" select 2);
+ if (_detectStance < 1.3) then {
+ _recoilMulti = _recoilMulti - 0.10;
+ };
+ if (_detectStance < 0.7) then {
+ _recoilMulti = _recoilMulti - 0.20;
+ };
+
+ // Reduce reticle movement if the player is rested (tmr_autorest).
+ if (player getVariable ["tmr_autorest_rested", false]) then {
+ _recoilMulti = _recoilMulti - 0.20;
+ };
+
+ // Reduce reticle movement if the player is deployed (tmr_autorest).
+ if (player getVariable ["tmr_autorest_deployed", false]) then {
+ _recoilMulti = _recoilMulti - 0.30;
+ };
+ _recoilMulti = 1;
+ // @endtodo
+
+
+ // Constants which determine how the scope recoils
+ _recoilScope = 0.03 * _recoilMulti + random 0.0015;
+ _recoilRing = 0.03 * _recoilMulti + random 0.0015;
+
+ _randomScopeShiftX = 0.005 * _recoilMulti - random 0.011;
+
+ _randomReticleShiftX = 0.0036 * _recoilMulti + random 0.0045; // Always tend up and right;
+ _randomReticleShiftY = -0.0046 * _recoilMulti - random 0.0055;
+
+ /////////
+ // Center everything
+
+ // getResolution select 4 should return the aspect ratio, but it's totally wrong
+ // for triple head displays. We'll compute it manually.
+ _aspectRatio = (getResolution select 0) / (getResolution select 1);
+
+ _reticleX = (SafeZoneXAbs + SafeZoneWAbs/2 - (SafeZoneWAbs / _aspectRatio)/2);
+ _reticleY = SafeZoneY;
+ _reticleW = SafeZoneWAbs / _aspectRatio;
+ _reticleH = SafeZoneH;
+
+ // Reticle
+ (_scope displayCtrl 1) ctrlSetPosition [_reticleX, _reticleY, _reticleW, _reticleH];
+ // Reticle night (illum)
+ (_scope displayCtrl 2) ctrlSetPosition [_reticleX, _reticleY, _reticleW, _reticleH];
+
+ _bodyX = (SafeZoneXAbs + SafeZoneWAbs/2 - (SafeZoneWAbs / _aspectRatio));
+ _bodyY = SafeZoneY - (SafeZoneH/2);
+ _bodyW = SafeZoneWAbs / _aspectRatio * 2;
+ _bodyH = SafeZoneH * 2;
+
+ // Body night
+ (_scope displayCtrl 5) ctrlSetPosition [_bodyX, _bodyY, _bodyW, _bodyH];
+ // Body
+ (_scope displayCtrl 6) ctrlSetPosition [_bodyX, _bodyY, _bodyW, _bodyH];
+
+ _centerDelay = 0.01;
+ (_scope displayCtrl 1) ctrlCommit _centerDelay;
+ (_scope displayCtrl 2) ctrlCommit _centerDelay;
+ (_scope displayCtrl 5) ctrlCommit _centerDelay;
+ (_scope displayCtrl 6) ctrlCommit _centerDelay;
+
+ /////////
+ // Create and commit recoil effect
+
+ // Move reticle
+
+ (_scope displayCtrl 1) ctrlSetPosition [_reticleX - (_recoilScope/2) + _randomReticleShiftX, _reticleY - (_recoilScope/2) + _randomReticleShiftY, _reticleW + _recoilScope, _reticleH + _recoilScope];
+ (_scope displayCtrl 2) ctrlSetPosition [_reticleX - (_recoilScope/2) + _randomReticleShiftX, _reticleY - (_recoilScope/2) + _randomReticleShiftY, _reticleW + _recoilScope, _reticleH + _recoilScope];
+
+ // Move body
+
+ (_scope displayCtrl 5) ctrlSetPosition [_bodyX - (_recoilScope/2) + _randomScopeShiftX, _bodyY - (_recoilScope/2), _bodyW + _recoilScope, _bodyH + _recoilScope];
+ (_scope displayCtrl 6) ctrlSetPosition [_bodyX - (_recoilScope/2) + _randomScopeShiftX, _bodyY - (_recoilScope/2), _bodyW + _recoilScope, _bodyH + _recoilScope];
+
+ _recoilDelay = 0.036;
+ _fa = false;
+ _cwm = currentWeaponMode player;
+ if (_cwm == "FullAuto" || _cwm == "manual" || _cwm == "Burst") then {
+ _recoilDelay = getNumber (_config >> _cwm >> "reloadTime")/2.2;
+ _fa = true;
+ };
+ (_scope displayCtrl 1) ctrlCommit _recoilDelay;
+ (_scope displayCtrl 2) ctrlCommit _recoilDelay;
+ (_scope displayCtrl 5) ctrlCommit _recoilDelay;
+ (_scope displayCtrl 6) ctrlCommit _recoilDelay;
+
+ //////////////
+
+ waituntil {sleep 0.01; ctrlCommitted (_scope displayCtrl 6)};
+
+ //////////////
+
+ //////
+ // Bring them all back
+ (_scope displayCtrl 1) ctrlSetPosition [_reticleX, _reticleY, _reticleW, _reticleH];
+ (_scope displayCtrl 2) ctrlSetPosition [_reticleX, _reticleY, _reticleW, _reticleH];
+ (_scope displayCtrl 5) ctrlSetPosition [_bodyX, _bodyY, _bodyW, _bodyH];
+ (_scope displayCtrl 6) ctrlSetPosition [_bodyX, _bodyY, _bodyW, _bodyH];
+
+ _recenterDelay = 0.09;
+ if (_fa) then {
+ _recenterDelay = getNumber (_config >> _cwm >> "reloadTime")/2.2;
+ };
+ (_scope displayCtrl 1) ctrlCommit _recenterDelay;
+ (_scope displayCtrl 2) ctrlCommit _recenterDelay;
+ (_scope displayCtrl 5) ctrlCommit _recenterDelay;
+ (_scope displayCtrl 6) ctrlCommit _recenterDelay;
+};
diff --git a/TO_MERGE/agm/Optics/functions/fn_hideScope.sqf b/TO_MERGE/agm/Optics/functions/fn_hideScope.sqf
new file mode 100644
index 0000000000..8b048f1bd7
--- /dev/null
+++ b/TO_MERGE/agm/Optics/functions/fn_hideScope.sqf
@@ -0,0 +1,19 @@
+/*
+ * Original Author: Taosenai
+ * Adapted By: KoffeinFlummi
+ *
+ * Hides the scope.
+ *
+ */
+
+private ["_scope"];
+
+((uiNameSpace getVariable "AGM_Optics_Scope") displayCtrl 1) ctrlSetTextColor [1,1,1,0];
+((uiNameSpace getVariable "AGM_Optics_Scope") displayCtrl 2) ctrlSetTextColor [1,1,1,0];
+((uiNameSpace getVariable "AGM_Optics_Scope") displayCtrl 5) ctrlSetTextColor [1,1,1,0];
+((uiNameSpace getVariable "AGM_Optics_Scope") displayCtrl 6) ctrlSetTextColor [1,1,1,0];
+
+((uiNameSpace getVariable "AGM_Optics_Scope") displayCtrl 1) ctrlCommit 0;
+((uiNameSpace getVariable "AGM_Optics_Scope") displayCtrl 2) ctrlCommit 0;
+((uiNameSpace getVariable "AGM_Optics_Scope") displayCtrl 5) ctrlCommit 0;
+((uiNameSpace getVariable "AGM_Optics_Scope") displayCtrl 6) ctrlCommit 0;
diff --git a/TO_MERGE/agm/Optics/functions/fn_initScope.sqf b/TO_MERGE/agm/Optics/functions/fn_initScope.sqf
new file mode 100644
index 0000000000..f2e078ebbe
--- /dev/null
+++ b/TO_MERGE/agm/Optics/functions/fn_initScope.sqf
@@ -0,0 +1,25 @@
+/*
+ * Original Author: Taosenai
+ * Adapted By: KoffeinFlummi
+ *
+ * Initializes the scope resources.
+ *
+ */
+
+private ["_display"];
+
+// Make sure we only cutRsc when the resource isn't already available
+if (isNil {uiNameSpace getVariable "AGM_Optics_Scope"} or {isNull (uiNameSpace getVariable "AGM_Optics_Scope")}) exitWith {
+ AGM_Optics_scopeRSC cutRsc ["AGM_Optics_Scope","PLAIN",0];
+ ((uiNameSpace getVariable "AGM_Optics_Scope") displayCtrl 1) ctrlSetTextColor [1,1,1,0];
+ ((uiNameSpace getVariable "AGM_Optics_Scope") displayCtrl 2) ctrlSetTextColor [1,1,1,0];
+ ((uiNameSpace getVariable "AGM_Optics_Scope") displayCtrl 5) ctrlSetTextColor [1,1,1,0];
+ ((uiNameSpace getVariable "AGM_Optics_Scope") displayCtrl 6) ctrlSetTextColor [1,1,1,0];
+
+ ((uiNameSpace getVariable "AGM_Optics_Scope") displayCtrl 1) ctrlCommit 0;
+ ((uiNameSpace getVariable "AGM_Optics_Scope") displayCtrl 2) ctrlCommit 0;
+ ((uiNameSpace getVariable "AGM_Optics_Scope") displayCtrl 5) ctrlCommit 0;
+ ((uiNameSpace getVariable "AGM_Optics_Scope") displayCtrl 6) ctrlCommit 0;
+ True
+};
+False
diff --git a/TO_MERGE/agm/Optics/functions/fn_mainLoop.sqf b/TO_MERGE/agm/Optics/functions/fn_mainLoop.sqf
new file mode 100644
index 0000000000..e73b56db37
--- /dev/null
+++ b/TO_MERGE/agm/Optics/functions/fn_mainLoop.sqf
@@ -0,0 +1,94 @@
+/*
+ * Original Author: Taosenai
+ * Adapted By: KoffeinFlummi
+ *
+ * Monitors the RscInGameUI and displays the overlays when needed.
+ *
+ * Arguments:
+ * None
+ *
+ * Return Value:
+ * None
+ */
+
+if !(cameraOn == AGM_player && {alive AGM_player} && {!visibleMap} && {ctrlShown ((uinamespace getVariable "AGM_OpticsIGUI") displayCtrl 154)}) exitWith {
+ // Failed the state check, hide the scope if it's up
+ if (AGM_Optics_inScope) then {
+ // Hide the scope
+ AGM_Optics_inScope = false;
+ AGM_Optics_inScope_FOV = ([] call cba_fnc_getFOV) select 0;
+
+ [] call AGM_Optics_fnc_hideScope;
+ };
+};
+
+AGM_Optics_Camera setposATL (positioncameratoworld [0,0,0.4]);
+AGM_Optics_Camera camPrepareTarget (positioncameratoworld [0,0,50]);
+AGM_Optics_Camera camCommitPrepared 0;
+
+if (cameraView == "Gunner") then {
+ AGM_Optics_Camera camsetFOV 0.7;
+ AGM_Optics_Camera camcommit 0;
+} else {
+ AGM_Optics_Camera camsetFOV 0.01;
+ AGM_Optics_Camera camcommit 0;
+};
+
+private ["_optic", "_scope"];
+
+disableSerialization;
+
+// Get the name of the attached optic
+_optic = (primaryWeaponItems AGM_player) select 2;
+_scope = uiNameSpace getVariable "AGM_Optics_Scope";
+
+// Init the scope (if needed)
+[] call AGM_Optics_fnc_initScope;
+
+// Check if the optic has changed since we last drew it
+_doUpdateAllLayers = false;
+if (AGM_Optics_currentOptic != _optic) then {
+ AGM_Optics_currentOptic = _optic;
+ _doUpdateAllLayers = true;
+};
+
+// Check if Splendid Camera, unit switch, etc. has blanked out our displays for no good reason (grrr)
+if (ctrlText (_scope displayCtrl 1) == "") then {
+ _doUpdateAllLayers = true;
+};
+
+// Draw the correct layers (don't show them)
+if (_doUpdateAllLayers) then {
+ (_scope displayCtrl 1) ctrlSetText getText (configFile >> "CfgWeapons" >> _optic >> "AGM_Optics_reticle");
+ (_scope displayCtrl 2) ctrlSetText getText (configFile >> "CfgWeapons" >> _optic >> "AGM_Optics_reticleIllum");
+ (_scope displayCtrl 5) ctrlSetText getText (configFile >> "CfgWeapons" >> _optic >> "AGM_Optics_bodyNight");
+ (_scope displayCtrl 6) ctrlSetText getText (configFile >> "CfgWeapons" >> _optic >> "AGM_Optics_body");
+};
+
+// Stop processing if already in the scope view and FOV hasn't changed
+if (AGM_Optics_inScope) exitwith {};
+
+// Mark that we're in enhanced scope view
+AGM_Optics_inScope = true;
+
+// Calculate lighting
+_lighting = sunOrMoon; // 1 is day, 0 is night
+
+_nightOpacity = 1;
+_dayOpacity = (0 max moonIntensity * (1 - (0 max overcast)))/5;
+
+if (_lighting == 1) then {
+ _nightOpacity = 0;
+ _dayOpacity = 1;
+};
+
+// Apply lighting and make layers visible
+(_scope displayCtrl 1) ctrlSetTextColor [1,1,1,1];
+(_scope displayCtrl 2) ctrlSetTextColor [1,1,1,_nightOpacity];
+(_scope displayCtrl 5) ctrlSetTextColor [1,1,1,_nightOpacity];
+(_scope displayCtrl 6) ctrlSetTextColor [1,1,1,_dayOpacity];
+
+(_scope displayCtrl 1) ctrlCommit 0;
+(_scope displayCtrl 2) ctrlCommit 0;
+(_scope displayCtrl 5) ctrlCommit 0;
+(_scope displayCtrl 6) ctrlCommit 0;
diff --git a/addons/common/HintConfig.hpp b/addons/common/HintConfig.hpp
index 5dc0e6384a..bd74ac510a 100644
--- a/addons/common/HintConfig.hpp
+++ b/addons/common/HintConfig.hpp
@@ -53,17 +53,6 @@ class RscTitles {
};
};
- class ACE_EventHandlerHelper: ACE_Rsc_Display_Base {
- idd = -1;
- class controls {
- class CameraView: RscMapControl {
- onDraw = "if (cameraView != uiNamespace getVariable 'ACE_EventHandler_CameraMode') then {uiNamespace setVariable ['ACE_EventHandler_CameraMode', cameraView]; {[uiNamespace getVariable 'ACE_EventHandler_CameraMode'] call _x; nil} count ((missionNamespace getVariable 'ACE_EventHandler_CameraMode') select 2);};";
- idc = -1;
- w = 0;
- h = 0;
- };
- };
- };
class ACE_EventHandlerHelper2: ACE_Rsc_Display_Base {
class controls {
class MapMarkerCreated: RscMapControl {
diff --git a/addons/common/XEH_preInit.sqf b/addons/common/XEH_preInit.sqf
index de848941fd..39132e0df5 100644
--- a/addons/common/XEH_preInit.sqf
+++ b/addons/common/XEH_preInit.sqf
@@ -6,9 +6,7 @@ ADDON = false;
// ACE Common Function
PREP(addActionEventHandler);
PREP(addActionMenuEventHandler);
-PREP(addCameraEventHandler);
PREP(addCanInteractWithCondition);
-PREP(addCustomEventHandler);
PREP(addLineToDebugDraw);
PREP(addMapMarkerCreatedEventHandler);
PREP(addScrollWheelEventHandler);
@@ -21,8 +19,6 @@ PREP(beingCarried);
PREP(binarizeNumber);
PREP(blurScreen);
PREP(cachedCall);
-PREP(callCustomEventHandlers);
-PREP(callCustomEventHandlersGlobal);
PREP(canGetInPosition);
PREP(canInteract);
PREP(canInteractWith);
@@ -150,9 +146,7 @@ PREP(readSettingFromModule);
PREP(receiveRequest);
PREP(removeActionEventHandler);
PREP(removeActionMenuEventHandler);
-PREP(removeCameraEventHandler);
PREP(removeCanInteractWithCondition);
-PREP(removeCustomEventHandler);
PREP(removeMapMarkerCreatedEventHandler);
PREP(removeScrollWheelEventHandler);
PREP(removeSpecificMagazine);
@@ -258,8 +252,6 @@ if (hasInterface) then {
ACE_player = missionNamespace getVariable ["BIS_fnc_moduleRemoteControl_unit", player];
uiNamespace setVariable ["ACE_player", ACE_player];
- // Raise custom event. @todo, remove
- [missionNamespace, "playerChanged", [ACE_player, _oldPlayer]] call FUNC(callCustomEventHandlers);
// Raise ACE event
["playerChanged", [ACE_player, _oldPlayer]] call FUNC(localEvent);
};
diff --git a/addons/common/functions/fnc_addCameraEventHandler.sqf b/addons/common/functions/fnc_addCameraEventHandler.sqf
deleted file mode 100644
index 45fdb3bdca..0000000000
--- a/addons/common/functions/fnc_addCameraEventHandler.sqf
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Author: commy2
- *
- * Add a camera view event handler. The event script is called when the camera view changes.
- * The argument of the called function is stored in the _this variable and has as first element the new camera mode. Possible arguments are ["INTERNAL"], ["EXTERNAL"], ["GUNNER"] and ["GROUP"].
- *
- * Argument:
- * 0: Code to execute (Code or String)
- *
- * Return value:
- * ID of the event script (used to remove it later).
- */
-#include "script_component.hpp"
-
-private ["_statement", "_actionsVar", "_id", "_actionIDs", "_actions"];
-
-_statement = _this select 0;
-
-if (typeName _statement == "STRING") then {
- _statement = compile _statement;
-};
-
-_actionsVar = missionNamespace getVariable ["ACE_EventHandler_CameraMode", [-1, [], []]];
-
-_id = (_actionsVar select 0) + 1;
-_actionIDs = _actionsVar select 1;
-_actions = _actionsVar select 2;
-
-if (_id == 0) then {
- uiNamespace setVariable ["ACE_EventHandler_CameraMode", cameraView];
- (QGVAR(EventHandlerHelper) call BIS_fnc_rscLayer) cutRsc [QGVAR(EventHandlerHelper), "PLAIN"];
-};
-
-_actionIDs pushBack _id;
-_actions pushBack _statement;
-
-missionNamespace setVariable ["ACE_EventHandler_CameraMode", [_id, _actionIDs, _actions]];
-
-_id
diff --git a/addons/common/functions/fnc_addCustomEventHandler.sqf b/addons/common/functions/fnc_addCustomEventHandler.sqf
deleted file mode 100644
index e31730dbb3..0000000000
--- a/addons/common/functions/fnc_addCustomEventHandler.sqf
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Author: commy2
- *
- * Add a custom event to a unit. The event scripts are called by FUNC(callCustomEventHandlers).
- *
- * Argument:
- * 0: Object the event should be assigned to or namespace (Object OR Namespace)
- * 1: Name of the event (String)
- * 2: Code to execute (Code or String)
- *
- * Return value:
- * ID of the event script (used to remove it later).
- */
-#include "script_component.hpp"
-
-private ["_object", "_type", "_statement", "_name", "_actionsVar", "_id", "_actionIDs", "_actions"];
-
-_object = _this select 0;
-_type = _this select 1;
-_statement = _this select 2;
-
-if (typeName _statement == "STRING") then {
- _statement = compile _statement;
-};
-
-_name = format ["ACE_CustomEventHandlers_%1", _type];
-
-_actionsVar = _object getVariable [_name, [-1, [], []]];
-
-_id = (_actionsVar select 0) + 1;
-_actionIDs = _actionsVar select 1;
-_actions = _actionsVar select 2;
-
-_actionIDs pushBack _id;
-_actions pushBack _statement;
-
-_object setVariable [_name, [_id, _actionIDs, _actions]];
-
-_id
diff --git a/addons/common/functions/fnc_cachedCall.sqf b/addons/common/functions/fnc_cachedCall.sqf
index 0c9aafcfc8..03916b8600 100644
--- a/addons/common/functions/fnc_cachedCall.sqf
+++ b/addons/common/functions/fnc_cachedCall.sqf
@@ -1,6 +1,6 @@
/*
* Author: CAA-Picard and Jaynus
- * Returns the result of the function and caches it up to a given time
+ * Returns the result of the function and caches it up to a given time or event
*
* Arguments:
* 0: Parameters
@@ -8,6 +8,7 @@
* 2: Namespace to store the cache on
* 3: Cache uid
* 4: Max duration of the cache
+ * 5: Event that clears the cache (Optional)
*
* Return Value:
* Result of the function
@@ -20,6 +21,40 @@ EXPLODE_5_PVT(_this,_params,_function,_namespace,_uid,_duration);
if (((_namespace getVariable [_uid, [-99999]]) select 0) < diag_tickTime) then {
_namespace setVariable [_uid, [diag_tickTime + _duration, _params call _function]];
+
+ // Does the cache needs to be cleared on an event?
+ if (count _this > 5) then {
+ private ["_event","_varName","_cacheList"];
+ _event = _this select 5;
+ _varName = format [QGVAR(clearCache_%1),_event];
+ _cacheList = missionNamespace getVariable _varName;
+
+ // If there was no EH to clear these caches, add one
+ if (isNil {_cacheList}) then {
+ _cacheList = [];
+ missionNamespace setVariable [_varName, _cacheList];
+
+ [_event, {
+ private ["_varName","_cacheList"];
+ // _eventName is defined on the function that calls the event
+ #ifdef DEBUG_MODE_FULL
+ diag_log text format ["ACE: Clear cached variables on event: %1", _eventName];
+ #endif
+ // Get the list of caches to clear
+ _varName = format [QGVAR(clearCache_%1),_eventName];
+ _cacheList = missionNamespace getVariable [_varName, []];
+ // Erase all the cached results
+ {
+ _x call FUNC(eraseCache);
+ } forEach _cacheList;
+ // Empty the list
+ missionNamespace setVariable [_varName, []];
+ }] call FUNC(addEventhandler);
+ };
+
+ // Add this cache to the list of the event
+ _cacheList pushBack [_namespace, _uid];
+ };
#ifdef DEBUG_MODE_FULL
diag_log format ["Calculated result: %1 %2", _namespace, _uid];
} else {
diff --git a/addons/common/functions/fnc_callCustomEventHandlers.sqf b/addons/common/functions/fnc_callCustomEventHandlers.sqf
deleted file mode 100644
index 4b822e0754..0000000000
--- a/addons/common/functions/fnc_callCustomEventHandlers.sqf
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Author: commy2
- *
- * Execute all custom event script assigned to this object.
- *
- * Argument:
- * 0: Object the eventhandlers are assigned to or namespace (Object or Namespace)
- * 1: Name of the event (String)
- * 2: Arguments passed to the eventhandler script (Array, optional default: [Object the event handlers are assigned to])
- *
- * Return value:
- * None.
- */
-#include "script_component.hpp"
-
-private ["_object", "_type", "_argument", "_name", "_actions"];
-
-_object = _this select 0;
-_type = _this select 1;
-_argument = _this select 2;
-
-if (isNil "_argument") then {_argument = [_object]};
-
-_name = format ["ACE_CustomEventHandlers_%1", _type];
-
-_actions = (_object getVariable [_name, [-1, [], []]]) select 2;
-
-{
- _argument call _x; nil;
-} count _actions;
-nil
diff --git a/addons/common/functions/fnc_callCustomEventHandlersGlobal.sqf b/addons/common/functions/fnc_callCustomEventHandlersGlobal.sqf
deleted file mode 100644
index e1dddd5916..0000000000
--- a/addons/common/functions/fnc_callCustomEventHandlersGlobal.sqf
+++ /dev/null
@@ -1,16 +0,0 @@
-/*
- * Author: commy2
- *
- * Execute all custom event script assigned to this object on every machine.
- *
- * Argument:
- * 0: Object the eventhandlers are assigned to or namespace (Object or Namespace)
- * 1: Name of the event (String)
- * 2: Arguments passed to the eventhandler script (Array, optional default: [Object the event handlers are assigned to])
- *
- * Return value:
- * None.
- */
-#include "script_component.hpp"
-
-[_this, QUOTE(FUNC(callCustomEventHandlers)), 2] call FUNC(execRemoteFnc);
diff --git a/addons/common/functions/fnc_canInteractWith.sqf b/addons/common/functions/fnc_canInteractWith.sqf
index b74f2092b4..667aec38b3 100644
--- a/addons/common/functions/fnc_canInteractWith.sqf
+++ b/addons/common/functions/fnc_canInteractWith.sqf
@@ -1,16 +1,16 @@
/*
* Author: commy2
- *
* Check if the unit can interact.
*
* Arguments:
- * 0: The player. (Object)
- * 1: The interaction target. objNull to ignore. (Object)
- * 2: Exceptions. What general conditions are to skip? (Array)
+ * 0: The player.