Jump to content

BDU bomb practicing with MIST2.0


Recommended Posts

I wrote a little script for practicing with BDU-50LD/HD bombs. This script indicates the BDU hit in relation to you attack path and the target, therefore it prints out:

 

-total off in m

-how far short or long in m

-how far to left or right in m

 

The target unit to drop your BDUs on is marked with a green flare every 5 seconds. After one drop the next unit with the name "target(n)" (n=1,2,..) will be marked with flares

 

But you need MIST2.0 and have to place units in the ME with the names "target1", "target2"...

 

I found it helpfull in practicing bomb deliveries, so someone might agree. ;)

 

Ah, btw works also with WP rockets.

 

PS: The second file with the name BDUIndicatorMultipleZones_v1.lua uses triggerzones as target and prints out the weapon impact in relation to the closest triggerzone with the name "target1", "target2",...

BDUIndicatorMultipleTargets.lua

BDUIndicatorMultipleZones_v1.lua


Edited by SNAFU

[sIGPIC][/sIGPIC]

 

Unsere Facebook-Seite

Link to comment
Share on other sites

Hi Midnight,

 

I took a look at your miz and rearranged the trigger slightly to the way I am used to.

 

For the BDU targets: They need to be units and have the unitname "target1","target2" etc, not static. ;)

But I also made one version, in which the aimpoint is a zone center, might be better for your puropose. You just place the zone with the name "target" over the static position and voila. I attached the script below, that might suite your purpose better.

 

To the random traffic:

Airfield Lochini is named Tbilisi-Lochini, that was the bug. Thought is was otherwise, but good to know. ;)

 

I attached the modified miz below, so you can see what I mean.

BDUIndicatorZone.lua

Tbilisi ILS Training - MP1 Day_snafumod.miz

[sIGPIC][/sIGPIC]

 

Unsere Facebook-Seite

Link to comment
Share on other sites

  • 2 weeks later...

I need some help here please, this script is not working the way I want it to.

 

I want to set up 4 target zones:

 

targetrange = {'target1', 'target2', 'target3', 'target4'} -- targetzone name

 

that must activate when a player enters that zone, say zone is 5 miles.

 

Script below:

 

targetrange = {'target1', 'target2', 'target3', 'target4'} -- targetzone name

function SignalTarget()
       Aimpoint = trigger.misc.getZone(targetrange)
       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.Green, 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") 
           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
                       local zOffset = BombDummyPos.z - Aimpointposz
                       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("Distance off: "..string.format(BombOffsetInt) .. "m / Off right "..string.format(xOffsetRelAbs) .. "m / Too long by "..string.format(zOffsetRelAbs).."m", 10)
                           elseif (xOffsetRel > 0 and zOffsetRel < 0)
                           then
                               trigger.action.outText("Distance off: "..string.format(BombOffsetInt) .. "m / Off right "..string.format(xOffsetRelAbs) .. "m / Too short by "..string.format(zOffsetRelAbs).."m", 10)
                           elseif (xOffsetRel < 0 and zOffsetRel > 0)
                           then
                               trigger.action.outText("Distance off: "..string.format(BombOffsetInt) .. "m / Off left "..string.format(xOffsetRelAbs) .. "m / Too long by "..string.format(zOffsetRelAbs).."m", 10)
                           elseif (xOffsetRel < 0 and zOffsetRel < 0)
                           then
                               trigger.action.outText("Distance off: "..string.format(BombOffsetInt) .. "m / Off left "..string.format(xOffsetRelAbs) .. "m / Too short by "..string.format(zOffsetRelAbs).."m", 10)
                           end    

                       return
                   end
                   return timer.getTime() + 0.01                    
               end
               timer.scheduleFunction(TrackBombDummy, nil, timer.getTime() + 1)
           end
       --end
   end
end
world.addEventHandler(DummybombHandler)

 

I tried many different options without result. At most I can get only one zone active(target1)

Midnite Signature.jpg

552334314_MidniteSignature.jpg.7c1678ea5639bd6d044b092eb97c300e.jpg

Link to comment
Share on other sites

May I suggest to create into the ME some triggers 'In Zone' that execute lua like 'ActiveTarget = target1' for first zone, 'ActiveTarget = target2' for second an so on...

 

