Initial commit scuba

This commit is contained in:
BaerMitUmlaut
2016-07-13 11:16:07 +02:00
parent 96a08dfc01
commit 9c01ef4541
11 changed files with 143 additions and 0 deletions

1
addons/scuba/$PBOPREFIX$ Normal file
View File

@ -0,0 +1 @@
z\ace\addons\scuba

View File

@ -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));
};
};

View File

@ -0,0 +1,3 @@
PREP(calculateSafePressure);
PREP(pfhMain);
PREP(updateCompartments);

View File

@ -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;

View File

@ -0,0 +1,3 @@
#include "script_component.hpp"
#include "XEH_PREP.hpp"

17
addons/scuba/config.cpp Normal file
View File

@ -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"

View File

@ -0,0 +1,23 @@
/*
* Author: BaerMitUmlaut
* Calculates a safe pressure the player can ascend to.
*
* Arguments:
* None
*
* Return Value:
* Maximum ambient pressure tolerated <NUMBER>
*/
#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

View File

@ -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
};

View File

@ -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];

View File

@ -0,0 +1 @@
#include "\z\ace\addons\blank\script_component.hpp"

View File

@ -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"