Jump to content
Sign in to follow this  
funkee

Unguided bombs & CCIP bombing mode

Recommended Posts

CCIP can be done, it's just a matter of getting the arithmetic right. :)

Hi, I have played a little with the script General Barron and you have developed here.

Fiddled a little with the values and now it works pretty well for the Mk82s of the AV-8B CAS.

There is a point I do not understand, probably because my math is a little rusty:

//work-in-progress ccip / fcs script
//by General Barron, modifications by Franze and schaefsky
//Note, this script only takes terrain into account.
//It does NOT account for objects or buildings on the terrain!

#define DELTA_T1	0.2	//sleep step used in script (between impact point calculations)
#define DELTA_T2	0.3	//time step used in trajectory simulations
#define G_CONST		5.2	//acceleration due to gravity
#define AIRFRICTION	-0.0005 //air friction constant for the ammo being computed by the CCIP
#define INIT_VEL	0 	//initial velocity of the ammo being computed by the CCIP
//#define DEBUG 		//uncomment for visual debuggging
//create an object for ASL calcs
_detector = "emptydetector" createVehicle (position player);
bomb = objNull;
_VzBombOld = 0;
_VzBomb = 0;
_accBomb = 0;
_tsOld = 0;
_tsNow = 0;

while {true} do
{
//position of ammo, if it were fired right now (same as firing vehicle)
_Px = (getposASL vehicle player) select 0;
_Py = (getposASL vehicle player) select 1;
_Pz = (getposASL vehicle player) select 2;
//set our detector position and get its ASL
_detector setpos [_Px,_Py,0];
_detectorasl = getposasl _detector;

//base velocity of ammo, if it were fired right now (same as firing vehicle)
_Vx = (velocity vehicle player) select 0;
_Vy = (velocity vehicle player) select 1;
_Vz = (velocity vehicle player) select 2;
_Vmag = sqrt (_Vx^2 + _Vy^2 + _Vz^2);

//add in initial velocity of ammo due to being fired
_Vx = _Vx + (_Vx/_Vmag)*INIT_VEL;
_Vy = _Vy + (_Vy/_Vmag)*INIT_VEL;
_Vz = _Vz + (_Vz/_Vmag)*INIT_VEL;

//bomb = nearestObject[vehicle player, "Bo_Mk82"];

//simulate ammo trajectory until it impacts the ground

_VzBomb = (velocity bomb) select 2;
_tsNow = diag_tickTime;
_accBomb = (_VzBomb-_VzBombOld) / (_tsNow - _tsOld);
hint format ["%1 %2 %3 %4", bomb, _accBOmb, (_VzBomb - _VzBombOld), _tsNow - _tsOld];
_VzBombOld = (velocity bomb) select 2;
_tsOld = diag_tickTime;

while {_Pz > (_detectorasl) select 2} do
{
	//adjust ammo velocity for air friction and gravity (the only forces working on the ammo)
	//_Vmag = sqrt (_Vx^2 + _Vy^2 + _Vz^2);
	_vMag = 1;

	_Vx = _Vx + DELTA_T2*(_Vmag*_Vx*AIRFRICTION);
	_Vy = _Vy + DELTA_T2*(_Vmag*_Vy*AIRFRICTION);
	_Vz = _Vz + DELTA_T2*(_Vmag*_Vz*AIRFRICTION-G_CONST); //factor in gravity here

	//adjust ammo position using time step and new velocity
	_Px = _Px + _Vx*DELTA_T2;
	_Py = _Py + _Vy*DELTA_T2;
	_Pz = _Pz + _Vz*DELTA_T2;
	_detector setpos [_Px,_Py,0];
	_detectorasl = getposasl _detector;
};

//we now have the impact position if we were to fire the ammo right now: [_Px, _Py, 0]
//todo: do something with this...
[group player, 1] setWPPos [_Px, _Py];

//wait a bit before recalculating the impact point
sleep DELTA_T1;
};

As you might see, I have set _Vmag (the vector norm) to 1 to basicly ignore it in the calculation. The point I do not understand is how the vector norm plays into the velocity calculation of the vector components. Is it not sufficient to only regard the components? Seems to work better when ignoring it. Then again, it was probably put there for a reason...

The other thing I did is updating the _detector position to the calculated point in flight path, since terrain height might vary greatly between point of plane and impact point.

The whole thing works pretty well under about 300m, then the gravity value gets wrong I think. I had Arma2 hint me out the actual (negative/downwards) accellaration of a fired bomb, it seems to me it is jettisoned away from the plane and then airfriction and lift (? as pointed out by vektorboson) set in (got around -12 m/s² at start, quickly decreasing to about -5.5 and then slower decrease to around -4 m/s², where decrease of downward acceleration seems to end).

EDIT:

To get hints about bomb values, put for example this in the init line of the harrier you are flying:

this addEventHandler ["fired", "bomb = nearestObject [this, ""Bo_Mk82""];"];

So, anyone got a good idea how to calculate the actual lift and airfriction influencing the bomb?

To my knowledge it is possible to read out config values, does anybody know how to get to the config values in question? And would they suffice?

Another quick and dirty way would be to simply build up a table with "gravity" values in relation to flight height, but well... if it is possible to do it right, I would prefer that.

Hope for your all input.

Edited by schaefsky

Share this post


Link to post
Share on other sites
Hi, I have played a little with the script General Barron and you have developed here.

Fiddled a little with the values and now it works pretty well for the Mk82s of the AV-8B CAS.

