GaSi Posted October 12, 2016 Posted October 12, 2016 Hi. I have no knowledge of lua. I'm developing on a mission editor and I need to define a trigger zone that is not circular. I need the area is polygonal or square and that this defined by geographical coordinates. Is that possible? or I can just make circular in the default? If there way to do this through a LUA, and someone can help me write the code, I would really be very thankful. Regards!
ESAc_matador Posted October 12, 2016 Posted October 12, 2016 You can do it, check Mist functions. You put some units to define the area. I never did, but you can.
GaSi Posted October 12, 2016 Author Posted October 12, 2016 (edited) I check the PDF document but i do not understand lua and I can not find a way to make the script. Somewhere I read that could be done but can not find the forum, I have been hours looking for it. We will have to wait for a programmer in lua. I check the PDF document but i do not understand lua and I can not find a way to make the script. Somewhere I read that could be done but can not find the forum, I have been hours looking for it. We will have to wait for a programmer in lua. EDIT ---> Maybe this is what you say? Examples: mist.flagFunc.units_in_polygon{ units = {'[blue][vehicle]'}, zone = mist.getGroupPoints('forest1'), flag = 11 } --[[Once run, this function will start a process that will set flag 11 true when any blue vehicles are within the polygon shape created by the waypoints of the group named "forest1"]] mist.flagFunc.units_in_polygon{ units = {'[red][plane]'}, zone = { [1] = mist.DBs.unitsByName['AO 1'].point, [2] = mist.DBs.unitsByName['AO 2'].point, [3] = mist.DBs.unitsByName['AO 3'].point, [4] = mist.DBs.unitsByName['AO 4'].point, [5] = mist.DBs.unitsByName['AO 5'].point, [6] = mist.DBs.unitsByName['AO 6'].point, }, flag = 201, maxalt = 6000, interval = 30 } --[[Once run, this function will start a process that will set flag 201 true when any red planes are within the polygon shape derived by the intial starting positions of the units named "AO 1" through "AO 6" and are less than 6000 meters above sea level. This process will run once every 30 seconds.]] Edited October 12, 2016 by GaSi
mwd2 Posted October 12, 2016 Posted October 12, 2016 You place a unit (give it a name) on the map and add WPs (Waypoints) to a close polygon (your trigger zone). mist.flagFunc.units_in_polygon{ units={'[blue][plane]'}, --unit names zone=mist.getGroupPoints('inf1WP'), flag=101, interval=20, } every 20sec. the zone will check if a blue aircraft is in the zone, which the WPs of unit inf1WP define; if it found a blue aircraft, it set Flag 101 true. Playing: DCS World Intel i7-13700KF, 64GB DDR5 @5600MHz, RTX 4080 ZOTAC Trinity, WIN 11 64Bit Prof. Squadron "Serious Uglies" / Discord-Server: https://discord.gg/2WccwBh Ghost0815
GaSi Posted October 13, 2016 Author Posted October 13, 2016 Thanks !!! Thats perfect!!! I tested and work good!!! Thanks again :)
ESAc_matador Posted October 13, 2016 Posted October 13, 2016 What about, making a trigger zone. Would be interesting a function, mist.teleporttopolyzone(groupteleported, groupdefiningzone)
SnowTiger Posted October 17, 2016 Posted October 17, 2016 The ability to create polygon areas (not just radii / circles) is something that would be a great addition to the ME. I was once hoping to create a zone that was basically "L" shaped that encompassed a specific area within a town/city. Obviously, I discovered one of the many shortfalls of the ME. There is a ton that you can do, but one must find many work-arounds to achieve really creative missions IMO. But I stopped learning before I even got started, simply because Updates kept making missions no longer work. So the ME is useless to me at the moment until it's perfected and finished. SnowTiger AMD Ryzen 9 7950X - Zen 4 16-Core 4.5 GHz - Socket AM5 - 170W Desktop Processor ASUS ROG STRIX X670E-A GAMING WIFI 6E Socket AM5 (LGA 1718) Ryzen 7000 gaming motherboard Geforce RTX 4090 Gaming Trio X - 24GB GDDR6X + META Quest 3 + Controllers + Warthog Throttle, CH Pro Pedals, VKB Gunfighter MKII MCG Pro G.SKILL Trident Z5 Neo Series 64 GB RAM (2 x 32GB) 288-Pin PC RAM DDR5 6000 RAM
BaD CrC Posted October 18, 2016 Posted October 18, 2016 But I stopped learning before I even got started, simply because Updates kept making missions no longer work. So the ME is useless to me at the moment until it's perfected and finished. Well, you then can just permanently give up on ME as it will never ever be perfect and finished. Patches have been breaking previous missions for a decade. It's always been like this. I even learned to never schedule a mission on Friday night as I know the friday update will screw up the mission I am working on the previous week. I don't say it is normal. It's just the way it is. But since I want to fly on DCS aircraft and enjoy it with my squad mates, there is no choice. If we were all waiting for the ME to be perfect, that would be the end of DCS. https://www.blacksharkden.com http://discord.gg/blacksharkden
SnowTiger Posted October 24, 2016 Posted October 24, 2016 Well, you then can just permanently give up on ME as it will never ever be perfect and finished. Patches have been breaking previous missions for a decade. It's always been like this. Excellent Answer. Very reassuring. A positive selling point. At least you sold me. I have already given up on ME amongst other things. SnowTiger AMD Ryzen 9 7950X - Zen 4 16-Core 4.5 GHz - Socket AM5 - 170W Desktop Processor ASUS ROG STRIX X670E-A GAMING WIFI 6E Socket AM5 (LGA 1718) Ryzen 7000 gaming motherboard Geforce RTX 4090 Gaming Trio X - 24GB GDDR6X + META Quest 3 + Controllers + Warthog Throttle, CH Pro Pedals, VKB Gunfighter MKII MCG Pro G.SKILL Trident Z5 Neo Series 64 GB RAM (2 x 32GB) 288-Pin PC RAM DDR5 6000 RAM
ESAc_matador Posted October 24, 2016 Posted October 24, 2016 Actually, this is simply not true. For me, all missions that work, stay working for ages... Only few things are or have been broken.
Veteran66 Posted February 1, 2017 Posted February 1, 2017 Hi all I try to get work the "polygon trigger zone" but it will not work for me. Please, can you upload a sample mission and the Lua-script? German WW2 Radio calls Mod: https://www.digitalcombatsimulator.com/en/files/2161798/
ENO Posted February 3, 2017 Posted February 3, 2017 I thought there was a way to create a zone based on the route of a late activated object... I'm not trying to create a zone to detect a unit entering- I'm just trying to establish a zone that a unit can be randomly spawned within. "ENO" Type in anger and you will make the greatest post you will ever regret. "Sweetest's" Military Aviation Art
Grimes Posted February 3, 2017 Posted February 3, 2017 I thought there was a way to create a zone based on the route of a late activated object... I'm not trying to create a zone to detect a unit entering- I'm just trying to establish a zone that a unit can be randomly spawned within. mist.getGroupPoints Spawning in a poly is a little more difficult than a circle, but it is fairly straight forward. Actually have an example on hand because I used this for a Viggen mission I made. local avg = mist.getAvgPoint(coords) local radius = 0 for i = 1, #coords do if mist.utils.get2DDist(avg, coords[i]) > radius then radius = mist.utils.get2DDist(avg, coords[i]) end end local lSpawnPos = {} for j = 1, 100 do lSpawnPos = mist.getRandPointInCircle(avg, radius) if mist.pointInPolygon(lSpawnPos, coords) then break end end coords is a table of points used to define the polygon. It is getting the average position (center) of all of the coordinates and then checks the distance between each coordinate and the center to figure out the total radius. Imagine you drew a shape and then made a perfect circle from the center to encompass the entire shape. If it is a rather complex shape then chances are only 1 point will ever touch the circle. I use the center position and the radius to generate a random point within and then check if that point is within the polygon. I run it on a for, j = 100 do loop so that it has 100 chances to return a point within the zone. You could also generate a random number based on the x and y min/max bounds of the polygon. 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
sunski34 Posted February 4, 2017 Posted February 4, 2017 (edited) A peace of lua code.... local function isInPolygon(_P, _vertex) local point = _P local isOnVertex = false for i = 1, #_vertex do if _vertex[i].x == point.x and _vertex[i].z == point.z then isOnVertex = true end end if isOnVertex == false then local inside = 0 for i = 1, #_vertex - 1 do if _vertex[i].y <= point.y then if _vertex[i + 1].y > point.y and whichSide(_vertex[i], _vertex[i+1], point) < 0 then inside = inside + 1 end elseif _vertex[i + 1].y <= point.y and whichSide(_vertex[i], _vertex[i+1], point) > 0 then inside = inside - 1 end end -- if inside == 0 then point outside polygon -- if inside ~= 0 then point inside polygon -- No efficient for crossed polygon return inside ~= 0 else return true end end whichSide(A,B,P) is a basic function to find the position of a point P relative to an oriented segment AB : det =(B.x - A.x) * (P.z - A.z) - (B.z - A.z) * (P.x - A.x) det < 0 if P on left and det > 0 if P on right That is the code I will include in my ATME script Tools in next version ;) The biggest problem is to spawn in such a polygon... Code is near good too ;) Sunski Edited February 4, 2017 by sunski34
Recommended Posts