taskConvoy.sqf Convoy script

Post Reply
User avatar
Jim
Posts: 90
Joined: Wed Jul 13, 2016 10:54 am
Contact:

taskConvoy.sqf Convoy script

Post by Jim »

Hey everyone, but especially 2600K!,

I'm trying to use the taskConvoy script in the framework and I'm having trouble understanding what it is that I'm supposed to be doing to get it working.

I've watched the video at http://youtu.be/_aELNA7j__c
named my ungrouped vics: truck, truck_1, truck_2, etc.
named my empty system markers: mkrConv, mkrConv_1, mkrConv_2
created an initial move waypoint - and in its 'On Action' field typed

Code: Select all

nul = [truck,"mkrConv",20] spawn ws_fnc_taskConvoy;
as per the video.

But then in the script explaination there's line 22:

Code: Select all

[[vehicle1,vehicle2],"firstMarker",speedLimit] execVM "scripts\taskConvoy.sqf";


So should I be using execVM instead of spawn_ws_fnc or does the execVM part need to go into the mission init field or a vic init field? do I need change [vehicle1,vehicle2] into [truck,truck_1,truck_2,Truck_3,Truck_4] as per line 30 that reads:

Code: Select all

Example: [[c1,c2,c3,c4,c5],"cvwp"] execVM "scripts\taskConvoy.sqf";
or do it need to edit something in the script?

Sorry, and thanks for your patience
lawman
Posts: 49
Joined: Sun Oct 23, 2016 7:21 pm
Contact:

Re: taskConvoy.sqf Convoy script

Post by lawman »

Hey Jim.

Would be useful to know precisely what error message you're being given that refers to line 22.
spawn and execVM are both methods of executing code, but tend to be used in different ways.

With the spawn command you're referring the engine back to a function which has been (hopefully) defined already in the mission at some point, in this case as part of the files contained within the template. I imagine spawn would be failing if it is not able to find the function.

You should be able to use execVM as you have suggested providing the file indicated only contains the desired code for the convoy.
You might run into trouble however if the file specified contains other functions as well.

This is (as I understand it) one advantage of using spawn and a pre-defined function.
You could have one file that defines a few different functions, and just call the one you want using spawn, while not having lots of separate files.

Truthfully though, i've never really used spawn (perhaps a bad habit i need to get around to breaking).
I know much more about execVM.

If you're around I'm free to hop on TS for a bit and see if we can work it out.
lawman
Posts: 49
Joined: Sun Oct 23, 2016 7:21 pm
Contact:

Re: taskConvoy.sqf Convoy script

Post by lawman »

I now see that you're not being referred to line 22 by a script error but by an example you're following.
Which makes your question a bit clearer now.

Basically you could use either, providing your script file contains only the desired effects.
If you're using the same piece of code multiple times it's considered good practice to make a function out of it:
Pre-compilation by the game engine can save up 20x the amount of time processing, even if the initial time is slightly lengthened. If you've written it twice, or if there is a kind of loop consistently being compiled (perhaps a script run by execVM), make it into a function (FUNCVAR =compile preprocessfilelinenumbers "filename.sqf");
See also:
https://community.bistudio.com/wiki/Cod ... a_function
User avatar
2600K
Posts: 173
Joined: Sun Jan 17, 2016 5:21 pm
Contact:

Re: taskConvoy.sqf Convoy script

Post by 2600K »

What is written in the sqf file is how it should be used - So use execVM. I probably should have removed that link.

Arma won't actually warm you if you try and use a function that doesn't exist... It just does nothing. There is no 'ws_fnc_taskConvoy' function in the framework, so nothing will ever happen.
User avatar
Jim
Posts: 90
Joined: Wed Jul 13, 2016 10:54 am
Contact:

Re: taskConvoy.sqf Convoy script

Post by Jim »

Thanks @Lawman & @2600K,

I'll try to catch you tonight for a chat, in the meantime I'll try to brute force it using execVM
User avatar
Jim
Posts: 90
Joined: Wed Jul 13, 2016 10:54 am
Contact:

Re: taskConvoy.sqf Convoy script

Post by Jim »

Figured it out and made a little example on the test server to fit into the template if you want to include it in the next update 2600K...

Make your convoy and ensure that the vics are not grouped together. Name the lead vic whatever you like, and the next vic the same but _1, then _2 etc.

Give the lead vic a regular Move Waypoint.

Then place an empty system marker - name it whatever you like - I've used: mkrConv

in the Move Waypoint 'On Activation' field type the following:

Code: Select all

nul = [[truck,truck_1,truck_2,truck_3,truck_4],"mkrConv"] execVM "scripts\taskConvoy.sqf";
where
truck, truck_1 etc are the variable names of the convoy vics,
mkrConv is the name of the first empty system marker (visible in eden map only) - simply copy and paste the first marker, eden editor will automatically add an underscore and a sequential number to the following markers - these are what your convoy will follow. Be careful with these on bridges and close to buildings. - Use the Hide Terrain Objects tool to remove obstacles that you find in testing.

To delay the convoy from heading off immediately you can add a delay timer to the Move WP.

In the template scripts folder is taskConvoy.sqf with more details and options to change the speed limit
lawman
Posts: 49
Joined: Sun Oct 23, 2016 7:21 pm
Contact:

Re: taskConvoy.sqf Convoy script

Post by lawman »

So the convoy script you've been using isn't within the template?
I'm still finding out lots about the template and was hoping you'd just made my life a bit easier
User avatar
Jim
Posts: 90
Joined: Wed Jul 13, 2016 10:54 am
Contact:

Re: taskConvoy.sqf Convoy script

Post by Jim »

The script is in there! Fear not!

2600K was referring to the link in the script description blurb to a video on YouTube that says to use ws_fnc (which is incorrect)

execVM is the way forward!

I think I need to experiment with the frequency of markers - it would be nice to use a lot fewer than i did on tonight's mission
lawman
Posts: 49
Joined: Sun Oct 23, 2016 7:21 pm
Contact:

Re: taskConvoy.sqf Convoy script

Post by lawman »

I may be wrong, but I think it's incorrect to say that vehicles HAVE to be named incrementally for that script to run?
As far as I can see it just runs the following:

_convoy = array of vehicles;
{do the things} forEach _convoy;
User avatar
Jim
Posts: 90
Joined: Wed Jul 13, 2016 10:54 am
Contact:

Re: taskConvoy.sqf Convoy script

Post by Jim »

@Lawman - My understanding really is sub-par so I have no idea! you could well be right! Will try tonight with Alice, Bob, Charlie, Duncan and Emily!
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests