massdriver Posted September 9, 2021 Share Posted September 9, 2021 Hi, I was wondering if someone can help me shed light on how to use setCommand() and setTask() / pushTask() properly. I have spent may hours on this but cannot make it work. Specifically, I am trying to use the SwitchWaypoint/GoToWaypoint commands. All of the following examples have no effect on the unit/group in question: 1) via group local g = Group.getByName("Aerial-1") local c = g:getController() local switchWaypointCommand = { ["id"] = 'SwitchWaypoint', ["params"] = { ["fromWaypointIndex"] = 2, ["goToWaypointIndex"] = 5, } } -- the following has no effect c:setCommand(switchWaypointCommand) 2) via unit local u = Unit.getByName("Aerial-1-1") local c = u:getController() local switchWaypointCommand = { ["id"] = 'SwitchWaypoint', ["params"] = { ["fromWaypointIndex"] = 2, ["goToWaypointIndex"] = 5, } } -- the following has no effect c:setCommand(switchWaypointCommand) 3) using a WrappedAction task local g = Group.getByName("Aerial-1") local c = g:getController() local wrappedActionTask = { ["id"] = "WrappedAction", ["params"] = { ["action"] = { ["id"] = "SwitchWaypoint", ["params"] = { ["goToWaypointIndex"] = 5, ["fromWaypointIndex"] = 2, } } } -- neither of the two following work or do anything c:pushTask(wrappedActionTask) c:setTask(wrappedActionTask) All of the above equivalently do not have any effect when GoToWaypoint is used for ground units. ----------------------------- As a side note, the following similar, and possibly related issue puzzles me: a) consider I create a series of LandingReFuAr waypoints for a plane unit in the mission editor b) if I run the mission at this stage, everything runs fine, i.e. the plane flies from airport to airport and lands, refuels, and rearms c) however, if I - via triggered script - then deepcopy the plane's mission task (as defined from within the mission editor) and reassign it using setTask(), the plane will keep flying along the route of waypoints, but not land anymore. I have checked the original mission (extracted from the .miz file) against the one that I set and confirmed that they are 100% identical Can someone help me better understand the inner workings of setTask() and setCommand()? Thanks. Link to comment Share on other sites More sharing options...
toutenglisse Posted September 9, 2021 Share Posted September 9, 2021 52 minutes ago, massdriver said: Hi, I was wondering if someone can help me shed light on how to use setCommand() and setTask() / pushTask() properly. I have spent may hours on this but cannot make it work. Specifically, I am trying to use the SwitchWaypoint/GoToWaypoint commands.... Your first example ( 1) via group ) works without issue, I just tried with an AI Ah64d, and when script is called the apache goes reaching wpt 1 (the 2nd wpt) and then wpt 4 (the 5th wpt). Link to comment Share on other sites More sharing options...
massdriver Posted September 9, 2021 Author Share Posted September 9, 2021 (edited) Motivated by your comment, I just re-tried this (with a plane, not a helicopter) and can confirm it is definitely not working for me. Attached is the .miz file with my test mission. The AI plane takes off from Batumi and simply continues to follow along the original waypoints, even though the above script is set to run when it crosses waypoint 1. There is another trigger in that script to confirm the script is actually run: trigger.action.outText("script runs now", 10) Any ideas? Thanks in advance. set_command_test.miz Edited September 9, 2021 by massdriver forgot to attach mission file Link to comment Share on other sites More sharing options...
toutenglisse Posted September 10, 2021 Share Posted September 10, 2021 1 hour ago, massdriver said: ...Any ideas? Thanks in advance... I can see your issue. When your AI Viper reaches waypoint 1 it gets the script command but at first gets the "land/rearm/refuel" task linked to wpt 2, and that takes priority over the command that is ignored. Just adding a wpt between wpt 1 and wpt 2 fixes that (AI flies from wpt 1 to wpt 4). Other thing to do is to add a wpt near and before any wpt of "land/rearm/refuel" type, because if you switch to a wpt that has an altitude of 0 AGL (like each "land/rearm/refuel" type wpt) the AI flies dangerously low. Last thing I did was to set "player" Viper as "client" to get smoother fast forward F10 map view as spectator (time x 50). set_command_test_modified.miz Link to comment Share on other sites More sharing options...
massdriver Posted September 10, 2021 Author Share Posted September 10, 2021 Great, thanks a lot for your suggestions! I will keep testing this. Link to comment Share on other sites More sharing options...
jross194 Posted October 26, 2021 Share Posted October 26, 2021 Any luck with this? I can't, as of today (Oct 25, 2021) get this to work in LUA. Works via ME fine. I've had to get it all working via setting a flag in LUA, associated with the condition field in the ME. Rather not have to do it this way. Thanks. i6700k 4.4mhz, 32Gb, nVidia 1080, Odyssey+, CH Products, Derek Speare Designs button box, Bass shaker w/SimShaker For Aviators Link to comment Share on other sites More sharing options...
Hellbat Posted October 26, 2021 Share Posted October 26, 2021 (edited) Update: I thought I had an issue, but I think I got my script working. The set waypoint command appeared to be ignored since I had CAP aircraft engaging targets (I say appeared since I don't know if it set the waypoint, but the aircraft weren't redirected). By first setting the aircraft to weapons hold, they terminated their current engagement and then redirected to the correct waypoint. Edited October 27, 2021 by Hellbat Link to comment Share on other sites More sharing options...
Recommended Posts