mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
99c85e3c12
* move overheating cookoff into separate function * move heatCoef and require mission restart for setting change - move heatCoef to a more sensible place - require mission restart for heatCoef setting change (it gets cached per ammo type) * add exit to ammo temp loop if cookoffCoef is changed to 0 mid-mission - add exit to ammo temp loop if cookoffCoef is changed to 0 mid-mission, this prevents an issue where all weapon cookoff regardless of temp, because required temp gets multiplied by cookoffCoef which has been set to 0. * file end new line * update header for ace_overheating_fnc_cookoffWeapon * use ambientTemperature as floor for weapon and ammo temp * add coolingCoef setting * improve feature documentation * add fnc_cookoffWeapon to XEH_PREP * add type of jam to ace_weaponJammed local event - add type of jam to ace_weaponJammed local event - fix #8637 * fix misspelling Co-authored-by: TyroneMF <TyroneMF@hotmail.com> * clear all weapon heat on death * Update addons/overheating/functions/fnc_updateTemperature.sqf Co-authored-by: GhostIsSpooky <69561145+Salluci@users.noreply.github.com> * deprecate ace_overheating_fnc_getBarrelMass, cache weapon bolt and barrel mass values - cache closed bolt value by moving config look up to ace_overheating_fnc_getWeaponData - cache barrel mass value by moving calculation from ace_overheating_fnc_getBarrelMass to ace_overheating_fnc_getWeaponData - deprecate ace_overheating_fnc_getBarrelMass to be a wrapper for ace_overheating_fnc_getWeaponData that only returns barrel mass * add public functions to get and set weapon and ammo temperature * add `canCoolWeaponWithItem` function, workaround for #8657 * Apply suggestions from code review Co-authored-by: PabstMirror <pabstmirror@gmail.com> * add coef setting for addition heat from suppressor * Update fnc_overheat.sqf * improve fnc_canCoolWeaponWithItem * remove extra ( * Move canCoolWeaponWithItem action code to function * Use hashmaps and reset on settings change * Apply suggestions from code review Co-authored-by: jonpas <jonpas33@gmail.com> Co-authored-by: TyroneMF <TyroneMF@hotmail.com> Co-authored-by: GhostIsSpooky <69561145+Salluci@users.noreply.github.com> Co-authored-by: PabstMirror <pabstmirror@gmail.com> Co-authored-by: jonpas <jonpas33@gmail.com>
69 lines
2.4 KiB
Plaintext
69 lines
2.4 KiB
Plaintext
#include "script_component.hpp"
|
|
/*
|
|
* Author: esteldunedain
|
|
* Calculate the cooling down of a weapon over a time interval.
|
|
*
|
|
* Arguments:
|
|
* 0: Initial temperature <NUMBER>
|
|
* 1: Barrel mass <NUMBER>
|
|
* 2: Time interval <NUMBER>
|
|
*
|
|
* Return Value:
|
|
* Final temperature <NUMBER>
|
|
*
|
|
* Example:
|
|
* [_temperature, _barrelMass, _totalTime] call ace_overheating_fnc_calculateCooling
|
|
*
|
|
* Public: No
|
|
*/
|
|
|
|
params ["_temperature", "_barrelMass", "_totalTime"];
|
|
|
|
// The lowest temperature a weapon can reach is the ambient air temperature.
|
|
private _ambientTemperature = ambientTemperature select 0;
|
|
|
|
// If a long time passed since the last shot, there's no need to calculate anything; the weapon should be cool
|
|
if (_totalTime > 1800) exitWith {_ambientTemperature};
|
|
if (_temperature <= _ambientTemperature) exitWith {_ambientTemperature};
|
|
|
|
//AR-15 (0.00570m bullet diameter) (barrel diameter usually 0.75" or 0.008255m radius)
|
|
//Steel Denisty = 7850 m^3 / kg
|
|
//Area of a cylinder (2/r)*(Pi * r^3 + V) - for a 0.008255m radius barrel -> Area = 210(1/meters) * Volume
|
|
//Adjusted volume for being hollowed out is ~1.1x
|
|
//So Area = 210 * 1.1 * (mass / 7850) = mass * 0.029427 (for steel near that diameter)
|
|
|
|
private _barrelSurface = _barrelMass * 0.029427;
|
|
private _convectionRate = 25;
|
|
|
|
//provide additional cooling if swimming or raining or windy
|
|
if (ACE_player call EFUNC(common,isSwimming)) then {
|
|
_convectionRate = 500;
|
|
} else {
|
|
// this will give a convection rate between 25 (no wind or rain) and 125 (max rain and >=50 m/s wind)
|
|
_convectionRate = _convectionRate * ((linearConversion [0,1,rain,1,5,true] + (5 min (vectorMagnitude wind / 10))) / 2);
|
|
};
|
|
|
|
TRACE_4("cooling",_temperature,_totalTime,_barrelMass,_barrelSurface);
|
|
|
|
private _time = 0;
|
|
while {true} do {
|
|
private _deltaTime = (_totalTime - _time) min 20;
|
|
|
|
_temperature = _temperature - (
|
|
// Convective cooling
|
|
_convectionRate * _barrelSurface * _temperature
|
|
// Radiative cooling
|
|
+ 0.4 * 5.67e-8 * _barrelSurface * ((_temperature + 273.15) ^ 4 - 273.15 ^ 4)
|
|
) * GVAR(coolingCoef) * _deltaTime / (_barrelMass * 466);
|
|
|
|
if (_temperature <= _ambientTemperature) exitWith {_ambientTemperature};
|
|
|
|
if (isNil "_temperature") exitWith {
|
|
diag_log text format ["[ACE] ERROR: _totalTime = %1; _time = %2; _deltaTime = %3;", _totalTime, _time, _deltaTime];
|
|
0
|
|
};
|
|
|
|
_time = _time + _deltaTime;
|
|
if (_time >= _totalTime) exitWith {_temperature max _ambientTemperature};
|
|
};
|