Then, remove the

 

                       ActiveTarget = ActiveTarget + 1
                       if (ActiveTarget > nrTargets)
                           then
                           ActiveTarget = 1
                       end

that switches to the next target after the ordnance impact on the previous active target in the original script.

 

For me, I don't want the trainee to respect some order to engage the targets, so taht I am building a training area with long-distance separated objectives, and the active target is computed while the ordnance impacts the ground (I get the closest target position).


Edited by galevsky06
Link to comment
Share on other sites

I forgot: don't schedule the signalTarget function until there is an active target !

 

Add a function in your lua:

function activateTarget(id)
   if (activeTarget == nil) then
       activeTarget = "target"..id
       timer.scheduleFunction(SignalTarget, nil, timer.getTime() + 1)
   else
        activateTarget = "target"..id
   end
end

And lua code for InZone triggers becomes:

 

activateTarget("X"); -- X in {1,2,3,4} according to the zone

Link to comment
Share on other sites

I forgot: don't schedule the signalTarget function until there is an active target !

 

Add a function in your lua:

function activateTarget(id)
   if (activeTarget == nil) then
       activeTarget = "target"..id
       timer.scheduleFunction(SignalTarget, nil, timer.getTime() + 1)
   else
        activateTarget = "target"..id
   end
end

And lua code for InZone triggers becomes:

 

activateTarget("X"); -- X in {1,2,3,4} according to the zone

 

 

You saved the day...thank m8

Midnite Signature.jpg

552334314_MidniteSignature.jpg.7c1678ea5639bd6d044b092eb97c300e.jpg

Link to comment
Share on other sites

Just one last hing, since I am going to use practice bombs, I surely need to deactivate target 1 before target 2 gets activated. If not the script will measure distance from the first target only.

 

There should be a condition though: if bomb hits inside a preset zone = 100meters, then only activate target 2.

 

any ideas?

Midnite Signature.jpg

552334314_MidniteSignature.jpg.7c1678ea5639bd6d044b092eb97c300e.jpg

Link to comment
Share on other sites

Just one last hing, since I am going to use practice bombs, I surely need to deactivate target 1 before target 2 gets activated. If not the script will measure distance from the first target only.

 

There should be a condition though: if bomb hits inside a preset zone = 100meters, then only activate target 2.

 

any ideas?

 

Ok,

 

First: we don't need to deactivate the previous target: the original SignalTarget function will just start flaring on the current target:

 

local Rangetarget = Unit.getByName('target'..string.format(ActiveTarget))

So it works fine with ActiveTarget content only. A better implementation for you could be:

 

function SignalTarget()
       local Rangetarget = Unit.getByName(ActiveTarget)
       if RangeTarget then -- <<<<<<< flare only if ActiveTarget is not nil
           Aimpointpos  = Rangetarget:getPosition().p
           Aimpointposx = Aimpointpos.x
           Aimpointposz = Aimpointpos.z
           Aimpointposy = land.getHeight({x = Aimpointposx, y = Aimpointposz})
           Aimpt3 = {x=Aimpointposx, y=Aimpointposy, z=Aimpointposz}
           trigger.action.signalFlare({x=Aimpointposx, y=Aimpointposy, z=Aimpointposz}, trigger.flareColor.Green, 0)
       end
   return timer.getTime() + 5
end
timer.scheduleFunction(SignalTarget, nil, timer.getTime() + 1)

Then, set the ActivateTarget to nil when unit destruction is caught for the unit named 'ActivateTarget'. And do simple

 
activateTarget = "targetX"

for InZone triggers.

 

Secondly, you can handle your ActivateTarget variable with impacts on the ground by looking for the closest unit. This is my solution. But you cannot do

SignalTarget because you will know who is your active target only when bombs hit the ground ! So you have to choose:

 

 

  • Want to flare on targets before bombs impact ? => InZone trigger looks fine, or fixed order as it was in the original script.
  • Doesn't mind about flaring, just want to display stats after impact ? Search for you target just before computing stats, inside TrackBombDummy. That implies that you have the full list of targets, and you loop on them to compute the distance to the impact...


Edited by galevsky06
Link to comment
Share on other sites

? Are you talking about BDUIndicatorMultipleTargets.lua script or something else ? Don't know what is "indicator zone lua"

 

Yes, the script attached to post #3.

 

