Habu_69 Posted June 3, 2023 Posted June 3, 2023 Has anyone forced an AI wingman to human pilot rearm/refuel? if so, how?
Solution PravusJSB Posted June 7, 2023 Solution Posted June 7, 2023 I use the task action & type of 'LandingReFuAr' to achieve that. Takes them a while to fully refuel and re-arm and for good measure you should re-task them to be your wingman after they get airborne again. Creator & Developer of XSAF ::An AI model that wants to kill you, and needs no help from humans. Discord: PravusJSB#9484 twitch.tv/pravusjsb https://www.patreon.com/XSAF https://discord.gg/pC9EBe8vWU https://bmc.link/johnsbeaslu Work with me on Fiverr: https://www.fiverr.com/pravusjsb
Habu_69 Posted June 9, 2023 Author Posted June 9, 2023 Tried that, but was probably not patient enough. I will give it another go. Tx.
PravusJSB Posted June 9, 2023 Posted June 9, 2023 (edited) Yea for sure it works, but its a lengthy old process. I think the pilot goes cold and dark and exits the cockpit during the process too so it looks to not work but he will come back. If you need some tips on how to structure the task let me know I'll try put it together for you. Edited June 9, 2023 by PravusJSB Creator & Developer of XSAF ::An AI model that wants to kill you, and needs no help from humans. Discord: PravusJSB#9484 twitch.tv/pravusjsb https://www.patreon.com/XSAF https://discord.gg/pC9EBe8vWU https://bmc.link/johnsbeaslu Work with me on Fiverr: https://www.fiverr.com/pravusjsb
Habu_69 Posted June 9, 2023 Author Posted June 9, 2023 5 hours ago, PravusJSB said: Yea for sure it works, but its a lengthy old process. I think the pilot goes cold and dark and exits the cockpit during the process too so it looks to not work but he will come back. If you need some tips on how to structure the task let me know I'll try put it together for you. Would appreciate your guidance here. I am trying to get P-51 wingman to rearm/refuel. I set flight path to WP with task RearmRefuel, 5 min on ground, then additional waypoints. I land, taxi to apron. --2 lands, parks, shuts down. He does not exit airplane. I rearm/refuel, takeoff. But after 15 min. --2 still sitting, engine off, not rearmed.
PravusJSB Posted June 9, 2023 Posted June 9, 2023 (edited) 1 hour ago, Habu_69 said: Would appreciate your guidance here. I am trying to get P-51 wingman to rearm/refuel. I set flight path to WP with task RearmRefuel, 5 min on ground, then additional waypoints. I land, taxi to apron. --2 lands, parks, shuts down. He does not exit airplane. I rearm/refuel, takeoff. But after 15 min. --2 still sitting, engine off, not rearmed. Hopefully you can glean from this the right struct to pass, its a constructor for all tasks so i dont remember the specifics of how i wrote... it wont be copy/pasteable but you should be able to just see the right struct, thats half of the problem with tasks and getting the desired results. EDIT: from the if obj.trg.pers is the rearm reful, but it looks like i add in the WPs for going back up again that might be what makes the magic happen. Yea im giving them an infinite patrol task after they get back up to give me time to pick them back up again and re-task them.... and work out the glide path for them so they go straight in with no extra delays. -- internal function -- air waypoint generate local function PointTask(pos,type,_speed,action,tasking,alt,spdlock,radio,wrap,push) local point = {['x'] = pos.x, ['y'] = pos.y or alt, ['z'] = pos.z} local speed = _speed if not action then action = "Turning Point" end if not type then type = "Turning Point" end local task = wrap or { ["id"] = "ComboTask", ["params"] = { ["tasks"] = tasking or {}, }, } return { ["properties"] = { ["addopt"] = { }, -- end of ["addopt"] }, -- end of ["properties"] ["type"] = type, ["name"] = new_point_name(), ["x"] = point.x, ["y"] = point.z, ["alt"] = alt or (point.y + Disposition.getPointHeight(pos)), ["alt_type"] = radio or "RADIO", ["speed"] = speed, ["action"] = action, ["task"] = task, ["ETA"] = push or 0, ["ETA_locked"] = push == true, ["speed_locked"] = spdlock or false, ["formation_template"] = "", } end; local function land_function(_group) local group = _group local obj = optDB.aiV4[group] -- our running thread, stopping when the object is dead or we flag it as dead while (obj.alive == true) do local start = os.clock() if not obj:isAlive() then obj.alive = false else local res,fun = pcall(function() if obj.flag == 0 then -- setup our objects tasking local vec = obj:vec3() local pnt if obj:inAir() and vec and vec.y and vec.y > 800 and obj.trg.perField then obj:clearTask() local base = Airbase.getByName(obj.trg.perField) local ret if not base then ret, base = pcall(function() _log("JSB V4 AI: Error in tasking land_func, had to find a base;\n%s",jsb.tbl2(obj)) return aiMed.fun.getJMR().getBaseClose(vec, 1) end) end if base then local rwObj = base:getRunways()[1] pnt = rwObj.position local rw = rwObj.course * -1 local dir = rw + (math.pi) local glide = { ['x'] = pnt.x + 2200 * math.cos( dir ), ['y'] = 0, ['z'] = pnt.z + 2200 * math.sin( dir ) } optDB.aiV4[group].task = { ['id'] = 'Mission', -- Mission ['params'] = { ['airborne'] = true, ['route'] = { ['points'] = { PointTask(vec, nil, mToKnots(0.75), 'Fly Over Point', nil, 10500/3.35), -- PointTask(shiftPoint(pnt,2000),nil,mToKnots(0.85),nil,nil,obj.trg.alt or (35000/3.3)), }, }, }, } if obj.trg.pers then -- TODO needs testing local patrol = { { ["number"] = 1, ["auto"] = false, ["id"] = "WrappedAction", ["enabled"] = true, ["params"] = { ["action"] = { ["id"] = "SwitchWaypoint", ["params"] = { ["goToWaypointIndex"] = #obj.task.params.route.points+1, ["fromWaypointIndex"] = #obj.task.params.route.points+2, }, }, }, }, } obj.task.params.route.points[#obj.task.params.route.points+1] = PointTask(glide,nil,mToKnots(0.45),nil,nil,450) -- landing phase obj.task.params.route.points[#obj.task.params.route.points+1] = PointTask(pnt,'LandingReFuAr',130,'LandingReFuAr',nil,100) obj.task.params.route.points[#obj.task.params.route.points]["airdromeId"] = base:getID() obj.task.params.route.points[#obj.task.params.route.points+1] = PointTask(pnt,nil,mToKnots(0.85),'Fly Over Point',nil,25500/3.35) obj.task.params.route.points[#obj.task.params.route.points+1] = PointTask(pnt,nil,mToKnots(0.85),'Fly Over Point',patrol,25500/3.35) -- obj:unitTask(true) -- optDB.aiV4[group].task = { -- ['id'] = 'EngageTargets', -- ['params'] = { -- ['maxDistEnabled'] = true, -- ['maxDist'] = 3000, -- ['targetTypes'] = { obj.trg.target_types or "All" }, -- ['priority'] = 1, -- ['noTargetTypes'] = obj.trg.trg_not, -- }, -- } obj:unitTask() elseif obj.trg.points and #obj.trg.points > 0 then -- new astar code for i = 1, #obj.trg.points do obj.task.params.route.points[#obj.task.params.route.points+1] = PointTask({x = obj.trg.points[i][1], y = 0, z = obj.trg.points[i][2]}, nil, mToKnots(0.85), nil, nil, obj.trg.alt or obj.trg.points[i][3] or (42000/3.3)) -- specific route end obj.task.params.route.points[#obj.task.params.route.points+1] = PointTask(glide,nil,mToKnots(0.45),nil,nil,450) -- landing phase obj.task.params.route.points[#obj.task.params.route.points+1] = PointTask(pnt,'LandingReFuAr',130,'LandingReFuAr',nil,100) obj.task.params.route.points[#obj.task.params.route.points]["airdromeId"] = base:getID() obj.task.params.route.points[#obj.task.params.route.points - 2].alt = (10000/3.3) obj.task.params.route.points[#obj.task.params.route.points - 3].alt = (14000/3.3) -- obj.task.params.route.points[#obj.task.params.route.points - 4].alt = (17000/3.3) -- obj.task.params.route.points[#obj.task.params.route.points - 5].alt = (25000/3.3) -- obj.task.params.route.points[#obj.task.params.route.points - 6].alt = (30000/3.3) obj:unitTask() _log("Pushed new ASTAR route %s number points %d", _group, #obj.task.params.route.points) else obj.task.params.route.points[#obj.task.params.route.points+1] = PointTask(glide,nil,mToKnots(0.45),nil,nil,450) -- landing phase obj.task.params.route.points[#obj.task.params.route.points+1] = PointTask(pnt,'LandingReFuAr',130,'LandingReFuAr',nil,100) obj.task.params.route.points[#obj.task.params.route.points]["airdromeId"] = base:getID() obj:unitTask() end obj.flag = 1 -- _log("Has moved %s to flag 1",obj.name) else _log("JSB V4 AI: Error in tasking land_func, data;\n%s",jsb.tbl2(obj)) obj.flag = 2 end elseif not obj.trg.perField or not vec or not vec.y then obj.flag = 2 end elseif obj.flag == 1 then -- TDOO check for threats on way and route around them? obj.flag = 2 elseif obj.flag == 2 then -- TDOO check for threats on way and route around them? obj.alive = false end end) if not res then _log("ERROR in ai %s",tostring(fun)) obj.alive = false end end local fin = os.clock()-start if fin > 0.014 then _log("Land cor took %f",fin) end coroutine.yield() end end Edited June 9, 2023 by PravusJSB Creator & Developer of XSAF ::An AI model that wants to kill you, and needs no help from humans. Discord: PravusJSB#9484 twitch.tv/pravusjsb https://www.patreon.com/XSAF https://discord.gg/pC9EBe8vWU https://bmc.link/johnsbeaslu Work with me on Fiverr: https://www.fiverr.com/pravusjsb
PravusJSB Posted June 9, 2023 Posted June 9, 2023 Feel free to drop me a discord if you need any more help integrating. Creator & Developer of XSAF ::An AI model that wants to kill you, and needs no help from humans. Discord: PravusJSB#9484 twitch.tv/pravusjsb https://www.patreon.com/XSAF https://discord.gg/pC9EBe8vWU https://bmc.link/johnsbeaslu Work with me on Fiverr: https://www.fiverr.com/pravusjsb
Habu_69 Posted June 9, 2023 Author Posted June 9, 2023 2 hours ago, PravusJSB said: Feel free to drop me a discord if you need any more help integrating. Well, I certainly was not expecting such a complex script would be needed for a simple task. Most all my scripting has been Moose, so will take me a bit of study to parse this out. TYVM for the input. 1
PravusJSB Posted June 9, 2023 Posted June 9, 2023 (edited) Yea, I mean it's not all relevant to your needs but the way I build my task and the expectations you should be able to extract, if not happy to help further. My code is normally for me only so some of the older stuff I'd yet to figure out the importance of naming conventions and readability so its a bit tougher than it should be. The PointTask func you should be able to copy paste, just replace the function that names it with your own, and theres some duplication because of overloads with the 'ASTAR' that you can stop reading from. So that last task with the looped waypoints is important and the rest you should be OK with. Does not need to be in a coroutine either (sorry if thats obvious), I just copied my live implementation straight out of my AI so its just how its setup but not needed here for you. Edited June 9, 2023 by PravusJSB Creator & Developer of XSAF ::An AI model that wants to kill you, and needs no help from humans. Discord: PravusJSB#9484 twitch.tv/pravusjsb https://www.patreon.com/XSAF https://discord.gg/pC9EBe8vWU https://bmc.link/johnsbeaslu Work with me on Fiverr: https://www.fiverr.com/pravusjsb
Habu_69 Posted June 21, 2023 Author Posted June 21, 2023 Still have not solved this issue. I can not get recommended script to work for a human pilot's AI wingman, I think because the wingman does not really follow a flightplan. They follow lead and execute menu-driven instructions. Another complicating issue is that WWII aircraft have only imprecise methods to follow a flightplan, like dead reckoning and visual recognition of landmarks. So I believe that with current DCS processes my quest is mission impossible.
Recommended Posts