Jump to content

Recommended Posts

   IN GAME TASKS ON MARKERS

 

Hi all,

Here is a little script to create some tasks while in game, just placing markers on map.

 

EDITED: 23/12/2018

 

parameters:   none

There is no parameters. Just place some map markers.

 

The available markers are "OBJECTIVE" "AMBUSH" "DESTROY" "PICK UP" "JOIN"  (like actions for units). All others remain standard markers.

 

Channel: As markers come with selectable channel "GLOBAL" "SIDE" "COMMAND" "GROUP" "VEHICLE", the automated task will be displayed for the same channel.

So, don't forget a global marker will create a global task, and so on.

 

Task deletion: There are 2 ways for deleting a task:

- try to delete the red circle marker below the task marker. Not easy. Usually works when you catch the marker owner name in MP.

- go to task description and click on "Delete task" It's an active link.

 

Associated action: At this time, there is no difference between the type of tasks.

These tasks are like some 3D markers and are displayed as tasks. But there is no condition for completion.

That means, these tasks can be CREATED or ASSIGNED but never COMPLETED or CANCELED. They can be deleted.

 

Extra feature: In task description, you can click on "GO GO GO" link. This will order the concerned units (CHANNEL) to move at the task destination.

You can order a task for the side, then order another task for your group. This, you can have two different objectives.

But, please, keep on mind AIs will obey to the last order. So, have some players coordination in MP.

That's the main reason why the move order is not automatic. You can create all tasks you need as 3D markers, then decide to order or not a movement for units.

 

All comments, ideas are welcome!

 

Run this code on initPlayerLocal.sqf or any script running with interface (player). A condition true trigger works also.

 

Spoiler

 


