Jump to content
Sign in to follow this  
aduke823

New markers on dynamically placed waypoint positions

Recommended Posts

Hello there,

So, I have this dialog that I have been working on that looks like this........

MFD.jpg

The way it works is that the user can bring up the map, and set multiple waypoints for themselves.

The problem I am having is in the waypoint placement and the waypoint's associated markers, the area is marked in bold here...........

_unit = vehicle player;

if (((_this select 1) select 1) == 0) then

{

if (leader group player == player) then

{

if (!((_this select 1) select 6)) then

{

_pos = ((_this select 1) select 0) ctrlMapScreenToWorld [(_this select 1) select 2, (_this select 1) select 3];

_wp = group player addWaypoint [_pos, 0];

_wp setWaypointType "MOVE";

_wp showWaypoint "NEVER";

_ad_nav_markernumber = _ad_nav_markernumber + 1;

createMarkerLocal [format["navmarker%1", _ad_nav_markernumber], _pos];

format["navmarker%1", _ad_nav_markernumber] setMarkerTypeLocal "mil_circle";

playSound "ad_bleep";

}

else

{

_pos = ((_this select 1) select 0) ctrlMapScreenToWorld [(_this select 1) select 2, (_this select 1) select 3];

_closer = 0;

_min_dst = 100000;

_wps = waypoints group player;

for [{_i=0},{_i < (count _wps)},{_i=_i+1}] do

{

_dist = _pos distance getWPPos [group player, _i];

if ((_dist < _min_dst) && (_dist < 100)) then

{

_min_dst = _dist;

_closer = _i;

};

};

if (_closer != 0) then

{

deleteWaypoint [group player, _closer];

};

};

}

else

{

playSound "denied";

titleText ["You are not the group leader and cannot modify waypoints", "PLAIN DOWN"];

};

};

The problem is that I want a new marker to be created at each waypoints map position, right now a waypoint is ONLY being created at the first placed waypoint's position.

Can you help?

If so chime in please.

-AD

Edited by ADuke823

Share this post


Link to post
Share on other sites

Okay, the magical crystal ball strikes in again :D

When is this script called? Through which command/eventhandler is it called?

In which format is the parameter delivered to your code? (all the nested selects are confusing ^^)

If this code is called within an eventhandler or part of a spawn/execVM, your variable "_ad_nav_markernumber" will always have the number 1 or "any", because the variable is local and is destroyed once you leave the if-clause where it gets defined.

I know I'm a lazy bitch, but if you just toss your code into a non-highlighted bbcode (try using PHP-Tags) without even adding any indention, it's really hard to read and if the select-orgy isn't commented or saved in local variables with descriptive names, no one really can see where your flow of code is going because we don't know which values the selects will receive.

You just add one marker when creating the first MOVE-waypoint (WP-Index: 0). What you have to do is whenever the user clicks into the map to assign a new waypoint, your script has to create the waypoint AND the marker.

I'm sure you knew that and this is the problem your having, but if you can't describe your code better, we can't help you, at least I can't xD

Share this post


Link to post
Share on other sites

OK, to clear things up........

The first script is executed via an eventhandler in the config, like so....

	class EventHandlers 
	{
		init = "[_this select 0] execVM ""\ad_helos_det7\Scripts\navcomputer_init.sqf""";
	};

This is the script that is executed.........

_helo = _this select 0;
_pilot = driver _helo;

_navact = _helo addAction ["Navigation Computer", "\ad_helos_det7\Scripts\navcomputer.sqf"];

Here is that next script.......

_handle = CreateDialog "AD_NAV_DIALOG";

I know, both of those scripts do not have much to them, I am going to add some server side/client side stuff later, right now I just need the basic functions to work before I make it MP friendly.

Here is the defines.hpp file, which is #included in the config....

// Control types
#define CT_STATIC           0
#define CT_BUTTON           1
#define CT_EDIT             2
#define CT_SLIDER           3
#define CT_COMBO            4
#define CT_LISTBOX          5
#define CT_TOOLBOX          6
#define CT_CHECKBOXES       7
#define CT_PROGRESS         8
#define CT_HTML             9
#define CT_STATIC_SKEW      10
#define CT_ACTIVETEXT       11
#define CT_TREE             12
#define CT_STRUCTURED_TEXT  13
#define CT_CONTEXT_MENU     14
#define CT_CONTROLS_GROUP   15
#define CT_SHORTCUTBUTTON   16
#define CT_XKEYDESC         40
#define CT_XBUTTON          41
#define CT_XLISTBOX         42
#define CT_XSLIDER          43
#define CT_XCOMBO           44
#define CT_ANIMATED_TEXTURE 45
#define CT_OBJECT           80
#define CT_OBJECT_ZOOM      81
#define CT_OBJECT_CONTAINER 82
#define CT_OBJECT_CONT_ANIM 83
#define CT_LINEBREAK        98
#define CT_USER             99
#define CT_MAP              100
#define CT_MAP_MAIN         101
#define CT_LISTNBOX         102

// Static styles
#define ST_POS            0x0F
#define ST_HPOS           0x03
#define ST_VPOS           0x0C
#define ST_LEFT           0x00
#define ST_RIGHT          0x01
#define ST_CENTER         0x02
#define ST_DOWN           0x04
#define ST_UP             0x08
#define ST_VCENTER        0x0C
#define ST_GROUP_BOX       96
#define ST_GROUP_BOX2      112
#define ST_ROUNDED_CORNER  ST_GROUP_BOX + ST_CENTER
#define ST_ROUNDED_CORNER2 ST_GROUP_BOX2 + ST_CENTER

#define ST_TYPE           0xF0
#define ST_SINGLE         0x00
#define ST_MULTI          0x10
#define ST_TITLE_BAR      0x20
#define ST_PICTURE        0x30
#define ST_FRAME          0x40
#define ST_BACKGROUND     0x50
#define ST_GROUP_BOX      0x60
#define ST_GROUP_BOX2     0x70
#define ST_HUD_BACKGROUND 0x80
#define ST_TILE_PICTURE   0x90
#define ST_WITH_RECT      0xA0
#define ST_LINE           0xB0

#define ST_SHADOW         0x100
#define ST_NO_RECT        0x200
#define ST_KEEP_ASPECT_RATIO  0x800

#define ST_TITLE          ST_TITLE_BAR + ST_CENTER

// Slider styles
#define SL_DIR            0x400
#define SL_VERT           0
#define SL_HORZ           0x400

#define SL_TEXTURES       0x10

// progress bar 
#define ST_VERTICAL       0x01
#define ST_HORIZONTAL     0

// Listbox styles
#define LB_TEXTURES       0x10
#define LB_MULTI          0x20

// Tree styles
#define TR_SHOWROOT       1
#define TR_AUTOCOLLAPSE   2

// MessageBox styles
#define MB_BUTTON_OK      1
#define MB_BUTTON_CANCEL  2
#define MB_BUTTON_USER    4

////////////////
//Base Classes//
////////////////

class RscText
{
   access = 0;
   idc = -1;
   type = CT_STATIC;
   style = ST_CENTER;
   linespacing = 1;
   colorBackground[] = {0,0,0,0};
   colorText[] = {1,1,1,.5};
   text = "";
   shadow = 2;
   font = "Bitstream";
   SizeEx = 0.02300;
   fixedWidth = 0;
   x = 0;
   y = 0;
   h = 0;
   w = 0;
};
class RscPicture
{
   access = 0;
   idc = -1;
   type = CT_STATIC;
   style = ST_PICTURE;
   colorBackground[] = {0,0,0,0};
   colorText[] = {1,1,1,1};
   font = "Bitstream";
   sizeEx = 0;
   lineSpacing = 0;
   text = "";
   fixedWidth = 0;
   shadow = 0;
   x = 0;
   y = 0;
   w = 0.2;
   h = 0.15;
};
class RscButton
{
access = 0;
   type = CT_BUTTON;
   text = "";
   colorText[] = {1,1,1,.9};
   colorDisabled[] = {0.4,0.4,0.4,0};
   colorBackground[] = {0.75,0.75,0.75,0.8};
   colorBackgroundDisabled[] = {0,0.0,0};
   colorBackgroundActive[] = {0.75,0.75,0.75,1};
   colorFocused[] = {0.75,0.75,0.75,.5};
   colorShadow[] = {0.023529,0,0.0313725,1};
   colorBorder[] = {0.023529,0,0.0313725,1};
   soundEnter[] = {"\ca\ui\data\sound\onover",0.09,1};
   soundPush[] = {"\ca\ui\data\sound\new1",0,0};
   soundClick[] = {"\ca\ui\data\sound\onclick",0.07,1};
   soundEscape[] = {"\ca\ui\data\sound\onescape",0.09,1};
   style = 2;
   x = 0;
   y = 0;
   w = 0.055589;
   h = 0.039216;
   shadow = 2;
   font = "Bitstream";
   sizeEx = 0.03921;
   offsetX = 0.003;
   offsetY = 0.003;
   offsetPressedX = 0.002;
   offsetPressedY = 0.002;
   borderSize = 0;
};
class RscFrame
{
   type = CT_STATIC;
   idc = -1;
   style = ST_FRAME;
   shadow = 2;
   colorBackground[] = {1,1,1,1};
   colorText[] = {1,1,1,0.9};
   font = "Bitstream";
   sizeEx = 0.03;
   text = "";
};
class BOX
{ 
  type = CT_STATIC;
   idc = -1;
   style = ST_CENTER;
   shadow = 2;
   colorText[] = {1,1,1,1};
   font = "Bitstream";
   sizeEx = 0.02;
   colorBackground[] = { 0.2,0.2,0.2, 0.9 }; 
   text = ""; 
};
class rscMapControl
{
access = ReadAndWrite;
type = 101;
idc = 51;
style = 48;
colorBackground[] = {1, 1, 1, 1};
colorText[] = {0, 0, 0, 1};
font = "TahomaB";
sizeEx = 0.04;
colorSea[] = {0.56, 0.8, 0.98, 0.5};
colorForest[] = {0.6, 0.8, 0.2, 0.5};
colorRocks[] = {0.5, 0.5, 0.5, 0.5};
colorCountlines[] = {0.65, 0.45, 0.27, 0.5};
colorMainCountlines[] = {0.65, 0.45, 0.27, 1};
colorCountlinesWater[] = {0, 0.53, 1, 0.5};
colorMainCountlinesWater[] = {0, 0.53, 1, 1};
colorForestBorder[] = {0.4, 0.8, 0, 1};
colorRocksBorder[] = {0.5, 0.5, 0.5, 1};
colorPowerLines[] = {0, 0, 0, 1};
colorNames[] = {0, 0, 0, 1};
colorInactive[] = {1, 1, 1, 0.5};
colorLevels[] = {0, 0, 0, 1};
colorOutside[] = { 1, 1, 0, 1};		
colorRailWay[] = { 0 , 0, 0.5, 1};
maxSatelliteAlpha = 0.8;
alphaFadeStartScale = 1;
alphaFadeEndScale = 2;		
fontLabel = "Zeppelin32";
sizeExLabel = 0.027;
fontGrid = "Zeppelin32";
sizeExGrid = 0.027;
fontUnits = "Zeppelin32";
sizeExUnits = 0.027;
fontNames = "Zeppelin32";
sizeExNames = 0.027;
fontInfo = "Zeppelin32";
sizeExInfo = 0.027;
fontLevel = "Zeppelin32";
sizeExLevel = 0.027;
text = "#(argb,8,8,3)color(1,1,1,1)";
stickX[] = {0.2, {"Gamma", 1, 1.5}};
stickY[] = {0.2, {"Gamma", 1, 1.5}};
ptsPerSquareSea = 6;
ptsPerSquareTxt = 8;
ptsPerSquareCLn = 8;
ptsPerSquareExp = 8;
ptsPerSquareCost = 8;
ptsPerSquareFor = "4.0f";
ptsPerSquareForEdge = "10.0f";
ptsPerSquareRoad = 2;
ptsPerSquareObj = 10;	
class Bunker 
{
	icon = "\ca\ui\data\map_bunker_ca.paa";
	color[] = {0.55, 0.64, 0.43, 1};
	size = 16;
	importance = 1.5 * 14 * 0.05;
	coefMin = 0.25;
	coefMax = 4;
};
class Bush 
{
	icon = "\ca\ui\data\map_bush_ca.paa";
	color[] = {0.55, 0.64, 0.43, 1};
	size = 16;
	importance = 0.2 * 14 * 0.05;
	coefMin = 0.25;
	coefMax = 4;
};
class BusStop 
{
	icon = "\ca\ui\data\map_busstop_ca.paa";
	color[] = {0, 0, 1, 1};
	size = 10;
	importance = 1 * 10 * 0.05;
	coefMin = 0.25;
	coefMax = 4;
};
class Cross 
{
	icon = "\ca\ui\data\map_cross_ca.paa";
	color[] = {0.55, 0.64, 0.43, 1};
	size = 16;
	importance = 0.7 * 16 * 0.05;
	coefMin = 0.25;
	coefMax = 4;
};
class Task 
{
	icon = "\ca\ui\data\map_cross_ca.paa";
	color[] = {0.55, 0.64, 0.43, 1};
	size = 16;
	importance = 0.7 * 16 * 0.05;
	coefMin = 0.25;
	coefMax = 4;
       iconCreated = "#(argb,8,8,3)color(1,1,1,1)";
       iconCanceled = "#(argb,8,8,3)color(0,0,1,1)";
       iconDone = "#(argb,8,8,3)color(0,0,0,1)";
       iconFailed = "#(argb,8,8,3)color(1,0,0,1)";
       colorCreated[] = {1,1,1,1};
       colorCanceled[] = {1,1,1,1};
       colorDone[] = {1,1,1,1};
       colorFailed[] = {1,1,1,1};
};
class CustomMark 
{
	icon = "\ca\ui\data\map_cross_ca.paa";
	color[] = {0.55, 0.64, 0.43, 1};
	size = 16;
	importance = 0.7 * 16 * 0.05;
	coefMin = 0.25;
	coefMax = 4;
};
class Fortress 
{
	icon = "\ca\ui\data\map_bunker_ca.paa";
	color[] = {0.55, 0.64, 0.43, 1};
	size = 16;
	importance = 2 * 16 * 0.05;
	coefMin = 0.25;
	coefMax = 4;
};
class Fuelstation 
{
	icon = "\ca\ui\data\map_fuelstation_ca.paa";
	color[] = {0.55, 0.64, 0.43, 1};
	size = 16;
	importance = 2 * 16 * 0.05;
	coefMin = 0.75;
	coefMax = 4;
};
class Fountain 
{
	icon = "\ca\ui\data\map_fountain_ca.paa";
	color[] = {0, 0.35, 0.7, 1};
	size = 12;
	importance = 1 * 12 * 0.05;
	coefMin = 0.25;
	coefMax = 4;
};
class Hospital 
{
	icon = "\ca\ui\data\map_hospital_ca.paa";
	color[] = {0.78, 0, 0.05, 1};
	size = 16;
	importance = 2 * 16 * 0.05;
	coefMin = 0.5;
	coefMax = 4;
};
class Chapel 
{
	icon = "\ca\ui\data\map_chapel_ca.paa";
	color[] = {0.55, 0.64, 0.43, 1};
	size = 16;
	importance = 1 * 16 * 0.05;
	coefMin = 0.9;
	coefMax = 4;
};
class Church 
{
	icon = "\ca\ui\data\map_church_ca.paa";
	color[] = {0.55, 0.64, 0.43, 1};
	size = 16;
	importance = 2 * 16 * 0.05;
	coefMin = 0.9;
	coefMax = 4;
};
class Lighthouse 
{
	icon = "\ca\ui\data\map_lighthouse_ca.paa";
	color[] = {0.78, 0, 0.05, 1};
	size = 20;
	importance = 3 * 16 * 0.05;
	coefMin = 0.9;
	coefMax = 4;
};
class Quay 
{
	icon = "\ca\ui\data\map_quay_ca.paa";
	color[] = {0.55, 0.64, 0.43, 1};
	size = 16;
	importance = 2 * 16 * 0.05;
	coefMin = 0.5;
	coefMax = 4;
};
class Rock 
{
	icon = "\ca\ui\data\map_rock_ca.paa";
	color[] = {0.55, 0.64, 0.43, 1};
	size = 12;
	importance = 0.5 * 12 * 0.05;
	coefMin = 0.25;
	coefMax = 4;
};
class Ruin 
{
	icon = "\ca\ui\data\map_ruin_ca.paa";
	color[] = {0.78, 0, 0.05, 1};
	size = 16;
	importance = 1.2 * 16 * 0.05;
	coefMin = 1;
	coefMax = 4;
};
class SmallTree 
{
	icon = "\ca\ui\data\map_smalltree_ca.paa";
	color[] = {0.55, 0.64, 0.43, 1};
	size = 16;
	importance = 0.6 * 12 * 0.05;
	coefMin = 0.25;
	coefMax = 4;
};
class Stack 
{
	icon = "\ca\ui\data\map_stack_ca.paa";
	color[] = {0.55, 0.64, 0.43, 1};
	size = 20;
	importance = 2 * 16 * 0.05;
	coefMin = 0.9;
	coefMax = 4;
};
class Tree 
{
	icon = "\ca\ui\data\map_tree_ca.paa";
	color[] = {0.55, 0.64, 0.43, 1};
	size = 16;
	importance = 0.9 * 16 * 0.05;
	coefMin = 0.25;
	coefMax = 4;	
};
class Tourism 
{
	icon = "\ca\ui\data\map_tourism_ca.paa";
	color[] = {0.78, 0, 0.05, 1};
	size = 16;
	importance = 1 * 16 * 0.05;
	coefMin = 0.7;
	coefMax = 4;
};
class Transmitter 
{
	icon = "\ca\ui\data\map_transmitter_ca.paa";
	size = 20;
	color[] = {0, 0.35, 0.7, 1};
	importance = 2 * 16 * 0.05;
	coefMin = 0.9;
	coefMax = 4;
};
class ViewTower 
{
	icon = "\ca\ui\data\map_viewtower_ca.paa";
	size = 16;
	color[] = {0, 0.35, 0.7, 1};
	importance = 2.5 * 16 * 0.05;
	coefMin = 0.5;
	coefMax = 4;
};
class Watertower 
{
	icon = "\ca\ui\data\map_watertower_ca.paa";
	color[] = {0, 0.35, 0.7, 1};
	size = 32;
	importance = 1.2 * 16 * 0.05;
	coefMin = 0.9;
	coefMax = 4;
};
class Waypoint 
{
	icon = "\ca\ui\data\map_waypoint_ca.paa";
	size = 16;
	color[] = {0, 0.35, 0.7, 1};
	importance = 2.5 * 16 * 0.05;
	coefMin = 0.5;
	coefMax = 4;		
};
class WaypointCompleted 
{
	icon = "\ca\ui\data\map_waypoint_completed_ca.paa";
	size = 16;
	color[] = {0, 0.35, 0.7, 1};
	importance = 2.5 * 16 * 0.05;
	coefMin = 0.5;
	coefMax = 4;		
};	
};

