diff --git a/addons/common/XEH_PREP.hpp b/addons/common/XEH_PREP.hpp index f1726954595..db18cd12f16 100644 --- a/addons/common/XEH_PREP.hpp +++ b/addons/common/XEH_PREP.hpp @@ -81,6 +81,8 @@ PREP(getGunner); PREP(getInPosition); PREP(getItemReplacements); PREP(getLocalUnits); +PREP(getMagneticBearing); +PREP(getMagneticBearingOffset); PREP(getMapData); PREP(getMapGridData); PREP(getMapGridFromPos); diff --git a/addons/common/functions/fnc_getMagneticBearing.sqf b/addons/common/functions/fnc_getMagneticBearing.sqf new file mode 100644 index 00000000000..212dd96ecfe --- /dev/null +++ b/addons/common/functions/fnc_getMagneticBearing.sqf @@ -0,0 +1,23 @@ +#include "..\script_component.hpp" +/* + * Author: PabstMirror + * Returns magnetic heading (0..360) + * + * Arguments: + * 0: Object or Bearing (default: ACE_player) + * + * Return Value: + * Compass Bearing + * + * Example: + * [player] call ace_common_fnc_getMagneticBearing + * + * Public: Yes + */ + +params [["_source", ACE_player, [objNull, 0]]]; + +[ + (if (_source isEqualType 0) then { _source } else { getDir _source }) + + (missionNamespace getVariable [QGVAR(magneticDeclinationOffset), 0]) +] call CBA_fnc_simplifyAngle; diff --git a/addons/common/functions/fnc_getMagneticBearingOffset.sqf b/addons/common/functions/fnc_getMagneticBearingOffset.sqf new file mode 100644 index 00000000000..d070cbfb78b --- /dev/null +++ b/addons/common/functions/fnc_getMagneticBearingOffset.sqf @@ -0,0 +1,152 @@ +#include "..\script_component.hpp" +/* + * Author: PabstMirror + * Calculate magnetic offset based on lat/long + * + * Arguments: + * None + * + * Return Value: + * None + * + * Example: + * [] call ace_common_fnc_getMagneticBearingOffset + * + * Public: No + */ + +TRACE_1("",GVAR(magneticDeclination)); + +if (!GVAR(magneticDeclination)) exitWith { + if (!isNil QGVAR(magneticDeclinationOffset)) then { // was previously set + GVAR(magneticDeclinationOffset) = nil; + setCompassDeclination 0; // reset + }; +}; + +private _long = GVAR(mapLongitude); +private _lat = GVAR(mapLatitude); + +private _size = 5; +private _data = [ +[148.667,141.133,128.969,110.073,85.876,63.866,48.485,38.446,31.613,26.636,22.794,19.716,17.209,15.167,13.526,12.242,11.272,10.563,10.046,9.638,9.243,8.766,8.135,7.315,6.331,5.256,4.192,3.232,2.424,1.754,1.146,0.468,-0.487,-2.091,-5.472,-22.385,-167.474], +[143.667,135.498,122.735,104.013,81.617,61.849,47.803,38.367,31.798,26.935,23.134,20.053,17.512,15.413,13.702,12.343,11.305,10.548,10.020,9.655,9.368,9.072,8.685,8.158,7.486,6.717,5.929,5.200,4.579,4.060,3.581,3.021,2.175,0.644,-2.820,-20.855,-162.474], +[138.667,129.945,116.786,98.516,77.850,59.960,47.029,38.122,31.800,27.059,23.316,20.253,17.697,15.556,13.781,12.346,11.230,10.408,9.845,9.491,9.280,9.137,8.982,8.755,8.426,8.007,7.542,7.088,6.685,6.337,5.998,5.562,4.826,3.361,-0.216,-19.612,-157.474], +[133.667,124.479,111.112,93.493,74.464,58.182,46.208,37.766,31.669,27.049,23.375,20.349,17.801,15.640,13.821,12.322,11.134,10.246,9.639,9.279,9.119,9.099,9.149,9.202,9.210,9.149,9.026,8.868,8.704,8.545,8.360,8.057,7.433,6.024,2.291,-18.776,-152.474], +[128.667,119.103,105.694,88.866,71.375,56.505,45.373,37.345,31.448,26.937,23.334,20.358,17.839,15.684,13.844,12.305,11.066,10.127,9.485,9.121,9.003,9.085,9.307,9.602,9.909,10.176,10.378,10.514,10.597,10.639,10.622,10.463,9.956,8.591,4.645,-18.478,-147.474], +[123.667,113.816,100.513,84.564,68.517,54.918,44.551,36.900,31.179,26.757,23.216,20.289,17.812,15.681,13.847,12.294,11.029,10.065,9.410,9.058,8.988,9.162,9.527,10.018,10.567,11.107,11.590,11.993,12.317,12.570,12.736,12.735,12.349,11.013,6.777,-18.864,-142.474], +[118.667,108.618,95.545,80.529,65.838,53.407,43.757,36.465,30.900,26.545,23.043,20.155,17.716,15.620,13.808,12.264,10.998,10.033,9.389,9.068,9.058,9.322,9.809,10.453,11.183,11.930,12.636,13.268,13.817,14.282,14.644,14.816,14.557,13.229,8.604,-20.091,-137.474], +[113.667,103.506,90.768,76.706,63.292,51.954,42.998,36.062,30.646,26.338,22.849,19.973,17.557,15.490,13.706,12.183,10.933,9.985,9.366,9.090,9.146,9.497,10.089,10.852,11.713,12.606,13.478,14.295,15.043,15.717,16.284,16.643,16.513,15.162,10.018,-22.302,-132.474], +[108.667,98.480,86.158,73.052,60.838,50.532,42.265,35.702,30.442,26.171,22.667,19.770,17.347,15.291,13.528,12.027,10.799,9.874,9.287,9.055,9.171,9.599,10.278,11.132,12.087,13.080,14.068,15.027,15.947,16.815,17.588,18.138,18.133,16.715,10.874,-25.580,-127.474], +[103.667,93.533,81.693,69.527,58.436,49.113,41.536,35.377,30.299,26.065,22.527,19.575,17.109,15.033,13.272,11.786,10.578,9.675,9.114,8.916,9.076,9.560,10.302,11.221,12.239,13.296,14.360,15.420,16.476,17.514,18.479,19.210,19.311,17.758,10.983,-29.874,-122.474], +[98.667,88.662,77.353,66.096,56.052,47.660,40.777,35.058,30.202,26.027,22.448,19.415,16.871,14.741,12.956,11.471,10.277,9.393,8.849,8.668,8.847,9.354,10.125,11.076,12.126,13.213,14.315,15.433,16.579,17.746,18.868,19.749,19.910,18.118,10.097,-34.930,-117.474], +[93.667,83.862,73.118,62.731,53.654,46.137,39.942,34.700,30.114,26.036,22.431,19.309,16.661,14.450,12.619,11.121,9.935,9.064,8.527,8.343,8.509,8.997,9.750,10.687,11.724,12.802,13.897,15.023,16.202,17.436,18.652,19.619,19.757,17.569,7.907,-40.277,-112.474], +[88.667,79.129,68.972,59.406,51.213,44.505,38.981,34.240,29.976,26.048,22.455,19.258,16.505,14.200,12.311,10.790,9.605,8.740,8.197,7.982,8.095,8.513,9.189,10.051,11.021,12.035,13.072,14.145,15.285,16.500,17.713,18.657,18.634,15.821,4.079,-45.348,-107.474], +[83.667,74.456,64.900,56.103,48.706,42.732,37.840,33.608,29.709,25.991,22.466,19.235,16.401,14.013,12.065,10.518,9.324,8.449,7.874,7.594,7.606,7.896,8.430,9.151,9.986,10.877,11.794,12.745,13.760,14.847,15.923,16.681,16.289,12.544,-1.619,-49.654,-102.474], +[78.667,69.840,60.891,52.806,46.115,40.790,36.473,32.733,29.221,25.765,22.373,19.169,16.299,13.855,11.859,10.279,9.059,8.147,7.506,7.119,6.981,7.088,7.420,7.934,8.574,9.278,10.010,10.766,11.562,12.396,13.166,13.519,12.475,7.448,-9.069,-52.912,-97.474], +[73.667,65.273,56.932,49.504,43.431,38.661,34.843,31.550,28.421,25.257,22.051,18.934,16.078,13.611,11.577,9.955,8.684,7.701,6.957,6.425,6.100,5.983,6.069,6.331,6.724,7.189,7.680,8.172,8.657,9.106,9.386,9.079,7.065,0.499,-17.538,-55.048,-92.474], +[68.667,60.753,53.016,46.190,40.648,36.335,32.925,30.007,27.221,24.346,21.352,18.360,15.556,13.087,11.019,9.339,7.992,6.911,6.039,5.344,4.818,4.467,4.292,4.283,4.401,4.593,4.801,4.977,5.077,5.032,4.657,3.463,0.240,-7.796,-25.800,-56.131,-87.474], +[63.667,56.274,49.136,42.861,37.769,33.815,30.710,28.074,25.555,22.923,20.123,17.260,14.517,12.050,9.941,8.191,6.756,5.569,4.574,3.731,3.027,2.465,2.053,1.784,1.632,1.544,1.454,1.288,0.967,0.369,-0.748,-2.928,-7.361,-16.331,-32.725,-56.294,-82.474], +[58.667,51.831,45.285,39.518,34.804,31.115,28.207,25.740,23.385,20.909,18.241,15.469,12.765,10.288,8.130,6.310,4.797,3.533,2.457,1.521,0.700,-0.010,-0.604,-1.084,-1.470,-1.811,-2.180,-2.670,-3.397,-4.528,-6.353,-9.425,-14.763,-23.866,-37.772,-55.686,-77.474], +[53.667,47.420,41.460,36.164,31.765,28.257,25.441,23.024,20.706,18.268,15.637,12.886,10.177,7.670,5.467,3.603,2.059,0.781,-0.298,-1.239,-2.085,-2.852,-3.541,-4.153,-4.703,-5.236,-5.828,-6.585,-7.649,-9.217,-11.599,-15.302,-21.071,-29.638,-40.955,-54.441,-72.474], +[48.667,43.036,37.657,32.804,28.673,25.276,22.458,19.973,17.560,15.028,12.316,9.502,6.742,4.196,1.975,0.123,-1.373,-2.571,-3.552,-4.396,-5.161,-5.880,-6.559,-7.201,-7.819,-8.455,-9.185,-10.122,-11.419,-13.286,-16.022,-20.042,-25.811,-33.500,-42.556,-52.678,-67.474], +[43.667,38.675,33.874,29.444,25.549,22.212,19.317,16.661,14.032,11.279,8.378,5.424,2.585,0.019,-2.163,-3.918,-5.269,-6.288,-7.075,-7.724,-8.311,-8.875,-9.434,-9.993,-10.570,-11.208,-11.983,-13.008,-14.434,-16.464,-19.362,-23.442,-28.938,-35.674,-42.906,-50.493,-62.474], +[38.667,34.334,30.106,26.091,22.416,19.111,16.089,13.190,10.251,7.180,4.010,0.878,-2.035,-4.571,-6.633,-8.199,-9.314,-10.073,-10.592,-10.975,-11.303,-11.621,-11.955,-12.325,-12.759,-13.307,-14.047,-15.084,-16.558,-18.648,-21.572,-25.548,-30.642,-36.492,-42.297,-47.961,-57.474], +[33.667,30.007,26.352,22.750,19.297,16.020,12.855,9.677,6.378,2.941,-0.524,-3.825,-6.763,-9.195,-11.056,-12.356,-13.172,-13.623,-13.832,-13.904,-13.915,-13.915,-13.945,-14.045,-14.262,-14.658,-15.310,-16.312,-17.783,-19.869,-22.739,-26.528,-31.189,-36.265,-40.957,-45.146,-52.474], +[28.667,25.692,22.607,19.425,16.210,12.984,9.693,6.245,2.590,-1.203,-4.932,-8.343,-11.230,-13.483,-15.078,-16.067,-16.556,-16.678,-16.556,-16.290,-15.950,-15.593,-15.277,-15.068,-15.037,-15.257,-15.801,-16.748,-18.190,-20.238,-23.014,-26.586,-30.829,-35.243,-39.057,-42.097,-47.474], +[23.667,21.384,18.869,16.116,13.169,10.037,6.672,3.008,-0.948,-5.032,-8.946,-12.379,-15.136,-17.150,-18.446,-19.107,-19.259,-19.041,-18.577,-17.958,-17.258,-16.542,-15.888,-15.384,-15.120,-15.174,-15.615,-16.503,-17.906,-19.901,-22.565,-25.913,-29.768,-33.618,-36.725,-38.853,-42.474], +[18.667,17.079,15.131,12.821,10.180,7.204,3.845,0.056,-4.101,-8.374,-12.370,-15.739,-18.304,-20.048,-21.033,-21.361,-21.165,-20.592,-19.770,-18.799,-17.758,-16.726,-15.789,-15.049,-14.601,-14.526,-14.882,-15.715,-17.071,-19.000,-21.543,-24.671,-28.171,-31.532,-34.057,-35.447,-37.474], +[13.667,12.774,11.389,9.535,7.239,4.491,1.238,-2.555,-6.787,-11.130,-15.114,-18.355,-20.700,-22.166,-22.833,-22.809,-22.239,-21.284,-20.095,-18.790,-17.460,-16.188,-15.060,-14.170,-13.608,-13.447,-13.738,-14.518,-15.818,-17.667,-20.080,-22.992,-26.164,-29.094,-31.126,-31.905,-32.474], +[8.667,8.464,7.636,6.248,4.336,1.888,-1.153,-4.817,-8.985,-13.282,-17.181,-20.272,-22.401,-23.592,-23.925,-23.510,-22.515,-21.145,-19.590,-17.993,-16.450,-15.036,-13.819,-12.872,-12.266,-12.061,-12.304,-13.027,-14.258,-16.013,-18.285,-20.981,-23.844,-26.384,-27.987,-28.249,-27.474], +[3.667,4.146,3.866,2.948,1.449,-0.635,-3.362,-6.766,-10.732,-14.878,-18.651,-21.601,-23.542,-24.464,-24.428,-23.560,-22.082,-20.270,-18.369,-16.539,-14.871,-13.412,-12.199,-11.273,-10.680,-10.465,-10.671,-11.333,-12.481,-14.126,-16.246,-18.724,-21.287,-23.465,-24.684,-24.497,-22.474], +[-1.333,-0.184,0.070,-0.380,-1.448,-3.123,-5.453,-8.480,-12.116,-16.018,-19.636,-22.470,-24.253,-24.903,-24.449,-23.060,-21.054,-18.800,-16.595,-14.604,-12.890,-11.464,-10.321,-9.468,-8.924,-8.722,-8.901,-9.501,-10.556,-12.079,-14.034,-16.286,-18.553,-20.384,-21.249,-20.663,-17.474], +[-6.333,-4.529,-3.757,-3.752,-4.388,-5.629,-7.508,-10.069,-13.266,-16.827,-20.245,-22.970,-24.605,-24.957,-24.033,-22.081,-19.546,-16.895,-14.458,-12.380,-10.684,-9.337,-8.298,-7.540,-7.063,-6.885,-7.044,-7.583,-8.541,-9.931,-11.708,-13.723,-15.689,-17.181,-17.711,-16.760,-12.474], +[-11.333,-8.893,-7.623,-7.182,-7.401,-8.213,-9.622,-11.665,-14.334,-17.448,-20.580,-23.140,-24.585,-24.589,-23.155,-20.651,-17.660,-14.719,-12.151,-10.062,-8.427,-7.178,-6.245,-5.580,-5.167,-5.014,-5.154,-5.633,-6.491,-7.737,-9.319,-11.079,-12.732,-13.885,-14.091,-12.799,-7.474], +[-16.333,-13.278,-11.535,-10.686,-10.518,-10.927,-11.884,-13.400,-15.484,-18.040,-20.741,-22.999,-24.138,-23.712,-21.757,-18.785,-15.490,-12.421,-9.850,-7.825,-6.284,-5.133,-4.290,-3.697,-3.328,-3.186,-3.301,-3.713,-4.461,-5.548,-6.912,-8.393,-9.716,-10.522,-10.410,-8.791,-2.474], +[-21.333,-17.689,-15.497,-14.274,-13.761,-13.817,-14.370,-15.393,-16.880,-18.783,-20.872,-22.606,-23.242,-22.274,-19.818,-16.525,-13.133,-10.128,-7.689,-5.805,-4.385,-3.329,-2.553,-2.001,-1.647,-1.493,-1.562,-1.890,-2.506,-3.408,-4.524,-5.694,-6.664,-7.114,-6.682,-4.742,2.526], +[-26.333,-22.128,-19.515,-17.953,-17.145,-16.911,-17.132,-17.731,-18.661,-19.871,-21.184,-22.132,-22.007,-20.356,-17.432,-13.982,-10.698,-7.927,-5.737,-4.061,-2.793,-1.834,-1.111,-0.575,-0.207,-0.010,-0.005,-0.221,-0.676,-1.357,-2.186,-3.009,-3.599,-3.679,-2.921,-0.660,7.526], +[-31.333,-26.597,-23.591,-21.730,-20.678,-20.220,-20.192,-20.460,-20.919,-21.470,-21.930,-21.878,-20.728,-18.226,-14.832,-11.341,-8.296,-5.863,-3.994,-2.572,-1.481,-0.632,0.039,0.567,0.966,1.227,1.332,1.258,0.999,0.580,0.081,-0.357,-0.538,-0.233,0.859,3.448,12.526], +[-36.333,-31.099,-27.728,-25.603,-24.356,-23.736,-23.538,-23.575,-23.676,-23.674,-23.320,-22.188,-19.831,-16.306,-12.368,-8.831,-6.039,-3.954,-2.415,-1.258,-0.361,0.364,0.968,1.481,1.906,2.235,2.451,2.542,2.511,2.393,2.266,2.250,2.502,3.209,4.646,7.576,17.526], +[-41.333,-35.636,-31.926,-29.569,-28.167,-27.437,-27.134,-27.024,-26.881,-26.462,-25.428,-23.291,-19.697,-15.036,-10.417,-6.704,-4.050,-2.227,-0.961,-0.042,0.670,1.261,1.782,2.256,2.688,3.070,3.393,3.655,3.872,4.085,4.364,4.800,5.509,6.633,8.428,11.718,22.526], +[-46.333,-40.210,-36.186,-33.622,-32.095,-31.288,-30.921,-30.722,-30.418,-29.704,-28.149,-25.187,-20.490,-14.704,-9.279,-5.194,-2.484,-0.767,0.336,1.087,1.649,2.118,2.548,2.964,3.378,3.790,4.205,4.634,5.108,5.670,6.377,7.286,8.467,10.022,12.195,15.870,27.526], +[-51.333,-44.823,-40.507,-37.753,-36.116,-35.246,-34.830,-34.563,-34.138,-33.198,-31.249,-27.657,-22.097,-15.350,-9.104,-4.487,-1.519,0.274,1.355,2.037,2.513,2.896,3.250,3.609,3.995,4.424,4.918,5.509,6.242,7.162,8.306,9.698,11.360,13.360,15.933,20.026,32.526], +[-56.333,-49.478,-44.889,-41.954,-40.206,-39.266,-38.788,-38.440,-37.886,-36.734,-34.449,-30.381,-24.222,-16.789,-9.854,-4.664,-1.300,0.726,1.921,2.643,3.117,3.474,3.793,4.121,4.496,4.951,5.532,6.292,7.288,8.568,10.149,12.022,14.170,16.628,19.629,24.181,37.526], +[-61.333,-54.175,-49.329,-46.213,-44.342,-43.304,-42.727,-42.255,-41.526,-40.126,-37.509,-33.055,-26.515,-18.701,-11.321,-5.650,-1.861,0.485,1.897,2.755,3.307,3.707,4.048,4.396,4.802,5.322,6.021,6.971,8.243,9.882,11.892,14.237,16.871,19.805,23.267,28.329,42.526], +[-66.333,-58.917,-53.827,-50.522,-48.500,-47.321,-46.588,-45.924,-44.951,-43.238,-40.252,-35.447,-28.675,-20.733,-13.179,-7.211,-3.068,-0.397,1.275,2.325,3.016,3.516,3.937,4.359,4.853,5.491,6.354,7.528,9.091,11.086,13.510,16.314,19.432,22.862,26.829,32.467,47.526], +[-71.333,-63.705,-58.384,-54.873,-52.661,-51.283,-50.321,-49.384,-48.079,-45.971,-42.559,-37.398,-30.467,-22.565,-15.059,-8.998,-4.638,-1.706,0.209,1.462,2.313,2.943,3.479,4.018,4.646,5.449,6.519,7.947,9.809,12.150,14.967,18.210,21.814,25.767,30.295,36.587,52.526], +[-76.333,-68.542,-62.999,-59.262,-56.812,-55.165,-53.889,-52.584,-50.851,-48.258,-44.350,-38.800,-31.729,-23.943,-16.628,-10.647,-6.219,-3.130,-1.034,0.388,1.386,2.145,2.802,3.472,4.253,5.242,6.535,8.221,10.373,13.035,16.213,19.875,23.966,28.478,33.637,40.684,57.526], +[-81.333,-73.429,-67.675,-63.685,-60.941,-58.947,-57.263,-55.486,-53.218,-50.043,-45.563,-39.577,-32.350,-24.703,-17.653,-11.871,-7.507,-4.374,-2.181,-0.646,0.460,1.319,2.078,2.862,3.782,4.943,6.439,8.353,10.755,13.692,17.190,21.243,25.825,30.941,36.823,44.751,62.526], +[-86.333,-78.368,-72.416,-68.144,-65.045,-62.619,-60.422,-58.060,-55.143,-51.281,-46.147,-39.677,-32.273,-24.769,-18.023,-12.521,-8.326,-5.255,-3.051,-1.470,-0.305,0.617,1.445,2.310,3.331,4.616,6.259,8.339,10.923,14.068,17.826,22.234,27.310,33.089,39.811,48.780,67.526], +[-91.333,-83.363,-77.226,-72.644,-69.126,-66.174,-63.353,-60.281,-56.589,-51.928,-46.062,-39.073,-31.494,-24.150,-17.744,-12.587,-8.648,-5.728,-3.593,-2.030,-0.854,0.094,0.956,1.864,2.939,4.287,6.003,8.162,10.837,14.102,18.044,22.756,28.322,34.831,42.545,52.761,72.526], +[-96.333,-88.415,-82.112,-77.195,-73.190,-69.613,-66.044,-62.123,-57.517,-51.941,-45.276,-37.764,-30.049,-22.916,-16.899,-12.146,-8.534,-5.844,-3.851,-2.365,-1.224,-0.284,0.583,1.501,2.583,3.934,5.642,7.787,10.450,13.730,17.758,22.699,28.735,36.048,44.947,56.682,77.526], +[-101.333,-93.526,-87.084,-81.809,-77.252,-72.943,-68.487,-63.559,-57.884,-51.276,-43.770,-35.773,-28.006,-21.162,-15.593,-11.296,-8.070,-5.673,-3.886,-2.533,-1.470,-0.574,0.268,1.163,2.211,3.506,5.133,7.172,9.716,12.891,16.882,21.943,28.395,36.582,46.913,60.528,82.526], +[-106.333,-98.700,-92.152,-86.506,-81.330,-76.173,-70.669,-64.549,-57.633,-49.884,-41.530,-33.140,-25.441,-18.977,-13.911,-10.107,-7.305,-5.247,-3.717,-2.549,-1.615,-0.806,-0.029,0.804,1.774,2.959,4.435,6.280,8.597,11.537,15.339,20.365,27.120,36.218,48.291,64.281,87.526], +[-111.333,-103.938,-97.329,-91.311,-85.453,-79.316,-72.572,-65.037,-56.687,-47.708,-38.559,-29.920,-22.435,-16.438,-11.909,-8.612,-6.249,-4.556,-3.322,-2.387,-1.632,-0.964,-0.304,0.415,1.253,2.269,3.525,5.091,7.074,9.643,13.082,17.860,24.715,34.683,48.865,67.914,92.526], +[-116.333,-109.242,-102.630,-96.254,-89.657,-82.391,-74.166,-64.938,-54.943,-44.692,-34.882,-26.201,-19.086,-13.630,-9.653,-6.854,-4.923,-3.600,-2.681,-2.016,-1.490,-1.019,-0.537,0.006,0.650,1.434,2.401,3.610,5.160,7.225,10.116,14.388,21.023,31.648,48.311,71.391,97.526], +[-121.333,-114.615,-108.071,-101.374,-93.992,-85.418,-75.399,-64.122,-52.268,-40.799,-30.579,-22.119,-15.541,-10.689,-7.265,-4.940,-3.416,-2.448,-1.847,-1.469,-1.206,-0.978,-0.729,-0.422,-0.032,0.460,1.077,1.862,2.899,4.351,6.527,10.023,16.009,26.803,46.161,74.660,102.526], +[-126.333,-120.057,-113.671,-106.719,-98.522,-88.427,-76.186,-62.399,-48.516,-36.049,-25.807,-17.881,-12.007,-7.815,-4.942,-3.064,-1.911,-1.267,-0.963,-0.867,-0.876,-0.914,-0.932,-0.900,-0.808,-0.653,-0.428,-0.108,0.371,1.148,2.505,5.011,9.895,20.038,41.772,77.643,107.526], +[-131.333,-125.569,-119.447,-112.345,-103.338,-91.456,-76.383,-59.494,-43.555,-30.561,-20.802,-13.730,-8.707,-5.227,-2.907,-1.452,-0.635,-0.277,-0.234,-0.389,-0.650,-0.946,-1.232,-1.487,-1.708,-1.905,-2.082,-2.231,-2.307,-2.198,-1.672,-0.239,3.223,11.738,34.438,80.213,112.526], +[-136.333,-131.150,-125.417,-118.321,-108.565,-94.563,-75.743,-55.026,-37.335,-24.561,-15.830,-9.877,-5.813,-3.079,-1.315,-0.271,0.236,0.346,0.173,-0.189,-0.659,-1.178,-1.706,-2.227,-2.746,-3.277,-3.832,-4.411,-4.984,-5.466,-5.678,-5.241,-3.260,2.927,23.905,82.158,117.526], +[-141.333,-136.800,-131.599,-124.725,-114.380,-97.845,-73.817,-48.519,-29.966,-18.352,-11.107,-6.440,-3.380,-1.399,-0.188,0.456,0.671,0.563,0.212,-0.309,-0.940,-1.634,-2.360,-3.110,-3.887,-4.708,-5.586,-6.521,-7.490,-8.430,-9.212,-9.571,-8.871,-5.113,11.332,83.083,122.526], +[-146.333,-142.514,-138.004,-131.648,-121.047,-101.479,-69.734,-39.521,-21.778,-12.232,-6.754,-3.416,-1.339,-0.083,0.600,0.863,0.806,0.503,0.006,-0.637,-1.389,-2.217,-3.102,-4.038,-5.029,-6.085,-7.213,-8.410,-9.654,-10.898,-12.057,-12.965,-13.219,-11.486,-0.691,82.184,127.526], +[-151.333,-148.288,-144.642,-139.183,-128.953,-105.845,-61.693,-27.966,-13.286,-6.427,-2.785,-0.718,0.453,1.054,1.262,1.183,0.886,0.414,-0.204,-0.948,-1.798,-2.738,-3.758,-4.851,-6.017,-7.255,-8.563,-9.930,-11.333,-12.739,-14.101,-15.336,-16.218,-15.941,-10.016,77.586,132.526], +[-156.333,-154.118,-151.509,-147.413,-138.659,-111.937,-46.094,-14.716,-5.053,-1.063,0.845,1.773,2.155,2.197,2.008,1.651,1.160,0.552,-0.167,-0.999,-1.941,-2.990,-4.137,-5.373,-6.688,-8.068,-9.499,-10.961,-12.432,-13.893,-15.331,-16.725,-17.981,-18.658,-16.167,64.445,137.526], +[-161.333,-159.994,-158.596,-156.391,-150.901,-123.400,-19.343,-1.568,2.471,3.810,4.198,4.153,3.878,3.469,2.972,2.406,1.776,1.071,0.272,-0.637,-1.670,-2.829,-4.104,-5.477,-6.924,-8.417,-9.930,-11.436,-12.916,-14.365,-15.799,-17.245,-18.700,-19.967,-19.686,33.766,142.526], +[-166.333,-165.908,-165.875,-166.105,-166.352,-163.756,9.995,9.785,9.035,8.181,7.313,6.467,5.661,4.898,4.170,3.460,2.739,1.973,1.122,0.152,-0.961,-2.223,-3.617,-5.115,-6.677,-8.262,-9.829,-11.350,-12.807,-14.210,-15.598,-17.034,-18.579,-20.193,-21.286,-2.315,147.526], +[-171.333,-171.850,-173.309,-176.440,175.186,112.896,29.013,18.657,14.565,12.051,10.196,8.711,7.479,6.435,5.531,4.717,3.941,3.146,2.272,1.268,0.102,-1.236,-2.723,-4.320,-5.972,-7.624,-9.227,-10.745,-12.166,-13.510,-14.835,-16.229,-17.796,-19.603,-21.544,-20.488,152.526], +[-176.333,-177.808,179.157,172.837,155.690,90.806,39.094,25.207,19.101,15.426,12.830,10.847,9.272,7.999,6.948,6.053,5.241,4.438,3.568,2.567,1.389,0.021,-1.516,-3.171,-4.879,-6.573,-8.193,-9.699,-11.080,-12.362,-13.617,-14.952,-16.500,-18.402,-20.868,-27.445,157.526], +[178.667,176.232,171.586,162.055,137.998,82.523,44.416,29.897,22.736,18.310,15.189,12.828,10.981,9.514,8.335,7.367,6.527,5.732,4.892,3.930,2.786,1.438,-0.095,-1.762,-3.488,-5.197,-6.818,-8.304,-9.641,-10.861,-12.043,-13.308,-14.811,-16.744,-19.534,-29.724,162.526], +[173.667,170.282,164.048,151.567,123.611,77.595,47.246,33.187,25.580,20.716,17.245,14.612,12.553,10.926,9.636,8.603,7.742,6.965,6.175,5.282,4.213,2.935,1.454,-0.179,-1.887,-3.584,-5.190,-6.647,-7.937,-9.093,-10.198,-11.384,-12.822,-14.744,-17.736,-29.884,167.526], +[168.667,164.356,156.613,141.669,112.398,73.966,48.677,35.437,27.746,22.662,18.978,16.159,13.944,12.193,10.813,9.726,8.851,8.100,7.374,6.573,5.613,4.443,3.058,1.499,-0.158,-1.819,-3.391,-4.808,-6.043,-7.127,-8.150,-9.249,-10.607,-12.490,-15.609,-28.988,172.526], +[163.667,158.467,149.342,132.543,103.622,70.983,49.264,36.915,29.340,24.181,20.381,17.442,15.119,13.274,11.822,10.692,9.809,9.088,8.432,7.737,6.909,5.881,4.630,3.184,1.615,0.022,-1.494,-2.851,-4.017,-5.021,-5.954,-6.957,-8.224,-10.048,-13.250,-27.552,177.526], +[158.667,152.626,142.289,124.257,96.589,68.380,49.316,37.818,30.458,25.314,21.463,18.451,16.051,14.133,12.621,11.449,10.554,9.858,9.269,8.684,8.003,7.145,6.067,4.780,3.345,1.861,0.439,-0.830,-1.906,-2.817,-3.650,-4.551,-5.719,-7.473,-10.737,-25.858,-177.474], +[153.667,146.845,135.490,116.790,90.789,66.030,49.017,38.291,31.189,26.114,22.253,19.198,16.738,14.757,13.183,11.963,11.042,10.352,9.813,9.329,8.798,8.128,7.260,6.182,4.940,3.625,2.350,1.211,0.251,-0.549,-1.274,-2.066,-3.129,-4.808,-8.127,-24.091,-172.474] +]; + +// Bilinear interpolation +private _x = (_long + 180) / _size; +private _x1 = floor _x; +private _x2 = (_x1 + 1) % (360 / _size); +_x = _x % 1; + +private _y = (_lat + 90) / _size; +private _y1 = floor _y; +private _y2 = (_y1 + 1) % (180 / _size); +_y = _y % 1; + +private _q11 = (1-_x) * (1-_y) * (_data # _x1 # _y1); +private _q12 = (1-_x) * _y * (_data # _x1 # _y2); +private _q21 = _x * (1-_y) * (_data # _x2 # _y1); +private _q22 = _x * _y * (_data # _x2 # _y2); + +GVAR(magneticDeclinationOffset) = _q11 + _q12 + _q21 + _q22; +setCompassDeclination rad GVAR(magneticDeclinationOffset); + + +/* +Table generated with https://github.com/cmweiss/geomag +gm = GeoMag("WMM.COF") +size = 5 +whole = "[" +whole_first = True +for x in range(-180, 180, size): + if (whole_first): + whole_first = False + else: + whole += "," + line = "\n[" + line_first = True + for y in range(-90, 90+size, size): + if (line_first): + line_first = False + else: + line += "," + mag = gm.GeoMag(y,x) + line += f"{mag.dec:.3f}" #f"[{x}, {y}]" + line += "]" + whole += line +whole += "\n]" +print(f"--- START ---") +print(f"{whole}") +print(f"--- END ---") +*/ diff --git a/addons/common/initSettings.inc.sqf b/addons/common/initSettings.inc.sqf index a784ac64a95..4b3a2fd9c9d 100644 --- a/addons/common/initSettings.inc.sqf +++ b/addons/common/initSettings.inc.sqf @@ -102,6 +102,16 @@ private _categorySway = [_category, LSTRING(subcategory_sway)]; 0 ] call CBA_fnc_addSetting; +[ + QGVAR(magneticDeclination), + "CHECKBOX", + [LSTRING(magneticDeclination), LSTRING(magneticDeclinationooltip)], + _category, + false, + 1, + {call FUNC(getMagneticBearingOffset)} +] call CBA_fnc_addSetting; + [ QGVAR(enableSway), "CHECKBOX", diff --git a/addons/common/stringtable.xml b/addons/common/stringtable.xml index bd8c977d6fc..884f436dc45 100644 --- a/addons/common/stringtable.xml +++ b/addons/common/stringtable.xml @@ -1793,6 +1793,12 @@ 装载 Yükle + + Realistic Compass Declination + + + Compass will point to magnetic north + Players only Pouze hráči diff --git a/addons/maptools/functions/fnc_openMapGpsUpdate.sqf b/addons/maptools/functions/fnc_openMapGpsUpdate.sqf index 6d184366255..b048e591387 100644 --- a/addons/maptools/functions/fnc_openMapGpsUpdate.sqf +++ b/addons/maptools/functions/fnc_openMapGpsUpdate.sqf @@ -30,7 +30,7 @@ if (CBA_missionTime < GVAR(mapGpsNextUpdate)) exitWith {}; GVAR(mapGpsNextUpdate) = CBA_missionTime + 0.5; private _ctrl = _mapDisplay displayCtrl 913590; -_ctrl ctrlSetText str (round (getDir ACE_player)); // Set Heading +_ctrl ctrlSetText str (round ([ACE_player] call EFUNC(common,getMagneticBearing))); // Set Heading _ctrl = _mapDisplay displayCtrl 913591; _ctrl ctrlSetText str (round ((getPosASL ACE_player) select 2) + EGVAR(common,mapAltitude)); // Set Altitude