Jump to content
Sign in to follow this  
trini scourge

Diver Stats: A light simulation of depth, pressure and air consumption rates

Recommended Posts

Got my first problem.. As soon as im diving with a group (All using the script) it bugs.. the information is just getting mad hehe and as soon as a particular diver gets out of the water it stops showing for me..

Share this post


Link to post
Share on other sites
Got my first problem.. As soon as im diving with a group (All using the script) it bugs.. the information is just getting mad hehe and as soon as a particular diver gets out of the water it stops showing for me..

Hey Brian thanks for trying it out. Can you send me pics of the bugs you're encountering?

The script auto-closes the display when the diver is able to breathe surface air, if you get back in the water it should continue the display.

Share this post


Link to post
Share on other sites
Hey Brian thanks for trying it out. Can you send me pics of the bugs you're encountering?

The script auto-closes the display when the diver is able to breathe surface air, if you get back in the water it should continue the display.

Well, I cant get a picture.. but when in the editor, place a group of divers.. all give em:

null = [this,25,3000] execVM "scripts\trindisplay\diverstats.sqf" then go underwater with the group.. it's showing your computer but keeps switching every half second to someone else's information... ill try to capture it

Share this post


Link to post
Share on other sites
Well, I cant get a picture.. but when in the editor, place a group of divers.. all give em:

null = [this,25,3000] execVM "scripts\trindisplay\diverstats.sqf" then go underwater with the group.. it's showing your computer but keeps switching every half second to someone else's information... ill try to capture it

I think I understand what you mean. You're experiencing my lack of scripting prowess. If there are more than 1 instance of the script running on a single client that error will occur.

For now (until I get better at scripting), you'll be better off using the script on a single diver.

Share this post


Link to post
Share on other sites
I think I understand what you mean. You're experiencing my lack of scripting prowess. If there are more than 1 instance of the script running on a single client that error will occur.

For now (until I get better at scripting), you'll be better off using the script on a single diver.

Well, Im duplicated the diverstats.sqf and named them: diverstats.sqf, diverstats1.sqf, diverstats2.sqf etc. and that seems to work! It is really a great script!

Also before i forget to ask,

Can i change the text color and change the display? If im allowed then please tell me how to change the text color:)

Share this post


Link to post
Share on other sites

To change the text color go into: scripts\trindisplay\dialog\trin_display.hpp and edit the values there. Changing the display is a lot more involved and requires you to do some research and lots of reading. Check HERE and HERE to go down the rabbit hole.

Share this post


Link to post
Share on other sites

So does this script have implications for breaching diving physics/biology or is it centered around you obeying your Dive Computer? Also - is it possible to switch between ft and meters? As a non-American I can't stand anything in imperial especially it comes to diving where metric is even more important - 10m = 1 bar = 1/2 volume of air = 2x atmospheric pressure etc

Anyway script looks great - would just like answers to the above before I give it a whirl.

Share this post


Link to post
Share on other sites

Hey I just saw this and was super impressed. It's open circuit, yeah, but it's still a great job. I love the dive computer. There are a lot of things on there that are just as complicated as the dive computers I've found in my research. Nicely done.

FYI, I think there's a new scripting command that tells the script if a player is using imperial or metric. Don't know if it's implemented yet in A3 but if it is, it would be a nice way of switching between ft/meters automatically. But it is easy enough to just add an addAction or a keystroke to switch between the two. Also, I noticed that you used getPosASL for your depth measurements. It might not matter, but I switched over to the new command getPosASLW which is depth below the wave height. It's nit-picking, but it's more accurate. And with wave height changing depending on storms, time of day, moon cycle, etc, sea level varies greatly. Hope that helps.

Share this post


Link to post
Share on other sites

Love the script is it possible to make it so the palyer does not have to be a diver and can be any character and just needs to have a re breather equipped ?

i have a mission where half way through u need to equip diving gear and would love to use this script however it gets a bit buggy i think due to changing uniforms , any insight?

Cheer,

Roman

Share this post


Link to post
Share on other sites
the new command getPosASLW which is depth below the wave height. It's nit-picking, but it's more accurate. And with wave height changing depending on storms, time of day, moon cycle, etc, sea level varies greatly. Hope that helps.

Man... BIS is good.

http://community.bistudio.com/wiki/getPosASLW

