Jump to content
Sign in to follow this  
wyattwic

[Snipplet] Open ghosthawk doors based on altitude

Recommended Posts

Here is my neat little snipplet that will open ghosthawk doors based on altitude.

I couldn't find one already out there, so here it is.

Somewhere in the vehicle init

null = [this] execvm "ghosthawkdoors.sqf";

ghosthawkdoors.sqf

	
_unit = _this select 0; 


_doorstate = false;
while {alive _unit} do {
	_alt = getposatl _unit select 2;


	// If under 10 altitude and doors are already closed, open them.
	if ((_alt <= 10) && !(_doorstate)) then {
		_unit animateDoor ['door_R', 1]; 
		_unit animateDoor ['door_L', 1];
		_doorstate = true;
		};


	// If over 10 altitude and doors are open then close them.
	if ((_alt > 10) && (_doorstate)) then {
		_unit animateDoor ['door_R', 0]; 
		_unit animateDoor ['door_L', 0]; 
		_doorstate = false;
		};

	//Slow the script down some.  This is not a critical loop.
	sleep 7;
};

This setup assumes that the doors are closed on start by default, as BIS had them set.

If anyone sees an error, it would be a big help.

Edited by Wyattwic

Share this post


Link to post
Share on other sites

That's great. Beats the hell out of setting open or close at different waypoints. Thanks for posting this.

Share this post


Link to post
Share on other sites

Oh neat. Cheers.

---------- Post added at 14:19 ---------- Previous post was at 14:16 ----------

(_doorstate == false)

Shouldn't the condition be just !(_doorstate) ?

while {alive _unit} do {
       _alt = getposatl _unit select 2;


       // If under 10 altitude and doors are already closed, open them.
       if ((_alt <= 10) && !(_doorstate)) then {
           _unit animateDoor ['door_R', 1]; 
           _unit animateDoor ['door_L', 1];
           _doorstate = true;
           };


       // If over 10 altitude and doors are open then close them.
       if ((_alt > 10) && (_doorstate)) then {
           _unit animateDoor ['door_R', 0]; 
           _unit animateDoor ['door_L', 0]; 
           _doorstate = false
           };

       //Slow the script down some.  This is not a critical loop.
       sleep 7;
   };  

Share this post


Link to post
Share on other sites

Yea, that works. What I get for seeing almost anything as a string. Updating it.

EDIT: that and I found a few syntax errors. lol.

Share this post


Link to post
Share on other sites

Sweet idea.

Personally, I would rather check for both the altitude AND the velocity of the chopper.

Share this post


Link to post
Share on other sites

Do closed doors improve the top speed of the aircraft?

Curious if the simulation is that detailed?

Share this post


Link to post
Share on other sites

I highly doubt it.

Though you could easily script them to do that.

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  

×