Jump to content
Sign in to follow this  
nephros

Is it possible to slingload another helicopter with BIS fnc wpSlingLoadAttach?

Recommended Posts

I have been putting together a kind of sandbox on the south asia map, and one of the features I am trying to impement is the ability to recover a helicopter that has crashed (provided it is small or medium, and therefore within the external weight restriction of the heavy helicopter) and bring it back to a repair point at the sumrakent airport, via slingloading.

The problem I am running into is that it appears the TOH helicopter models are not allowed as targets for slingload attachment via 'BIS fnc wpSlingLoadAttach' (although the ARMA 2 helicopter models are).

If I try to create a bucket and attach it to the center of the target helicopter and then slingload the bucket:

bucket setPosATL [getPosATL targetHelicopter]; 
bucket attachTo [targetHelicopter];

the helicopter holds the bucket to the ground and I can't slingload either.

Alternatively, if I attach the target helicopter to the bucket:

bucket setPosATL [getPosATL targetHelicopter]; 
targetHelicopter attachTo [bucket];

The bucket separates from the target helicopter on attachment, leaving the helicopter behind.

Is there a way to allow the TOH helicopters as targets or do I need to find a different approach?

===============================================================

SOLVED

Here is the code that works:

_slingHelper = "Misc_cargo_cont_net1" createVehicleLocal getPosATL targetHeli; 
_slingHelper hideObject true;

If (targetHeli isKindOf "Heli_Medium01_Base_H") then
{_slingHelper attachTo [targetHeli, [0,0,-2]];
sleep 1;
detach _slinghelper;
targetheli attachTo [_slingHelper,[0,0,2]]} 
else 
{_slingHelper attachTo [targetHeli, [0,0,-1.5]];
sleep 1;
detach _slinghelper;
targetheli attachTo [_slingHelper,[0,0,1.5]]};

Commentary (for other scripting novices like me who are trying to figure this stuff out :p )

-Since I can't directly slingload the TOH helicopter (named targetHeli), I am creating an invisible cargo in net (_slingHelper), attaching the targetHeli to the cargo in net, and then slingloading the cargo in net. I delete the cargo in net at the end, and voila!

-Problems and solutions:

1) Attaching _slinghelper to targetheli doesn't work: The helicopter stays frozen to the ground when you try to lift _slinghelper. You have to attach TargetHeli to _slinghelper.

2) When you create _slinghelper through code, it will spawn about 5m away from the helicopter. To teleport it 5m over to the helicopter (and not vice versa), you have to attach _slinghelper to targetheli first, then detach it. You have to sleep 1 second or else _slinghelper won't move at all (figured that out by dumb luck).

3) The center of gravity of the cargo in net (_slinghelper) is 1.5m lower than that of the light helicopters, and 2m lower than that of the medium helicopters, so you have to offset it or else your helicopter will either be buried in the ground or floating in the air.

4) If you try to use a smaller item than the cargo in net as your _slinghelper (I tried the ammocrate first), it spins wildly when you add the weight of a helicopter to it. I haven't experimented with this yet, but if you find that the cargo in net is still not stable enough, you could probably use a shipping crate instead for added stability. You'd have to expirement with the center of gravity offset.

5) My code is set up to account for either a light or medium helicopter and ignores all other possibilities. This is because in the mission I am creating I will have already excluded hinds and large helicopters from slingloading due to their weights.

Also (for other fledgling scripters), here is the full code for my test scenario in which I pick up targetHeli, deposit it at a helipad named hw3, and then land at hw1 (with a few hints thrown in). It shows how I'm doing custom waypoint scripting. A similar script will be triggered in my mission when a player reports his helicopter has crashed, and become an available task until either the task is performed, the helicopter is repaired, or the helicopter is destroyed.

 //heliWaypointInit.sqf
//player waypoint and task testing
//waypoint format: [player, target, completion radius, <arguments>] spawn <functionName>;
//attachslingload arguments: [posLimit, failCode, weight] spawn BIS_fnc_wpSlingLoadAttach;
//detachslingload arguments: [posLimit, LimitDir] spawn BIS_fnc_wpSlingLoadDetach;
//land arguments: [dirParam, visualize] spawn BIS_fnc_wpLand;
//_slinghelper offset for light: targetheli attachTo [_slingHelper,[0,0,1.5]];
//_slinghelper offset for medium: targetheli attachTo [_slingHelper,[0,0,2]];

WT_LIGHT = 722;
wT_MEDIUM = 3100;

//Assign weight to target helicopter based on size
If (targetHeli isKindOf "Heli_Medium01_Base_H") then {targetWeight = WT_MEDIUM} else 

{targetWeight = WT_LIGHT};

//task setup
_helitsk1 = player createsimpletask ["pick up container"];  
_helitsk1  setsimpletaskdescription ["pick up the container and take it to the marker noted", 

"pick up container", ""];   
_helitsk1  settaskstate "CREATED"; 

waitUntil {taskState _helitsk1 == "ASSIGNED"};

//we cant attach helicopter directly, so we use slinghelper
_slingHelper = "Misc_cargo_cont_net1" createVehicleLocal getPosATL targetHeli; 
_slingHelper hideObject true;

If (targetHeli isKindOf "Heli_Medium01_Base_H") then
{_slingHelper attachTo [targetHeli, [0,0,-2]];
sleep 1;
detach _slinghelper;
targetheli attachTo [_slingHelper,[0,0,2]]} 
else 
{_slingHelper attachTo [targetHeli, [0,0,-1.5]];
sleep 1;
detach _slinghelper;
targetheli attachTo [_slingHelper,[0,0,1.5]]};

_helitsk1  setsimpletaskdestination (getPosATL _slingHelper);  
hint "heli task assigned";
_wp1 = [Player, _slingHelper, 10, 1, {hintC "You dropped the cargo!"},targetWeight] spawn 

BIS_fnc_wpSlingLoadAttach;

waitUntil {scriptDone _wp1};

hint "sling load attached";
_helitsk1 setSimpleTaskDestination (getPosATL hw3);
_wp2 = [Player, hw3, 10, 1, [0,360]] spawn BIS_fnc_wpSlingLoadDetach;

waituntil {scriptDone _wp2};

deleteVehicle _slingHelper;
hint "slingload detached";
_helitsk1 setSimpleTaskDestination (getPosATL hw1);
_wp3 = [player, getPosATL hw1, 10,[],true] spawn BIS_fnc_wpLand;

waitUntil {scriptDone _wp3};

_helitsk1 setTaskState "SUCCEEDED";
hintc "good job, shut down your engine!";

//cleanup
player removeSimpleTask _helitsk1;

Edited by nephros

Share this post


Link to post
Share on other sites

Nice! Thanks for sharing. I remember trying to air lift helis in the past and got no where. Presumed I'd done something wrong.

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  

×