Here is dialogs.hpp, also #included in the config.......

class AD_NAV_DIALOG
{
idd = -1;
movingEnable = false;
onLoad = "(_this select 0) call compile preprocessFileLineNumbers ""\ad_helos_det7\Scripts\hideControls.sqf""";
class controlsBackground
{
	class AD_NAV_MAP: rscMapControl
	{
		idc = 420;
		maxSatelliteAlpha = 0;
		x = 0.317972 * safezoneW + safezoneX;
		y = 0.292763 * safezoneH + safezoneY;
		w = 0.362428 * safezoneW;
		h = 0.417379 * safezoneH;
		onMouseZChanged = "";
		onMouseButtonDown = "[""onMapClick"", _this] execVM ""\ad_helos_det7\Scripts\add_waypoints.sqf""";
	};
};
class controls
{
	class AD_NAV_PICTURE: RscPicture
	{
		idc = 421;
		text = "\ad_helos_det7\textures\navcomputer.paa";
		x = 0.306987 * safezoneW + safezoneX;
		y = 0.267192 * safezoneH + safezoneY;
		w = 0.388058 * safezoneW;
		h = 0.464999 * safezoneH;
	};
	class AD_NAV_BUTTON1: RscButton
	{
		idc = 422;
		text = "o";
		x = 0.308033 * safezoneW + safezoneX;
		y = 0.369486 * safezoneH + safezoneY;
		w = 0.0151097 * safezoneW;
		h = 0.0240728 * safezoneH;
		tooltip = "Remove all waypoints";
		action = "_nil=[]ExecVM ""\ad_helos_det7\Scripts\remove_waypoints_button.sqf""";
	};
	class AD_TEXT1: RscText
	{
		idc = 423;
		text = "ALL WAYPOINTS REMOVED";
		x = 0.305941 * safezoneW + safezoneX;
		y = 0.744274 * safezoneH + safezoneY;
		w = 0.387535 * safezoneW;
		h = 0.0805112 * safezoneH;
		colorText[] = {0.5625,0.92969,0.5625,1};
		size = 0.01921;
	};
	class AD_NAV_BUTTON2: RscButton
	{
		idc = 424;
		text = "NO";
		x = 0.598337 * safezoneW + safezoneX;
		y = 0.596121 * safezoneH + safezoneY;
		w = 0.0464939 * safezoneW;
		h = 0.0672836 * safezoneH;
	};
};
};

See this bit here?

		onMouseButtonDown = "[""onMapClick"", _this] execVM ""\ad_helos_det7\Scripts\add_waypoints.sqf""";

Ya, that is where the problem script is...

_unit = vehicle player;

if (((_this select 1) select 1) == 0) then
{

if (leader group player == player) then
{
	if (!((_this select 1) select 6)) then
	{
		_pos = ((_this select 1) select 0) ctrlMapScreenToWorld [(_this select 1) select 2, (_this select 1) select 3];
		_wp = group player addWaypoint [_pos, 0];
		_wp setWaypointType "MOVE";
		_wp showWaypoint "NEVER";
		_ad_nav_markernumber = _ad_nav_markernumber + 1;
		createMarkerLocal [format["navmarker%1", _ad_nav_markernumber], _pos];
		format["navmarker%1", _ad_nav_markernumber] setMarkerTypeLocal "mil_circle";
		playSound "ad_bleep";
	}
	else
	{
		_pos = ((_this select 1) select 0) ctrlMapScreenToWorld [(_this select 1) select 2, (_this select 1) select 3];
		_closer = 0;
		_min_dst = 100000;
		_wps = waypoints group player;
		for [{_i=0},{_i < (count _wps)},{_i=_i+1}] do
		{
			_dist = _pos distance getWPPos [group player, _i];
			if ((_dist < _min_dst) && (_dist < 100)) then
			{
				_min_dst = _dist;
				_closer = _i;
			};
		};	
	if (_closer != 0) then
	{
		deleteWaypoint [group player, _closer];
	};		
};
}
else
{
	playSound "denied";
	titleText ["You are not the group leader and cannot modify waypoints", "PLAIN DOWN"];
};
};

I know, clear as mud right?

The "select orgy" that you are referring to is there to calculate the position of the click within the dialog.

I am not concerned with that at the moment, what I am concerned with is these markers being placed at every click.

-AD

Edited by ADuke823

Share this post


Link to post
Share on other sites
I am not concerned with that at the moment, what I am concerned with is these markers being placed at every click.

That might be true, you might not be concerned about that, but I am ^^ Because I don't know what ((_this select 1) select 6) is.

According to BIKI there is either no element at index 6 or a boolean indicating if the alt-button was pressed while clicking.

This is important information, I need to understand what your script does before going in and searching for errors :)

Okay, the problem IS the local variable :D The weirdest problems are caused by the tiniest things... xDD

_unit = vehicle player;
if (isNil "ad_nav_markernumber") then
{
   ad_nav_markernumber = 0;
};


if (((_this select 1) select 1) == 0) then
{

   if (leader group player == player) then
   {
       if (!((_this select 1) select 6)) then
       {
           _pos = ((_this select 1) select 0) ctrlMapScreenToWorld [(_this select 1) select 2, (_this select 1) select 3];
           _wp = group player addWaypoint [_pos, 0];
           _wp setWaypointType "MOVE";
           _wp showWaypoint "NEVER";
           ad_nav_markernumber = ad_nav_markernumber + 1;
           _marker = createMarkerLocal [format["navmarker%1", ad_nav_markernumber], _pos];
           _marker setMarkerTypeLocal "mil_circle";
           playSound "ad_bleep";
       }
       else
       {
           _pos = ((_this select 1) select 0) ctrlMapScreenToWorld [(_this select 1) select 2, (_this select 1) select 3];
           _closer = 0;
           _min_dst = 100000;
           _wps = waypoints group player;
           for [{_i=0},{_i < (count _wps)},{_i=_i+1}] do
           {
               _dist = _pos distance getWPPos [group player, _i];
               if ((_dist < _min_dst) && (_dist < 100)) then
               {
                   _min_dst = _dist;
                   _closer = _i;
               };
           };    
       if (_closer != 0) then
       {
           deleteWaypoint [group player, _closer];
       };        
   };
   }
   else
   {
       playSound "denied";
       titleText ["You are not the group leader and cannot modify waypoints", "PLAIN DOWN"];
   };
};  

