Custom pets

From Heroes of Hammerwatch wiki
Revision as of 16:26, 29 September 2021 by Ziadoma (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

You can create custom pets inside you own mod. For more informationen about creating your own mod and the info.xml file Mod_base

File Structure

Modfilestructure.png

All of these files can be copied from the games files, after using the Packager. Note if you edit these files and remove the default content, it wont be in the game when you install your mod!

  • info.xml: Information about your own custom mod.
  • icons_pets.png: The icons displayed in the pet shop. This file needs to have the size of X² (32x32, 64x32, 64x64 ...).
  • your_pet.png: Sprites of the custom pet. This file needs to have the size of X².
  • your_pet.unit: Behaviour of the custom pet.
  • pets.sval: The available content of the pet shop.

Behaviour

The pet behaviour can be defined in the your_pet.unit file. There are two types of pets: walking and flying pets.

Behaviour type

Walking Flying
This line needs to be added before the behaviour.
<unit netsync="none" save="false">
<unit netsync="none" save="false" layer="50">
Afterwards the values of the behaviour can be modified.
	<behavior class="MiniPetWalking">
		<string name="anim-idle">idle 8</string>
		<string name="anim-walk">walk 8</string>
	
		<float name="speed">5.5</float>
		<float name="idle-speed">4</float>
		
		<int name="range-idle">50</int>
		<int name="range-min-idle">20</int>
		<int name="range-pickup">160</int>

		<int name="pickup-duration">5000</int>
		<int name="idle-duration">2000</int>

		<int name="idle-delay">100</int>
		<int name="pickup-delay">30</int>

		<int name="leash-range">180</int>
	</behavior>
	<behavior class="MiniPetFlying">
		<string name="anim-idle">idle 8</string>
		<string name="anim-walk">walk 8</string>
		
		<float name="speed">4.3</float>
		<float name="idle-speed">2.7</float>
		<float name="turn-speed">5</float>
		
		<int name="pickup-duration">5000</int>
		<int name="idle-duration">750</int>
		
		<int name="leash-range">300</int>
		<int name="range-idle">80</int>
		<int name="range-pickup">200</int>

		<float name="acceleration-duration">250</float>
		<float name="deceleration-duration">750</float>
		<float name="turn-speed-boost">50</float>
	</behavior>

Custom Sprites

The default your_pet.png has the following layout:

Pet sprite layout.png

  • All sprites are 24x24 pixels.
  • The first row are the idle animations for all 8 directions.
  • Below are 4 frames for each animation.
  • You can place your own sprites into this file.
  • The layout can be changed and is defined in your_pet.unit file.

Animations

After the behaviour the animations are defined in your_pet.unit. The first line defines the starting animations before the pet moves.

Idle Animation

<scenes start="idle-0 idle-1 idle-2 idle-3 idle-4 idle-5 idle-6 idle-7">

The texture will be the file with your sprites in it. In this example it isplayers/pets/your_pet.png. Inside the frame tag are the coordinates of the specific sprite for you animation. The first two numbers are the X/Y coordinates where the sprites start and the last two are the X/Y coordinates where the frame ends. This is a default idle animation.

<scene name="idle-0">
	<sprite origin="12 12" looping="true" texture="players/pets/your_pet.png" material="system/default.mats:default-noxray">
		<frame>0 0 24 24</frame>
	</sprite>
</scene>

Walking Animation

In the example of the default walking animation there are multiple frames. And the time attribute specifies how long the frame of the animation takes.

<scene name="walk-0">
	<sprite origin="12 12" looping="true" texture="players/pets/your_pet.png" material="system/default.mats:default-noxray">
		<frame time="80">0 24 24 24</frame>
		<frame time="80">0 48 24 24</frame>
		<frame time="80">0 72 24 24</frame>
		<frame time="80">0 96 24 24</frame>
	</sprite>
</scene>

After writing all 8 idle and walking animations you need to close the tags to finish the your_pet.unit file.

	</scenes>
</unit>

For example check the unpacked files.

Pet icons

  • Pet icons can be added to icons_pets.png.
  • The size of icons are 24x24 pixel.
  • The file pixels needs to be the power of 2 (p.e. 256x128).
  • If you want to keep the default icons, do not overwrite them.

Adding pets to the shop

To add pets to the pet shop inside the game you need to edit the pets.sval file. Do not delete the already given pets if you want to have them.

  • Cost of the pet can be changed.
  • Change the coordinates to your custom icon <int>100</int><vec4>0 0 24 24</vec4>
  • There can be multiple skins
  • This example has two skins: your_pet and your_pet2.
<dict>
	<string name="id">yourpet_id</string>
	<string name="name">your_pet</string>

	<int name="cost">25000</int>

	<array name="skins">
		<dict>
			<string name="name">your_pet</string>

			<string name="unit">players/pets/your_pet.unit</string>
			<array name="icon">
				<string>gui/icons_pets.png</string>
				<int>100</int><vec4>0 72 24 24</vec4>
			</array>
		</dict>
			
		<dict>
			<string name="name">your_pet2</string>

			<string name="unit">players/pets/your_pet2.unit</string>
			<array name="icon">
				<string>gui/icons_pets.png</string>
				<int>100</int><vec4>24 72 24 24</vec4>
			</array>
		</dict>
	</array>
</dict>