Modding

From Hammerwatch 2 Wiki
Revision as of 17:12, 22 August 2023 by Lloyd (talk | contribs)
Jump to navigation Jump to search

Hammerwatch 2 has a robust system for modding, with a few different types of mods possible.

Resource mods

Scenarios

Languages

Getting Started

  1. Open the game's folder (e.g. C:\Program Files (x86)\Steam\steamapps\common\Hammerwatch 2)
  2. Run "PACKAGER.exe"
  3. Select "Resources" from the list
  4. Click the "Extract Base Resources" button at the top (icon is a cardboard box)
  5. Wait for the unpacking to finish (This will take a while). It may give an error, this can be ignored.
  6. When finished, it will create a new folder named "unpacked_assets_[number]" containing all of the base game files
  7. Create a new folder named "mods"
  8. Create a new folder in mods with the name of your mod (cannot have spaces).
  9. Create a file info.xml with the following information

<dict>

<string name="name">Mod Name Here</string>

<string name="author">Your Name Here</string>

<string name="description">Explanation of what the mod is/does.</string>

</dict>

  1. Copy files you want to modify with their existing folder structure to your mod folder
  2. Use the <loader> tag to add new files.

Creating a new class

  1. In your mod folder, create a new folder "players"
  2. Copy an existing class from the unpacked players folder into your mod players folder
    1. Rename the baseclass folder and the baseclass.unit file within to your new class name
  3. Create a new file in players named <yourclass>.inc
    1. Copy the baseclass section %defblock to %endblock from unpacked/players/classes.inc into <yourclass>.inc
    2. Replace the baseclass with yourclass on the first line %defblock
    3. Edit the id, name and description at the top of the file to your own text (remove the .item.info.tooltip.class. and .menu.class. text).
    4. Edit the unit field to be players/yourclass/yourclass.unit
    5. Replace the baseclass with yourclass for every line in the <array name="skills"> section
  4. Create a new file in player named "modded_classes.sval"
    1. Paste the following contents into the file, using yourclass name:
      1. <loader order="1">PlayerClass::LoadMultiple</loader>%include "players/yourclass.in<array>%block yourclass</array>
  5. Fix .tif files
  6. Test - you should now be able to start a new save with the mod enabled and select your class


Fixing .tif files

The unpackager tool does not create tif files in the correct format to use for the game. Any .tif files copied from the unpacked_assets folder to your mod folders will show as an empty or glitched texture in game, popup an error on loading, and record an ERR event in HW2.exe.log. This can be corrected with any of the following methods

  1. Adobe Photoshop (Best - maintains masking to allow recoloring sprites)
    1. Photoshop has an option to convert tif files from standard (RGBRGB) to planar (RRGGBB) that the game expects. (Need more details on steps to perform)
  2. Image Magick Conversion (masking is lost and sprites can no longer be recolored)
    1. Open powershell and navigate to your class folder: "cd \Steam\steamapps\common\Hammerwatch 2\mods\yourmod\players\yourclass"
    2. Convert all of the png files into tif with planar interlacing using the command "magick mogrify -format tif -interlace plane *.png"