Jump to content

BDU bomb practicing with MIST2.0


SNAFU

Recommended Posts

  • 1 month later...

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

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

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

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 by SNAFU
  • Like 1

[sIGPIC][/sIGPIC]

 

Unsere Facebook-Seite

Link to comment
Share on other sites

  • 1 month later...

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

  • 2 weeks later...

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

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"...

  • Like 1

[sIGPIC][/sIGPIC]

 

Unsere Facebook-Seite

Link to comment
Share on other sites

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

  • 1 year later...

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

  • 1 month later...

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

  • 4 weeks later...

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 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

  • 3 months later...
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

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 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

  • Recently Browsing   0 members

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