Jump to content
nullrick

Script for auto opening Huron's cargo door? (dev branch)

Recommended Posts

Apart from hopelessly trying to get AI to open the Huron's cargo door open, I'm now left wondering if there's just a script to have it open througout the mission.

Share this post


Link to post
Share on other sites

Have you tried animateDoor ?

myHelo animateDoor ["door_rear", 1, false];

init.sqf

myHelo addAction ["Toggle Door", {
private [ "_state" ];
_state = ( _this select 0 ) doorPhase "door_rear";
if ( _state == 0 ) then {
	( _this select 0 ) animateDoor ["Door_rear", 1, false];
} else {
	( _this select 0 ) animateDoor ["Door_rear", 0, false];
};
}];

Edited by Iceman77

Share this post


Link to post
Share on other sites

I don't know what's wrong, but it's not working. Tried both ways and changed "myHelo" to what I needed. I changed it to ["door_rear", 1, true]; and other values as well. Maybe the Huron doesn't have properly designated doors for scripts yet?

Share this post


Link to post
Share on other sites

You're both glorious! Thank you very much! Especially for that sources list, Ranger.

Share this post


Link to post
Share on other sites

I did this for another thread in the A3 Q&A Forum, but I figured it's relevant here as well, for those interested.

Binds user custom action keys #9 and #10 to open/close the rear ramp of the Huron:

