Modding

From Hammerwatch 2 Wiki
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. Copy files you want to modify with their existing folder structure to your mod folder
  11. Use the <loader> tag to add new files. (Need More Details on this process)

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. Create new starting items for your class
    1. Create the folder structure tweak/items/equipment in your mod folder
    2. Create a new file equipment_start_yourclass.inc in the equipment folder
    3. Copy the starting equipment <dict> blocks from unpacked/tweak/items/equipment_start.inc into equipment_start_yourclass.inc
    4. Edit the id and req-class strings to replace baseclass with yourclass for mainhand and offhand weapons. Do not replace baseclass in strings in modifiers
    5. Edit the names of the items to a text string (e.g. Dull Sword)
  6. Set up a loader for your new items
    1. Create a new file equipment_unique_yourclass.sval in the tweak/items/equipment folder
    2. Add the following to equipment_unique_yourclass.sval (based on the default equipment_unique.sval file)
      1. <loader order="-1">Equipment::UniqueEquipment::LoadMultiple</loader>
      2. <array>
      3. %include "tweak/items/equipment/equipment_start_yourclass.inc"
      4. </array>
  7. Set your class to spawn with their starting items
    1. Create a new file "starting_items_yourclass.sval" in the players folder
    2. Add the following to the file
      1. %include "tweak/loot/defines.inc"
      2. <loader>Item::LootTable::LoadMultiple</loader>
      3. <array></array>
    3. Copy the <dict> block of the class you copied from unpacked/players/starting_items.sval into starting_items_yourclass.sval between the array tags
    4. Rename the three instances of baseclass to yourclass within the <dict> block
    5. In yourclass.inc, update the "starting-items" string to use the id start_items_yourclass
  8. Set the class items for your class (Incomplete Work In Progress)
    1. Copy the file tweak/items/equipment/equipment_class_baseclass.sval to your tweak/item/equipment folder and rename baseclass to yourclass
    2. In equipment_class_yourclass.sval:
      1. Replace all [defaultWeapon]Tags with [yourWeapon]Tags (e.g. DaggerTags becomes ScytheTags) for main and offhand weapons
      2. Replace the baseclass with yourclass in the two renamed defblocks for Tags at the top of the file
      3. Replace all req-class">baseclass< with req-class"yourclass<
      4. Replace all default "weapon_" with "yourweapon_" (e.g. dagger_ becomes scythe_) for main and off hand weapons.
      5. Replace all ".equipment.baseclass.mainhand." and ".equipment.baseclass.offhand." with "YourWeapon "
    3. To be continued
  9. Fix .tif files
  10. 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"