I went and changed flare into smoke, but for some reason the smoke doesn't appear. I've no clue why. I know that the unedited version works fine.

 

EDIT. I figured it out. I had to delete the Return from the smoke/flare portion of the script. Smoke appears in place of the flares, now I need to test out the actual accuracy calling to see if it works properly


Edited by P*Funk

Warning: Nothing I say is automatically correct, even if I think it is.

Link to comment
Share on other sites

Well I was silly and shortsighted and forgot that if I don't have a Return for the smoke it'll dissipate rather quickly.

 

So, I'm going to play with it, but anybody have the hard numbers on how long smoke lasts?

Warning: Nothing I say is automatically correct, even if I think it is.

Link to comment
Share on other sites

The original script:

 

 

function SignalTarget()
	local Rangetarget = Unit.getByName('target'..string.format(ActiveTarget))
	Aimpointpos  = Rangetarget:getPosition().p
	Aimpointposx = Aimpointpos.x
	Aimpointposz = Aimpointpos.z
	Aimpointposy = land.getHeight({x = Aimpointposx, y = Aimpointposz})
	Aimpt3 = {x=Aimpointposx, y=Aimpointposy, z=Aimpointposz}
	trigger.action.signalFlare({x=Aimpointposx, y=Aimpointposy, z=Aimpointposz}, trigger.flareColor.Green, 0)
return [b]timer.getTime() + 5
[/b]end

 

Every 5s a new smoke is launched. I guess that SNAFU chose the right value...

Link to comment
Share on other sites

Well the original script pops signal flares every 5 seconds rather than smoke. I initially tried changing this to smoke once I found out what to input, but with the return timer it seems to stop the smoke appearing at all.

 

I just checked and a single smoke will last exactly 5 minutes, or 300 seconds. If I eliminate the Return command the smoke appears, but it dissipates. If I have the Return command it seems to prevent smoke from appearing, unlike with flares.

 

 

This works, but doesn't last.

 

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.Green, 0)

end

 

 

This seems to prevent the smoke from appearing, though the rest of the script functions correctly:

 

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.Green, 0)

return timer.getTime() + 5

end

 

 

Warning: Nothing I say is automatically correct, even if I think it is.

Link to comment
Share on other sites

Well the original script pops signal flares every 5 seconds rather than smoke.

Oups... my mistake :D

 

This seems to prevent the smoke from appearing, though the rest of the script functions correctly:

 

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.Green, 0)

return timer.getTime() + 5

end

 

 

 

Did you try 1min ? It seems to be an issue with already existing smoke, maybe not, but let's try with big time.... in case smoke still exists even if invisible.

Link to comment
Share on other sites

I figured it out. I was a bad boy and broke the cardinal rule: I changed more than 1 variable at a time.

 

I turned the smoke from Green to Red at the same time that I was fiddling with the Return timer, but I didn't capitalize the "r" and apparently if you don't capitalize the colour it doesn't render the smoke.

 

It works fine. This functions to turn the flare into smoke and refreshes the smoke after 4 minutes. The reason I'm using 4 minutes is because around 4 minutes into the life of a smoke plume it starts to thin out considerably and the final 15 seconds or so its basically a whisp. This way the new smoke starts right when the old one starts thinning.

 

 

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() + 240

end

 

 

Now, I'm not sure if making the Return timer operate every 5 seconds or something similar would lead to an endless supply of new smoke that would slow the machine down or if it just replaces the old one. Either way there's no need to Return the smoke that often. 4 minutes should do just fine, and if it does create a second plume on top of the first, this way it'll dissipate back to 1 plume within 60 seconds so you won't get so many individual smoke plumes that you get lag after a while.

Warning: Nothing I say is automatically correct, even if I think it is.

Link to comment
Share on other sites

Now, I'm not sure if making the Return timer operate every 5 seconds or something similar would lead to an endless supply of new smoke that would slow the machine down or if it just replaces the old one. Either way there's no need to Return the smoke that often. 4 minutes should do just fine, and if it does create a second plume on top of the first, this way it'll dissipate back to 1 plume within 60 seconds so you won't get so many individual smoke plumes that you get lag after a while.

 

Good News ! No bug here :smoke:

 

Smoke has no ID => normaly, you can smoke it as many times as you want, just slowing down the framerate. As we do as JTAC for fun :P

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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