This commit is contained in:
KoffeinFlummi 2015-07-25 19:35:26 +02:00
commit 88a5609016
18 changed files with 391 additions and 170 deletions

View File

@ -114,7 +114,7 @@ if (_caliber > 0 && _bulletLength > 0 && _bulletMass > 0 && _barrelTwist > 0) th
GVAR(currentbulletID) = (GVAR(currentbulletID) + 1) % 10000;
"ace_advanced_ballistics" callExtension format["new:%1:%2:%3:%4:%5:%6:%7:%8:%9:%10:%11:%12:%13:%14:%15:%16:%17:%18", GVAR(currentbulletID), _AmmoCacheEntry select 0, _AmmoCacheEntry select 6, _AmmoCacheEntry select 7, _AmmoCacheEntry select 8, _AmmoCacheEntry select 5, _stabilityFactor, _WeaponCacheEntry select 1, _muzzleVelocity, _AmmoCacheEntry select 4, getPosASL _bullet, EGVAR(weather,Latitude), EGVAR(weather,currentTemperature), EGVAR(weather,Altitude), EGVAR(weather,currentHumidity), overcast, floor(ACE_time), ACE_time - floor(ACE_time)];
"ace_advanced_ballistics" callExtension format["new:%1:%2:%3:%4:%5:%6:%7:%8:%9:%10:%11:%12:%13:%14:%15:%16:%17:%18", GVAR(currentbulletID), _AmmoCacheEntry select 0, _AmmoCacheEntry select 6, _AmmoCacheEntry select 7, _AmmoCacheEntry select 8, _AmmoCacheEntry select 5, _stabilityFactor, _WeaponCacheEntry select 1, _muzzleVelocity, _AmmoCacheEntry select 4, getPosASL _bullet, EGVAR(common,mapLatitude), EGVAR(weather,currentTemperature), EGVAR(common,mapAltitude), EGVAR(weather,currentHumidity), overcast, floor(ACE_time), ACE_time - floor(ACE_time)];
[{
private ["_args", "_index", "_bullet", "_caliber", "_bulletTraceVisible", "_bulletVelocity", "_bulletPosition"];

View File

@ -37,6 +37,14 @@
};
}] call FUNC(addEventhandler);
//~~~~~Get Map Data~~~~~
//Find MGRS zone and 100km grid for current map
[] call FUNC(getMGRSdata);
//Prepare variables for FUNC(getMapGridFromPos)/FUNC(getMapPosFromGrid)
[] call FUNC(getMapGridData);
["fixCollision", DFUNC(fixCollision)] call FUNC(addEventhandler);
["fixFloating", DFUNC(fixFloating)] call FUNC(addEventhandler);
["fixPosition", DFUNC(fixPosition)] call FUNC(addEventhandler);

View File

@ -69,7 +69,11 @@ PREP(getFirstTerrainIntersection);
PREP(getForceWalkStatus);
PREP(getGunner);
PREP(getInPosition);
PREP(getMapGridData);
PREP(getMapGridFromPos);
PREP(getMapPosFromGrid);
PREP(getMarkerType);
PREP(getMGRSdata);
PREP(getName);
PREP(getNumberFromMissionSQM);
PREP(getNumberMagazinesIn);

View File

