Jump to content

Recommended Posts

MIL_BombRanges

 

This is technically a mission, but it's intended use is as a means to determine how far a bomb will travel, unguided, when dropped in level flight:

https://steamcommunity.com/sharedfiles/filedetails/?id=2373287174

 

The script is contained within the mission, so you will need to unpack it in order to adjust the options (there aren't many). In a nutshell, you open up the mission in the editor, select your aircraft and/or bomb, then edit a small section of the init.sqf to set the range of speeds and altitudes that will be recorded when dropping bombs. The script will automatically set speeds and altitudes for the player, meaning all you have to do is select your weapon after the mission starts and keep off the controls while the script runs. Further instructions and considerations are contained within the init.sqf.

 

For anyone interested, I already populated a spreadsheet (requires MS Excel or a PDF viewer) using bombs dropped from Firewill's F/A-18 Hornet: MIL_BombRanges (Dropbox)

Edit: bombs will generally fly further when guided, these ranges were based on unguided releases. 

 

For anyone further interested, below is the code I've used to do this. There'd be plenty of ways to do this, however it evolved as I continually streamlined the results to fit nicely into Excel, and I'm not an Excel guru. So it did it's fair share of evolving......

 

init.sqf

Spoiler

/*
///////
//USE:
///////

Set the range of speeds (km/h) and altitudes (m) to record, as well as the interval between each value:
[[[startingSpeed,finishingSpeed,interval],[startingAltitude,finishinAltitude,interval]]]

Multiple settings can be used. Example:
[
	[[300,1500,100],[250,1000,250]],	//Speeds from 300 to 1500 at every 100km/h, altitude from 250 to 1000 at every 250m
	[[300,1500,100],[2000,15000,1000]]	//Speeds from 300 to 1500 at every 100km/h, altitude from 2000 to 15000 at every 1000m
]
*/

/////////////////////////////////////////////////////////
//Edit below only////Edit below only////Edit below only//
/////////////////////////////////////////////////////////

if (false) exitWith {};	//debug only, generally leave as false

private _ranges = [
	[[300,1500,100],[50,100,50]]
];

/////////////////////////////////////////////////////////
//Edit above only////Edit above only////Edit above only//
/////////////////////////////////////////////////////////

/*
Add the weapon required to the aircraft, then run the mission.
You will have 5 seconds after starting the mission before the script runs.
YOU MUST select the weapon to be recorded before the script starts.
Avoid touching any controls during recording. I usually activate external view and free-look before the script runs.
Info about the process will be presented on-screen during the recording.

///////
//CONSIDERATIONS:
///////

- Some munitions require a larger sleep time after dropping for recording to work properly
	- Seems to be cluster bombs mainly
	- Change sleep to 1 second if needed (release.sqf, line 42-44)
- Cluster mine munitions deploy mines, and so FPS plummets if there's too many
	- {deleteVehicle _x} forEach allMines;
	- Run the above from debug console when FPS drops
	- Mines will be auto deleted anyway if FPS drops below 45
- "Real-world" testing indicates that:
	- without guidance, bombs will fall up to around 10% short of the recorded distance
	- with guidance, bombs can reach further than the recorded distance
	- at very low altitudes some munitions have slightly odd values
		- some munitions detonate almost immediately, like some CBUs

///////
//COPYING TO EXCEL:
///////

The array will be populated something like this:
["WeaponName",[-1],num,num,num,[-1],num,num,num,[-1],num,num,num,[-1],num,num,num,[-1]]

Use a text editor to replace ,[-1], with a new line/line break.
With some minor manual editing, this will give (something similar):

"WeaponName"
num,num,num
num,num,num
num,num,num

Copy ONLY the number lines into a .txt file, then in Excel use the "Data -> From Text/CSV" function to import the file's contents.
*/

MIL_Data = [];
MIL_BombsFalling = 0;

plane0 addEventHandler ["Fired",{
	params ["_unit","_weapon","_muzzle","_mode","_ammo","_magazine","_projectile","_gunner"];
	plane0 setVehicleAmmo 1;
	private _releasePosition = getPos _projectile;
	private _planeSpeed = speed plane0;
	private _planeAltitude = (getPos plane0) select 2;
	
	private _index = count MIL_Data;
	MIL_Data pushBack -1;
	
	MIL_BombsFalling = MIL_BombsFalling + 1;
	
	nul =  [_projectile,_releasePosition,_planeSpeed,_planeAltitude,_index] spawn {
		params ["_projectile","_releasePosition","_planeSpeed","_planeAltitude","_index",["_impactPosition",[0,0,0]]];		
		while {alive _projectile} do {
			_impactPosition = getPos _projectile;
			sleep 0.1;
		};
		private _flightDistance = _releasePosition distance2D _impactPosition;
		MIL_BombsFalling = MIL_BombsFalling - 1;
		MIL_Data set [_index,round _flightDistance];
	};
}];

sleep 5;
if (typeName ((_ranges select 0) select 0) != "ARRAY") exitWith {
	systemChat "Supplied speed and altitude ranges are incorrect.";
	systemChat "See init.sqf and check instructions.";
	systemChat "SCRIPT WILL NOT RUN.";
};
diag_log (getText (configfile >> "CfgWeapons" >> (currentWeapon plane0) >> "displayName"));
MIL_Data pushBack (getText (configfile >> "CfgWeapons" >> (currentWeapon plane0) >> "displayName"));
MIL_Data pushBack [-1];

{
	_x params ["_speeds","_altitudes"];
	_handle = [currentWeapon plane0,_speeds,_altitudes] execVM "release.sqf";
	waitUntil {scriptDone _handle};
	sleep 1;
} forEach _ranges;

sleep 1;

setAccTime 4;
systemChat "Accelerating time to x4 and waiting for all bombs to impact.....";
while {MIL_BombsFalling > 0} do {
	sleep 5;
	systemChat format["Remaining bombs falling: %1",MIL_BombsFalling];
	
	if ((count allMines > 0) && (diag_fps < 45)) then {
		{
			deleteVehicle _x;
		} forEach allMines;
	};
};

waitUntil {MIL_BombsFalling == 0};

setAccTime 1;
systemChat "Decelerating time to x1 and copying data.....";
copyToClipboard str MIL_Data;
systemChat "Data collection complete. All data copied to clipboard. Go grab a beer and celebrate another job, ummm, done. Mission will end shortly.";
sleep 10;
endMission "END1";

 

 

release.sqf

Spoiler

params ["_type","_speeds","_altitudes"];
_speeds params ["_speedStart","_speedFinish","_speedIncrement"];
_altitudes params ["_altitudeStart","_altitudeFinish","_altitudeIncrement"];

plane0 setAirplaneThrottle 0.25;
MIL_KMH = 0.277778;
private _currentSpeed = _speedStart;
private _currentAltitude = _altitudeStart;
private _weaponName = getText (configfile >> "CfgWeapons" >> _type >> "displayName");

plane0 selectWeapon _type;
plane0 setWeaponReloadingTime [gunner plane0,_type,0];
plane0 allowDamage false;

private _fps = round diag_fps;
hintSilent format["Recording %1\nSpeed (km/h): [%2 - %3]\nAltitude (m): [%4 - %5]\n\nClient FPS: %6",_weaponName,_speedStart,_speedFinish,_altitudeStart,_altitudeFinish,_fps];

while {_currentSpeed <= _speedFinish} do {
	while {_currentAltitude <= _altitudeFinish} do {
		private _fps = round diag_fps;
		hintSilent format["
			Recording %1\n
			\n
			Speed (km/h)\n
			Current: %2\n
			Range: [%3 - %4]\n
			\n
			Altitude (m)\n
			Current: %5\n
			Range: [%6 - %7]\n
			\n
			Client FPS: %8
		",_weaponName,_currentSpeed,_speedStart,_speedFinish,_currentAltitude,_altitudeStart,_altitudeFinish,_fps];
		private _position = getPos plane0;
		_position set [2,_currentAltitude];
		plane0 setPos _position;
		plane0 setVectorDirAndUp [[0,1,0],[0,0,1]];
		plane0 setVelocityModelSpace [0,_currentSpeed * MIL_KMH,0];
		plane0 fire _type;
		_currentAltitude = _currentAltitude + _altitudeIncrement;
		sleep 0.25;
		//sleep 0.5;
		//sleep 1;
		
		if ((count allMines > 0) && (_fps < 45)) then {
			{
				deleteVehicle _x;
			} forEach allMines;
		};
	};
	_currentAltitude = _altitudeStart;
	_currentSpeed = _currentSpeed + _speedIncrement;
	MIL_Data pushBack [-1];
};

 

 

  • Like 4

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×