this should do the trick

Share this post


Link to post
Share on other sites

Thanks for your reply, but unfortunately.............

I tested multiple times and I still only get a marker at the first waypoint only.

:(

Share this post


Link to post
Share on other sites

Hmm that's very strange, I just did test it several times and it worked every time, are the waypoints after the first one set accordingly?

Like hearing the bleep-sound every time you place a waypoint?

Is the marker placed on the ingame map (the one you can open with M) and not on yours perhaps? (I know that makes no sense but it's worth a try :D)

Maybe the _pos value turns into something not appropriate to place the marker, try to output using "hintsilent str _pos" and check the values for validity.

I'll try to implement your mini-map and try it out for myself in the meantime.

Share this post


Link to post
Share on other sites

The marker is actually placed on my dialog map and the in-game map.

I would actually like it to ONLY be placed on my dialog map if at all possible (I have seen this done and it baffles me).

I do hear the beep sound.

I will try to output the pos in a hint.

Thanks,

-AD

EDIT: I hear the beep sound at EVERY placed waypoint, and I can follow them in succession, everything works as normal....minus the additional markers

Share this post


Link to post
Share on other sites

Thats really strange, I just implemented your stuff and with the code I provided in Post #4 it works, the additional markers are shown.

I don't know how to limit the markers for your custom map-ctrl though, that would be worth a new thread I suppose, I'd like to know that as well :D

Edited by XxAnimusxX

Share this post


Link to post
Share on other sites

I must have done something wrong, will recheck and retest.

---------- Post added at 23:16 ---------- Previous post was at 23:05 ----------

I don't know how to limit the markers for your custom map-ctrl though, that would be worth a new thread I suppose, I'd like to know that as well

I think the key to that lies in deleting the markers when the dialog closes, and then re-adding them when it opens.

Or maybe just removing them when the dialog closes, because with each new instance of the dialog you are setting a new path.

EDIT: OK, your code works, I just had a rogue underscore screwing things up.

Onto, my next question........

I need these markers to be deleted when the dialog closes, or for them to be deleted upon reaching each waypoint.

I am brainstorming that now.

---------- Post added at 23:29 ---------- Previous post was at 23:16 ----------

I am going to try using setWaypointStatements to delete the closest marker to the waypoint when the waypoint is completed I think.

Edited by ADuke823

Share this post


Link to post
Share on other sites

Okay, fiddled around and now got both working: Deleting marker when you reach the waypoint and delete all markers when you close the dialog and readd them when you open it.

But for this to work I had to also delete the waypoint when you reach it, that shouldn't be a great problem though :)

Okay, add this somewhere in your hideControls.sqf:

if (isNil "ad_nav_markernumber") then
{
   ad_nav_markernumber = 0;
ad_nav_markers = [];
};

{
if (_x select 1 != 0) then
{
	ad_nav_markernumber = ad_nav_markernumber + 1;
	_marker = createMarkerLocal [format["navmarker%1", ad_nav_markernumber], getWPPos _x];
	_marker setMarkerTypeLocal "mil_circle";
	ad_nav_markers set [count ad_nav_markers, _marker];
};
} forEach (waypoints group player);

This is the content of add_waypoint.sqf:

_unit = vehicle player;

if (((_this select 1) select 1) == 0) then
{
   if (leader group player == player) then
   {
       if (!((_this select 1) select 6)) then
       {
		ad_nav_markernumber = ad_nav_markernumber + 1;

           _pos = ((_this select 1) select 0) ctrlMapScreenToWorld [(_this select 1) select 2, (_this select 1) select 3];

           _wp = group player addWaypoint [_pos, 0];
           _wp setWaypointType "MOVE";
           _wp showWaypoint "NEVER";
           _wp setWaypointStatements ["true", format["deleteMarker 'navmarker%1'; deleteWaypoint [group this, 0];", ad_nav_markernumber]];

           _marker = createMarkerLocal [format["navmarker%1", ad_nav_markernumber], _pos];
           _marker setMarkerTypeLocal "mil_circle";
		ad_nav_markers set [count ad_nav_markers, _marker];

           playSound "ad_bleep";
       }
       else
       {
           _pos = ((_this select 1) select 0) ctrlMapScreenToWorld [(_this select 1) select 2, (_this select 1) select 3];
           _closer = 0;
           _min_dst = 100000;
           _wps = waypoints group player;
           for [{_i=0},{_i < (count _wps)},{_i=_i+1}] do
           {
               _dist = _pos distance getWPPos [group player, _i];
               if ((_dist < _min_dst) && (_dist < 100)) then
               {
                   _min_dst = _dist;
                   _closer = _i;
               };
           };    
       if (_closer != 0) then
       {
           deleteWaypoint [group player, _closer];
       };        
   };
   }
   else
   {
       playSound "denied";
       titleText ["You are not the group leader and cannot modify waypoints", "PLAIN DOWN"];
   };
};  

And at last, this should be called by your addAction:

[] spawn {
   createDialog "AD_NAV_DIALOG";
   waitUntil {!dialog};
   {
   	deleteMarker _x;
   } forEach ad_nav_markers;
   ad_nav_markers = [];
   ad_nav_markernumber = 0;
};

It works great and it looks like the markers are just set on your custom map :)

I'd like to thank you as well bud, I wanted to do something similiar with a custom map and now you delivered all the knowledge I need to config that beast (I'm not that knowledgable about configs...)

Edited by XxAnimusxX

Share this post


Link to post
Share on other sites

Wow, you are a beast with the scripting, thanks a lot for all of your help.

I will be sure to let everyone who uses this know how much you helped.

This thread could also be a world of knowledge for someone trying to do something similar, which happens more often than we know probably.

-AD

Share this post


Link to post
Share on other sites

Okay, hold on bud, I found something really interesting :D

I was browsing through the map-config and noticed two really interesting subclasses: class Waypoint and class WaypointCompleted.

Just editing the icon-path will yield the SAME results like doing it with markers! It means we don't need any markers anymore :D

Okay browse into your defines.hpp and get to the very bottom, there you'll see the above meantioned subclasses.

Change the icon of class Waypoint to "\ca\ui\data\markers\gr_marker_circle_CA.paa" and size to 20 or greater. You can also fiddle with the color to colorize the waypoint-marker.

For the icon of the class WaypointCompleted I took "\ca\ui\data\markers\hd_start_point_CA.paa" and left the original size. You can take your own images if you want, supplying pure white images will enable you to colorize it using the color[] attribute.

Outcome so far:

    class Waypoint 
   {
       icon = "\ca\ui\data\markers\gr_marker_circle_CA.paa";
       size = 20;
       color[] = {0, 0, 0, 1};
       importance = 2.5 * 16 * 0.05;
       coefMin = 0.5;
       coefMax = 4;        
   };
   class WaypointCompleted 
   {
       icon = "\ca\ui\data\markers\hd_start_point_CA.paa";
       size = 16;
       color[] = {0, 0.7, 0.0, 0.5};
       importance = 2.5 * 16 * 0.05;
       coefMin = 0.5;
       coefMax = 4;        
   };    

Replace all the code you added into your hideControls.sqf with this:

{
if (_x select 1 != 0) then
{
	_x showWaypoint "ALWAYS";
}
} forEach (waypoints group player);

add_waypoint.sqf:

_unit = vehicle player;

