Jump to content

Basic Principles Of Modding: Difference between revisions

From WarhammerWorkshop
Created page with "== Space Marine 2 PAK == Game uses PAK files to store all the game assets. PAK file is essentially just ZIP archive you can open or create with any archiver. There are few requirements: * All files inside of PAK must be lower case * Format of file must be ZIP, not RAR or any other archiving format * Compression must be "Store" (No compression) ** You can compress non graphical files, but to avoid confusion and mistakes it is adviced not to use compression Vanilla PAK f..."
 
HAPPYMAN5 (talk | contribs)
No edit summary
Line 1: Line 1:
== Space Marine 2 PAK ==
== How does Modding Space Marine 2 Work? ==
Game uses PAK files to store all the game assets. PAK file is essentially just ZIP archive you can open or create with any archiver. There are few requirements:
Modding Space Marine 2 isn't like Modding Minecraft. There's zero programming involved. A good understanding of Computer Science will take you quite a long way, but getting into modding the game is fairly straightforward and simple for complete beginners, and this wiki is designed to make it even easier to understand.  


* All files inside of PAK must be lower case
Space Marine 2's files do not allow us to edit any lines of actual code, but we are allowed to edit the text files that that code refers to in order to function. And while this may sound like a limitation, and it many ways it is, you would be surprised how much you can do.
* Format of file must be ZIP, not RAR or any other archiving format
* Compression must be "Store" (No compression)
** You can compress non graphical files, but to avoid confusion and mistakes it is adviced not to use compression


Vanilla PAK files are accompanied with a cache file. Cache file is not required for modding.
= How Does Space Marine 2's File System Work? =
Space Marine 2 uses a compression format known as a PAK file to store all of its game assets, this includes, models, textures, audio, everything. PAK files are a format of compression archive like a ZIP  or RAR file. You can open SM2's PAK files with any archiving tool, but we suggest [https://www.win-rar.com/download.html?&L=0 WinRar].


Client and Server assets are separated. You can find client assets at '''"client_pc/root/paks/client/"''' and server assets at '''"server_pc/root/paks/server/"'''
=== File Structure ===
[[File:SM2 Directory.png|thumb|403x403px|SM2 Directory]]
Inside the Space Marine 2 Directory you will see 3 Folders, 2 EXEs, and an INI file. These EXE files are what launch the game, the INI file is helpful for the protected game EXE, and the folders are where the game data is stored. ''EasyAntiCheat'' is a folder you generally want to ignore. Messing with the anti cheat system can screw up some serious things and get you in a lot of trouble. The folders we get free reign over however are the "client_pc" and "server_pc" folders. These folders contain ALL of the data for the game, and a majority of their contents will have information about them somewhere in this wiki.


=== Resource PAK ===
=== Virtual File System ===
Both client and server have resource tree metadata stored at "resources.pak". More on resources tree read at [[Resource_System]]
Space Marine 2 uses something called a Virtual File System for handling how resources and assets are loaded. Mods use that VFS to completely override Vanilla files with files that were modified. Space Marine 2 does not have [[wikipedia:Delta_update|Delta-Patching]], so mods can only replace an entire file, and not parts of one.


=== Default PAK ===
== PAK Files ==
Delfault paks contain all of the base game resources.
Inside of the client_pc and server_pc folders are a hundreds of pak files all dedicated to storing the information for the game. You can open every single one of these pak files and edit all of their information to change how the game looks, sounds, and operates.


* default_other.pak - Space Marine 2 is mainly data driven and most of the parameters, descriptions, defenitions, AI logic and server scenarios are stored there as a text files in Property Section format.
== Default Paks ==
* default_ssl.pak - this pak contains game's scripts in SSL - Saber Scripting Language. Those scripts are compiled into sslbin files. '''sslbin editing and replacement isn't supported by modding system'''
The game stores all of its main data in what are called "Default Paks." Both the client side and the server side of the game have their own separate Default Paks. Server assets are handled in the server side paks and Client side assets are handled in the client side paks. To find these pak files, navigate to '''''client_pc\root\paks\client\default''''' for client paks, and '''''server_pc\root\paks\server\default''''' for server side paks. You can open these pak files with WinRar.
* default_pct_x.pak - contains all of the textures
* default_tpl_x.pak - contains all of the models
* default_td.pak - contains all of the materials


