Jump to content
Sign in to follow this  
Daefera

Unit refuses to board my heli...

Recommended Posts

Hi,

As I am new to scripting missions, I still have a lot to learn. That's why I take baby-steps in making my first scripted mission. Here's my problem I encountered on it's way. (yes, I did search and checked dozens of other scripts)

I want to make a pilot mission where the player is the pilot. In the 2D editor I have set two markers ('marker_base_heli', heli_1 is there aswell) and marker_spawn_location where I spawn my units. I created a trigger that's activated once the player entered the vehicle. Then the group df_1 will run towards the heli and board it.

Everything works fine, except for the fact that the group 'refuses' to board the plane. They do however run towards the heli once the player enters it. They just don't board the vehicle. I tried it with 'LOAD' and 'GETIN'.

It's probably an easy fix, but I need some guidance. Thanks for your time.

Here's my code:

// groep: DF_1
df_1 = createGroup WEST;
_df1_leader = "US_Delta_Force_TL_EP1" createUnit [getMarkerPos "marker_spawn_location", df_1,"", 0.9, "SERGEANT"];
_df1_1 = "US_Delta_Force_AR_EP1" createUnit [getMarkerPos "marker_spawn_location", df_1,"", 0.9, "CORPORAL"];
_df1_2 = "US_Delta_Force_Marksman_EP1" createUnit [getMarkerPos "marker_spawn_location", df_1,"", 0.9, "CORPORAL"]; 
_df1_3 = "US_Delta_Force_Medic_EP1" createUnit [getMarkerPos "marker_spawn_location", df_1,"", 0.9, "CORPORAL"]; 
_df1_4 = "US_Delta_Force_Marksman_EP1" createUnit [getMarkerPos "marker_spawn_location", df_1,"", 0.9, "CORPORAL"]; 

//Trigger 1: Speler in heli_1
_trig = createTrigger ["EmptyDetector", getMarkerPos "marker_base_heli"]; 
_trig setTriggerArea [0, 0, 0, true];
_trig setTriggerActivation ["ANY", "PRESENT", false];
_trig setTriggerStatements [	"player in heli_1", 
				"titleText ['Delta One, boarding Little B.','PLAIN DOWN']; titleFadeOut 4;
				_wp = df_1 addWaypoint [getPos heli_1, 0]; [df_1, 1] setWaypointBehaviour 'AWARE'; [df_1, 1] setWaypointType 'LOAD';", ""];

Share this post


Link to post
Share on other sites

Well it won't work because you don't explicitly tell the group to move into the helo.

I've rewritten the code to make it a bit easier, and I'll explain it on the way.

// groep: DF_1 
df_1 = createGroup WEST; 
_troops = ["US_Delta_Force_TL_EP1","US_Delta_Force_AR_EP1","US_Delta_Force_Marksman_EP1","US_Delta_Force_Medic_EP1","US_Delta_Force_Marksman_EP1"]; //This is a simple array containing all troops for the group.
_usgroup = [(getmarkerpos "marker_spawn_location",WEST,_troops] call BIS_fnc_spawngroup; // This is an effective way to spawn the group, by giving the function a position, telling it the side (this way you can even give OPFOR a couple of US Troops) and passing an array containing all units. This requires a Function Module on the map which you find when you press F7 -> double click -> Functions.

//Stuff: Speler in heli_1

waitUntil {player in heli}; // This halts the script until the player is in heli (which needs to be named previously).
{
_x assignascargo heli; // This assigns everybody to heli.
_x ordergetin true; // As the troops are all assigned, ordergetin makes them move into their respective vehicles, in this case, all of them move into heli.
} foreach units _usgroup; // "foreach" is basically just what it sounds like. This code gets executed for every solder in _usgroup.

Commands used:

BIS_fnc_spawnGroup

assignasCargo / If you want instant effects use moveincargo

ordergetin

waitUntil

Helpful links:

http://www.armaholic.com/page.php?id=4847 - Mr. Murrays Editing Guide (English version)

http://seit.unsw.adfa.edu.au/coursework/ZEIT2305/Resources/SQF_Tutorial/basic_sqf.HTML - The basics of SQF, bringing you closer to statements and such.

http://community.bistudio.com/wiki/Main_Page - The BIKI, where about every ingame command available is documented. FOR ADDITIONAL HELP, use F1 ingame when you stumble upon autocompletion. This is equivalent to the wiki and is up-to-date with potential bugs noted by developers.

http://www.arma2.com/comref/comref.html - ARMA 2 Comref, short for Command Reference. Automatically generated system which stores every scripting command available in ArmA2.

Just a personal tip. Use -showscripterrors. Code on and try to go straight on into problems unless you plan on making real missions early on, which I don't suggest. Just make random little missions for fun, script something neat for them and hope you run into problems. What I mean with real missions is stuff which you plan to release.

Share this post


Link to post
Share on other sites

I'll give it a try right away!

Thank you for your time and effort! -showscripterrors is already on. It didn't give me any errors (until I made one on purpose to see if it worked at all :))

Edited by Daefera
Missed the Personal tip the first time.

Share this post


Link to post
Share on other sites

Hi Again,

There was a small error in the script, but I managed to fix it. _x ordergetin true; needed to be [_x] ordergetin true;

But can anyone explain to me why my next waitUntill won't work? I want to wait with the mission until all men of the group _df_1 are inside the heli (heli_1).

waitUntil {_df_1 in heli_1};

I checked all forums, Murray's guide and the wiki, but the examples given with it won't help me answer my question.

Share this post


Link to post
Share on other sites

_df_1 is a group and in only works with units

try this, it should check that all living units are on board, you don't want to be waiting for a dead one.

waituntil  {{_x in heli_1} count units _df_1  == {alive _x} count units  _df_1}; 

Share this post


Link to post
Share on other sites

Thanks a lot for the explanation! There were some typo's. But this seemed to work!

waituntil {{_x in heli_1} count units _df_1  == {alive _x} count units _df_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
Sign in to follow this  

×