if (((_this select 1) select 1) == 0) then
{
   if (leader group player == player) then
   {
       if (!((_this select 1) select 6)) then
       {
           _pos = ((_this select 1) select 0) ctrlMapScreenToWorld [(_this select 1) select 2, (_this select 1) select 3];

           _wp = group player addWaypoint [_pos, 0];
           _wp setWaypointType "MOVE";
		_wp showWaypoint "ALWAYS";
           //_wp setWaypointStatements ["true", "deleteWaypoint [group this, 0];"];
           playSound "ad_bleep";
       }
       else
       {
           _pos = ((_this select 1) select 0) ctrlMapScreenToWorld [(_this select 1) select 2, (_this select 1) select 3];
           _closer = 0;
           _min_dst = 100000;
           _wps = waypoints group player;
           for [{_i=0},{_i < (count _wps)},{_i=_i+1}] do
           {
               _dist = _pos distance getWPPos [group player, _i];
               if ((_dist < _min_dst) && (_dist < 100)) then
               {
                   _min_dst = _dist;
                   _closer = _i;
               };
           };    
       if (_closer != 0) then
       {
           deleteWaypoint [group player, _closer];
       };        
   };
   }
   else
   {
       playSound "denied";
       titleText ["You are not the group leader and cannot modify waypoints", "PLAIN DOWN"];
   };
};  

(as you can see all traces of creating markers have disappeared).

The setWaypointStatements is commented out for a good reason. With this, every completed waypoint won't be deleted, but show a different icon. You could even use the same icon, but another color to show that the waypoint has been completed.

If you decide to erase the comment-lines and use the statement to delete the current waypoint, the first waypoint in your list will look like the icon defined in WaypointCompleted.

Just fiddle around with these values in the subclasses to achieve some eye-candy :)

And at last, replace the code in your addAction-eventhandler with this:

[] spawn {
   createDialog "AD_NAV_DIALOG";
   waitUntil {!dialog};
   {
   	_x showWaypoint "NEVER";
   } forEach (waypoints group player);
};

No more createMarker and arrays and alike, configs are awesome if you understand them properly :D

Share this post


Link to post
Share on other sites

Wow, that sounds cool,

I will try to implement that later tonight, got some other real-life things to take care of.

-AD

Just brainstorming here, but I am going to make an icon that looks like a plus symbol.

Then maybe I/We could figure out a way to draw lines between the waypoints, like so.......

Just a thought,

-AD

OK, so I tried all of those changes, and it worked great!

I especially like the fact that the UI now places lines between the waypoints, makes it seem more realistic.

I have one major concern here.....

It seems that the values listed in defines.hpp are overwriting default ArmA2 values, I was getting some very strange UI bugs.

So I left the default classes alone, created my own classes with their own values, and inherited from the default classes, like so.......

defines.hpp

#define CT_STATIC           0
#define CT_BUTTON           1
#define CT_EDIT             2
#define CT_SLIDER           3
#define CT_COMBO            4
#define CT_LISTBOX          5
#define CT_TOOLBOX          6
#define CT_CHECKBOXES       7
#define CT_PROGRESS         8
#define CT_HTML             9
#define CT_STATIC_SKEW      10
#define CT_ACTIVETEXT       11
#define CT_TREE             12
#define CT_STRUCTURED_TEXT  13
#define CT_CONTEXT_MENU     14
#define CT_CONTROLS_GROUP   15
#define CT_SHORTCUTBUTTON   16
#define CT_XKEYDESC         40
#define CT_XBUTTON          41
#define CT_XLISTBOX         42
#define CT_XSLIDER          43
#define CT_XCOMBO           44
#define CT_ANIMATED_TEXTURE 45
#define CT_OBJECT           80
#define CT_OBJECT_ZOOM      81
#define CT_OBJECT_CONTAINER 82
#define CT_OBJECT_CONT_ANIM 83
#define CT_LINEBREAK        98
#define CT_USER             99
#define CT_MAP              100
#define CT_MAP_MAIN         101
#define CT_LISTNBOX         102
#define ST_POS            0x0F
#define ST_HPOS           0x03
#define ST_VPOS           0x0C
#define ST_LEFT           0x00
#define ST_RIGHT          0x01
#define ST_CENTER         0x02
#define ST_DOWN           0x04
#define ST_UP             0x08
#define ST_VCENTER        0x0C
#define ST_GROUP_BOX       96
#define ST_GROUP_BOX2      112
#define ST_ROUNDED_CORNER  ST_GROUP_BOX + ST_CENTER
#define ST_ROUNDED_CORNER2 ST_GROUP_BOX2 + ST_CENTER
#define ST_TYPE           0xF0
#define ST_SINGLE         0x00
#define ST_MULTI          0x10
#define ST_TITLE_BAR      0x20
#define ST_PICTURE        0x30
#define ST_FRAME          0x40
#define ST_BACKGROUND     0x50
#define ST_GROUP_BOX      0x60
#define ST_GROUP_BOX2     0x70
#define ST_HUD_BACKGROUND 0x80
#define ST_TILE_PICTURE   0x90
#define ST_WITH_RECT      0xA0
#define ST_LINE           0xB0
#define ST_SHADOW         0x100
#define ST_NO_RECT        0x200
#define ST_KEEP_ASPECT_RATIO  0x800
#define ST_TITLE          ST_TITLE_BAR + ST_CENTER
#define SL_DIR            0x400
#define SL_VERT           0
#define SL_HORZ           0x400
#define SL_TEXTURES       0x10
#define ST_VERTICAL       0x01
#define ST_HORIZONTAL     0
#define LB_TEXTURES       0x10
#define LB_MULTI          0x20
#define TR_SHOWROOT       1
#define TR_AUTOCOLLAPSE   2
#define MB_BUTTON_OK      1
#define MB_BUTTON_CANCEL  2
#define MB_BUTTON_USER    4

class RscText;
class AD_RscText: RscText
{
   access = 0;
   idc = -1;
   type = CT_STATIC;
   style = ST_CENTER;
   linespacing = 1;
   colorBackground[] = {0,0,0,0};
   colorText[] = {1,1,1,.5};
   text = "";
   shadow = 2;
   font = "Bitstream";
   SizeEx = 0.02300;
   fixedWidth = 0;
   x = 0;
   y = 0;
   h = 0;
   w = 0;
};
class RscPicture;
class AD_RscPicture: RscPicture
{
   access = 0;
   idc = -1;
   type = CT_STATIC;
   style = ST_PICTURE;
   colorBackground[] = {0,0,0,0};
   colorText[] = {1,1,1,1};
   font = "Bitstream";
   sizeEx = 0;
   lineSpacing = 0;
   text = "";
   fixedWidth = 0;
   shadow = 0;
   x = 0;
   y = 0;
   w = 0.2;
   h = 0.15;
};
class RscButton;
class AD_RscButton: RscButton
{
access = 0;
   type = CT_BUTTON;
   text = "";
   colorText[] = {1,1,1,.9};
   colorDisabled[] = {0.4,0.4,0.4,0};
   colorBackground[] = {0.75,0.75,0.75,0.8};
   colorBackgroundDisabled[] = {0,0.0,0};
   colorBackgroundActive[] = {0.75,0.75,0.75,1};
   colorFocused[] = {0.75,0.75,0.75,.5};
   colorShadow[] = {0.023529,0,0.0313725,1};
   colorBorder[] = {0.023529,0,0.0313725,1};
   soundEnter[] = {"\ca\ui\data\sound\onover",0.09,1};
   soundPush[] = {"\ca\ui\data\sound\new1",0,0};
   soundClick[] = {"\ca\ui\data\sound\onclick",0.07,1};
   soundEscape[] = {"\ca\ui\data\sound\onescape",0.09,1};
   style = 2;
   x = 0;
   y = 0;
   w = 0.055589;
   h = 0.039216;
   shadow = 2;
   font = "Bitstream";
   sizeEx = 0.03921;
   offsetX = 0.003;
   offsetY = 0.003;
   offsetPressedX = 0.002;
   offsetPressedY = 0.002;
   borderSize = 0;
};
class RscFrame;
class AD_RscFrame: RscFrame
{
   type = CT_STATIC;
   idc = -1;
   style = ST_FRAME;
   shadow = 2;
   colorBackground[] = {1,1,1,1};
   colorText[] = {1,1,1,0.9};
   font = "Bitstream";
   sizeEx = 0.03;
   text = "";
};
class RscMapControl;
class AD_RscMapControl: RscMapControl
{
access = ReadAndWrite;
type = 101;
idc = 51;
style = 48;
colorBackground[] = {1, 1, 1, 1};
colorText[] = {0, 0, 0, 1};
font = "TahomaB";
sizeEx = 0.04;
colorSea[] = {0.56, 0.8, 0.98, 0.5};
colorForest[] = {0.6, 0.8, 0.2, 0.5};
colorRocks[] = {0.5, 0.5, 0.5, 0.5};
colorCountlines[] = {0.65, 0.45, 0.27, 0.5};
colorMainCountlines[] = {0.65, 0.45, 0.27, 1};
colorCountlinesWater[] = {0, 0.53, 1, 0.5};
colorMainCountlinesWater[] = {0, 0.53, 1, 1};
colorForestBorder[] = {0.4, 0.8, 0, 1};
colorRocksBorder[] = {0.5, 0.5, 0.5, 1};
colorPowerLines[] = {0, 0, 0, 1};
colorNames[] = {0, 0, 0, 1};
colorInactive[] = {1, 1, 1, 0.5};
colorLevels[] = {0, 0, 0, 1};
colorOutside[] = { 1, 1, 0, 1};		
colorRailWay[] = { 0 , 0, 0.5, 1};
maxSatelliteAlpha = 0.8;
alphaFadeStartScale = 1;
alphaFadeEndScale = 2;		
fontLabel = "Zeppelin32";
sizeExLabel = 0.027;
fontGrid = "Zeppelin32";
sizeExGrid = 0.027;
fontUnits = "Zeppelin32";
sizeExUnits = 0.027;
fontNames = "Zeppelin32";
sizeExNames = 0.027;
fontInfo = "Zeppelin32";
sizeExInfo = 0.027;
fontLevel = "Zeppelin32";
sizeExLevel = 0.027;
text = "#(argb,8,8,3)color(1,1,1,1)";
stickX[] = {0.2, {"Gamma", 1, 1.5}};
stickY[] = {0.2, {"Gamma", 1, 1.5}};
ptsPerSquareSea = 6;
ptsPerSquareTxt = 8;
ptsPerSquareCLn = 8;
ptsPerSquareExp = 8;
ptsPerSquareCost = 8;
ptsPerSquareFor = "4.0f";
ptsPerSquareForEdge = "10.0f";
ptsPerSquareRoad = 2;
ptsPerSquareObj = 10;	
class Bunker 
{
	icon = "\ca\ui\data\map_bunker_ca.paa";
	color[] = {0.55, 0.64, 0.43, 1};
	size = 16;
	importance = 1.5 * 14 * 0.05;
	coefMin = 0.25;
	coefMax = 4;
};
class Bush 
{
	icon = "\ca\ui\data\map_bush_ca.paa";
	color[] = {0.55, 0.64, 0.43, 1};
	size = 16;
	importance = 0.2 * 14 * 0.05;
	coefMin = 0.25;
	coefMax = 4;
};
class BusStop 
{
	icon = "\ca\ui\data\map_busstop_ca.paa";
	color[] = {0, 0, 1, 1};
	size = 10;
	importance = 1 * 10 * 0.05;
	coefMin = 0.25;
	coefMax = 4;
};
class Cross 
{
	icon = "\ca\ui\data\map_cross_ca.paa";
	color[] = {0.55, 0.64, 0.43, 1};
	size = 16;
	importance = 0.7 * 16 * 0.05;
	coefMin = 0.25;
	coefMax = 4;
};
class Task 
{
	icon = "\ca\ui\data\map_cross_ca.paa";
	color[] = {0.55, 0.64, 0.43, 1};
	size = 16;
	importance = 0.7 * 16 * 0.05;
	coefMin = 0.25;
	coefMax = 4;
       iconCreated = "#(argb,8,8,3)color(1,1,1,1)";
       iconCanceled = "#(argb,8,8,3)color(0,0,1,1)";
       iconDone = "#(argb,8,8,3)color(0,0,0,1)";
       iconFailed = "#(argb,8,8,3)color(1,0,0,1)";
       colorCreated[] = {1,1,1,1};
       colorCanceled[] = {1,1,1,1};
       colorDone[] = {1,1,1,1};
       colorFailed[] = {1,1,1,1};
};
class CustomMark 
{
	icon = "\ca\ui\data\map_cross_ca.paa";
	color[] = {0.55, 0.64, 0.43, 1};
	size = 16;
	importance = 0.7 * 16 * 0.05;
	coefMin = 0.25;
	coefMax = 4;
};
class Fortress 
{
	icon = "\ca\ui\data\map_bunker_ca.paa";
	color[] = {0.55, 0.64, 0.43, 1};
	size = 16;
	importance = 2 * 16 * 0.05;
	coefMin = 0.25;
	coefMax = 4;
};
class Fuelstation 
{
	icon = "\ca\ui\data\map_fuelstation_ca.paa";
	color[] = {0.55, 0.64, 0.43, 1};
	size = 16;
	importance = 2 * 16 * 0.05;
	coefMin = 0.75;
	coefMax = 4;
};
class Fountain 
{
	icon = "\ca\ui\data\map_fountain_ca.paa";
	color[] = {0, 0.35, 0.7, 1};
	size = 12;
	importance = 1 * 12 * 0.05;
	coefMin = 0.25;
	coefMax = 4;
};
class Hospital 
{
	icon = "\ca\ui\data\map_hospital_ca.paa";
	color[] = {0.78, 0, 0.05, 1};
	size = 16;
	importance = 2 * 16 * 0.05;
	coefMin = 0.5;
	coefMax = 4;
};
class Chapel 
{
	icon = "\ca\ui\data\map_chapel_ca.paa";
	color[] = {0.55, 0.64, 0.43, 1};
	size = 16;
	importance = 1 * 16 * 0.05;
	coefMin = 0.9;
	coefMax = 4;
};
class Church 
{
	icon = "\ca\ui\data\map_church_ca.paa";
	color[] = {0.55, 0.64, 0.43, 1};
	size = 16;
	importance = 2 * 16 * 0.05;
	coefMin = 0.9;
	coefMax = 4;
};
class Lighthouse 
{
	icon = "\ca\ui\data\map_lighthouse_ca.paa";
	color[] = {0.78, 0, 0.05, 1};
	size = 20;
	importance = 3 * 16 * 0.05;
	coefMin = 0.9;
	coefMax = 4;
};
class Quay 
{
	icon = "\ca\ui\data\map_quay_ca.paa";
	color[] = {0.55, 0.64, 0.43, 1};
	size = 16;
	importance = 2 * 16 * 0.05;
	coefMin = 0.5;
	coefMax = 4;
};
class Rock 
{
	icon = "\ca\ui\data\map_rock_ca.paa";
	color[] = {0.55, 0.64, 0.43, 1};
	size = 12;
	importance = 0.5 * 12 * 0.05;
	coefMin = 0.25;
	coefMax = 4;
};
class Ruin 
{
	icon = "\ca\ui\data\map_ruin_ca.paa";
	color[] = {0.78, 0, 0.05, 1};
	size = 16;
	importance = 1.2 * 16 * 0.05;
	coefMin = 1;
	coefMax = 4;
};
class SmallTree 
{
	icon = "\ca\ui\data\map_smalltree_ca.paa";
	color[] = {0.55, 0.64, 0.43, 1};
	size = 16;
	importance = 0.6 * 12 * 0.05;
	coefMin = 0.25;
	coefMax = 4;
};
class Stack 
{
	icon = "\ca\ui\data\map_stack_ca.paa";
	color[] = {0.55, 0.64, 0.43, 1};
	size = 20;
	importance = 2 * 16 * 0.05;
	coefMin = 0.9;
	coefMax = 4;
};
class Tree 
{
	icon = "\ca\ui\data\map_tree_ca.paa";
	color[] = {0.55, 0.64, 0.43, 1};
	size = 16;
	importance = 0.9 * 16 * 0.05;
	coefMin = 0.25;
	coefMax = 4;	
};
class Tourism 
{
	icon = "\ca\ui\data\map_tourism_ca.paa";
	color[] = {0.78, 0, 0.05, 1};
	size = 16;
	importance = 1 * 16 * 0.05;
	coefMin = 0.7;
	coefMax = 4;
};
class Transmitter 
{
	icon = "\ca\ui\data\map_transmitter_ca.paa";
	size = 20;
	color[] = {0, 0.35, 0.7, 1};
	importance = 2 * 16 * 0.05;
	coefMin = 0.9;
	coefMax = 4;
};
class ViewTower 
{
	icon = "\ca\ui\data\map_viewtower_ca.paa";
	size = 16;
	color[] = {0, 0.35, 0.7, 1};
	importance = 2.5 * 16 * 0.05;
	coefMin = 0.5;
	coefMax = 4;
};
class Watertower 
{
	icon = "\ca\ui\data\map_watertower_ca.paa";
	color[] = {0, 0.35, 0.7, 1};
	size = 32;
	importance = 1.2 * 16 * 0.05;
	coefMin = 0.9;
	coefMax = 4;
};
class Waypoint 
{
       icon = "\ca\ui\data\markers\gr_marker_circle_CA.paa"; 
       size = 20; 
       color[] = {0, 0, 0, 1}; 
       importance = 2.5 * 16 * 0.05; 
       coefMin = 0.5; 
       coefMax = 4;         
};
class WaypointCompleted 
{
      icon = "\ca\ui\data\markers\hd_start_point_CA.paa"; 
       size = 16; 
       color[] = {0, 0.7, 0.0, 0.5}; 
       importance = 2.5 * 16 * 0.05; 
       coefMin = 0.5; 
       coefMax = 4;    
};	
};

dialogs.hpp

class AD_NAV_DIALOG
{
idd = -1;
movingEnable = false;
onLoad = "(_this select 0) call compile preprocessFileLineNumbers ""\ad_helos_det7\Scripts\hideControls.sqf""";
class controlsBackground
{
	class AD_NAV_MAP: AD_RscMapControl
	{
		idc = 420;
		maxSatelliteAlpha = 0;
		x = 0.317972 * safezoneW + safezoneX;
		y = 0.292763 * safezoneH + safezoneY;
		w = 0.362428 * safezoneW;
		h = 0.417379 * safezoneH;
		onMouseZChanged = "";
		onMouseButtonDown = "[""onMapClick"", _this] execVM ""\ad_helos_det7\Scripts\add_waypoints.sqf""";
	};
};
class controls
{
	class AD_NAV_PICTURE: AD_RscPicture
	{
		idc = 421;
		text = "\ad_helos_det7\textures\navcomputer.paa";
		x = 0.306987 * safezoneW + safezoneX;
		y = 0.267192 * safezoneH + safezoneY;
		w = 0.388058 * safezoneW;
		h = 0.464999 * safezoneH;
	};
	class AD_NAV_BUTTON1: AD_RscButton
	{
		idc = 422;
		text = "o";
		x = 0.308033 * safezoneW + safezoneX;
		y = 0.369486 * safezoneH + safezoneY;
		w = 0.0151097 * safezoneW;
		h = 0.0240728 * safezoneH;
		tooltip = "Remove all waypoints";
		action = "_nil=[]ExecVM ""\ad_helos_det7\Scripts\remove_waypoints_button.sqf""";
	};
	class AD_TEXT1: AD_RscText
	{
		idc = 423;
		text = "ALL WAYPOINTS REMOVED";
		x = 0.305941 * safezoneW + safezoneX;
		y = 0.744274 * safezoneH + safezoneY;
		w = 0.387535 * safezoneW;
		h = 0.0805112 * safezoneH;
		colorText[] = {0.5625,0.92969,0.5625,1};
		size = 0.01921;
	};
};
};

So that takes care of that.

Another bug was that when the waypoint deleting function in add_waypoints.sqf was commented out, I was not getting a marker with the first waypoint, so I just uncommented it, I myself don't need to see the waypoint after it is completed.

Here's that script for reference as to what I mean........

_unit = vehicle player; 

if (((_this select 1) select 1) == 0) then 
{ 
   if (leader group player == player) then 
   { 
       if (!((_this select 1) select 6)) then 
       { 
           _pos = ((_this select 1) select 0) ctrlMapScreenToWorld [(_this select 1) select 2, (_this select 1) select 3]; 

           _wp = group player addWaypoint [_pos, 0]; 
           _wp setWaypointType "MOVE"; 
           _wp showWaypoint "ALWAYS"; 
           _wp setWaypointStatements ["true", "deleteWaypoint [group this, 0];"]; 
           playSound "ad_bleep"; 
       } 
       else 
       { 
           _pos = ((_this select 1) select 0) ctrlMapScreenToWorld [(_this select 1) select 2, (_this select 1) select 3]; 
           _closer = 0; 
           _min_dst = 100000; 
           _wps = waypoints group player; 
           for [{_i=0},{_i < (count _wps)},{_i=_i+1}] do 
           { 
               _dist = _pos distance getWPPos [group player, _i]; 
               if ((_dist < _min_dst) && (_dist < 100)) then 
               { 
                   _min_dst = _dist; 
                   _closer = _i; 
               }; 
           };     
       if (_closer != 0) then 
       { 
           deleteWaypoint [group player, _closer]; 
       };         
   }; 
   } 
   else 
   { 
       playSound "denied"; 
       titleText ["You are not the group leader and cannot modify waypoints", "PLAIN DOWN"]; 
   }; 
};  

OK, so what is next?

I will tell you what is next.........

1.)____________________________________________________________________________________________________________________________

Currently, at the bottom of add_waypoints.sqf, there is a bit that denies anyone in the vehicle from editing waypoints who is not the group leader.

This should not be, I would like the pilot and/or co-pilot to be able to edit waypoints no matter their standing in the group.

The only requirement would be that they both need to be in the same group. Which leads me to my next feature....

2.)____________________________________________________________________________________________________________________________

I would like a button that, when pressed, will take the pilot and co-pilot out of their respective groups, and place them in a new group, with the pilot as the group leader. I have done something similar to this before in a script, I will just have to dig it up.

3.)____________________________________________________________________________________________________________________________

I need a button in the dialog that allows the user to edit the description of the last placed waypoint.

Imagine placing a flight path to an LZ, which the pilot then has to land at.

I would like to be able to edit the description of that last waypoint to say "LAND" or something to that effect.

I have seen examples of dialogs with text fields in them, I will have to learn this.

As far as I know that is all for now, but I am sure something will come to mind later.

-AD

Edited by ADuke823

Share this post


Link to post
Share on other sites

1.)____________________________________________________________________________________________________________________________

Currently, at the bottom of add_waypoints.sqf, there is a bit that denies anyone in the vehicle from editing waypoints who is not the group leader.

This should not be, I would like the pilot and/or co-pilot to be able to edit waypoints no matter their standing in the group.

The only requirement would be that they both need to be in the same group. Which leads me to my next feature....

OK, so for this, I tried changing the if statement in add_waypoints.sqf from this.....

if (leader group player == player) then 

to this.......

if ((_this select 0 == driver (vehicle player) or (_this select 0 == _copilot)) then

and defined _copilot as this...

_helo = vehicle player; 
_pilot = driver _helo;
_copilot = _helo turretUnit [2];

But so far that is not working, I am assuming my syntax is wrong, going to keep trying.

Share this post


Link to post
Share on other sites

1.)

_airCraft       = vehicle player;	
_params         = _this select 1;
_ctrl           = _params select 0;
_button         = _params select 1;
_mapX           = _params select 2;
_mapY           = _params select 3;
_altKeyPressed  = _params select 6;
_pos            = [];
_hasPermission  = false;

// Check the permissions
if (driver _airCraft == player) then
{
// player is pilot
_hasPermission = true;
}
else
{
// Check if player is the first in cargo (aka co-pilot)
_crew 	= crew _airCraft;
_cargo 	= _crew - [driver _airCraft] - [gunner _airCraft] - [commander _airCraft];
if (_cargo select 0 == player) then
{
	_hasPermission = true;
};
};

if (_button == 0) then
{
   if (_hasPermission) then
   {
	_pos = _ctrl ctrlMapScreenToWorld [_mapX, _mapY];

       if (!_altKeyPressed) then
       {
           _wp = group player addWaypoint [_pos, 0];
           _wp setWaypointType "MOVE";
		_wp showWaypoint "ALWAYS";
           _wp setWaypointStatements ["true", "deleteWaypoint [group this, 0];"];
           playSound "ad_bleep";
       }
       else
       {     
           _closer = 0;
           _min_dst = 100000;
           _wps = waypoints group player;
           for "_i" from 0 to ((count _wps)-1) do
           {
               _dist = _pos distance getWPPos [group player, _i];
               if ((_dist < _min_dst) && (_dist < 100)) then
               {
                   _min_dst = _dist;
                   _closer = _i;
               };
           };    
		if (_closer != 0) then
		{
			deleteWaypoint [group player, _closer];
		};        
	};
   }
   else
   {
       playSound "denied";
       titleText ["You are not the group leader and cannot modify waypoints", "PLAIN DOWN"];
   };
};  

This is working under the assumption that this code is executed upon an aircraft and the first person in cargo is the co-pilot.

I had some weird bugs though when I was in the helo and assigned waypoints, they got immediately completed...

