Jump to content
madrussian

Getting mortar projectile speed from config [SOLVED]

Recommended Posts

I understand how this is suppose to work, but the result I'm getting is quite perplexing!

 

According to CfgWeapons reference:

 

Quote

cfgWeapons >> weaponType >> "initSpeed":

 

Initial speed of shot in meters per second. Also present in cfgMagazines.

In OFP this must be set in the class of the magazine, not that of the weapon.

In A3 this has multiple usages. positive values override magazine initspeed with the fixed number. Negative values act as modifier to the magazine's initispeed.

initSpeed = 1050; //overwrites magazine's value with 1050m/s initSpeed = -1.1; //multiplies magazine's value by +1.1

(^ This also implies that if cfgWeapons initSpeed is 0, you simply use the cfgMagazines initSpeed.)

 

So my vehicle is "B_Mortar_01_F".

 

My weapon is "mortar_82mm".  Checking config, initSpeed for this weapon is 0.

cfgWeapons >> "mortar_82mm" >> "initSpeed" = 0

 

My magazine is "8Rnd_82mm_Mo_shells".  Checking config, initSpeed for this mag is 200.

cfgMagazines >> "8Rnd_82mm_Mo_shells" >> "initSpeed" = 200

 

Thus the initial speed of this mortar round (per instructions in the ref) should be 200 mps.

 

However, when I test the actual speed for this mortar round in the editor, I get a very different result.  Simple test mission with me and an unmanned "B_Mortar_01_F" mortar tube (named TEST_Vehic), with a fired EH on the mortar tube.  Start mission, board vehic, fire!  Here the code for "init.sqf":

_vehic = TEST_Vehic;

TEST_Fired = {
	params ["_unit","_weapon","_muzzle","_mode","_ammo","_magazine","_projectile","_gunner"];
	
	_initSpeedWeapon = 0;
	_initSpeedMagazine = 0;

	_initSpeedWeaponCfg = configFile >> "CfgWeapons" >> _weapon >> "initSpeed";
	if (isNumber _initSpeedWeaponCfg) then { _initSpeedWeapon = getNumber _initSpeedWeaponCfg };
	
	_initSpeedMagazineCfg = configFile >> "CfgMagazines" >> _magazine >> "initSpeed";
	if (isNumber _initSpeedMagazineCfg) then { _initSpeedMagazine = getNumber _initSpeedMagazineCfg };
	
	_projectedSpeedMPS = _initSpeedMagazine;
	if (_initSpeedWeapon > 0) then {
		_projectedSpeedMPS = _initSpeedWeapon;
	} else {
		if (_initSpeedWeapon < 0) then {
			_projectedSpeedMPS = abs (_initSpeedMagazine * _initSpeedWeapon);
		};
	};
	
	_actualSpeedMPS = vectorMagnitude (velocity _projectile);
	
	hint format ["_weapon: %1\n_initSpeedWeapon: %2\n_magazine: %3\n_initSpeedMagazine:%4\n\n_projectedSpeedMPS:%5\n_actualSpeedMPS:%6", _weapon, _magazine, _initSpeedWeapon, _initSpeedMagazine, _projectedSpeedMPS, _actualSpeedMPS];
};

_vehic addEventHandler ["fired", { _this call TEST_Fired }];


Test results:

 

Projected speed is 200 meters per second (as expected per the config).

Actual speed in ~70.0 (meters per second).

 

Anyone have any clue... why the discrepancy?  I'm sure it's something simple, please I welcome any help understanding this.

 

Share this post


Link to post
Share on other sites

OK, I figured it out.  There is a further multiplier, "artilleryCharge", which is based on the weapon's mode.

 

configfile >> "CfgWeapons" >> "mortar_82mm" >> "Single1" >> "artilleryCharge" = 0.35

configfile >> "CfgWeapons" >> "mortar_82mm" >> "Single2" >> "artilleryCharge" = 0.7

configfile >> "CfgWeapons" >> "mortar_82mm" >> "Single3" >> "artilleryCharge" = 1

 

So, here's a breakdown of this weapon's modes / expected initial velocities:

Single1:  200mps * 0.35 = 70mps

Single2:  200mps * 0.7 = 140mps

Single3:  200mps * 1 = 200mps

 

Good, it all makes sense now!  Hmmm... Hope that helped someone. :smile_o:

  • Like 2

Share this post


Link to post
Share on other sites

@madrussian Thank you very much, Sir, it helped me a lot! I am working on a graphical artillery computer and I need to calculate the projectile trajectory of the various fire modes and shells. 

  • Like 1

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

×