Skip to content

Instantly share code, notes, and snippets.

@Silverfeelin
Last active October 9, 2022 08:06
Show Gist options
  • Save Silverfeelin/8ab21efd3317c519aa5b672a271059a6 to your computer and use it in GitHub Desktop.
Save Silverfeelin/8ab21efd3317c519aa5b672a271059a6 to your computer and use it in GitHub Desktop.
Creating a skin mod for A Hat in Time

AHIT - Your First Skin Mod

Creating a skin mod for A Hat in Time

This guide assumes you have the AHIT modding tools set up. Both the game and the modding tool should be up-to-date.

As skin mods require scripting, we do not need to use the editor. Only if you want to add a custom skin icon, you will need to use the editor for that purpose.
We will be using the modding tools to compile and cook the scripts necessary to create the skin mod.

Quick Access

Important Locations

When the guide refers to a folder, here's where to find them.

Mod Folder \HatinTime\HatinTimeGame\Mods
Classes Folder \HatinTime\HatinTimeGame\Mods\<yourmod>\Classes
Contents Folder \HatinTime\HatinTimeGame\Mods\<yourmod>\Content
Localization Folder \HatinTime\HatinTimeGame\Mods\<yourmod>\Localization\INT

<yourmod> Represents the mod folder containing your mod files.

In 1. Creating a Mod, you choose this when entering the Mod Folder, and you can go to the folder by pressing Browse.

File Extensions

Whenever the guide tells you to make a text file, it will end with a file extension (I.e. .uc). Make sure the actual file extension matches what's written (so not MyFile.uc.txt!).

You can confirm this by showing file extensions in your file explorer. View -> File name extensions

Video Tutorials

MekuCube has made a couple of useful modding tutorials for us and posted them on YouTube. I highly suggest viewing them, as parts of this guide are heavily based on the videos!

Tutorial Link
Creating Dyes https://www.youtube.com/watch?v=19FMpNtN0pw
Assets & Localization https://www.youtube.com/watch?v=me8ARBf6wHU

Back to Top

1. Creating a mod

  • Open the modding tools.
  • Press New Mod.
    • If you already have a mod named NewMod, rename it first or move it out of your mod folder temporarily.
  • Change the info in the Basic Info section and press Save Changes.

Back to Top

2. Setting up the skin

  • In your mod folder, create a new folder Classes.
    • You can open the mod folder by pressing Browse in the modding tool.
  • Create a new text file with a unique name for your skin.
    • I.e. Hat_Collectible_Skin_Oreo.uc.
    • To prevent naming conflicts with other mods, you may want to go for something even more unique (I.e. Hat_Collectible_Skin_Silver_Oreo.uc).
    • It doesn't matter where you put this file, as long as it's in Classes or a subfolder inside Classes. The vanilla skins are usually in Classes/Collectibles/Skins.
  • Open the created text file in a text editor.
  • Paste the following code in the file:
class CLASS_NAME extends Hat_Collectible_Skin;

defaultproperties
{
	HUDIcon = Texture2D'TEXTURE_PATH'
	ItemName = "LOCALIZATION_KEY"
	ItemQuality = class'Hat_ItemQuality_Legendary'

	SkinColor[SkinColor_Dress] = (R=0, G=0,B=0)
	SkinColor[SkinColor_Cape] = (R=0, G=0,B=0)
	SkinColor[SkinColor_Pants] = (R=0, G=0,B=0)
	SkinColor[SkinColor_Shoes] = (R=0, G=0,B=0)
	SkinColor[SkinColor_ShoesBottom] = (R=0, G=0,B=0)
	SkinColor[SkinColor_Zipper] = (R=0, G=0,B=0)
	SkinColor[SkinColor_Hair] = (R=0, G=0,B=0)
	SkinColor[SkinColor_Orange] = (R=0, G=0,B=0)
	SkinColor[SkinColor_Hat] = (R=0, G=0,B=0)
	SkinColor[SkinColor_HatAlt] = (R=0, G=0,B=0)
	SkinColor[SkinColor_HatBand] = (R=0, G=0,B=0)
}
  • Replacing the following data in the code:
Key Value
CLASS_NAME The name of this file, but without the .uc extension.
I.e. Hat_Collectible_Skin_Oreo.
TEXTURE_PATH Path to the skin icon. See Icon.
LOCALIZATION_KEY A localization key that is used to later name your skin. See Localization.
I.e. OreoSkinName.
Hat_ItemQuality_Legendary You can change this to give the skin a different rarity.
Known values are listed in Rarities.

