Jump to content
black_hawk_mw2_87

HELICOPTER EXFILTRATION - HOW DOES THIS WORK?

Recommended Posts

Hello, guys, I am working on a test mission where the player needs to be extracted from a spesific LZ by a helicopter after his mission is complete. I have found a new script where you can throw an IR grenade and activate a trigger. What I am asking for is the way I need to create my waypoints for the chopper in order to come and take me on board and move to a spesific direction when this trigger is activated. I know how to call the chopper when the trigger is activated (when the IR grenade is thrown into a trigger zone using a skipwaypoint trigger), but here comes the part with the landing of the bird, getting in and taking me to the place I need to fly to. Would you help me with that? :) I've tried with the GET IN and LOAD commands, but they work for me ONLY if the chopper is on the ground and I get inside instead of it flying to my position and THEN taking me on board, and taking off... Thank you in advance! :)

  • Like 1

Share this post


Link to post
Share on other sites

Solution without triggers:

 


GOM_fnc_chopperPickup = {

	params ["_unit","_chopper"];
	_unit setVariable ["GOM_fnc_pickUpChopper",_chopper];
	waitUntil {time > 1};//put your condition in here to make the chopper move towards the player

	_chopper move (_unit getPos [50 + random 50,random 360]);//this will move the chopper near the player within 50-100m
	waitUntil {_chopper distance2d _unit < 300};

	//now the player can throw a smoke to mark the landing area
	hintC "Throw smoke to mark landing area!";
	_unit addEventHandler ["Fired",{
		params ["_unit", "_weapon", "_muzzle", "_mode", "_ammo", "_magazine", "_projectile", "_gunner"];

		if (toUpper _ammo find "SMOKE" >= 0) then {
			_unit removeEventHandler ["Fired",_thisEventhandler];
			hint "Smoke out!";
			_chopper = _unit getVariable ["GOM_fnc_pickUpChopper",objNull];
				_wait = [_chopper,_projectile] spawn {
					params ["_chopper","_projectile"];
					waitUntil {vectorMagnitude velocityModelSpace _projectile < 0.01};
					hintC "The Chopper will land now!";
					//spawn landing pad at smoke position and make chopper land
					_pad = "Land_HelipadEmpty_F" createVehicle getPosATL _projectile;
					_pad setPosATL getPosATL _projectile;//just in case...
					doStop _chopper;
					_chopper land "GET IN";
					waitUntil {_unit in crew _chopper};
					//cancel the landing
					_chopper land "NONE";
					_chopper move getPosATL _chopper;
					sleep 5;
					_chopper move [0,0,0];//position where the chopper should move to

				}
		}
}]
};

//to run the function:
[player,chopper] spawn GOM_fnc_chopperPickup;

Using waypoints can be funky sometimes, doing this with a simple script snippet is a bit more convenient.

 

This will allow the player to mark the landingzone of the chopper by throwing a smoke grenade,

chopper will land and wait for the player to board it with engines on,

then will move to [0,0,0] once the player is in it, you can add your own position or whatever.

 

Cheers

  • Like 4
  • Thanks 3

Share this post


Link to post
Share on other sites

Thank you very much for your answer. I will try this out, but, still, do I need to put this script into a trigger with a condition to successfully activate it? And how can I find any map location's position which I could fill in instead of using 0.0.0? :) And one more thing... It's about all lines of the script where you put a sentence with //(describing something). Do I still need these parts included (just copied) when I input the script in the game's editor or I try it without them?

Share this post


Link to post
Share on other sites
4 hours ago, black_hawk_mw2_87 said:

Thank you very much for your answer. I will try this out, but, still, do I need to put this script into a trigger with a condition to successfully activate it? And how can I find any map location's position which I could fill in instead of using 0.0.0? :) And one more thing... It's about all lines of the script where you put a sentence with //(describing something). Do I still need these parts included (just copied) when I input the script in the game's editor or I try it without them?

 

You can put the first part, which defines the function into init.sqf or wherever you seem fit.

Then you can call it anytime in game from a trigger, another script, or debug console like this:
 

[player,chopper] spawn GOM_fnc_chopperPickup;

Then the function will wait for the condition to happen, the first waitUntil line, if you don't need this and want the chopper to immediately head towards the player simply delete this line:

waitUntil {time > 1};//put your condition in here to make the chopper move towards the player

No need to delete comments, since they're ignored by the engine.

For a position you can place a marker, name it and use getMarkerPos, or place an object, name it and use getPos:

_chopper move getMarkerPos "MyMarker01";
//or
_chopper move getPos flagFOB01;

Cheers

Share this post


Link to post
Share on other sites

Thank you again! There is only one problem now - the chopper is not taking off again. I have created a task and called my player - player1. I have created a chopper and called it 'chopper'. The script's put in the init.sqf file and I have put a trigger with a condition when an enemy unit is killed the script to run and it works just fine. The chopper flies close to my position, then I throw a smoke grenade and it lands. But when I enter it, an error pops up.

Share this post


Link to post
Share on other sites

This is how the error looks like in the error window that pops up:

 

'...per;
_chopper land "GET IN";
waitUntil {|#|_unit in crew _chopper};

_chopper la...'
Error Undefined variable in expression: _unit

 

I even tried to exchange _unit with my player's name: player1. The same error appears.

Share this post


Link to post
Share on other sites

Now I have exchanged all of _unit places with _player1 and will try it out again.

 

RESULTS: Same error...

 

EDITED: I have changed the chopper to a Hummingbird instead of Pawnee and the only difference is that the chopper takes off, but doesn't fly to the marker. I have created a marker called MyMarker1 like you told me and put it in the correct line.

 

This is how it looks like:

 

GOM_fnc_chopperPickup = {

 params ["_unit","_chopper"];
 _unit setVariable ["GOM_fnc_pickUpChopper",_chopper];
 waitUntil {time > 1};//put your condition in here to make the chopper move towards the player

 _chopper move (_unit getPos [50 + random 50,random 360]);//this will move the chopper near the player within 50-100m
 waitUntil {_chopper distance2d _unit < 300};

 //now the player can throw a smoke to mark the landing area
 hintC "Throw smoke to mark landing area!";
 _unit addEventHandler ["Fired",{
  params ["_unit", "_weapon", "_muzzle", "_mode", "_ammo", "_magazine", "_projectile", "_gunner"];

  if (toUpper _ammo find "SMOKE" >= 0) then {
   _unit removeEventHandler ["Fired",_thisEventhandler];
   hint "Smoke out!";
   _chopper = _unit getVariable ["GOM_fnc_pickUpChopper",objNull];
    _wait = [_chopper,_projectile] spawn {
     params ["_chopper","_projectile"];
     waitUntil {vectorMagnitude velocityModelSpace _projectile < 0.01};
     hintC "The Chopper will land now!";
     //spawn landing pad at smoke position and make chopper land
     _pad = "Land_HelipadEmpty_F" createVehicle getPosATL _projectile;
     _pad setPosATL getPosATL _projectile;//just in case...
     doStop _chopper;
     _chopper land "GET IN";
     waitUntil {_unit in crew _chopper};
     //cancel the landing
     _chopper land "NONE";
     _chopper move getPosATL _chopper;
     sleep 5;
     _chopper move getMarkerPos "MyMarker01";//position where the chopper should move to

    }
  }
}]
};

Share this post


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

Now I have exchanged all of _unit places with _player1 and will try it out again.

 

RESULTS: Same error...

 

EDITED: I have changed the chopper to a Hummingbird instead of Pawnee and the only difference is that the chopper takes off, but doesn't fly to the marker. I have created a marker called MyMarker1 like you told me and put it in the correct line.

 

This is how it looks like:

 

GOM_fnc_chopperPickup = {

 params ["_unit","_chopper"];
 _unit setVariable ["GOM_fnc_pickUpChopper",_chopper];
 waitUntil {time > 1};//put your condition in here to make the chopper move towards the player

 _chopper move (_unit getPos [50 + random 50,random 360]);//this will move the chopper near the player within 50-100m
 waitUntil {_chopper distance2d _unit < 300};

 //now the player can throw a smoke to mark the landing area
 hintC "Throw smoke to mark landing area!";
 _unit addEventHandler ["Fired",{
  params ["_unit", "_weapon", "_muzzle", "_mode", "_ammo", "_magazine", "_projectile", "_gunner"];

  if (toUpper _ammo find "SMOKE" >= 0) then {
   _unit removeEventHandler ["Fired",_thisEventhandler];
   hint "Smoke out!";
   _chopper = _unit getVariable ["GOM_fnc_pickUpChopper",objNull];
    _wait = [_chopper,_projectile] spawn {
     params ["_chopper","_projectile"];
     waitUntil {vectorMagnitude velocityModelSpace _projectile < 0.01};
     hintC "The Chopper will land now!";
     //spawn landing pad at smoke position and make chopper land
     _pad = "Land_HelipadEmpty_F" createVehicle getPosATL _projectile;
     _pad setPosATL getPosATL _projectile;//just in case...
     doStop _chopper;
     _chopper land "GET IN";
     waitUntil {_unit in crew _chopper};
     //cancel the landing
     _chopper land "NONE";
     _chopper move getPosATL _chopper;
     sleep 5;
     _chopper move getMarkerPos "MyMarker01";//position where the chopper should move to

    }
  }
}]
};

Make sure the marker names are identical both on the marker itself and in the script.

Since in your post you wrote MyMarker01 and MyMarker1 and be aware that strings (stuff between quotation marks) is case sensitive.

 

Also you don't need to change _unit and no need to change the function at all, since it's just a variable holding the object passed into the function.

Change the objects you pass into the function:

//player unit named SomeSoldier
//chopper named EvacChopper

[SomeSoldier,EvacChopper] spawn GOM_fnc_chopperPickup;

That's all there is to it.

 

Posting a screenshot can be as simple as:

  1. Hit print screen
  2. go to imgur.com
  3. click on new post
  4. ctrl+v
  5. paste the image link to the forum

Cheers

Share this post


Link to post
Share on other sites

Thanks a lot again! Your advices are really helpful. But there's one more thing that appears not to be working. All of the scripts inside my triggers now are with 'call' function somehow automatically added just before the function... So, when I tried to put the real working scripts... it didn't work. When I firstly tried I put ' _chopper move getMarkerPos "MyMarker01' as a condition for the task to be completed with a task state connected to the trigger itself. And now I am not allowed to do this using such a condition. It says: 'Condition: Local variable in global space'... What am I doing wrong this time? I have recopied and replaced the script in the init.sqf file again, but, as you have said, there was no need to exchange the 'player' lines inside it with my player's variable name, am I correct? So, just putting a different name for the player and for the chopper would be enough and I only need to use both changed names into the other trigger with the condition: '!alive enemy1' which activates [player1,chopper] spawn GOM_fnc_chopperPickup; - player1 is the name of the player and chopper is the variable name of the helicopter in my case.

Share this post


Link to post
Share on other sites
46 minutes ago, black_hawk_mw2_87 said:

Thanks a lot again! Your advices are really helpful. But there's one more thing that appears not to be working. All of the scripts inside my triggers now are with 'call' function somehow automatically added just before the function...

 

Getting this as well, for some reason the editor automatically converts every called function and adds a call on its own.

 

As to your example, so you have the function inside init.sqf? Then there should be no local variable in global space error from the trigger.

Not really sure from your description.

 

Cheers

 

Share this post


Link to post
Share on other sites

OK, the only thing that I would like to know is how to use this command which calls the chopper to fly by and pick me up AS a condition in a trigger that's activated by another condition, in my case: !alive enemy1; I have even tried with this command: [] execVM "init.sqf"; and there are not errors after using it, but is still doesn't work for me.

Cheers.

Share this post


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

OK, the only thing that I would like to know is how to use this command which calls the chopper to fly by and pick me up AS a condition in a trigger that's activated by another condition, in my case: !alive enemy1; I have even tried with this command: [] execVM "init.sqf"; and there are not errors after using it, but is still doesn't work for me.

Cheers.

Ouch, a few things:

init.sqf is automatically run by the game upon mission start, no need to run it again.

In the triggers onAct field simply put:

[SomeSoldier,EvacChopper] spawn GOM_fnc_chopperPickup;

I recommend to further look into some scripting guides to make things more clear:

Mr Murray for Arma, worth its weight in gold and still valid.

Kylanias page with loads of examples

and KKs glorious page for more advanced users.

 

Cheers

Share this post


Link to post
Share on other sites

Grumpy Old Man, thank you very much for all the patience and information shared by you! :) I have done everything absolutely right. But still the same error appears:

'...per;
_chopper land "GET IN";
waitUntil {|#|_unit in crew _chopper};

_chopper la...'
Error Undefined variable in expression: _unit

I would only ask you for one more thing: you're about to receive a PM from me with my email. I'd like to ask you to send me a mission file with your example of how it smoothly works. :) Thank you in advance!

Cheers

Share this post


Link to post
Share on other sites

I appreciate your help, mate! :) I have a list with about 25 different scripts here and I am still learning, but I am about to start a new mission, a complicated one, full of scripts, so thanks again! I am glad you see how important this mission script is and I believe it would take you only a couple of minutes. :)

Cheers

Share this post


Link to post
Share on other sites

just to check...

 

if you are calling the function with GOM's

 

Quote

[SomeSoldier,EvacChopper] spawn GOM_fnc_chopperPickup;

 

and are getting the error

 

16 minutes ago, black_hawk_mw2_87 said:

Error Undefined variable in expression: _unit

 

are you def using the right variable names?

 

i.e. if your player is called 'player1' and the chopper is called 'chopper' then function needs to be called with

 

Quote

[player1,Chopper] spawn GOM_fnc_chopperPickup;

 

Edited by lordfrith

Share this post


Link to post
Share on other sites

My player is called SomeSoldier and the chopper is called EvacChopper, but I was told not to change player's and chopper's fields in the script, only the variable names of the units. And this error is only connected to the player somehow, not to the chopper, so I am not sure if that has anything to do with the error.

