Tutorial - How to make a mod from scratch

From FreeSpace Wiki
Revision as of 12:41, 19 October 2020 by MatthTheGeek (talk | contribs) (woo)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Introduction

This tutorial covers the creation of a simple FS mod step by step with no prior knowledge required. It assumes you have FS2 and the latest MediaVPs installed, but the concept is globally the same (with different filenames and paths) if you wish to edit another mod or a Total Conversion.


Step 1: creating your "sandbox" mod

For a lot of reasons, we do not want to modify retail or MVP files directly. Those reasons include not breaking compatibility, facilitating debugging and facilitating backward compatibility - the vast majority of mods assume both the retail and the MVP data to be intact in order to function.

With Freespace Open, you can isolate all the files you modify, and only the files you modify in their own mod folder, and add dependencies (usually the MediaVPs) that contain the rest of the files you need.


With Knossos

Text Picture
First you will need to create a Nebula account and log in with it on Knossos. Logging in on Knossos
In develop > Create, enter a name and a unique ID for your mod. Don't worry, this mod will not be published on Knossos until we decide to do so.

Leave the fields Type = Mod and Parent mod = Retail FS2 as they are by default.

Creating a mod on Knossos
Like Knossos helpfully tells you, you must create at least one package before we can get started, so click the + Package button.

We're not doing a very complex mod, so just call it Root.

Adding a package
You will now have a tab with the name of your package. In it, we want to do two things : 1) set the status as Required, and 2) add the MediaVPs as a dependency (caution: look for Freespace Upgrade MediaVPs in alphabetical order in the dropdown list).

Make sure to press Save at the bottom of the page after your changes.

Adding dependancies
Your package tab should look like this once properly saved.

You can now press Play to start the mod. It should look identical to starting the MediaVPs, as we've only added the dependency and not changed anything yet.

To start the actual modding, click on the Mod Path to reach the folder Knossos uses to store and load the modded files we will create.

Dependancies added
At this point, the mod folder only contains your package's folder and a few json files. Ignore the json files and create a folder named "data" inside the package (which we named root here). This is where we will start adding files in Step 2. Package folder


With wxLauncher

TODO


Step 2: Modifying a ship

Text Picture
We're going to start with something simple : create a modular ship table that replaces the Helios compatibility with the Harpoon for the GTF Myrmidon.

Whether you used Knossos or wxLauncher in Step 1, you should now have an explorer window opened on a folder named "data". Inside this folder, create a new folder named "tables".

Tables folder
In this folder, you will create a text file named "mymod-shp.tbm". Make sure you have file name extensions enabled in the explorer, as we really want it to be "mymod-shp.tbm" and not "mymod-shp.tbm.txt"

Open this file in a plain text editor like windows' Notepad, or a third party program like Notepad++ or Sublime Text, then copy this text into it and save the file (I'll explain what this does later).

#Ship Classes

$Name:	GTF Myrmidon
+nocreate
+Tech Description:
XSTR("We changed the description here so we can quickly check that our mod works.", -1)
$end_multi_text
$Allowed SBanks:	( "Rockeye" "Hornet" "Tornado" "Tempest" "Trebuchet" "Stiletto II" "Hornet#Weak" "EMP Adv." "Infyrno" "Harpoon" )

#End
Back in Knossos or wxLauncher, start the game again. If you go in the tech room and select the GTF Myrmidon, you should see that the tech description has been changed. New description
Congratulations, you have successfully modded the game !

Now if you start a mission featuring both the Myrmidon and Harpoons, you will be able to equip the Harpoon and use it in-mission. For example, you can go in the Tech Room > mission Simulator and start SM1-06 The Great Hunt (if it isn't available because of campaign progress, press CTRL+SHIFT+S to unlock everything in the tech room, including missions).

You can equip Harpoons
So, how did we manage that? What did that file do?

Freespace follows a simple folder hierarchy when loading data. In our "data" folder, we created a "tables" folder, where FSO will look for table files (models are in the "models" folder, textures in the "maps" folder, missions in the "missions" folder, etc. You can find the detailed folder hierarchy in this page:

FS2 Data Structure

Back in retail (and early versions of FSO), you could only use full table files. What we created instead is a "modular table", mymod-shp.tbm (note the TBM extension instead of TBL). This allows us to only enter the data we want to change, and not the entirety of the ships data the game requires for every single ship.

The ships entry always starts with the "$Name:" entry. We follow it with "+nocreate" to tell the game that this is an existing ship we're modifying, and then the "+Tech Description:" and "$Allowed SBanks:" are the two entries we changed. You can find the details of the possible ships.tbl structure in Ships.tbl. Be careful, as the properties need to be in the order listed on this page.