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

View File

@ -3,7 +3,6 @@
DAGR_RUN = false; DAGR_RUN = false;
DAGR_STP = false; DAGR_STP = false;
DAGR_MENU_RUN = false; DAGR_MENU_RUN = false;
Dagr_Map_Info = "default";
DAGR_DIRECTION = true; // true -> degrees; false -> milliradian DAGR_DIRECTION = true; // true -> degrees; false -> milliradian
DAGR_GRID_VECTOR = "00000000"; // Default DAGR_GRID_VECTOR = "00000000"; // Default
@ -18,11 +17,11 @@ DAGR_WP1 = 0;
DAGR_WP2 = 0; DAGR_WP2 = 0;
DAGR_WP3 = 0; DAGR_WP3 = 0;
DAGR_WP4 = 0; DAGR_WP4 = 0;
DAGRSLEEP = 0.5; // Update timer on DAGR, set for 0.5 seconds DAGR_UPDATE_INTERVAL = 0.5; // Update timer on DAGR, set for 0.5 seconds
DAGR_EMPTYVECTOR = true; // Keeps DAGR Vector display from filling up before use DAGR_EMPTY_VECTOR = true; // Keeps DAGR Vector display from filling up before use
DAGR_DISPLAY_SELECTION = "DATA"; // Sets DAGR for data display 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); ["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_OUTPUT_WP);
PREP(DAGR_START); PREP(DAGR_START);
PREP(DAGR_VECTOR); PREP(DAGR_VECTOR);
PREP(mapCoord);
ADDON = true; ADDON = true;

View File

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

View File

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

View File

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

View File

@ -17,14 +17,14 @@
*/ */
#include "script_component.hpp" #include "script_component.hpp"
#define EMP_RF_ACC 5 #define EMP_RF_ACC 5 // Rangefinder Accuracy
PARAMS_3(_slopeDistance,_azimuth,_inclination); PARAMS_3(_slopeDistance,_azimuth,_inclination);
if (!DAGR_EMPTYVECTOR) then { if (!DAGR_EMPTY_VECTOR) then {
DAGRLAZPOS = (eyePos player) vectorAdd ([_slopeDistance, _azimuth, _inclination] call CBA_fnc_polar2vect); GVAR(LAZPOS) = (eyePos player) vectorAdd ([_slopeDistance, _azimuth, _inclination] call CBA_fnc_polar2vect);
DAGRLAZDIST = _slopeDistance * cos(_inclination); GVAR(LAZDIST) = _slopeDistance * cos(_inclination);
DAGRLAZDIST = floor(DAGRLAZDIST / EMP_RF_ACC) * EMP_RF_ACC; GVAR(LAZDIST) = floor (GVAR(LAZDIST) / EMP_RF_ACC) * EMP_RF_ACC;
DAGRLazHeading = _azimuth; GVAR(LAZHEADING) = _azimuth;
NODAGRDISPLAY = false; 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 #endif
#include "\z\ace\addons\main\script_macros.hpp" #include "\z\ace\addons\main\script_macros.hpp"
#define DEG_TO_MIL(d) (d / 360 * 6400)
#define MIL_TO_DEG(d) (d / 6400 * 360)