Jump to content
redarmy

Need some help with High command "create task"

Recommended Posts

So im trying to run a code on a groups wp via High command/modify wp/create task"

 

BIS_HC_1 setVariable ["onTaskCreated", Code, true];

the biki has this.

 

I have my code and syntax as such:

 

BIS_HC_1 setVariable ["onTaskCreated", [_this] call CBA_fnc_taskDefend, true];

However, it doesnt do anything, the group dont utilise the CBA defend script. i get no errors either. I am either misunderstanding its functionality,or its seems broken.

Share this post


Link to post
Share on other sites

[_this]  is probably undefined here.

change _this variable for  this  (group leader in waypoint activation field), if I understand your context. I'm not using CBA, so check for leader or group and point at the right thing.

 

Share this post


Link to post
Share on other sites
56 minutes ago, pierremgi said:

[_this]  is probably undefined here.

change _this variable for  this  (group leader in waypoint activation field), if I understand your context. I'm not using CBA, so check for leader or group and point at the right thing.

 

its actually a wp being given dynamically via High command in a scenario,not from the editor. its more to do with the currently selected group or groups.

 

Its a bit different to EH's too and special to High command https://community.bistudio.com/wiki/Arma_3:_High_Command (example at bottom of page)

 

actually i have it working but still getting errors regarding "_this"   :  BIS_HC_1 setVariable ["onTaskCreated", {_this call CBA_fnc_taskDefend}, true];

Share this post


Link to post
Share on other sites

Are you sure the onTaskCreated code is passed anything at all in _this? Try testing what is being passed...

BIS_HC_1 setVariable ["onTaskCreated", {hint format["_this is %1",  [str _this,"nil"] select (isnil "_this")]}, true];

EDIT: According to hc_gui_menu.sqf it is passed the current waypoint the user is hovering over on the hc map.

Quote

case "WP_CREATETASK":		{_wpover spawn (_logic getvariable "onTaskCreated")};

 

So your then saying...

[GROUP, INDEX] call CBA_fnc_taskDefend

...Which is not what CBA_fnc_taskDefend expects

Quote

Parameters

_groupthe group <GROUP, OBJECT>

_positioncentre of area to defend <ARRAY, OBJECT, LOCATION, GROUP> (Default: _group)

_radiusradius of area to defend <NUMBER> (Default: 50)

_thresholdminimum building positions required to be considered for garrison <NUMBER> (Default: 3)

_patrolchance for each unit to patrol instead of garrison, true for default, false for 0% <NUMBER, BOOLEAN> (Default: 0.1)

_holdchance for each unit to hold their garrison in combat, true for 100%, false for 0% <NUMBER, BOOLEAN> (Default: 0)

Are you sure your error is not coming from CBA function?

 

If you just want the defaults from taskDefend by just passing the group...

