Mod Files

Before I go any further, I think it would be beneficial to cover the various files created when you make a mod,
Starting in the Mod direcetory itself (darwinia/mods/modname/).

game.txt


This is the most important file in your mod, as it tells the mod how to behave. It is divided into various sections, each with a different purpose. It is essentially the default save file for your mod, which is loaded when then mod is first loaded up.
Heres some info on the various sections in the file.

Locations_StartDefinition
This contains the information on the levels you've created so far. It has the ID number of a level, which you need for TrunkPorts, Avail - whether the map is availible at the start, and the map and mission files associated with the level. Setting Avail to 0 means the level won't appear on the map until you open it up using a script. This is the technique the main game uses to unlock the levels as you progress. If you do set Avail to 0, you should also set missionFile to 'null' just to be sure.

Buildings_StartDefinition
This section contains Global Building info. Remember the Is Global option in the Building part of the guide? This is where the buildings with that set to one go as you play. However, to start with, you don't want a lot to be in here. You should delete everything in this section from the file, and only add what you need to be in here at the start. Infact, leaving everything in there might cause you problems later on when it comes to scripting. Its an interesting point that the main games game.txt only has 2 entries here. So, go ahead and delete all the entries in this section.
Now, lets say you want a TrunkPort to be online at the start of your level.
In the Buildings_StartDefinition section, you would type the following:

# Id teamId locId type link online
# =======================================
4 2 2 0 0 1


ID is the building ID that you want to be online. You can find this by looking at the title of the Building editor window while the building is selected.
Team ID is the team you want the building to be on (Team 2 is the player team, remember).
locID is the Level ID that your TrunkPort is in.
Type and link are used to remember what buildings are linked to. Not all buildings use these values.
Here is a list of building type numbers, and the effect of the link value:

Building Type Link
Radar Dish 3 ID of receiving dish
Control Tower 5 N/A
Trunk Port 11 ID of receiving location
Generator 14 N/A
Refinery 23 ??? (> 0) Could be number of primitives refined?
Mine 24 N/A
Yard 25 N/A
Incubator 29 N/A
Safe Area 31 N/A
Spirit Processor 36 N/A
Spawn Point Master 39 N/A
Blueprint Store 43 N/A
Spam 47 N/A

Online obviously needs to be set to 1 to turn the building on, otherwise the whole thing would be pointless.
Now when you load your level, you should find that the TrunkPort is online by default! Better yet, the attached ControlTower is too.

Research_StartDefinition
This section contains all of the default research levels, as well as the default current research, and the progress in that research. Its pretty self explanatory really.

Research Engineer 0 2
CurrentResearch Squad
CurrentPoints 0


The first line obviously refers to the Engineer research. The rest of the Research in the game is refered in the same way. The first number is set to 0. It represents the number of research points currently gained for this research. Use this if you want, for example, the player to be half way through researching the squad when they start.
The second number is the level of the research, 2 in this case. Set this to 0 if you want the player not to have this availible at the start, otherwise, set it to a number between 1 and 4. You can set it higher than 4, but the game doesn't support anything higher.
The next line is even more obvious that the first - When the player starts, he will be Currently researching the squad unit. You can change this to any of the others, but make sure its something that has a default level of more than 0 or you might break things. The final line is the number of points currently put into the Squad research.
Thats all there is to it!

Events_StartDefinition
This section will contain the scripts that will drive your game. This section is covered in detail in the scripting section later on, so I wont say anything else about it now.

Thats all for game.txt, so on to the next file.

locations.txt


This file is a lot simpler than game.txt - it only contains one type of information - the ID number for your locations, and the coordinates of the physical location of your level on the world map. There is no reason to mess with this file at all - all moving of your levels should be done using the Move function in the editor.

Now lets take a look at the files inside the Levels folder. If you have only made one level, there should be 2 files in here, so lets take a look at them.

map_levelname.txt


This is the file that contains most of the information about your level, including all the landscape, lights, level settings, and most of the buildings. Like game.txt, it is divided into sections.

