Framework for Emote Mods
First off, if you are a mod user and not a mod author, you've made a wrong turn. This page isn't for you. Begone, user!
Framework for Emote Mods will let you add more emotes for NPCs and players to be able to use in your events (or anywhere else that allows emoting). To be clear, this refers to the little thought bubble ish animation that you can make appear above a characters head with the Emote event command. This framework will not allow you to make the kinds of emotes that players can use in multiplayer to communicate with their friends. While you can already extend the emote spritesheet using Content Patcher alone to add custom emotes, doing so can very easily lead to incompatibility issues with any other mod adding emotes. Framework for Emote Mods allows you to add custom emotes in a compatibility-friendly way with a lot more customizability.
If needed, an example content pack is available on the NexusMods page.
Emotion Data
In order to define a custom emote, you will want to do an edit targeting
Spiderbuttons.FEM/Emotes, which is a string to EmotionData dictionary.? The model
is described below:
| FIELD | PURPOSE |
|---|---|
| Id | The string Id of this emote. This should be globally unique, so using the {{ModId}}
Content Patcher token is highly recommended. |
| Texture | The asset name corresponding to the texture that this emote will use. This texture does not need to be the same resolution as the vanilla emote texture, nor does it need to have only four frames per emote like the vanilla texture. |
| SpriteIndex | (Optional) The index of this emote on the Texture defined above. Unlike vanilla emotes, custom emotes are indexed sequentially, where the first row of emotes is index 0, the second row is index 1, the third row is index 2, and so on. Default 0 |
| FrameWidth | (Optional) An integer defining how many pixels wide each frame of this emote is. Custom emotes can be any resolution, so you are not limited to 16 pixels wide for each frame. Default 16 |
| FrameHeight | (Optional) An integer defining how many pixels tall each frame of this emote is. Custom emotes can be any resolution, so you are not limited to 16 pixels tall for each frame. Default FrameWidth |
| MillisecondsPerFrame | (Optional) An integer defining how many milliseconds to display each frame of this emote for. Default 250 |
| Loops | (Optional) An integer defining how many times this emote should loop before shrinking away. Default 1 |
| PositionOffset | (Optional) A Vector2 defining how many pixels to offset this emote from the default position above the character's head. Positive X moves the emote right, positive Y moves the emote down. Default { "X": 0, "Y": 0 } |
| OpeningTexture | (Optional) The asset name corresponding to the texture that this emote should use for the opening animation[1] when the thought bubble is still appearing. If not set, the vanilla opening animation will be used. If your custom emote has a resolution higher than the vanilla 16 x 16 or your emote uses more than four frames, you must set a custom opening texture with a matching resolution and/or frame count. See Opening Texture. Default null |
| ShowOpeningAnimation | (Optional) A bool that defines whether or not your custom emote will show the opening animation at all. If set to true, then an opening animation will display. If set to false, then the emote will start from the first frame of your emote without playing the usual opening animation. Default true |
| ShowClosingAnimation | (Optional) A bool that defines whether or not your custom emote will show the closing animation at all. If set to true, then a closing animation[1] will display once your emote ends. If set to false, then the emote will disappear immediately after displaying the last frame without playing the usual closing animation.[1] Default true |
[1] The closing animation is the opening animation played in reverse.
Every emote added to Spiderbuttons.FEM/Emotes will be available to use in the vanilla Emote event command as well as in the trigger action action and map actions that this mod provides.
For the event command, if you use an integer for the emote, then control is passed to the usual vanilla behaviour and nothing will be different. If instead of using an integer you use a string, and that string matches the Id of a custom emote, then Framework for Emote Mods will handle the event command. For the custom trigger action and map actions, integer Ids corresponding to vanilla emotes and string Ids corresponding to custom emotes are both supported.
Texture Layout
The texture you use for your custom emotes will follow the same general format as the vanilla emotes found in TileSheets/emotes. Each row will contain one emote and each emote must only be contained in one row. However, unlike vanilla emotes, each entire row counts as one index when it comes to the SpriteIndex, meaning you should not count in fours and should instead start at 0 and add 1 for each row down on your emote texture.
Additionally, vanilla emotes are limited to being four frames long, but your custom emote texture does not need to follow this same limitation; your texture can be as wide as you want and the number of frames will be calculated by dividing the width of your texture by the FrameWidth defined in your EmotionData. It is important to note, though, that since the number of frames cannot be set per individual emote, every emote that uses the same texture must have the same number of frames. If you want different emotes to have different frame counts, they must use different textures.
Opening Textures
Each emote can define an OpeningTexture which will be used for displaying the opening and closing animations of an emote—vanilla will play the opening animation in reverse for the closing animation, and this framework does the same. In the vanilla emote spritesheet, this opening texture is the first row and is shared by every emote. It works similarly with a custom opening texture: whatever asset name you provide will be loaded and the first row will be used for the frames of the opening animation of your custom emote.
If you are making 16 x 16 emotes that have four frames and use the same thought bubble as vanilla, then you don't need to define an opening texture; this framework will use the vanilla asset and then switch to your custom emote texture after the opening animation. However, if your custom emote is a different size or has a different number of frames, then you must set a custom opening texture for your emote to use. The easiest way to do this would be to dedicate the first row of your custom emote texture to your custom opening animation frames and then adjust the SpriteIndex of any emote as needed. Then, every emote on that texture can define that same texture as both its Texture and OpeningTexture.
If ShowOpeningAnimation and ShowClosingAnimation are both set to false, then you don't need to worry about the OpeningTexture at all, even if you are creating an emote with a different resolution or frame count.
Emote Resolution
Framework for Emote Mods supports higher resolution emote textures, meaning you are not limited to your emotes being 16 x 16 pixels per frame. Any emote with a higher resolution will still be displayed to the user at the same size on the screen, but will appear to be more HD. However, it is important to keep in mind that there is an upper limit to what is considered a safe maximum size for a texture and that is generally 4096 x 4096 pixels. If your texture is larger than 4096 pixels on either axis, it may not work correctly on some players' hardware.
This does leave you with a maximum of 256 frames for a 16 x 16 emote or 4 frames for a 1024 x 1024 emote, though, so you really shouldn't need more than that, I'd hope...
Emotes are also not restricted to being perfectly square. You are more than welcome to define an emote that is 16 pixels wide but 32 pixels tall, for example, so long as you define your FrameWidth and FrameHeight correctly. Emotes are assumed to be square unless told otherwise.
As previously mentioned, if you do opt to use an emote with a resolution other than 16 x 16, you must set a custom OpeningTexture if either ShowOpeningAnimation or ShowClosingAnimation are set to true.
Actions
Framework for Emote Mods adds the following action, which is registered as a trigger action action, a touch action, and a tile action:
| ACTION | DESCRIPTION |
|---|---|
Spiderbuttons.FEM[<Character]>+ [<EmoteId]>+ | Display the emote with a matching EmoteId above the head of the given Character. If Character is set to Farmer, then the emote will play over the current player's head, otherwise it will search for an NPC whose internal name matches Character to perform the emote. |
If you encounter any issues with using this mod, feel free to ping me @spiderbuttons in the Stardew Valley
Discord in the #making-mods-general channel.
Please do not DM me! Just ping me in the channel.