Jump to content

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


ChuckIV

Recommended Posts

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


Edited by ChuckIV

"Never in the field of human conflict was so much owed by so many to so few." Winston Churchill

 

SYSTEM:

Processor - Intel® Core i9-9900KF CPU @ 3.60GHz 3600MHz water-cooled

Installed memory (RAM) - 32.0 GB

64-bit Operating System, x64-based processor

Windows 10 & DCS on SSD

Video Card - water-cooled NVIDIA GeForce RTX 2080 Ti

Internet: Cable 200Mbps 12Mbps

Link to comment
Share on other sites

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):

 

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 )

Link to comment
Share on other sites

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® Core i9-9900KF CPU @ 3.60GHz 3600MHz water-cooled

Installed memory (RAM) - 32.0 GB

64-bit Operating System, x64-based processor

Windows 10 & DCS on SSD

Video Card - water-cooled NVIDIA GeForce RTX 2080 Ti

Internet: Cable 200Mbps 12Mbps

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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 *

Link to comment
Share on other sites

OK, I'm trying something with the resetTask() coding.... Using this code...

 

 

function CONTROLLABLE:ClearTasks()

self:F2()

 

local DCSControllable = self:GetDCSObject()

 

if DCSControllable then

local Controller = self:_GetController()

Controller:resetTask()

return self

end

 

return nil

end

 

If the controllable group is called FGroup, then should the code look something like this where the function is called in the last line??.....

 

function CONTROLLABLE:ClearTasks(Group)

self:F2(Group)

 

local DCSControllable = self:GetDCSObject(Group)

 

if DCSControllable then

local Controller = self:_GetController(Group)

Controller:resetTask(Group)

return self

end

 

return nil

end

CONTROLLABLE:ClearTasks(FGroup) -- This line calling the function ????

"Never in the field of human conflict was so much owed by so many to so few." Winston Churchill

 

SYSTEM:

Processor - Intel® Core i9-9900KF CPU @ 3.60GHz 3600MHz water-cooled

Installed memory (RAM) - 32.0 GB

64-bit Operating System, x64-based processor

Windows 10 & DCS on SSD

Video Card - water-cooled NVIDIA GeForce RTX 2080 Ti

Internet: Cable 200Mbps 12Mbps

Link to comment
Share on other sites

CONTROLLABLE:ClearTasks(FGroup) -- This line calling the function ????

No, it would be

FGroup:ClearTasks()

The FGroup is the CONTROLLABLE object in this case.

A warrior's mission is to foster the success of others.

i9-12900K | MSI RTX 3080Ti Suprim X | 128 GB Ram 3200 MHz DDR-4 | MSI MPG Edge Z690 | Samung EVO 980 Pro SSD | Virpil Stick, Throttle and Collective | MFG Crosswind | HP Reverb G2

RAT - On the Range - Rescue Helo - Recovery Tanker - Warehouse - Airboss

Link to comment
Share on other sites

Is this how the code should look?? Do I leave the word CONTROLLABLE as part of the function name??

 

function CONTROLLABLE:ClearTasks(FGroup)

self:F2(FGroup)

 

local DCSControllable = self:GetDCSObject(FGroup)

 

if DCSControllable then

local Controller = self:_GetController(FGroup)

Controller:resetTask(Fgroup)

return self

end

 

return nil

end

 

FGroup:ClearTasks()

 

 

******* Do I need to put FGroup where there are parenthesis ?? ****************


Edited by ChuckIV

"Never in the field of human conflict was so much owed by so many to so few." Winston Churchill

 

SYSTEM:

Processor - Intel® Core i9-9900KF CPU @ 3.60GHz 3600MHz water-cooled

Installed memory (RAM) - 32.0 GB

64-bit Operating System, x64-based processor

Windows 10 & DCS on SSD

Video Card - water-cooled NVIDIA GeForce RTX 2080 Ti

Internet: Cable 200Mbps 12Mbps

Link to comment
Share on other sites

Thanks funkyfranky

 

funkyfranky,

 

Thanks for you help - the lua file is working much, much, better now. The groups STOP following Blue Leader and can now be tasked with something new like RTB, ORBIT HERE, or more importantly, ATTACK!

 

Thanks again,

ChuckIV

"Never in the field of human conflict was so much owed by so many to so few." Winston Churchill

 

SYSTEM:

Processor - Intel® Core i9-9900KF CPU @ 3.60GHz 3600MHz water-cooled

Installed memory (RAM) - 32.0 GB

64-bit Operating System, x64-based processor

Windows 10 & DCS on SSD

Video Card - water-cooled NVIDIA GeForce RTX 2080 Ti

Internet: Cable 200Mbps 12Mbps

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...