Jump to content
Sign in to follow this  
evans d [16aa]

creating a Helicopter and Giving Waypoints via a Script

Recommended Posts

Heya guys,

I have searched but I couldn't make much sense out of the stuff I found.

I want to create a helicopter (already flying at an altitude of around 20m) through a script and give it a series of waypoints so it moves to an invisble helipad named "LZ1", lands (or hovers just above the ground, either one's good) and waits for 2 groups of 5 infantry to get in then takes off, goes through some more waypoints and lands (or hovers again) at another invisible helipad named "LZ2" and waits for the groups to get out then flies back to where it originaly spawned (a destroyer just off the coast of Isla Duala) and then it can either just be left or it can be deleted.

I found this while I was searching:

_unit = this select 0
_unit doMove (getMarkerPos "East_WP1");
waitUntil {_unit distance (getMarkerPos "East_WP1") < 10};

I can vaguely understand this but I don't know how to create the helo when it's already flying or how to make it land. From that I THINK I know how to create waypoints but I'd apreciate any help you guys can offer.

Thanks,

Bashkire.

Share this post


Link to post
Share on other sites

_group = group _unit;
_waypoint1 = _group [url=http://community.bistudio.com/wiki/addWaypoint]addWaypoint[/url] [position LZ1, 0];
_waypoint1 [url=http://community.bistudio.com/wiki/setWaypointType]setWaypointType[/url] "MOVE";

and so on...

These are the basics - it's just a matter of placing the waypoints and giving them types, just as you would in the editor.

You can use the land command to bring it down. To keep it there, I usually create a HOLD waypoint, then just deleteWaypoint _waypointName to have it continue it's path. Ordering units to board the heli via script will also force a landing.

Share this post


Link to post
Share on other sites
Thanks, Do you know how to create the chopper as well (engines on so it doesn't crash imedietly)?

try using BIS_fnc_spawnVehicle, also maybe take a look at my script and see if you can modify it to your own needs. scripts are detailed with info on each part, so you can easily pick and choose if you have some scripting knowledge.

http://forums.bistudio.com/showthread.php?t=111311

Anyway here is a functioning spawned East mi8 with East crew at 100 meters flying

// create drophelo with full crew at 100 altitude, setting heli to spawn at high altitude sometimes causes nosedive to fiery death when alot of scripts are running, works fine if not. set 100 to 0 if issues arise in your mission
_sv = [[getMarkerPos anymarker select 0, getMarkerPos anymarker select 1, 100], random 360, "Mi17_TK_EP1", EAST] call BIS_fnc_spawnVehicle;

// Name the vehicle and group
_drophelo = _sv select 0;  // vehicle spawned.
_drophelogrp = _sv select 2;  // group of vehicle so waypoints work.
_helopilot = (driver _drophelo);  // get pilot of drophelo
_helopilot setSkill 1;  // set high skill on pilot.

// set what height drophelo will fly in: this seems to fix the crash when spawned at altitude
_drophelo flyInHeight 100;

// go to random Position 3000m from center of city marker, flyby..
_wp0 = _drophelogrp addWaypoint [getMarkerPos "headtocity", 3000];
_wp0 setWaypointType "MOVE";
_wp0 setWaypointSpeed "FULL";
_wp0 setWaypointBehaviour "AWARE";  // set to "CARELESS" if trouble with enemys distracting heli.
_wp0 setWaypointFormation "LINE";
[_drophelogrp,0] setWaypointStatements ["true", "hint 'heli have reached waypoint'"];

// activate first move for pilot incase something stops 1st wp to be executed somehow
_helopilot doMove (getWPPos _wp0);

EDIT: you need to have function module placed on map, in editor press F7.

Edited by Demonized
added important info

Share this post


Link to post
Share on other sites

I think there is an error in the above script, you need "" around your marker name?

should be:

_sv = [[getMarkerPos "anymarker" select 0, getMarkerPos "anymarker" select 1, 100];

It would not work for me until I did that. Nice script though - the naming, assigning and Wp parts were very useful.

Or you can define it this way (I learned this from lucky44):

_position = [getpos "marker1" select 0, getpos "marker1" select 1, 100];
[_position, 0, "Mi17_TK_EP1", EAST] call bis_fnc_spawnvehicle;

for a friendly vehicle:

_position = [getpos "marker1" select 0, getpos "marker1" select 1, 100];
[_position, 0, "AH64D_EP1", WEST] call bis_fnc_spawnvehicle;

Many advise that this is important:

waituntil {!isnil "bis_fnc_init"};

If you add it at the begining of the script it waits untill the functions module is ready, or the script may fail.

Edited by PELHAM
additional info

Share this post


Link to post
Share on other sites

Thanks for the help but I don't need this any more. :D Sorry.

I found a way to do it without the script. The problem I had was that as soon as the destroyer was out of sight range it would delete itself (probally to save memory) and the helo on the deck fell into the sea and exploded. I solved it by creating ANOTHER invisible H and attaching the helo to it once the players were far enough away so they don't see it bouncing. Then when it needs to come and pick my guys up it's given a waypoint and a trigger waits a while to make sure it's flying (while still attached) and then detaches it from the pad so it can fly about normally. Then it returns to the destroyer and just hovers until it runs out of fuel. :D

Thanks again, and I'll try and use this info if I need help again :icon14:

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  

×