Share this post


Link to post
Share on other sites
8 minutes ago, lordfrith said:

just to check...

 

if you are calling the function with GOM's

 

 

and are getting the error

 

 

are you def using the right variable names?

 

i.e. if your player is called 'player1' and the chopper is called 'chopper' then function needs to be called with

 

 

I know that, I have done this right, but now using the names I mentioned above, but it still doesn't work.

Share this post


Link to post
Share on other sites

Allright, I know what happened,

a mistake on my part, I forgot to pass the _unit variable to the spawned scope inside the fired eventhandler.

When I tried it it simply worked because I was using "player" instead of "_unit" inside that scope, go figure...

 

This is how the function should look like:


GOM_fnc_chopperPickup = {

	params ["_unit","_chopper"];
	_unit setVariable ["GOM_fnc_pickUpChopper",_chopper];
	waitUntil {time > 1};//put your condition in here to make the chopper move towards the player

	_chopper move (_unit getPos [50 + random 50,random 360]);//this will move the chopper near the player within 50-100m
	waitUntil {_chopper distance2d _unit < 300};

	//now the player can throw a smoke to mark the landing area
	hintC "Throw smoke to mark landing area!";
	_unit addEventHandler ["Fired",{
		params ["_unit", "_weapon", "_muzzle", "_mode", "_ammo", "_magazine", "_projectile", "_gunner"];

		if (toUpper _ammo find "SMOKE" >= 0) then {
			_unit removeEventHandler ["Fired",_thisEventhandler];
			hint "Smoke out!";
			_chopper = _unit getVariable ["GOM_fnc_pickUpChopper",objNull];
				_wait = [_unit,_chopper,_projectile] spawn {//forgot the _unit here, heh
					params ["_unit","_chopper","_projectile"];
					waitUntil {vectorMagnitude velocityModelSpace _projectile < 0.01};
					hintC "The Chopper will land now!";
					//spawn landing pad at smoke position and make chopper land
					_pad = "Land_HelipadEmpty_F" createVehicle getPosATL _projectile;
					_pad setPosATL getPosATL _projectile;//just in case...
					doStop _chopper;
					_chopper land "GET IN";
					waitUntil {_unit in crew _chopper};
					//cancel the landing
					_chopper land "NONE";
					_chopper move getPosATL _chopper;
					sleep 5;
					_chopper move [0,0,0];//position where the chopper should move to

				}
		}
	}]
};

Demo mission.

 

Cheers

  • Like 1
  • Thanks 1

Share this post


Link to post
Share on other sites
12 minutes ago, Grumpy Old Man said:

Allright, I know what happened,

a mistake on my part, I forgot to pass the _unit variable to the spawned scope inside the fired eventhandler.

When I tried it it simply worked because I was using "player" instead of "_unit" inside that scope, go figure...

 

This is how the function should look like:



GOM_fnc_chopperPickup = {

	params ["_unit","_chopper"];
	_unit setVariable ["GOM_fnc_pickUpChopper",_chopper];
	waitUntil {time > 1};//put your condition in here to make the chopper move towards the player

	_chopper move (_unit getPos [50 + random 50,random 360]);//this will move the chopper near the player within 50-100m
	waitUntil {_chopper distance2d _unit < 300};

	//now the player can throw a smoke to mark the landing area
	hintC "Throw smoke to mark landing area!";
	_unit addEventHandler ["Fired",{
		params ["_unit", "_weapon", "_muzzle", "_mode", "_ammo", "_magazine", "_projectile", "_gunner"];

		if (toUpper _ammo find "SMOKE" >= 0) then {
			_unit removeEventHandler ["Fired",_thisEventhandler];
			hint "Smoke out!";
			_chopper = _unit getVariable ["GOM_fnc_pickUpChopper",objNull];
				_wait = [_unit,_chopper,_projectile] spawn {//forgot the _unit here, heh
					params ["_unit","_chopper","_projectile"];
					waitUntil {vectorMagnitude velocityModelSpace _projectile < 0.01};
					hintC "The Chopper will land now!";
					//spawn landing pad at smoke position and make chopper land
					_pad = "Land_HelipadEmpty_F" createVehicle getPosATL _projectile;
					_pad setPosATL getPosATL _projectile;//just in case...
					doStop _chopper;
					_chopper land "GET IN";
					waitUntil {_unit in crew _chopper};
					//cancel the landing
					_chopper land "NONE";
					_chopper move getPosATL _chopper;
					sleep 5;
					_chopper move [0,0,0];//position where the chopper should move to

				}
		}
	}]
};

Demo mission.

 

Cheers

Making mistakes is a part of our life, but making people happy is another part! So, cheers, you've done a PERFECT work, it works great for me! And CHEERS again! :) :) :)

  • 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

×