0toks 10 Posted April 26, 2010 Hey guys ive got an idea for a script but dont quite have the skill to pull it off. Basic concept i want is as follows; I want an SQF script when activated vior my radio alpha trigger does this; 'heli_1' is to depart my HQ, off 'pad_1' and fly to a map-click position on the map and wait for all members of my patrol to board. Once my patrol is on 'heli_1' it will then fly to another map-click position. Here it will wait until all my patrol is off then it will fly back to my HQ and land on a heli pad named 'pad_1'. I want this to be a repeated script, one i can call on anytime for heli/dynamic movement. 1. The helicopter is a blackhawk named 'heli_1'. 2. The heli pad is named 'pad_1'. 3. I have a trigger that is radio alpha, repeated. 4. My patrol consists of 6 members; my player (no name) and five others named 'a', 'b', 'c', 'd' and 'e'. SOMEONE PLEASE HELP :o Share this post Link to post Share on other sites
IndeedPete 1038 Posted April 26, 2010 You don't need to write a script for that. Just use the SecOps Module! ;) http://community.bistudio.com/wiki/Secondary_Operations_Manager http://forums.bistudio.com/showthread.php?t=73329 Share this post Link to post Share on other sites
0toks 10 Posted April 26, 2010 I know the SECOP way, just would like to actually script it for my own learning. Can anyone do this?? Share this post Link to post Share on other sites
Joshii 10 Posted April 26, 2010 Alrighty, what I did for you is I placed a second pad over pad_1 called it pad_2, its invisible. Then the code should be self explaining hint "Click on the map to select a pickup point"; onMapSingleClick "pad_2 setPos _pos; onMapSingleClick ''; true;"; waitUntil {pad_1 distance pad_2 > 20}; hint "Location Confirmed"; heli_1 move getPos pad_2; waitUntil {heli_1 distance pad_2 < 120}; heli_1 land "LAND"; waitUntil {player in (crew heli_1)}; heli_1 move getPos pad_1; waitUntil {heli_1 distance pad_1 < 120}; heli_1 land "LAND"; Share this post Link to post Share on other sites
0toks 10 Posted April 26, 2010 Will try, cheers mate hope it goes well! ---------- Post added at 09:10 PM ---------- Previous post was at 08:41 PM ---------- Okay it works but the helicopter wont land to pick me up it just hovers... ? Share this post Link to post Share on other sites
Joshii 10 Posted April 26, 2010 Should be picking you up. Tested it on Utes airport and it seemed to be working for you if it doesn't you should use the PICKUP waypoint, search through the forums for it. In addition to that you might want to add a if condition around the code to clarify whether the helicopter is available or not. Could be a distance check to pad_1 or or so. Or just check whether the engine is on or not. Share this post Link to post Share on other sites
0toks 10 Posted April 26, 2010 wow thats a bit advanced for me!! im a learner ok cheers will try look around a bit more Share this post Link to post Share on other sites
Joshii 10 Posted April 27, 2010 (edited) Code with the if condition checking whether pad_1 is at pad_2 location and setting pad_2 back to pad_1 as soon as the helicopter has the people inside. if ((pad_1 distance pad_2) < 5) then { hint "Click on the map to select a pickup point"; onMapSingleClick "pad_2 setPos _pos; onMapSingleClick ''; true;"; waitUntil {pad_1 distance pad_2 > 20}; hint "Location Confirmed"; heli_1 move getPos pad_2; waitUntil {heli_1 distance pad_2 < 120}; heli_1 land "LAND"; waitUntil {player in (crew heli_1)}; pad_2 setPos getPos pad_1; heli_1 move getPos pad_1; waitUntil {heli_1 distance pad_1 < 120}; heli_1 land "LAND"; } else { hint "The helicopter is currently busy"; }; Also what you could do to get some more stuff into it + learn some sqf basics. Calculate a ETA of the helicopter to the pickup. Idea To calculate that you would need the speed of the helicopter, I currently can't go ingame to check but I am going to calculate it with 150. Then you basically could take the distance in meters and then calculate the heli eta Calculation My calculation is probably wrong, but just showing up the system anyways. I took a airspeed of 150km/h and then distance and then rounded it to minutes. Code if ((pad_1 distance pad_2) < 5) then { hint "Click on the map to select a pickup point"; onMapSingleClick "pad_2 setPos _pos; onMapSingleClick ''; true;"; waitUntil {pad_1 distance pad_2 > 20}; hint "Location Confirmed"; _location = heli_1 distance pad_2; _meterps = 150; if (isEngineOn heli_1) then { _time = ceil(_location / _meterps); hint format ["Helicopter ETA is %1 minutes",_time]; } else { _time = ceil(_location / _meterps + 2); // taking 2 minutes into account for the engine to start hint format ["Helicopter ETA is %1 minutes",_time]; }; heli_1 move getPos pad_2; waitUntil {heli_1 distance pad_2 < 120}; heli_1 land "LAND"; waitUntil {player in (crew heli_1)}; pad_2 setPos getPos pad_1; heli_1 move getPos pad_1; waitUntil {heli_1 distance pad_1 < 120}; heli_1 land "LAND"; } else { hint "The helicopter is currently busy"; }; Edited April 27, 2010 by Joshii Share this post Link to post Share on other sites
0toks 10 Posted April 27, 2010 Kool joshii i'll try that now, hope it works... ---------- Post added at 06:38 PM ---------- Previous post was at 05:45 PM ---------- Seriously the helicopter wont land....???? I have the exact same script the heli wont land?? Share this post Link to post Share on other sites
Joshii 10 Posted April 27, 2010 (edited) Right.. Check this out. It was working on every single of my tests. The only problem that may be there is that if the heli doesn't get too close to the landing pad ( 200 meter ) in this case. Then it won't land. But it should be working fine. Post a feedback asap please. Edited April 27, 2010 by Joshii Share this post Link to post Share on other sites
0toks 10 Posted April 27, 2010 testing now cheers mate ---------- Post added at 08:42 PM ---------- Previous post was at 08:20 PM ---------- Still wont land, i used your files... is it my game?? ---------- Post added at 08:43 PM ---------- Previous post was at 08:42 PM ---------- I have the latest ACE 6 installer etc. Tried it on VBS2 1.3 same problem wont land... Share this post Link to post Share on other sites
Joshii 10 Posted April 27, 2010 Nah probably not your game, just that I didn't write the script to actually pick someone up but to land at a place as soon as it's close enough and then wait for someone to enter. If you have a debug console installed (( http://forums.bistudio.com/showthread.php?t=73356 )) then you should type in the following heli_1 distance pad_2 if that is above 200 then the helicopter won't land at all. This could be cause by e.g a mountain blocking the way so that the helicopter can't get close enough. I only tested it on flat terrain such as the airport runway and it wasn't a problem there :o A way to avoid this is simply by adding a load waypoint for the helicopter http://community.bistudio.com/wiki/setWaypointType So just go ahead and modify it. p.s you have vbs 2? :o Share this post Link to post Share on other sites
0toks 10 Posted April 27, 2010 yeah learning scripting now with vbs2 im green man!! Still learning cheers mate i'll try that out too Share this post Link to post Share on other sites
Joshii 10 Posted April 27, 2010 Roger, if that with the waypoint doesn't work then just send me a PM and I will write something that takes me more than 1 minute and that actually works :P But the other thingy is a good base to start off something I guess. Good luck and have fun with it :P Share this post Link to post Share on other sites
0toks 10 Posted April 27, 2010 cheers dude thanks for the help! Share this post Link to post Share on other sites
0toks 10 Posted May 1, 2010 My attempt at a script to make my own dynamic transport or map-click transport. Remember im very new to this and from my research this is what ive made up. I dont want to use the BI function/sec ops etc i want to script it for learning purposes. I have a mission with these; 1. Helicopter named chopper. 2. Trigger, radio alpha activated repeated. It's on act is nul=[] execVM "scripts\heli\dt.sqf"; 3. H Pad named pad. 4. Invisible H Pad named loc. 5. My player named toks. 6. Marker named lz. dt.sqf is //call chopper commands dt=true; titleText ["Indicate LZ on map by map-click","PLAIN DOWN"]; onMapSingleClick "loc setPos _pos;dt=false"; waitUntil {!dt}; "lz" setMarkerPos getPos loc; chopper move getPos loc; //land chopper commands player assignAsCargo chopper; waitUntil {chopper distance loc < 180}; chopper land "GET IN"; waitUntil {player in chopper}; nul=[] execVM "scripts\heli\repeat.sqf"; repeat.sqf is //repeat repeat=true; titleText ["Indicate LZ on map by map-click","PLAIN DOWN"]; onMapSingleClick "loc setPos _pos;repeat=false"; waitUntil {!repeat}; "lz" setMarkerPos getPos loc; chopper move getPos loc; nul=[] execVM "scripts\heli\drop.sqf"; drop.sqf is //drop off commands waitUntil {chopper distance loc < 180}; chopper land "GET OUT"; unassignVehicle toks; waitUntil {!(player in chopper)}; chopper move getpos pad; //chopper return to base commands waitUntil {chopper distance pad < 180}; chopper land "LAND"; Okay BUT THERES PROBLEMS. 1. Helicopter comes to my map-click, starts landing to its hover point then as soon as its near the ground it starts climbing again and then just hovers high above me. It (the helicopter) doesnt listen to my waitUntil commands... 2. I tried to use Code: chopper land "LAND" and i found sometimes the chopper actually lands and waits, sometimes it wont. Its all just too stressfull and inconsistant! During these times it does wait if my player jumps on it actually continues with the script, i click on my next destination and it moves there and goes to land but it then has another problem it wont wait for me to get out! AAAHHHH!!! Is this a bug in the game engine or is it my bad ammature scripting?? Share this post Link to post Share on other sites
Joshii 10 Posted May 1, 2010 Check out the arma.rpt http://community.bistudio.com/wiki/arma.rpt it pops up the error messages from your script. So if you have done anything wrong then it will show up in there makes it a lot easier to debug stuff. Share this post Link to post Share on other sites
Inkompetent 0 Posted May 1, 2010 Check out the arma.rpthttp://community.bistudio.com/wiki/arma.rpt it pops up the error messages from your script. So if you have done anything wrong then it will show up in there makes it a lot easier to debug stuff. In addition to the above: Run the game with -showScriptErrors in the shortcut. Makes error messages that are logged in the RPT file also pop up in-game, so you can see exactly when it encounters an error. I do however not have a clue why the darn waitUntil {player in chopper}; wouldn't be enough though =/ Share this post Link to post Share on other sites
0toks 10 Posted May 3, 2010 Yea the chopper does wait, i found that out through testing but waits high above in a hover. It doesnt wait in the "GET IN" position (just above the ground). Its insane, if i order my men in the chopper it comes back down then as soon as they are in it hovers high again. It wont wait for ME to get in but if i do manage to get on, it takes off to the next position i planned for on the map. I tried the flyInHeight command but it causes the chopper to crash itself into the ground. Share this post Link to post Share on other sites