galevsky06 Posted July 22, 2013 Share Posted July 22, 2013 No MP, everybody should be interested in that topic :) I think that I got it ! Coroutines are the solution. I will do the implementation with it soon. Link to comment Share on other sites More sharing options...
Leto Posted September 9, 2013 Share Posted September 9, 2013 Great stuff here! :thumbup: Unfortunatelly, my .lua skills peak in "copy&paste" but I got your scripts working and adapted them a little bit. Now I am trying to get 2 shooting ranges at the same time to work. Let's call them range BLUE and range RED. I used SNAFU's excellent BDUIndicatorZone.lua script and thought I can assign range BLUE the "target" zone from the original script (works) and by creating a second script (BDUIndicatorZone-B.lua) where I assign a "target-B" zone to range RED that these zones can work in parallel. But that doesn't work. Only 1 range (I think it's the one which got loaded at last) works. For the other target area I get the read out for the active zone (99999999m off). Is it possible to have two or more ranges active at the same time? How? [sIGPIC][/sIGPIC] Ariescon.com Intel i7-6700K | 32GB RAM | NVIDIA GTX 1080 | 1TB m.2 SSD | TM Warthog | Logitech G-35 | TrackIR 5 | Windows 10 Ultimate 64bit | 3 monitor setup @5760x1080 | Occulus Rift Link to comment Share on other sites More sharing options...
SNAFU Posted September 9, 2013 Author Share Posted September 9, 2013 Well, that is a little bit more tricky. How should the programm know, which target you intent to hit? So you have to modify the script in a way, that the script compares the coordinates of where the bomb hit, with the closest targetzone around, assuming you wanted to hit that one. ;) I used a similar function my AFAC script to detect the closest unit to the smokemarker, will see if I can easily implement that function in this script, when I have time. [sIGPIC][/sIGPIC] Unsere Facebook-Seite Link to comment Share on other sites More sharing options...
Laud Posted September 9, 2013 Share Posted September 9, 2013 That would be really awesome! TY! [sIGPIC][/sIGPIC] Asus ROG STRIX Z390-F Gaming, Intel Core i7 9700k , 32gb Corsair DDR4-3200 Asus RTX 2070 super, Samsung 970 EVO Plus M2, Win10 64bit, Acer XZ321QU (WQHD) TM HOTAS Warthog, SAITEK Rudder Pedals, TIR 5 Link to comment Share on other sites More sharing options...
SNAFU Posted September 10, 2013 Author Share Posted September 10, 2013 (edited) Here you have script, which now marks zones with the names "target1", "target2", "target3"... with green smoke and prints out which player dropped his BDU HD/LD training bomb how far off, in relation to the direction the player dropped his bomb. It is mandatory to name the triggerzones accordingly and to initiate MIST prior to the script. If you have more than 3 targetzones, you have to edit a line in the script: numberofzones = (integer of the number of zones you want to use) Attached you find the script and the example mission.BDUTrainingOnMultipleTargetZones_v1.rar Edited September 10, 2013 by SNAFU 1 [sIGPIC][/sIGPIC] Unsere Facebook-Seite Link to comment Share on other sites More sharing options...
Leto Posted September 11, 2013 Share Posted September 11, 2013 Thanks a lot SNAFU, will try it tomorrow Much appreciated:thumbup: [sIGPIC][/sIGPIC] Ariescon.com Intel i7-6700K | 32GB RAM | NVIDIA GTX 1080 | 1TB m.2 SSD | TM Warthog | Logitech G-35 | TrackIR 5 | Windows 10 Ultimate 64bit | 3 monitor setup @5760x1080 | Occulus Rift Link to comment Share on other sites More sharing options...
Midnight Posted October 25, 2013 Share Posted October 25, 2013 Hey SNAFU, do you know of a list of other weapons that could be used in your script? I tried using the exact names stated in SLMOD event viewer for other weapons with no or little success. Cheers Mid Link to comment Share on other sites More sharing options...
SNAFU Posted October 25, 2013 Author Share Posted October 25, 2013 In you folder DCS World\Config\Weapons you can find some table-files. You can open this files with the notepad and look for weapon names. You then just have to find the right name of the weapon you are looking for and add this weapon to the line if (_ordnanceName == "weapons.bombs.BDU_50HD" or _ordnanceName == "weapons.bombs.BDU_50LD") with the right type and name or _ordnanceName == "weapons.type.name" The smoke WP rockets are used in the AFAC script the same way. [sIGPIC][/sIGPIC] Unsere Facebook-Seite Link to comment Share on other sites More sharing options...
johnv2pt0 Posted November 4, 2013 Share Posted November 4, 2013 Can someone help me here? I'm trying to use your script SNAFU, and it's working however I can only get 1 of my 3 zones/targets to give correct feedback. As it is "Rocket" reads correct, but "Dumb" and "LGB" read 70km off! Any help is appreciated. target = 'DUMB-' -- targetzone name function SignalTarget() Aimpoint = trigger.misc.getZone(target) Aimpointpos = {} Aimpointposx = Aimpoint.point.x Aimpointposz = Aimpoint.point.z Aimpointposy = land.getHeight({x = Aimpoint.point.x, y = Aimpoint.point.z}) Aimpt3 = {x=Aimpointposx, y=Aimpointposy, z=Aimpointposz} trigger.action.smoke({x=Aimpointposx, y=Aimpointposy, z=Aimpointposz}, trigger.smokeColor.Red, 0) return timer.getTime() + 5 end timer.scheduleFunction(SignalTarget, nil, timer.getTime() + 1) DummybombHandler = {} function DummybombHandler:onEvent(event) if event.id == world.event.S_EVENT_SHOT then BombInit = event.initiator BombInitGroup = BombInit:getGroup() _alpha = mist.getHeading(BombInit) _ordnance = event.weapon _ordnanceName = _ordnance:getTypeName() if (_ordnanceName == "weapons.bombs.BDU_50HD" or _ordnanceName == "weapons.bombs.BDU_50LD" or _ordnanceName == "weapons.bombs.FAB_250" or _ordnanceName == "weapons.bombs.BetAB_500ShP" or _ordnanceName == "weapons.bombs.AN_M64") then function TrackBombDummy() local BombDummyPos = _ordnance:getPoint() local _time = timer.getTime(); if BombDummyPos.y < land.getHeight({x = BombDummyPos.x, y = BombDummyPos.z}) + 10 then local xOffset = (BombDummyPos.x - Aimpointposx)*3.28084 local zOffset = (BombDummyPos.z - Aimpointposz)*3.28084 local BombOffset = math.sqrt(xOffset * xOffset + zOffset * zOffset) local BombOffsetInt = math.floor(BombOffset) local _beta = math.atan2(zOffset,xOffset) local _gamma = _alpha - _beta local xOffsetRel = BombOffset * math.sin(_gamma*(-1)) local zOffsetRel = BombOffset * math.cos(_gamma) local xOffsetRelAbs = math.floor(math.abs(xOffsetRel)) local zOffsetRelAbs = math.floor(math.abs(zOffsetRel)) if (xOffsetRel > 0 and zOffsetRel > 0) then trigger.action.outText("DUMB BOMB: "..string.format(BombOffsetInt) .. "ft / Off right "..string.format(xOffsetRelAbs) .. "ft / Too long by "..string.format(zOffsetRelAbs).."ft", 10) elseif (xOffsetRel > 0 and zOffsetRel < 0) then trigger.action.outText("DUMB BOMB: "..string.format(BombOffsetInt) .. "ft / Off right "..string.format(xOffsetRelAbs) .. "ft / Too short by "..string.format(zOffsetRelAbs).."ft", 10) elseif (xOffsetRel < 0 and zOffsetRel > 0) then trigger.action.outText("DUMB BOMB: "..string.format(BombOffsetInt) .. "ft / Off left "..string.format(xOffsetRelAbs) .. "ft / Too long by "..string.format(zOffsetRelAbs).."ft", 10) elseif (xOffsetRel < 0 and zOffsetRel < 0) then trigger.action.outText("DUMB BOMB: "..string.format(BombOffsetInt) .. "ft / Off left "..string.format(xOffsetRelAbs) .. "ft / Too short by "..string.format(zOffsetRelAbs).."ft", 10) end return end return timer.getTime() + 0.01 end timer.scheduleFunction(TrackBombDummy, nil, timer.getTime() + 1) end --end end end world.addEventHandler(DummybombHandler) target2 = 'LGB-' -- targetzone name function SignalTarget() Aimpoint = trigger.misc.getZone(target2) Aimpointpos = {} Aimpointposx = Aimpoint.point.x Aimpointposz = Aimpoint.point.z Aimpointposy = land.getHeight({x = Aimpoint.point.x, y = Aimpoint.point.z}) Aimpt3 = {x=Aimpointposx, y=Aimpointposy, z=Aimpointposz} trigger.action.smoke({x=Aimpointposx, y=Aimpointposy, z=Aimpointposz}, trigger.smokeColor.Red, 0) return timer.getTime() + 5 end timer.scheduleFunction(SignalTarget, nil, timer.getTime() + 1) LGBHandler = {} function LGBHandler:onEvent(event) if event.id == world.event.S_EVENT_SHOT then LGBInit = event.initiator LGBInitGroup = LGBInit:getGroup() _alpha = mist.getHeading(LGBInit) _ordnance = event.weapon _ordnanceName = _ordnance:getTypeName() if (_ordnanceName == "weapons.bombs.BDU_50LGB" or _ordnanceName == "weapons.warheads.KAB_500Kr" or _ordnanceName == "weapons.warheads.KAB_500KrOD" or _ordnanceName == "weapons.bombs.GBU_38" ) then function TrackBombLGB() local BombLGBPos = _ordnance:getPoint() local _time = timer.getTime(); if BombLGBPos.y < land.getHeight({x = BombLGBPos.x, y = BombLGBPos.z}) + 10 then local xOffset = (BombLGBPos.x - Aimpointposx)*3.28084 local zOffset = (BombLGBPos.z - Aimpointposz)*3.28084 local BombOffset = math.sqrt(xOffset * xOffset + zOffset * zOffset) local BombOffsetInt = math.floor(BombOffset) local _beta = math.atan2(zOffset,xOffset) local _gamma = _alpha - _beta local xOffsetRel = BombOffset * math.sin(_gamma*(-1)) local zOffsetRel = BombOffset * math.cos(_gamma) local xOffsetRelAbs = math.floor(math.abs(xOffsetRel)) local zOffsetRelAbs = math.floor(math.abs(zOffsetRel)) if (xOffsetRel > 0 and zOffsetRel > 0) then trigger.action.outText("LGB: "..string.format(BombOffsetInt) .. "ft / Off right "..string.format(xOffsetRelAbs) .. "ft / Too long by "..string.format(zOffsetRelAbs).."ft", 10) elseif (xOffsetRel > 0 and zOffsetRel < 0) then trigger.action.outText("LGB: "..string.format(BombOffsetInt) .. "ft / Off right "..string.format(xOffsetRelAbs) .. "ft / Too short by "..string.format(zOffsetRelAbs).."ft", 10) elseif (xOffsetRel < 0 and zOffsetRel > 0) then trigger.action.outText("LGB: "..string.format(BombOffsetInt) .. "ft / Off left "..string.format(xOffsetRelAbs) .. "ft / Too long by "..string.format(zOffsetRelAbs).."ft", 10) elseif (xOffsetRel < 0 and zOffsetRel < 0) then trigger.action.outText("LGB: "..string.format(BombOffsetInt) .. "ft / Off left "..string.format(xOffsetRelAbs) .. "ft / Too short by "..string.format(zOffsetRelAbs).."ft", 10) end return end return timer.getTime() + 0.01 end timer.scheduleFunction(TrackBombLGB, nil, timer.getTime() + 1) end --end end end world.addEventHandler(LGBHandler) target3 = 'ROCKET-' -- targetzone name function SignalTarget() Aimpoint = trigger.misc.getZone(target3) Aimpointpos = {} Aimpointposx = Aimpoint.point.x Aimpointposz = Aimpoint.point.z Aimpointposy = land.getHeight({x = Aimpoint.point.x, y = Aimpoint.point.z}) Aimpt3 = {x=Aimpointposx, y=Aimpointposy, z=Aimpointposz} trigger.action.smoke({x=Aimpointposx, y=Aimpointposy, z=Aimpointposz}, trigger.smokeColor.Red, 0) return timer.getTime() + 5 end timer.scheduleFunction(SignalTarget, nil, timer.getTime() + 1) ROCKETHandler = {} function ROCKETHandler:onEvent(event) if event.id == world.event.S_EVENT_SHOT then RocketInit = event.initiator RocketInitGroup = RocketInit:getGroup() _alpha = mist.getHeading(RocketInit) _ordnance = event.weapon _ordnanceName = _ordnance:getTypeName() if (_ordnanceName == "weapons.nurs.HYDRA_70_M156" or _ordnanceName == "weapons.nurs.HYDRA_70WP" or _ordnanceName == "weapons.nurs.HYDRA_70_MK1" or _ordnanceName == "weapons.nurs.HYDRA_70_MK5" or _ordnanceName == "weapons.nurs.HYDRA_70_MK61" or _ordnanceName == "weapons.nurs.HYDRA_70_M151" or _ordnanceName == "weapons.nurs.HYDRA_70_WTU1B" or _ordnanceName == "weapons.nurs.HYDRA_70_M274" or _ordnanceName == "weapons.nurs.HYDRA_70_M257" or _ordnanceName == "weapons.nurs.C_8" or _ordnanceName == "weapons.nurs.C_8OM" or _ordnanceName == "weapons.nurs.C_8CM" or _ordnanceName == "weapons.nurs.C_8OFP2" or _ordnanceName == "weapons.nurs.HVAR") then function TrackBombRocket() local BombRocketPos = _ordnance:getPoint() local _time = timer.getTime(); if BombRocketPos.y < land.getHeight({x = BombRocketPos.x, y = BombRocketPos.z}) + 10 then local xOffset = (BombRocketPos.x - Aimpointposx)*3.28084 local zOffset = (BombRocketPos.z - Aimpointposz)*3.28084 local BombOffset = math.sqrt(xOffset * xOffset + zOffset * zOffset) local BombOffsetInt = math.floor(BombOffset) local _beta = math.atan2(zOffset,xOffset) local _gamma = _alpha - _beta local xOffsetRel = BombOffset * math.sin(_gamma*(-1)) local zOffsetRel = BombOffset * math.cos(_gamma) local xOffsetRelAbs = math.floor(math.abs(xOffsetRel)) local zOffsetRelAbs = math.floor(math.abs(zOffsetRel)) if (xOffsetRel > 0 and zOffsetRel > 0) then trigger.action.outText("ROCKET: "..string.format(BombOffsetInt) .. "ft / Off right "..string.format(xOffsetRelAbs) .. "ft / Too long by "..string.format(zOffsetRelAbs).."ft", 10) elseif (xOffsetRel > 0 and zOffsetRel < 0) then trigger.action.outText("ROCKET: "..string.format(BombOffsetInt) .. "ft / Off right "..string.format(xOffsetRelAbs) .. "ft / Too short by "..string.format(zOffsetRelAbs).."ft", 10) elseif (xOffsetRel < 0 and zOffsetRel > 0) then trigger.action.outText("ROCKET: "..string.format(BombOffsetInt) .. "ft / Off left "..string.format(xOffsetRelAbs) .. "ft / Too long by "..string.format(zOffsetRelAbs).."ft", 10) elseif (xOffsetRel < 0 and zOffsetRel < 0) then trigger.action.outText("ROCKET: "..string.format(BombOffsetInt) .. "ft / Off left "..string.format(xOffsetRelAbs) .. "ft / Too short by "..string.format(zOffsetRelAbs).."ft", 10) end return end return timer.getTime() + 0.01 end timer.scheduleFunction(TrackBombRocket, nil, timer.getTime() + 1) end --end end end world.addEventHandler(ROCKETHandler) Link to comment Share on other sites More sharing options...
SNAFU Posted November 4, 2013 Author Share Posted November 4, 2013 It appears to me, that you use the variables Aimpoint of function function SignalTarget() Aimpoint = trigger.misc.getZone(target2) Aimpointpos = {} Aimpointposx = Aimpoint.point.x Aimpointposz = Aimpoint.point.z Aimpointposy = land.getHeight({x = Aimpoint.point.x, y = Aimpoint.point.z}) Aimpt3 = {x=Aimpointposx, y=Aimpointposy, z=Aimpointposz} trigger.action.smoke({x=Aimpointposx, y=Aimpointposy, z=Aimpointposz}, trigger.smokeColor.Red, 0) return timer.getTime() + 5 end for all other functions. Try to indiviualize the Aimpoint variables the same way you did with target, f.e. rename SignalTarget function and its Aimpoint with all its variables Aimpointx etc. Do this also in the Eventhaendler funcitons for every target area and try again. You might also just use the variation I posted in this post and modify the _ordnanceName == line again, as in your script. This variation compares the impact of the weapon with the position of the closest triggerzone with the name starting with "target", for example "target1", "target2", "target3"... 1 [sIGPIC][/sIGPIC] Unsere Facebook-Seite Link to comment Share on other sites More sharing options...
Cougar Posted November 4, 2013 Share Posted November 4, 2013 Im no expert in lua but maybe putting local in front of aimpoint variables would fix the scope of the variable to the function only? Link to comment Share on other sites More sharing options...
johnv2pt0 Posted November 4, 2013 Share Posted November 4, 2013 It appears to me, that you use the variables Aimpoint of function function SignalTarget() Aimpoint = trigger.misc.getZone(target2) Aimpointpos = {} Aimpointposx = Aimpoint.point.x Aimpointposz = Aimpoint.point.z Aimpointposy = land.getHeight({x = Aimpoint.point.x, y = Aimpoint.point.z}) Aimpt3 = {x=Aimpointposx, y=Aimpointposy, z=Aimpointposz} trigger.action.smoke({x=Aimpointposx, y=Aimpointposy, z=Aimpointposz}, trigger.smokeColor.Red, 0) return timer.getTime() + 5 end for all other functions. Try to indiviualize the Aimpoint variables the same way you did with target, f.e. rename SignalTarget function and its Aimpoint with all its variables Aimpointx etc. Do this also in the Eventhaendler funcitons for every target area and try again. You might also just use the variation I posted in this post and modify the _ordnanceName == line again, as in your script. This variation compares the impact of the weapon with the position of the closest triggerzone with the name starting with "target", for example "target1", "target2", "target3"... Ok thanks, I'll check it out tonight EDIT: Works great and is much better than what I was trying to do. Thanks again...rep inbound Link to comment Share on other sites More sharing options...
TwoLate Posted February 18, 2015 Share Posted February 18, 2015 On post 55 an example mission and Lua file is posted. When I go into the mission it says luaV4 but the posted is version 1. I am tying to do a target range for my squad to practice bombing and rockets with a P_51. I cant get the F10 menu to get the results of how close. Looking inside the LUA looks like the message is not setup. Anybody have a target range mission like this. I am trying to learn this LUA but it is difficult for me. Trying to learn by example. [sIGPIC][/sIGPIC] Link to comment Share on other sites More sharing options...
TwoLate Posted February 20, 2015 Share Posted February 20, 2015 Never mind I figured it out. [sIGPIC][/sIGPIC] Link to comment Share on other sites More sharing options...
baltic_dragon Posted April 9, 2015 Share Posted April 9, 2015 Does this script with the newest version of DCS and mist 3.3? I am desperately looking for something like this as I can't get the "bomb in zone" triggers to work properly..l Link to comment Share on other sites More sharing options...
SNAFU Posted April 16, 2015 Author Share Posted April 16, 2015 AFIAK DCS scripting environment is currently bugged and the EVENT for a bomb release is not registered by the game in the scripting engine. So this script does not work anymore, at the moment. Nothing we can do. [sIGPIC][/sIGPIC] Unsere Facebook-Seite Link to comment Share on other sites More sharing options...
baltic_dragon Posted May 8, 2015 Share Posted May 8, 2015 Any news on this after recent updates? Link to comment Share on other sites More sharing options...
SNAFU Posted May 8, 2015 Author Share Posted May 8, 2015 As far as I know, the bug in the scripting environment is still present. Maybe Grimes knows, if it is fixed internally. [sIGPIC][/sIGPIC] Unsere Facebook-Seite Link to comment Share on other sites More sharing options...
Grimes Posted May 9, 2015 Share Posted May 9, 2015 It is fixed internally, just hasn't been merged into a patch for public release. I'll ask again if it can be merged. 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 Link to comment Share on other sites More sharing options...
nuts Posted May 9, 2015 Share Posted May 9, 2015 Has anyone made any target ranges we can use in dcs? Link to comment Share on other sites More sharing options...
mwd2 Posted May 9, 2015 Share Posted May 9, 2015 Has anyone made any target ranges we can use in dcs? http://forums.eagle.ru/showthread.php?t=115228 Playing: F-16C Intel i7-13700KF, 64GB DDR5 @5600MHz, RTX 4080 ZOTAC Trinity, WIN 11 64Bit Prof. Squadron "Serious Uglies" / Discord-Server: https://discord.gg/2WccwBh Ghost0815 Link to comment Share on other sites More sharing options...
nuts Posted May 9, 2015 Share Posted May 9, 2015 Thanks, awesome sauce Link to comment Share on other sites More sharing options...
SNAFU Posted September 4, 2015 Author Share Posted September 4, 2015 It is fixed internally, just hasn't been merged into a patch for public release. I'll ask again if it can be merged. Hey Grimes, do you know, if it is planned to return this "event" into the scripting engine? Just checked yesterday with the latest DCS version, still no joy. [sIGPIC][/sIGPIC] Unsere Facebook-Seite Link to comment Share on other sites More sharing options...
Grimes Posted September 4, 2015 Share Posted September 4, 2015 The last time I checked on the tester build it was fixed and I was never notified that they actually merged the fix into 1.2.16. So hopefully the fix will be in 1.5, and I'll keep an eye out for it. 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 Link to comment Share on other sites More sharing options...
SNAFU Posted September 6, 2015 Author Share Posted September 6, 2015 Thank you. Really appreciated. [sIGPIC][/sIGPIC] Unsere Facebook-Seite Link to comment Share on other sites More sharing options...
Recommended Posts