== Local server ==
=== Default_Other.pak ===
During modded sessions, game uses local server instead of server hosted by Saber. One of the players will act as a host, running a local server with all server modifications installed on their build. When playing with server mods, ensure that all players have the same server mods installed to avoid problems with server migration.
Space Marine 2 is mainly data driven and almost all of the parameters, descriptions, defenitions, AI logic, and server scenarios are stored in "default_other.pak" This PAK files contain tons of text files written in Property Section format. Default Other is probably the most important PAK file because it contains the majority of the games editable data. If you wanted to make a change to the game, there is a 95% chance the way to do it is a file in this PAK file.
 
Both client_pc and server_pc, have their own seperate versions of ''default_other.pak.'' Client assets will be stored in the client_pc version, and server assets in the server_pc version. There are many instances where a file will be present in both client_pc and server_pc, and when that is the case, the two files will need to be identical to avoid crashes and data issues.
 
=== Default_SSL.pak ===
This pak contains all of the game's scripts in sabers own Scripting Language called "SSL". All of the game's scripts are compiled into sslbin files. As stated before, editing the games code directly is not something we can do. So editing and replacing SSLbins is not something that is supported, and Saber has no plans to let us edit them in the future. It is best to avoid this pak because messing with it will really mess your game up.
 
=== Default_PCT Paks ===
There are a bunch of pak files titled "default_pct_x.pak" x in this case being a number 0-31. These pak files contain all of the textures(PCT Files) in the game, they can be edited, but changing textures is a lot more involved than simple text editing, and there are better ways of going about replacing textures than doing it in these paks.
 
=== Default_TPL Paks ===
There are bunch of pak files titled "default_tpl_x.pak" x in this case being a number 1-6. These pak files contain all of the models for everything in the game, they can be edited, but changing Models is a lot more involved than simple text editing, and there are better ways of going about replacing them.
 
=== Default_TD.pak ===
default_td.pak contains all of the files needed for objects to be made of the proper materials like metal and dirt. Changing these materials is also a lot more involved than simple text editing, and there are better ways of going about replacing materials than doing it here.
 
=== Default_Sound Paks ===
These pak files contain all of the audio heard in the game, they can be edited but trying to navigate them is a nightmare, and adding, changing, and replacing them even more so. They are listed as strings of numbers without proper definitions and you need a license to a separate program in order to just listen to then. A [https://docs.google.com/spreadsheets/d/1KH8KhYk-Q_PQdi0GG8zdc0JkM0NeX8xV-z1DXekPjJ4/edit?gid=0#gid=0 spreadsheet of sounds] was being developed that had information on specific sounds but it has not been updated in a long while.
 
== Cache Files ==
Every PAK file is accompanied by a Cache file of the same name. The Cache file is what is used to make the data in the PAK files readable by Space Marine 2's internal System. In the land of long ago, Cave Men Modders would use a magical tool called "Pakcacher" to cache the PAK files, which would generate a new cache file with the proper information for the edits you made to the PAK file. Now thanks to Saber, after the 7.0 Update of April 2025, the way creating mods changed, and we can all leave Cache files well enough alone.
 
== Resource Paks ==
Both the client and the server side of the game have resource tree metadata stored in a pak called "resources.pak". This file is edited just like any other pak file, but if you ''REALLY'' don't know what you're doing, messing with this file is going to break something major. If you'd like to read more about Resource Paks and resources trees, see: [[Resource_System]].
 
== Local Folder ==
The Local folder is a special folder in your SM2 Directory designed for the development and testing of mods. Its designed to be used while you are creating them so that you do not have to turn everything into a pak file when you want to test something. The Local folder is located in "'''''client_pc\root".'''''
 
=== What files can go into a Local Folder? ===
Any and all files can go into a Local Folder, this includes but is not limited to client side files, server side files, and resource files. The game only requires the pathing to files be correct.
 
=== How to use a Local Folder ===
When you are using a Local Folder to build a mod, you are treating the Local Folder as if it is the default_other.pak. So the pathing to files needs to start where the pathing to files would start in the default_other.pak.
 
Since Client and Server files share a lot of the same pathing within their respective default_other.pak, both client and server files can be placed in the same place. When the game loads the Folder, it will know to separate client, server, and resource files. Another thing to note is that files that are in both client_pc and server_pc, only need one instance in the local folder. Since they have identical pathing, naming, and require their contents to be identical, the Virtual File System handles the separation, and will replace both instances of a file with the single edited version in the Local Folder.
 
=== Performance Issues ===
While Local Folders take priority in loading assets, they load very slowly, and can cause performance issues if it is the primary way you are playing your mods. It is not recommended to actually use and operate completed versions of mods using the Local Folder. It is intended only for building mods, and generally you should not upload or send the Local folder, or files/folders intended to be put in the local folder to other users as a way of playing a finished product.
 
== Mods Folder ==
The Mods Folder is a Special folder in your SM2 Directory designed specifically for mods. It is designed for the average user rather than the average mod creator, and intended to be an easy way to install finished and downloaded mods.
 
=== What goes into a Mods Folder? ===
Mods, specifically '''Mod.paks.''' The Mods folder will only load files that are formatted as PAK files. If a ZIP or RAR file makes its way into the folder, it will either be ignored or the game will attempt to load it but fail, and you may experience a broken game.
 
=== How does Mod Load order wok? ===
Mods are Loaded in Alphanumerical order. Meaning if mod_a and mod_b modify the same file, the game will use the modifications from mod_a, and if mod_a1 and mod_a modify the same file, the game will use the modifications from mod_a1.


== Virtual File System ==
=== Stuff to look out for ===
Space Marine 2 uses Virtual File System for handling resources and assets. Mods use VFS to completely override vanilla files with modded files. Space Marine 2 have no delta-patching, mods can only replace file whole.
When naming a modpak it is heavily recommended that you keep all of your letters in the name of the modpak lowercase. Not doing so can sometimes result in loading issues and crashes.


=== Local folder ===
= Creating a Modpak =
You can replace files by putting them in '''"client_pc/root/local"''' folder. You can place client, server and resource files in this local folder.
[[File:Paking Mods Tutorial.gif|thumb|416x416px]]
[[File:Local Folder Example.png|thumb|Example on how Local Folder will look]]
To create a Modpak start by building it in the Local Folder, if you do not know how to do that see [[Basic Principles Of Modding#Local folder|Local Folder]].
Example: if you want to replace a file with path '''"/ssl/main/user/weapon_loadouts/initial_mastery_infos_library.sso"''' from defaullt_other.pak, you create the same folder structure in your local folder like this: '''"/client_pc/root/local/ssl/main/user/weapon_loadouts/initial_mastery_infos_library.sso"'''


Local folder is mostly used for development, as it can cause performance issues.
Once you have your mod built and tested, Highlight all of the folders in the Local Folder, and right click. Select the WinRar Option, and select "Add to Archive". From the WinRar menu, you need to select the archive format "ZIP", and change the compression type to "Store".


=== Mods folder ===
It is very important the the compression type is set to Store. Mod Paks cannot have any amount of compression or they will cause crashes, infinite loading, or they will just not load at all.  
Preferred way to install and redistribute mods are mod paks. You simply place your mod pak into '''"client_pc/root/mods"''' folder. Mod Paks do not require cache files, but otherwise the same as regular paks you wil find in default folder. All requirements for pak format apply too:


* All files inside of PAK must be lower case
The name of a pak needs to be all lowercase, but can be whatever you want. It also NEEDS to be a ".pak". The Mods folder will only load files that are formatted as PAK files. If a ZIP or RAR file makes its way into the folder, it will either be ignored or the game will attempt to load it but fail, and you may experience a broken game.
* Format of file must be ZIP, not RAR or any other archiving format
* Compression must be "Store" (No compression)
** You can compress non graphical files, but to avoid confusion and mistakes it is adviced not to use compression


As an example on how to create your mod pak, considering you have a setup in local folder, you just select all your files in local folder (not local folder itself) and use any archiver to create a zip file without compression, then change its extension to '''".pak"'''
Once you have paked your mod, it is ready to be placed into the Mods folder in your SM2 Directory. The file is also ready to be uploaded and sent to other users.


Root of your mod pak file must contain folders like "ssl", "tpl", "td" and etc,  like what you'd see in root of default paks or your local folder, not "local"
== Local server ==
While playing with mods, the game will always force you into a private lobby. During this time, the game uses a Local Server running off of the host's computer instead of a server hosted by Saber. This method is called [[wikipedia:Peer-to-peer|Peer-to-Peer (P2P).]]


It is adviced to name your mod paks in lower case, as you would name internal files, to avoid unexpected problems.
=== How do mods work on a Local Server? ===
When you host a Local Server while playing modded, your mods get loaded onto the server, meaning in some cases, players who do not have mods installed on their device, or do not have the exact mods as you do on their device, including console players, will be able to experience the mods that you downloaded. However it is always a better idea to make sure all parties playing a modded game have the same mods installed to avoid any issues.


Mod Paks have priority over Derfault paks. Mod Paks are loaded in alphanumerical order and the pak that was loaded first have greated priority over later modpaks. For example, if mod_a and mod_b modify the same file, game will use file from mod_a.
For a Guide on how to install mods, see [[How To Install Mods|How to Install Mods]].

Revision as of 02:11, 28 April 2025

How does Modding Space Marine 2 Work?

Modding Space Marine 2 isn't like Modding Minecraft. There's zero programming involved. A good understanding of Computer Science will take you quite a long way, but getting into modding the game is fairly straightforward and simple for complete beginners, and this wiki is designed to make it even easier to understand.

Space Marine 2's files do not allow us to edit any lines of actual code, but we are allowed to edit the text files that that code refers to in order to function. And while this may sound like a limitation, and it many ways it is, you would be surprised how much you can do.

How Does Space Marine 2's File System Work?

Space Marine 2 uses a compression format known as a PAK file to store all of its game assets, this includes, models, textures, audio, everything. PAK files are a format of compression archive like a ZIP or RAR file. You can open SM2's PAK files with any archiving tool, but we suggest WinRar.

File Structure

SM2 Directory

Inside the Space Marine 2 Directory you will see 3 Folders, 2 EXEs, and an INI file. These EXE files are what launch the game, the INI file is helpful for the protected game EXE, and the folders are where the game data is stored. EasyAntiCheat is a folder you generally want to ignore. Messing with the anti cheat system can screw up some serious things and get you in a lot of trouble. The folders we get free reign over however are the "client_pc" and "server_pc" folders. These folders contain ALL of the data for the game, and a majority of their contents will have information about them somewhere in this wiki.

Virtual File System

Space Marine 2 uses something called a Virtual File System for handling how resources and assets are loaded. Mods use that VFS to completely override Vanilla files with files that were modified. Space Marine 2 does not have Delta-Patching, so mods can only replace an entire file, and not parts of one.

PAK Files

Inside of the client_pc and server_pc folders are a hundreds of pak files all dedicated to storing the information for the game. You can open every single one of these pak files and edit all of their information to change how the game looks, sounds, and operates.

Default Paks

The game stores all of its main data in what are called "Default Paks." Both the client side and the server side of the game have their own separate Default Paks. Server assets are handled in the server side paks and Client side assets are handled in the client side paks. To find these pak files, navigate to client_pc\root\paks\client\default for client paks, and server_pc\root\paks\server\default for server side paks. You can open these pak files with WinRar.

Default_Other.pak

Space Marine 2 is mainly data driven and almost all of the parameters, descriptions, defenitions, AI logic, and server scenarios are stored in "default_other.pak" This PAK files contain tons of text files written in Property Section format. Default Other is probably the most important PAK file because it contains the majority of the games editable data. If you wanted to make a change to the game, there is a 95% chance the way to do it is a file in this PAK file.

Both client_pc and server_pc, have their own seperate versions of default_other.pak. Client assets will be stored in the client_pc version, and server assets in the server_pc version. There are many instances where a file will be present in both client_pc and server_pc, and when that is the case, the two files will need to be identical to avoid crashes and data issues.

Default_SSL.pak

This pak contains all of the game's scripts in sabers own Scripting Language called "SSL". All of the game's scripts are compiled into sslbin files. As stated before, editing the games code directly is not something we can do. So editing and replacing SSLbins is not something that is supported, and Saber has no plans to let us edit them in the future. It is best to avoid this pak because messing with it will really mess your game up.

Default_PCT Paks

There are a bunch of pak files titled "default_pct_x.pak" x in this case being a number 0-31. These pak files contain all of the textures(PCT Files) in the game, they can be edited, but changing textures is a lot more involved than simple text editing, and there are better ways of going about replacing textures than doing it in these paks.

Default_TPL Paks

There are bunch of pak files titled "default_tpl_x.pak" x in this case being a number 1-6. These pak files contain all of the models for everything in the game, they can be edited, but changing Models is a lot more involved than simple text editing, and there are better ways of going about replacing them.

Default_TD.pak

default_td.pak contains all of the files needed for objects to be made of the proper materials like metal and dirt. Changing these materials is also a lot more involved than simple text editing, and there are better ways of going about replacing materials than doing it here.

Default_Sound Paks

These pak files contain all of the audio heard in the game, they can be edited but trying to navigate them is a nightmare, and adding, changing, and replacing them even more so. They are listed as strings of numbers without proper definitions and you need a license to a separate program in order to just listen to then. A spreadsheet of sounds was being developed that had information on specific sounds but it has not been updated in a long while.

Cache Files

Every PAK file is accompanied by a Cache file of the same name. The Cache file is what is used to make the data in the PAK files readable by Space Marine 2's internal System. In the land of long ago, Cave Men Modders would use a magical tool called "Pakcacher" to cache the PAK files, which would generate a new cache file with the proper information for the edits you made to the PAK file. Now thanks to Saber, after the 7.0 Update of April 2025, the way creating mods changed, and we can all leave Cache files well enough alone.

Resource Paks

Both the client and the server side of the game have resource tree metadata stored in a pak called "resources.pak". This file is edited just like any other pak file, but if you REALLY don't know what you're doing, messing with this file is going to break something major. If you'd like to read more about Resource Paks and resources trees, see: Resource_System.

Local Folder

The Local folder is a special folder in your SM2 Directory designed for the development and testing of mods. Its designed to be used while you are creating them so that you do not have to turn everything into a pak file when you want to test something. The Local folder is located in "client_pc\root".

What files can go into a Local Folder?

Any and all files can go into a Local Folder, this includes but is not limited to client side files, server side files, and resource files. The game only requires the pathing to files be correct.

How to use a Local Folder

When you are using a Local Folder to build a mod, you are treating the Local Folder as if it is the default_other.pak. So the pathing to files needs to start where the pathing to files would start in the default_other.pak.

Since Client and Server files share a lot of the same pathing within their respective default_other.pak, both client and server files can be placed in the same place. When the game loads the Folder, it will know to separate client, server, and resource files. Another thing to note is that files that are in both client_pc and server_pc, only need one instance in the local folder. Since they have identical pathing, naming, and require their contents to be identical, the Virtual File System handles the separation, and will replace both instances of a file with the single edited version in the Local Folder.

Performance Issues

While Local Folders take priority in loading assets, they load very slowly, and can cause performance issues if it is the primary way you are playing your mods. It is not recommended to actually use and operate completed versions of mods using the Local Folder. It is intended only for building mods, and generally you should not upload or send the Local folder, or files/folders intended to be put in the local folder to other users as a way of playing a finished product.

Mods Folder

The Mods Folder is a Special folder in your SM2 Directory designed specifically for mods. It is designed for the average user rather than the average mod creator, and intended to be an easy way to install finished and downloaded mods.

What goes into a Mods Folder?

Mods, specifically Mod.paks. The Mods folder will only load files that are formatted as PAK files. If a ZIP or RAR file makes its way into the folder, it will either be ignored or the game will attempt to load it but fail, and you may experience a broken game.

How does Mod Load order wok?

Mods are Loaded in Alphanumerical order. Meaning if mod_a and mod_b modify the same file, the game will use the modifications from mod_a, and if mod_a1 and mod_a modify the same file, the game will use the modifications from mod_a1.

Stuff to look out for

When naming a modpak it is heavily recommended that you keep all of your letters in the name of the modpak lowercase. Not doing so can sometimes result in loading issues and crashes.

Creating a Modpak

To create a Modpak start by building it in the Local Folder, if you do not know how to do that see Local Folder.

Once you have your mod built and tested, Highlight all of the folders in the Local Folder, and right click. Select the WinRar Option, and select "Add to Archive". From the WinRar menu, you need to select the archive format "ZIP", and change the compression type to "Store".

It is very important the the compression type is set to Store. Mod Paks cannot have any amount of compression or they will cause crashes, infinite loading, or they will just not load at all.

The name of a pak needs to be all lowercase, but can be whatever you want. It also NEEDS to be a ".pak". The Mods folder will only load files that are formatted as PAK files. If a ZIP or RAR file makes its way into the folder, it will either be ignored or the game will attempt to load it but fail, and you may experience a broken game.

Once you have paked your mod, it is ready to be placed into the Mods folder in your SM2 Directory. The file is also ready to be uploaded and sent to other users.

Local server

While playing with mods, the game will always force you into a private lobby. During this time, the game uses a Local Server running off of the host's computer instead of a server hosted by Saber. This method is called Peer-to-Peer (P2P).

How do mods work on a Local Server?

When you host a Local Server while playing modded, your mods get loaded onto the server, meaning in some cases, players who do not have mods installed on their device, or do not have the exact mods as you do on their device, including console players, will be able to experience the mods that you downloaded. However it is always a better idea to make sure all parties playing a modded game have the same mods installed to avoid any issues.

For a Guide on how to install mods, see How to Install Mods.