twisted 128 Posted January 10, 2015 (edited) been trying to get an AI heli to simply 1) fly to a position 2) stop 3) drop sling load 4) fly to another positio 5) release slingload ive got up to... _helic = "B_Heli_Transport_01_camo_F"; _veh = [[_tempPos select 0, 50 + (_tempPos select 1), _tempPos select 2], 180, _helic, _callSide] call BIS_fnc_spawnVehicle; // THIS PART WORKS FINE _heliVehicle = _veh select 0; _heliCrew = _veh select 1; _heliGroup = _veh select 2; _wp1 = _heliGroup addWaypoint [_landPos, 1]; //PROBLEM EVEN WITH THIS SIMPLE WAYPOINT _wp1 setWaypointSpeed "FULL"; // THE HELI DOESNT COME HERE AND STOP. IT FLIES TO SOMEWHERE IN ABOUT 100m-200m AND EACH TIME ITS DIFFERENT _wp1 setWaypointType "MOVE"; _wp2 = _heliGroup addWaypoint [_landPos, 0]; // HERE NOTHING HAPPENS _wp2 setWaypointSpeed "NORMAL"; _wp2 setWaypointType "LIFT CARGO"; // UNTIL I GET THE ABOVE WORKING NO POINT IN TRYING THE OTHER STEPS. SHOULD BE SIMPLE RIGHT? How can something that should be so simple be soooo very unpredicatble>? be very useful for me (and others seeking to get to figure out the heli slingload scripts) to have a step by step bulletproof way to accomplish this. solving the problem well so anyone trying to get what should be straightforward functionality actually finds it doable. Edited January 10, 2015 by twisted Share this post Link to post Share on other sites
soolie 189 Posted January 10, 2015 (edited) I have a supply drop script with working waypoints(this one is just for VAS, finished a fully customizable one last night will post later). The first waypoint is created when you click on the map(where the drop is) and the second is semi random so it flies far away before being deleted. Hope it helps! (the _pos refers to where you click the map) openMap [true,true]; clicked = 0; hintc "Left click on the map where you want the supplies dropped"; ["supplymapclick", "onMapSingleClick", { _supplyLocArray = [+1000,-1375,-1500,-1125,+1250,-1000,+1375,-1250,+1500,+1125]; //~~~~~~~~~~Use the one below for testing. It spawns the heli much closer~~~~~~~~~~~~~~~~~~ //_supplyLocArray = [+500,-500]; _supplyRandomLocX = _supplyLocArray select floor random count _supplyLocArray; _supplyRandomLocY = _supplyLocArray select floor random count _supplyLocArray; _supply = [[(_pos select 0)+_supplyRandomLocX, (_pos select 1)+_supplyRandomLocY, (_pos select 2)+50], 180, "I_Heli_Transport_02_F", WEST] call bis_fnc_spawnvehicle; _supplyHeli = _supply select 0; _supplyHeliPos = getPos _supplyHeli; _supplyMrkrHeli = createMarker ["supplyMrkrHeli", _supplyHeliPos]; _supplyCrew = _supply select 1; _supplyGrp = _supply select 2; _supplyGrp setSpeedMode "FULL"; _supplyGrp setBehaviour "CARELESS"; _supplyWP1 =_supplyGrp addWaypoint [(_pos),1]; _supplyWP1 setWaypointType "MOVE"; _supplyWP2 = _supplyGrp addWaypoint [[(_pos select 0)+_supplyRandomLocX, (_pos select 1)+_supplyRandomLocY, _pos select 2], 2]; _supplyMrkrLZ = createMarker ["supplyMrkrLZ", _pos]; "supplyMrkrLZ" setMarkerType "Empty"; "supplyMrkrHeli" setMarkerType "Empty"; clicked = 1; openmap [false,false]; onMapSingleClick '';}] call BIS_fnc_addStackedEventHandler; waitUntil {(clicked == 1)}; //hint "After clicked"; _supplyMrkrHeliPos = getMarkerPos "supplyMrkrHeli"; _supplyMrkrHeliPos2 = [_supplyMrkrHeliPos select 0, _supplyMrkrHeliPos select 1, (_supplyMrkrHeliPos select 2)+50]; _supplyHeli = _supplyMrkrHeliPos2 nearestObject "I_Heli_Transport_02_F"; _supplyMrkrLZPos = getMarkerPos "supplyMrkrLZ"; _supplyLZ = createVehicle ["Land_Laptop_device_F", getMarkerPos "supplyMrkrLZ", [], 0, "NONE"]; deleteMarker "supplyMrkrHeli"; deleteMarker "supplyMrkrLZ"; _supplyLZ hideObject true; waitUntil {( _supplyLZ distance _supplyHeli)<200}; _supplyHeli animateDoor ["CargoRamp_Open",1]; waitUntil {( _supplyLZ distance _supplyHeli)<100}; sleep 1.2; _supplyHeli allowDammage false; _supplyBox = "Box_NATO_Ammo_F" createVehicle position _supplyHeli; //~~~~~~~~~~~~~~~~~~~Edit Box Contents~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ clearWeaponCargo _supplyBox; clearMagazineCargo _supplyBox; clearItemCargo _supplyBox; //_supplyBox addweaponcargo ["srifle_EBR_F",10]; //_supplyBox addweaponcargo ["hgun_P07_F",10]; //_supplyBox addmagazinecargo ["20Rnd_762x51_Mag", 100]; //_supplyBox addmagazinecargo ["16Rnd_9x21_Mag", 30]; //_supplyBox addmagazinecargo ["30Rnd_9x21_Mag", 10]; //_supplyBox additemcargo ["optic_Aco", 10]; //_supplyBox additemcargo ["optic_Hamr", 10]; //_supplyBox additemcargo ["optic_Holosight", 10]; //_supplyBox additemcargo ["acc_flashlight", 10]; //_supplyBox additemcargo ["acc_pointer_IR", 10]; //_supplyBox additemcargo ["U_B_CombatUniform_mcam", 10]; //_supplyBox additemcargo ["U_B_CombatUniform_mcam_tshirt", 10]; //_supplyBox additemcargo ["U_B_CombatUniform_mcam_vest", 10]; //_supplyBox additemcargo ["H_HelmetB", 10]; //_supplyBox additemcargo ["H_HelmetB_light", 10]; //_supplyBox additemcargo ["H_HelmetB_paint", 10]; //_supplyBox additemcargo ["V_PlateCarrier1_rgr", 10]; //_supplyBox additemcargo ["V_PlateCarrier2_rgr", 10]; //_supplyBox additemcargo ["V_PlateCarrierGL_rgr", 10]; //_supplyBox addbackpackcargo ["B_AssaultPack_ocamo", 10]; //~~~~~~~~~~~~~~~~Add VAS~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ _supplyBox addAction["<t color='#ff1111'>Virtual Ammobox</t>", "VAS\open.sqf"]; deleteVehicle _supplyLZ; _supplyBox attachTo [_supplyHeli, [0, 0, -2] ]; detach _supplyBox; _supplyChute = createVehicle ["B_parachute_02_F", position _supplyBox, [], 0, "CAN_COLLIDE"]; _supplyBox attachTo [_supplyChute,[0,0,-0.5]]; _supplyChute hideObject true; _supplyChute setPos getPos _supplyBox; _supplySmoke = "SmokeShell" createVehicle (position _supplyBox); _supplySmoke attachTo [_supplyBox, [0,0,0]]; _supplyLight = "Chemlight_green" createVehicle (position _supplyBox); _supplyLight attachTo [_supplyBox, [0,0,0]]; sleep 1; _supplyChute hideObject false; _supplyHeli allowDammage true; _supplyHeli animateDoor ["CargoRamp_Open",0]; waitUntil {(getPos _supplyBox select 2)<3}; detach _supplyBox; sleep 10; {deleteVehicle _x;}forEach crew _supplyHeli;deleteVehicle _supplyHeli; //hint "end"; edit - Just noticed your code _wp2 = _heliGroup addWaypoint [_landPos, 0] I believe the 0 is the index number, which is the order in which the waypoints are added? Not sure but try changing the first to 1 and the second to 2 Edited January 10, 2015 by Soolie Share this post Link to post Share on other sites
epicgoldenwarrior 11 Posted January 10, 2015 Atm heli's have trouble picking stuff up. You could use triggers to sling load and release the load though. Not the same, but it works. Share this post Link to post Share on other sites
twisted 128 Posted January 20, 2015 (edited) thanks (sorry for taking so long to get back but still having no progess here) the code im using isnt dissimilar to the examples above. i call the heli using this addAction ["Call extraction heli.", "tws_claim_objective.sqf",[this],1,true,true]; put inside the init of a mrap tws_claim_objective.sqf is ... sleep 2; _eastHeli = " I_Heli_Transport_02_F"; _westHeli = "B_Heli_Transport_03_F"; _westHeliAttack = ["B_Heli_Attack_01_F"]; _eastHeliAttack = ["O_Heli_Attack_02_black_F"]; _heliA = ["B_Heli_Transport_01_camo_F"]; _helic = "B_Heli_Transport_03_F"; /*_vehGroup1 = [];*/ _objective = _this select 0; _caller = _this select 1; _landPos = getpos _objective; diag_log format ["in claim objective _obective is %1", _objective]; systemChat format ["in claim objective _obective is %1", _objective]; systemChat format ["in claim objective _caller is %1", _caller]; diag_log format ["in claim objective _caller is %1", _caller]; _tempName = format ["tws_objective_pos_%1", random 1009]; _foo = createmarker [_tempName, _landPos]; _foo setMarkerSize [100 , 100 ]; _foo setMarkerShape "ELLIPSE"; _foo setMarkerBrush "SOLID"; _foo setMarkerColor "ColorYELLOW"; _foo SetMarkerAlpha 0.95; _callSide = side _caller ; _areaClear = 0; if (_callSide == resistance) then { _helic = _eastHeli; _heliA = _eastHeliAttack; } else { _helic = _westHeli; _heliA = _westHeliAttack; }; // if area is not clear then halt. say are not clear _areaClear = 1; if (_areaClear == 1 ) then { if (heliOnRoute == 0) then { objectiveActivated = 0; publicvariable "objectiveActivated"; } else { hint format ["another chopper is on route. Please standby"]; sleep 5; }; _readyToSling = 0; if (objectiveActivated == 0) then { hint format ["Roger that. Extraction chopper inbound."]; sleep 1; heliOnRoute = 1; publicvariable "heliOnRoute"; _tempPos = [ getpos _caller, 350 , random 360 ] call BIS_fnc_relPos; _safeSpot = 0; _searchRadius = 500; _heliChosen = _heliA select 0; if (_callSide == west ) then { _heliChosen = _heliA select floor (random (count _heliA)); } else { _heliChosen = tws_east_helis select floor (random (count tws_west_helis)); }; _veh = [[_tempPos select 0, 50 + (_tempPos select 1), _tempPos select 2], 180, _helic, _callSide] call BIS_fnc_spawnVehicle; _heliVehicle = _veh select 0; _heliCrew = _veh select 1; _heliGroup = _veh select 2; heliOnRoute = 1; publicvariable "heliOnRoute"; _destPos = getPosVisual _objective; _wp2 = _heliGroup addWaypoint [_destPos, 0]; _wp2 setWaypointSpeed "NORMAL"; _wp2 setWaypointType "MOVE"; _wp2 setWaypointStatements ["true", "_readyToSling = 1;"]; _tempName = format ["tws_objective_pos3_%1", random 1009]; _foo3 = createmarker [_tempName, _destPos]; _foo3 setMarkerSize [10 , 10 ]; _foo3 setMarkerShape "ELLIPSE"; _foo3 setMarkerBrush "SOLID"; _foo3 setMarkerColor "ColorGREEN"; _foo3 SetMarkerAlpha 0.95; //////////////////// objectiveActivated = 1; publicvariable "objectiveActivated"; _dist = _heliVehicle distance _landPos; systemChat format ["dist is %1 ", _dist]; waitUntil { sleep 1; _readyToSling == 1}; _check = [[[_heli,_landPos, _objective],"tws_slingload_vehicle.sqf"],"BIS_fnc_execVM",false,false] call BIS_fnc_MP; } else { hintsilent format ["Cool down period. wait 30 seconds then try again."]; }; } else { hint format ["The area is not clear. Cannot send heli."]; } ; but the heli never ever gets above the object, so the below code to actually lift the heli never gets called _helisv = _this select 0; _landPos = _this select 1; _objective = _this select 2; _flyOffTo = [[[ _landPos,2000]],[] call BIS_fnc_randomPos; _heli = _helisv select 0; _heliCrew = _helisv select 1; _heliGroup = _helisv select 2; _heli enableRopeAttach enable; (tws_objective_array select 0) enableRopeAttach enable; sleep 5; _heli flyInHeight 20; _heli setSlingLoad (tws_objective_array select 0); sleep 5; waituntil {tws_objective_array ropeAttachedTo == _heli}; sleep 3; _heli flyInHeight 100; _wp2 = _heliGroup addWaypoint [_flyOffTo, 110]; _wp2 setWaypointSpeed "FULL"; _wp2 setWaypointType "MOVE"; it should be simple and a fundamental thing to be able to move a heli into position to sling an object. where am i screwing up? Edited January 20, 2015 by twisted Share this post Link to post Share on other sites
Lala14 135 Posted January 21, 2015 The only thing that I can think of is that sling loading is not working because the helicopter itself is unable to carry the vehicle! Description: Creates sling loading from first object to second object if possible Share this post Link to post Share on other sites
twisted 128 Posted January 21, 2015 The only thing that I can think of is that sling loading is not working because the helicopter itself is unable to carry the vehicle! taking your advice i changed it to a quad bke. still nothing, on further tests i notice that the helicopter stops 100m away from the position no matter what direction it comes from. setting trigger size doesn't help. why 100m? Share this post Link to post Share on other sites
Lala14 135 Posted January 21, 2015 here I fixed it and here is a mission Its now using only one script by the way. Also few notes added here and there also I suggest not using BIS_fnc_randomPos as it may not work on modded maps! also I added _actionid if you want to remove the action when the vehicle gets lifted ---------- Post added at 00:47 ---------- Previous post was at 00:18 ---------- here's another version without the use of the HOOK waypoint, it still can be combined into one script but i decided to leave it as it was. Now I should have told you what was your error, the error was that when setWaypointStatements, local variables are stored in another scope so you would have to change it to become a public version. Also Your cool down period doesn't seem to work and I didn't want to change it just a heads up. Share this post Link to post Share on other sites
twisted 128 Posted January 22, 2015 Thanks a lot man. Am at work right now but will give these a try when I get home. Appreciate your showing me where I was going wrong. Scope is a real tricky one. Share this post Link to post Share on other sites