Jump to content
Sign in to follow this  
BackSH00TER

Boat Insertion Mission (Need Scripting Help)

Recommended Posts

I am new to the whole Arma Mission Editing so I'm reaching out to the community in hopes that you guys will be able to help me in making this mission. Before anyone tells me to google it, I shall let you know I have already searched the forums for hours and found somewhat similar cases but they don't satisfy exactly what I'm looking for. And with being new to the editor I'm not exactly sure how to find the scripts I've found to work for my mission.

So here is what I'm trying to do:

1 group of soldiers rides up to the shore riding in 2 boats. When they reach the shore, all the soldiers get out of the boat except for the driver(AI). After all of the soldiers have successfully exited the boat then the two drivers of the boats will turn around and head off into the ocean and then disappear.

There is more to the mission after this and I've figured most of it out. This is the part that I'm having the most trouble with however.

This is what I have:

Mission begins with 1 group of 8 players under the command of 1 Team leader. The group is riding in separately on 2 different Assault Boats, 4 on each boat and each boat has its own NPC driver. The boats are named c1 and c2, and in 4 of the soldiers init I put, this MoveInCargo c1, and in the other 4 I put, this MoveInCargo c2. The drivers are the same except for, this MoveInDriver.

The waypoints for the boats head up to shore with the first being a full speed waypoint and then as they near the shore I would like for them to slow down to either normal or limited speed. (For some reason when they get to limited speed the AI driver starts doing weird things like randomly stopping backing up, going forward. If anyone knows a fix for that please let me know).

So after the first full speed, I change it to normal speed and then immediately after that is a Transport Unload waypoint, and after that is a move waypoint that has 8 seconds in its timeout.

I have tried numerous things in the "On Act" field of the Transport Unload waypoint but none have worked thusfar other than this,

{unassignvehicle _x; dogetout _x} foreach units player;

The only problem with this line is that since all the units are in 1 group and they are split in two groups. When I put that in the transport unload of the first boat and its soldiers unload then the second boat just kinda stops moving and drops its soldiers there whether its at the shore or not.

So if there is a way to put a script in for each boat that will only make the units in THAT boat get out and that will keep the driver in as well.

I apologize for how long this is, I'm just trying to include as much information as I can to help you guys help me :).

Thanks in advance for the help!

Share this post


Link to post
Share on other sites

You could try using EJECT to get them out.

As far as the insertion goes, have you tried unit capture/unit play? That way you can drive exactly how you want for the insertion and ensure you drop them right where you want them

Share this post


Link to post
Share on other sites

As far as the insertion goes, have you tried unit capture/unit play? That way you can drive exactly how you want for the insertion and ensure you drop them right where you want them

I'm not familiar with unit capture/ unit play. Do you mind explaining how that works? Does it allow you to tell the boat exactly where it is going to go?

Share this post


Link to post
Share on other sites

You actually record the position of where you drive a vehicle then you play back those positions with another vehicle precisely. Depending on how long you travel it can take up quite a bit of space in your missions. For single player it's not bad but multiplayer might not be a good choice. It tends to jitter a lot in MP. Also it's for vehicles only, there's no animation, it merely moves the model along the path, so for infantry they'll glide while not moving for example.

Share this post


Link to post
Share on other sites

Sweet, I think the boat ride would be about like 30 seconds max so that shouldn't be too bad for MP? I tried looking it up for use in Arma3 but couldn't find very much about how it works. I watched a few Arma2 tutorials on how to use it and it appears some of the things are missing or haven't been added yet to Arma3? Either that or I just couldn't find them.

Share this post


Link to post
Share on other sites
OA-UnitCapture-amp-UnitPlay-Functions dig through that for instructions. :) Basically you'll run the UnitCapture in the editor, start capture, do your moves, stop. Then paste the clipboard into a script. Then play the script back using UnitPlay on a vehicle.

Share this post


Link to post
Share on other sites

Just because I like the idea...

The link given has all the info you need but to summarise:

BACKGROUND

BIS_fnc_UnitCapture

Description:

Records movement data of input unit over a specified period of time.

Pressing the ESC key, the duration ending, or the unit dying ends

the recording.

Parameters:

Unit - Unit to capture movement data from

Duration - Duration to capture for

OPT:FPS - OPTIONAL: Frames recorded Per Second (default 20). Limit is 1 - 100

OPT:Firing - OPTIONAL: If true, will record the input unit's weapon fire data as well

OPT:StartTime - OPTIONAL: Starting time offset for the frame time

CONTEXT

I will use your scenario as context - we will have a boat called boat1 and we want to insert them onto a beach

What unit capture/play actually does is copy the POSITION and when you play it, it sets the vehicle position to the position it was every frame when you recorded - this simulates the movement!

It also means a lower FPS recording (covered below) will seem jerky because ... well it is!

USAGE (RECORDING)

So to run unit capture at a minimum you use something like:

