Call to Arms

Call to Arms

Not enough ratings
Automatic Mine Laying Script
By The Old Relic
This guide shows you how to create a minefield with engineers working continuously until there are no mines left in the supply truck.
   
Award
Favorite
Favorited
Unfavorite
The Video of the Completed Script
This guide is a text version of a script I saw in a german language youtube video dated Oct 2010. A big thanks to the owner of the original video. The reason i put it into a guide is that I hope it will help those who are interested in scripting to start with something easy with a step by step guide to assist.
https://youtu.be/DlH6vUA7foI
Start with the basics.
Create your Map
In F2 mode, create your map and save it.



Spawn Units from Mission Editor
Press F3 to access mission editor. Spawn in the following units:

- 2 tank crew (can be any infantry type but i use tank crew to drive the supply truck)
- 3 engineers (mine laying team)
- 1 basic supply truck (to carry the engineers and mines to the minefield location



Load Truck with Mines and Soldiers
Still in F3 mode, you need to load the supply truck with mines.

1. Select the truck and press U (U brings up a menu that allows you to alter a number of things for the selected entity) Click on inventory option as shown below.

2. The Stuffing screen will appear. Select S at bottom right of Stuffing screen to bring up a list of Stuff. (A is for Ammunition, W is for Weapons) As shown below.

3. Locate the Claymore mine in the list. Select it and drag it into the inventory screen on the left. It will transfer Claymore mines to the Truck inventory in bundles of 100. Ctrl + drag will move an individual mine.

4. Load soldiers into truck. Press F1 to get into Game Mode. Select tank crew first and right click on truck. (The AI loads the cabin first so that is where you want your tank crew). Once crew are loaded, select your engineers and right click on truck. Then engineers will climb up into the back of the truck. As you can see in both pics below.



Congratulations, the basics are out of the way. Now onto the next section where we start Scripting!
Give the Truck a Tag
You now need to give the truck a tag ( a name). This tag allows the editor to identify what entity you are referring to in the rest of the scripting process. To tag an entity, do the below:

1. Enter Mission Editor mode (press F3) and select the truck only.
2. Press Ctrl + T. This brings up the Tag screen.
3. Type the name of the Tag. For this example i used minetruck as shown in the below pic. (You can use any name as the tag)


Tagging is essential when creating missions. The editor needs to be told what entity to use in your scripting. As you can see, creating a tag is rather easy. If you want to view tags in a mission, simply press Alt + T. Then press it again to hide them.
Create Waypoints for the Truck.
By creating waypoints, you are telling a mobile entity where you want it to move to when you start the mission. Waypoints can be used for many things, including but not limited to:
1. Convoy paths for vehicles in a game
2. Patrolling soldiers
3. Helicopter and Aircraft flying patterns, etc etc.

Creating the Waypoints for the Minetruck.

Whilst still in F3 mode, select the Waypoint submenu (looks like a flag in a hole and highlighted in green in the below pic). Click on Add (next to the autolink checkbox) and place as many waypoints as you need. For this example I will use 3 waypoints

Click where you want to place the waypoints as i have done below. Once placed, click link so that each waypoint links to the other. For some reason, autolink does not work for me. Might be a bug.

And once linked they should look like the below. You can move each waypoint around by selecting and dragging to a new location. The truck will follow the waypoints as it drives when the mission starts.
Creating the Minefield location using Zones
Now we need to tell the engineers where to lay the mines. For this we use the Zone sub menu in F3 mode. This will tell the engineers to lay mines only inside the zone.
Zones identify an area on the map for scripting. This can be handy when you want to insert paratroopers or place off map artillery during a mission. Zones can be used for many other applications as well.

Placing the Minefield zone.

Whilst in F3 mode, select the Zones sub menu which is identified by a dotted circle as highlighted in green below.

Give the zone a name.
Click on New Circle (round zone) or New Poly (square/rectangle zone) then enter a name for your zone. In this example I call it minefield.

Press Ok and your zone will appear. Note it also appears in the zone box in the zone submenu as shown below. Now left click to place your new zone on your map. As you can see below, i placed it off the sand. However I want the minefield on the sand.

This is easily fixed by selecting a corner and dragging it to where you want it. In the below pic you will see I have made it diagonal and elongated to fit along the length of the sand. Remember, this is the boundary for the placement of mines. They will only be laid inside the zone. You will also note in the below pic i added 3 more points to my zone to make it a custom shape to better fit in the sand zone. You can do this by clicking "Add" shown in the Zone menu options above points.
Fine Tune the Waypoints
Now you have placed the zone, you can fine tune the waypoints to make the truck park closer and reducing the distance it takes the engineers to run to the truck, thus making the mine laying process quicker. Simply click on the Waypoint sub-menu and select a waypoint and move it where you want it. In the below pic i just moved waypoint 2 closer to the sand.
Create A Trigger and Scripting
A trigger is what contains conditions and commands for the entity we tagged earlier. There are many commands and conditions you can use to make entities do all sorts of things. I only cover a few in this guide.
Whilst still in F3 mode, select the Triggers sub menu. It is shown below highlighted in green.

Right click in the Triggers box and select Add. Type the name of the trigger in the text line and click ok. The name of your trigger now appears in the trigger box as shown below.

I do not want the truck to start driving as soon as the mission starts so I need to set a delay. To do this right click in the Commands box and select Add as shown below.

The Select Commands box appears. Click on delay and click Ok as shown below.

You will now be presented with the Delay Properties box. I want a delay of 3 seconds before the script starts. Type in 3 next to delay and press Ok. You will notice the delay is now set to 3 in the Commands box as shown below.



Commands occur in the order they appear, so now we have told the script to delay starting by 3 seconds (no truck movement until then) we need to tell the editor what should occur next.

Right click in the Commands box again and select Add. This time select Waypoint as shown below.

Once you click Ok, the waypoint command properties box appears as seen below.

Here we select Actor on the Who line as it is only one entity (the truck) as shown below.You will note the options change from Squad (default) to Actor.

Click on the Tags and select the tag you gave the truck earlier. For me it is minetruck as shown below.

Now go to the action menu and ensure Start is selected then next to waypoint select 0 as the starting waypoint for the entity named minetruck as seen below.

Once finished click Ok.

What you have just done is tell the editor to start the entity tagged minetruck from waypoint 0 and it will follow the waypoints that are linked until it reaches the end. Now we need to tell it what to do when it reaches the end (waypoint 2).

In F3 mode select the Waypoint sub-menu again. Select the end waypoint (waypoint 2) and you should notice the Commands box appear in the Waypoint sub-menu to the right. Right Click in the Commands box and select Add. Select Actor as shown below.

Then select mine from the Actor sub-menu as shown below and click Ok. This tells the truck entity to commence the mine action and it will use the engineers on-board to lay mines from its inventory.

The Mine Command properties box will now appear and should look like what you see below.

Click on the Selector box and click Standart as shown below.

In the Selector properties box, click on the tag line and enter the tag we created for the truck earlier as shown below. Click Ok when done.

Now you are back in the Mine Command Properties box. Click the Zone line and select the name of the zone you created earlier in the guide. For me it is called minefield. As you can see below.

Now click Ok.
You have just completed the script. Before clicking start, click Save and give the mission a name. Now press start and watch the script unfold similar to the video at the start of this guide.
If you navigate to the folder where you saved the map in F2 mode at the start of this game, you should see the mission name inside it. You can open the mission using Notepad or a similar program and edit the text file directly if you feel adventurous. Just be careful to maintain the spacing and save a copy before you start playing around with it.
Hope you enjoy it. I just learnt this script about 1 hour ago and think its great. I might see what else i can get the engineers to build from the back of a truck.

Kind regards,

Aussie.