_MGI_taskOnMarker = addMissionEventHandler ["map",{
  if (_this select 0) then {
    [] spawn {
      _mks_USER = allMapMarkers select {_x find "_USER" == 0};
      private ["_tgt","_tgtText","_mk"];
      while {visibleMap && hasInterface} do {
        waitUntil {!(_mks_USER isEqualTo (allMapMarkers select {_x find "_USER" == 0}))};
        if (count (allMapMarkers select {_x find "_USER" == 0}) > 0) then {  _mks = allMapMarkers select {_x find "_USER" == 0};
          _mk = _mks select (count _mks - 1);
          _mkType = markerType _mk;
          if (_mkType in ["hd_objective","hd_ambush","hd_destroy","hd_pickup","hd_join"]) then {
            _mkText = markerText _mk;
            _mkPos = getMarkerPos _mk;

            _tskType = switch (_mkType) do {
              case "hd_objective": {"target"};
              case "hd_ambush": {"attack"};
              case "hd_destroy": {"destroy"};
              case "hd_pickup": {"interact"};
              case "hd_join": {"meet"};
            };
            _mkTitle = switch (_mkType) do {
              case "hd_objective": {"new objective"};
              case "hd_ambush": {"ambush here"};
              case "hd_destroy": {"destroy"};
              case "hd_pickup": {"pick up"};
              case "hd_join": {"join"}
            };
            _channel = _mk select [count _mk - 1];
            call {
              if (_channel == "0") exitWith {_tgt = true; _tgtText = "all!        "};
              if (_channel == "1") exitWith {_tgt = playerSide; _tgtText = "our camp!   "};
              if (_channel == "2") exitWith {_tgt = allPlayers select {side _x == playerSide && _x == leader _x}; _tgtText = "all leaders!"};
              if (_channel == "3") exitWith {_tgt = Group player; _tgtText = "our group!  "};
              if (_channel == "4") exitWith {_tgt = crew vehicle player; _tgtText = "our crew!   "};
              _tgt = player; _tgtText = "ourselves!  "
            };

            _tsk = [_mk, _tgt, [
              "new task for "
              + format [_tgtText
              + toString [60,98,114,47,62]
              + _mkText
              + toString [60,98,114,47,62]
              + "<execute expression='1 call fn_tsk'>Go, go, go!</execute>"
              + toString [60,98,114,47,62]
              + "<execute expression='0 call fn_tsk'>Delete task</execute>"
             ],
             _mkTitle,_mk],
             _mkPos, "AUTOASSIGNED", 1, true, true, _tskType, false
            ] call BIS_fnc_setTask;

            fn_tsk = {
              _variant = _this;
              _tskUnderway = (player call bis_fnc_tasksUnit) select {!((_x call bis_fnc_taskstate) in ["SUCCEEDED","FAILED","CANCELED"])};
              if (count _tskUnderway == 0) exitWith {};
              _tskDesc = (((_tskUnderway select (lbCurSel (findDisplay 12 displayCtrl 1002)))) call BIS_fnc_taskDescription) select 0 select 0;

              _tskDest = (((_tskUnderway select (lbCurSel (findDisplay 12 displayCtrl 1002)))) call BIS_fnc_taskDestination);
              _shortText = _tskdesc select [0,24];
              call {
                if (_variant == 0) then {
                  deleteMarker (_tskUnderway select (lbCurSel (findDisplay 12 displayCtrl 1002)))
                };
                if ((_shortText find "all!") >-1 && _variant == 1) exitWith {
                  hint "This meeting is impossible!"};
                if ((_shortText find "camp!")>-1) exitWith {
                  { _l = leader group _x;
                    doStop _x; _x doFollow _l; if (_variant == 1 && {_x != _l or !isPlayer _x}) then {
                    _x doMove _tskDest}} forEach allUnits select {side _x == playerSide && !isPlayer _x}
                };
                if ((_shortText find "leaders")>-1) exitWith {
                  {_l = leader group _x;
                   doStop _x; _x doFollow _l; if (_variant == 1 && {_x == _l && !isPlayer _x}) then {_x doMove _tskDest}} forEach allUnits select {side _x == playerSide && !isPlayer _x}
                };
                if ((_shortText find "group!")>-1) exitWith {
                  {doStop _x; _x doFollow leader group _x; if (_variant == 1) then {_x doFollow leader group _x; _x doMove _tskDest}} forEach (units player -[player])
                };
                if ((_shortText find "crew!")>-1) exitWith {
                  {doStop _x; _x doFollow leader group _x; if (_variant == 1) then {_x doFollow leader group _x; _x doMove _tskDest}} forEach (crew vehicle player - allPlayers)
                };
              };
            };

            if (_channel == "2" && player != leader player) then {
              hint "You are not a leader"
            } else {
              _mk setMarkertype "mil_circle";
              _mk setMarkerColor "colorRed";
            };

            [_tsk,_mk] spawn {
              params ["_tsk","_mk"];
              waitUntil {sleep 0.5; !(_mk in allMapMarkers)};
              [_mk] call BIS_fnc_deleteTask;
            };
          };
        };
        _mks_USER = allMapMarkers select {_x find "_USER" == 0};
      };
    };
  };
}];

 

 

 

 

Thanks

Pierre MGI

 

 

 

  • Like 8
  • Thanks 1

Share this post


Link to post
Share on other sites

Any way to add the completed, canceled, or failed to a future script version.

 

We run ghost missions on our server and this would be perfect for integrating the random pop-up mission or on the fly mission, in addition to ghost.

 

Reed

Share this post


Link to post
Share on other sites
1 hour ago, Jnr4817 said:

Any way to add the completed, canceled, or failed to a future script version.

 

We run ghost missions on our server and this would be perfect for integrating the random pop-up mission or on the fly mission, in addition to ghost.

 

Reed

 

The problem is: on what criteria? How can you give a condition for that?

But possible manually. Some owner could decide the task is completed and click on a  link. Same for canceled. Failed seems to me weird if initiated by a player. Say admin?

 

Share this post


Link to post
Share on other sites
13 hours ago, pierremgi said:

 

The problem is: on what criteria? How can you give a condition for that?

But possible manually. Some owner could decide the task is completed and click on a  link. Same for canceled. Failed seems to me weird if initiated by a player. Say admin?

 

Excellent questions.

 

I guess it would work like slimmer zeus tasking.

 

If I am admin and conducting a mission. Maybe I set 3 ghost task in the parameters, then launch game.

 

Maybe all the ghost missions are a destroy. So 3 destroy task are present.

 

Then with your script, when an enemy is seen by an air asset or UAV operator or Team leader, a destroy objective could be placed and then that could be the priority task, I would have no clue how to make that condition met once the enemy vehicle is destroyed.

 