rec1 = [boat1, 300] spawn BIS_fnc_UnitCapture;

***NOTE: Use SPAWN not CALL

This will record the unit 'boat1' movement for 300 seconds or until you press escape (or die)

If you are going to do it in MP or when you review it, it seems choppy, you can make it smoother by increasing the recording FPS value (defaults to 20)

So eg2 (What I used in the test mission I will link to)

rec1 = [boat1, 300, 40] spawn BIS_fnc_UnitCapture; (boat1 recorded for 300 seconds at 40 FPS)

To actually record something you need to call that function. Easiest way is to set up a radio trigger with the above line in the On Activation. Another way to do it is just put that line in the unit init box (which will start recording as soon as the mission starts)

So to record what you want - start the recording, do whatever crazy driving you want to do and then press escape (which will bring up the standard escape/pause menu). Press it again or click resume game and when you are back in game you will have a hint summarising the recording. Now all you need to do is press F1!

RECORDED! F1 pressed... WHAT NOW?

Alt-tab out and open note pad (or other script editor). Paste the data (control-V or edit-paste) and you will see a WALL of numbers come up. That is the movement data you just recorded in the form of arrays of positions.

Step 1 -Assingn the movement data to a variable. (eg. testMovementData1)

At the VERY start of the data (eg. something like this: [[0,[2771.43,6518.35,-0.383466]........)

put

testMovementData1 =

So now you have something like:

testMovementData1 = [[0,[2771.43,6518.35,-0.383466]........

Step 2 - SEMI COLON!

At the end of your data, put a ;

ie...

.....,[0.854578,-0.687499,0.00402232]]]

becomes

.....,[0.854578,-0.687499,0.00402232]]];

Save the file as testMovementData1.sqf in the folder that your mission is saved to.

SCRIPTING TIME!

Create a new sqf file (we will call it moveBoat.sqf)

In moveBoat.sqf put:

move_now = [boat1, testMovementData1] spawn BIS_fnc_UnitPlay;

THAT WAS EASY... PLAY!

Open your mission again and remove the recording part (ie. if you put it in your boat1 init, delete it)

All we need to do is execute our testMovementData1.sqf script (to set the value of our moveData) then our moveBoat.sqf file! For now, create a radio trigger that will execute the script (eg. On act -- null = [] execVM "testMovementData1.sqf"; null = [] execVM "moveBoat.sqf";)

Note - You can just have one script with all the information in it ie. instead of setting your move data in testMovementData1.sqf, you can declare the variable at the start of the moveBoat.sqf and paste the wall of text in there... The issue with this is if you have multiple sets of movement data (eg. an insert and an extract), it can make your script messy!

Press preview!

Nothing happens.... the boat sits there...

Call your radio trigger - And we are away!

POINTS TO NOTE!

Floating boat! As the unitCapture works on POSITION, you may find your boat floats a bit - that is due to differences in the waves when you recorded it. For a boat insertion I would suggest setting the waves to 0 to avoid that issue.

Quiet insert! If you play it straight away, you will probably find you are moving but there is no engine sound... There are two ways around this:

1. Write in your mission that you are inserting super quietly

2. Give the boat a waypoint straight in front of it and put your unitPlay call in the onActivation of the waypoint - the AI driver will turn the engine on and you will have the engine sounds! Note that the engine sound wont change in line with the speed though (recall that this issue is caused because all we are doing with unitCapture/unitPlay is setting the position of the boat to give the illusion of movement)

I DONT WANT THE BOAT TO WAIT ON THE BEACH!

You can get rid of the boat by giving it a waypoint once you are out of the boat. You can also use unitCapture/Play to record some funky driving to get rid of it.

See next post for some more advanced options including detail on getting the blokes out of the boat.

---------- Post added at 11:17 AM ---------- Previous post was at 10:45 AM ----------

SOLUTION TO YOUR QUESTION

I have set up a QUICK demo mission of how it could look for you here:

https://dl.dropboxusercontent.com/u/74159983/testCapturePlat.Stratis.zip

(Note it was meant to be testCapturePlay but I typed it too quickly... oops)

The way I did it was recorded myself driving to the insertion location, escape, F1 and set that as moveData1

I then made a script that would:

1. execute that data (unitPlay)

2. On completion of the playback would immediately start recording again. (See below for how-to)

3. Unload the dismounts in the boat

I then ran the mission a second time with the above script in the init of the boat.

This led to:

1. Me as driver sitting the the boat not controlling it

2. Arriving at the beach and a recording starting

3. Transported dismounts got out one at a time

4. Then I pulled back from the shore and took off.

5. At a suitable distance away, escape, F1 and save the data to moveData2

I then exited the mission again, and modified the script to do the below:

1. Execute moveData1 (insertion)

2. On completion of that playback, execute moveData2 (extraction)

3. Unload dismounts in the boat

This new script was saved and now when you run it, the boat goes to shore, dismounts unload and the boat extracts.