@ -0,0 +1,165 @@
/*
* Author: VKing
* Gets the current map's MGRS grid zone designator and 100km square.
* Also gets longitude, latitude and altitude offset for the map
*
* Argument:
* 0: Optional: Map name, if undefined the current map is used (String)
*
* Return value:
* 0: Grid zone designator (String)
* 1: 100km square (String)
* 2: GZD + 100km sq. as a single string (String)
* Writes return values to GVAR(MGRS_data) if run on the current map
*/
// #define DEBUG_MODE_FULL
#include "script_component.hpp"
private ["_zone","_band","_GZD","_long","_lat","_UTM","_easting","_northing", "_altitude"];
DEFAULT_PARAM(0,_map,worldName);
_long = getNumber (ConfigFile >> "CfgWorlds" >> _map >> "longitude");
_lat = getNumber (ConfigFile >> "CfgWorlds" >> _map >> "latitude");
_altitude = getNumber (ConfigFile >> "CfgWorlds" >> _map >> "elevationOffset");
if (_map in ["Chernarus", "Bootcamp_ACR", "Woodland_ACR", "utes"]) then { _lat = 50; _altitude = 0; };
if (_map in ["Altis", "Stratis"]) then { _lat = 40; _altitude = 0; };
if (_map in ["Takistan", "Zargabad", "Mountains_ACR"]) then { _lat = 35; _altitude = 2000; };
if (_map in ["Shapur_BAF", "ProvingGrounds_PMC"]) then { _lat = 35; _altitude = 100; };
if (_map in ["fallujah"]) then { _lat = 33; _altitude = 0; };
if (_map in ["fata", "Abbottabad"]) then { _lat = 30; _altitude = 1000; };
if (_map in ["sfp_wamako"]) then { _lat = 14; _altitude = 0; };
if (_map in ["sfp_sturko"]) then { _lat = 56; _altitude = 0; };
if (_map in ["Bornholm"]) then { _lat = 55; _altitude = 0; };
if (_map in ["Imrali"]) then { _lat = 40; _altitude = 0; };
if (_map in ["Caribou"]) then { _lat = 68; _altitude = 0; };
if (_map in ["Namalsk"]) then { _lat = 65; _altitude = 0; };
if (_map in ["MCN_Aliabad"]) then { _lat = 36; _altitude = 0; };
if (_map in ["Clafghan"]) then { _lat = 34; _altitude = 640; };
if (_map in ["Sangin", "hellskitchen"]) then { _lat = 32; _altitude = 0; };
if (_map in ["Sara"]) then { _lat = 40; _altitude = 0; };
if (_map in ["reshmaan"]) then { _lat = 35; _altitude = 2000; };
if (_map in ["Thirsk"]) then { _lat = 65; _altitude = 0; };
if (_map in ["lingor"]) then { _lat = -4; _altitude = 0; };
if (_map in ["Panthera3"]) then { _lat = 46; _altitude = 0; };
if (_map in ["Kunduz"]) then { _lat = 37; _altitude = 400; };
_UTM = [_long,_lat] call BIS_fnc_posDegToUTM;
_easting = _UTM select 0;
_northing = _UTM select 1;
// _zone = _UTM select 2;
TRACE_4("",_UTM,_easting,_northing,_zone);
/*
_band = switch (true) do {
case (_lat<-72): {"C"};
case (_lat<-64): {"D"};
case (_lat<-56): {"E"};
case (_lat<-48): {"F"};
case (_lat<-40): {"G"};
case (_lat<-32): {"H"};
case (_lat<-24): {"J"};
case (_lat<-16): {"K"};
case (_lat<-8): {"L"};
case (_lat<0): {"M"};
case (_lat>72): {"X"};
case (_lat>64): {"W"};
case (_lat>56): {"V"};
case (_lat>48): {"U"};
case (_lat>40): {"T"};
case (_lat>32): {"S"};
case (_lat>24): {"R"};
case (_lat>16): {"Q"};
case (_lat>8): {"P"};
case (_lat>=0): {"N"};
};
*/
_zone = 1 + (floor ((_long + 180) / 6));
_band = "Z";
if (_lat <= -80) then {
_band = "A";
} else {
if (_lat < 84) then {
_band = "CDEFGHJKLMNPQRSTUVWXX" select [(floor ((_lat / 8) + 10)), 1];
};
};
if (_map == "VR") then {_zone = 0; _band = "RV";};
_GZD = format ["%1%2",_zone,_band];
TRACE_3("",_zone,_band,_GZD);
private ["_set1","_set2","_set3","_set4","_set5","_set6","_metaE","_metaN","_letterE","_letterN","_grid100km"];
_set1 = [1,7,13,19,25,31,37,43,49,55];
_set2 = [2,8,14,20,26,32,38,44,50,56];
_set3 = [3,9,15,21,27,33,39,45,51,57];
_set4 = [4,10,16,22,28,34,40,46,52,58];
_set5 = [5,11,17,23,29,35,41,47,53,59];
_set6 = [6,12,18,24,30,36,42,48,54,60];
switch (true) do {
case (_zone in _set1): {_metaE = 1; _metaN = 1;};
case (_zone in _set2): {_metaE = 2; _metaN = 2;};
case (_zone in _set3): {_metaE = 3; _metaN = 1;};
case (_zone in _set4): {_metaE = 1; _metaN = 2;};
case (_zone in _set5): {_metaE = 2; _metaN = 1;};
case (_zone in _set6): {_metaE = 3; _metaN = 2;};
};
TRACE_2("",_metaE,_metaN);
switch (true) do {
case (_zone == 0): {_letterE = "E"};
case (_easting > 800000): {LOG("E8"); switch (_metaE) do {case 1: {_letterE="H"}; case 2: {_letterE="R"}; case 3: {_letterE="Z"}; }; };
case (_easting > 700000): {LOG("E7"); switch (_metaE) do {case 1: {_letterE="G"}; case 2: {_letterE="Q"}; case 3: {_letterE="Y"}; }; };
case (_easting > 600000): {LOG("E6"); switch (_metaE) do {case 1: {_letterE="F"}; case 2: {_letterE="P"}; case 3: {_letterE="X"}; }; };
case (_easting > 500000): {LOG("E5"); switch (_metaE) do {case 1: {_letterE="E"}; case 2: {_letterE="N"}; case 3: {_letterE="W"}; }; };
case (_easting > 400000): {LOG("E4"); switch (_metaE) do {case 1: {_letterE="D"}; case 2: {_letterE="M"}; case 3: {_letterE="V"}; }; };
case (_easting > 300000): {LOG("E3"); switch (_metaE) do {case 1: {_letterE="C"}; case 2: {_letterE="L"}; case 3: {_letterE="U"}; }; };
case (_easting > 200000): {LOG("E2"); switch (_metaE) do {case 1: {_letterE="B"}; case 2: {_letterE="K"}; case 3: {_letterE="T"}; }; };
case (_easting > 100000): {LOG("E1"); switch (_metaE) do {case 1: {_letterE="A"}; case 2: {_letterE="J"}; case 3: {_letterE="S"}; }; };
default {_letterE="@"};
};
TRACE_1("",_letterE);
_northing = _northing mod 2000000;
TRACE_1("",_northing);
switch (true) do {
case (_zone == 0): {_letterN = "N"};
case (_northing > 1900000): {LOG("N19"); switch (_metaN) do {case 1: {_letterN = "V"}; case 2: {_letterN = "E"}; }; };
case (_northing > 1800000): {LOG("N18"); switch (_metaN) do {case 1: {_letterN = "U"}; case 2: {_letterN = "D"}; }; };
case (_northing > 1700000): {LOG("N17"); switch (_metaN) do {case 1: {_letterN = "T"}; case 2: {_letterN = "C"}; }; };
case (_northing > 1600000): {LOG("N16"); switch (_metaN) do {case 1: {_letterN = "S"}; case 2: {_letterN = "B"}; }; };
case (_northing > 1500000): {LOG("N15"); switch (_metaN) do {case 1: {_letterN = "R"}; case 2: {_letterN = "A"}; }; };
case (_northing > 1400000): {LOG("N14"); switch (_metaN) do {case 1: {_letterN = "Q"}; case 2: {_letterN = "V"}; }; };
case (_northing > 1300000): {LOG("N13"); switch (_metaN) do {case 1: {_letterN = "P"}; case 2: {_letterN = "U"}; }; };
case (_northing > 1200000): {LOG("N12"); switch (_metaN) do {case 1: {_letterN = "N"}; case 2: {_letterN = "T"}; }; };
case (_northing > 1100000): {LOG("N11"); switch (_metaN) do {case 1: {_letterN = "M"}; case 2: {_letterN = "S"}; }; };
case (_northing > 1000000): {LOG("N10"); switch (_metaN) do {case 1: {_letterN = "L"}; case 2: {_letterN = "R"}; }; };
case (_northing > 900000): {LOG("N09"); switch (_metaN) do {case 1: {_letterN = "K"}; case 2: {_letterN = "Q"}; }; };
case (_northing > 800000): {LOG("N08"); switch (_metaN) do {case 1: {_letterN = "J"}; case 2: {_letterN = "P"}; }; };
case (_northing > 700000): {LOG("N07"); switch (_metaN) do {case 1: {_letterN = "H"}; case 2: {_letterN = "N"}; }; };
case (_northing > 600000): {LOG("N06"); switch (_metaN) do {case 1: {_letterN = "G"}; case 2: {_letterN = "M"}; }; };
case (_northing > 500000): {LOG("N05"); switch (_metaN) do {case 1: {_letterN = "F"}; case 2: {_letterN = "L"}; }; };
case (_northing > 400000): {LOG("N04"); switch (_metaN) do {case 1: {_letterN = "E"}; case 2: {_letterN = "K"}; }; };
case (_northing > 300000): {LOG("N03"); switch (_metaN) do {case 1: {_letterN = "D"}; case 2: {_letterN = "J"}; }; };
case (_northing > 200000): {LOG("N02"); switch (_metaN) do {case 1: {_letterN = "C"}; case 2: {_letterN = "H"}; }; };
case (_northing > 100000): {LOG("N01"); switch (_metaN) do {case 1: {_letterN = "B"}; case 2: {_letterN = "G"}; }; };
case (_northing > 0): {LOG("N00"); switch (_metaN) do {case 1: {_letterN = "A"}; case 2: {_letterN = "F"}; }; };
};
TRACE_1("",_letterN);
_grid100km = _letterE+_letterN;
TRACE_1("",_grid100km);
if (_map == worldName) then {
GVAR(MGRS_data) = [_GZD,_grid100km,_GZD+_grid100km];
GVAR(mapAltitude) = _altitude;
GVAR(mapLatitude) = _lat;
GVAR(mapLongitude) = _long;
};
[_GZD,_grid100km,_GZD+_grid100km]