Another example, would be to add a RECON (Unknown / "hd_unknown" )marker for adding a task to recon an area or CAPTURE(Pick Up / "hd_pickup") marker for capturing a certain enemy asset without destroying it. Or adding waypoints as task (Waypoint / "waypoint" ).

 

The person who places the marker task would be the one to say  it completed, canceled, or failed.

 

I could even see this being used globally by a Commanding Officer, or within a squad by a squad leader.

 

Just some ideas. Many other examples can be used with the available markers.

 

Great script. Thanks for the hard work

 

Reed

Share this post


Link to post
Share on other sites

Corrected a little bug coming from tasks sorting (completed,failed,canceled are under the active ones).  Deletion should work even after some tasks completion now.

  • Thanks 1

Share this post


Link to post
Share on other sites
On 24/10/2017 at 2:13 AM, pierremgi said:

Corrected a little bug coming from tasks sorting (completed,failed,canceled are under the active ones).  Deletion should work even after some tasks completion now.

 

pierremgi can you help me adapt your script to fit a custom made tactical ping script I am making. 

 

For simplicity's sake lets make it is just a single type of _mkType, lets say: hd_objective with a single line of text: "Squad Lead Objective"

 

An the task needs to be created at the players' cursorTarget for all other side players to see it.

 

The only big difference would be that as soon as a new task is created the old one must be deleted. 

 

Here is my script so far:

 

//TACTICAL PING WITH DELETABLE TASKS

targeter = _this select 0;

playSound3D ["A3\Sounds_F\sfx\beep_target.wss", targeter];
targeter playAction "HandSignalPoint";
my_target = cursorTarget;
my_targetdis = targeter distance my_target; 
my_targetdis = round (my_targetdis);
my_targetdir = getdir targeter; 
my_targetdir = round (my_targetdir);

//Insert pierremgi fnc here:
_MGI_taskOnCursorTarget = {

};

mrktarget = {
	{
		_x doTarget cursorTarget;
	} 	forEach units group targeter;
};
my_msg = {
	//targeter groupChat format["Fire at this target! %1 m %2 deg from me", my_targetdis, my_targetdir];
	targeter groupChat format["Target - %1 m - Bearing %2 - From my position", my_targetdis, my_targetdir];	
};

[[targeter],"mrktarget",true,false] spawn BIS_fnc_MP;
[[targeter, my_targetdis, my_targetdir],"my_msg",true,false] spawn BIS_fnc_MP;

 

Share this post


Link to post
Share on other sites
On 24/10/2017 at 2:13 AM, pierremgi said:

Corrected a little bug coming from tasks sorting (completed,failed,canceled are under the active ones).  Deletion should work even after some tasks completion now.

 

I am getting this error when trying to delete a task:

 

11857153a108f7a52a199af352442aba0d9a6fac

Share this post


Link to post
Share on other sites

I can't reproduce that. Did you try to SUCCEED FAILED or CANCELED the task you decided to delete?

or in MP, task created by a player and tried to be deleted by another one?

Some hints for reproducing that?

Anyway, this should work...

I add a line to avoid this kind of error but no clue about the result.

 

Share this post


Link to post
Share on other sites
6 hours ago, pierremgi said:

I can't reproduce that. Did you try to SUCCEED FAILED or CANCELED the task you decided to delete?

or in MP, task created by a player and tried to be deleted by another one?

Some hints for reproducing that?

Anyway, this should work...

I add a line to avoid this kind of error but no clue about the result.

 

 

MP Hosted. Just one player (the Host).

 

Adds the task then tries to delete it... sometimes it works, other times it shows this error, other times it shows no error but the task cannot be deleted. 

Share this post


Link to post
Share on other sites
1 hour ago, LSValmont said:

 

MP Hosted. Just one player (the Host).

 

Adds the task then tries to delete it... sometimes it works, other times it shows this error, other times it shows no error but the task cannot be deleted. 

Are you using the del key near the task or the "delete this task" in task menu?

Share this post


Link to post
Share on other sites
On 24/12/2018 at 1:15 AM, pierremgi said:

Are you using the del key near the task or the "delete this task" in task menu?

 

- "delete task" in task menu as shown on my screenshot... (The option under Go, go, go!)

 

PS: Merry Christmas dear pierremgi!

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

×