Jump to content
Sign in to follow this  
meatball

Spawned Helicopter not Moving to Waypoint

Recommended Posts

Having trouble with a helicopter I'm spawning with a script to move to a pickup location. The helicopter does spawn, but it just sits there, hovering at the spawn location. Here's the code I'm using.

// Spawn evac helicopter and fly to Evac Point
_evacH = [markerPos _spawnPos, random 360, "B_Heli_Transport_01_camo_F", west] call BIS_fnc_spawnVehicle;

_heli = _evacH select 0;
_heliCrew = _evacH select 1;
_heliGroup = _evacH select 2;

_heli allowDamage false;
evacHeli = _heli;

evacHeli doMove (getmarkerPos "_lzName");

call compile format["wp0 = _heliGroup addwaypoint [getPos %1, 0];",_hpName];
wp0 setWaypointType "LOAD";
wp0 setWaypointSpeed "FULL";
wp0 setWaypointBehaviour "CARELESS";
wp0 setWaypointCombatMode "BLUE";
doStop _heli;
_heli land "LAND";

The doMove was at attempt to force it to go, but no dice. Anyone have any ideas?

Share this post


Link to post
Share on other sites

i think its the "doStop _heli". you've added the waypoint, but immediately said 'stop, don't go' afterwords. Also, whats '_hpName', don't see it defined

Share this post


Link to post
Share on other sites

move didn't seem to work either. Here's the entire script. I'm sure it's not the cleanest, since it's my first shot at building my own script so any suggestions would be appreciated.

// randomExtract point script written by Meatball
//
//   Have 6 invisible markers already on the map named lz_0 through lz_5
//   Have 6 invisible helippads already on the map named hp_0 through hp_5
//      lz_0 is next to hp_0, etc.
//

if (!isServer)exitWith{};
private ["_randomExtract","_lzName","_hpName","_evacH","_evacWP","_evacTrig1","_bricks","_heli","_heliCrew","_heliGroup"];

// Pick Random extraction location.  
_randomExtract = floor(random 6);// Update 6 to total number of extraction points/helipads you've created on the map.

// Show Extraction point marker on map

_lzName = "lz_" + str _randomExtract;
_hpName = "hp_" + str _randomExtract;

radFound = 0;

//hint format["lzName & hpName: %1 & %2",_lzName,_hpName];

_lzName setMarkerTypeLocal "mil_Pickup";  // For more icon types see http://community.bistudio.com/wiki/cfgMarkers
_lzName setMarkerColorLocal "ColorRed";  // For more Colors see http://community.bistudio.com/wiki/setMarkerColorLocal

_bricks = [markerPos _lzName, random 360, "Land_Bricks_V4_F", CIVILIAN] call BIS_fnc_spawnVehicle;

// Create Guardians around extraction point.

//call compile format["nul = [%1,2,(numEnemies*80),true,true,false,0.20,0.05,enemySkill,nil,nil,nil] execVM 'militarize.sqf';",_hpName];

// Create evac trigger.
// Trigger 1 - Radio Trigger
_evacTrig1=createTrigger["EmptyDetector",getMarkerPos _lzName];
_evacTrig1 setTriggerActivation["WEST","PRESENT",false];
_evacTrig1 setTriggerArea[2,2,0,false];
_evacTrig1 setTriggerStatements["this","hint 'After digging through the pile of bricks you find the radio and call in for evac.  The chopper is en route and they tell you to hold out till they arrive!';radFound = 1;",""];
_evacTrig1 setTriggerTimeout[2,2,2,false];

waitUntil {radFound == 1};  // Wait for players to 'find' radio with Radio Trigger.

// Spawn evac helicopter and fly to Evac Point
_evacH = [markerPos "evacSpawn", random 360, "B_Heli_Transport_01_camo_F", west] call BIS_fnc_spawnVehicle;

_heli = _evacH select 0;
_heliCrew = _evacH select 1;
_heliGroup = _evacH select 2;

_heli allowDamage false;

evacHeli = _heli;

call compile format["wp0 = _heliGroup addwaypoint [getPos %1, 0];",_hpName];
wp0 setWaypointType "LOAD";
wp0 setWaypointSpeed "FULL";
wp0 setWaypointBehaviour "CARELESS";
wp0 setWaypointCombatMode "BLUE";
wp0 setWaypointStatements ["true","doStop evacHeli; evacHeli land 'LAND';"];

sleep 20;
hint "DemoTeam two, this is Ghost twelve.  We are en route for evac.  ETA under two minutes.";

// Wait for units to extract
waitUntil {{_x in evacHeli} count units demoteam == {alive _x and !captive _x} count units demoteam};

wp1 = _heliGroup addwaypoint [getMarkerPos "endMark", 5];
wp1 setwaypointtype "MOVE";  

---------- Post added at 22:17 ---------- Previous post was at 22:13 ----------

You're right, it is the doStop...duh.

Any idea how to assign the doStop and Land commands to wp0?

Edited by MeatballCB

Share this post


Link to post
Share on other sites

I see a few problems

call compile format["wp0 = _heliGroup addwaypoint [getmarkerPos %1, 0];",str _hpName];// getmarkerpos and needs str to make it a string

I had to remove dostop or heli doesn't move to "endmark" once inside

Share this post


Link to post
Share on other sites
call compile format["wp0 = _heliGroup addwaypoint [getmarkerPos %1, 0];",str _hpName];// getmarkerpos and needs str to make it a string

Hmm, strange. It seems to be working without the str in the call.

Share this post


Link to post
Share on other sites

can't explain that as it gives me the error 0 elements provided and 3 expected translates to position not recognised.

you don't need to compile the line anyway just like in the second wp.

wp0 = _heliGroup addwaypoint [getmarkerPos _hpName,0];

Edited by F2k Sel

Share this post


Link to post
Share on other sites

hes correct the way it was written for that line, it should be:

call compile format["wp0 = _heliGroup addwaypoint [getPos %1, 0];",_hpName];

because _hpName is a string of an object name. ( _hpName = "hp_" + str _randomExtract; )

since _hpName is already a string, so don't need str before _hpname (plus format takes care of that for us),can't use getMarkerPos cause it won't work on objects (helipad), only markers. returns [0,0,0] if not a marker,

-----------

as copy&pasted from above it works perfectly. moving the doStop did it.

btw, if you change 'land "LAND"' to 'land "GET IN"', it will still land on the helipad, but the engines will stay running instead

Edited by dr_strangepete

Share this post


Link to post
Share on other sites

Yes I'd forgot about the pads. Id actually placed them in the game as markers.

Edited by F2k Sel

Share this post


Link to post
Share on other sites

Yeah, I've prepoulated both the invisible helipads and the waypoints on the map.

Thanks for all the input so far though!

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  

×