dr_hippo Posted March 18, 2021 Posted March 18, 2021 Hi All, I have a F18 loaded with HARMS. When they have fired all the HARMS I want him to fly to a tanker before going home. There is a "RTB out of Ammo" option, then the F18 is flying home. Do I think I have to add some LUA script in the stop condition for the enrout task in the F18? Is this the best approach? Next those have a F15 Escort group. The escort command says escort until a certain waypoint. I would like when the F18s are flying to the tanker that the task from the F15s is changing to patrol in a region! The patrol I can assign to a waypoint in the F15. The question is that the F15 should change from escort to patrol when the F18`s are flying to the tanker. I think that I have to script it as well in in the stop condition for the escort or from the F18? Is that the correct approach? I prefer to do the lua script direct in the mission editor. I find a lot of examples using moose or Mist. I do not find them for lua script in advanced waypoint actions! If someone can give me a link or hint or starting point? that would be amazing Thanks
Grimes Posted March 19, 2021 Posted March 19, 2021 mist and moose are scripting libraries that you load via do script file that simplify and add functionality to the scripting engine to make certain things easier. Both are limited to what the scripting engine itself can do. An example of that would be to package the sample of code below into a function and save it in a file. Then whenever whenever you want to use it instead of copy pasting it each time, you just load the file its in and can load at any point. So to answer your question you can do a mix of flags and scripting to accomplish it. There is no trigger to see how much or of what type of weapons a given aircraft has on board. Thus you will need to use the scripting engine to check it for the F-18 flight and then to order them to go to a WP to refuel before RTB via setting a flag. The setup would be something like this. F-18 Search and Engage sams task> Stop condition script local gp = ... local harms = 0 for i, unit in pairs(gp:getUnits) do local ammo = unit:getAmmo() if ammo and #ammo > 0 and harms == 0 then for j = 1, #ammo do if ammo[j].desc.displayName == 'AGM-88C' then harms = harms + ammo[j].count end end end end if harms == 0 then trigger.action.setUserFlag(20, true) return true end This would set flag 20 to true and would stop the AI's task to engage sams. Then you can setup triggered actions for each group to switch waypoint and set the stop condition for the F-15 escort task to be if flag 20 is true. Now create a trigger for flag 20 is true with the actions for AI Push Task (F-18 switch WP). I'd set the AI to refuel at that waypoint that way they will do it even if they dont run out of HARMs. 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
dr_hippo Posted March 19, 2021 Author Posted March 19, 2021 @Grimes, Thanx a lot, that is not just a Hint, that is the complete solution! Thank you very much, I give it a go later on this day. Stijn
dr_hippo Posted March 19, 2021 Author Posted March 19, 2021 Hmmmmm, script is working so that is great. The only problem is that on the trigger action nothing appears under the drop down menu in AI push task
dr_hippo Posted March 20, 2021 Author Posted March 20, 2021 Hi All, I am new in lua scripting. I have some scripting experience,.... not to much.. I have played around with Moose. I copy, paste and adapt some scripts and I get the thing working most of the time... I am not able to get the script working in the stopcondition for the advanced waypoint. I asume that I have to put the group name or function to get the groupname in the ... in the " gp = ... ". That always results in errors. I do understand the rest of the script.... I do have a second issue in the trigger function where the acttion should be " push ai task ". The drop down menu under push ai task does not show any options. I asked another DCS player and he have the same. I think I can change that with do script and script the action I want... or is there any ither reason why I do not see any option under push ai task? Can someon give me a hint for the script what to fill in at the ... local gp = ... local harms = 0 for i, unit in pairs(gp:getUnits) do local ammo = unit:getAmmo() if ammo and #ammo > 0 and harms == 0 then for j = 1, #ammo do if ammo[j].desc.displayName == 'AGM-88C' then harms = harms + ammo[j].count end end end end if harms == 0 then trigger.action.setUserFlag(20, true) return true end thanx
toutenglisse Posted March 20, 2021 Posted March 20, 2021 You need to fill 1st line with : local gp = Group.getByName('name of your group') For "push ai task" to show options you have to create tasks : select the group, open tab "actions", create a task.
dr_hippo Posted March 20, 2021 Author Posted March 20, 2021 Hi toutenglisse, Thanx for your hint. The "push ai task "and create task I did not know so that is clear!. The Group.getByName is is one of the things I have tried! Here is the error message
toutenglisse Posted March 21, 2021 Posted March 21, 2021 1 hour ago, dr_hippo said: ... Here is the error message... It looks like it lacks () in the third line : for i, unit in pairs(gp:getUnits()) do
Grimes Posted March 21, 2021 Posted March 21, 2021 Sorry didn't have the time to look into this until just now. Yeah I did forget a () in there. However there also appears to be a bug with how DCS does the start and stop condition scripts. So that method is out for checking. The ... in the script is like a special way to write "self" for that group. It only works in scripts run as part of a group's task. Normally you would need to do local gp = Group.getByName('whatever') However within that group task it can just be: local gp = ... Its like a shortcut. You can write the same bit of code and copy it into a bunch of groups do script tasks without having to change anything. I've changed it to run that code on a do script in the triggers. Also changed the stop condition of that task from the script to just a flag value. me Bandar Abbastest_modf.miz 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
Recommended Posts