This commit is contained in:
ulteq 2015-06-08 12:57:16 +02:00
parent eae8c8cae2
commit 29c55a5495
9 changed files with 245 additions and 373 deletions

View File

@ -1504,7 +1504,7 @@ class FSM
init = /*%FSM<STATEINIT""">*/"DAGR_DISPLAY_SELECTION = ""DATA"";" \n
"((uiNameSpace getVariable _dsp) displayCtrl _mainText) ctrlSetText ""Acquiring Data."";" \n
"_wait = time + 0.5;" \n
"DAGR_EMPTYVECTOR = true;"/*%FSM</STATEINIT""">*/;
"DAGR_EMPTY_VECTOR = true;"/*%FSM</STATEINIT""">*/;
precondition = /*%FSM<STATEPRECONDITION""">*/""/*%FSM</STATEPRECONDITION""">*/;
class Links
{
@ -1934,7 +1934,7 @@ class FSM
{
name = "Remove_Menu";
init = /*%FSM<STATEINIT""">*/"DAGR_SEL = false;" \n
"DAGR_EMPTYVECTOR = true;" \n
"DAGR_EMPTY_VECTOR = true;" \n
"((uiNameSpace getVariable _dsp) displayCtrl _Option0) ctrlSetText """";" \n
"((uiNameSpace getVariable _dsp) displayCtrl _Option1) ctrlSetText """";" \n
"((uiNameSpace getVariable _dsp) displayCtrl _Option2) ctrlSetText """";" \n
@ -2218,7 +2218,7 @@ class FSM
init = /*%FSM<STATEINIT""">*/"DAGR_DISPLAY_SELECTION = ""VECTOR"";" \n
"((uiNameSpace getVariable _dsp) displayCtrl _mainText) ctrlSetText ""Vector Connected"";" \n
"_wait = time + 2.5;" \n
"DAGR_EMPTYVECTOR = false;"/*%FSM</STATEINIT""">*/;
"DAGR_EMPTY_VECTOR = false;"/*%FSM</STATEINIT""">*/;
precondition = /*%FSM<STATEPRECONDITION""">*/""/*%FSM</STATEPRECONDITION""">*/;
class Links
{
@ -5825,7 +5825,7 @@ class FSM
"DAGR_RIGHT = false;" \n
"DAGR_LEFT = false;" \n
"DAGR_SEL = false;" \n
"_newSleep = DAGRSLEEP;" \n
"_newSleep = DAGR_UPDATE_INTERVAL;" \n
"_text = str (_newSleep*1000) + ""ms"";" \n
"((uiNameSpace getVariable _dsp) displayCtrl _mainText) ctrlSetText _text;" \n
"((uiNameSpace getVariable _dsp) displayCtrl _F1) ctrlSetText ""Save"";" \n
@ -5907,7 +5907,7 @@ class FSM
init = /*%FSM<STATEINIT""">*/"((uiNameSpace getVariable _dsp) displayCtrl _F1) ctrlSetText """";" \n
"((uiNameSpace getVariable _dsp) displayCtrl _F3) ctrlSetText """";" \n
"((uiNameSpace getVariable _dsp) displayCtrl _mainText) ctrlSetText ""Updating."";" \n
"DAGRSLEEP = _newSleep;" \n
"DAGR_UPDATE_INTERVAL = _newSleep;" \n
"_wait = time + 0.2;"/*%FSM</STATEINIT""">*/;
precondition = /*%FSM<STATEPRECONDITION""">*/""/*%FSM</STATEPRECONDITION""">*/;
class Links
@ -7457,7 +7457,7 @@ class FSM
init = /*%FSM<STATEINIT""">*/"DAGR_DISPLAY_SELECTION = ""VECTOR"";" \n
"((uiNameSpace getVariable _dsp) displayCtrl _mainText) ctrlSetText ""SOFLAM Connected"";" \n
"_wait = time + 2.5;" \n
"DAGR_EMPTYVECTOR = false;"/*%FSM</STATEINIT""">*/;
"DAGR_EMPTY_VECTOR = false;"/*%FSM</STATEINIT""">*/;
precondition = /*%FSM<STATEPRECONDITION""">*/""/*%FSM</STATEPRECONDITION""">*/;
class Links
{
@ -7848,7 +7848,7 @@ class FSM
{
name = "__96";
init = /*%FSM<STATEINIT""">*/"DAGR_SEL = false;" \n
"DAGR_EMPTYVECTOR = true;"/*%FSM</STATEINIT""">*/;
"DAGR_EMPTY_VECTOR = true;"/*%FSM</STATEINIT""">*/;
precondition = /*%FSM<STATEPRECONDITION""">*/""/*%FSM</STATEPRECONDITION""">*/;
class Links
{

View File

@ -3,7 +3,6 @@
DAGR_RUN = false;
DAGR_STP = false;
DAGR_MENU_RUN = false;
Dagr_Map_Info = "default";
DAGR_DIRECTION = true; // true -> degrees; false -> milliradian
DAGR_GRID_VECTOR = "00000000"; // Default
@ -18,11 +17,11 @@ DAGR_WP1 = 0;
DAGR_WP2 = 0;
DAGR_WP3 = 0;
DAGR_WP4 = 0;
DAGRSLEEP = 0.5; // Update timer on DAGR, set for 0.5 seconds
DAGR_EMPTYVECTOR = true; // Keeps DAGR Vector display from filling up before use
DAGR_UPDATE_INTERVAL = 0.5; // Update timer on DAGR, set for 0.5 seconds
DAGR_EMPTY_VECTOR = true; // Keeps DAGR Vector display from filling up before use
DAGR_DISPLAY_SELECTION = "DATA"; // Sets DAGR for data display
NODAGRDISPLAY = true;
DAGR_NO_DISPLAY = true;
["RangerfinderData", {_this call FUNC(DAGR_VECTOR)}] call EFUNC(common,addEventHandler);

View File

@ -8,6 +8,5 @@ PREP(DAGR_OUTPUT_VECTOR);
PREP(DAGR_OUTPUT_WP);
PREP(DAGR_START);
PREP(DAGR_VECTOR);
PREP(mapCoord);
ADDON = true;

View File

@ -12,110 +12,95 @@
*
* Public: No
*/
#include "script_component.hpp"
disableSerialization;
private ["_pos", "_x", "_y", "_xgrid", "_pos", "_ygrid", "_lastY", "_lastX", "_xcoord", "_ycoord", "_display", "_speed", "_vic", "_dagrHeading", "_dagrGrid", "_background", "_dagrElevation", "_dagrSpeed", "_dagrTime", "_elevation", "_elevationControl", "_grid", "_gridControl", "_headingControl", "_speedControl", "_timeControl"];
#include "script_component.hpp"
135471 cutRsc ["DAGR_DISPLAY", "plain down"];
_display = (uiNameSpace getVariable "DAGR_DISPLAY");
_gridControl = _display displayCtrl 266851;
_speedControl = _display displayCtrl 266852;
_elevationControl = _display displayCtrl 266853;
_headingControl = _display displayCtrl 266854;
_timeControl = _display displayCtrl 266855;
_background = _display displayCtrl 266856;
#define __display (uiNameSpace getVariable "DAGR_DISPLAY")
_background ctrlSetText QUOTE(PATHTOF(UI\dagr_gps.paa));
#define __gridControl (__display displayCtrl 266851)
#define __speedControl (__display displayCtrl 266852)
#define __elevationControl (__display displayCtrl 266853)
#define __headingControl (__display displayCtrl 266854)
#define __timeControl (__display displayCtrl 266855)
#define __background (__display displayCtrl 266856)
while {DAGR_RUN} do {
if (Dagr_Map_Info == "default") then {
_dagrGrid = mapGridPosition ACE_player;
} else {
//GRID
_pos = getPos ACE_player;
_x = _pos select 0;
_y = _pos select 1;
__background ctrlSetText QUOTE(PATHTOF(UI\dagr_gps.paa));
_grid = ACE_player call FUNC(mapCoord);
_xgrid = floor (call compile (_grid select 0));
_ygrid = floor (call compile (_grid select 1));
[{
private ["_pos", "_xgrid", "_ygrid", "_lastY", "_lastX", "_xcoord", "_ycoord", "_display", "_speed", "_vic", "_dagrHeading", "_dagrGrid", "_dagrElevation", "_dagrSpeed", "_dagrTime", "_elevation"];
// Abort Condition
if !(DAGR_RUN && [ACE_player, "ACE_DAGR"] call EFUNC(common,hasItem)) exitWith {
135471 cutText ["", "PLAIN"];
[_this select 1] call CBA_fnc_removePerFrameHandler;
};
// GRID
_pos = getPosASL ACE_player;
//Incase grids go neg due to 99-00 boundry
if (_xgrid < 0) then {_xgrid = _xgrid + 9999;};
if (_ygrid < 0) then {_ygrid = _ygrid + 9999;};
_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 =
if (_xgrid >= 1000) then {
str _xgrid;
} else {
if (_xgrid >= 100) then {
"0" + str _xgrid;
} else {
if (_xgrid >= 10) then {
"00" + str _xgrid;
} else{
"000" + str _xgrid;
};
};
};
// Incase grids go neg due to 99-00 boundry
if (_xgrid < 0) then {_xgrid = _xgrid + 9999;};
if (_ygrid < 0) then {_ygrid = _ygrid + 9999;};
_ycoord =
if (_ygrid >= 1000) then {
str _ygrid;
} else {
if (_ygrid >= 100) then {
"0" + str _ygrid;
} else {
if (_ygrid >= 10) then {
"00" + str _ygrid;
} else{
"000" + str _ygrid;
};
};
};
_dagrGrid = _xcoord + " " + _ycoord;
_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) };
};
//SPEED
if (vehicle ACE_player != ACE_player) then {
_vic = vehicle ACE_player;
_speed = speed _vic;
} else{
_speed = speed ACE_player;
_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) };
};
_speed = floor (_speed *10) / 10;
_dagrGrid = _xcoord + " " + _ycoord;
// SPEED
_speed = speed (vehicle ACE_player);
_speed = floor (_speed * 10) / 10;
_speed = abs(_speed);
_dagrspeed = str _speed + "kph";
//Elevation
// Elevation
_elevation = getPosASL ACE_player;
_elevation = floor ((_elevation select 2) + EGVAR(weather,altitude));
_dagrElevation = str _elevation + "m";
//Heading
if (vehicle ACE_player != ACE_player) then {
_vic = vehicle ACE_player;
_dagrHeading = if (!DAGR_DIRECTION) then {floor ((direction _vic)/360*6400)} else {floor (direction _vic);};
} else{
_dagrHeading = if (!DAGR_DIRECTION) then {floor ((direction ACE_player)/360*6400)} else {floor (direction ACE_player);};
// Heading
_dagrHeading = if (!DAGR_DIRECTION) then {
floor (DEG_TO_MIL(direction (vehicle ACE_player)))
} else {
floor (direction (vehicle ACE_player))
};
//Time
// Time
_dagrTime = [daytime, "HH:MM"] call bis_fnc_timeToString;
//output
_gridControl ctrlSetText format ["%1", _dagrGrid];
_speedControl ctrlSetText format ["%1", _dagrSpeed];
_elevationControl ctrlSetText format ["%1", _dagrElevation];
_headingControl ctrlSetText (if (!DAGR_DIRECTION) then { format ["%1", _dagrHeading] } else { format ["%1 °", _dagrHeading] });
_timeControl ctrlSetText format ["%1", _dagrTime];
sleep DAGRSLEEP;
if !([ACE_player, "ACE_DAGR"] call EFUNC(common,hasItem)) exitWith {
DAGR_RUN = false;
135471 cutText ["", "PLAIN"];
};
};
// Output
__gridControl ctrlSetText format ["%1", _dagrGrid];
__speedControl ctrlSetText format ["%1", _dagrSpeed];
__elevationControl ctrlSetText format ["%1", _dagrElevation];
__headingControl ctrlSetText (if (!DAGR_DIRECTION) then { format ["%1", _dagrHeading] } else { format ["%1 °", _dagrHeading] });
__timeControl ctrlSetText format ["%1", _dagrTime];
}, DAGR_UPDATE_INTERVAL, []] call CBA_fnc_addPerFrameHandler;

View File

@ -14,96 +14,82 @@
*/
#include "script_component.hpp"
disableSerialization;
private ["_x", "_y", "_xgrid", "_ygrid", "_dsp", "_dagrGrid", "_background", "_bearing", "_dagrDist", "_dagrElevation", "_dagrTime", "_display", "_elevation", "_elevationControl", "_grid", "_gridControl", "_headingControl", "_speedControl", "_timeControl", "_xcoord", "_ycoord"];
private ["_xGrid", "_yGrid", "_dagrGrid", "_bearing", "_dagrDist", "_dagrElevation", "_dagrTime", "_display", "_elevation", "_xCoord", "_yCoord"];
135471 cutRsc ["DAGR_DISPLAY", "plain down"];
_display = (uiNameSpace getVariable "DAGR_DISPLAY");
_gridControl = _display displayCtrl 266851;
_speedControl = _display displayCtrl 266858;
_elevationControl = _display displayCtrl 266853;
_headingControl = _display displayCtrl 266854;
_timeControl = _display displayCtrl 266855;
_background = _display displayCtrl 266856;
#define __display (uiNameSpace getVariable "DAGR_DISPLAY")
_background ctrlSetText QUOTE(PATHTOF(UI\dagr_vector.paa));
#define __gridControl (__display displayCtrl 266851)
#define __speedControl (__display displayCtrl 266858)
#define __elevationControl (__display displayCtrl 266853)
#define __headingControl (__display displayCtrl 266854)
#define __timeControl (__display displayCtrl 266855)
#define __background (__display displayCtrl 266856)
if (NODAGRDISPLAY) exitwith {};
__background ctrlSetText QUOTE(PATHTOF(UI\dagr_vector.paa));
if (Dagr_Map_Info == "default") then {
_dagrGrid = mapGridPosition DAGRLAZPOS;
} else {
//find laser position
_x = DAGRLAZPOS select 0;
_y = DAGRLAZPOS select 1;
if (DAGR_NO_DISPLAY) exitwith {};
_grid = [_x, _y] call ace_fnc_mapCoord;
_xgrid = floor (call compile (_grid select 0));
_ygrid = floor (call compile (_grid select 1));
// Find laser position
_xGrid = toArray Str(round(GVAR(LAZPOS) select 0));
while {count _xGrid < 5} do {
_xGrid = [48] + _xGrid;
};
_xGrid resize 4;
_xGrid = toString _xGrid;
_xGrid = parseNumber _xGrid;
//Incase grids go neg due to 99-00 boundry
if (_xgrid < 0) then {_xgrid = _xgrid + 9999;};
if (_ygrid < 0) then {_ygrid = _ygrid + 9999;};
_yGrid = toArray Str(round(GVAR(LAZPOS) select 1));
while {count _yGrid < 5} do {
_yGrid = [48] + _yGrid;
};
_yGrid resize 4;
_yGrid = toString _yGrid;
_yGrid = parseNumber _yGrid;
_xcoord =
if (_xgrid >= 1000) then {
str _xgrid;
} else {
if (_xgrid >= 100) then {
"0" + str _xgrid;
} else {
if (_xgrid >= 10) then {
"00" + str _xgrid;
}else{
"000" + str _xgrid;
};
};
};
// Incase grids go neg due to 99-00 boundry
if (_xGrid < 0) then {_xGrid = _xGrid + 9999;};
if (_yGrid < 0) then {_yGrid = _yGrid + 9999;};
_ycoord =
if (_ygrid >= 1000) then {
str _ygrid;
} else {
if (_ygrid >= 100) then {
"0" + str _ygrid;
} else {
if (_ygrid >= 10) then {
"00" + str _ygrid;
}else{
"000" + str _ygrid;
};
};
};
_dagrGrid = _xcoord + " " + _ycoord;
_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) };
};
//find target elevation
_elevation = floor ((DAGRLAZPOS select 2) + EGVAR(weather,altitude));
_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;
// Find target elevation
_elevation = floor ((GVAR(LAZPOS) select 2) + EGVAR(weather,altitude));
_dagrElevation = str _elevation + "m";
//Time
// Time
_dagrTime = [daytime, "HH:MM"] call bis_fnc_timeToString;
//Bearing
_bearing = DAGRLazHeading;
// Bearing
_bearing = GVAR(LAZHEADING);
if (_bearing >= 360) then {_bearing = _bearing - 360;};
if (!DAGR_DIRECTION) then {_bearing = floor (_bearing/360*6400)};
if (!DAGR_DIRECTION) then {_bearing = DEG_TO_MIL(_bearing)};
_bearing = floor (_bearing);
//Distance
_dagrDist = str DAGRLAZDIST + "m";
// Distance
_dagrDist = str GVAR(LAZDIST) + "m";
//put grid into variable so DAGR menu can access it TODO: check if it is safe to do it in this fashion
// put grid into variable so DAGR menu can access it TODO: check if it is safe to do it in this fashion
DAGR_GRID_VECTOR = _dagrGrid;
//OUTPUT
_gridControl ctrlSetText format ["%1", _dagrGrid];
_speedControl ctrlSetText format ["%1", _dagrDist];
_elevationControl ctrlSetText format ["%1", _dagrElevation];
_headingControl ctrlSetText (if (!DAGR_DIRECTION) then { format ["%1", _bearing] } else { format ["%1°", _bearing] });
_timeControl ctrlSetText format ["%1", _dagrTime];
// OUTPUT
__gridControl ctrlSetText format ["%1", _dagrGrid];
__speedControl ctrlSetText format ["%1", _dagrDist];
__elevationControl ctrlSetText format ["%1", _dagrElevation];
__headingControl ctrlSetText (if (!DAGR_DIRECTION) then { format ["%1", _bearing] } else { format ["%1°", _bearing] });
__timeControl ctrlSetText format ["%1", _dagrTime];

View File

@ -14,159 +14,109 @@
*/
#include "script_component.hpp"
disableSerialization;
private ["_pos", "_x", "_y", "_xgrid", "_ygrid", "_lastY", "_lastX", "_xcoord", "_ycoord", "_sec", "_min", "_hour", "_time", "_display", "_speed", "_vic", "_dagrHeading", "_WPHeading", "_dagrGrid", "_bearing", "_MYpos", "_WPpos", "_background", "_dagrDistance", "_distance", "_elevationControl", "_grid", "_gridControl", "_headingControl", "_speedControl", "_timeControl"];
135471 cutRsc ["DAGR_DISPLAY", "plain down"];
_display = (uiNameSpace getVariable "DAGR_DISPLAY");
_gridControl = _display displayCtrl 266851;
_speedControl = _display displayCtrl 266858;
_elevationControl = _display displayCtrl 266857;
_headingControl = _display displayCtrl 266854;
_timeControl = _display displayCtrl 266859;
_background = _display displayCtrl 266856;
#define __display (uiNameSpace getVariable "DAGR_DISPLAY")
_background ctrlSetText QUOTE(PATHTOF(UI\dagr_wp.paa));
#define __gridControl (__display displayCtrl 266851)
#define __speedControl (__display displayCtrl 266858)
#define __elevationControl (__display displayCtrl 266857)
#define __headingControl (__display displayCtrl 266854)
#define __timeControl (__display displayCtrl 266859)
#define __background (__display displayCtrl 266856)
while {DAGR_RUN} do {
//if (Dagr_Map_Info == "default") exitwith {_gridControl ctrlSetText "ERROR"};
//GRID
_pos = getPos ACE_player;
_x = _pos select 0;
_y = _pos select 1;
__background ctrlSetText QUOTE(PATHTOF(UI\dagr_wp.paa));
_grid = ACE_player call FUNC(mapCoord);
_xgrid = floor (call compile (_grid select 0));
_ygrid = floor (call compile (_grid select 1));
//Incase grids go neg due to 99-00 boundry
if (_xgrid < 0) then {_xgrid = _xgrid + 9999;};
if (_ygrid < 0) then {_ygrid = _ygrid + 9999;};
_xcoord =
if (_xgrid >= 1000) then {
str _xgrid;
} else {
if (_xgrid >= 100) then {
"0" + str _xgrid;
} else {
if (_xgrid >= 10) then {
"00" + str _xgrid;
}else{
"000" + str _xgrid;
};
};
};
_ycoord =
if (_ygrid >= 1000) then {
str _ygrid;
} else {
if (_ygrid >= 100) then {
"0" + str _ygrid;
} else {
if (_ygrid >= 10) then {
"00" + str _ygrid;
}else{
"000" + str _ygrid;
};
};
};
_dagrGrid = _xcoord + " " + _ycoord;
//WP Grid
_xgrid2 = floor (DAGR_WP_INFO / 10000);
_ygrid2 = DAGR_WP_INFO - _xgrid2 * 10000;
_xcoord2 =
if (_xgrid2 >= 1000) then {
str _xgrid2;
} else {
if (_xgrid2 >= 100) then {
"0" + str _xgrid2;
} else {
if (_xgrid2 >= 10) then {
"00" + str _xgrid2;
}else{
"000" + str _xgrid2;
};
};
};
_ycoord2 =
if (_ygrid2 >= 1000) then {
str _ygrid2;
} else {
if (_ygrid2 >= 100) then {
"0" + str _ygrid2;
} else {
if (_ygrid2 >= 10) then {
"00" + str _ygrid2;
}else{
"000" + str _ygrid2;
};
};
};
_dagrGrid2 = _xcoord2 + " " + _ycoord2;
//Distance
_WPpos = [[_xcoord2, _ycoord2], true] call CBA_fnc_mapGridToPos;
_MYpos = [[_xcoord, _ycoord], true] call CBA_fnc_mapGridToPos;
_distance = _MYpos distance _WPpos;
_distance = floor (_distance * 10);
_distance = _distance / 10;
_dagrDistance = str _distance + "m";
//ACE_player Heading
if (vehicle ACE_player != ACE_player) then {
_vic = vehicle ACE_player;
if (DAGR_DIRECTION) then {
_dagrHeading = floor (direction _vic);
} else {
_dagrHeading = floor ((direction _vic)/360*6400);
};
}else{
if (DAGR_DIRECTION) then {
_dagrHeading = floor (direction ACE_player);
} else {
_dagrHeading = floor ((direction ACE_player)/360*6400);
};
};
//WP Heading
_x = ((_WPpos select 0) - (_MYpos select 0));
_y = ((_WPpos select 1) - (_MYpos select 1));
if (_distance == 0) then {
_bearing = 0;
} else {
_bearing = _x / _distance;
if (_bearing >= 1) then {_bearing = 1;};
if (_bearing <= -1) then {_bearing = -1;};
_bearing = acos _bearing;
//_bearing = floor (_bearing);
if (_x >= 0 && {_y >= 0}) then {_bearing = 0 - _bearing + 90;};
if (_x < 0 && {_y >= 0}) then {_bearing = 0 - _bearing + 450;};
if (_x < 0 && {_y < 0}) then {_bearing = _bearing + 90;};
if (_x >= 0 && {_y < 0}) then {_bearing = _bearing + 90;};
if (!DAGR_DIRECTION) then {_bearing = floor (_bearing/360*6400)} else {_bearing = floor (_bearing)};
};
//output
_gridControl ctrlSetText format ["%1", _dagrGrid];
_speedControl ctrlSetText format ["%1", _bearing];
_elevationControl ctrlSetText format ["%1", _dagrGrid2];
_headingControl ctrlSetText (if (!DAGR_DIRECTION) then { format ["%1", _dagrHeading] } else { format ["%1°", _dagrHeading] });
_timeControl ctrlSetText format ["%1", _dagrDistance];
sleep DAGRSLEEP;
if !([ACE_player, "ACE_DAGR"] call EFUNC(common,hasItem)) exitWith {
DAGR_RUN = false;
[{
private ["_pos", "_xGrid", "_yGrid", "_lastY", "_lastX", "_xCoord", "_yCoord", "_speed", "_dagrHeading", "_WPHeading", "_dagrGrid", "_bearing", "_MYpos", "_WPpos", "_dagrDistance", "_distance"];
// Abort Condition
if !(DAGR_RUN && [ACE_player, "ACE_DAGR"] call EFUNC(common,hasItem)) exitWith {
135471 cutText ["", "PLAIN"];
[_this select 1] call CBA_fnc_removePerFrameHandler;
};
};
// GRID
_pos = getPosASL ACE_player;
_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;
// Incase grids go neg due to 99-00 boundry
if (_xGrid < 0) then {_xGrid = _xGrid + 9999;};
if (_yGrid < 0) then {_yGrid = _yGrid + 9999;};
_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;
// WP Grid
_xGrid2 = floor (DAGR_WP_INFO / 10000);
_yGrid2 = DAGR_WP_INFO - _xGrid2 * 10000;
_xCoord2 = switch true do {
case (_xGrid2 >= 1000): { "" + Str(_xGrid2) };
case (_xGrid2 >= 100): { "0" + Str(_xGrid2) };
case (_xGrid2 >= 10): { "00" + Str(_xGrid2) };
default { "000" + Str(_xGrid2) };
};
_yCoord2 = switch true do {
case (_yGrid2 >= 1000): { "" + Str(_yGrid2) };
case (_yGrid2 >= 100): { "0" + Str(_yGrid2) };
case (_yGrid2 >= 10): { "00" + Str(_yGrid2) };
default { "000" + Str(_yGrid2) };
};
_dagrGrid2 = _xCoord2 + " " + _yCoord2;
// Distance
_WPpos = [[_xCoord2, _yCoord2], true] call CBA_fnc_mapGridToPos;
_MYpos = [[_xCoord, _yCoord], true] call CBA_fnc_mapGridToPos;
_distance = _MYpos distance _WPpos;
_distance = floor (_distance * 10) / 10;
_dagrDistance = str _distance + "m";
// Heading
_dagrHeading = floor (if (DAGR_DIRECTION) then {
direction (vehicle ACE_player)
} else {
DEG_TO_MIL(direction (vehicle ACE_player))
});
// WP Heading
_bearing = floor ((_WPpos vectorDiff _MYpos) call CBA_fnc_vectDir);
// Output
__gridControl ctrlSetText format ["%1", _dagrGrid];
__speedControl ctrlSetText format ["%1", _bearing];
__elevationControl ctrlSetText format ["%1", _dagrGrid2];
__headingControl ctrlSetText (if (!DAGR_DIRECTION) then { format ["%1", _dagrHeading] } else { format ["%1°", _dagrHeading] });
__timeControl ctrlSetText format ["%1", _dagrDistance];
}, DAGR_UPDATE_INTERVAL, []] call CBA_fnc_addPerFrameHandler;

View File

@ -17,14 +17,14 @@
*/
#include "script_component.hpp"
#define EMP_RF_ACC 5
#define EMP_RF_ACC 5 // Rangefinder Accuracy
PARAMS_3(_slopeDistance,_azimuth,_inclination);
if (!DAGR_EMPTYVECTOR) then {
DAGRLAZPOS = (eyePos player) vectorAdd ([_slopeDistance, _azimuth, _inclination] call CBA_fnc_polar2vect);
DAGRLAZDIST = _slopeDistance * cos(_inclination);
DAGRLAZDIST = floor(DAGRLAZDIST / EMP_RF_ACC) * EMP_RF_ACC;
DAGRLazHeading = _azimuth;
NODAGRDISPLAY = false;
if (!DAGR_EMPTY_VECTOR) then {
GVAR(LAZPOS) = (eyePos player) vectorAdd ([_slopeDistance, _azimuth, _inclination] call CBA_fnc_polar2vect);
GVAR(LAZDIST) = _slopeDistance * cos(_inclination);
GVAR(LAZDIST) = floor (GVAR(LAZDIST) / EMP_RF_ACC) * EMP_RF_ACC;
GVAR(LAZHEADING) = _azimuth;
DAGR_NO_DISPLAY = false;
};

View File

@ -1,50 +0,0 @@
/*
* Author: Rosuto, Ruthberg
* Converts any kind of position into a position string array
*
* Arguments:
* 0: position <ARRAY|OBJECT|STRING>
*
* Return Value:
* 0: x-pos <STRING>
* 1: y-pos <STRING>
*
* Example:
*
* Public: No
*/
#include "script_component.hpp"
private ["_pos", "_grid", "_xGrid", "_yGrid"];
_pos = [0, 0];
switch (typeName _this) do {
//--- Coordinates
case "ARRAY": {
_pos = _this;
};
//--- Unit
case "OBJECT": {
_pos = getPosASL _this;
};
//--- Marker
case "STRING": {
_pos = markerPos _this;
};
};
_grid = toArray (mapGridPosition _pos);
if (count _grid > 4) then {
if (count _grid > 6) then {
_xGrid = toString [_grid select 0, _grid select 1, _grid select 2, _grid select 3];
_yGrid = toString [_grid select 4, _grid select 5, _grid select 6, _grid select 7];
} else {
_xGrid = toString [_grid select 0, _grid select 1, _grid select 2];
_yGrid = toString [_grid select 3, _grid select 4, _grid select 5];
};
} else {
_xGrid = toString [_grid select 0, _grid select 1];
_yGrid = toString [_grid select 2, _grid select 3];
};
[_xGrid, _yGrid]

View File

@ -10,3 +10,6 @@
#endif
#include "\z\ace\addons\main\script_macros.hpp"
#define DEG_TO_MIL(d) (d / 360 * 6400)
#define MIL_TO_DEG(d) (d / 6400 * 360)