View File

@ -0,0 +1,76 @@
/*
* Author: PabstMirror (ideas from Nou's mapGridToPos and BIS_fnc_gridToPos)
* Finds real x/y offset and map step for a 10 digit grid
* Save time by preparing data one time at startup
*
* Argument:
* None
*
* Return values:
* None
*
* Example:
* [] call ace_map_fnc_getMapGridData
*
* Public: No
*/
#include "script_component.hpp"
private["_cfgGrid", "_formatX", "_formatY", "_heightOffset", "_offsetX", "_offsetY", "_originGrid", "_realOffsetY", "_startGrid", "_stepX", "_stepY", "_zoom", "_zoomMax", "_letterGrid"];
GVAR(mapGridData) = [];
//--- Extract grid values from world config (Borrowed from BIS_fnc_gridToPos)
_cfgGrid = configFile >> "CfgWorlds" >> worldName >> "Grid";
_offsetX = getNumber (_cfgGrid >> "offsetX");
_offsetY = getNumber (_cfgGrid >> "offsetY");
_zoomMax = 1e99;
_formatX = "";
_formatY = "";
_stepX = 1e10;
_stepY = 1e10;
{
_zoom = getnumber (_x >> "zoomMax");
if (_zoom < _zoomMax) then {
_zoomMax = _zoom;
_formatX = getText (_x >> "formatX");
_formatY = getText (_x >> "formatY");
_stepX = getNumber (_x >> "stepX");
_stepY = getNumber (_x >> "stepY");
};
} foreach configProperties [_cfgGrid, "isClass _x", false];
_letterGrid = false;
if (((toLower _formatX) find "a") != -1) then {_letterGrid = true};
if (((toLower _formatY) find "a") != -1) then {_letterGrid = true};
if (_letterGrid) exitWith {
diag_log text format ["[ACE] Map Grid Warning (%1) - Map uses letter grids [%2,%3]", worldName, _formatX, _formatY];
};
//Start at [0, 500] and move north until we get a change in grid
_heightOffset = 500;
_startGrid = mapGridPosition [0, _heightOffset];
_originGrid = _startGrid;
while {_startGrid == _originGrid} do {
_heightOffset = _heightOffset + 1;
_originGrid = mapGridPosition [0, _heightOffset];
};
//Calculate the real y offset
_realOffsetY = parseNumber (_originGrid select [(count _formatX), (count _formatY)]) * _stepY + _heightOffset - 1;
//Calculate MGRS 10digit step - they should both be 1 meter:
_stepXat5 = _stepX * 10 ^ ((count _formatX) - 5);
_stepYat5 = -1 * _stepY * 10 ^ ((count _formatY) - 5);
if (_stepYat5 < 0) then {
diag_log text format ["[ACE] Map Grid Warning (%1) - Northing is reversed", worldName];
};
if (_stepXat5 != 1) then {
diag_log text format ["[ACE] Map Grid Warning (%1) - MGRS 10 digit grid does not equal 1 meter: (%2) for x", worldName, _stepXat5];
};
if ((_stepYat5 != 1) && {_stepYat5 != -1}) then {
diag_log text format ["[ACE] Map Grid Warning (%1) - MGRS 10 digit grid does not equal 1 meter: (%2) for y", worldName, _stepXat5];
};
GVAR(mapGridData) = [_offsetX, _realOffsetY, _stepXat5, _stepYat5];

