Jump to content
Sign in to follow this  
AlexVestin

Helicopter waypoint script for MP. I broke it. Altough not by much, I think.

Recommended Posts

Greetings!

I tried modifying a script that spawns a helicopter. This script.

It's for a multiplayer mission.

Here's what I called my stuff in-game.

Transport helicopter waiting at landing pad: HeliInsertion

The marker placed right where the helicopter is at: HeliTransportStart

The marker where I want it to goto first and land: HeliTransportEnd

It's supposed to fly back to the first marker after drop off and then just wait there on the landing pad.

Hopefully to be able to trigger it again later.

I tried making it simpler by just making the helicopter already spawned and:

1. Get triggered and wait for the squad to get in,

2. Check if squad is in cargo,

3. Fy away when squad is in cargo,

4. Drop off squad,

5. Check if squad has left cargo,

6. Fly back to start and land,

7. Await trigger again?

I have no idea what I broke here or what's required to be in there, since I'm not used to scripting.

Here's my version of the script:

/////////////////////////////////////////////////////////////////////////////
//  From trigger:
//  nul = [player] execVM "Heli_Insertion_Script.sqf";
//
//  Pre-place "HeliTransportStart" and "HeliTransportEnd" markers on the map.
/////////////////////////////////////////////////////////////////////////////

// Wait till the Functions module is ready.
waituntil {!isnil "bis_fnc_init"};

// Declare everything.
_unit = _this select 0;						// who called it.
_start = getMarkerPos "HeliTransportStart";			// location of start/base location.
_end = getMarkerPos "HeliTransportEnd";				// location of drop off.


if (isServer) then {
// message letting them know it's ready.
player globalChat "Transport is ready. Hop in.";
// Name the helo globally so that waypoint orders will work.
HeliInerstion = _ch select 0;
_chGroup = _ch select 1;				// group of helo so waypoints work.
_chGroup setBehaviour "CARELESS";			// Make sure they don't get distracted.


_lzPickup = "HeliEmpty" createvehicle _start;
_lzDropOff = "HeliEmpty" createvehicle _end;


// These lines might be needed in MP. :)   Didn't test it yet.
_ch select 0 setVehicleInit "HeliInsertion = this; this setVehicleVarName ""HeliInsertion""";
processInitCommands;


// Wait till the player's group is in the helo.
waitUntil{{_x in HeliInsertion} count units group _unit == count units group _unit};


// Once they are, off we go by setting a TRANSPORT UNLOAD waypoint.  
// It'll auto boot the leader once there, but he'll have to tell the others to get out.
player globalChat "Chopper taking off.";
wp0 = _chGroup addwaypoint _end;
wp0 setwaypointtype "TR UNLOAD";
wp0 setWaypointStatements ["","HeliInsertion land ""GET OUT"""];


// Wait till the player's group is out of the helo.
waitUntil{{_x in HeliInsertion} count units group _unit == 0};


// Once they are out, set a waypoint back to the start and clean up by deleting the landing pads.
player globalChat "Insertion successful. Enjoy your stay.";
wp2 = _chGroup addwaypoint _start;
wp2 setwaypointtype "MOVE";
wp2 setWaypointStatements ["","HeliInsertion land ""GET IN"""];
deleteVehicle _lzPickup;
deleteVehicle _lzDropOff;
};

There's probably alot of un-needed functions in there.

All help is appreciated!

Share this post


Link to post
Share on other sites

_lzPickup = "HeliHEmpty" createVehicle _start;

Same for _lzDropOff.

The setvehicleinit is not needed if executed mid-mission.

_chgroup addWaypoint [_end,0] is the correct syntax.

Where is _ch defined? I don't see it anywhere really.

There shouldn't be anything else except that, just a personal tip. Don't start changing huge scripts if you're not used to scripting at all, start small.

Share this post


Link to post
Share on other sites

Alright. Thanks for the quick answer. I noticed a few of my spelling errors too. Hopefully they're all fixed. My second try:

The helicopter init: (works)

(group this) SetGroupId ["UH60 Transport"];this setBehaviour "CARELESS";this flyInHeight 10;

The trigger init: (works)

nul = [player] execVM "scripts\Heli_Insertion_Script.sqf";

