Bruce_D Posted August 30, 2019 Posted August 30, 2019 Hi, I need some help with “engageTargetsInZone”. This is part of my script: local Mission1 = { id = 'Mission', params = { route = { points = { [1] = { type = 'Turning Point', action = 'Fin Point', x = SPointxL, y = SPointyL, alt = SPointy, speed = 154.333333, task = { id = 'EngageTargetsInZone', params = { point = {x = SPointx, y = SPointy}, zoneRadius = 46300, targetTypes = {'All', 'Air', 'Planes', 'Fighters', 'Bombers'}, priority = 0 }, }, }, [2] = { type = 'Turning Point', action = 'Fin Point', x = SPointx, y = SPointy, alt = SPointy, speed = 154.333333, task = { id = 'Orbit', params = { pattern = 'Circle', speed = 154.333333, altitude = 7620, }, }, }, }, }, } } trigger.action.setUserFlag("2", 1) PlaneController:resetTask() PlaneController:pushTask(Mission1) What is happening: The plane goes to waypoint one and ignores the task task = { id = 'EngageTargetsInZone', params = { point = {x = SPointx, y = SPointy}, zoneRadius = 46300, targetTypes = {'All', 'Air', 'Planes', 'Fighters', 'Bombers'}, priority = 0 }, }, Then the plane goes to waypoint 2 and execute the task orbit. What am I doing wrong? Tks
TOViper Posted September 1, 2019 Posted September 1, 2019 (edited) Hi, I need some help with “engageTargetsInZone”. .. .. .. What am I doing wrong? Tks Does it work without scripting, I mean with using the UI settings pages? I had - in the past - problems with "Search Then Engage Targets in Zone". A few questions: Does any opponent for them exist which is worth they could attack? Do they have respective weapons? Are they over or under counted? Is it daylight or night? Is the enemy too strong? Are the pilots "Average" skilled, or differently ... Are the coordinates mixed up? Edited September 1, 2019 by TOViper Visit https://www.viggen.training ...Viggen... what more can you ask for? my computer: AMD Ryzen 5600G 4.4 GHz | NVIDIA RTX 3080 10GB | 32 GB 3.2 GHz DDR4 DUAL | SSD 980 256 GB SYS + SSD 2TB DCS | TM Warthog Stick + Throttle + TRP | Rift CV1
Bruce_D Posted September 1, 2019 Author Posted September 1, 2019 Hi, Tks for the answer! I am traveling right now but at soon as I arrive I will send the mission. Let try to answer the questions Does it work without scripting, I mean with using the UI settings pages? I had - in the past - problems with "Search Then Engage Targets in Zone Yes, it does. The problem is when AI refuels at the tanker, it stops working and the plane just orbits around the tanker and don't go back to the route. My script resets the AI tasks, so the plane starts a new route that I've created. The problem is I am not using the engage func correct (or it is not working). Does any opponent for them exist which is worth they could attack? No, all the opponents enter and stay in the zone. Do they have respective weapons? No, the enemies are unarmed and the plane that is on the route is armed. Are they over or under counted? It is 1 F-18 against 2 transports and 2 recon planes. Is it daylight or night? Day (8 am) Is the enemy too strong? No Are the pilots "Average" skilled, or differently ... Excellent You can find a copy of the mission without the script on this thread: https://forums.eagle.ru/showthread.php?t=246853&page=2 Tks for the attention
TOViper Posted September 1, 2019 Posted September 1, 2019 (edited) I made a playground for you, which is attached below. You might start the mission, and then Use F10 -> OTHER to select different Tasks. Watch the F15 flying from EAST to WEST (waypoint 0 to 1). If you don't command anything, it won't do anything. Once you command it to do something, it does. You will also receive visual and aural feedback. One thing I noticed: A refuel task cannot be cancelled once it startet. All other tasks can be reset anytime. After such a reset, the F15 returns to its original task (fly to waypoint 1) I used triggered actions. One of them uses the script "resetTask()", which is an important one. All other tasks (orbit, engage, refuel, follow) include a resetTask before the task itself is launched. The triggered actions also make use of "Stop conditions", which trigger the RESET flag (which is 9). Works like a charm. But I still cannot say if your script has a failure, or the DCS engine has a bug for using the SearchThenEngangeInZone thing ... What you might do is adding a triggered action for this and try it out. What I can also say is that setting ROEs is super-important for everything that has to do with making missions in DCS. It is some kind of super elixir. Hope this brings some light into darkness. TOViper_Task_Test.miz Edited September 1, 2019 by TOViper Visit https://www.viggen.training ...Viggen... what more can you ask for? my computer: AMD Ryzen 5600G 4.4 GHz | NVIDIA RTX 3080 10GB | 32 GB 3.2 GHz DDR4 DUAL | SSD 980 256 GB SYS + SSD 2TB DCS | TM Warthog Stick + Throttle + TRP | Rift CV1
Bruce_D Posted September 1, 2019 Author Posted September 1, 2019 Thank you gor your help! I will check your mission next week, as soon as I get home. And I will send you the script and the mission. Tks
Hardcard Posted September 2, 2019 Posted September 2, 2019 (edited) I'd push the tasks independently from the Mission1 table, in order to identify and isolate the problem: PlaneController:pushTask(Mission1.params.route.points[1].task) [color="Blue"] -- This should direct pushTask to the EngageTargetsInZone task table[/color] PlaneController:pushTask(Mission1.params.route.points[2].task) [color="Blue"] -- This should direct pushTask to the Orbit task table[/color] If these tasks run on their own, means that your problem is somewhere inside the Mission1 table. Also, PlaneController might need to be the controller of the AI group, not the individual AI units... try it both ways, see what happens. Also, it might also be that you're missing some required parameters or that some of the parameters have invalid values. Edited September 2, 2019 by Hardcard [sIGPIC][/sIGPIC]
Bruce_D Posted September 2, 2019 Author Posted September 2, 2019 Hi, Tks for the tip! I'll try it! Also, PlaneController might need to be the controller of the AI group, not the individual AI units... try it both ways, see what happens. Also, it might also be that you're missing some required parameters or that some of the parameters have invalid values. PlaneController is a controller for ai, I just put part of the code on this tread, but it is specified above the mission1. What I'm not sure about is this parameters in engage in zone : targetTypes = {'All', 'Air', 'Planes', 'Fighters', 'Bombers'}, I think this is the problem, but I am not sure. Tks
Bruce_D Posted September 9, 2019 Author Posted September 9, 2019 I’ve solved the problem! I’m 100% sure that it is a bug! If the AI plane goes to refuel automatic on the tanker, all the engage tasks don’t work. Viper’s mission gave me the insight! What have I done to fix? I’ve created the follow function: function Qfuel(Gfuelplane) local fuelplane = Group.getByName(Gfuelplane):getUnit(1) local fuel = Unit.getFuel(fuelplane) local PlaneName = fuelplane:getName() local Controle = Group.getByName(Gfuelplane):getController() if fuel < 0.21 then local Refueling = { id = 'Refueling', params = {}, } Controle:pushTask(Refueling) end end Then inside the mission I’ve created a “CONTINUOUS ACTION” that does the script “Qfuel('Blue')”. I’ve attached the script and the mission.teste2.luaAA Test.miz
Grimes Posted September 9, 2019 Posted September 9, 2019 There is a known bug where if the AI automatically go to a tanker they forget most of their tasking. They will still follow correctly but that is about it. Also from your first post the tasks table should be indexed numerically. local Mission1 = { id = 'Mission', params = { route = { points = { [1] = { type = 'Turning Point', action = 'Fin Point', x = SPointxL, y = SPointyL, alt = SPointy, speed = 154.333333, task = { [1] = { id = 'EngageTargetsInZone', params = { point = {x = SPointx, y = SPointy}, zoneRadius = 46300, targetTypes = {'All', 'Air', 'Planes', 'Fighters', 'Bombers'}, priority = 0 }, }, }, }, [2] = { type = 'Turning Point', action = 'Fin Point', x = SPointx, y = SPointy, alt = SPointy, speed = 154.333333, task = { [1] = { id = 'Orbit', params = { pattern = 'Circle', speed = 154.333333, altitude = 7620, }, }, }, }, }, }, } } trigger.action.setUserFlag("2", 1) PlaneController:resetTask() PlaneController:pushTask(Mission1) The right man in the wrong place makes all the difference in the world. Current Projects: Grayflag Server, Scripting Wiki Useful Links: Mission Scripting Tools MIST-(GitHub) MIST-(Thread) SLMOD, Wiki wishlist, Mission Editing Wiki!, Mission Building Forum
Bruce_D Posted September 9, 2019 Author Posted September 9, 2019 Hi, Tks for the answer! Also from your first post the tasks table should be indexed numerically. The reason why I didn’t index numerically the task table is because every time I do that DCS (at least on my PC) crashes. It works without index the task table. Here is the code that crashes the PC: local Mission1 = { id = 'Mission', params = { route = { points = { [1] = { type = 'Turning Point', action = 'Fin Point', x = SPointxL + 200, y = SPointzL + 200, alt = SPointy, speed = 154.333333, task = { [1] = { id = 'EngageTargetsInZone', params = { point = {x = SPointx, y = SPointz}, zoneRadius = 46300, targetTypes = {'Air', 'Planes', 'Fighters', 'Bombers'}, priority = 1 }, }, }, }, [2] = { type = 'Turning Point', action = 'Fin Point', x = SPointx, y = SPointz, alt = SPointy, speed = 154.333333, task = { [1] = { id = 'Orbit', params = { pattern = 'Circle', speed = 154.333333, altitude = SPointy, }, }, }, }, }, }, } }Logs.rartesteCrash.luaAA TestCrash.miz
Bruce_D Posted September 9, 2019 Author Posted September 9, 2019 I’ve created the follow function: . . . Then inside the mission I’ve created a “CONTINUOUS ACTION” that does the script “Qfuel('Blue')”. I’ve improved the function, so now if the group is destroyed the script will not give an error message. function Qfuel(Gfuelplane) if Group.getByName(Gfuelplane) ~= nil then local fuelplane = Group.getByName(Gfuelplane):getUnit(1) local fuelplane2 = Group.getByName(Gfuelplane):getUnit(2) local fuel = Unit.getFuel(fuelplane) local Controle = Group.getByName(Gfuelplane):getController() if fuelplane2 ~= nil then local fuel2 = Unit.getFuel(fuelplane2) if fuel < 0.21 or fuel2 < 0.21 then trigger.action.outText("Plane 1 = " .. fuel .. " / Plane 2 = " .. fuel2, 0.5) local Refueling = { id = 'Refueling', params = {}, } Controle:pushTask(Refueling) end else if fuel < 0.21 then trigger.action.outText("Plane 1 = " .. fuel, 0.5) local Refueling = { id = 'Refueling', params = {}, } Controle:pushTask(Refueling) end end end end
Grimes Posted September 9, 2019 Posted September 9, 2019 local Mission1 = { id = 'Mission', params = { route = { points = { [1] = { type = 'Turning Point', action = 'Fin Point', x = SPointxL + 200, y = SPointzL + 200, alt = PlanePointL.y, speed = 154.333333, task = { id = "ComboTask", params = { tasks = { [1] = { id = 'EngageTargetsInZone', params = { point = {x = PlanePointL.x, y = PlanePointL.z}, zoneRadius = 46300, targetTypes = {'Air', 'Planes', 'Fighters', 'Bombers'}, priority = 1 }, }, }, }, }, }, [2] = { type = 'Turning Point', action = 'Fin Point', x = PlanePointL.x, y = PlanePointL.z, alt = PlanePointL.y, speed = 154.333333, task = { id = "ComboTask", params = { tasks = { [1] = { id = 'Orbit', params = { pattern = 'Circle', speed = 154.333333, altitude = PlanePointL.y, }, }, }, }, }, }, }, }, } } Forgot an oddity of the task table. For some reason it needs a nested table within. For instance. task = { id = "ComboTask", params = { tasks = { [1] = { The right man in the wrong place makes all the difference in the world. Current Projects: Grayflag Server, Scripting Wiki Useful Links: Mission Scripting Tools MIST-(GitHub) MIST-(Thread) SLMOD, Wiki wishlist, Mission Editing Wiki!, Mission Building Forum
Bruce_D Posted September 9, 2019 Author Posted September 9, 2019 Forgot an oddity of the task table. For some reason it needs a nested table within. For instance. task = { id = "ComboTask", params = { tasks = { [1] = { Thanks! It worked and the game didn’t crash.
Bruce_D Posted September 11, 2019 Author Posted September 11, 2019 I’ve improved the function, so now if the group is destroyed the script will not give an error message. Hi, I’ve improved again and correct an error. Now it works for the 4 wingmen: function Qfuel(Gfuelplane, numero) if Group.getByName(Gfuelplane) ~= nil then local fuelplane = Group.getByName(Gfuelplane):getUnit(1) local fuelplane2 = Group.getByName(Gfuelplane):getUnit(2) local fuelplane3 = Group.getByName(Gfuelplane):getUnit(3) local fuelplane4 = Group.getByName(Gfuelplane):getUnit(4) local Refueling = { id = 'Refueling', params = {}, } if fuelplane4 ~= nil then local fuel = Unit.getFuel(fuelplane) local fuel2 = Unit.getFuel(fuelplane2) local fuel3 = Unit.getFuel(fuelplane3) local fuel4 = Unit.getFuel(fuelplane4) local Controle = Group.getByName(Gfuelplane):getController() if fuel < numero or fuel2 < numero or fuel3 < numero or fuel4 < numero then Controle:pushTask(Refueling) end elseif fuelplane3 ~= nil then local fuel = Unit.getFuel(fuelplane) local fuel2 = Unit.getFuel(fuelplane2) local fuel3 = Unit.getFuel(fuelplane3) local Controle = Group.getByName(Gfuelplane):getController() if fuel < numero or fuel2 < numero or fuel3 < numero then Controle:pushTask(Refueling) end elseif fuelplane2 ~= nil then local fuel = Unit.getFuel(fuelplane) local fuel2 = Unit.getFuel(fuelplane2) local Controle = Group.getByName(Gfuelplane):getController() if fuel < numero or fuel2 < numero then Controle:pushTask(Refueling) end elseif fuelplane ~= nil then local fuel = Unit.getFuel(fuelplane) local Controle = Group.getByName(Gfuelplane):getController() if fuel < numero then Controle:pushTask(Refueling) end end end end On the function 'Qfuel(Gfuelplane, numero)', 'Gfuelplane' is the group name, 'numero' is a number between 1 and 0 that represents the % of fuel for each unit of the group.
Recommended Posts