If you want to use a custom icon, please read Icon carefully now,

  • Set the colors for each part of the skin by changing the R, G and B numbers. If you don't want to set a color for a part, just remove the entire line for that part.
    • Not sure which values to use? I released a mod that allows you to try out different values directly in the game using console commands! View SetColor Command on Steam.
    • When using (R=0,G=0,B=0), the color will not be applied. If you want to use this color, you should use (R=1,G=1,B=1) instead.
  • Save the file.

At this point, your skin is ready. After compiling and cooking your mod, you can spend tokens in-game to obtain the item. A later section will show how to automatically unlock the skin.

For multiple skins, just repeat this step using different file and class names.

Example:

Icon

When replacing TEXTURE_PATH, you can use one of the existing textures, or add your own. These are the brush icons available in the game:

TEXTURE_PATH
HatInTime_Hud_ItemIcons.PaintBrushes.paint_green_orange
HatInTime_Hud_ItemIcons.PaintBrushes.paint_lightblue_lightred
HatInTime_Hud_ItemIcons.PaintBrushes.paint_pink_yellow
HatInTime_Hud_ItemIcons.PaintBrushes.paint_white_red
HatInTime_Hud_ItemIcons.PaintBrushes.Paintbrush_black
HatInTime_Hud_ItemIcons.PaintBrushes.Paintbrush_blue_white
HatInTime_Hud_ItemIcons.PaintBrushes.Paintbrush_blue_yellow
HatInTime_Hud_ItemIcons.PaintBrushes.Paintbrush_green
HatInTime_Hud_ItemIcons.PaintBrushes.Paintbrush_Green_Cream
HatInTime_Hud_ItemIcons.PaintBrushes.Paintbrush_pink
HatInTime_Hud_ItemIcons.PaintBrushes.Paintbrush_purple_yellow
HatInTime_Hud_ItemIcons.PaintBrushes.Paintbrush_red_black
HatInTime_Hud_ItemIcons.PaintBrushes.Paintbrush_Red_Purple

For a custom icon, use the following: MODNAME_Content.Textures.PAINT_TEXTURE

Replace MODNAME with your mod name (I.e. OreoSkin), and PAINT_TEXTURE with your texture name (I.e. Paint_Oreo). At this point you don't have the actual asset that's used here.

Complete 2. Setting up the skin and come back to this section when you're done.

  • Open the Editor and press away the warnings.
  • In the Content Explorer, press Import and select your image file.
    • The dimensions of your image file should be a factor of 2. 256x256 or 512x512 are recommended.

  • In the Info section, you will have to enter values matching the string TEXTURE_PATH in the skin. We do it in this order so that you don't have to restart the editor first (and it can prevent a crash).
Key Value
Package MODNAME_Content, where MODNAME is what you changed (I.e. OreoSkin).
Grouping Textures
Name The value you used for PAINT_TEXTURE earlier.

  • You can check Alpha to Opacity if your image supports transparency.
  • Press OK.
  • Select your package under NewPackages.
  • Right click and save the package.
    • Put the package in your mod Contents folder but keep the file name the same.
    • After doing this, the package will move from NewPackages to HatinTimeGame/Mods/yourmod/Content in the Content Browser.
  • If not greyed out, press Fully Load when right clicking your saved package.

  • Just to be sure everything is set up correctly, right click the image in your package and press Copy Full Name to Clipboard. Paste this text somewhere and see if it matches what you entered in your skin class.
    • I.e. HUDIcon = Texture2D'OreoSkin_Content.Textures.Paint_Oreo'

Qualities

Rarity Code Preview
Common Hat_ItemQuality
Rare* Hat_ItemQuality_Rare
Epic** Hat_ItemQuality_Epic
Legendary*** Hat_ItemQuality_Legendary
Completionist Hat_ItemQuality_Completionist
Gold Hat_ItemQuality_Gold
Supporter Hat_ItemQuality_Supporter

Common seems to stop you from equipping the skin! Please use another quality.

Back to Top

3. Unlocking the Skin

To unlock the skin by default (that is, when the mod is loaded), we're going to have to add a new script.

  • In the Classes folder, create a new text file with a unique name.
    • I.e. OreoSkinMod.uc.
  • Open the created file in a text editor.
  • Paste the following code in the file:
class CLASS_NAME extends GameMod
	config(Mods);

