EasyEB Posted May 25, 2016 Posted May 25, 2016 (edited) So, with mist I was able to make a friendly group move to an enemy groups current position, wherever that enemy group was. Now I want to make a friendly MQ-9 Reaper move to, and orbit, the same enemy group. I guess I'll start with mist.FixedWingBuildWP, however I do not know how to implement it, and how do I get the Reaper to orbit the location once it get there, and not just move on? The group that I want the Reaper to orbit is spawned via script at random locations and may or may not move to different random locations once it is spawned. The name of the group is known, but names of units is unknown. Cheers! Edit: Here is what works, it will make Group1 move to and orbit Group2. local orbit = { id = 'Orbit', params = { pattern = 'Circle', point = mist.utils.makeVec2(mist.getAvgPos(mist.makeUnitTable({'[g]Group2'}))), speed = 200, altitude = 8000, } } Group.getByName('Group1'):getController():pushTask(orbit) Edited May 26, 2016 by EasyEB
Grimes Posted May 25, 2016 Posted May 25, 2016 You could create a task for the AI to orbit the position. 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
EasyEB Posted May 26, 2016 Author Posted May 26, 2016 Looks good! So I figured I'd use this to get the Reaper to orbit the group "Red". Orbit = { id = 'Orbit', params = { pattern = enum AI.Task.OribtPattern, point = mist.getLeadPos('Red'), speed = 200, altitude = 20000 } } } But how do I implement it? I tried putting it as a Do Script as a triggered action for the reaper, but it only gave me error. I feel like the Reapers name should be somewhere in the script?
Grimes Posted May 26, 2016 Posted May 26, 2016 It is sort of like using a triggered action for a group. http://wiki.hoggit.us/view/DCS_func_pushTask Group.getByName('Reaper'):getController():pushTask(orbitTable) 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
EasyEB Posted May 26, 2016 Author Posted May 26, 2016 (edited) Oh, so just Group.getByName('Reaper'):getController():pushTask (Orbit = { id = 'Orbit', params = { pattern = enum AI.Task.OribtPattern, point = mist.getLeadPos('Red'), speed = 200, altitude = 20000 } }) ? Edit: Didn't work. Edited May 26, 2016 by EasyEB
Grimes Posted May 26, 2016 Posted May 26, 2016 A few things: 1. It doesn't need to be declared as Orbit= {}. It can be just a table. So local orbitTable = {id = Orbit', etc.} Group.getByName('Reaper'):getController():pushTask (orbitTable) OR Group.getByName('Reaper'):getController():pushTask({id = Orbit', etc.}) 2. enum AI.task.OrbitPattern is the type of value. So it can be defined as either the table entry or just the end value. That is a failure of the documentation and is pretty much what happens when I just try to get the pages made with a basic level of detail with intent to add more information later. There is a pretty obvious correlation to when people ask scripting questions and the relevant wiki article magically gets updated around the same time as an answer. :music_whistling: so AI.Task.OrbitPattern.CIRCLE or simply a string 'Circle' 3. point is a vec2 table meaning its only x and y coordinates. mist.getLoadPos() returns a vec3 coordinate. So you need to convert it using mist.utils.makeVec2. Also you may need to set the value before the pushTask() is done, as in my first example listed above. 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
EasyEB Posted May 26, 2016 Author Posted May 26, 2016 (edited) Thanks! I'll fiddle a bit. If I understand point 1 and 2 correctly, I'll try with Group.getByName('Reaper'):getController():pushTask ({id = 'Orbit', params = { pattern = 'Circle', point = mist.getLeadPos('Red'), speed = 200, altitude = 20000 } }}) I'm not sure if I understand point 3 though. Well, I should say I understand what you are saying, just not how to use the converter, and also how to set the value before the pushTask() is done. Is it as simple as do local point = mist.utils.makeVec2(mist.getLeadPos('Red')):getPosition().p local surfType= and.getSurfaceType(point) end ? But now I feel lost in the inception, does this give me the vec2 of the leader of Red? I almost want to Group.getByName('Reaper'):getController():pushTask ({id = 'Orbit', params = { pattern = 'Circle', point = (local point = mist.utils.makeVec2(mist.getLeadPos('Red')):getPosition().p local surfType= and.getSurfaceType(point)), speed = 200, altitude = 20000 } }}) But it just feels like I'm guessing. :) Edit: I see you updated the wiki. Thanks! Just a note: The example explanation should maybe note that it will make a group named "Reaper" orbit the group "arty"? Edited May 26, 2016 by EasyEB
Grimes Posted May 26, 2016 Posted May 26, 2016 I attached a mission to my post. It uses the same example I have placed in the updated orbit wiki page. mist.makeVec2 suffers from an incomplete example on the documentation. If the example is weird just look at the syntax information. vec2 mist.utils.makeVec2(table vec3) What gets returned name of function(type of value the actual value) So you can pretty much always just try writing just that line to get an idea. Blue stuff is required, Green is optional. local vec2 = mist.utils.makeVec2(someVec3Table)pushTask_orbit_test.miz 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
EasyEB Posted May 26, 2016 Author Posted May 26, 2016 I used the example in the wiki and it worked great! Thanks alot! Only issue I found is that the Reaper now seems stuck in the same orbit position forever. I use a radio trigger to run the script and get the Reaper to start the orbit over the enemy groups position, however, if the enemy group moves and I give the order again the Reaper doesn't respond, it just stays over the same position it got the first time.
EasyEB Posted May 26, 2016 Author Posted May 26, 2016 I managed to find a way to send the Reaper to the enemy groups position again, after it had once been given the command. It ain't pretty, and I'm wondering if there is a better way to do it? What I want is the Reaper to follow the group if they start moving. What I did was I gave the Reaper a triggered action of TASK SET (Task push didn't work, the Reaper was non-responsive) of Switch Waypoint to it's first waypoint (where it is set to orbit at mission start). What happens then is the Reaper starts RTB, so then if I immediately give it the Orbit-script it will update it's orbit position. Rinse and repeat.
Grimes Posted May 27, 2016 Posted May 27, 2016 I managed to find a way to send the Reaper to the enemy groups position again, after it had once been given the command. It ain't pretty, and I'm wondering if there is a better way to do it? What I want is the Reaper to follow the group if they start moving. You may need to use popTask() first to remove the active orbit task. It *should* be accepting of any task you give it, but the pushTask command is different because it doesn't completely overwrite the mission task or other tasks that may be active. So perhaps it just didn't want to have multiple orbits in the task stack. You could also try the FAC tasking. I coulda swore I got a drone to follow a group around at one point, but I don't remember when that was or why it happened. 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
FlightControl Posted May 28, 2016 Posted May 28, 2016 (edited) So, with mist I was able to make a friendly group move to an enemy groups current position, wherever that enemy group was. Now I want to make a friendly MQ-9 Reaper move to, and orbit, the same enemy group. I guess I'll start with mist.FixedWingBuildWP, however I do not know how to implement it, and how do I get the Reaper to orbit the location once it get there, and not just move on? The group that I want the Reaper to orbit is spawned via script at random locations and may or may not move to different random locations once it is spawned. The name of the group is known, but names of units is unknown. Cheers! Edit: Here is what works, it will make Group1 move to and orbit Group2. Maybe, maybe try the MOOSE framework... Ensure you have the Moose.lua file included at mission start. Then code something like this: local ReaperGroup = GROUP:FindByName( "Reaper Group Name" ) local EnemyUnit = UNIT:FindByName( "Name of Enemy Unit" ) local OrbitTask = ReaperGroup:TaskOrbitCircleAtVec2( EnemyUnit:GetPointVec2(), 1000, 300 ) ReaperGroup:PushTask( OrbitTask ) This will send your reaper for orbit to the Enemy Unit location, orbitting at 1000 meters with a speed of 300 km/h. Simple, really ...:megalol: Edited May 28, 2016 by FlightControl [TABLE][sIGPIC][/sIGPIC]| Join MOOSE community on: DISCORD :thumbup: Website of the MOOSE LUA Framework. MOOSE framework Downloads. Check out Example Missions to try out and learn. MOOSE YouTube Channel for live demonstrations and tutorials. [/TABLE]
Recommended Posts