How to STOP a task? Once done, how to change to a WP? - ED Forums
 


Notices

Reply
 
Thread Tools Display Modes
Old 11-30-2019, 04:11 PM   #1
ChuckIV
Junior Member
 
ChuckIV's Avatar
 
Join Date: Jul 2017
Location: Elk Grove, CA.
Posts: 44
Talking How to STOP a task? Once done, how to change to a WP?

Good Day MOOSE coders!! I was hoping someone could show me HOW TO STOP this task seen below... This task is working great - other groups join the lead Blue Group following a VEC3 position. I need the following group to STOP FOLLOWING now so they can RTB, etc. That would be my NEXT question; how to get the following group to change to a landing waypoint at the base?

FGroup is the name of the following group
Blue_Group is the leading group
Any help would be greatly appreciated. Thanks!


function CHANGE_SQ_FORMATION( FGroup, Vec_Point )
local GP_Offset = Vec_Point
local GP_Task = FGroup:TaskFollow( Blue_Group, GP_Offset:GetVec3() )
FGroup:PushTask( GP_Task, 1 )
end
__________________
"Never in the field of human conflict was so much owed by so many to so few." Winston Churchill

SYSTEM:
Processor - Intel(R) Core(TM) i7-6700K CPU @ 4.00GHz 4.00 GHz
Installed memory (RAM) - 32.0 GB
64-bit Operating System, x64-based processor
Windows 10 Pro on 110 GB SSD; DCS on 512 GB SSD; Backup Files on 931 GB Regular Drive
Video Card - NVIDIA GeForce GTX 1070

Last edited by ChuckIV; 11-30-2019 at 04:16 PM.
ChuckIV is offline   Reply With Quote
Old 11-30-2019, 07:57 PM   #2
Tiramisu
Member
 
Join Date: Oct 2018
Location: Germany
Posts: 477
Default

I am having a similar problem at the moment. I have tried to use the function popTask from the API of DCS, but it does not work. Maybe it is not cancelling the current task, but the task that would come after the current one.
Tiramisu is offline   Reply With Quote
Old 11-30-2019, 08:26 PM   #3
Tiramisu
Member
 
Join Date: Oct 2018
Location: Germany
Posts: 477
Default

Ok, I have found a way how to stop all current tasks. You overwrite the AI tasks with a task, that has a false condition, i.e. it will not be executed. Here is my code (assuming pContr is the controller of your unit or group):

Code:
local tEmptyTask =
        {
                ["enabled"] = true,
                ["auto"] = false,
                ["id"] = "ControlledTask",
                ["number"] = 1,
                ["params"] = 
                {
                     ["task"] = 
                     {
                          ["id"] = "Orbit",
                          ["params"] = 
                          {
                                ["altitude"] = 5048.0976,
                                ["pattern"] = "Race-Track",
                                ["speed"] = 115,
                          }, -- end of ["params"]
                     }, -- end of ["task"]
                     ["condition"] = 
                     {
                          ["condition"] = "return false",
                     }, -- end of ["condition"]
                }, -- end of ["params"]
          }        
        pContr:setTask( tEmptyTask )
Tiramisu is offline   Reply With Quote
Old 12-02-2019, 02:22 AM   #4
ChuckIV
Junior Member
 
ChuckIV's Avatar
 
Join Date: Jul 2017
Location: Elk Grove, CA.
Posts: 44
Default I tried - it did not work

I tried your code simply changing "Race-Track" to "Circle", the speed of the orbiting, and the pContr to FGroup, but it didn't work. My following groups do not DISENGAGE; they do not stop following me after I tried your code. Any other ideas??
__________________
"Never in the field of human conflict was so much owed by so many to so few." Winston Churchill

SYSTEM:
Processor - Intel(R) Core(TM) i7-6700K CPU @ 4.00GHz 4.00 GHz
Installed memory (RAM) - 32.0 GB
64-bit Operating System, x64-based processor
Windows 10 Pro on 110 GB SSD; DCS on 512 GB SSD; Backup Files on 931 GB Regular Drive
Video Card - NVIDIA GeForce GTX 1070
ChuckIV is offline   Reply With Quote
Old 12-02-2019, 02:54 AM   #5
Tiramisu
Member
 
Join Date: Oct 2018
Location: Germany
Posts: 477
Default

For me it worked, when I used the code above to stop an AI task consisting of several barrel rolls.

The idea of my workaround was to make the AI go RTB, by simply replacing all AI tasks (including waypoints) with an arbitrary task, that will not be executed anyway, because of the code line ["condition"] = "return false".
So it was not necessary for you to change parameters like "Race-Track" with something else. Could you try it again without changing those parameters? Maybe your changes broke my code. Also make sure, that the code for the AI-task-stop is executed at the right time. Adding an ingame message when the code is executed can be helpful for bugfixing.

If this still does not work, you can upload your mission and I will take a look at it.
Tiramisu is offline   Reply With Quote
Old 12-02-2019, 11:50 AM   #6
A101Wayz
Member
 
Join Date: Feb 2019
Posts: 125
Default

I've never done this without the use of MOOSE...
However, MOOSE calls controller:resetTask()
This should clear the tasks, then you can assign new tasks.
You might want to give that a shot.
__________________
Wayz Out


Intel Core i9 9900K | ASUS ROG Strix Z390E Gaming MB | G.Skill Ripjaws V 32gb DDR4-3200 | GeForce RTX 2080 Ti | Samsung 970 EVO Plus NVMe
HTC Vive Pro VR | Logitech G x56 HOTAS | Logitech G PRO Pedals
A101Wayz is offline   Reply With Quote
Old 12-02-2019, 03:11 PM   #7
Tiramisu
Member
 
Join Date: Oct 2018
Location: Germany
Posts: 477
Default

Oh, that is an easier solution and has the same result like mine. I was assuming that resetTask just restarts the current task.
Tiramisu is offline   Reply With Quote
Old 12-02-2019, 03:54 PM   #8
Pikey
Veteran
 
Pikey's Avatar
 
Join Date: Sep 2009
Location: Reading, UK (GMT)
Posts: 3,664
Default

be careful clearing the tasks because without anything the controller resorts to RTB and then you cant change that one, it's permanent!
__________________
___________________________________________________________________________
SIMPLE SCENERY SAVING * SIMPLE GROUP SAVING * SIMPLE STATIC SAVING * PLAYLIST
===========
Pikey is offline   Reply With Quote
Old 12-02-2019, 04:26 PM   #9
Tiramisu
Member
 
Join Date: Oct 2018
Location: Germany
Posts: 477
Default

Does that mean you cannot even use setTask for assigning a new task after using resetTask? Does my code have the same problem, when the AI goes RTB?
Tiramisu is offline   Reply With Quote
Old 12-02-2019, 04:38 PM   #10
Pikey
Veteran
 
Pikey's Avatar
 
Join Date: Sep 2009
Location: Reading, UK (GMT)
Posts: 3,664
Default

If the lights come on and the plane goes stupid, yes. Without a task a plane RTB's. But this area of code is not reliable to explain and talk confidently about. It's a black box. I'm not sure what reset task actually does. I'd only say, give a plane always something, else you can lose them.
__________________
___________________________________________________________________________
SIMPLE SCENERY SAVING * SIMPLE GROUP SAVING * SIMPLE STATIC SAVING * PLAYLIST
===========
Pikey is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

All times are GMT. The time now is 04:23 AM. vBulletin Skin by ForumMonkeys. Powered by vBulletin®.
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.