However, I've been told (haven't seen it for myself) that waves are client side and not synced - so if you are diving with mates you could potentially be in the exact same position underwater and the getPosASLW command would potentially return different values. So depending on a bit of luck you could have different bottom times for the same exact dive in Co-Op.... Is this right?

---------- Post added at 12:23 ---------- Previous post was at 11:38 ----------

Okay - just tried using the script and getting an error in Editor (DEV build). Getting Type Script, expected Nothing.

Share this post


Link to post
Share on other sites
Hey I just saw this and was super impressed. It's open circuit, yeah, but it's still a great job. I love the dive computer. There are a lot of things on there that are just as complicated as the dive computers I've found in my research. Nicely done.

FYI, I think there's a new scripting command that tells the script if a player is using imperial or metric. Don't know if it's implemented yet in A3 but if it is, it would be a nice way of switching between ft/meters automatically. But it is easy enough to just add an addAction or a keystroke to switch between the two. Also, I noticed that you used getPosASL for your depth measurements. It might not matter, but I switched over to the new command getPosASLW which is depth below the wave height. It's nit-picking, but it's more accurate. And with wave height changing depending on storms, time of day, moon cycle, etc, sea level varies greatly. Hope that helps.

Thanks for trying it out Feint. I'm really looking forward to your underwater diving module. I spent dozens of hours trying to figure out how to implement n2 narcosis and decompression sickness but nothing really worked. I'm glad to see that you've included those aspects in your module.

I have tried ASLW, but it presents issues with wildly fluctuating values (even at high depths), especially with the way I calculate ascent time. ASL is less accurate but gives more stable readings, so I went that route.

Love the script is it possible to make it so the palyer does not have to be a diver and can be any character and just needs to have a re breather equipped ?

i have a mission where half way through u need to equip diving gear and would love to use this script however it gets a bit buggy i think due to changing uniforms , any insight?

Cheer,

Roman

Hmm. The script does not detect changes in unit type or gear (i need to fix that actually). What specific bugs are you encountering?

Man... BIS is good.

http://community.bistudio.com/wiki/getPosASLW

However, I've been told (haven't seen it for myself) that waves are client side and not synced - so if you are diving with mates you could potentially be in the exact same position underwater and the getPosASLW command would potentially return different values. So depending on a bit of luck you could have different bottom times for the same exact dive in Co-Op.... Is this right?

---------- Post added at 12:23 ---------- Previous post was at 11:38 ----------

Okay - just tried using the script and getting an error in Editor (DEV build). Getting Type Script, expected Nothing.

That error is common when you try to run SQF without a handle. For example [this, 25, 1500] execVM "blah.sqf" will not work, instead use: null = [this, 25, 1500] execVM "blah.sqf"

Share this post


Link to post
Share on other sites
That error is common when you try to run SQF without a handle. For example [this, 25, 1500] execVM "blah.sqf" will not work, instead use: null = [this, 25, 1500] execVM "blah.sqf"

Thanks, that worked. Really enjoying the mod actually. Looking forward to future updates. I use the dev branch and found it a bit glitchy (ascent time was jumping around like crazy) but that could just be the dev branch. The sound effects are great. Is there any reason it wont let you go beyond 80ft?

Share this post


Link to post
Share on other sites
Love the script is it possible to make it so the palyer does not have to be a diver and can be any character and just needs to have a re breather equipped ?

i have a mission where half way through u need to equip diving gear and would love to use this script however it gets a bit buggy i think due to changing uniforms , any insight?

Cheer,

Roman

You could check to see if the player has a vest: http://community.bistudio.com/wiki/vest

if (underwater _diver && vest _diver == "V_RebreatherB") then {divestatus} // just a guess not tested

Share this post


Link to post
Share on other sites
Thanks, that worked. Really enjoying the mod actually. Looking forward to future updates. I use the dev branch and found it a bit glitchy (ascent time was jumping around like crazy) but that could just be the dev branch. The sound effects are great. Is there any reason it wont let you go beyond 80ft?

Hey glad you got it working. Ascent time is a little glitchy but I have ideas on how to fix it. I'll be releasing an update some time tomorrow with some fixes. With regard to the warning tone, it's indirectly related to depth, and reflects the level of Nitrogen tissue saturation (the bars on the left of the display). I need to tweak some variables because you are right, it goes off a little early. Basically, without adding a lot of more complex features (like decompression/deep/safety stops and the consequences of neglecting them) there really is no penalty (other than annoyance) for going past the recommended tissues saturation limit.

@Cobra

I'll look into that tomorrow, but moving the display and all the text is a royal pain.

Edited by trini scourge

Share this post


Link to post
Share on other sites

Yes well IRL if I was to dive to 80ft straight away my tissue saturation would be negligible because I haven't been deep for long enough for my body tissues to absorb the nitrogen. Time at depth inhaling highly compressed air is what causes nitrogen absorption. Its the ascent where you have to be careful that your body can dispose of the nitrogen (you probably know this).

Share this post


Link to post
Share on other sites
Yes well IRL if I was to dive to 80ft straight away my tissue saturation would be negligible because I haven't been deep for long enough for my body tissues to absorb the nitrogen. Time at depth inhaling highly compressed air is what causes nitrogen absorption. Its the ascent where you have to be careful that your body can dispose of the nitrogen (you probably know this).

Yes you are absolutely right but tissue saturation rate is one of the abstractions that I'm willing to make in order to simplify the player experience (not to mention my sanity).

Semi-Accurate calculation of real tissue absorption rates requires a metric crapload of complex variables tracking everything from partial alveolar pressure to tissue halftimes (which are different depending on the type of tissue). The mathematics for all this technically works, but collapses when placed in the context of a videogame that allows the player to swim 10ft/sec. That being said, I do have a version that uses the Schreiner Equation to determine partial pressure of the gas in the tissue, but like i said previously it doesn't work that well in the context of Arma.

The Equation:

Pt (t) = Palv + R[t + −R/k] − [Palv − Pt −R/k]e^−kt

In the script:

_nConst (partial pressure of gas in tissue) = _pAlv + _rNAmb *(_diveTime +((-1) *(_rNamb/_tisK))) - (_pAlv -0.736 - (_rNAmb/_tisK) *(exp _tisConst))

where:

_pAlv (partial alveolar pressure) = 0.78 *((constAmbPressure -0.0627) + (((1 -0.9)/0.9) *0.0534))

_rNAmb (rate of chage of partial inert gas pressure) = (pressureDiff * 0.78)/60

_tisK (tissue halflife) = (ln 2)/4

_tisConst = _tisK * Dive time

