Landing Craft AI Explained
Adding landing zones to a map is very tricky. They are the first things to break and there are so many ways to break them. The StrategicAreas.con is also more complex than land based maps. The first thing that needs to be done is to group up all the vehicle types. This is from the StrategicAreas.con in my ai folder for the Invasion of the Philippines. I've chosen it because of the difficutlies associated with it. First, we create the different groups:
rem *** Create vehicle groups *** aiSettings.createVehicleGroup land aiSettings.createVehicleGroup any aiSettings.createVehicleGroup sea aiSettings.createVehicleGroup infantry
In the IoP map, infantry is the only vehicle type that can traverse the entire island, so they get their own group.
rem * add vehicles to the groups * aiSettings.addVehicleToVehicleGroup 0 land aiSettings.addVehicleToVehicleGroup 1 any aiSettings.addVehicleToVehicleGroup 2 sea aiSettings.addVehicleToVehicleGroup 3 infantry aiSettings.addVehicleToVehicleGroup 4 any aiSettings.addVehicleToVehicleGroup 5 land aiSettings.addVehicleToVehicleGroup 6 land aiSettings.addVehicleToVehicleGroup 7 any aiSettings.addVehicleToVehicleGroup 8 any aiSettings.addVehicleToVehicleGroup 9 sea aiSettings.addVehicleToVehicleGroup 10 any aiSettings.addVehicleToVehicleGroup 11 any aiSettings.addVehicleToVehicleGroup 12 sea aiSettings.addVehicleToVehicleGroup 13 any aiSettings.addVehicleToVehicleGroup 14 land aiSettings.addVehicleToVehicleGroup 15 any aiSettings.addVehicleToVehicleGroup 16 any aiSettings.addVehicleToVehicleGroup 17 any aiSettings.addVehicleToVehicleGroup 18 any aiSettings.addVehicleToVehicleGroup 19 any aiSettings.addVehicleToVehicleGroup 20 land aiSettings.addVehicleToVehicleGroup 21 any
Normally, there are only 18 vehicle types (0-17) in a bf1942 map. I've added some new ones, thus the number is higher here. Your map should only include 0-17. These numbers are significant. They are the vehicle numbers found in the AIbehaviours.con file. Planes, fixed weapons and landing craft all belong to the any group. Tanks, jeeps and such go into the land group. Ships and boats go into the sea group and infantry gets its own. This is done so the vehicle groups can be restricted to areas that they can actually get too. The next step is to create the strategic area categories:
rem *** Create categories *** aiStrategicArea.createNewCategory land aiStrategicArea.createNewCategory sea
I'm not sure of the significance of this, but its done for all maps that have both land and sea vehicles, so I don't question it. Now we can create our strategic areas:
rem *** control points *** aiStrategicArea.create US_Marine_BaseCP 535/1225 547/1237 20 land aiStrategicArea.create West_HarbourCP 550/769 559/778 150 land aiStrategicArea.create AirfieldCP 1077/1104 1089/1116 200 land aiStrategicArea.create Point_BoyingtonCP 1126/1326 1134/1334 150 land aiStrategicArea.create East_HarbourCP 1557/1492 1568/1503 150 land aiStrategicArea.create IslandsCP 822/989 836/1003 150 land rem *** land routes *** aiStrategicArea.create WestCentre 645/926 660/940 8 land aiStrategicArea.create WestRt 1065/991 1080/1004 8 land aiStrategicArea.create EastNRt 1312/1450 1332/1470 8 land aiStrategicArea.create EastSRt 1400/1230 1420/1250 8 land rem *** seas *** aiStrategicArea.create NorthWSea 100/1700 212/1812 1 sea aiStrategicArea.create NorthESea 1850/1890 1905/1940 1 sea aiStrategicArea.create SouthESea 975/275 1025/325 1 sea aiStrategicArea.create SouthWSea 100/150 200/300 1 sea
The IoP map has 6 control points, spread out across 3 islands. I had to create the 4 strategic areas in the middle of this list to keep the SAI from assigning manned land vehicles from island to island. Only infantry is allowed in these strategic areas, so they act as a filter. The second X/Z pair for each strategic area is actually the center of it, so be careful or your strategic areas will end up being twice the size you expect them to be. Now its time to create the landing zones:
rem *** landing zones *** aiLandingZone.createLandingZone WestLanding 272/1110 429/1220 LZXMax aiLandingZone.createLandingZone WestNLanding 787/1021 861/1082 LZZMin aiLandingZone.createLandingZone WestSLanding 596/775 757/869 LZXMin aiLandingZone.createLandingZone NorthELanding 1263/1522 1362/1668 LZZMin aiLandingZone.createLandingZone EastNLanding 1642/1591 1712/1730 LZZMin
Unlike the strategic areas, the second X/Z pair is not the centre of the area, its the far corner. Both of the values of the first X/Z pair should be smaller than the corresponding values of the second for both strategic areas and landing zones. if, by accident, one of the values in the first pair is greater then the second, don't expect the landing craft to work.
The last argument of the command is also very important. It can be set with any of 4 possible values: LZXMin, LZXMax, LZZMin and LZZMax. It tells the game where the beach side of the landing zone is. If the origin of the map is on the bottom left, as it is during game play, then use:
LZXMin == left of the zone LZXMax == right of the zone LZZMin == bottom of the zone LZZMax == top of the zone
With all the strategic areas and landing zones created, it's time to fill in the rest. The first area looks like this:
rem *** strategic areas aiStrategicArea.setActive US_Marine_BaseCP aiStrategicArea.addAllowedVehicleGroup land aiStrategicArea.addAllowedVehicleGroup any aiStrategicArea.addAllowedVehicleGroup infantry aiStrategicArea.addLandingZoneUnit LandingCraft aiStrategicArea.attachLandingZone WestLanding aiStrategicArea.addNeighbour West_HarbourCP aiStrategicArea.addNeighbour WestCentre aiStrategicArea.addNeighbour NorthWSea aiStrategicArea.addNeighbour SouthWSea aiStrategicArea.addObjectTypeFlag ControlPoint aiStrategicArea.addObjectTypeFlag West aiStrategicArea.setOrderPosition Tank 557/1257 aiStrategicArea.setOrderPosition Infantry 535/1240 aiStrategicArea.setOrderPosition Boat 200/1430 aiStrategicArea.setOrderPosition LandingCraft 250/1350 aiStrategicArea.setOrderPosition Car 560/1250 aiStrategicArea.setSide 2
Everything accept sea vessels are allowed in this area because of the lines:
aiStrategicArea.addAllowedVehicleGroup land aiStrategicArea.addAllowedVehicleGroup any aiStrategicArea.addAllowedVehicleGroup infantry
For every vehicle that is allowed, there must also be these:
aiStrategicArea.setOrderPosition Tank 557/1257 aiStrategicArea.setOrderPosition Infantry 535/1240 aiStrategicArea.setOrderPosition Boat 200/1430 aiStrategicArea.setOrderPosition LandingCraft 250/1350 aiStrategicArea.setOrderPosition Car 560/1250
Which sets the waypoints in this area for each vehicle class. The setOrderPostion for the boat isn't really needed since all the boats are in the sea vehicle group and not allowed. It doesn't hurt anything having it there. Even though the marine base is on land, I could have allowed the sea vehicle group to enter. These waypoints don't have to be in the strategic area, they can be anywhere on the map. Once ordered to a strategic area, this is the point where the bot will take the given vehicle. For landing craft, the best choice is a point on the seaward side of the zone. Beware of these. if any of them don't fall into valid pathfinding areas for each vehicle listed, the landing craft will not land and the game could even CTD. If the setOrderPosition isn't set for a vehicle that is allowed in a strategic area, the game will assume a value of 0/0 and try to send the vehicle there, if it is possible to do so.
One more thing about this strategic area, both of these lines are needed to add a landing zone to it:
aiStrategicArea.addLandingZoneUnit LandingCraft aiStrategicArea.attachLandingZone WestLanding
If you omit one, the map will CTD. More than one landing zone can be attached to a strategic area as well. The other control points are put together in a similar manner.
The 4 strategic areas that I use as a buffer between islands are next. Here is an example:
aiStrategicArea.setActive WestRt aiStrategicArea.addAllowedVehicleGroup infantry aiStrategicArea.addExpelledUnit LandingCraft aiStrategicArea.addExpelledUnit Tank aiStrategicArea.addNeighbour West_HarbourCP aiStrategicArea.addNeighbour IslandsCP aiStrategicArea.addNeighbour AirfieldCP aiStrategicArea.addObjectTypeFlag Route aiStrategicArea.setOrderPosition Infantry 1070/995 aiStrategicArea.setSide 0
I put these strategic areas between the islands as neighbours to the control points on them. This way, bots in tanks don't get ordered to another island, only infantry. Also notice the addExpelledUnit commands. These lines are also not needed, but make a good example of how to use them. After listing the allowed vehicle groups, you can selectively forbid individual vehicles to a strategic area, even if they are contained in the allowed group.
Even if the StrategicAreas.con is set up properly, the bots might still refuse to land the landing craft. Here are some things to check for:
1. Make sure that vehicles 7, 10 and 11 are in the any vehicle group. 2. The strategic area allows the any vehicle group to enter it. 3. None of the vehicle waypoints (setOrderPostion) land on invalid pathfinding areas. 4. The landing craft pathfinding files exist and are correct. 5. The landing zones don't extent too far onto land. 6. The landing zones extend far enough out to sea for the bots to make a good approach. 7. None of the soldier and vehicle spawn points are on invalid. pathfinding positions (search the logs for the keyword 'invalid'). 8. Check for typo's and remember case matters in the names used. 9. Make sure the beachside of all the landing zones is set correctly.
If all that looks good and they still refuse to land them, try removing all of the landing zones and add them back one at a time. Also try changing their location, resizing and moving them around a little. If the game doesn't like one of the landing zones, it's my experience that it will hate all of them.
The picture below shows the strategic area layout for IoP. I didn't list the sea vehicle group, it is included in the any vehicle group pic. I probably should have labelled that pic as Sea.