Jump to content
Sign in to follow this  
silentkiller*

[HELP] Script for exchange air

Recommended Posts

Hi everyone,

I'm making this script for allow diver to exchange their oxygen, but i'm a little newbie with arma scripting (but i'm a programmer and this help a lot in understanding arma scripting :D).

In particular this is a script for emulate the emergency diver procedure used in case of end-air (like SCUBA-Diver manual).

I'm initializing the player (now is only for test) with this in init code:

this addAction["Give Air","GiveAir.sqf",[this],0];

And the GiveAir.sqf file is:

_Me=_this select 2;
_Me=_Me select 0;
_Source= nearestObject[_Me,"B_diver_TL_F"];

if(_Source getOxygenRemaining >= 0.2) then
{_Source setOxygenRemaining (_Source getOxygenRemaining)-0.2;

  if((_Me getOxygenRemaining)<0.8) 
    then {_Me setOxygenRemaining (_Me getOxygenRemaining + 0.2)} 
    else {hint "You bomble is full!";};}
else{
hint "Not enought air in target to get.";};

This script receive (if i've understand good) the object who have called the action (the [this] in init line) inside an array, so auto-clean itself with an assignment of the first object in the array received (the second line), it take the nearest player of type "B_diver_TL_F" (i'll limit the distance next) and verify if they have enought oxygen (else print "Not enought air in target to get"; if the player have enought it verify if there's enought space in bomble to get air, if it is the script remove the oxygen to other diver and allocate that to the caller, if not true it prompt "Your bomble is full!".

But i don't understand why it doesn't work.. any suggestion?

Thanks and regards.

Share this post


Link to post
Share on other sites

sooooo, you got me curious about the air thing and i been toying with it a bit. but i dont think its for divers (they use rebreathers) i believe its for regular units without rebreather. they can only hold there breath for so long. thats where those commands come in. i say this because unsing the hintsilent format to monitor air of diver is always at 1 - full, even if this is in his init field:

this setOxygenRemaining 0; 

Share this post


Link to post
Share on other sites

Wow, I can see this going the way of CPR with tweak scripting an additional animation... but would you really want to see that?

Share this post


Link to post
Share on other sites

In my opinion, the OxygenRemaining will be used for see the amount of rebreather (who, we guess, have a limited use).

You can try it simply by making a script like:

HintAir.sqf

while{"a"=="a"} do {
hint format[Remaining oxygen: %1, this getOxygenRemaining];
sleep 5;
};

And initializing it to player by adding in init:

null = [] execVM "HintAir.sqf";

If i've understanded the ArmA scripting enought, this will hint every 5 seconds how much air you have, in this way:

"while" will have always a true condition because any letter is ever equal for himself.

"this getOxygenRemaining" will get how oxygen do you have and return a number who is take by "format" who set that number in "%1" area and return a String.

"hint" take the string and display that in game

"sleep 5" will cause a delay of 5 seconds before follow

than the cicle restart.

If i'm wrong anywhere please feel free to correct me.

Share this post


Link to post
Share on other sites

Hello, i'm new to scripting also, but from what i've tried so far and understood is that the addAction command call the script with 4 arguments being the first the target (target: Object - the object which the action is assigned to) the second the caller (caller: Object - the unit that activated the action) the third the ID (ID: Integer - ID of the activated action) and the forth aditional parameters for your script (arguments: Anything - arguments given to the script if you are using the extended syntax).

So this being said when you do the _this select 2 you are selecting the ID, probably not the thing you need.

So you probably dont need the "this addAction["Give Air","GiveAir.sqf",[this],0];" if you want to get the caller just do "_this select 1"

So suming up what i tried to say, when you use the addAction method what it does is passing to your script the arguments in something like this ["the target","the caller","ID","additional arguments you want for your script"]

Hope it is'nt too confusing :p

Share this post


Link to post
Share on other sites

Ok for the filling i would do something like this

GiveAir.sqf:

private ["_me","_oxygen"];
_me = _this select 1;
_oxygen = getOxygenRemaining _me;
if (_oxygen<= 0.2) then
{
 _me setOxygenRemaining 1;
};
if(_oxygen > 0.8) then
{
 hint "Your oxygen tank is full!";
};

now im not sure if it is totally right, but its a start i guess, good luck

Share this post


Link to post
Share on other sites

This template can work according to my opini

---------- Post added at 07:22 ---------- Previous post was at 07:20 ----------

*opinion, but don't do what i want: this give air and i want to take air..

---------- Post added at 07:23 ---------- Previous post was at 07:22 ----------

And, this give air to himself by creating it, also a wrong script logic xD

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  

×