Perhaps my math is wrong (I'm definitely not a math brain) so i'll gladly accept any help here.

Share this post


Link to post
Share on other sites

first thanks for this nice script very nice work...!!!but i have 1 problem guys i hope somone can help me out ... the problem is if i use this script in my dive coop mission and is more from 1 player online the script not work and the display status buging as hell ..!!i lose the display if somone login in my mission and if this guy go to water to with me i see some time the display with status from this guy not mine...!!!so any way for this problem here????

Share this post


Link to post
Share on other sites
first thanks for this nice script very nice work...!!!but i have 1 problem guys i hope somone can help me out ... the problem is if i use this script in my dive coop mission and is more from 1 player online the script not work and the display status buging as hell ..!!i lose the display if somone login in my mission and if this guy go to water to with me i see some time the display with status from this guy not mine...!!!so any way for this problem here????

Sorry about that Angelo. Thanks for trying the script out. I guess i should clarify that in it's current state, SP is the focus.

To be honest, I really don't know how to make this script MP compatible. This is really my first foray into sqf and I have a lot left to learn. Hopefully one of the other helpful lads can be of assistance.

Share this post


Link to post
Share on other sites

trini

For singleplayer and hosted MP this should work.

if (isServer && !isDedicated) then {diverstatus};

while {alive _diver && _psi >= 0 && player == _diver} do {the rest of the script.....

I didnt want to upload an example without permission since I made some changes of my own.

This is what the diverstats should look like.

/*
Script: diverstats.sqf

Created By: triniscourge

Description:
Creates a diving gauge for depth, pressure, oxygen, etc.

Parameter(s):
_this select 0: this is the diver
_this select 1: (optional) user defined Surface Air Consumption Rate (Imperial)
_this select 2: (optional) user defined tank size (abstracted to psi)
_this select 3: (optional) disposable tank
_this select 4: (optional) debug

Example(s):
null = [this, 25, 3000,true] execVM "diverstats.sqf" //disposable tank
null = [this,25,3000,false] execVM "diverstats.sqf"//rebreather
null = [this] execVM "diverstats.sqf"
*/

_diver = _this select 0;
_sacRT = if (count _this > 1) then {_this select 1} else {-25}; 
_tankSize = if (count _this > 2) then {_this select 2} else {2500}; //

//Starting PSI of a full tank.
_psi = _tankSize;

_airConsumption = 0;
_ascTime = 0;
_maxDepth = 0;
_timeleft = 0;
_diveTime = 0;
_diverBearing = 0;

//---Depth Variables---
_depth = 0;
_depthA = 0;
_depthB = 0;
_dDepth = 0;

//---Pressure Variables---
_pressure = 0;

//---Gas Variables---
_oTot = 0;
_nTot = 0;
_nPerc = 0;
_oPerc = 0;
_tempC = 22;
_tempF = 0;
_tempK = 0;
_nConst = 0;

if (isServer && !isDedicated) then {

private "_pGridPos";

while {alive _diver && _psi >= 0 && player == _diver} do {
	if (underwater _diver) then {

		_pGridPos = mapGridPosition _diver;

		//Main display elements						
		disableSerialization;
		2 cutRsc ["trin_disp","PLAIN"];
		_displayUI = uiNamespace getVariable 'trin_disp';
		(_displayUI displayCtrl 1111) ctrlSetText format["%1",[((round(_ascTime))/60)+.01,"HH:MM"] call bis_fnc_timetostring];
		(_displayUI displayCtrl 1112) ctrlSetText format["%1",(round(_depth *10))/10];
		(_displayUI displayCtrl 1113) ctrlSetText format["%1",[((_diveTime)/60)+.01,"HH:MM"] call bis_fnc_timetostring];
		(_displayUI displayCtrl 1114) ctrlSetText format["%1",(round(_maxDepth *10))/10];
		(_displayUI displayCtrl 1115) ctrlSetText format["%1",[((_timeleft)/60)+.01,"HH:MM"] call bis_fnc_timetostring];
		(_displayUI displayCtrl 1116) ctrlSetText format["%1",(round(_pressure *10))/10];
		(_displayUI displayCtrl 1117) ctrlSetText format["%1",round(_airConsumption)];
		(_displayUI displayCtrl 1118) ctrlSetText format["%1",round(_psi)];			
		(_displayUI displayCtrl 1121) ctrlSetText format["%1",(round(_dDepth *10))/10];
		(_displayUI displayCtrl 1122) ctrlSetText format["%1",(round(_nPerc *10))/10];
		(_displayUI displayCtrl 1126) ctrlSetText format["%1",round(_diverBearing)];
		(_displayUI displayCtrl 1127) ctrlSetText format["%1 C | %2 K",(round(_tempC *10))/10, (round(_tempF *10))/10];
		(_displayUI displayCtrl 1128) ctrlSetText format["POS: %1",_pGridPos];			

		_diveTime = _diveTime + 1;
		_depth = (((getPosASLW _diver) select 2)* -3.28); //Conversion to feet (inverted for pressure calculation)
		_pressure = ((_depth / 33) + 1);
		_diverBearing = getdir _diver;

		//---N2/O2 Total gas volume calculation; See scripts\trin_fn_gasCalc.sqf---
		_tempK = _tempC + 273.15;
		_tempF = (_tempC *1.8) +32;
		_nTot = [_pressure, 0.78, 1600, _tempK] call getGasTot;
		_oTot = [_pressure, 0.31, 756.7, _tempK] call getGasTot;
		_nPerc = ((_nTot /1000)/5) *100;
		_oPerc = ((_oTot /1000)/5) *100;			

		_airConsumption = (_pressure * _sacRT);
		_psi = (_psi - (_airConsumption /60));
		_timeleft = ((_psi / _airConsumption) *60);
		_depthA = (((getPosASLW _diver) select 2)* -3.28);			

		//Display elements for ascent indicators			
		switch (true) do {
			case (_dDepth > 0): {
				(_displayUI displayCtrl 1119) ctrlSetText "images\upArrow.paa";
				(_displayUI displayCtrl 1120) ctrlSetText "^";
			};
			case (_dDepth < 0): {
				(_displayUI displayCtrl 1119) ctrlSetText "images\downArrow.paa";
				(_displayUI displayCtrl 1120) ctrlSetText "v";
			};
			case (_dDepth == 0): {
				(_displayUI displayCtrl 1119) ctrlSetText "images\noArrow.paa";
				(_displayUI displayCtrl 1120) ctrlSetText "";
			};						 					
		};

		//Display element for ascent warning
		if (_dDepth > 8) then {(_displayUI displayCtrl 1125) ctrlSetText "FAST ASCENT!"; playSound "trin_dispExit"};	

		//Display elements for tissue saturation
		switch (true) do {
			case (_nConst <= 0): {(_displayUI displayCtrl 1124) ctrlSetText "images\tis_1.paa"};	
			case ((_nConst > 0) && (_nConst <= 0.32)): {(_displayUI displayCtrl 1124) ctrlSetText "images\tis_1.paa"};
			case ((_nConst > 0.32) && (_nConst <= 0.44)): {(_displayUI displayCtrl 1124) ctrlSetText "images\tis_2.paa"};
			case ((_nConst > 0.44) && (_nConst <= 0.66)): {(_displayUI displayCtrl 1124) ctrlSetText "images\tis_3.paa"};
			case ((_nConst > 0.66) && (_nConst <= 0.88)): {(_displayUI displayCtrl 1124) ctrlSetText "images\tis_4.paa"};
			case ((_nConst > 0.88) && (_nConst <= 1.1)): {(_displayUI displayCtrl 1124) ctrlSetText "images\tis_5.paa"};
			case ((_nConst > 1.1) && (_nConst <= 1.32)): {(_displayUI displayCtrl 1124) ctrlSetText "images\tis_6.paa"};
			case ((_nConst > 1.32) && (_nConst <= 1.54)): {(_displayUI displayCtrl 1124) ctrlSetText "images\tis_7.paa"};
			case ((_nConst > 1.54) && (_nConst <= 1.76)): {(_displayUI displayCtrl 1124) ctrlSetText "images\tis_8.paa"};
			case ((_nConst > 1.76) && (_nConst <= 1.98)): {playSound "trin_dispWarn";(_displayUI displayCtrl 1124) ctrlSetText "images\tis_9.paa"};
			case (_nConst > 1.98): {playSound "trin_dispWarn";(_displayUI displayCtrl 1124) ctrlSetText "images\tis_9.paa"};	
		};

		sleep 1; //---DO NOT CHANGE --- All time based calculations dependent on value.			

		_depthB = (((getPosASLW _diver) select 2)* -3.28);			
		_dDepth = _depthA - _depthB;				

		//Nitrogen tissue saturation (fudged not simulated)
		if (_nConst < _nPerc) then {_nConst = _nPerc};

		switch (true) do {
			case (_depthB > _depthA): {_nConst = _nConst + ((_nConst/1000) *(_pressure/100)); _tempC = _tempC + (_dDepth *0.0004)};
			case (_depthA >= _depthB): {_nConst = _nConst - ((_nConst/10) *(_pressure/10))};
		};			

		//Calculate Max Depth so far
		if ((_depthB > _depthA) && (_maxDepth < _depthB)) then {_maxDepth = _depthB};			

		//Calculate ascending time and temperature change at depth					
		if (_depthA > _depthB) then {_ascTime = _depth / _dDepth;_tempC = _tempC + (_dDepth *0.0004)} else {_ascTime = 0;_tempC = _tempC};

		// Running out of air results in tanks being discarded.
		if (_psi < 0) then {removeVest _diver};
	};

	2 cutText ["","PLAIN"];	

};
};

Edited by cobra4v320

Share this post


Link to post
Share on other sites
trini

For singleplayer and hosted MP this should work.

if (isServer && !isDedicated) then {diverstatus};

while {alive _diver && _psi >= 0 && player == _diver} do {the rest of the script.....

I didnt want to upload an example without permission since I made some changes of my own.

This is what the diverstats should look like.

/*
Script: diverstats.sqf

Created By: triniscourge

Description:
Creates a diving gauge for depth, pressure, oxygen, etc.

Parameter(s):
_this select 0: this is the diver
_this select 1: (optional) user defined Surface Air Consumption Rate (Imperial)
_this select 2: (optional) user defined tank size (abstracted to psi)
_this select 3: (optional) disposable tank
_this select 4: (optional) debug

Example(s):
null = [this, 25, 3000,true] execVM "diverstats.sqf" //disposable tank
null = [this,25,3000,false] execVM "diverstats.sqf"//rebreather
null = [this] execVM "diverstats.sqf"
*/

_diver = _this select 0;
_sacRT = if (count _this > 1) then {_this select 1} else {-25}; 
_tankSize = if (count _this > 2) then {_this select 2} else {2500}; //

//Starting PSI of a full tank.
_psi = _tankSize;

_airConsumption = 0;
_ascTime = 0;
_maxDepth = 0;
_timeleft = 0;
_diveTime = 0;
_diverBearing = 0;

//---Depth Variables---
_depth = 0;
_depthA = 0;
_depthB = 0;
_dDepth = 0;

//---Pressure Variables---
_pressure = 0;

//---Gas Variables---
_oTot = 0;
_nTot = 0;
_nPerc = 0;
_oPerc = 0;
_tempC = 22;
_tempF = 0;
_tempK = 0;
_nConst = 0;

if (isServer && !isDedicated) then {

   private "_pGridPos";

   while {alive _diver && _psi >= 0 && player == _diver} do {
       if (underwater _diver) then {

           _pGridPos = mapGridPosition _diver;

           //Main display elements                        
           disableSerialization;
           2 cutRsc ["trin_disp","PLAIN"];
           _displayUI = uiNamespace getVariable 'trin_disp';
           (_displayUI displayCtrl 1111) ctrlSetText format["%1",[((round(_ascTime))/60)+.01,"HH:MM"] call bis_fnc_timetostring];
           (_displayUI displayCtrl 1112) ctrlSetText format["%1",(round(_depth *10))/10];
           (_displayUI displayCtrl 1113) ctrlSetText format["%1",[((_diveTime)/60)+.01,"HH:MM"] call bis_fnc_timetostring];
           (_displayUI displayCtrl 1114) ctrlSetText format["%1",(round(_maxDepth *10))/10];
           (_displayUI displayCtrl 1115) ctrlSetText format["%1",[((_timeleft)/60)+.01,"HH:MM"] call bis_fnc_timetostring];
           (_displayUI displayCtrl 1116) ctrlSetText format["%1",(round(_pressure *10))/10];
           (_displayUI displayCtrl 1117) ctrlSetText format["%1",round(_airConsumption)];
           (_displayUI displayCtrl 1118) ctrlSetText format["%1",round(_psi)];            
           (_displayUI displayCtrl 1121) ctrlSetText format["%1",(round(_dDepth *10))/10];
           (_displayUI displayCtrl 1122) ctrlSetText format["%1",(round(_nPerc *10))/10];
           (_displayUI displayCtrl 1126) ctrlSetText format["%1",round(_diverBearing)];
           (_displayUI displayCtrl 1127) ctrlSetText format["%1 C | %2 K",(round(_tempC *10))/10, (round(_tempF *10))/10];
           (_displayUI displayCtrl 1128) ctrlSetText format["POS: %1",_pGridPos];            

           _diveTime = _diveTime + 1;
           _depth = (((getPosASLW _diver) select 2)* -3.28); //Conversion to feet (inverted for pressure calculation)
           _pressure = ((_depth / 33) + 1);
           _diverBearing = getdir _diver;

           //---N2/O2 Total gas volume calculation; See scripts\trin_fn_gasCalc.sqf---
           _tempK = _tempC + 273.15;
           _tempF = (_tempC *1.8) +32;
           _nTot = [_pressure, 0.78, 1600, _tempK] call getGasTot;
           _oTot = [_pressure, 0.31, 756.7, _tempK] call getGasTot;
           _nPerc = ((_nTot /1000)/5) *100;
           _oPerc = ((_oTot /1000)/5) *100;            

           _airConsumption = (_pressure * _sacRT);
           _psi = (_psi - (_airConsumption /60));
           _timeleft = ((_psi / _airConsumption) *60);
           _depthA = (((getPosASLW _diver) select 2)* -3.28);            

           //Display elements for ascent indicators            
           switch (true) do {
               case (_dDepth > 0): {
                   (_displayUI displayCtrl 1119) ctrlSetText "images\upArrow.paa";
                   (_displayUI displayCtrl 1120) ctrlSetText "^";
               };
               case (_dDepth < 0): {
                   (_displayUI displayCtrl 1119) ctrlSetText "images\downArrow.paa";
                   (_displayUI displayCtrl 1120) ctrlSetText "v";
               };
               case (_dDepth == 0): {
                   (_displayUI displayCtrl 1119) ctrlSetText "images\noArrow.paa";
                   (_displayUI displayCtrl 1120) ctrlSetText "";
               };                                             
           };

           //Display element for ascent warning
           if (_dDepth > 8) then {(_displayUI displayCtrl 1125) ctrlSetText "FAST ASCENT!"; playSound "trin_dispExit"};    

           //Display elements for tissue saturation
           switch (true) do {
               case (_nConst <= 0): {(_displayUI displayCtrl 1124) ctrlSetText "images\tis_1.paa"};    
               case ((_nConst > 0) && (_nConst <= 0.32)): {(_displayUI displayCtrl 1124) ctrlSetText "images\tis_1.paa"};
               case ((_nConst > 0.32) && (_nConst <= 0.44)): {(_displayUI displayCtrl 1124) ctrlSetText "images\tis_2.paa"};
               case ((_nConst > 0.44) && (_nConst <= 0.66)): {(_displayUI displayCtrl 1124) ctrlSetText "images\tis_3.paa"};
               case ((_nConst > 0.66) && (_nConst <= 0.88)): {(_displayUI displayCtrl 1124) ctrlSetText "images\tis_4.paa"};
               case ((_nConst > 0.88) && (_nConst <= 1.1)): {(_displayUI displayCtrl 1124) ctrlSetText "images\tis_5.paa"};
               case ((_nConst > 1.1) && (_nConst <= 1.32)): {(_displayUI displayCtrl 1124) ctrlSetText "images\tis_6.paa"};
               case ((_nConst > 1.32) && (_nConst <= 1.54)): {(_displayUI displayCtrl 1124) ctrlSetText "images\tis_7.paa"};
               case ((_nConst > 1.54) && (_nConst <= 1.76)): {(_displayUI displayCtrl 1124) ctrlSetText "images\tis_8.paa"};
               case ((_nConst > 1.76) && (_nConst <= 1.98)): {playSound "trin_dispWarn";(_displayUI displayCtrl 1124) ctrlSetText "images\tis_9.paa"};
               case (_nConst > 1.98): {playSound "trin_dispWarn";(_displayUI displayCtrl 1124) ctrlSetText "images\tis_9.paa"};    
           };

           sleep 1; //---DO NOT CHANGE --- All time based calculations dependent on value.            

           _depthB = (((getPosASLW _diver) select 2)* -3.28);            
           _dDepth = _depthA - _depthB;                

           //Nitrogen tissue saturation (fudged not simulated)
           if (_nConst < _nPerc) then {_nConst = _nPerc};

           switch (true) do {
               case (_depthB > _depthA): {_nConst = _nConst + ((_nConst/1000) *(_pressure/100)); _tempC = _tempC + (_dDepth *0.0004)};
               case (_depthA >= _depthB): {_nConst = _nConst - ((_nConst/10) *(_pressure/10))};
           };            

           //Calculate Max Depth so far
           if ((_depthB > _depthA) && (_maxDepth < _depthB)) then {_maxDepth = _depthB};            

           //Calculate ascending time and temperature change at depth                    
           if (_depthA > _depthB) then {_ascTime = _depth / _dDepth;_tempC = _tempC + (_dDepth *0.0004)} else {_ascTime = 0;_tempC = _tempC};

           // Running out of air results in tanks being discarded.
           if (_psi < 0) then {removeVest _diver};
       };

       2 cutText ["","PLAIN"];    

   };
};

Thanks a lot Cobra. Saved me some hours of research :)

I've had a breakthrough with the calculation of tissue saturation (using The Buhlmann ZH-L16 model now). The new version will feature deco stops, deep stops, accurate tissue simulation and user created breathing gas mixtures (any combination of O2,N2 or He).

It should be ready for testing by tomorrow.

Share this post


Link to post
Share on other sites
Thanks a lot Cobra. Saved me some hours of research :)

I've had a breakthrough with the calculation of tissue saturation (using The Buhlmann ZH-L16 model now). The new version will feature deco stops, deep stops, accurate tissue simulation and user created breathing gas mixtures (any combination of O2,N2 or He).

It should be ready for testing by tomorrow.

Woohoo - PM me if you want me to test it out before you post it. I'll even get out my diving tables :D

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×