Jump to content
Sign in to follow this  
Franklin

Checking units in chopper

Recommended Posts

As usual, I've done a search and found nothing that fits my mission.

I have 2 groups of blufor troops, No friendly AI in an MP environment. (group names are "sfg1" and "sfg2")

I also have a dynamically spawned helicopter that is utilizing mando heli route scripts to move into the pickup zone for these troops. (helicopter is only referenced in the script as "_vcl_new")

I would like to know if it is possible to use a waitUntil inside a script to check if the groups are inside the helicopter, and then execute the mando heliroute script. I am trying to allow for some of the playable slots not to be filled by players or AI, and the script still count the proper number of people in the groups.

what i have tryed so far:

_scr = [_vcl_new,[getPos landing_mh60],25, true] execVM "mando_heliroute_arma.sqf";

Sleep 1;

waitUntil {_vcl_new getVariable "mando_heliroute" != "busy"};

waituntil {{_x in _vcl_new} count units sfg1 == count units sfg1} && {{_x in _vcl_new} count units sfg2 == count units sfg2};

_scr = [_vcl_new,[getPos wp1_mh60],25, false] execVM "mando_heliroute_arma.sqf";

Sleep 1;

waitUntil {_vcl_new getVariable "mando_heliroute" != "busy"};

Share this post


Link to post
Share on other sites

waitUntil {count units sfg1 == count units sfg1 in crew heliName}; should work I think. Although I'd recommend a slower looping while-loop or something for such a check if it will be running during any longer time during the mission, since it is fairly resource-taxing with such a complex check with the frequency of a waitUntil check.

Share this post


Link to post
Share on other sites

It doesn't seem to work Inkompetent, thank you for the quick reply though!

Here is the full script I'm using, hopefully it may help.

I put the snippet of code you gave me as is just for testing. although id like something along the lines of:

waitUntil {count units sfg1 == count units sfg1 in crew _vcl_new} && {count units sfg2 == count units sfg2 in crew _vcl_new};
// spawn_chopper.sqf

// JULY 2009 - norrin

if (!isServer) exitWith {};

_type = _this select 0;

_marker_pos = _this select 1;

_skill = _this select 2;

// Create Crew

_Mh60crew = createGroup WEST;

"USMC_Soldier_Pilot" createUnit [(getMarkerPos _marker_pos), _Mh60crew, "mh60p1 = this;"];

"USMC_Soldier_Pilot" createUnit [(getMarkerPos _marker_pos), _Mh60crew, "mh60p2 = this;"];

"USMC_Soldier_Pilot" createUnit [(getMarkerPos _marker_pos), _Mh60crew, "mh60p3 = this;"];

"USMC_Soldier_Pilot" createUnit [(getMarkerPos _marker_pos), _Mh60crew, "mh60p4 = this;"];

_unitsGroup = units _Mh60crew;

// Create Vehicle

_pos = [(getMarkerPos _marker_pos) select 0, (getMarkerPos _marker_pos) select 1, 30];

_vcl_new = _type createVehicle _pos;

_vcl_new engineOn true;

// Move crew in Vehicle

for [{ _loop = 0 },{ _loop < count _unitsGroup},{ _loop = _loop + 1}] do

{

_guy = _unitsGroup select _loop;

_guy setSkill _skill;

if (_loop == 0) then {_guy moveInDriver _vcl_new};

if (_loop == 1) then {_guy moveInCargo _vcl_new};

sleep 0.005;

};

mh60p3 MoveInTurret [_vcl_new,[0]];

mh60p4 MoveInTurret [_vcl_new,[1]];

sleep 15;

_vcl_new setPos [11,4326,30];

_vcl_new setDir 90;

_vcl_new setvelocity [20, 0, 0];

_vcl_new flyInHeight 30;

_scr = [_vcl_new,[getPos landing_mh60],25, true] execVM "mando_heliroute_arma.sqf";

_vcl_new setSpeedMode "LIMITED";

_vcl_new setBehaviour "careless";

_vcl_new forceSpeed 100;

Sleep 1;

waitUntil {_vcl_new getVariable "mando_heliroute" != "busy"};

player globalchat "choper is waiting";

Sleep 5;

waitUntil {count units sfg1 == count units sfg1 in crew _vcl_new};

player globalchat "everybodys in";

_scr = [_vcl_new,[getPos wp1_mh60],25, false] execVM "mando_heliroute_arma.sqf";

Sleep 1;

waitUntil {_vcl_new getVariable "mando_heliroute" != "busy"};

_scr = [_vcl_new,[getPos wp2_mh60],25, false] execVM "mando_heliroute_arma.sqf";

Sleep 1;

waitUntil {_vcl_new getVariable "mando_heliroute" != "busy"};

_scr = [_vcl_new,[getPos landing2_mh60],25, true] execVM "mando_heliroute_arma.sqf";

Sleep 1;

waitUntil {_vcl_new getVariable "mando_heliroute" != "busy"};

Share this post


Link to post
Share on other sites

You can't write a waitUntil {test1} && {test2}; line of code. You can't compare two lines of code to eachother. Just the boolean result of said code. It should be written as waitUntil {(test1) && (test2)};

Try with that first. :)

Share this post


Link to post
Share on other sites

Good to know, I'm very new to all this and spend hours upon hours searching these forums, and reading in the BIS Wiki... Lots to learn!

Ill add that to the script, but as a test I ran the script exactly as it was posted (without the addition of the check for sfg2). I hosted my own MP server, disabled all the AI and used a radio alpha to exec the script. Everything ran fine and I got the global chat "chopper is waiting." I hopped in the chopper and it just sat there and never moved.

Is it an issue related to non-existent members of the team, or could it be related to the name of the helicopter being local to the script?

Also, just an FYI in regards to the statement about the loop and this taxing the server. In the scenario this script is executed after having cleared out an area, at which time there will be almost no AI on the map ~10-15 at most. The group will have a short 200-300m run to the pickup point, where they will then load the chopper and move to the next objective area, which will be spawned in dynamically during the chopper ride. So there shouldn't be too much of an issue in regards to server processes.

Edited by franklin

Share this post


Link to post
Share on other sites

The helicopter itself isn't local to the script. It exists globally. However the variable _vcl_new that is a reference to the helicopter object is local only in the scope it was created, in this case the main scope (and all lower level scopes) of the script.

A moment though and I'll test so that I got my waitUntil check right.

Edit:

Okay, I tested in the editor noticed my syntax was at fault. The waitUntil should look like:

waitUntil {(count units sfg1 == {_x in crew _vcl_new} count units sfg1) && (count units sfg2 == {_x in crew _vcl_new} count units sfg2)};

Edited by Inkompetent

Share this post


Link to post
Share on other sites

Sweet, I'll test it out on my mission when i get home from work tonight, Thanks a ton!

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  

×