mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
Merge pull request #3337 from acemod/overheatingSilencers
Substantially increase overheating when using silencers or flash suppresors
This commit is contained in:
commit
d7403976aa
@ -13,8 +13,9 @@ if (isServer) then {
|
||||
|
||||
if !(hasInterface) exitWith {};
|
||||
|
||||
GVAR(cacheWeaponData) = createLocation ["ACE_HashLocation", [-10000,-10000,-10000], 0, 0];
|
||||
GVAR(cacheWeaponData) setText QGVAR(cacheWeaponData);
|
||||
GVAR(cacheWeaponData) = call CBA_fnc_createNamespace;
|
||||
GVAR(cacheAmmoData) = call CBA_fnc_createNamespace;
|
||||
GVAR(cacheSilencerData) = call CBA_fnc_createNamespace;
|
||||
|
||||
// Add keybinds
|
||||
["ACE3 Weapons", QGVAR(unjamWeapon), localize LSTRING(UnjamWeapon),
|
||||
|
@ -20,22 +20,47 @@
|
||||
params ["_unit", "_weapon", "", "", "_ammo", "", "_projectile"];
|
||||
TRACE_4("params",_unit,_weapon,_ammo,_projectile);
|
||||
|
||||
//Only do heat calculations every 3 bullets
|
||||
// Only do heat calculations every 3 bullets
|
||||
if (((_unit ammo _weapon) % 3) != 0) exitWith {};
|
||||
|
||||
BEGIN_COUNTER(overheat);
|
||||
|
||||
// Get physical parameters
|
||||
private _bulletMass = getNumber (configFile >> "CfgAmmo" >> _ammo >> "ACE_BulletMass");
|
||||
if (_bulletMass == 0) then {
|
||||
// If the bullet mass is not configured, estimate it
|
||||
_bulletMass = 3.4334 + 0.5171 * (getNumber (configFile >> "CfgAmmo" >> _ammo >> "hit") + getNumber (configFile >> "CfgAmmo" >> _ammo >> "caliber"));
|
||||
// Get bullet parameters
|
||||
private _bulletMass = GVAR(cacheAmmoData) getVariable _ammo;
|
||||
if (isNil "_bulletMass") then {
|
||||
_bulletMass = getNumber (configFile >> "CfgAmmo" >> _ammo >> "ACE_BulletMass");
|
||||
if (_bulletMass == 0) then {
|
||||
// If the bullet mass is not configured, estimate it
|
||||
_bulletMass = 3.4334 + 0.5171 * (getNumber (configFile >> "CfgAmmo" >> _ammo >> "hit") + getNumber (configFile >> "CfgAmmo" >> _ammo >> "caliber"));
|
||||
};
|
||||
GVAR(cacheAmmoData) setVariable [_ammo, _bulletMass];
|
||||
};
|
||||
//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
|
||||
|
||||
// Projectile motion is roughly equal to Barrel heat
|
||||
// Ref: https://en.wikipedia.org/wiki/Physics_of_firearms
|
||||
// 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);
|
||||
|
||||
// Increase overheating depending on how obstrusive is the current supressor,
|
||||
// if any. Typical arma supressors have visibleFire=0.5 and audibleFire=0.3,
|
||||
// so they produce x2.1 overheating
|
||||
private _silencer = switch (_weapon) do {
|
||||
case (primaryWeapon _unit) : {(primaryWeaponItems _unit) select 0};
|
||||
case (handgunWeapon _unit) : {(handgunItems _unit) select 0};
|
||||
default {""};
|
||||
};
|
||||
if (_silencer != "") then {
|
||||
private _silencerCoef = GVAR(cacheSilencerData) getVariable _silencer;
|
||||
if (isNil "_silencerCoef") then {
|
||||
_silencerCoef = 1 +
|
||||
(1 - getNumber (configFile >> "CfgWeapons" >> _silencer >> "ItemInfo" >> "AmmoCoef" >> "audibleFire")) +
|
||||
(1 - getNumber (configFile >> "CfgWeapons" >> _silencer >> "ItemInfo" >> "AmmoCoef" >> "visibleFire"));
|
||||
GVAR(cacheSilencerData) setVariable [_silencer, _silencerCoef];
|
||||
};
|
||||
_energyIncrement = _energyIncrement * _silencerCoef;
|
||||
};
|
||||
|
||||
TRACE_2("heat",_bulletMass,_energyIncrement);
|
||||
|
||||
[_unit, _weapon, _energyIncrement] call FUNC(updateTemperature);
|
||||
|
Loading…
Reference in New Issue
Block a user