RATIONALE FOR MY SOLUTION

The main benefit of unitCapture/Play is you have fine control over the movements. The issue you will run into a lot of the time with a vehicle inserting then extracting is the gap between you arriving at your destination and when you have to leave - the AI will try and take over and do unpredictable stuff... Then when your departure unitPlay script is called the vehicle will teleport to the location you started the recording from - Looks terrible!

The benefit of the above technique is whilst you are playing two seperate recordings, the second one starts immediately after the first. It also allows you to set up your disembark script to fire between the two recordings. That means the second recording will commence with you waiting for dismounts to get out, then when you are happy they are all out, you execute your amazing departure!

The best way to work this stuff out though is just make a test mission and play around.

(eg. Want a hover tank? unitCapture a chopper, fly low and slow, then unitPlay that data on a tank!)

WHEN HAS RECORDING PLAYBACK FINISHED?

If you want to wait until the playback is finished before doing something (eg. Wait until insertion playback is finished, then order dismounts to get out/play extraction unitPlay) you can add a variable that will be assigned TRUE when it is finished.

eg.

[sCRIPT]

boat1 setVariable ["InsertionDone", false];

[boat1, moveData1, [boat1, "InsertionDone"]] spawn BIS_fnc_UnitPlay;

waitUntil { boat1 getVariable "InsertionDone"};

// stuff you want to execute once insertion is complete!

[boat1, moveData2] spawn BIS_fnc_UnitPlay;

[/sCRIPT]

GET DISMOUNTS OUT

For this scenario I named the group of dismounts delta1 by putting in the group leaders init

delta1 = group this;

Then in the insertion script (As it was being run right at the start of the mission) I put

[sCRIPT]

{_X moveInCargo boat1} forEach units delta1;

[/sCRIPT]

then in the same script, once the playback of the insertion had finished I put

[sCRIPT]

{

doGetOut _X;

unassignVehicle _X;

} forEach units delta1;

[/sCRIPT]

Simple search will help for that kind of stuff eg:

http://forums.bistudio.com/showthread.php?76848-Eject-MoveInCargo-Howto

WHAT ELSE CAN IT DO?

You can also set it to record firing data... Quite useful for if you want to set up a perfect CAS run, you can record movement and firing data then when a trigger fires have the plane come in perfectly and engage the (static) target (assuming you can pilot it well enough!)

If you are interested in that, PM me or I can add it to this post for reference later if needed.

FINAL POINTS

As I mentioned earlier, the engine will not be on if you start playback on init. You can try out something like:

[sCRIPT]

this engineOn true;

[/sCRIPT]

Or set waypoints. Note this is true of choppers too - if you go straight into unitPlay with a chopper on the ground, you will be flying with no engine on!

The benefit of waypoints is (eg. using the boat insertion example) you can set a waypoint out to sea where you want the boat to wait and call the insertion movement on init. Once the AI has control of the boat again he will go back to heading to the current waypoint. Note you would still want to record part of the movement away from the beach to ensure that the driver:

1. Waits for dismounts to get out

2. Doesnt do something stupid like drive into a rock

But it does mean you could have a much shorter unitCapture/Play; once he is safely pointed to the waypoint, when the unitPlay ends he will keep going to it!

Hopefully that helped you out somewhat, have fun playing around with it!

BIG CAVEAT - All of the information above is stuff I have worked out through trial and error - I am by no means a jedi at this stuff and would listen to those more informed over me if it is contradicting.

That said - All of the above is stuff I have effectively used in SP and MP (hosted and dedi) without issues.

Also - Some of the stuff included in unit init would be better in the init.sqf however it was kept in-editor for simplicity at this stage. Variable declaration especially would be better declared in the init.sqf!

Edited by Zodd
Added final info

Share this post


Link to post
Share on other sites

Ok i found out why it stutters, when i remove everything from the map the animation playes without stuttering.. So the problem is the object density or the object amount.

Share this post


Link to post
Share on other sites

One addition:

For the unitPlay, enclose everything in

if (isServer) then

{

//Stuff goes in here

}

Share this post


Link to post
Share on other sites

I'm also very new to editing and mission building, but as this is an interesting setup for me as well, I'll have a shot ;)

May be a workaround would be to use 2 smaller (4 guys) teams - each on one boat - at first during the insertion phase, and let one group join (probably via this command) the other via trigger when they're all on solid ground.

Just an idea, not sure if it works, but I might try it later today.

Edit:

It's probably an easier method to use a "join" waypoint.

I did the following: 2 boats with each 4 men to form one team plus driver. I made the unload waypoints for the boats 1 and 2 and made one waypoint for the other group a slight bit away from the shore. That's a "join" waypoint. Then I made a second waypoint for my team and synchronize (not group) it to the other groups "join" waypoint. When the other team reaches its waypoint, the other groups members become your team members.

Here's a link to a little mission sample: Download

Edited by Schlonz75
One never stops learning :)

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  

×