Modding/Creating A Custom Class

From Hammerwatch 2 Wiki
Jump to navigation Jump to search

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>
      2. %include "players/yourclass.inc
      3. <array>
      4. %block yourclass
      5. </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. Repair or convert the .tif files Instructions
  10. Test - you should now be able to start a new save with the mod enabled and select your class

Creating Necromancer Summon Skeleton Skill

This tutorial assumes you have followed the steps above to copy the warlock class into a new mod named necromancer. Line numbers listed are approximations and may no longer be accurate, but should give a rough idea of where in the file to look.

Copy an existing skill to use as a starting point

First, we'll overwrite an existing skill on our custom class with a skill from a different class to use as a starting point to customize.

  1. Copy and rename the follow file from the unpacked ranger folder into the matching folder of your custom class folder:
    1. skills/ran_summon_wolf.sval -> skill/nec_summon_skeleton.sval
  2. Edit the fourth string of skill to be "nec_summon_skeleton.sval" instead of "war_claws.sval"
  3. Modify the necromancer nec_summon_skeleton.sval to be an apprentice skill
    1. On line 22, change the tier from adept to apprentice
    2. On line 23, change the starting level from 0 to 1
  4. Test - You should now be able to create a new game, select your necromancer mod, and spawn with the ability to summon a ranger wolf at level 1

Set up skeleton files

  1. Copy wolf.unit and wolf.inc from unpacked/players/ranger/units to necromancer/units and rename them to skeleton.unit and skeleton.inc
  2. Edit skeleton.unit to change "players/ranger/units/wolf.inc" to "players/necromancer/units/skeleton.inc"
  3. Update nec_summon_skeleton.sval
    1. Replace 2 instances of "players/ranger/units/wolf.unit" with "players/necromancer/units/skeleton.unit"
    2. Replace 5 instances of "wolf-unit" with "skeleton-unit"
    3. Replace 5 instances of "wolf-hp" with "skeleton-hp"
    4. Replace 5 instances of "wolf-dmg" with "skeleton-dmg"
  4. Update skeleton.inc
    1. Replace wolf-hp with skeleton-hp and wolf-dmg with skeleton-dmg
  5. Test - Everything should still be working to summon a wolf

Replace the wolf sprite with skeleton sprite

We'll be using unpacked/actors/undead/rotten/rotten_footman as our new sprite. Any references to rotten_footman mean this folder.

  1. Set up your sprite files
    1. Create a new folder "skeleton" in your necromancer/units folder
    2. Copy the three .png and three .tif files from rotten_footman to the new skeleton folder
    3. Rename these files from "rotten_footman" to "skeleton", leaving the rest after footman in place
    4. Repair or convert the .tif files Instructions
  2. Update skeleton.inc Best practice - Create a copy of skeleton.inc and name it skeleton.backup so you can easly revert back if something goes wrong
    1. Find <scenes start="idle-0 idle-1 idle-2 idle-3 idle-4 idle-5 idle-6 idle-7"> (line 227)
    2. Right after, replace the values of shadow.unit:18 with that from rotten_footman.inc shadow.unit.:14
    3. Replace the two circle tags within <collision static="false"> </collision> with those from rotten_footman.inc
    4. Replace the 8 <scene name="idle#"> sections with those from rotten_footman.inc
    5. Replace the 8 <scene name="walk#"> sections with section %defblock AnimWalk XCOORD through the 8 walk scenes from rotten_footman.inc
    6. Replace the 8 <scene name="attack#"> sections with section %defblock AnimMelee XCOORD through the 8 melee scenes from rotten_footman.inc
    7. Replace all 8 instances of "melee-" with "attack-" to match the original wolf scene names
    8. Replace all 10 instances of "default.mats:enemy" with "default.mats:player" to match the original wolf settings
    9. Replace all 10 instances of "rotten_footman/rotten_footman" with "skeleton_skeleton" to point to the tif files in your folder
    10. Remove <scene name="jump-0"> (lines 457) through the final </scene> (line 625). The jump and howl animations do not exist for the skeleton

Customizing the base skill

These changes will all be made in nec_summon_skeleton.sval

  1. Change the cooldown
    1. Cooldown values are shown in milliseconds. Divide by 1000 to get the value in seconds
    2. Change the int cooldown value (line 31) from 30000 to 5000 to swap it from 30s to 5s
  2. Increase the base maximum summoned and allow it to scale with skill levels
    1. On like 52, there's an array block commented out (shown by the tags around it) that contains a dict with ModifySummons, the skeleton.unit, and add-max-num 2
    2. Copy this block, including the array and dict tags, into each dict of the "upgrades" array (line 129)
      1. Each of these dicts represents an upgrade of the base skill overwriting the default information. The skill has 5 total levels, so there are 4 upgrades dicts.
      2. It should go after the </dict> that closes <dict name="binds"> but before the </dict> that closes the overall upgrade
    3. Change the first two values of add-max-num from 2 to 1
  3. Decrease the health and damage of the skeletons to compensate for it being an apprentice skill and a higher number of minions summoned
    1. In the skill dict binds (line 43), change the skeleton-hp and skeleton-dmg values to half their current value
    2. In each of the upgrade dics (line 130), change the skeleton-hp and skeleton-dmg values to half their current value
  4. Update the skill information page
    1. In the name string (line 2), replace ".skills.ranger.adept.spell_2.name" with a new name "Summon Skeletons"
      1. The existing value here with strings seperated by a . is referencing strings in a language file to allow for translations to other languages. For this tutorial, we assume the new class is only going to support a single langauge and will be writing the strings directly into the files.
    2. In the description string (line 4), replace ".skills.ranger.adept.spell_2_desc" with a new description to use. "Summon an army of skeletons to fight for and procect you."
    3. In the description params array:
      1. Replace the .skill.desc.params.wolf. strings with new strings "Skeleton Damage" "Skeleton Damage Per Level" and "Skeleton Health"
      2. Replace the values of the damage and health with the new values set above
    4. In the "description-params" array at the top of the file, add a new line to display the new effect of upgrades on max summons
      1. <array><s>max-skeletons</s><b>t</b><s>Max Skeletons</s><s>1</s><s>2</s><s>2</s><s>3</s><s>3</s></array>

Customizing the skill modifiers

In development