Mod Distribution

From Battletech Modding Wiki
Jump to: navigation, search

Overview

The current state of Mod Distribution is that you need to roll your own installer. The good new is that there are now editors that can make it easier to create a user friendly installer of your mod. In the future wiki versions we will hopefully get separate entries for modding and for user distribution of mods. There is currently too much information on the page about editing instead of distribution of mods.

Battletech Mod Loader/ModTek Editor

For editing there is ModTek, while it can be used for Mod Distribution ModTek only supports editing and not useful for mod distribution.

Mod Distribution

There is currently no easy method to distribute ModTek with you Battletech mod. You need to create your own installer see, "rolling your own installer" on how to create an installer.

About ModTek

Battletech Mod Loader (BTML) is a mod loader that hooks into the Unity engine and allows you to run arbitrary code.

ModTek is a BTML mod that provides a simple format for creating other BTML mods. A big advantage of BTML/ModTek is that they handle patching the VersionManifest.csv for you, so you can spend less time dealing with that and more time focusing on the important parts of your mod.

ModTek mods that only change existing json

A ModTek mod that only changes existing game json is very simple:

  1. A directory containing the mod
  2. inside that directory, a mod.json file containing the mod's name. This can be as simple as { "Name": "SimpleModTekMod" }
  3. inside that directory, a StreamingAssets/data directory.
  4. inside the data directory, one or more directories corresponding to directories in the game, containing json files that match files in the game. Each file should contain any lines of json that need to be changed. For instance, to change the starting player battlemech, there would need to be a file StreamingAssets/data/simGameConstants/SimGameConstants.json containing {"Story" : {"StartingPlayerMech" : "mechdef_shadowhawk_SHD-2D" }}

ModTek and BTML will handle everything else, such as patching the change into the game's json.

ModTek mods that add new json

A ModTek that adds an entirely new json file is not much more complicated. In addition to the files above, it would need:

  1. a directory inside the mod's directory containing the new json, such as mymechdefs
  2. a manifest entry in the mod.json file "Manifest" = { "Type": "MechDef", "Path": "mymechdefs" }

Again, ModTek and BTML will handle everything else, including adding the new files to the VersionManifest.csv.

ModTek mods that add new code

ModTek supports adding code to Battletech. This is slightly more complicated, and documented here.

Rolling Your Own Installer

If you want casual Battletech users to actually play your mod, you must create your own installer app that can be used for distribution on windows (for instance InnoSetup), and a regular self extracting script can be used on any OS that is not windows. There are some alternative installers that might be more powerful such as https://www.pyinstaller.org/ that can be used to create an easy to use packager (unlike innoSetup).

In the current situation it might be of interest to create a javascript GUI on the web that makes it easier to roll your own installer to reduce the hassle to create the actual installer exe files. There are several helpful libraries for creating an install roller, for instance Tar-stream or JSZIP could be used to create a drag and drop javascript GUI to convert a tar archive or zip file into a compilable file for InnoSetup (or other installer).

We hope to have a few easy to use tools soon, at the moment you need to program all the manifest changes into your installer.

Example Using InnoSetup for Windows

Once you know what files you want to include install InnoSetup on your computer and write an install script. For instance if we use the example from the page Add Grand Dragon we have.

#define MyAppName "Battletech Grand Dragon Pack"
#define MyAppVersion "1.0"
#define MyAppPublisher "Creative Commons"
#define MyAppURL "http://btmodding.warriorsblood.com"

[Setup]
; NOTE: The value of AppId uniquely identifies this application.
; Do not use the same AppId value in installers for other applications.
; (To generate a new GUID, click Tools | Generate GUID inside the IDE.)
AppId={{1682A81B-DE05-4332-9F6D-F66C0B544CA8}
       AppName={#MyAppName}
       AppVersion={#MyAppVersion}
       ;AppVerName={#MyAppName} {#MyAppVersion}
       AppPublisher={#MyAppPublisher}
       AppPublisherURL={#MyAppURL}
       AppSupportURL={#MyAppURL}
       AppUpdatesURL={#MyAppURL}
       DefaultDirName=C:\Program Files (x86)\Steam\steamapps\common\BATTLETECH\BattleTech_Data\StreamingAssets\data
       DefaultGroupName={#MyAppName}
       AllowNoIcons=yes
       LicenseFile=
       OutputDir=C:\dev\battltech\grand_dragon\compiled
       OutputBaseFilename=mechpack
       Compression=lzma
       SolidCompression=yes
       
       [Languages]
       Name: "english"; MessagesFile: "compiler:Default.isl"
       
       [Files]
       ;
       ;Add all the files you want to include below
       ;
       Source: "C:\dev\battltech\grand_dragon\chassisdef_dragon_DRG-5K.json"; DestDir: "{app}\chassis"; Flags: ignoreversion
       Source: "C:\dev\battltech\grand_dragon\mechdef_dragon_DRG-5K.json"; DestDir: "{app}\mech"; Flags: ignoreversion
       Source: "C:\dev\battltech\grand_dragon\movedef_dragon_DRG-5K.json"; DestDir: "{app}\movement"; Flags: ignoreversion
       ; NOTE: Don't use "Flags: ignoreversion" on any shared system files
       
       [Icons]
       Name: "{group}\{cm:ProgramOnTheWeb,{#MyAppName}}"; Filename: "{#MyAppURL}"
      Name: "{group}\{cm:UninstallProgram,{#MyAppName}}"; Filename: "{uninstallexe}"
      
      
      [CODE]
      
      function GetCustomSetupExitCode: Integer;
      var
 filename: String;
 filenameB: String;
 lines : TArrayOfString;
begin
  fileName := ExpandConstant('{app}\VersionManifest.csv');
  fileNameB := ExpandConstant('{app}\VersionManifestOrigNoGrandDragon.csv');
  FileCopy(fileName,fileNameB,false);
  SetArrayLength(lines, 3);
  ;
  ;You need to add a row for every asset below. The values depend on the file types. Don't forget to adjust array size.
  ;
  lines[0] := 'chassisdef_dragon_DRG-5K,ChassisDef,data/chassis/chassisdef_dragon_DRG-5K.json,15,2018-02-27T00:45:27.7565230Z,2018-04-05T20:51:06.8057259Z,,,False,0,False';
  lines[1] := 'mechdef_dragon_DRG-5K,MechDef,data/mech/mechdef_dragon_DRG-5K.json,15,2018-02-27T00:45:28.4155235Z,2018-04-05T01:11:44.5915965Z,,,False,0,False';
  lines[2] := 'movedef_dragon_DRG-5K,MovementCapabilitiesDef,data/movement/movedef_dragon_DRG-5K.json,8,2018-02-27T00:45:28.5045251Z,2018-04-05T01:11:44.7155966Z,,,False,0,False';
  SaveStringsToFile(filename,lines,true);
  Result := 0;
end;

function UninstallNeedRestart(): Boolean;
var
  filename: String;
  filenameB: String;
begin
 fileName := ExpandConstant('{app}\VersionManifest.csv');
 fileNameB := ExpandConstant('{app}\VersionManifestOrigNoGrandDragon.csv');
 FileCopy(fileNameB,fileName,false);
 Result := False;
end;

The [FILES] Section should contain all included files that are going to be imported. Also the [CODE] sections need to be modified to include an entry for each included file. Furthermore it should pointed out that this installer lacks ability to add any data to the campaign. As a warning this particular installer is somewhat unstable if the game updates and uninstall is performed, tough reinstall and unsintall should work. It also lacks any warnings about install side effects. The installer currently breaks if multiple installers are used ontop of the original Battletech (easy to fix in the code, if someone has enough time).


Example Mod - New Pilot, New Pilot Icon and 2 new lances

Please Note this example was built against BETA 1. Changes in Skills etc may require you to modify the File some.

The following is an example mod with the structure for New content as described below to install it you would follow the steps listed.

  1. Download the zip file here: Btmoddingexample.zip
  2. Read the information in description.txt in the zip
    1. ModName: Robs Example Mod ModAuthor: Rob Graham ModDescription: This is an example mod showing a new pilot and 2 new lance def's.. Special Instructions: If you want the 'Catapult' lance to show up you will need to mod the Catapult's Cbill cost down some.
  3. Extract the StreamingAssets/ folder to your BATTLETECH/BattleTech_Data/ Folder so you have this:
    ExampleModFilestructure.png
  4. Add the contents of VersionManifestedits.csv to the bottom of your VersionManifest.csv file
  5. Run the game.

For End Users

Ask the mod maker to give you an installer to install the mod. Ensure you use virus software before installation and read the instruction. If the game Battletech breaks, deinstall all mods and reinstall the game.

If the mod maker has not created an installer, we suggest asking on the BattletechGame discord in the #game_mods directory or on the forums in the off topic beta/game discussions area.



Wiki Quick Nav: File Formats | Other Tweaks and Adjustments | Tools and Scripts | Troubleshooting | Style Guide


For Mod Makers

We recommend that mod makers try to create an installer (with source code available), if not we recommend the following

For mods that change existing files:

  • You WARN the user that such will happen! So they can back up the files if they need to!
  • That you create the mod from the view point of the 'Root StreamingAsset' folder for Battletech
    • this means for example if you where creating a pilot edit mod you would have in your zip:
<mod>VersionManifestEdits.csv       
description.txt
          <Folder> StreamingAssets
             |  <Folder>data
                      | <Folder> pilot
                            | mychangedpilot.json
       
  • That your 'VersionManifest.csv' file only contain the lines that need to be added by the end user.
  • That you include a description.txt file that has
    • ModName: Your Mod name
    • ModAuthor: Your name
    • ModDescription: A Description of your mod.
    • Special Instructions: If it requires Database edits.
  • If your mod needs Database edits we recommend at the moment that you include a SQL statement file with the required information.
  • That you use .zip file format.

For Mods that only add NEW content we recommend that

  • You create the mod with the view point that your mod will sit in a folder called "mods" in the /StreamingAssets/ folder
    • Make sure the folder is named mods as this follows HBS's syntax and prevents each modder from making a slightly different mod folders (Mod, MODS, Mods, MODDING, etc)
    • this means for example if you where creating a new Lance you would have this file structure in your zip:
<mod>VersionManifestEdits.csv       
description.txt
| <Folder> StreamingAssets
       | <Folder> mods
              | <Folder> <yourmodname>
                    | <Folder> Lance
                          | mynewLancedef.json

Then you would simply reference the data/mods/yourmodname/ in the ManifestEdits eg:

  • lancedef_arena_heavy_catapult,LanceDef,mods/robsLanceMod/lance/lancedef_arena_heavy_catapult.json,0,2017-05-17T08:26:05.0000000Z,2017-05-17T08:26:05.0000000Z,,,0

Wiki Quick Nav: File Formats | Other Tweaks and Adjustments | Tools and Scripts | Troubleshooting | Style Guide