Jump to content
dreadedentity

Automatic landing gear for helicopters

Recommended Posts

Hello, been a while. Anyway, I am back with a new script, starting off small as I try to get back into the swing of arma scripting. This is just for helicopters, although I think it would work for airplanes. Actually, the majority of helicopters don't have retractable landing gear, so it's really just for the ghost hawk, huron, and mohawk. There might be others, but I got bored of checking. Anyway, if it has retractable landing gears, this will work, and not to toot my own horn or anything but the effect is damn cool

 

So without further delay, here's the code (github):

Spoiler

NEEDS_GEAR_CHANGE = true;
PLAYER_HEIGHT_STATE = 0;
private ["_action", "_veh", "_height"];
_action = "LandGear";
while {true} do {
	if (vehicle player != player) then {
		_veh = vehicle player;
		_height = (getPosATL _veh) select 2;
		if (speed _veh < 50) then {
			if (_height > 5) then {
				if (PLAYER_HEIGHT_STATE == 0) then {
					PLAYER_HEIGHT_STATE = 1;
					NEEDS_GEAR_CHANGE = true;
					_action = "LandGearUp";
				};
			} else {
				if (PLAYER_HEIGHT_STATE == 1) then {
					PLAYER_HEIGHT_STATE = 0;
					NEEDS_GEAR_CHANGE = true;
					_action = "LandGear";
				};
			};
			if (NEEDS_GEAR_CHANGE) then { _veh action [_action, _veh];NEEDS_GEAR_CHANGE = false; };
		};
	};
	sleep 1;
};

This should be put in a code block and run via spawn due to the use of sleep.

 

As always, this script is meant for noobs to learn from; by showing something pretty cool you can do with scripting, and as a bonus the effect is actually semi-usable

 

Have fun,

DE

  • Like 3
  • Thanks 1

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

×