File information

Last updated

Original upload

Created by

aedenthorn

Uploaded by

aedenthorn

Virus scan

Safe to use

Tags for this mod

About this mod

Lets modders add particle emissions to farmers, NPCs, objects, and game locations.

Requirements
Permissions and credits
Changelogs
Donations
This framework uses Content Patcher to designate custom particle effects to:

  • farmers wearing specific equipment or wielding specific tools / weapons
  • specific-named NPCs
  • specific-named objects
  • specific coordinates on a named game location

Since Content Patcher allows for its own customization, the above can be more finely-tuned to, e.g. time, day, season, etc.


Creating Particle Effects
Content Patcher syntax should be something like:

        {
            "Action": "EditData",
            "Target": "Mods/aedenthorn.ParticleEffects/dict",
            "Entries": {
                "aedenthorn.CPParticleEffects/heartCat": {
                    "type":"object",
                    "name":"Statue Of Endless Fortune",
                    "movementType":"random",
                    "movementSpeed": 1,
                    "frameSpeed": 0.05,
                    "acceleration":0,
                    "minRotationRate":0.05,
                    "maxRotationRate":0.05,
                    "particleWidth":11,
                    "particleHeight":10,
                    "fieldOuterWidth": 128,
                    "fieldOuterHeight":256,
                    "fieldOffsetY": -32,
                    "belowOffset": 0.001,
                    "aboveOffset": 0.001,
                    "minParticleScale": 2,
                    "maxParticleScale": 2,
                    "particleChance": 0.1,
                    "maxParticles": 20,
                    "minLifespan": 80,
                    "maxLifespan": 160,
                    "spriteSheetPath": "Mods/aedenthorn.ParticleEffects/heart",
                }
            }
        },
        {
            "Action": "Load",
            "Target": "Mods/aedenthorn.ParticleEffects/heart",
            "FromFile": "assets/heart.png"
        }


Don't change "Target", that's the mod's dictionary path.

The entry key must be unique.

Value fields:

  • type: the type of thing to target; one of "object", "npc", "location", "hat", "shirt", "boots", "pants", "tool", "ring"
  • name: the name or id of the specific thing of type to target
  • movementType: how particles move; one of "none", "away", "towards", "up", "down", "left", "right", "random"
  • movementSpeed: how many pixels a particle moves per tick
  • acceleration: how many pixels / tick the movement speed increases per tick
  • frameSpeed: how many animation frames change per tick (see textures below)
  • restrictOuter: whether particles disappear when they move outside the field (default false)
  • restrictInner: whether particles disappear when they move inside the inner boundary (default false)
  • belowOffset: if set to > 0, allows particles to move behind the thing by the given layer depth offset (default -1
  • aboveOffset: if set to > 0, allows particles to move in front of the thing by the given layer depth offset (default 0.001)
  • minRotationRate: if set to > 0, allows particles to rotate around their center
  • maxRotationRate: if set to > 0, allows particles to rotate around their center
  • minAlpha: allows transparency (default: 1)
  • maxAlpha: allows transparency (default: 1)
  • particleWidth: the width of each particle on the sprite sheet (see textures below)
  • particleHeight: the height of each particle on the sprite sheet (see textures below)
  • fieldOuterRadius: if set to > 0, specifies a circular particle spawn field and sets the outer radius of the field
  • fieldInnerRadius: if set to > 0, sets the inner radius of the field
  • fieldOuterWidth: if fieldOuterRadius is set to 0, designates the outer width of the rectangular particle field
  • fieldOuterHeight: if fieldOuterRadius is set to 0, designates the outer height of the rectangular particle field
  • fieldInnerWidth: if set to > 0, sets the inner width of the rectangular particle field
  • fieldInnerHeight: if set to > 0, sets the inner height of the rectangular particle field
  • fieldOffsetX: for locations, specifies the X coordinate of the field center on the map; for everything else, specifies the field X offset from the thing's center
  • fieldOffsetY: for locations, specifies the Y coordinate of the field center on the map; for everything else, specifies the field Y offset from the thing's center
  • maxParticles: sets the maximum number of simultaneous particles in a field
  • minLifespan: minimum number of ticks a particle lives
  • maxLifespan: maximum number of ticks a particle lives
  • minParticleScale: minimum scale of each particle in the field
  • maxParticleScale: maximum scale of each particle in the field
  • particleChance: the chance (0 to 1) that a new particle will be created, checked each tick
  • spriteSheetPath: the fake path to this particle's spritesheet, caught by your Content Patcher pack (as in the example above).


Textures

Your sprite sheets should be created with frames horizontally and alternatives vertically.

So, say your particles are 3x3 pixels each, each particle has ten frames, and there are five alternative sprites to choose from for each particle, then your sprite sheet texture should be 30x15 pixels in size: ten frames across x five alternatives down.

The mod will choose an alternative randomly for each particle if there are multiple alternatives.


API

There is a SMAPI API you can use in other SMAPI mods. The methods you can access are:

        public void BeginFarmerParticleEffect(long farmerID, string key);
        public void EndFarmerParticleEffect(long farmerID, string key);
        public void BeginNPCParticleEffect(string npc, string key);
        public void EndNPCParticleEffect(string npc, string key);
        public void BeginLocationParticleEffect(string location, int x, int y, string key);
        public void EndLocationParticleEffect(string location, int x, int y, string key);
        public List<string> GetEffectNames();

x and y are pixel positions on the map.


Notes

There's an example pack in the files section.


Technical

Requires SMAPI, uses Harmony.

Compatible with Mod Updater for automatic updates.

Code is at https://github.com/aedenthorn/StardewValleyMods.

If you want to complain or ask for help or help me test my mods, you can visit my Discord server.

A list of all my mods for Stardew Valley is available at https://www.nexusmods.com/stardewvalley/articles/895.