Jagged Alliance 3

Jagged Alliance 3

Not enough ratings
Map Prefabs
By injto4ka
This guide is for map makers. It describes how map prefabs can be used to simplify the map creation process.
   
Award
Favorite
Favorited
Unfavorite
Introduction
The prefab is a collection of objects and terrain forming a single structure. Something similar to a micro map that can be placed inside other maps. The JA3 game engine natively supports prefabs, but they are not meant for modding. Actually their main purpose is for procedural map generation, which isn't used in JA3 at all, but in other HG games like Stranded Alien Dawn and Surviving Mars, where the maps are procedural.
As there is no official way to be created and used, the Map Modding mod provides a way not only to create prefabs, but also to place them as objects on your custom maps.
Requirements
To use the prefab feature you need to subscribe and enable the mod Map Modding.

Another mod that is not mandatory but highly recommended to have is the Common LIb.

To edit maps the game has to be started in debug mode.
Prefab map
The prefab source is located on a separate map, usually along many other prefabs.



Saving a map containing prefabs would trigger a step where each prefab source is exported to an output folder in a binary format. As the prefab data could be very large, this data is not stored in the game memory, but loaded from these exported locations when the prefab is being placed.
In order to have a map for creating prefabs, the Map Modding mod introduces the Map mod item. It is a standalone map not dependent on any sector or campaign. You don't need to include this map in mod containing your campaign, so you can have a local, not published mod just for the purpose of holding these prefab maps. Or you could include it in the campaign mod to serve as reference how to.

To create a prefab map click of the "Create New Mod item" button and choose "Map":



The map mod item properties are actually the same as those of the map data. First name your map in such way so that you recognize it easily along other maps. This name will be used to create a subfolder for the map in the mod's Maps folder when the map is saved from the map editor. If you change the name of the map after creating it, you will have to manually fix the map folder name where the map files are located - the mods cannot manage these file operations. In this example the map will be named "PrefabMap". Also the preset group is named "Prefabs" for clarity:



Save the mod. If everything is ok you won't see any error messages. Open the map list by F5 and check if the map is listed there:



If there are errors or the map doesn't appear in the list, try restarting the game.
Select your prefab map from the map list (F5) and conform it's loading. After a few moments the loading screen will close and the camera will present an empty map. The game will not be automatically put in map editing mod, like the sector maps do. You are free to enter and exit the map editing via the F3 key. So enter map edit mode by pressing F3:



Saving this map should be allowed and should produce a folder name with the same name in the mod's Maps directory. All map files will be located inside:

Prefab marker
The prefabs are defined by special Prefab markers. Once on the prefab map, enter the map editor (F3) and open the place objects menu (N). In order to see all objects select Art Set "All" and then select the "Prefab Marker" in the list:



Place the Prefab Marker attached to the mouse cursor on the ground. Open it's properties from its RMB menu:



When the properties are open, an additional marker would appear initially to help change the size of the prefab area by dragging it. You need to fill an unique prefab name, to choose if the terrain has to be captured or not, to specify the invalid terrain for masking, and eventually to set the prefab tags and type for filtering. In order to have custom tags and types for selection, you need to define such via the respective mod items "Prefab Tag" and "Prefab Type". Please keep in mind that the majority of the prefab related properties are of no use for manual placement as they are meant for the random map generator only. Many of the props have a help text on rollover.



Now create your sophisticated structure from objects and terrain inside the prefab area. The capture size can be changed at any time from the properties, so there is not need to respect it. The prefabs can contain anything placed on a map. But avoid to place grid markers or other dynamic objects that depend on their location. In case that the prefab contains terrain modification, it needs to be masked by an invalid terrain. The mask need a transition distance so that the prefab effect is gradually applied in the surrounding map on placement.



By default the marker is configured to capture objects, height and texture from the terrain masked by invalid terrain "Black" (there is also a grass capture option, but it's unused in JA3). The invalid terrain isn't captured in the prefab, it only serves as a "Green screen" background to define where the prefab is inside the prefab capture area. So a good practice is to fill the whole marker area with the invalid terrain, and then to draw on top the prefab form itself. Another mask related property is the Transition Zone. It defines how smoothly the prefab will be merged into the surrounding map when placed. Too short distance could result in artefacts at the prefab border, while too large zone would blur the prefab features. After capturing that form will be extracted only. It can also be seen in the prefab marker properties:



If you want to capture only objects, without a mask, you need to untick the terrain options and clear the "Invalid Terrain" property. Otherwise an error will be generated.



When placing the prefab objects, there is an important aspect to be aware of about the object's position. When something is placed on the terrain, it don't have a valid Z coordinate so it follows the terrain when the terrain moves up and down. Normally the map objects often have a valid Z coordinate, as they are offset slightly under the ground. When the prefab is placed, the object's offset from the ground is preserved, so they follow the resulting terrain. This behavior can be disabled per object, in the respective properties.
When the prefab is placed, it would be added on top of the existing height filed, which would more or less distort slightly the terrain features. This can be prevented by specifying "Equals" operator for prefab placement in the prefab property Apply Height. This will force the prefab to conserve it's original height map but requires a longer transition zone distance in order to make the smooth transition to the surroundings:



In order to make possible the placement of the prefab on other maps it has to be "exported". The export process is linked to saving the map. Just hit Ctrl-S to trigger the save and if no errors are reported, some prefab files should appear in the AppData folder of the game under Maps:

Prefab brush
If the export process is successful the prefab can now be placed on any map. Just load your campaign map for editing and open the Prefab Brush tool or press Ctrl-,



The prefab brush is a tool similar to the place objects tool - it provides a list of choices and a way to filter it. Once selected, a prefab is placed on the mouse cursor to be positioned on the map. You can rotate it by holding the Ctrl key and moving the mouse left or right, or by pressing + or - keys. The Shift and the Alt are rotation speed modifiers. The middle mouse button makes aligned rotation on 90% which is useful for rooms and other structured map objects. The first mouse button confirms the location while the right button or the ESC key cancels it and closes the brush.
Once placed the prefab is "unpacked" and it's no longer considered as a single object. If you want to keep the objects collected together, you need to place them in a collection inside the prefab and then to specify in the prefab properties "Important Collections" as true. Otherwise any collections are wiped from the prefab objects on export.

Disclaimer
The prefabs unlocked by the Map Modding mod provide a fast way to fill maps with various content. But as every mod, there is no 100% guarantee that everything would work flawlessly. Therefore always save a backup copy of your mod before editing your maps.