2.)

_crew        = crew _airCraft;
_cargo       = _crew - [driver _airCraft] - [gunner _airCraft] - [commander _airCraft];
_units       = [driver _airCraft];

if (count _cargo > 0) then
{
   _units set [1, _cargo select 1];
};

_newGrp = createGroup (side (driver _airCraft));
_units joinSilent grpNull;
_units joinSilent _newGrp;
// _newGrp setLeader (driver _airCraft);

Again, this script assumes that the first unit in cargo is the co-pilot.

3.) Markers :D You can place empty markers but with a text and voilà, there you have your label.

But that would mean to roll back to the previous script state, namely saving all markers, deleting them upon closing and readding them upon opening the dialog :D

Share this post


Link to post
Share on other sites

3.) Markers You can place empty markers but with a text and voilà, there you have your label.

But that would mean to roll back to the previous script state, namely saving all markers, deleting them upon closing and readding them upon opening the dialog

For that part I was actually talking about the waypoint description (The text that the pilot sees when he views the waypoint in the HUD).

For #1........

The Co-Pilot in the helicopter I am working with is not actually in cargo, but in the 2nd turret position.

But thanks, everything helps.

-AD

Edited by ADuke823

Share this post


Link to post
Share on other sites

setWaypointDescription is the command you're searching for :)

With a combination of waypoints and some simple selects, you can change the description of the last waypoint:

_wps = waypoints (group player); (_wps select ((count _wps)-1)) setWaypointDescription "LAND here, dammit!"; 

You could also change the waypoint type to "LAND", just to make it consistent.

And the permission check:

// Check the permissions
if (driver _airCraft == player || _airCraft turretUnit [2] == player) then
{
   _hasPermission = true;
};

Share this post


Link to post
Share on other sites

With a combination of waypoints and some simple selects, you can change the description of the last waypoint:

_wps = waypoints (group player); (_wps select ((count _wps)-1)) setWaypointDescription "LAND here, dammit!"; 

You could also change the waypoint type to "LAND", just to make it consistent.

OK, great, I will just integrate that into an editable text field within the dialog, along with a button.

I am adding buttons to the dialog as we speak....err type. :)

EDIT: Roger on the permission check.

Share this post


Link to post
Share on other sites

OK, so I have a bug with my button that removes/deletes all of the player's current waypoints.

Here is the script.......

remove_waypoints_button.sqf

_group = group player;
_leader = leader _group;

playSound "ad_button";

while {(count (waypoints _group)) > 0} do
{
deleteWaypoint ((waypoints _group) select 0);
ctrlShow [423, true];
sleep 2;
ctrlShow [423, false];
};

[_group, 0] setWaypointPosition [position _leader, 0];

The bug is this...

Consistently, if I open the dialog and set a series of waypoints, everything works fine, I get map marks at every waypoint.

But, if I set a series of waypoints, then use my remove waypoints button.......

Then the next waypoint that I set will not get a marker, if I set a second waypoint, then markers show for both the first and second waypoint.

I would like the marks to show up with every waypoint even after removing the last set of waypoints.

-AD

Edited by ADuke823

Share this post


Link to post
Share on other sites

OK so, instead of an action menu entry, I am trying to map the thing to a key bind.

Here is the script so far......

_helo = _this select 0;_pilot = driver _helo;
//_navact = _helo addAction ["Navigation Computer", "\ad_helos_det7\Scripts\navcomputer.sqf"];
nul = findDisplay 46 displayAddEventHandler ["keyDown", "    if (_this select 1 in (actionKeys ""User20"")) then {        null = [] execVM "\ad_helos_det7\Scripts\navcomputer.sqf";            if (!dialog) then {                null = player call cms_fnc_dialog;            } else {                    closeDialog 0;                    };                };                  "];

Getting an error with that though.

-AD

EDIT:

I keep re-entering the script within the php tags but it still looks screwy.

Edited by ADuke823

Share this post


Link to post
Share on other sites

_helo = _this select 0;_pilot = driver _helo;

//_navact = _helo addAction ["Navigation Computer", "\ad_helos_det7\Scripts\navcomputer.sqf"];
openNavComp = {

if (_this select 1 in (actionKeys "User20")) then 
{        
	null = [] execVM "ad_helos_det7\Scripts\navcomputer.sqf";
	if (!dialog) then 
	{
		null = player call cms_fnc_dialog;
       } 
	else 
	{
		closeDialog 0;
	};
};                  

};
waitUntil {!isNull (findDisplay 46)};
nul = (findDisplay 46) displayAddEventHandler ["keyDown", "_this call openNavComp;"];

The first execVM had backslashes missing :D

Share this post


Link to post
Share on other sites
_helo = _this select 0;_pilot = driver _helo;

//_navact = _helo addAction ["Navigation Computer", "\ad_helos_det7\Scripts\navcomputer.sqf"];
openNavComp = {

   if (_this select 1 in (actionKeys "User20")) then 
   {        
       null = [] execVM "ad_helos_det7\Scripts\navcomputer.sqf";
       if (!dialog) then 
       {
           null = player call cms_fnc_dialog;
       } 
       else 
       {
           closeDialog 0;
       };
   };                  

};
waitUntil {!isNull (findDisplay 46)};
nul = (findDisplay 46) displayAddEventHandler ["keyDown", "_this call openNavComp;"];

The first execVM had backslashes missing :D

Thanks buddy, you're awesome......

Now I just need to add _selects to detect control shift and alt.

Share this post


Link to post
Share on other sites

OK so......

Did some heavy multiplayer testing last night on this.

I need this script........

_helo = _this select 0;_pilot = driver _helo; 
//_navact = _helo addAction ["Navigation Computer", "\ad_helos_det7\Scripts\navcomputer.sqf"]; openNavComp = {     if (_this select 1 in (actionKeys "User20")) then      {                 null = [] execVM "\ad_helos_det7\Scripts\navcomputer.sqf";         if (!dialog) then          {             null = player call cms_fnc_dialog;         }          else          {             closeDialog 0;         };     };                   
}; waitUntil {!isNull (findDisplay 46)}; nul = (findDisplay 46) displayAddEventHandler ["keyDown", "_this call openNavComp;"];  

To do the following........

I want the keybind to only work if the player is currently either the pilot, or the copilot.

I also want the keybind to NOT WORK if the player is no longer in the helo.

Share this post


Link to post
Share on other sites

This looks s-o-o-o nice, I hope you'll consider releasing it as a general addon. I don't fly, but I think it would be great for ground missions too :D

Share this post


Link to post
Share on other sites

okay, this is highly experimental, I didn't test this, just wrote it down.

Test it in MP and see if its working. (it wouldn't hurt to insert some hint's to see if it's working).

_helo = _this select 0;

if (isNil "openNavComp") then
{
openNavComp = {     
	if (_this select 1 in (actionKeys "User20")) then 
	{
		null = [] execVM "\ad_helos_det7\Scripts\navcomputer.sqf";
		if (!dialog) then 
		{
			null = player call cms_fnc_dialog;         
		}
		else
		{
			closeDialog 0;
		};
	};                   
};

navCompGetinHandler = {
	_veh = _this select 0;
	_pos = _this select 1;
	_unit = _this select 2;

	if (local _unit) then
	{
		if (_pos == "driver" || _veh turretUnit[2] == _unit) then
		{
			// add the eventhandler to open the navcomputer
			_handle = (findDisplay 46) displayAddEventHandler ["keyDown", "_this call openNavComp;"]; 

			// to be able to remove the keyDown-handler, we need to assign it to the helo
			_veh setVariable ["getoutHandle", _handle];
		};
	};
};

navCompGetoutHandler = {
	_veh = _this select 0;
	_unit = _this select 2;
	_displayHandle = _this select 3;

	if (local _unit) then
	{
		_handler = _veh getVariable ["getoutHandle", -1];
		if (_handler > -1) then
		{
			(findDisplay 46) displayRemoveEventHandler ["keyDown", _handler];
			_veh setVariable ["getoutHandle", -1];
		};
	};
};

};

_navact = _helo addAction ["Navigation Computer", "\ad_helos_det7\Scripts\navcomputer.sqf"]; 

// Check the permissions everytime someone enters the helo
_helo addEventHandler ["GetIn", "_this call navCompGetinHandler;"];

// Delete the keyDown-handler if it was added
_helo addEventHandler ["GetOut", "_this call navCompGetoutHandler"];

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×