mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
e2ac18a05d
* advanced_ballistics * advanced_fatigue * advanced_throwing * ai * aircraft * arsenal * atragmx * attach * backpacks * ballistics * captives * cargo * chemlights * common * concertina_wire * cookoff * dagr * disarming * disposable * dogtags * dragging * explosives * fastroping * fcs * finger * frag * gestures * gforces * goggles * grenades * gunbag * hearing * hitreactions * huntir * interact_menu * interaction * inventory * kestrel4500 * laser * laserpointer * logistics_uavbattery * logistics_wirecutter * magazinerepack * map * map_gestures * maptools * markers * medical * medical_ai * medical_blood * medical_menu * microdagr * minedetector * missileguidance * missionmodules * mk6mortar * modules * movement * nametags * nightvision * nlaw * optics * optionsmenu * overheating * overpressure * parachute * pylons * quickmount * rangecard * rearm * recoil * refuel * reload * reloadlaunchers * repair * respawn * safemode * sandbag * scopes * slideshow * spectator * spottingscope * switchunits * tacticalladder * tagging * trenches * tripod * ui * vector * vehiclelock * vehicles * viewdistance * weaponselect * weather * winddeflection * yardage450 * zeus * arsenal defines.hpp * optionals * DEBUG_MODE_FULL 1 * DEBUG_MODE_FULL 2 * Manual fixes * Add SQF Validator check for #include after block comment * explosives fnc_openTimerUI * fix uniqueItems
60 lines
1.9 KiB
Plaintext
60 lines
1.9 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"];
|
|
|
|
if (_temperature < 1) exitWith {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 {0};
|
|
|
|
//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;
|
|
|
|
TRACE_4("cooling",_temperature,_totalTime,_barrelMass,_barrelSurface);
|
|
|
|
private _time = 0;
|
|
while {true} do {
|
|
private _deltaTime = (_totalTime - _time) min 20;
|
|
|
|
_temperature = _temperature - (
|
|
// Convective cooling
|
|
25 * _barrelSurface * _temperature
|
|
// Radiative cooling
|
|
+ 0.4 * 5.67e-8 * _barrelSurface *
|
|
( (_temperature + 273.15)*(_temperature + 273.15)
|
|
* (_temperature + 273.15)*(_temperature + 273.15)
|
|
- 273.15 * 273.15 * 273.15 *273.15 )
|
|
) * _deltaTime / (_barrelMass * 466);
|
|
|
|
if (_temperature < 1) exitWith {0};
|
|
|
|
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 0 };
|
|
};
|