Skip to content

Commit

Permalink
Overheating - Increase cooling for open bolt guns and spare barrels (#…
Browse files Browse the repository at this point in the history
…9827)

* open bolt and spare barrel cooling boost

* change magic number to macro
  • Loading branch information
Drofseh authored Mar 6, 2024
1 parent 78334e2 commit 6ea0312
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 10 deletions.
6 changes: 5 additions & 1 deletion addons/overheating/functions/fnc_calculateCooling.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
* 0: Initial temperature <NUMBER>
* 1: Barrel mass <NUMBER>
* 2: Time interval <NUMBER>
* 3: Bolt type <NUMBER>
*
* Return Value:
* Final temperature <NUMBER>
Expand All @@ -17,7 +18,7 @@
* Public: No
*/

params ["_temperature", "_barrelMass", "_totalTime"];
params ["_temperature", "_barrelMass", "_totalTime", "_boltType"];

// The lowest temperature a weapon can reach is the ambient air temperature.
private _ambientTemperature = ambientTemperature select 0;
Expand All @@ -43,6 +44,9 @@ if (ACE_player call EFUNC(common,isSwimming)) then {
_convectionRate = _convectionRate * ((linearConversion [0,1,rain,1,5,true] + (5 min (vectorMagnitude wind / 10))) / 2);
};

//Increase convection cooling for open bolt type guns
if (_boltType == 0) then {_convectionRate = _convectionRate * OPEN_BOLT_ADDITIONAL_CONVECTION};

TRACE_4("cooling",_temperature,_totalTime,_barrelMass,_barrelSurface);

private _time = 0;
Expand Down
4 changes: 2 additions & 2 deletions addons/overheating/functions/fnc_coolWeaponWithItem.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ private _fnc_onSuccess = {
};

// cool the weapon
private _barrelMass = ([_weapon] call FUNC(getWeaponData)) select 7;
_temperature = [_temperature, _barrelMass, _liquidAmount * 10] call FUNC(calculateCooling);
private _weaponData = [_weapon] call FUNC(getWeaponData);
_temperature = [_temperature, _weaponData select 7, _liquidAmount * 10, _weaponData select 6] call FUNC(calculateCooling);
[_target, _tempVarName, _temperature, TEMP_TOLERANCE] call EFUNC(common,setApproximateVariablePublic);
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ private _fnc_condition = {
};

//Cool the weapon down
private _barrelMass = ([_weapon] call FUNC(getWeaponData)) select 7;
_temperature = [_temperature, _barrelMass, 20] call FUNC(calculateCooling);
private _weaponData = [_weapon] call FUNC(getWeaponData);
_temperature = [_temperature, _weaponData select 7, 20, _weaponData select 6] call FUNC(calculateCooling);
[_player, _tempVarName, _temperature, TEMP_TOLERANCE] call EFUNC(common,setApproximateVariablePublic);

/* // to be added when licence compatible audio can be found or recorded
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ TRACE_1("updateSpareBarrelsTemperaturesThread1",GVAR(storedSpareBarrels));
_y params ["_initialTemp","_initialTime", "_barrelMass"];

// Calculate cooling
private _finalTemp = [_initialTemp, _barrelMass, CBA_missionTime - _initialTime] call FUNC(calculateCooling);
private _finalTemp = [_initialTemp, _barrelMass, CBA_missionTime - _initialTime, 0] call FUNC(calculateCooling); //the zero is to indicate an open bolt gun. Barrel is outside of a gun here, so always open.
TRACE_4("updateSpareBarrelsTemperaturesThread2",_barrelMagazineID,_initialTemp,_finalTemp,_barrelMass);
if (_finalTemp < 5) then {
// The barrel is cool enough to keep calculating. Remove it from the hash
if (_finalTemp <= (ambientTemperature select 0)) then {
// The barrel is cool enough to finish calculating. Remove it from the hash
GVAR(storedSpareBarrels) deleteAt _x;
} else {
// Store the new temp
Expand Down
5 changes: 3 additions & 2 deletions addons/overheating/functions/fnc_updateTemperature.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,9 @@ _trackedWeapons pushBackUnique _tempVarName;
_unit setVariable [QGVAR(trackedWeapons), _trackedWeapons];

// Calculate cooling
private _barrelMass = ([_weapon] call FUNC(getWeaponData)) select 7;
_temperature = [_temperature, _barrelMass, CBA_missionTime - _lastTime] call FUNC(calculateCooling);
private _weaponData = [_weapon] call FUNC(getWeaponData);
private _barrelMass = _weaponData select 7;
_temperature = [_temperature, _barrelMass, CBA_missionTime - _lastTime, _weaponData select 6] call FUNC(calculateCooling);

TRACE_1("cooledTo",_temperature);
// Calculate heating
Expand Down
1 change: 1 addition & 0 deletions addons/overheating/script_component.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#define TEMP_TOLERANCE 50
#define METAL_MASS_RATIO 0.55
#define GUNPOWDER_IGNITION_TEMP 180
#define OPEN_BOLT_ADDITIONAL_CONVECTION 1.1

#ifdef DEBUG_MODE_FULL
#define TRACE_PROJECTILE_INFO(BULLET) _vdir = vectorNormalized velocity BULLET; _dir = (_vdir select 0) atan2 (_vdir select 1); _up = asin (_vdir select 2); _mv = vectorMagnitude velocity BULLET; TRACE_3("adjusted projectile",_dir,_up,_mv);
Expand Down

0 comments on commit 6ea0312

Please sign in to comment.