Modding

From Hammerwatch 2 Wiki
Revision as of 04:45, 6 September 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
    1. <dict>
    2. <string name="name">Mod Name Here</string>
    3. <string name="author">Your Name Here</string>
    4. <string name="description">Explanation of what the mod is/does.</string>
    5. </dict>
  10. Start making changes!
    1. Files with the same name as an existing file will take precedence and completely overwrite anything in the base file. You can copy folders or files directly from the unpacked_assets folder and make changes
    2. All .sval files are all read in when the game loads. You can use <loader> tags to merge additional data into existing and set load order
    3. .inc files are referenced with a %include in .sval files, but not automatically loaded

Troubleshooting

The game logs all events in "HW2.exe.log", in the root of the game folder. If something isn't working, check there first for errors about expected characters or missing files.

Documentation

Tutorials

Video Tutorial - Hammerwatch 2 Modding: NPCs, Quests, and Custom Crafting

Text Tutorial - How to create a custom 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. Replacement
    1. Download the HW2 TIFS ZIP
    2. Copy the tifs you need from the zip into your mods folder
  2. Convert with Adobe Photoshop (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)
  3. Convert with Image Magick (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"

Modifiers Array

All skills have a modifiers array denoted by <array name="modifiers"> ... </array> that is global across the skill. It's important to note that individual modifiers within this array are positional and modifiers added in skill specializations need to be moved to the next position in the array by using <array><null /></array> blocks for each existing modifier, otherwise the new modifiers will overwrite the modifier in the existing position. This is especially important to be aware of when copying code from other classes as the number or position of modifiers may be different.

Example: A dash skill has Modifiers::SkillTriggerEffect that creates a sprite. On dash, the sprite appears. Then in a skill specialization for dash, there is Modifiers::SkillCost that reduces the cost of dash. Putting a point in that specialization reduces the cost, but makes the base skill no longer create the sprite. If in the specialization code <array><null /></array> is placed before the block for the Modifiers::SkillCost, both now work correctly.

a little more info on the <null /> lines:

skills dont just have arrays of modifiers, they have arrays of arrays of modifiers, the reason is so you can have several sets of modifiers that individually get replaced by sub skills,

so you can have a skill that has three sets of modifiers, one that modifies some passive thing, one that modifies the projectile that gets shot, and one that modifies some bonus attack speed, then if you wanna make a sub-skill that replaces the attack speed modifiers you just define the modifiers as

<null />

<null />

<array>...</array>