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:

[System.Serializable]
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.

2 Likes

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:
image
and change the dll name here: