Modding Tutorial: Introduction to Script Mods

Script Mods can make powerful modifications to the way the game plays because they can access the data directly.

I recommend the following steps to get started:

  1. Read the basic intro below and have the Example Mod source code open on the side to compare

  2. Compile the Example Mod yourself to see how it works using the steps outlined in the FFModKit Readme

  3. Decompile Founders’ Fortune to dive into the game code

  4. Make your own mods and have fun!

Basic Info about Script modding

In the Founders’ Fortune game code, there is a small class cladd Mod. At the time of writing, the complete source code is this:

public abstract class Mod {

    // Load is called right after the player indicates he wants to start a game.
    public abstract void Load();

    // Start is called when the game starts
    public abstract void Start();

    // Update is called once per frame
    public abstract void Update();

This is the base class for all of your mods.
You are going to have a Visual Studio project referencing the game’s .dll file so you can make derived class from the Mod parent class. Once you compile your project, you’ll end up with a .dll file for your mod. You will put that in the game mod’s folder and the game will find it. Founders’ Fortune will load your .dll and search for any child classes derived from Mod. All of the found classes are then instantiated once, using the default constructor and the methods are called at the appropriate points in time.

Some additional notes to the order of execution:

  • When the player clicks on “New Game”, Load() is called before switching to the crew selection screen
  • When the player clicks on “Load” to load a saved game, Load() is called before switching to the loading screen
  • Don’t try to access any objects that are only available ingame, from Load(). For example WorldScripts.Instance.weatherManager.ChangeWeather(Weather.Foggy); is going to give you errors when called from the main menu.

Now that you understand the basics, I recommend reading and compiling the example script mod to see how to get your code in the game.


Important notes about making script mods

How to make a new project

  • You can either create a new Visual Studio project or simply copy our example project from GitHub
  • If you make a new project, make sure to select Class Library (.NET Framework) and then the Framework version 4.7.2

Make sure your naming is correct

Your .dll file needs to start with the name of your mod. For example, if your mod is called “Strange Magic Mod”, you can call your dll
Strange Magic Mod.dll or
Strange Magic Mod_andSomeOtherStuff.dll.

Make sure you change the name of the dll file to begin with the name of your mod.
To do that, click on Properties in the C# project menu:
and change the dll name here:

How to call private methods and access private fields

Sometimes, modders want to go a little deeper and need to access private methods and fields. While usually forbidden in the C# programming languages, you can circumvent it for your mods using reflection.

This is how you call a private method:

// Get a handle for the private method you want to call
// 'ConstructionManager' is the type of the class
// 'UpdateBuildableAtFloorLevel' is the name of the method
MethodInfo updateBuildableMethod = typeof(ConstructionManager).GetMethod("UpdateBuildableAtFloorLevel", BindingFlags.NonPublic | BindingFlags.Instance);

// Call the method
// 'WorldScripts.Instance.constructionManager' is the specific object you want to call this method on
// 'new object[] { 0 }' are the parameter of the method
// in this case, the parameter is just an int with the value 0
updateBuildableMethod.Invoke(WorldScripts.Instance.constructionManager, new object[] { 0 });

You can access and modify private fields with similar code.

How to use Harmony for advanced mods

Harmony is an amazing modding library giving you even more power about the internals of Founders’ Fortune. With Harmony you can inject your own code into Founders’ Fortune methods, giving you control over almost everything that happens in game.

1. Download Harmony

Get the newest release. Consider donating to @pardeike, the author of the repo.

2. Pick the correct dll

Go in the Harmony Folder → Releasenet4720Harmony.dll

3. Add it as a reference in Visual Studio


4. Make your mod

Check our example mod on GitHub for a start.
Check out the official Harmony Documentation for all the juicy details.

5. Distribute your mod

Simply add the Harmony dll to your mod folder:
Be sure not to change its name!

6. Playtest

Check out if it works and let us know about the cool stuff you made!