diff --git a/addons/scuba/$PBOPREFIX$ b/addons/scuba/$PBOPREFIX$ new file mode 100644 index 0000000000..1d245e4747 --- /dev/null +++ b/addons/scuba/$PBOPREFIX$ @@ -0,0 +1 @@ +z\ace\addons\scuba diff --git a/addons/scuba/CfgEventHandlers.hpp b/addons/scuba/CfgEventHandlers.hpp new file mode 100644 index 0000000000..93e3311cf2 --- /dev/null +++ b/addons/scuba/CfgEventHandlers.hpp @@ -0,0 +1,11 @@ +class Extended_PreStart_EventHandlers { + class ADDON { + init = QUOTE(call COMPILE_FILE(XEH_preStart)); + }; +}; + +class Extended_PreInit_EventHandlers { + class ADDON { + init = QUOTE(call COMPILE_FILE(XEH_preInit)); + }; +}; diff --git a/addons/scuba/XEH_PREP.hpp b/addons/scuba/XEH_PREP.hpp new file mode 100644 index 0000000000..6e18fbbfb8 --- /dev/null +++ b/addons/scuba/XEH_PREP.hpp @@ -0,0 +1,3 @@ +PREP(calculateSafePressure); +PREP(pfhMain); +PREP(updateCompartments); diff --git a/addons/scuba/XEH_preInit.sqf b/addons/scuba/XEH_preInit.sqf new file mode 100644 index 0000000000..bab4a254dc --- /dev/null +++ b/addons/scuba/XEH_preInit.sqf @@ -0,0 +1,19 @@ +#include "script_component.hpp" + +ADDON = false; + +#include "XEH_PREP.hpp" + +GVAR(inertGasTypes) = ["nitrogen", "helium"]; +GVAR(inertGasHalftimes) = [ + [4, 8, 12.5, 18.5, 27, 38.3, 54.3, 77, 109, 146, 187, 239, 305, 390, 498, 635], + [1.5, 3.0, 4.7, 7.0, 10.2, 14.5, 20.5, 29.1, 41.1, 55.1, 70.6, 90.2, 115.1, 147.2, 187.9, 239.6] +]; +GVAR(interGasAValues) = GVAR(inertGasHalftimes) apply {_x apply { + 2 * _x ^ (-1/3) +}}; +GVAR(interGasBValues) = GVAR(inertGasHalftimes) apply {_x apply { + 1.005 - (_x ^ (-1/2)) +}}; + +ADDON = true; diff --git a/addons/scuba/XEH_preStart.sqf b/addons/scuba/XEH_preStart.sqf new file mode 100644 index 0000000000..022888575e --- /dev/null +++ b/addons/scuba/XEH_preStart.sqf @@ -0,0 +1,3 @@ +#include "script_component.hpp" + +#include "XEH_PREP.hpp" diff --git a/addons/scuba/config.cpp b/addons/scuba/config.cpp new file mode 100644 index 0000000000..f21f33dd80 --- /dev/null +++ b/addons/scuba/config.cpp @@ -0,0 +1,17 @@ +#include "script_component.hpp" + +class CfgPatches { + class ADDON { + name = COMPONENT_NAME; + units[] = {}; + weapons[] = {}; + requiredVersion = REQUIRED_VERSION; + requiredAddons[] = {"ace_common"}; + author = ECSTRING(common,ACETeam); + authors[] = {"BaerMitUmlaut"}; + url = ECSTRING(main,URL); + VERSION_CONFIG; + }; +}; + +#include "CfgEventHandlers.hpp" diff --git a/addons/scuba/functions/fnc_calculateSafePressure.sqf b/addons/scuba/functions/fnc_calculateSafePressure.sqf new file mode 100644 index 0000000000..69b720d5b4 --- /dev/null +++ b/addons/scuba/functions/fnc_calculateSafePressure.sqf @@ -0,0 +1,23 @@ +/* + * Author: BaerMitUmlaut + * Calculates a safe pressure the player can ascend to. + * + * Arguments: + * None + * + * Return Value: + * Maximum ambient pressure tolerated + */ +#include "script_component.hpp" + +private _maxPAmbtol = 0; + +{ + private _a = GVAR(interGasAValues) select (_forEachIndex * 2); + private _b = GVAR(interGasBValues) select (_forEachIndex * 2); + + private _pAmbtol = (_x - _a) * _b; + _maxPAmbtol = _maxPAmbTol max _pAmbtol; +} forEach (ACE_player getVariable QGVAR(compartments)); + +_maxPAmbtol diff --git a/addons/scuba/functions/fnc_pfhMain.sqf b/addons/scuba/functions/fnc_pfhMain.sqf new file mode 100644 index 0000000000..79186630f4 --- /dev/null +++ b/addons/scuba/functions/fnc_pfhMain.sqf @@ -0,0 +1,19 @@ +/* + * Author: BaerMitUmlaut + * Simulates physical effects while diving. + * + * Arguments: + * None + * + * Return Value: + * None + */ +#include "script_component.hpp" + +[] call FUNC(updateCompartments); +private _safePressure = [] call FUNC(calculateSafePressure); +private _safeDepth = (_safePressure - 1) * 10; + +if (_safeDepth > ((getPosASL ACE_player select 2) * -1)) then { + // Damage here +}; diff --git a/addons/scuba/functions/fnc_updateCompartments.sqf b/addons/scuba/functions/fnc_updateCompartments.sqf new file mode 100644 index 0000000000..8ce7b7eef3 --- /dev/null +++ b/addons/scuba/functions/fnc_updateCompartments.sqf @@ -0,0 +1,28 @@ +/* + * Author: BaerMitUmlaut + * Updates the inert gas pressure in each compartment. + * + * Arguments: + * None + * + * Return Value: + * None + */ +#include "script_component.hpp" + +private _compartments = ACE_player getVariable [QGVAR(compartments), [0,0,0,0,0,0,0,0]]; + +{ + private _pBegin = _x; + private _pGas = ACE_player getVariable QGVAR(inertGasPressure); + private _tExposure = 1/60; + private _gasType = ACE_player getVariable QGVAR(inertGasType); + private _tHalftime = (GVAR(inertGasHalftimes) select (GVAR(inertGasTypes) find _gasType)) select (_forEachIndex * 2); + + // Bühlmann algorithm + private _pComp = _pBegin + (_pGas - _pBegin) * (1 - 2 ^ (-1 * _tExposure / _tHalftime)); + + _compartments set [_forEachIndex, _pComp]; +} forEach _compartments; + +ACE_player setVariable [QGVAR(compartments), _compartments]; diff --git a/addons/scuba/functions/script_component.hpp b/addons/scuba/functions/script_component.hpp new file mode 100644 index 0000000000..3cc9111162 --- /dev/null +++ b/addons/scuba/functions/script_component.hpp @@ -0,0 +1 @@ +#include "\z\ace\addons\blank\script_component.hpp" \ No newline at end of file diff --git a/addons/scuba/script_component.hpp b/addons/scuba/script_component.hpp new file mode 100644 index 0000000000..d16c06f1e7 --- /dev/null +++ b/addons/scuba/script_component.hpp @@ -0,0 +1,18 @@ +#define COMPONENT scuba +#define COMPONENT_BEAUTIFIED Scuba +#include "\z\ace\addons\main\script_mod.hpp" + +// #define DEBUG_MODE_FULL +// #define DISABLE_COMPILE_CACHE +// #define CBA_DEBUG_SYNCHRONOUS +// #define ENABLE_PERFORMANCE_COUNTERS + +#ifdef DEBUG_ENABLED_SCUBA + #define DEBUG_MODE_FULL +#endif + +#ifdef DEBUG_SETTINGS_SCUBA + #define DEBUG_SETTINGS DEBUG_SETTINGS_SCUBA +#endif + +#include "\z\ace\addons\main\script_macros.hpp"