Jump to content

Bomb release event


lanmancz

Recommended Posts

Hello,

I'm trying to create a simple script that would show me how close my Mk82 landed to a dummy target unit. I'm using a S_EVENT_SHOT even handler to get the bomb and then check and report it's distance on screen. This works fine for maverick for example but for some reason a Mk82 release does not trigger this event. Do you please have any tip how to rewrite this to make it work for Mk82 as well ? I didn't notice any other event triggered by the weapon release. Is there please perhaps a different method to get the landing distance ?

 

local StaticTargetName = "DUMMY"
local BombRangeHandler = {}
function BombRangeHandler:onEvent(event)
   if event.id == world.event.S_EVENT_SHOT then
       local _ordnance = event.weapon
       local _initiator = event.initiator
       local _initname = _initiator:getName()
       local _ordnanceName = _ordnance:getTypeName()
       --trigger.action.outText("Name:".._ordnanceName, 2)
       --if _ordnanceName == "Mk82?" then
           local TrackShot = {}
           function TrackShot()
               local _shotPos = _ordnance:getPoint()
               local _staticTarget = Unit.getByName(StaticTargetName)
               local _staticTargetPos = _staticTarget:getPoint()
               local _distance = math.floor(math.sqrt(math.pow((_shotPos.x - _staticTargetPos.x), 2) + math.pow((_shotPos.y - _staticTargetPos.y), 2) + math.pow((_shotPos.z - _staticTargetPos.z), 2)))
               
               if _distance < 50 then
                   local _text = "Name: ".._initname.." Ordnance: ".._ordnanceName.." Distance: ".._distance
                   trigger.action.outText(_text, 10)
               end
               if _ordnance:isExist() == true then
                   return timer.getTime() + 0.005
               end
           end
           timer.scheduleFunction(TrackShot, nil, timer.getTime() + 1)            
       --end
   end
end

world.addEventHandler(BombRangeHandler)

edit: OK so this ^^ works fine at the moment for ordnance that triggers the ON_SHOT trigger. Once the bug that Grimes mentioned is fixed it will work for the Mk82 as well. If someone wants to use this just put a unit named 'DUMMY' (group name does not matter) on a map and run this on mission start.


Edited by lanmancz

[sIGPIC][/sIGPIC]

 

Gigabyte Aorus Z390 Elite, Intel i9 9900K, Fractal Design Kelvin S36, Zotac GTX 1070 8GB AMP Extreme, 32GB DDR4 HyperX CL15 Predator Series @ 3000 MHz, Kingston SSD 240GB (OS), Samsung 970 EVO 1TB M.2 NVMe (sim), Fractal Design Define R5 Black Window, EVGA SuperNOVA 750 G2, Win 10 Home x64, Thrustmaster Warthog HOTAS, Saitek Pro Flight Rudder Pedals, Thrustmaster MFD Cougar Pack, TrackIR (DelanClip), 3x 27" BenQ EW2740L, Oculus Rift S

 

Link to comment
Share on other sites

I don't have an answer for you, but I was planning to write a script that would do the exact same thing so I'm very much interested in the answer as well!

 

If I play around and find a solution, I'll be sure to get back, but if we get lucky, maybe some of the wizards around here can point us in the right direction. :thumbup:

Link to comment
Share on other sites

Its a bug that was reported in the wrong forum. http://forums.eagle.ru/showthread.php?p=2368086

 

Its fixed internally but still needs to be merged to the 1.2.16 open beta patch.

The right man in the wrong place makes all the difference in the world.

Current Projects:  Grayflag ServerScripting 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

Ah, okay. Thanks.

[sIGPIC][/sIGPIC]

 

Gigabyte Aorus Z390 Elite, Intel i9 9900K, Fractal Design Kelvin S36, Zotac GTX 1070 8GB AMP Extreme, 32GB DDR4 HyperX CL15 Predator Series @ 3000 MHz, Kingston SSD 240GB (OS), Samsung 970 EVO 1TB M.2 NVMe (sim), Fractal Design Define R5 Black Window, EVGA SuperNOVA 750 G2, Win 10 Home x64, Thrustmaster Warthog HOTAS, Saitek Pro Flight Rudder Pedals, Thrustmaster MFD Cougar Pack, TrackIR (DelanClip), 3x 27" BenQ EW2740L, Oculus Rift S

 

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...