BIS_HC_1 setVariable ["onTaskCreated", {_this #0 call CBA_fnc_taskDefend}, true]; 

 

Share this post


Link to post
Share on other sites
14 hours ago, Larrow said:

 

If you just want the defaults from taskDefend by just passing the group...


BIS_HC_1 setVariable ["onTaskCreated", {_this #0 call CBA_fnc_taskDefend}, true]; 

 

Yeah im still getting an error when this is run about "_this" . The error is related to CBA. However after further testing theres a larger issue with the usage of it for me,and that is that once the script is run and units garrison,they can never act on new waypoints. I imagine this is because the defend script has a DoStop or something similar in its code. If i cant get them to move again it wont be usable anyway,its supposed to be a dynamic way of getting a high command group to garrison a random building at what ever time i choose.

 

I dont suppose theres a way i can break the doStop with a DoMove is there? again i wouldnt be able to reference a group name for this example as it could be applied to any group in the mission. Or any alternative in built BIS function (currently testing with BIS TASK DEFEND) that garrisons a group dynamically without a DoStop type of order included?

Share this post


Link to post
Share on other sites
9 hours ago, redarmy said:

However after further testing theres a larger issue with the usage of it for me,and that is that once the script is run and units garrison,they can never act on new waypoints. I imagine this is because the defend script has a DoStop or something similar in its code. If i cant get them to move again it wont be usable anyway,

Well the MOVE command from the same menu ( when you add a waypoint ) has a similar function call...

//--- Add waypoint
		_codeWP = _logic getvariable 'GUI_WP_MOVE';
		_script = [_is3D,_pos,_shift,_ctrl,false,_selected] spawn _codeWP;

However, I would not change this directly as I believe it is already set by the HC system...

 

Spoiler

hc_gui.sqf


///////////////////////////////////////////////////////////////////////////////////
///// Waypoint - MOVE
///////////////////////////////////////////////////////////////////////////////////
_GUI_WP_MOVE = {scriptname "HC: _GUI_WP_MOVE";

	_is3D = _this select 0;
	_worldpos = _this select 1;
	_shift = _this select 2;
	_ctrl = _this select 3;
	_alt = _this select 4;
	_selected = if (count _this > 5) then {_this select 5} else {hcSelected player};
	_logic = player getvariable "BIS_HC_scope";

	//_selected = hcselected player;
	_selectedCount = count _selected;
	_posList = [[0,0],[0,0]]; //--- Default offsets for multiple groups

	//--- Need some delay to check if RMB is still pressed
	if !(_is3D) then {sleep CLICK_DELAY};

	//--- Button is still pressed - Exit
	if (_logic getvariable "LMB_hold") exitwith {};

	//--- MOVE, you pacifist
	if (_selectedCount > 1) then {
		_columnCount = round sqrt(_selectedCount);
		_column = 0;
		_row = 0;
		_coef = 25;
		_averageX = 0;
		_averageY = 0;
		_posList = [];
		for "_i" from 0 to (_selectedCount - 1) do {
			_relX = _column * _coef;
			_relY = -_row * _coef;
			_posList = _posList + [[_relY,_relX]]; // That's not mistake
			_averageX = _averageX + _relX;
			_averageY = _averageY + _relY;

			_column  = _column + 1;
			if (_column >= _columNCount) then {_column = 0; _row = _row + 1};
		};
		_averageX = _averageX / _selectedCount;
		_averageY = _averageY / _selectedCount;
		_posList = [[_averageY,_averageX]] + _posList;
	};

	//--- Begin WP adding process
	for "_i" from 0 to (_selectedCount - 1) do {

		//--- Add new waypoint (wait if button is not still pressed)
		_group = _selected select _i;
		_offsetBase = _posList select 0;
		_offsetGroup = _posList select (_i + 1);
		_offset = [(_offsetBase select 0) - (_offsetGroup select 0),(_offsetBase select 1) - (_offsetGroup select 1)];

		//--- Create new waypoint
		if !(_ctrl) then {

			//--- Reset waypoints
			while {count (waypoints _group) > 0} do {deletewaypoint ((waypoints _group) select 0)};
		};

		_wppos = [(_worldpos select 0) + (_offset select 0),(_worldpos select 1) + (_offset select 1)];
		_wp = _group addwaypoint [_wppos,0];
		_wp setwaypointtype "move";
		_wp showwaypoint "never";
		if !(_ctrl) then {_group setcurrentwaypoint _wp};

		//--- Move handler
		_handler = _logic getvariable "onGroupMove";
		if (!isnil "_handler") then {[_group,_wp,grpnull] spawn _handler};
	};

    //--- Report
	if (count _selected > 1) then {_selected = _selected - [group player]};
	//(leader (_selected select 0)) sideradio "HC_Move";
};


//snip

_logic setvariable ["GUI_WP_MOVE",_GUI_WP_MOVE];

 

However, you will notice this code also has a call to a function stored on the HC logic.

//--- Move handler
		_handler = _logic getvariable "onGroupMove";
		if (!isnil "_handler") then {[_group,_wp,grpnull] spawn _handler};

This _handler is run both when adding a new waypoint(MOVE) or issuing an WP ATTACK. Although I am not sure if this is already in use by the system ( did a quick grep and could not see it set anywhere ).

So you could use this to cancel the doStop by issuing a doFollow as suggested on the wiki doStop page.

BIS_HC_1 setVariable ["onGroupMove", {
	params[ "_group", "_wp" ];
	
	units _group doFollow leader _group;
	
}, true]; 

 

Or there is always the missionEventhandlers for onGroupClicked, or it may even be possible to inject your own command into a subMenu of RscHCGroupRootMenu see how #USER:HCWPWaitRadio etc are manipulated in hc_gui.sqf .

 

Having a good read through the hc files in \a3\modules_f\hc\data\scripts would be a good idea and may lead you to some ideas.

Share this post


Link to post
Share on other sites
20 minutes ago, Larrow said:

Well the MOVE command from the same menu ( when you add a waypoint ) has a similar function call...


//--- Add waypoint
		_codeWP = _logic getvariable 'GUI_WP_MOVE';
		_script = [_is3D,_pos,_shift,_ctrl,false,_selected] spawn _codeWP;

However, I would not change this directly as I believe it is already set by the HC system...

 

  Reveal hidden contents

hc_gui.sqf



///////////////////////////////////////////////////////////////////////////////////
///// Waypoint - MOVE
///////////////////////////////////////////////////////////////////////////////////
_GUI_WP_MOVE = {scriptname "HC: _GUI_WP_MOVE";

	_is3D = _this select 0;
	_worldpos = _this select 1;
	_shift = _this select 2;
	_ctrl = _this select 3;
	_alt = _this select 4;
	_selected = if (count _this > 5) then {_this select 5} else {hcSelected player};
	_logic = player getvariable "BIS_HC_scope";

	//_selected = hcselected player;
	_selectedCount = count _selected;
	_posList = [[0,0],[0,0]]; //--- Default offsets for multiple groups

	//--- Need some delay to check if RMB is still pressed
	if !(_is3D) then {sleep CLICK_DELAY};

	//--- Button is still pressed - Exit
	if (_logic getvariable "LMB_hold") exitwith {};

	//--- MOVE, you pacifist
	if (_selectedCount > 1) then {
		_columnCount = round sqrt(_selectedCount);
		_column = 0;
		_row = 0;
		_coef = 25;
		_averageX = 0;
		_averageY = 0;
		_posList = [];
		for "_i" from 0 to (_selectedCount - 1) do {
			_relX = _column * _coef;
			_relY = -_row * _coef;
			_posList = _posList + [[_relY,_relX]]; // That's not mistake
			_averageX = _averageX + _relX;
			_averageY = _averageY + _relY;

			_column  = _column + 1;
			if (_column >= _columNCount) then {_column = 0; _row = _row + 1};
		};
		_averageX = _averageX / _selectedCount;
		_averageY = _averageY / _selectedCount;
		_posList = [[_averageY,_averageX]] + _posList;
	};

	//--- Begin WP adding process
	for "_i" from 0 to (_selectedCount - 1) do {

		//--- Add new waypoint (wait if button is not still pressed)
		_group = _selected select _i;
		_offsetBase = _posList select 0;
		_offsetGroup = _posList select (_i + 1);
		_offset = [(_offsetBase select 0) - (_offsetGroup select 0),(_offsetBase select 1) - (_offsetGroup select 1)];

		//--- Create new waypoint
		if !(_ctrl) then {

			//--- Reset waypoints
			while {count (waypoints _group) > 0} do {deletewaypoint ((waypoints _group) select 0)};
		};

		_wppos = [(_worldpos select 0) + (_offset select 0),(_worldpos select 1) + (_offset select 1)];
		_wp = _group addwaypoint [_wppos,0];
		_wp setwaypointtype "move";
		_wp showwaypoint "never";
		if !(_ctrl) then {_group setcurrentwaypoint _wp};

		//--- Move handler
		_handler = _logic getvariable "onGroupMove";
		if (!isnil "_handler") then {[_group,_wp,grpnull] spawn _handler};
	};

    //--- Report
	if (count _selected > 1) then {_selected = _selected - [group player]};
	//(leader (_selected select 0)) sideradio "HC_Move";
};


//snip

_logic setvariable ["GUI_WP_MOVE",_GUI_WP_MOVE];

 

However, you will notice this code also has a call to a function stored on the HC logic.


//--- Move handler
		_handler = _logic getvariable "onGroupMove";
		if (!isnil "_handler") then {[_group,_wp,grpnull] spawn _handler};

This _handler is run both when adding a new waypoint(MOVE) or issuing an WP ATTACK. Although I am not sure if this is already in use by the system ( did a quick grep and could not see it set anywhere ).

So you could use this to cancel the doStop by issuing a doFollow as suggested on the wiki doStop page.


BIS_HC_1 setVariable ["onGroupMove", {
	params[ "_group", "_wp" ];
	
	units _group doFollow leader _group;
	
}, true]; 

 

Or there is always the missionEventhandlers for onGroupClicked, or it may even be possible to inject your own command into a subMenu of RscHCGroupRootMenu see how #USER:HCWPWaitRadio etc are manipulated in hc_gui.sqf .

 

Having a good read through the hc files in \a3\modules_f\hc\data\scripts would be a good idea and may lead you to some ideas.

Thats actually really logical Thanks alot,im going to take my time and read up on this as you suggest.

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

×