ChuckIV Posted November 30, 2019 Share Posted November 30, 2019 (edited) 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 November 30, 2019 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 More sharing options...
Tiramisu Posted November 30, 2019 Share Posted November 30, 2019 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. Link to comment Share on other sites More sharing options...
Tiramisu Posted November 30, 2019 Share Posted November 30, 2019 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 More sharing options...
ChuckIV Posted December 2, 2019 Author Share Posted December 2, 2019 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 More sharing options...
Tiramisu Posted December 2, 2019 Share Posted December 2, 2019 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 More sharing options...
A101Wayz Posted December 2, 2019 Share Posted December 2, 2019 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 More sharing options...
Tiramisu Posted December 2, 2019 Share Posted December 2, 2019 Oh, that is an easier solution and has the same result like mine. :) I was assuming that resetTask just restarts the current task. Link to comment Share on other sites More sharing options...
Pikey Posted December 2, 2019 Share Posted December 2, 2019 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 * Link to comment Share on other sites More sharing options...
Tiramisu Posted December 2, 2019 Share Posted December 2, 2019 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? Link to comment Share on other sites More sharing options...
Pikey Posted December 2, 2019 Share Posted December 2, 2019 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 More sharing options...
ChuckIV Posted December 4, 2019 Author Share Posted December 4, 2019 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 More sharing options...
funkyfranky Posted December 4, 2019 Share Posted December 4, 2019 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 | RTX 4090 | 128 GB Ram 3200 MHz DDR-4 | Quest 3 RAT - On the Range - Rescue Helo - Recovery Tanker - Warehouse - Airboss Link to comment Share on other sites More sharing options...
ChuckIV Posted December 5, 2019 Author Share Posted December 5, 2019 (edited) 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 December 5, 2019 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 More sharing options...
ChuckIV Posted December 6, 2019 Author Share Posted December 6, 2019 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 More sharing options...
Recommended Posts