View File

@ -0,0 +1,63 @@
/*
* Author: VKing, PabstMirror
* Gets a 10-digit map grid for the given world position
*
* Argument:
* 0: Position (2D Position) <ARRAY>
* 1: Return type; false for array of easting and northing, true for single string <Bool>
*
* Return values:
* 0: Easting <String>
* 1: Northing <String>
*
* Example:
* [(getPos player)] call ace_common_fnc_getMapGridFromPos;
*
* Public: Yes
*/
// #define DEBUG_MODE_FULL
#include "script_component.hpp"
PARAMS_1(_pos);
DEFAULT_PARAM(1,_returnSingleString,false);
private["_count", "_easting", "_nativeGrid", "_northing"];
//Fallback, when map data is weird (letters)
if ((count GVAR(mapGridData)) == 0) exitWith {
_nativeGrid = mapGridPosition _pos;
if (_returnSingleString) then {
_nativeGrid
} else {
_count = floor ((count _nativeGrid) / 2);
[(_nativeGrid select [0, _count]), (_nativeGrid select [_count, _count])]
};
};
EXPLODE_4_PVT(GVAR(mapGridData),_offsetX,_realOffsetY,_stepXat5,_stepYat5);
_easting = floor (((_pos select 0) - _offsetX) / _stepXat5);
_northing = floor (((_pos select 1) - _realOffsetY) / _stepYat5);
//Attempt to handle negative east/north (e.g.: moving west of map bounds)
if (_easting > 0) then {
_easting = str _easting;
while {count _easting < 5} do {_easting = "0" + _easting;};
} else {
_easting = str abs _easting;
while {count _easting < 4} do {_easting = "0" + _easting;};
_easting = "-" + _easting;
};
if (_northing > 0) then {
_northing = str _northing;
while {count _northing < 5} do {_northing = "0" + _northing;};
} else {
_northing = str abs _northing;
while {count _northing < 4} do {_northing = "0" + _northing;};
_northing = "-" + _northing;
};
if (_returnSingleString) then {
_easting + _northing
} else {
[_easting, _northing]
};

View File

@ -0,0 +1,46 @@
/*
* Author: PabstMirror
* Gets position from grid cords
*
* Argument:
* 0: Grid Cords <STRING>
* 1: Get Center or bottom right <BOOL><OPTIONAL>
*
* Return values:
* Position <ARRAY>
*
* Example:
* ["6900080085"] call ace_common_fnc_getMapPosFromGrid
*
* Public: Yes
*/
#include "script_component.hpp"
PARAMS_1(_inputString);
DEFAULT_PARAM(1,_getCenterOfGrid,true);
private["_countInput", "_countInputHalf", "_xPart", "_xPos", "_yPart", "_yPos"];
if ((count GVAR(mapGridData)) == 0) exitWith {
ERROR("Map has bad data, falling back to BIS_fnc_gridToPos");
(_this call BIS_fnc_gridToPos) select 0
};
EXPLODE_4_PVT(GVAR(mapGridData),_offsetX,_realOffsetY,_stepXat5,_stepYat5);
_countInput = count _inputString;
_countInputHalf = floor (_countInput / 2);
//Split string, ignoring middle
_xPart = _inputString select [0, _countInputHalf];
_yPart = _inputString select [(ceil (_countInput / 2)), _countInputHalf];
_xPos = ((parseNumber _xPart) * _stepXat5 * 10 ^ (5 - _countInputHalf)) + _offsetX;
_yPos = ((parseNumber _yPart) * _stepYat5 * 10 ^ (5 - _countInputHalf)) + _realOffsetY;
if (_getCenterOfGrid) then {
_xPos = _xPos + 0.5 * _stepXat5 * 10 ^ (5 - _countInputHalf);
_yPos = _yPos + 0.5 * _stepYat5 * 10 ^ (5 - _countInputHalf);
};
[_xPos, _yPos, 0];

View File

