2015-01-16 02:36:31 +00:00
|
|
|
/*
|
2015-12-15 07:09:26 +00:00
|
|
|
* Author: Commy2 and esteldunedain
|
2015-02-08 22:54:12 +00:00
|
|
|
* Handle weapon fire, heat up the weapon
|
2015-01-16 02:36:31 +00:00
|
|
|
*
|
|
|
|
* Argument:
|
2015-02-08 22:54:12 +00:00
|
|
|
* 0: Unit <OBJECT>
|
|
|
|
* 1: Weapon <STRING>
|
|
|
|
* 3: Muzzle <STRING>
|
|
|
|
* 4: Ammo <STRING>
|
|
|
|
* 5: Magazine <STRING>
|
|
|
|
* 6: Projectile <OBJECT>
|
2015-01-16 02:36:31 +00:00
|
|
|
*
|
|
|
|
* Return value:
|
|
|
|
* None
|
2015-02-08 22:54:12 +00:00
|
|
|
*
|
|
|
|
* Public: No
|
2015-01-16 02:36:31 +00:00
|
|
|
*/
|
2015-12-15 07:09:26 +00:00
|
|
|
#include "script_component.hpp"
|
2015-01-11 16:42:31 +00:00
|
|
|
|
2015-12-15 07:09:26 +00:00
|
|
|
params ["_unit", "_weapon", "", "", "_ammo", "", "_projectile"];
|
|
|
|
TRACE_4("params",_unit,_weapon,_ammo,_projectile);
|
2015-01-16 02:36:31 +00:00
|
|
|
|
2015-12-15 07:09:26 +00:00
|
|
|
//Only do heat calculations every 3 bullets
|
|
|
|
if (((_unit ammo _weapon) % 3) != 0) exitWith {};
|
|
|
|
|
|
|
|
BEGIN_COUNTER(overheat);
|
2015-01-11 16:42:31 +00:00
|
|
|
|
|
|
|
// Get physical parameters
|
2015-12-15 07:09:26 +00:00
|
|
|
private _bulletMass = getNumber (configFile >> "CfgAmmo" >> _ammo >> "ACE_BulletMass");
|
2015-01-11 16:42:31 +00:00
|
|
|
if (_bulletMass == 0) then {
|
2015-12-15 07:09:26 +00:00
|
|
|
// If the bullet mass is not configured, estimate it
|
|
|
|
_bulletMass = 3.4334 + 0.5171 * (getNumber (configFile >> "CfgAmmo" >> _ammo >> "hit") + getNumber (configFile >> "CfgAmmo" >> _ammo >> "caliber"));
|
2015-01-11 16:42:31 +00:00
|
|
|
};
|
2015-12-29 03:01:56 +00:00
|
|
|
//https://en.wikipedia.org/wiki/Physics_of_firearms - Projectile motion is roughly equal to Barrel heat
|
|
|
|
//Muzzle Engergy = 1/2 * m * v^2 (1/2 * 0.001 g/kg * bulletMass (grams) * v^2)
|
|
|
|
//Multiple by 3 becase we only calc every 3rd bullet: (3 * 1/2 * 0.001) = 0.0015
|
|
|
|
private _energyIncrement = 0.0015 * _bulletMass * (vectorMagnitudeSqr velocity _projectile);
|
2015-12-15 07:09:26 +00:00
|
|
|
|
|
|
|
TRACE_2("heat",_bulletMass,_energyIncrement);
|
|
|
|
|
|
|
|
[_unit, _weapon, _energyIncrement] call FUNC(updateTemperature);
|
2015-01-11 16:42:31 +00:00
|
|
|
|
2015-12-15 07:09:26 +00:00
|
|
|
END_COUNTER(overheat);
|