There is a point I do not understand, probably because my math is a little rusty:

//work-in-progress ccip / fcs script
//by General Barron, modifications by Franze and schaefsky
//Note, this script only takes terrain into account.
//It does NOT account for objects or buildings on the terrain!

#define DELTA_T1	0.2	//sleep step used in script (between impact point calculations)
#define DELTA_T2	0.3	//time step used in trajectory simulations
#define G_CONST		5.2	//acceleration due to gravity
#define AIRFRICTION	-0.0005 //air friction constant for the ammo being computed by the CCIP
#define INIT_VEL	0 	//initial velocity of the ammo being computed by the CCIP
//#define DEBUG 		//uncomment for visual debuggging
//create an object for ASL calcs
_detector = "emptydetector" createVehicle (position player);
bomb = objNull;
_VzBombOld = 0;
_VzBomb = 0;
_accBomb = 0;
_tsOld = 0;
_tsNow = 0;

while {true} do
{
//position of ammo, if it were fired right now (same as firing vehicle)
_Px = (getposASL vehicle player) select 0;
_Py = (getposASL vehicle player) select 1;
_Pz = (getposASL vehicle player) select 2;
//set our detector position and get its ASL
_detector setpos [_Px,_Py,0];
_detectorasl = getposasl _detector;

//base velocity of ammo, if it were fired right now (same as firing vehicle)
_Vx = (velocity vehicle player) select 0;
_Vy = (velocity vehicle player) select 1;
_Vz = (velocity vehicle player) select 2;
_Vmag = sqrt (_Vx^2 + _Vy^2 + _Vz^2);

//add in initial velocity of ammo due to being fired
_Vx = _Vx + (_Vx/_Vmag)*INIT_VEL;
_Vy = _Vy + (_Vy/_Vmag)*INIT_VEL;
_Vz = _Vz + (_Vz/_Vmag)*INIT_VEL;

//bomb = nearestObject[vehicle player, "Bo_Mk82"];

//simulate ammo trajectory until it impacts the ground

_VzBomb = (velocity bomb) select 2;
_tsNow = diag_tickTime;
_accBomb = (_VzBomb-_VzBombOld) / (_tsNow - _tsOld);
hint format ["%1 %2 %3 %4", bomb, _accBOmb, (_VzBomb - _VzBombOld), _tsNow - _tsOld];
_VzBombOld = (velocity bomb) select 2;
_tsOld = diag_tickTime;

while {_Pz > (_detectorasl) select 2} do
{
	//adjust ammo velocity for air friction and gravity (the only forces working on the ammo)
	//_Vmag = sqrt (_Vx^2 + _Vy^2 + _Vz^2);
	_vMag = 1;

	_Vx = _Vx + DELTA_T2*(_Vmag*_Vx*AIRFRICTION);
	_Vy = _Vy + DELTA_T2*(_Vmag*_Vy*AIRFRICTION);
	_Vz = _Vz + DELTA_T2*(_Vmag*_Vz*AIRFRICTION-G_CONST); //factor in gravity here

	//adjust ammo position using time step and new velocity
	_Px = _Px + _Vx*DELTA_T2;
	_Py = _Py + _Vy*DELTA_T2;
	_Pz = _Pz + _Vz*DELTA_T2;
	_detector setpos [_Px,_Py,0];
	_detectorasl = getposasl _detector;
};

//we now have the impact position if we were to fire the ammo right now: [_Px, _Py, 0]
//todo: do something with this...
[group player, 1] setWPPos [_Px, _Py];

//wait a bit before recalculating the impact point
sleep DELTA_T1;
};

As you might see, I have set _Vmag (the vector norm) to 1 to basicly ignore it in the calculation. The point I do not understand is how the vector norm plays into the velocity calculation of the vector components. Is it not sufficient to only regard the components? Seems to work better when ignoring it. Then again, it was probably put there for a reason...

The other thing I did is updating the _detector position to the calculated point in flight path, since terrain height might vary greatly between point of plane and impact point.

The whole thing works pretty well under about 300m, then the gravity value gets wrong I think. I had Arma2 hint me out the actual (negative/downwards) accellaration of a fired bomb, it seems to me it is jettisoned away from the plane and then airfriction and lift (? as pointed out by vektorboson) set in (got around -12 m/s² at start, quickly decreasing to about -5.5 and then slower decrease to around -4 m/s², where decrease of downward acceleration seems to end).

So, anyone got a good idea how to calculate the actual lift and airfriction influencing the bomb?

To my knowledge it is possible to read out config values, does anybody know how to get to the config values in question? And would they suffice?

Another quick and dirty way would be to simply build up a table with "gravity" values in relation to flight height, but well... if it is possible to do it right, I would prefer that.

Hope for your all input.

i basically have no clue what you are talking about, but how can i use this script and if you need someone to test it tell me pls.

Share this post


Link to post
Share on other sites

Funkee, there are F16's in bf2 mods which use left over HUD parts from a F16 DICE never implemented.

Share this post


Link to post
Share on other sites

nvm Depleted.

so the job is already done, now I just wanna know if BI is interested to implement this in upcoming patches (I don't want it to be a mod but "vanilla" ArmA2).

Share this post


Link to post
Share on other sites

I've moved my post to the "Mission Editing & Scripting" section from the "General" one. Hope it might get more specific attention here. I think it would be really good thing to have CCIP in vanilla ArmA2... :icon_rolleyes:

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
Sign in to follow this  

×