//in the init.sqf
if (hasInterface && !isDedicated) then { 

_animateDoors = (findDisplay 46) displayAddEventHandler ["KeyDown",  
{  

   _handled = false;  

   if ((_this select 1) in (actionKeys "User9") && ((typeOf vehicle player) == "B_Heli_Transport_03_F")) then  
   {  
          (vehicle player) animateDoor ["Door_rear_source", 0];
          _handled = true;
   };  

   if ((_this select 1) in (actionKeys "User10") && ((typeOf vehicle player) == "B_Heli_Transport_03_F")) then  
   {  
          (vehicle player) animateDoor ["Door_rear_source", 1];
          _handled = true;
   };  

   _handled;

 };   

};

EDIT: For those of you who only want to define one user action key (this is cleaned up a bit as well :D):

//in the init.sqf
if (hasInterface && !isDedicated) then { 

_animateDoors = (findDisplay 46) displayAddEventHandler ["KeyDown",  
{  
	_veh = vehicle player;
	_handled = false;  

	if ((_this select 1) in (actionKeys "User9") && ((typeOf _veh) == "B_Heli_Transport_03_F")) then  
	{  
		if (((_veh) doorPhase "Door_rear_source") > 0) then {

			(_veh) animateDoor ["Door_rear_source", 0];
			_handled = true;

		} else {

			(_veh) animateDoor ["Door_rear_source", 1];
			_handled = true;
		};
	};
   _handled;
 };  

};

Edited by JShock
  • Like 1

Share this post


Link to post
Share on other sites

Hey I know this thread is old, but I'm having an issue. The heli1 AnimateDoor ["Door_rear_source", 1, true] code changes the rear ramp from closed to open instantly, without the animation of it actually opening. 

I found somewhere a script that does allow for the animated opening of the ramp but cannot, for the life of me, find it anywhere anymore.

Do any of you know what I'm talking about? And can anyone please help?

 

Thank you,

Rabbit

Share this post


Link to post
Share on other sites
12 minutes ago, intrepid_rabbit said:

Hey I know this thread is old, but I'm having an issue. The heli1 AnimateDoor ["Door_rear_source", 1, true] code changes the rear ramp from closed to open instantly, without the animation of it actually opening. 

I found somewhere a script that does allow for the animated opening of the ramp but cannot, for the life of me, find it anywhere anymore.

Do any of you know what I'm talking about? And can anyone please help?

 

Thank you,

Rabbit

 

Just use "false" as the third parameter of this command:

heli1 AnimateDoor ["Door_rear_source", 1, false]

 

  • Like 1

Share this post


Link to post
Share on other sites

Pushing my luck i know, but since the thread is active again;  
Would it be possible to see this if the heli is under say 10 feet of the ground?

So the doors open and close as it lands or takes off?

  • Like 1

Share this post


Link to post
Share on other sites
42 minutes ago, stegman said:

Would it be possible

 

It's Arma!

Quick and dirty:

//give your helicopter the variable name "heli1"

//paste into heli1's init field:

[] spawn 
{
	while {alive heli1} do 
	{
		if (getPosATL heli1#2 < 3) then 
		{
			heli1 AnimateDoor ["Door_rear_source", 1, false]
		}
		else 
		{
			heli1 AnimateDoor ["Door_rear_source", 0, false]
		};
		sleep 1;
	}
};

 

Share this post


Link to post
Share on other sites

DUDE!  That is awesome! Thanks so much.
Tested and works on the Huron!

but..one Welsh guy to another;) ..how would i do this for the ghoshawk?
I tried this, but it wont work..

[] spawn 
{
    while {alive heli1} do 
    {
        if (getPosATL heli1#2 < 3) then 
        {
            ( _this select 0 ) animateDoor ["Door_R", 1, false];
            ( _this select 0 ) animateDoor ["Door_L", 1, false];
        }
        else 
        {
            ( _this select 0 ) animateDoor ["Door_R", 0, false];
            ( _this select 0 ) animateDoor ["Door_L", 0, false];
        };
        sleep 1;
    }
};

I'm guessing its the #2 bit, right?


Anyway, i don't want to push it, thanks again mate.
I'll figure it out from here hopefully. 🙂  And i'll check out your other links there!  thanks.

Share this post


Link to post
Share on other sites
if (getPosATL heli1#2 < 3) then

# is shorthand for "select", so this says "if heli1's height above terrain level is less than 3 meters, then..."


The problem is that "_this" is not defined. 

 

[] spawn 
{
    while {alive heli1} do 
    {
        if (getPosATL heli1#2 < 3) then
        {
            heli1 animateDoor ["Door_R", 1, false];
            heli1 animateDoor ["Door_L", 1, false];
        }
        else 
        {
            heli1 animateDoor ["Door_R", 0, false];
            heli1 animateDoor ["Door_L", 0, false];
        };
        sleep 1;
    }
};


Of course, we could also bypass variable names by passing the vehicle via params:

 

[this] spawn 
{
    params ["_this"];
    while {alive _this} do 
    {
        if (getPosATL _this#2 < 3) then
        {
            _this animateDoor ["Door_R", 1, false];
            _this animateDoor ["Door_L", 1, false];
        }
        else 
        {
            _this animateDoor ["Door_R", 0, false];
            _this animateDoor ["Door_L", 0, false];
        };
        sleep 1;
    }
};


 

  • Like 1

Share this post


Link to post
Share on other sites
15 minutes ago, stegman said:

i don't want to push it

 

The forums are here for all to ask questions. Bring 'em!

 

(btw, I'm not Welsh per se, but it's in my blood from several generations ago. I've always felt a connection.)

Share this post


Link to post
Share on other sites
1 hour ago, Harzach said:

if (getPosATL heli1#2 < 3) then

# is shorthand for "select", so this says "if heli1's height above terrain level is less than 3 meters, then..."


The problem is that "_this" is not defined. 

Huh....ok, cool.
Yet it worked on the Huron. Odd. 🤔

anyway...

Quote

[this] spawn 
{
    params ["_this"];
    while {alive _this} do 
    {
        if (getPosATL _this#2 < 3) then
        {
            _this animateDoor ["Door_R", 1, false];
            _this animateDoor ["Door_L", 1, false];
        }
        else 
        {
            _this animateDoor ["Door_R", 0, false];
            _this animateDoor ["Door_L", 0, false];
        };
        sleep 1;
    }
};

Now, this works fine!  😁
Thanks a lot mate.  looks pretty good i think.  Better than mushing yourself against a closed door anyway!  😆

 

1 hour ago, Harzach said:

 

The forums are here for all to ask questions. Bring 'em!

Your gonna regret that! 😉
I have a bunch! of questions, such as "Can i get a medic to drop used 'medical Garbage' when healing?"  and a more involved Logistics "Hump and Dump" project im making zero progress on!

Quote

(btw, I'm not Welsh per se, but it's in my blood from several generations ago. I've always felt a connection.)

( I've had a chat with the the Senedd, and that makes you welsh, butty 😉 )

again, thanks for your help dude.  You definitely seem to know your stuff.

 

Share this post


Link to post
Share on other sites
24 minutes ago, stegman said:

Yet it worked on the Huron.

 

Nope! We used its variable name "heli1" throughout.

 

24 minutes ago, stegman said:

You definitely seem to know your stuff.

 

Hah, thanks, but make no mistake, I'm low-mid level. But there are a bunch of folks around here who will be able to answer pretty much any question you might have.

  • Thanks 1

Share this post


Link to post
Share on other sites
3 minutes ago, Harzach said:

 

Nope! We used its variable name "heli1" throughout.

..i see now. 😶 I'd butchered another script and merged them.
I completely see the issue.
Thanks mate.

  • Like 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

×