The script: (The helicopter "HeliInsertion" is not getting it's waypoints.)

_unit = _this select 0;						// who called it.
_start = getMarkerPos "HeliTransportStart";			// location of start/base location.
_end = getMarkerPos "HeliTransportEnd";				// location of drop off.

if (isServer) then {
// message letting them know it's ready.
player globalChat "Transport is ready. Hop in.";
_lzPickup = "HeliHEmpty" createvehicle _start;
_lzDropOff = "HeliHEmpty" createvehicle _end;


// Wait till the players group is in the helo.
waitUntil{{_x in HeliInsertion} count units group _unit == count units group _unit};
player globalChat "Everybody's in. Chopper taking off.";


// Once they are, off we go by setting a TRANSPORT UNLOAD waypoint.  
// It'll auto boot the leader once there, but he'll have to tell the others to get out.
HeliInsertion setBehaviour "STEALTH";
wp0 = HeliInsertion addwaypoint [_end,0];
wp0 setwaypointtype "TR UNLOAD";
wp0 setWaypointStatements ["","HeliInsertion land ""GET OUT"""];


// Wait till the players group is out of the helo.
waitUntil{{_x in HeliInsertion} count units group _unit == 0};
player globalChat "Insertion successful. Enjoy your stay.";


// Once they are out, set a waypoint back to the start and clean up by deleting the landing pads.
wp1 = HeliInsertion addWaypoint [_start,0];
wp1 setwaypointtype "MOVE";
wp1 setWaypointStatements ["","HeliInsertion land ""GET IN"""];
deleteVehicle _lzPickup;
deleteVehicle _lzDropOff;
HeliInsertion setBehaviour "CARELESS";
};

I know wp0 = HeliInsertion addwaypoint [_end,0]; etc. is incorrect.

I don't know how to make it work with the rest.

Edited by AlexVestin

Share this post


Link to post
Share on other sites

try

  wp0 = group HeliInsertion addwaypoint [_end,0];

Share this post


Link to post
Share on other sites

That worked! Thank you.

Might aswell post it all again once it's working. Not sure if MP compatible though.

I guess it's done for now.

Helicopter name: HeliInsertion

Helicopter Init:

(group this) SetGroupId ["UH60 Transport"];

Trigger init:

nul = [player] execVM "scripts\Heli_Insertion_Script.sqf";

Script "Heli_Insertion_Script.sqf":

/////////////////////////////////////////////////////////////////////////////
//  From trigger:
//  nul = [player] execVM "scripts\Heli_Insertion_Script.sqf";
//
//  Pre-place "HeliTransportStart" and "HeliTransportEnd" markers on the map.
/////////////////////////////////////////////////////////////////////////////

// Declare everything.
_unit = _this select 0;						// who called it.
_start = getMarkerPos "HeliTransportStart";			// location of start/base location.
_end = getMarkerPos "HeliTransportEnd";				// location of drop off.

if (isServer) then {
// message letting them know it's ready.
player globalChat "Transport is ready. Hop in.";
HeliInsertion setBehaviour "COMBAT";
group HeliInsertion setCombatMode "GREEN";
_lzPickup = "HeliHEmpty" createvehicle _start;
_lzDropOff = "HeliHEmpty" createvehicle _end;


// Wait till the players group is in the helo.
waitUntil{{_x in HeliInsertion} count units group _unit == count units group _unit};
player globalChat "Everybody's in. Chopper taking off.";


// Once they are, off we go by setting a TRANSPORT UNLOAD waypoint.
// It'll auto boot the leader once there, but he'll have to tell the others to get out.
wp0 = group HeliInsertion addwaypoint [_end,0];
wp0 setwaypointtype "TR UNLOAD";
wp0 setWaypointStatements ["","HeliInsertion land ""GET OUT"""];


// Wait till the players group is out of the helo.
waitUntil{{_x in HeliInsertion} count units group _unit == 0};
player globalChat "Transport is RTB. Enjoy your stay.";


// Once they are out, set a waypoint back to the start and clean up by deleting the landing pads.
wp1 = group HeliInsertion addwaypoint [_start,0];
wp1 setwaypointtype "MOVE";
wp1 setWaypointStatements ["","HeliInsertion land ""LAND"""];
deleteVehicle _lzPickup;
deleteVehicle _lzDropOff;
};

Edited by AlexVestin

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  

×