Jump to content
Sign in to follow this  
easyeb

Open helicopter doors at altitude below 3 meters

Recommended Posts

Hi all!

I have a scripting challange for you! Yes, much exciting!

Is it possible to make a script that opens all Ghosthawk and Huron doors when the vehicle is below three meters altitude and then close them up when they get above 3m altitude?

As always, cheers!

Share this post


Link to post
Share on other sites

Add this command in init field:

this execVM "watchForAltitude.sqf";

watchForAltitude.sqf:

while {true} do {
_position = getPosASL _this;

if (!(surfaceIsWater _position)) then {_position = ASLtoATL _position};

_altitude = _position select 2;

if (_altitude <= 3) then {
	switch (true) do {
		case (_this isKindOf "B_Heli_Transport_01_F"): {
			{_this animateDoor _x} forEach [
				[_doorname, _phase, _now],
				...
			];
		};
		case (_this isKindOf "B_Heli_Transport_03_base_F"): {
			{_this animateDoor _x} forEach [
				[_doorname, _phase, _now],
				...
			];
		};
	};
}
else {
	switch (true) do {
		case (_this isKindOf "B_Heli_Transport_01_F"): {
			{_this animateDoor _x} forEach [
				[_doorname, _phase, _now],
				...
			];
		};
		case (_this isKindOf "B_Heli_Transport_03_base_F"): {
			{_this animateDoor _x} forEach [
				[_doorname, _phase, _now],
				...
			];
		};
	};
};

sleep 0.1;
};

_doorname, _phase and _now you need to take from configs of Ghosthawk and Huron (use config viewer).

Share this post


Link to post
Share on other sites

Adapt to other helicopters

if (!isServer) exitWith {};

private ["_veh","_alt","_speed"];

_veh = _this select 0;

switch (typeof _veh) do {
   // UH-80 Ghost Hawk
   case "B_Heli_Transport_01_F": {
   while {alive _veh} do {
     sleep 0.5;
     _alt = getPos _veh select 2;
     _speed = (sqrt ((velocity _veh select 0)^2 + (velocity _veh select 1)^2 + (velocity _veh select 2)^2));
     if ((_alt < 8) && (_speed < 12)) then {
       _veh animateDoor ['door_R',1]; 
       _veh animateDoor ['door_L',1];
     } else {
       _veh animateDoor ['door_R',0]; 
       _veh animateDoor ['door_L',0];
     };
   };
 };

Share this post


Link to post
Share on other sites

Thanks guys! Have not gotten it working yet though, but I apreciate your answering!

Edbusana, this goes where? init.sqf? Have had no luck so far. I can see what the script does, I just can't get it to fire up.

Share this post


Link to post
Share on other sites

Put it in the init of the chopper with the following call line:

0 = [this] execVM "watchForAltitude.sqf";

Share this post


Link to post
Share on other sites

Create file example: door.sqf

copy and paste script

In init helicopter put => 0 = [this] execVM "door.sqf";

Share this post


Link to post
Share on other sites

Thanks guys! Will fiddle around with this :)

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  

×