event OnModLoaded()
{
  HookActorSpawn(class'Hat_Player', 'Hat_Player');
}

event OnHookedActorSpawn(Object NewActor, Name Identifier)
{
  if (Identifier == 'Hat_Player')
  {
    Hat_PlayerController(GetALocalPlayerController()).GetLoadout().AddBackpack(class'Hat_Loadout'.static.MakeLoadoutItem(class'SKIN_NAME'), true);
  }
}

event OnModUnloaded()
{
  Hat_PlayerController(GetALocalPlayerController()).GetLoadout().RemoveBackpack(class'Hat_Loadout'.static.MakeLoadoutItem(class'SKIN_NAME', class'Hat_CosmeticItemQualityInfo_SearchAny'));
}
  • Replacing the following data in the code:
Key Value
CLASS_NAME The name of this file, but without the .uc extension.
I.e. OreoSkinMod.
SKIN_NAME Your CLASS_NAME of the skin.
I.e. Hat_Collectible_Skin_Oreo. Note that there are two places where you have to enter this value!
true At the end of the first long line that adds the item, replace true with false if you don't want to automatically equip the skin when the mod loads.

If you have multiple skins, copy the two long lines of code that adds the item to your backpack, and change the class name of the skin to unlock.

Back to Top

4. Localization

To give the skin a proper name, we must define it in a localization file.

  • Create the localization folders to form the following folder structure: <yourmod>\Localization\INT.
  • In the INT folder, create a text file collectibles.int.
  • Open the created text file in a text editor.
  • Paste the following code in the file:
[skins]
LOCALIZATION_KEY = Oreo Skin
  • Replacing the following data in the code:
Key Value
LOCALIZATION_KEY The key used to identify the item name. This value should match the one set in the skin class at ItemName.
I.e. OreoSkinName.
Oreo Skin The visible skin name.
  • Save the file.

If you have multiple skins, just copy the second line and change the key and text.

Back to Top

5. Building the Mod

Now that everything is ready, all that's left is building the mod. Make sure you've saved all the files you changed beforehand.

To ensure your mod class (that gives the skin) is set properly first do this:

  • Close the modding tool.
  • Open the modinfo.ini file in your mod folder with a text editor.
  • If modclass=MOD_CLASS is not present, add this line to the bottom of the file.
  • Save the file.

Then:

  • Go back to the modding tool.
  • In the mod info, go to Scripting.
  • Press Refresh.
  • For the Main Mod Class, select the class you created for unlocking the skin (I.e. OreoSkinMod).
  • Press Compile Scripts and wait for the process to finish.
    • The terminal may show some warnings, but will end with "Success - 0 error(s)". You can now close this terminal and go back to the mod info.
  • Go to Publish and press Cook Mod. This will take a while (1 to 3 minutes).
    • If the option is locked, press Refresh again.
    • Again, when it's done it should say Success. The warnings shouldn't matter. Don't worry if it seems stuck at first, it will display something eventually.

Your mod is now fully built and ready for testing! Open the game, create or load a save and see if you have access to the skin.
If the skin isn't available, you most likely missed a step. If the skin is available but not equipped, it might be that another mod is changing the skin after your mod does so.

Back to Top

6. Releasing the Mod

If you're planning on making multiple skins, please consider merging them into one mod!

  • In the mod tool, go to Publish.
  • Under the button Submit to Steam Workshop, there will be a checklist of requirements before you can upload your mod.
Name Description
Cooked Mod If unchecked, please refer back to 5. Building the Mod.
Mod Title If unchecked, you still need to enter some mod information on the Info tab.
Mod Description See above.
Square Mod Icon With the mod tool closed, place a mod icon with equal dimensions in your mod folder named icon.png or icon.jpg. A 256x256 image will work, a 256x257 image will not.
In the modinfo.ini file, make sure the icon is set to your icon file name (I.e. icon = icon.png).
  • (Optional) Enter a message under Update Changelog. It doesn't have to be detailed, and is more relevant when updating the mod.
  • With everything checked, you can now submit your mod by pressing Submit to Steam Workshop.
    • It may take a couple of seconds before the program opens a command line interface that uploads the mod.

Releasing Updates

You can release updates just like you initially released the mod. Make sure that the tool is aware that the mod is released. In your mods folder, the file SteamWorkshop.ini contains all mods that are marked as released.

[FOLDER]
WorkshopId=MODID
TimeStamp=DATE

Back to Top

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment