Modding support for Megaton Rainfall
Hey modders, here you will find instructions to create your own modifications, missions or levels for Megaton Rainfall. It will be simple and straight to the point.
We have integrated Lua scripting support in the engine so that you can completely change the behaviour of the game, and reuse lots of libraries and documentation in the web. You can turn the game into a 3rd person camera, a racing game, or anything you can imagine (but you'll need scripting skills to achieve that).
The main advantage over other games is that you'll get fully destructible massive cities from the start.
Getting started
The installation folder of the game is usually "%programfiles(x86)%\Steam\SteamApps\common\Megaton Rainfall" (Steam) or "%programfiles(x86)%\GOG Galaxy\Games\Megaton Rainfall" (GOG).
Download the samples SampleEmpty, SampleEffects, SampleEnemies and SampleTeapots, and place them in the Assets folder inside the installation folder.
Launch the game. You'll see a new option User content in the main menu. You'll be able to run any of the samples from there.
As you can see, a mod is a Assets\*.fcm file, which is a standard zip file with scripts, mesh data, animations, and whatever is needed.
The "official" content of the game can also be found in standard Assets\*.fcm files.
You can also unzip the contents of the mod in the installation folder (not the Assets folder), so that you can develop and test your mod without having to zip it each time.
When the game needs any file (for example, the texture Textures\Asphalt.dds), it looks for it first in the installation folder, then in any of the Assets\*.fcm files (prioritizing the ones that are not standard). That allows you to create a mod that replaces the contents of the game with your own, without touching the standard .fcm files.
This can be done to replace any file of the game including (undocumented) scripts. For example, You can replace Data\scene_universe.txt changing the planets of the solar system.
To create a level/mission that will appear in the User content menu, you have to add a *\*.lua file with the following content (SampleEmpty basically does this).
table.insert(UserContent,"ModName")
ModName = {}
function ModName:Init()
-- code that will be executed at the beginning
end
function ModName:Update()
-- code that will be executed each logical frame (60 times per second).
end
To allow fast development of mods, you can set the game to windowed mode by opening %userprofile%\documents\MegatonRainfall\config.txt and changing video_windowed no to video_windowed yes.
Then, launch the game, enter your user content, and press F5 key to reload all the scripts and restart the mod. In this way you don't need to relaunch the game to test any change. Errors will appear on the screen. You can try this with the samples.
About the samples
Don't forget to read the (short and simple) Lua code of the samples:
- SampleEmpty: Minimium sample that appears in the user content and starts in a city.
- SampleEffects: Shows a lot of effects, explosions and stuff that can be added to your mods.
- SampleEnemies: Shows how to create an enemy map similar to the M1 mission in the game.
- SampleTeapots: Includes mesh, animation, collision, physics and 3rd person camera. You walk across the city and fire explosive teapots.
File formats
Besides the *\*.lua files for scripting, the engine supports:
- .ogg files for sounds.
- .dds files for textures.
- .dae (Collada) files for meshes. Meshes should be placed in Models\*.bin files (propietary format) that should be included within your mod. If it doesn't exist, the engine will try to create it from a MESH_IMPORT command inside a Data\global*.txt file, that should reference a .dae (Collada) file in your PC (no need to include it within your mod). You can export Collada mesh/animation files from any 3d package like Blender, 3DS Max, etc. See SampleTeapots for an example.
- .dae (Collada) files for animations. Animations should be included in .dae format within your mod. See SampleTeapots for an example.
Script reference
Here you can find the (scarce) documentation of all the functions available from the Lua scripts.
Future improvements
Do you have suggestions for more features that should be scriptable?
Do you think your script should work and it doesn't?
Don't hessitate to send your feedback to support@megatonrainfall.com.
If you think your script/mod should work and it doesn't, please send us a link to it and explain the problem (steps to reproduce the problem) so that we can investigate it.
If our community likes our modding support, we think about including the following features:
- Import cities from Open Street Map
- Add content to other planets.
- Support more functions from Lua.