Landscape_StartDefinition

worldSizeX 2000
worldSizeZ 2000
cellSize 12.00
outsideHeight -10.00
landColourFile landscape_default.bmp
wavesColourFile waves_default.bmp
waterColourFile water_default.bmp

The first 4 entries here are things you can easily change from the ingame editor, and although you can't do any major damage by changing them manually (unless you really screw it up), it would still be better to change them from the editor itself.

The next 3, however, can only be edited manually, so lets take a look.
landColourFile sets the texture file to be used by the levels land. The game reads the file and applies colour from the texture file to the ground depending on height and steepness. This is covered in more detail later on.
wavesColourFile determines the colour of the waves that appear on the water in a simple gradient. This is also covered later on.
waterColourFile determines the texture that is placed underneath the waves. It is a simple 128x128 bitmap file that is repeated at the base level. There are only 2 options for this, water_default.bmp and water_icecaps.bmp, although you can add your own by placing the file in darwinia/mods/modname/terrain/.

By changing these 3 filenames, you can drastically change the way your level looks and feels.

LandscapeTiles_StartDefinition
This is where all the islands you have created are defined. Its more trouble that it's worth trying to edit these manually, especially since the editor is there and lets you see what you're doing, so I wouldn't mess around with these.

LandFlattenAreas_StartDefinition
This is where your Flatten Areas are defined. These are a good deal simpler than normal land tiles, so if you really can't resist, you wont do much damage messing around with them, but there is still little point in doing so manually.

Lights_StartDefinition
You will find the lights you've added to your level here. If you want to change the position of your lights, this is where to do it. You might find editing the lights manually a lot easier than using the editor, simply because you can change the location of your lights this way, although it can be time consuming have to reload the game every time you make a change.

Buildings_StartDefinition
This is where all of the buildings you added to your level will be added, assuming you set their 'dynamic' variable to 0. The standard options for each building are obvious enough here, however, the building-specific settings that a lot of buildings have aren't labled, so I advise against editing buildings manually - it's very easy to blindly change something that will cause your game to crash when you load your level.

Thats it for your level's map file. Now lets move on to the mission file.

mission_levelname.txt


The mission files contain things that are likely to change during the level, as well as Camera mounts and mission objectives. The best part about mission files is that you can change their file names. This means you can use the same level more than once, with different enemies, buildings and scripts. Simply change the name of the mission file (although be sure that it still makes sense, something like mission_levelname_capture.txt), and update game.txt. You can also load different mission files with scripts, allowing you to return to areas of your mod with different circumstances.
Lets take a look at the file.

CameraMounts_StartDefinition
This contains all the cameras you've added to your level. You can see each of them by name, followed by a bunch of numbers, which represent its position, pitch and angle. Unless you've got an extremely good understanding of manipulating objects in 3D space, I wouldn't play around with these too much.

CameraAnimations_StartDefinition
This is where I assume your Camera Animation definitions would go, if I had any idea how they worked. Which I don't.

Buildings_StartDefinition
This is where all your 'dynamic' buildings will be defined. This normally means things that can be destroyed, or appear during gameplay, like GunTurrets and Triffids. You might also find ScriptTriggers here sometimes, if the trigger is set to Always.

InstantUnits_StartDefinition
This is where all of the units in your level will be. They are in here instead of the map file because once they are destroyed, they will be deleted. Since this is the file that is saved for your mission progress, if units weren't listed in here, they would simply reappear next time you loaded your game. Its easy enough to change the values here, as all the variables are labled the same as they are in the editor, except for the last 3. Feel free to mess around with them, but make a copy of your file before you do, as you're likely to crash your game.

PrimaryObjectives_StartDefinition
This is where you will list your objectives. These are covered in detail in the scripting section.

Thats it as far as files the game creates goes. You may well have a number of map and mission files depending on how many levels you've made, but the layout is all the same.

Now lets move on to some scripting!