@ -30,7 +30,7 @@ __background ctrlSetText QUOTE(PATHTOF(UI\dagr_gps.paa));
if (GVAR(outputPFH) != -1) exitWith {};
GVAR(outputPFH) = [{
private ["_pos", "_mapSize", "_gridConfig", "_offsetX", "_offsetY", "_stepX", "_stepY", "_xgrid", "_ygrid", "_xcoord", "_ycoord", "_speed", "_dagrHeading", "_dagrGrid", "_dagrElevation", "_dagrSpeed", "_dagrTime", "_elevation"];
private["_dagrElevation", "_dagrGrid", "_dagrHeading", "_dagrSpeed", "_dagrTime", "_elevation", "_gridArray", "_speed"];
// Abort Condition
if !(GVAR(run) && [ACE_player, "ACE_DAGR"] call EFUNC(common,hasItem)) exitWith {
@ -40,54 +40,8 @@ GVAR(outputPFH) = [{
};
// GRID
_pos = getPosASL ACE_player;
_mapSize = getNumber (configFile >> "CfgWorlds" >> worldName >> "MapSize");
_gridConfig = (configFile >> "CfgWorlds" >> worldName >> "Grid");
_offsetX = getNumber (_gridConfig >> "offsetX");
_offsetY = getNumber (_gridConfig >> "offsetY");
_stepX = getNumber (_gridConfig >> "Zoom1" >> "stepX");
_stepY = getNumber (_gridConfig >> "Zoom1" >> "stepY");
if (_stepY >= 0) then {
_pos set [1, (_mapSize - 100) - (_pos select 1) - _offsetY];
};
// Incase grids go neg due to 99-00 boundry
if (_pos select 0 < 0) then {_pos set [0, (_pos select 0) + 99999];};
if (_pos select 1 < 0) then {_pos set [1, (_pos select 1) + 99999];};
_xGrid = toArray Str(round(_pos select 0));
while {count _xGrid < 5} do {
_xGrid = [48] + _xGrid;
};
_xGrid resize 4;
_xGrid = toString _xGrid;
_xGrid = parseNumber _xGrid;
_yGrid = toArray Str(round(_pos select 1));
while {count _yGrid < 5} do {
_yGrid = [48] + _yGrid;
};
_yGrid resize 4;
_yGrid = toString _yGrid;
_yGrid = parseNumber _yGrid;
_xCoord = switch true do {
case (_xGrid >= 1000): { "" + Str(_xGrid) };
case (_xGrid >= 100): { "0" + Str(_xGrid) };
case (_xGrid >= 10): { "00" + Str(_xGrid) };
default { "000" + Str(_xGrid) };
};
_yCoord = switch true do {
case (_yGrid >= 1000): { "" + Str(_yGrid) };
case (_yGrid >= 100): { "0" + Str(_yGrid) };
case (_yGrid >= 10): { "00" + Str(_yGrid) };
default { "000" + Str(_yGrid) };
};
_dagrGrid = _xcoord + " " + _ycoord;
_gridArray = [(getPos ACE_player), false] call EFUNC(common,getMapGridFromPos);
_dagrGrid = format ["%1 %2", ((_gridArray select 0) select [0,4]), ((_gridArray select 1) select [0,4])];
// SPEED
_speed = speed (vehicle ACE_player);
@ -97,7 +51,7 @@ GVAR(outputPFH) = [{
// Elevation
_elevation = getPosASL ACE_player;
_elevation = floor ((_elevation select 2) + EGVAR(weather,altitude));
_elevation = floor ((_elevation select 2) + EGVAR(common,mapAltitude));
_dagrElevation = str _elevation + "m";
// Heading

View File

@ -72,7 +72,7 @@ _yCoord = switch true do {
_dagrGrid = _xCoord + " " + _yCoord;
// Find target elevation
_elevation = floor ((GVAR(LAZPOS) select 2) + EGVAR(weather,altitude));
_elevation = floor ((GVAR(LAZPOS) select 2) + EGVAR(common,mapAltitude));
_dagrElevation = str _elevation + "m";
// Time

View File

@ -30,7 +30,7 @@ __background ctrlSetText QUOTE(PATHTOF(UI\dagr_wp.paa));
if (GVAR(outputPFH) != -1) exitWith {};
GVAR(outputPFH) = [{
private ["_pos", "_mapSize", "_gridConfig", "_offsetX", "_offsetY", "_stepX", "_stepY", "_xGrid", "_yGrid", "_xCoord", "_yCoord", "_dagrHeading", "_dagrGrid", "_bearing", "_MYpos", "_WPpos", "_dagrDistance", "_distance"];
private["_MYpos", "_WPpos", "_bearing", "_dagrDistance", "_dagrGrid", "_dagrHeading", "_distance", "_gridArray"];
// Abort Condition
if !(GVAR(run) && [ACE_player, "ACE_DAGR"] call EFUNC(common,hasItem)) exitWith {
@ -40,54 +40,8 @@ GVAR(outputPFH) = [{
};
// GRID
_pos = getPosASL ACE_player;
_mapSize = getNumber (configFile >> "CfgWorlds" >> worldName >> "MapSize");
_gridConfig = (configFile >> "CfgWorlds" >> worldName >> "Grid");
_offsetX = getNumber (_gridConfig >> "offsetX");
_offsetY = getNumber (_gridConfig >> "offsetY");
_stepX = getNumber (_gridConfig >> "Zoom1" >> "stepX");
_stepY = getNumber (_gridConfig >> "Zoom1" >> "stepY");
if (_stepY >= 0) then {
_pos set [1, (_mapSize - 100) - (_pos select 1) - _offsetY];
};
// Incase grids go neg due to 99-00 boundry
if (_pos select 0 < 0) then {_pos set [0, (_pos select 0) + 99999];};
if (_pos select 1 < 0) then {_pos set [1, (_pos select 1) + 99999];};
_xGrid = toArray Str(round(_pos select 0));
while {count _xGrid < 5} do {
_xGrid = [48] + _xGrid;
};
_xGrid resize 4;
_xGrid = toString _xGrid;
_xGrid = parseNumber _xGrid;
_yGrid = toArray Str(round(_pos select 1));
while {count _yGrid < 5} do {
_yGrid = [48] + _yGrid;
};
_yGrid resize 4;
_yGrid = toString _yGrid;
_yGrid = parseNumber _yGrid;
_xCoord = switch true do {
case (_xGrid >= 1000): { "" + Str(_xGrid) };
case (_xGrid >= 100): { "0" + Str(_xGrid) };
case (_xGrid >= 10): { "00" + Str(_xGrid) };
default { "000" + Str(_xGrid) };
};
_yCoord = switch true do {
case (_yGrid >= 1000): { "" + Str(_yGrid) };
case (_yGrid >= 100): { "0" + Str(_yGrid) };
case (_yGrid >= 10): { "00" + Str(_yGrid) };
default { "000" + Str(_yGrid) };
};
_dagrGrid = _xCoord + " " + _yCoord;
_gridArray = [(getPos ACE_player), false] call EFUNC(common,getMapGridFromPos);
_dagrGrid = format ["%1 %2", ((_gridArray select 0) select [0,4]), ((_gridArray select 1) select [0,4])];
// WP Grid
_xGrid2 = floor (DAGR_WP_INFO / 10000);
@ -110,8 +64,8 @@ GVAR(outputPFH) = [{
_dagrGrid2 = _xCoord2 + " " + _yCoord2;
// Distance
_WPpos = [[_xCoord2, _yCoord2], true] call CBA_fnc_mapGridToPos;
_MYpos = [[_xCoord, _yCoord], true] call CBA_fnc_mapGridToPos;
_WPpos = [_dagrGrid2, true] call EFUNC(common,getMapPosFromGrid);
_MYpos = [_dagrGrid, true] call EFUNC(common,getMapPosFromGrid);
_distance = _MYpos distance _WPpos;
_distance = floor (_distance * 10) / 10;
_dagrDistance = str _distance + "m";

View File

@ -20,7 +20,7 @@ _playerAltitude = (getPosASL ACE_player) select 2;
_temperature = _playerAltitude call EFUNC(weather,calculateTemperatureAtHeight);
_humidity = EGVAR(weather,currentHumidity);
_barometricPressure = _playerAltitude call EFUNC(weather,calculateBarometricPressure);
_altitude = EGVAR(weather,Altitude) + _playerAltitude;
_altitude = EGVAR(common,mapAltitude) + _playerAltitude;
_airDensity = [_temperature, _barometricPressure, _humidity] call EFUNC(weather,calculateAirDensity);
_densityAltitude = _airDensity call EFUNC(weather,calculateDensityAltitude);
_chill = [_temperature, _humidity] call EFUNC(weather,calculateWindChill);

View File

@ -276,7 +276,7 @@ if (GVAR(referenceHeadingMenu) == 0) then {
};
case 12: { // ALTITUDE
if (!GVAR(MinAvgMax)) then {
_textCenterBig = Str(round(EGVAR(weather,Altitude) + _playerAltitude));
_textCenterBig = Str(round(EGVAR(common,mapAltitude) + _playerAltitude));
} else {
_textCenterLine1Left = "Min";
_textCenterLine2Left = "Avg";
@ -300,7 +300,7 @@ if (GVAR(referenceHeadingMenu) == 0) then {
};
case 14: { // User Screen 1
_textCenterLine1Left = Str(round(_playerDir));
_textCenterLine2Left = Str(round(EGVAR(weather,Altitude) + _playerAltitude));
_textCenterLine2Left = Str(round(EGVAR(common,mapAltitude) + _playerAltitude));
_textCenterLine3Left = Str(round(abs(_windSpeed) * 10) / 10);
_textCenterLine1Right = GVAR(Directions) select GVAR(Direction);
_textCenterLine2Right = "m";

View File

@ -39,25 +39,4 @@ GVAR(newWaypointPosition) = [];
GVAR(currentWaypoint) = -1;
GVAR(rangeFinderPositionASL) = [];
GVAR(mapAltitude) = getNumber (configFile >> "CfgWorlds" >> worldName >> "elevationOffset");
private ["_worldMapLong", "_worldMapLat", "_zone", "_band", "_squareID"];
//Calculate the map's MGRS:
_worldMapLong = getNumber (configFile >> "CfgWorlds" >> worldName >> "longitude");
_worldMapLat = getNumber (configFile >> "CfgWorlds" >> worldName >> "latitude");
//Pull UTM grid from world's long/lat
_zone = 1 + (floor ((_worldMapLong + 180) / 6));
_band = "Z";
if (_worldMapLat <= -80) then {
_band = "A";
} else {
if (_worldMapLat < 84) then {
_band = "CDEFGHJKLMNPQRSTUVWXX" select [(floor ((_worldMapLat / 8) + 10)), 1];
};
};
//calculating square ID from long/lat is a pain in the ass, just fake it unless someone wants to actualy do this
_squareID = if ((count worldName) > 2) then {toUpper(worldName select [0,2])} else {"XG"};
GVAR(mgrsGridZoneDesignator) = format ["%1%2 %3", _zone, _band, _squareID];
GVAR(mgrsGridZoneDesignator) = format ["%1 %2",EGVAR(common,MGRS_data) select 0, EGVAR(common,MGRS_data) select 1];

View File

@ -15,7 +15,7 @@
*/
#include "script_component.hpp"
private ["_display", "_editText", "_gridPosTuple", "_actualPos"];
private ["_display", "_editText", "_actualPos"];
PARAMS_1(_keypadButton);
disableSerialization;
@ -34,8 +34,7 @@ _editText = ctrlText (_display displayCtrl IDC_MODEMARK_CORDSEDIT);
switch (_keypadButton) do {
case ("ok"): {
if ((count GVAR(newWaypointPosition)) == 0) then {
_gridPosTuple = [_editText] call BIS_fnc_gridToPos;
_actualPos = [(((_gridPosTuple select 0) select 0) + 0.5 * ((_gridPosTuple select 1) select 0)), (((_gridPosTuple select 0) select 1) + 0.5 * ((_gridPosTuple select 1) select 1))];
_actualPos = [_editText, true] call EFUNC(common,getMapPosFromGrid);
_actualPos set [2, (getTerrainHeightASL _actualPos)];
GVAR(newWaypointPosition) = _actualPos;
[APP_MODE_MARK] call FUNC(saveCurrentAndSetNewMode);

View File

@ -15,7 +15,7 @@
*/
#include "script_component.hpp"
private ["_display", "_waypoints", "_posString", "_eastingText", "_northingText", "_numASL", "_aboveSeaLevelText", "_compassAngleText", "_targetPosName", "_targetPosLocationASL", "_bearingText", "_rangeText", "_targetName", "_bearing", "_2dDistanceKm", "_SpeedText", "_playerPos2d", "_wpListBox", "_currentIndex", "_wpName", "_wpPos", "_settingListBox", "_yearString", "_monthSring", "_dayString", "_daylight"];
private ["_display", "_waypoints", "_posString", "_eastingText", "_northingText", "_numASL", "_aboveSeaLevelText", "_compassAngleText", "_targetPos", "_targetPosName", "_targetPosLocationASL", "_bearingText", "_rangeText", "_targetName", "_bearing", "_2dDistanceKm", "_SpeedText", "_playerPos2d", "_wpListBox", "_currentIndex", "_wpName", "_wpPos", "_settingListBox", "_yearString", "_monthSring", "_dayString"];
disableSerialization;
_display = displayNull;
@ -37,18 +37,14 @@ _waypoints = [] call FUNC(deviceGetWaypoints);
switch (GVAR(currentApplicationPage)) do {
case (APP_MODE_INFODISPLAY): {
//Easting/Northing:
_posString = mapGridPosition ACE_player;
_eastingText = "";
_northingText = "";
if (count _posString > 0) then {
_eastingText = (_posString select [0, ((count _posString)/2)]) + "e";
_northingText = (_posString select [(count _posString)/2, (count _posString - 1)]) + "n";
};
_posString = [getPos ACE_player] call EFUNC(common,getMapGridFromPos);
_eastingText = (_posString select 0) + "e";
_northingText = (_posString select 1) + "n";
(_display displayCtrl IDC_MODEDISPLAY_EASTING) ctrlSetText _eastingText;
(_display displayCtrl IDC_MODEDISPLAY_NORTHING) ctrlSetText _northingText;
//Elevation:
_numASL = ((getPosASL ace_player) select 2) + GVAR(mapAltitude);
_numASL = ((getPosASL ace_player) select 2) + EGVAR(common,mapAltitude);
_aboveSeaLevelText = [_numASL, 5, 0] call CBA_fnc_formatNumber;
_aboveSeaLevelText = if (_numASL > 0) then {"+" + _aboveSeaLevelText + " MSL"} else {_aboveSeaLevelText + " MSL"};
(_display displayCtrl IDC_MODEDISPLAY_ELEVATIONNUM) ctrlSetText _aboveSeaLevelText;
@ -82,7 +78,8 @@ case (APP_MODE_INFODISPLAY): {
if (GVAR(currentWaypoint) == -2) then {
if (!(GVAR(rangeFinderPositionASL) isEqualTo [])) then {
_targetPosName = format ["[%1]", (mapGridPosition GVAR(rangeFinderPositionASL))];
_targetPos = [GVAR(rangeFinderPositionASL)] call EFUNC(common,getMapGridFromPos);
_targetPosName = format ["[%1 %2 %3]", EGVAR(common,MGRS_data) select 1, _targetPos select 0, _targetPos select 1];
_targetPosLocationASL = GVAR(rangeFinderPositionASL);
};
} else {
@ -100,7 +97,7 @@ case (APP_MODE_INFODISPLAY): {
};
_2dDistanceKm = (((getPosASL ace_player) select [0,2]) distance (_targetPosLocationASL select [0,2])) / 1000;
_rangeText = format ["%1km", ([_2dDistanceKm, 1, 1] call CBA_fnc_formatNumber)];
_numASL = (_targetPosLocationASL select 2) + GVAR(mapAltitude);
_numASL = (_targetPosLocationASL select 2) + EGVAR(common,mapAltitude);
_aboveSeaLevelText = [_numASL, 5, 0] call CBA_fnc_formatNumber;
_aboveSeaLevelText = if (_numASL > 0) then {"+" + _aboveSeaLevelText + " MSL"} else {_aboveSeaLevelText + " MSL"};
};
@ -136,7 +133,8 @@ case (APP_MODE_COMPASS): {
if (GVAR(currentWaypoint) == -2) then {
if (!(GVAR(rangeFinderPositionASL) isEqualTo [])) then {
_targetPosName = format ["[%1]", (mapGridPosition GVAR(rangeFinderPositionASL))];
_targetPos = [GVAR(rangeFinderPositionASL)] call EFUNC(common,getMapGridFromPos);
_targetPosName = format ["[%1 %2 %3]", EGVAR(common,MGRS_data) select 1, _targetPos select 0, _targetPos select 1];
_targetPosLocationASL = GVAR(rangeFinderPositionASL);
};
} else {

View File

@ -149,7 +149,7 @@ if (missionNamespace getVariable [QEGVAR(advanced_ballistics,enabled), false]) t
_barometricPressure = 1013.25;
if (missionNamespace getVariable [QEGVAR(advanced_ballistics,enabled), false]) then {
_barometricPressure = 1013.25 * (1 - (0.0065 * EGVAR(weather,altitude)) / 288.15) ^ 5.255754495;
_barometricPressure = 1013.25 * (1 - (0.0065 * EGVAR(common,mapAltitude)) / 288.15) ^ 5.255754495;
};
_relativeHumidity = 0.5;

View File

@ -14,4 +14,4 @@
*/
#include "script_component.hpp"
((1013.25 - 10 * overcast) * (1 - (0.0065 * (GVAR(Altitude) + _this)) / (KELVIN(GVAR(currentTemperature)) + 0.0065 * GVAR(Altitude))) ^ 5.255754495);
((1013.25 - 10 * overcast) * (1 - (0.0065 * (EGVAR(common,mapAltitude) + _this)) / (KELVIN(GVAR(currentTemperature)) + 0.0065 * EGVAR(common,mapAltitude))) ^ 5.255754495);

View File

@ -11,31 +11,6 @@
*/
#include "script_component.hpp"
GVAR(Altitude) = getNumber(configFile >> "CfgWorlds" >> worldName >> "elevationOffset");
GVAR(Latitude) = getNumber(configFile >> "CfgWorlds" >> worldName >> "latitude");
if (worldName in ["Chernarus", "Bootcamp_ACR", "Woodland_ACR", "utes"]) then { GVAR(Latitude) = 50; GVAR(Altitude) = 0; };
if (worldName in ["Altis", "Stratis"]) then { GVAR(Latitude) = 40; GVAR(Altitude) = 0; };
if (worldName in ["Takistan", "Zargabad", "Mountains_ACR"]) then { GVAR(Latitude) = 35; GVAR(Altitude) = 2000; };
if (worldName in ["Shapur_BAF", "ProvingGrounds_PMC"]) then { GVAR(Latitude) = 35; GVAR(Altitude) = 100; };
if (worldName in ["fallujah"]) then { GVAR(Latitude) = 33; GVAR(Altitude) = 0; };
if (worldName in ["fata", "Abbottabad"]) then { GVAR(Latitude) = 30; GVAR(Altitude) = 1000; };
if (worldName in ["sfp_wamako"]) then { GVAR(Latitude) = 14; GVAR(Altitude) = 0; };
if (worldName in ["sfp_sturko"]) then { GVAR(Latitude) = 56; GVAR(Altitude) = 0; };
if (worldName in ["Bornholm"]) then { GVAR(Latitude) = 55; GVAR(Altitude) = 0; };
if (worldName in ["Imrali"]) then { GVAR(Latitude) = 40; GVAR(Altitude) = 0; };
if (worldName in ["Caribou"]) then { GVAR(Latitude) = 68; GVAR(Altitude) = 0; };
if (worldName in ["Namalsk"]) then { GVAR(Latitude) = 65; GVAR(Altitude) = 0; };
if (worldName in ["MCN_Aliabad"]) then { GVAR(Latitude) = 36; GVAR(Altitude) = 0; };
if (worldName in ["Clafghan"]) then { GVAR(Latitude) = 34; GVAR(Altitude) = 640; };
if (worldName in ["Sangin", "hellskitchen"]) then { GVAR(Latitude) = 32; GVAR(Altitude) = 0; };
if (worldName in ["Sara"]) then { GVAR(Latitude) = 40; GVAR(Altitude) = 0; };
if (worldName in ["reshmaan"]) then { GVAR(Latitude) = 35; GVAR(Altitude) = 2000; };
if (worldName in ["Thirsk"]) then { GVAR(Latitude) = 65; GVAR(Altitude) = 0; };
if (worldName in ["lingor"]) then { GVAR(Latitude) = -4; GVAR(Altitude) = 0; };
if (worldName in ["Panthera3"]) then { GVAR(Latitude) = 46; GVAR(Altitude) = 0; };
if (worldName in ["Kunduz"]) then { GVAR(Latitude) = 37; GVAR(Altitude) = 400; };
// Assume default wind values
// Source: https://weatherspark.com/averages/32194/Lemnos-Limnos-North-Aegean-Islands-Greece
GVAR(WindSpeedMax) = [[8.8, 5.5], [8.8, 5], [8.6, 4.8], [7.6, 3.4], [7.0, 3.0], [7.1, 3.0], [7.5, 3.1], [8.0, 3.2], [7.6, 3.5], [7.8, 4.6], [7.9, 5.0], [8.2, 5.5]];